2012-09-28 4 views
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 не печатает ничего, если cun_two> cun –

+0

Что такое переменная 'cun'? –

+0

Согласовано с @JoranBeasley: еще раз отложите блок 'else', чтобы он дошел до уровня' if cun_two <= cun: ' –

ответ

1

Вы не определили свои глобальные области где угодно. У вас нет инструкции «else» в условии 3, так как cun_one не меньше/равно вашей неопределенной переменной cun, больше ничего не остается делать, когда ответ == 3.

+0

Теперь она работает, спасибо @sellikesybok и всем остальным! – lerugray

2

Это звучит для меня, как вы пропустили действительно большую группу дьявольских собак. Вы уверены, что хотите это исправить?

1

Удалено с момента его запуска , просто комментарий.

Вы можете использовать ввод ('Prompt'), поскольку он автоматически становится int, raw_input преобразует ввод в строку, а затем вы преобразовываете эту строку в int, что необязательно.

Смежные вопросы