Commit dd33757d by BellCodeEditor

save project

parent 19645c7e
Showing with 22 additions and 8 deletions
import random
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
self.level = 1 self.level = 1
self.hp = 250 self.hp = 1
self.attack = 40 self.attack = 40
self.m = self.hp self.m = self.hp
def cure(self): # 治疗 def cure(self): # 治疗
self.hp=self.hp+60 self.hp=self.hp+30
if self.hp>self.m: if self.hp>self.m:
self.hp=self.m self.hp=self.m
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击 def combat(self, enemy): # 普通攻击
...@@ -45,4 +43,21 @@ print('-'*30) ...@@ -45,4 +43,21 @@ print('-'*30)
print(' 开始游戏') print(' 开始游戏')
while True: while True:
print('-'*30) print('-'*30)
ss=input('请选择释放英雄技能(1攻击/2治疗):') ss=input('请选择释放英雄技能(1攻击/2治疗):')
\ No newline at end of file if ss=='q':
break
elif ss=='1':
houyi.combat(yase)
elif ss=='2':
houyi.cure()
else:
print('输入错误')
continue
p=random.randint(1,2)
if p==1:
yase.combat(houyi)
else:
yase.cure()
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