Commit 70189c8c by BellCodeEditor

save project

parent 5ad5491a
Showing with 21 additions and 6 deletions
import random
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -6,12 +7,6 @@ class Hero(object): ...@@ -6,12 +7,6 @@ class Hero(object):
self.attack = 40 self.attack = 40
self.max_hp = self.hp self.max_hp = self.hp
print('-' * 30)
print(' 游戏开始')
while True:
print('-' * 30)
ff = input("请释放技能(1攻击/2治疗) :")
def cure(self): # 治疗 def cure(self): # 治疗
self.hp=self.hp+80 self.hp=self.hp+80
if self.hp>self.max_hp: if self.hp>self.max_hp:
...@@ -48,3 +43,22 @@ houyi.combat(yase) ...@@ -48,3 +43,22 @@ houyi.combat(yase)
yase.combat(houyi) yase.combat(houyi)
houyi.cure() houyi.cure()
yase.cure() yase.cure()
print('-' * 30)
print(' 游戏开始')
while True:
print('-' * 30)
ff = input("请释放技能(1攻击/2治疗) :")
if ff == "q":
print("游戏结束")
break
elif ff == "1":
houyi.combat(yase)
elif ff == "2":
houyi.cure()
else:
print("请重新输入1或2")
num = random.randint(1,3)
if num == 1:
yase.cure()
else:
houyi.combat(yase)
\ 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