Commit 70189c8c by BellCodeEditor

save project

parent 5ad5491a
Showing with 23 additions and 9 deletions
import random
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -5,13 +6,7 @@ class Hero(object): ...@@ -5,13 +6,7 @@ class Hero(object):
self.hp = 250 self.hp = 250
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:
...@@ -47,4 +42,23 @@ yase = Hero("垭瑟") ...@@ -47,4 +42,23 @@ yase = Hero("垭瑟")
houyi.combat(yase) houyi.combat(yase)
yase.combat(houyi) yase.combat(houyi)
houyi.cure() houyi.cure()
yase.cure() yase.cure()
\ No newline at end of file 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