擅长:python、mysql、java
<p>你不需要一段时间的循环,这会持续降低所有的法力消耗到0。你可能需要一个完全不同的变量来控制增益/减益。你知道吗</p>
<p>例如:</p>
<pre><code>spell_manacost_modifier = 0
class Spell:
def __init__(self,manacost):
self.manacost = manacost
def calculate_cost(spell):
final_cost = spell.manacost + spell_manacost_modifier
return final_cost if final_cost >=0 else 0
s1 = Spell(1)
s2 = Spell(2)
s3 = Spell(3)
hand = [s1,s2,s3]
# this specific if statement should be run when the turn starts, after of course setting spell_manacost_modifier to 0
if creature in field:
spell_manacost_modifier -= 1
for spell in hand:
print(calculate_cost(spell))
</code></pre>
<p>希望这有帮助!你知道吗</p>