Commit de247ed1 by BellCodeEditor

save project

parent 28c8e6ab
Showing with 25 additions and 3 deletions
import random
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -9,7 +10,8 @@ class Hero(object): ...@@ -9,7 +10,8 @@ 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,'用了治疗,',self.name,"还有",self.hp,"滴血")
def combat(self, enemy): # 普通攻击 def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻," info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害," info2 = "造成"+str(self.attack)+"点伤害,"
...@@ -40,4 +42,24 @@ print('-'*30) ...@@ -40,4 +42,24 @@ print('-'*30)
print(" 游戏开始") print(" 游戏开始")
while True: while True:
print('-'*30) print('-'*30)
input("请选择释放技能(1攻击,2治疗):") ada=input("请选择释放技能(1攻击/2治疗):")
\ No newline at end of file if ada=='q':
print('game over.')
break
elif ada=='1':
houyi.combat(yase)
elif ada=='2':
houyi.cure()
else:
print('重输')
continue
a=random.randint(1,3)
if a==1 or a==2 :
yase.combat(houyi)
else:
yase.cure()
\ 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