我在制作纸牌游戏。我们假设它类似于万智牌,炉石等。跟踪卡牌交易游戏的游戏状态
我想弄清楚的问题是如何构建“光环”以及每张卡受到多少伤害。
现在我有一个卡组,我存储卡数据如下。我已经组成了将存在的卡片类型的名称。
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
所以当一张卡攻击另一张卡时,我需要跟踪两张卡所受的伤害。我不想更改每张卡片的基本统计数据,因此我需要跟踪调整情况。
我可以做这样的事情
-- Super Minion takes 3 damage
M.card[2].newHp = 1
-- or
M.card[2].adjHp = -3
-- Not sure which is better.
在战斗中我需要跟踪它的光环播放。例如,如果损害提升卡被播放。我只需要在一回合就给予另一张卡+1伤害。
比方说,我跟踪每回合数从1开始
我应该做这样的事情
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.
然后在每一个新的转折我遍历所有的光环,并确保在战斗开始前他们仍然活跃?
从建筑学角度来说,追踪角色所受伤害的最好方法是什么,而且正在给角色特殊能力的活跃魔法。
我喜欢这种方法。但是我该如何处理其他卡片给予的效果,以及在其他卡片被破坏时效果会消失的效果。假设卡牌1对所有其他友方卡牌造成+1点伤害。我不希望对所有卡片增加1点伤害效果,并且与原卡片的死亡有关。相反,将效果绑定到提供效果的卡片上可能更有意义,因此当卡片死亡时,效果会自动从所有卡片中移除。但是,你会如何编程? –
@fun_programming你可以给这个效果指定一个指向给予它们效果的卡片的字段,例如'dependsOn',然后当你处理效果以移除或者处理它们时,检查从属卡片是否仍然在播放,如果不是,则删除效果。 –