为什么我的课程提前结束?

时间:2012-09-28 14:22:49

标签: python

由于你的所有帮助,我最近能够让它运行,但我无法弄清楚为什么我的程序在这里结束。看着它,if answer == 3:应该带你到下一次遭遇,但我的计划正在结束。我错过了什么吗?

# First Encounter (main program really)
def fi_en():
    global pow, cun, per
    print"""
It smells of damp vegetation, and the air is particularly thick. You can 
hear some small animals in the distance. This was a nice place to sleep.

1. Stay close, find some cover, and wait for food to show up.

2. Explore the nearby marsh & find the nearest river, following it downstream.

3. Walk towards the large mysterious mountain in the distance. 
"""
    answer = int(raw_input(prompt))
    if answer == 1:
        cun_one = roll_3d6()
        if cun_one <= cun - 2:
            print"""Time passes as eventually you capture some varmints.
You feel slightly more roguish."""
            cun = cun + 1
            fi_en()
        else: 
            print """Time passes and a group of slavers marches into right 
where you are hiding in the woods. They locate you, capture you, and haul you
away for a lifetime of servitude in the main city.
Goodbye %s""" % name
    elif answer == 2: 
        power = roll_3d6()
        if power <= pow - 4:
            print"""You trudge through the marshes until you eventually reach 
a large river. Downstream from the river is a large temple covered in vines,
you walk towards it. You feel more powerful."""
            pow = pow + 2
            te_en()
        else:
            print """The vegetation here wraps itself around your legs making
it impossible to move. You will most likely die here in the vegetation. 
Goodbye %s.""" % name
    elif answer == 3:
        cun_two = roll_3d6()
        if cun_two <= cun:
            print """You make your way towards the mountain and you encounter
a really large group of devil dogs guarding the entrance to the mountain."""
            dd_en()
    else: 
        print"You have gotten lost and ended up right where you started."
        fi_en()

我的输出是:

It smells of damp vegetation, and the air is particularly thick. You can 
hear some small animals in the distance. This was a nice place to sleep.

1. Stay close, find some cover, and wait for food to show up.

2. Explore the nearby marsh & find the nearest river, following it downstream."

3. Walk towards the large mysterious mountain in the distance. 

> 3
Raymond-Weisss-MacBook-Pro:lod Raylug$

3 个答案:

答案 0 :(得分:2)

听起来像你错过了一大群魔鬼狗。你确定要解决这个问题吗?

答案 1 :(得分:1)

您尚未在任何地方定义全局变量。在条件三中你没有“else”语句,所以由于cun_one不小于/等于你的未定义的cun变量,所以当回答== 3时没有别的办法。

答案 2 :(得分:1)

删除了所有内容,因为您已经开始工作,只是评论。

您可以使用输入('Prompt'),因为它自动变为int,raw_input将输入转换为字符串,然后您将该字符串转换为int,这是不必要的。