这是我的代码(或只是一个很长的示例)
from easygui import*
health = 100
ai_h = 100
moves = ['scratch']
class player:
def starter():
starter = buttonbox('what do you want to see?',
choices = ['fjade', 'soarer','mudwet'])
msgbox = ('that is a great choice')
def p_attack():
global ai_h
battle = choicebox('battle, chose your move!',
choices = moves)
if battle == 'scratch':
msgbox('you used scratch')
ai_h = ai_h - 10
msgbox(ai_h)
if health < 0:
msgbox('you failed')
quit()
sys.exit()
def __init__(self):
self.health = health
class ai:
def __init__(self):
self.healtha = ai_h
def attack():
global health
msgbox('the oppenet hit you!')
msgbox('you lost 10 health')
health = health - 10
msgbox(health)
if ai_h < 0:
msgbox('you defeated ai')
class battle:
def __init__():
pass
def war(opponet, opponet_health, your_health):
msgbox('oppent want to battle!')`
那是我的代码,正如您所看到的def war(我想使用Battle) 尚未完成。我尝试了很多示例,但有时AI的健康状况会有所下降,并且程序仍在运行。有人可以帮忙吗?