Commit ca556c46 by BellCodeEditor

save project

parent a9a7a94a
Showing with 14 additions and 5 deletions
# 英雄角色类
class Hero(object):
def __init__(self, name,hp,attack):
def __init__(self, name):
self.level = 1
self.hp = hp
self.attack = attack
self.hp = 250
self.attack = 50
self.name = name
def combat(self,enemy): # 攻击
......@@ -17,8 +17,16 @@ class Hero(object):
else:
print(enemy.name+'阵亡.游戏结束.')
exit()
yase = Hero("垭瑟",240,30)
houyi= Hero("后羿",250,50)
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp=230
self.attack=60
yase = Hero("垭瑟")
houyi= Player("后羿")
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