Commit 184423be by BellCodeEditor

save project

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