Commit ba6f15d7 by BellCodeEditor

auto save

parent 10c7538b
Showing with 30 additions and 18 deletions
...@@ -9,7 +9,7 @@ class Hero(object): ...@@ -9,7 +9,7 @@ class Hero(object):
def cure(self): def cure(self):
self.hp+=60 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+"使用了治疗,血量增加:", 55,",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:", 55,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击 def combat(self, enemy): # 普通攻击
......
...@@ -9,7 +9,7 @@ class Hero(object): ...@@ -9,7 +9,7 @@ class Hero(object):
def cure(self): def cure(self):
self.hp+=60 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+"使用了治疗,血量增加:", 55,",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:", 55,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击 def combat(self, enemy): # 普通攻击
...@@ -47,24 +47,35 @@ class Player(Hero): ...@@ -47,24 +47,35 @@ class Player(Hero):
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
yase = Hero("垭瑟") yase = Hero("垭瑟")
while True: while True:
print('-'*30) print('-'*30)
a=input("请选择技能:1攻击/2治疗") a = input("请选择技能:1攻击/2治疗")
if int(a)==1:
houyi.combat(yase)
elif int(a)==2:
houyi.cure()
elif a=="q":
print('游戏结束')
break
else: # while True:
print('重输!') # print('-'*30)
continue # a=input("请选择技能:1攻击/2治疗")
b=random.randint(1,3) # if int(a)==1:
if b==3: # houyi.combat(yase)
yase.cure() # elif int(a)==2:
else: # houyi.cure()
yase.combat(houyi) # elif a=="q":
# print('游戏结束')
# break
# else:
# print('重输!')
# continue
# b=random.randint(1,3)
# if b==3:
# yase.cure()
# else:
# 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