Commit 057af5a9 by BellCodeEditor

save project

parent 693d16bc
Showing with 5 additions and 0 deletions
...@@ -5,6 +5,7 @@ class Hero(object): ...@@ -5,6 +5,7 @@ class Hero(object):
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
self.max_hp=self.hp
def combat(self,enemy): def combat(self,enemy):
enemy.hp -= self.attack enemy.hp -= self.attack
...@@ -15,6 +16,10 @@ class Hero(object): ...@@ -15,6 +16,10 @@ class Hero(object):
else: else:
info3 = enemy.name + '阵亡' info3 = enemy.name + '阵亡'
print(info1 + info2+ info3) print(info1 + info2+ info3)
def cure(self):
self.hp=60
if self.hp>self.max_hp:
self.hp=self.max_hp
class Player(Hero): class Player(Hero):
def __init__(self,name,hero_type): def __init__(self,name,hero_type):
super().__init__(name,hero_type) super().__init__(name,hero_type)
......
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