Commit a9a7a94a by BellCodeEditor

save project

parent 411d9195
Showing with 12 additions and 7 deletions
# 英雄角色类
class Hero(object):
def __init__(self, name):
def __init__(self, name,hp,attack):
self.level = 1
self.hp = 250
self.attack = 40
self.hp = hp
self.attack = attack
self.name = name
def combat(self,enemy): # 攻击
......@@ -14,6 +14,11 @@ class Hero(object):
info3=enemy.name+'还剩'+str(enemy.hp)+'血量。'
info=info1+info2+info3
print(info)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
else:
print(enemy.name+'阵亡.游戏结束.')
exit()
yase = Hero("垭瑟",240,30)
houyi= Hero("后羿",250,50)
while True:
houyi.combat(yase)
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