Commit 184423be by BellCodeEditor

save project

parent ee8548b7
Showing with 24 additions and 13 deletions
class Hero: class Hero(object):
def __init__(self,name,hp,attack): def __init__(self,name):
self.level=1 self.level = 1
self.hp = 250
self.attack = 40
self.name=name self.name=name
self.hp=hp
self.attack=attack def combat(self,enemy):
def uperade(self): a1 = self.name+"对"+enemy.name+"发起进攻,"
self.livel+=1 a2='造成'+str(self.attack)+'点伤害'
self.hp+=50 enemy.hp -= self.attack
self.attack+=5 if enemy.hp > 0:
yase= Hero('亚瑟',300,20) a3=enemy.name
yase.upgrade() a = a1+a2+a3
print(yase.hp) print(a)
\ No newline at end of file else:
a3 = enemy.name+"游戏结束"
a = a1+a2+a3
print(a)
exit()
yase= Hero('亚瑟')
houyi= Hero('后羿')
yase.combat(houyi)
\ 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