gpt4 book ai didi

Python:无法分配给运算符

转载 作者:太空宇宙 更新时间:2023-11-03 18:23:33 25 4
gpt4 key购买 nike

为游戏编写战斗序列,此错误显示在底线上,实际算术应该在后台发生并应用。我假设这是与算术方法相关的错误?

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]**

最佳答案

请注意分配变量的顺序。目标在左边,计算在右边。

curChar[健康] = curChar[健康] + curChar[ARMOR] - curEnemy[STRENGTH] - curEnemy[WEAPON_DAMAGE]

关于Python:无法分配给运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23641565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com