Commit f03476a7 by BellCodeEditor

auto save

parent 76d67a35
Showing with 16 additions and 7 deletions
...@@ -3,7 +3,7 @@ class Hero(object): ...@@ -3,7 +3,7 @@ class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
self.level = 1 self.level = 1
self.hp = 250 self.hp = 300
self.attack = 40 self.attack = 40
self.max_hp = self.hp self.max_hp = self.hp
...@@ -38,12 +38,19 @@ class Player(Hero): ...@@ -38,12 +38,19 @@ class Player(Hero):
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type) print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack) print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
def cure(self): def cure(self): # 治疗
c=random.randint(35,50) c=random.randint(30,70)
self.hp+=c if self.hp+c>self.max_hp:
if self.hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp) else:
self.hp+=c
def q(self):
self.max_hp+=20
self.attack+=5
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
yase = Hero("垭瑟") yase = Hero("垭瑟")
...@@ -51,11 +58,13 @@ print('-'*30) ...@@ -51,11 +58,13 @@ print('-'*30)
print('战斗开始') print('战斗开始')
while True: while True:
print('-'*30) print('-'*30)
a=input('请选择释放英雄技能(1攻击/2治疗)') a=input('请选择释放英雄技能(1攻击/2治疗/3升级)')
if a=='1': if a=='1':
houyi.combat(yase) houyi.combat(yase)
elif a=='2': elif a=='2':
houyi.cure() houyi.cure()
elif a=='3':
houyi.q()
elif a=='q': elif a=='q':
break break
else: else:
......
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