【发布时间】:2013-12-08 01:52:21
【问题描述】:
我正在开发一款纸牌游戏。假设它类似于万智牌、炉石传说等。
我试图弄清楚的问题是如何构建“光环”以及每张卡会受到多少伤害。
现在我有一个套牌,我存储卡片数据如下。我已经为将存在的卡片类型编造了名称。
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.
然后在每个新的回合中,我都会遍历所有光环,并确保它们在战斗开始前仍然处于活动状态?
只是想知道在架构上记录角色受到的伤害以及赋予角色特殊能力的有效法术的最佳方法是什么。
【问题讨论】: