Commit 1b032a08 by BellCodeEditor

auto save

parent 1e1a9f56
Showing with 35 additions and 11 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name):
self.level=1 self.level=1
self.name=name self.name=name
self.hp=hp self.hp=250
self.attack=attack self.attack=40
def a(self): #def a(self):
self.level=self.level+1 #self.level=self.level+1
self.hp=self.hp+20 #self.hp=self.hp+20
self.attack=self.attack+10 #self.attack=self.attack+10
lv=Hero("lv",300,50) #lv=Hero("lv",300,50)
lv.a() #lv.a()
print(lv.hp) #print(lv.hp)
\ No newline at end of file def combat(self,enemy):
enemy.hp -=self.attack
info1=self.name+"dui"+enemy.name+"fa qi gong ji"
info2="zaocheng"+str(self.attack)+"dian shang hai"
if enemy.hp>0:
info3=enemy.name+"hai sheng"+str(enemy.hp)+"hue"
info=info1+info2+info3
print(info)
else:
info3=enemy.name+"zheng wang"
info=info1+info2+info3
print(info)
exit()
class Player(Hero):
def __init__ (self,name):
super().__init__(name)
#self.level=1
#self.name=name
self.hp=200
self.attack=50
lb=Hero("lb")
hx=Hero("hx")
player=Player("mm")
print(player.hp)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment