Commit f03476a7 by BellCodeEditor

auto save

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