Commit 51ca6833 by BellCodeEditor

auto save

parent 3fd713f5
Showing with 19 additions and 2 deletions
import random # 导入random模块
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -42,4 +44,19 @@ print('-'*30) # 打印出分隔符'-'*30 ...@@ -42,4 +44,19 @@ print('-'*30) # 打印出分隔符'-'*30
print(' 战斗开始') # 打印出' 战斗开始' print(' 战斗开始') # 打印出' 战斗开始'
while True: # 设置while循环 while True: # 设置while循环
print('-'*30) # 打印出分隔符'-'*30 print('-'*30) # 打印出分隔符'-'*30
choice = input("请选择释放英雄技能(1攻击/2治疗):") # 选择=输入(内容) choice = input("请选择释放英雄技能(1攻击/2治疗):") # 选择=输入(内容)
\ No newline at end of file if choice == "q": # if判断选择q
# 打印出游戏结束
break # 结束程序
elif choice == "1": # 继续判断选择1
houyi.combat(yase) # 后羿攻击亚瑟
elif choice == "2": # 继续判断选择2
houyi.cure() # 后羿治疗
else: # 否则
print("请重新输入1或者2") # 打印出,请重新输入1或2提示
continue # 进入下一轮循环
num = random.randint(1,3) # 生成随机数1,3并赋值给num
if num == 1: # if判断num的值=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