Commit 0b8081de by BellCodeEditor

auto save

parent a4a5d6d3
Showing with 13 additions and 3 deletions
...@@ -4,8 +4,8 @@ class Hero(object): ...@@ -4,8 +4,8 @@ class Hero(object):
self.name = name self.name = name
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)+"点伤害,"
...@@ -20,6 +20,14 @@ class Hero(object): ...@@ -20,6 +20,14 @@ class Hero(object):
print(info) print(info)
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):
...@@ -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)
...@@ -55,5 +64,5 @@ while True: ...@@ -55,5 +64,5 @@ while True:
else: else:
yase.combat(houyi) 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