Commit a9a7a94a by BellCodeEditor

save project

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