Commit 5a8b67f1 by BellCodeEditor

save project

parent 29647d4c
Showing with 19 additions and 9 deletions
import random import random
cure_cishu_player=3 cure_cishu_player=3
cure_cishu_hero=3 huihe=1
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -10,7 +10,7 @@ class Hero(object): ...@@ -10,7 +10,7 @@ class Hero(object):
self.max_hp = self.hp self.max_hp = self.hp
def cure(self): # 治疗 def cure(self): # 治疗
self.hp=self.hp+60 self.hp=self.hp+blood
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,",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
...@@ -43,16 +43,27 @@ yase = Hero("垭瑟") ...@@ -43,16 +43,27 @@ yase = Hero("垭瑟")
print('-'*30) print('-'*30)
print(' Fight!') print(' Fight!')
print('-'*30) print('-'*30)
blood = random.randint(30,50)
while True: while True:
print('-'*30)
print(' 第',huihe,'回合')
choice=input('请输入(攻击———1 治疗术——2 退出——q):') choice=input('请输入(攻击———1 治疗术——2 退出——q):')
print('-'*30) print('-'*30)
if choice=='1': if choice=='1':
houyi.combat(yase) houyi.combat(yase)
elif choice=='2' and cure_cishu_player>0: elif choice=='2':
if cure_cishu_player>0:
houyi.cure() houyi.cure()
print('治疗还可用',cure_cishu_player-1,'次') print('治疗还可用',cure_cishu_player,'次')
cure_cishu_player=cure_cishu_player-1
else:
print('治疗术次数用完!')
continue
elif cure_cishu_player<0:
print('治疗术次数已用完!')
continue
elif choice=='q': elif choice=='q':
print('已退出!') print('我方已投降,游戏结束!')
break break
else: else:
print('Please try again!') print('Please try again!')
...@@ -60,10 +71,8 @@ while True: ...@@ -60,10 +71,8 @@ while True:
num = random.randint(1,2) num = random.randint(1,2)
if num==1: if num==1:
yase.combat(houyi) yase.combat(houyi)
elif num==2 and cure_cishu_hero>0: elif num==2:
yase.cure() yase.cure()
elif cure_cishu_hero=0: huihe=huihe+1
print('敌人以无治疗术')
continue
\ 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