Commit 0b8081de by BellCodeEditor

auto save

parent a4a5d6d3
Showing with 10 additions and 1 deletions
...@@ -5,7 +5,7 @@ class Hero(object): ...@@ -5,7 +5,7 @@ class Hero(object):
self.level = 1 self.level = 1
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.max_hp =self.hp
def combat(self, enemy): # 普通攻击 def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻," info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害," info2 = "造成"+str(self.attack)+"点伤害,"
...@@ -21,6 +21,14 @@ class Hero(object): ...@@ -21,6 +21,14 @@ class Hero(object):
print('你干嘛啊~~') print('你干嘛啊~~')
exit() exit()
def cure(self):
self.hp = self.hp+60
if self.hp>self.max_hp:
self.hp=self.max_hp
print("恢复了60血量,当前的血量为:",self.hp)
class Player(Hero): class Player(Hero):
def __init__(self,hero_type,name): def __init__(self,hero_type,name):
super().__init__(name) super().__init__(name)
...@@ -35,6 +43,7 @@ class Player(Hero): ...@@ -35,6 +43,7 @@ class Player(Hero):
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
houyi.cure()
yase = Hero("垭瑟") yase = Hero("垭瑟")
while True: while True:
print('-'*30) print('-'*30)
......
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