Commit 13736afd by BellCodeEditor

save project

parent c59ee84c
Showing with 13 additions and 5 deletions
...@@ -22,10 +22,10 @@ class Hero:#创建一个类 ...@@ -22,10 +22,10 @@ class Hero:#创建一个类
exit() exit()
def cure(self): def cure(self):
self.hp=self.hp+60 self.hp=self.hp+55
if self.hp>self.max_hp: if self.hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
print(self.name+'使用了治疗术,增加血量60,'+'当前血量为:'+str(self.hp)) print(self.name+'使用了治疗术,增加血量55,'+'当前血量为:'+str(self.hp))
class player(Hero): class player(Hero):
def __init__(self,name,Hero_type): def __init__(self,name,Hero_type):
...@@ -36,14 +36,22 @@ class player(Hero): ...@@ -36,14 +36,22 @@ class player(Hero):
self.max_hp=self.hp self.max_hp=self.hp
print("角色"+self.name+"创建成功,英雄类型为:"+self.Hero_type) print("角色"+self.name+"创建成功,英雄类型为:"+self.Hero_type)
print('当前等级、血量、攻击力分别为:'+str(self.level)+'、'+str(self.hp)+'、'+str(self.attack)) print('当前等级、血量、攻击力分别为:'+str(self.level)+'、'+str(self.hp)+'、'+str(self.attack))
print('-'*30)
print(' 战斗开始') def cure(self):
blood=random.randint(35,55)
self.hp=self.hp+blood
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+'使用了治疗术,增加血量'+str(blood)+',当前血量为:'+str(self.hp))
yase = Hero("亚瑟") yase = Hero("亚瑟")
houyi=player("后羿","射手") houyi=player("后羿","射手")
print('-'*30)
print(' 战斗开始')
while True: while True:
print('-'*30) print('-'*30)
a=input("请选择技能:1攻击/2治疗") a=input("请选择技能(1攻击/2治疗):")
if a=="q": if a=="q":
print('游戏结束') print('游戏结束')
break break
......
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