0

私は最近、あなたの助けのおかげでこれを実行することができましたが、なぜ私のプログラムがここで終了するのか理解できません。それを見ると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$
4

3 に答える 3

2

あなたが本当に大きな悪魔の犬のグループを逃しているように私には聞こえます。これを修正してもよろしいですか?

于 2012-09-28T14:27:13.787 に答える
1

コメントだけで、すでに機能しているのですべて削除しました。

input('Prompt')は自動的にintになり、raw_inputは入力を文字列に変換してから、その文字列をintに変換するため、これを使用できます。これは不要です。

于 2012-09-28T15:44:11.280 に答える
1

グローバルをどこにも定義していません。条件3には「else」ステートメントがないため、cun_oneは未定義のcun変数以上であるため、answer==3の場合は他に何もする必要はありません。

于 2012-09-28T14:34:37.967 に答える