Python文本冒险困境

时间:2015-10-10 22:36:28

标签: python

if schoice == 1:
    print "You walk right up to the rat and proceed to BEAT THE SHIT OUT OF IT AHHHHHH. Ahem. Anyway, you look at your blood-covered fists and feel good about yourself. You know that you just leveled up your Unarmed to 11. BOOYA!"
    skills("Unarmed") = 11
else:
    "You proceed to be a little bitch and sneak past the rat. Even though you know that you are being a total coward, you feel good, and you know that you leveled up your sneak to 11. Oh Yeah!"
    skills("Sneak") = 11

首先,我想说我有其他所有设置的raw_input内容,但我只是想知道我是否必须从这里拆分,然后必须写同样的东西数十亿次,或者我可以做出这两种选择,无论选择哪种,都可以进行共享的新选择?

1 个答案:

答案 0 :(得分:2)

每次有选择时,你都不必拆分所有东西,没有。

考虑一下:

print('This happens first')
choice = raw_input('Make a choice (1 or 2)')
if choice == 1:
    print('Conditional event no1')
else:
    print('Conditional event no2')
print('This happens after the choice, no matter what happened')

这个故事可以从那里继续下去。您可以将其视为类似于此的流程图:

                /------ Choice 1 -------\               
Starting point /                         \____ Happens in either case
               \                         /
                \------ Choice 2 -------/