为游戏编写一个战斗序列,这个错误显示在底线上,其中应该发生实际算术并在后台应用。我假设这是一个与算术方法有关的错误?
if choice == 'A':
print(curChar[NAME] + "attacks!")
attackHit = True
if WEAPON_ACCURACY < 100:
if roll() > WEAPON_ACCURACY:
attackHit = False
print(curChar[NAME], "'s attack missed!")
else:
attackHit == True
print(curChar[NAME], "'s attack landed and dealt", curChar[STRENGTH] + curChar[WEAPON_DAMAGE] - curEnemy[HEALTH] + curEnemy[ARMOR], "damage!")
**curChar[HEALTH] + curChar[ARMOR] - curEnemy[STRENGTH] - curEnemy[WEAPON_DAMAGE] = curChar[HEALTH]**
答案 0 :(得分:1)
注意分配变量的顺序。目标位于左侧,计算位于右侧。
curChar[HEALTH] = curChar[HEALTH] + curChar[ARMOR] - curEnemy[STRENGTH] - curEnemy[WEAPON_DAMAGE]