0

so this is my code( or just a long sample)

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!')`

that is my code and as you can see the def war(i wanted to use battle) is not yet finished. I tried many examples but sometimes the ai's health goes to negative something and the program is still going. can anyone help?

Haoyang Song
  • 162
  • 12

0 Answers0