Commit 8b16cf86 by BellCodeEditor

save project

parent 33bd0b01
Showing with 24 additions and 11 deletions
......@@ -9,10 +9,11 @@ class Hero(object):
def cure(self): # 治疗
flood = random.randint(30,50)
self.hp += 60
if self.hp > self.maxhp :
self.hp = self.maxhp
print(self.name+"使用了治疗术,血量增加"+str(60)+",目前血量为"+str(self.hp))
print(self.name+"使用了治疗术,血量增加"+str(flood)+",目前血量为"+str(self.hp))
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
......@@ -39,18 +40,30 @@ class Player(Hero):
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
def cure(self):
self.hp+=60
self.hp+=flood
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",str(60),",目前的血量为:",self.hp)
print(self.name+"使用了治疗,血量增加:",str(flood),",目前的血量为:",self.hp)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
print('-'*30)
print(" 战斗开始")
print("_"*30) # 打印分割符
print(" 战斗开始") # 打印游戏开始
while True:
print("-"*30)
choice = input("请选择英雄要释放的技能(1攻击/2治疗)")
if choice == "q":
print("")
\ No newline at end of file
print("_"*30) # 打印分隔符
choice = input("请选择英雄要释放的技能(1攻击/2治疗)") # 使用input("请选择英雄要释放的技能(1攻击/2治疗)")输入数据,并赋值给choice
if choice == "q": # 判断 如果输入的是字符 q
print("游戏结束") # 打印游戏结束
exit() # 退出
elif choice=="1": # 如果输入的是 1
houyi.combat(yase) # 攻击
elif choice=="2": # 如果输入的是 2
houyi.cure() # 治疗
else: # 否则
print('请其正确输入指令') # 输出 '请其正确输入指令'
continue # 继续
num = random.randint(1,3) # 随机生成1~3之间的整数
if num==1: # 如果生成为 1
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