Note that there are some explanatory texts on larger screens.

plurals
  1. POKeeping track of game state for a Card Trading Game
    primarykey
    data
    text
    <p>I am building a card game. Let's say it's similar to Magic the Gathering, Hearthstone, etc.</p> <p>The problem I am trying to figure out is how to architect "auras" and how much damage each card takes.</p> <p>Right now I have a deck and I store card data as follows. I've made up names for the types of cards that will exist.</p> <pre><code>M.card = {} -- Minion cards have health and damage M.card[1].name = "Minion" M.card[1].hp = 1 M.deck[1].dmg = 1 -- Super Minions have more health and damage M.card[2].name = "Super Minion" M.card[2].hp = 4 M.card[2].dmg = 4 -- Spell cards have no health and damage. Instead they affect the health and damage of other cards. M.card[3].name = "Heal" M.card[3].details = "This card heals any character for +2 health" M.card[3].healthboost = 2 M.card[4].name = "Damage Boost" M.card[4].details = "This card gives + 1 damage to any other card for 1 turn" M.card[4].dmgboost = 1 -- Super damage boost gives more damage boost to other cards M.card[5].name = "Super Damage Boost" M.card[5].details = "This card gives +3 damage to any other card permanently" M.card[5].dmgboost = 3 </code></pre> <p>So when one card attacks another card, I need to keep track of the damage taken by both cards. I don't want to change the base stats of each card so I need to keep track of adjustments. </p> <p>I could do something like this</p> <pre><code>-- Super Minion takes 3 damage M.card[2].newHp = 1 -- or M.card[2].adjHp = -3 -- Not sure which is better. </code></pre> <p>During the battle I need to keep track of which auras are played. So for example if the Damage boost card is played. I need to give another card +1 damage for just one turn. </p> <p>Let's say that I am keep track of each turn number starting from 1.</p> <p>Should I do something like this</p> <pre><code>M.aura[1] = 4 -- ( aura 1 is card # 4) M.aura[1].target = 2 -- (this aura is applied to card 2) M.aura[1].expires = 5 -- (this aura expires on turn 5) M.aura[2] = 3 -- ( second active aura is heal, card #3 ) M.aura[2].target = 2 M.aura[2].expires = 0 -- this is a one time aura. So I need to apply it to card #2 and then immediately expire it so it never activates again. </code></pre> <p>Then on every new turn I loop through all the auras and make sure they are still active before a fight begins?</p> <p>Just wondering architecturally what is the best way to keep track of Damage that characters have taken and spells that are active that are giving characters special abilities.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload