I am building a card game. Let's say it's similar to Magic the Gathering, Hearthstone, etc.
The problem I am trying to figure out is how to architect "auras" and how much damage each card takes.
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.
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 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.
I could do something like this
-- Super Minion takes 3 damage M.card[2].newHp = 1 -- or M.card[2].adjHp = -3 -- Not sure which is better. 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.
Let's say that I am keep track of each turn number starting from 1.
Should I do something like this 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. Then on every new turn I loop through all the auras and make sure they are still active before a fight begins?
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.