Commit 25f9ea05 by BellCodeEditor

save project

parent 68c9d33a
Showing with 18 additions and 3 deletions
...@@ -41,15 +41,29 @@ class Player(Hero): ...@@ -41,15 +41,29 @@ class Player(Hero):
print(' 战斗开始') print(' 战斗开始')
def cure(self): def cure(self):
c=random.randint(35,50) c=random.randint(35,50)
self.hp+=c self.hp+=60
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+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp)
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
yase = Hero("垭瑟") eyas = Hero("垭瑟")
while True: while True:
print('-'*30) print('-'*30)
a=input("请输入(1攻击、2治疗):") a=input("请输入(1攻击、2治疗):")
if a=="q":
print("游戏结束")
elif a=="1":
houyi.combat(eyas)
elif a=="2":
houyi.cure()
else:
print("输入错误")
continue
b=random.randint(1,3)
if b==1:
eyas.cure()
else:
eyas.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