Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var rows is an array of arrays, representing the table that is returned from a query to the postgres database.
- rows[x] will return a row in the table.
- rows[x][y] will return a column of a row in the table (ex. title or mana or attack, etc.)
- the way i have set up my code is that the columns of a row are in this order:
- 0 - title
- 1 - mana
- 2 - attack
- 3 - health
- 4 - ability (i didnt really use this but i am lazy and dont want to change all my indexes)
- 5 - maintext
- 6 - flavortext
- 7 - type
- 8 - rarity
- 9 - class
- 10 - views (not used, didnt know if we wanted to actually implement this)
- 11 - imagepath
- i dont think i missed anything, but if you want to add data to display, add it to the END of the array. unless you want to change the drawing code a bit, don't change this order.
- at the beginning, all the paths (src) to the card images (except the user uploaded pic) are hard coded. all these paths are then stored an array called
- paths
- they are stored IN A VERY SPECIFIC ORDER. minion card templates are from index 6-15, spell card templates are from index 16-25, and they are ordered by class in this order:
- druid, hunter, mage, neutral, paladin, priest, rogue, shaman, warlock, warrior
- the script will create a canvas (area where you draw all the cards) that you can set the size of by editing the variables
- canvas.width = 1200;
- canvas.height = 1000;
- this is what they are set to right now, you will most likely have to increase the height. i allocated 400 pixels per card horizontally, and 500 pixels per card vertically. you can change these values by editing
- var hpxPerCard = 400;
- var vpxPerCard = 500;
- the position of all images are based off of these values.
- walkthrough of script:
- get user image through imagepath (index 11 of the row), resize to 214x214, and draw it. this dimension works pretty well for both the minion and spell cards.
- find the appropriate card template (what class, minion or spell) and draw it.
- draw all the other shit like the mana, health, text, etc.
- the flavor text is displayed right below the card in italics.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement