|
|

楼主 |
发表于 2019-1-31 12:04:31
|
显示全部楼层
import easygui as g
import random as r
dict1 = {0:'zero()', 1:'one()', 2:'two()', 3:'three()', 4:'four()', 5:'five()', 6:'six()', 7:'seven()', 8:'eight()', 9:'nine()', 10:'ten()'}
legal_x = [0, 10]#游戏一共10个格子
class Person:
def __init__(self):
self.power = 100
self.x = 0
g.msgbox('游戏开始,您现在在起点.你拥有100点体力')
#游戏开始,生成坐标为0,体力为100
def zer(self):
g.msgbox('请投掷骰子请进!')
die_0 = r.choice([1, 2, 3])
new_x = self.x + die_0
self.x = new_x
self.power -= 10
g.msgbox('您掷出了%d点,您现在的位置是%d,剩余体力%d'%(die_0, self.x, self.power))
#初始随机前进
def advance(self):
g.msgbox('答对了,请投掷骰子前进!')
die_1 = r.choice([1, 2, 3])
new_x = self.x + die_1
self.x = new_x
self.power -= 10
g.msgbox('您掷出了%d点,您现在的位置是%d,剩余体力%d'%(die_1, self.x, self.power))
#答对随机前进
def back(self):
g.msgbox('答错了,请投掷骰子后退!')
die_2 = r.choice([-1, -2, -3])
new_x = self.x + die_2
self.x = new_x
self.power -= 10
g.msgbox('您掷出了%d点,您现在的位置是%d,剩余体力%d'%(die_2, self.x, self.power))
#答错随机后退
def zero():
g.msgbox('恭喜您又回到了原点呢!')
a.zer()
def one():
reply = g.buttonbox('请问公孙大娘叫什么名字?', '第1站,请答题',['公孙盈', '公孙芷', '公孙茵', '公孙幽'])
if reply == '公孙幽':
a.advance()
else:
a.back()
def two():
reply = g.buttonbox('请问以下人物谁瞎了眼睛?', '第2站,请答题',['郭岩', '陆危楼', '李复', '叶英'])
if reply == '叶英':
a.advance()
else:
a.back()
def three():
a.x = 0
g.msgbox('倒霉的你因摔了一跤,退回原点修养','第3站,突发事件!')
def four():
reply = g.buttonbox('请问宠物红绸在哪一个地图刷新?', '第4站,请答题',['君山岛', '寇岛', '洛道', '成都'])
if reply == '洛道':
a.advance()
else:
a.back()
def five():
a.power += 30
g.msgbox('牡丹姐姐给你打气哦,受到了鼓舞,体力增加30点!您现在的体力是%d,继续努力的请进吧'%a.power,'第5站,突发事件',)
a.zer()
def six():
reply = g.buttonbox('请问阿萨辛和陆危楼是什么关系?', '第6站,请答题',['曾经的伙伴', '兄弟', '情人', '三与被三'])
if reply == '曾经的伙伴':
a.advance()
else:
a.back()
def seven():
reply = g.buttonbox('请问当主播兰某人被举报开宏时,他是如何回应的?', '第7站,请答题',['朋友的挂', '没有这回事', '我是卢本伟', '是日常脚本'])
if reply == '是日常脚本':
a.advance()
else:
a.back()
def eight():
reply = g.buttonbox('请问伞爹的技能疾电叱羽主要作用是什么?', '第8站,请答题',['解控', '教育儿子', '减伤', '爆发'])
if reply == '减伤':
a.advance()
else:
a.back()
def nine():
a.x += 3
g.msgbox('遇见了一位木有小丁丁的二少,她使出绝技黄鸡螺旋桨带你飞了一程,前进了3格','第9站,突发事件!')
g.msgbox('您现在的位置是%d'%a.x)
def ten():
reply = g.buttonbox('请问你觉得该题的作者是个什么人?', '第10站,灵魂拷问',['智障', '神经病', '天才'])
if reply == '智障':
a.advance()
a = Person()
a.zer()
while True:
if a.power > 0 and legal_x[0] <= a.x <= legal_x[1]:
num = dict1[a.x]
eval(num)
elif a.power <= 0:
g.msgbox('没有体力了,游戏结束')
reply = g.choicebox('需要重新开始游戏吗?', choices = ['重新开始', '退出'])
if reply == '重新开始':
a = Person()
a.zer()
else:
break
elif a.x < legal_x[0]:
g.msgbox('很遗憾,闯关失败,游戏结束')
reply = g.choicebox('需要重新开始游戏吗?', choices = ['重新开始', '退出'])
if reply == '重新开始':
a = Person()
a.zer()
else:
break
elif a.x > legal_x[1]:
g.msgbox('恭喜您,闯关成功!!')
break
|
|