Commit 136f47fe by BellCodeEditor

save project

parent 7864dfd6
Showing with 10 additions and 2 deletions
class Hero:
def __init__(self,name,hp,attack):
def __init__(self,name,hp,attack,max_hp):
self.level = 1
self.name = name
self.hp = hp
self.attack = attack
self.max_hp = self.hp
def combat(self,enmey):
info1 = self.name + '对' + enmey.name + '发起进攻,'
info2 = '造成' + self.attack + '点伤害,'
......@@ -17,6 +18,13 @@ class Hero:
info = info1 + info2 + info3
print(info)
exit()
def cure(self):
self.hp = self.hp + 60
if self.hp > self.max_hp:
self.hp = self.max_hp
class Player(Hero):
def __init__(self,name,hero_type):
super(Player,self).__init__(name)
......@@ -26,7 +34,7 @@ class Player(Hero):
print('角色'+self.name+'已经创建','英雄类型为'+self.hero_type)
print('当前等级,血量,攻击力为'+self.name + self.attack)
player = Player('后羿','射手')
yase = Hero('亚瑟z')
yase = Hero('亚瑟')
......
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