Creating a complex chose your own adventure

Hi all,

I am trying to create a complex chose your own adventure. I didn’t like the idea of just nested if/else statements, I wanted stat/equipment tracking and the option for players to loop through choices. Game has a built in timer also, take too long and you die.

Though with it being my first solo bit of work of more than 20 lines I am running into a number of issues. The first major one being how I seem to be getting caught in infinite loops, or ‘locking off’ choices in the game.

The code below is a snippet, hopefully it makes some sense.
The player wakes up and is given three choices, DOOR, BOBIES or ROOM. The bit below only covers ‘door’ but allows the player to loop back to the main choice of door/bodies/room. Once the door is open, function adventure_2 ends, and _3 starts.

I appear to be getting a loop after ‘slam_again’ ideally after saying yes the code should print ‘You slam your body against the door, this time you hear the cracking of wood, the door is getting weaker…But you shoulder begs you to stop.’ but instead it it loops back to;

You approach the cell door, which is made of old oak. There is a small barred window, through…

Not sure why it doesnt follow through with the if statement?

If someone with some experience would be happy to do a full code review I would be grateful, but I am not expecting that!

#This is the second main choice def adventure_2(): global curse_rank, curse_growth, attack_bonus, defence_bonus, max_health, current_health, alignment q2_0 = print('Slowly you push yourself up from the ground, dried blood tangled in your hair.') while True: time.sleep(2.0) curse_health_check() q2_1 = input('Staring around you have three options. Check the cell DOOR, check the BODIES or search the ROOM. ').lower() while q2_1 == 'door': print("You approach the cell door, which is made of old oak. There is a small barred window, through it you see a hallway lit by a dim torch. A faint snore can be heard nearby.") time.sleep(1.0) while 'picks' in equipment: use_picks = input('You have some picks on you, want to use them to open the lock? ').lower() if use_picks == 'yes': print('You pull out the make shift picks and kneel next to the door, slowly you let your fingers move. You perform a skill you did not know you possessed, just what are you? A thieve? ') time.sleep(1.5) print('After a minute of silence, you eventually hear the click of the lock as the door opens. Slowly you pull your picks out, disheartened to see they are ruined.') equipment.remove('picks') curse_growth += 2 time.sleep(3.0) break else: print('You are not in a rush, you can try picking the lock later.') break else: print('The door is locked and relatively sturdy, you could possibly break it down.') time.sleep(1.5) q2_1_1 = input('Do you want to try and break it down? Yes or no? ').lower() if q2_1_1 == 'yes': slam = 0 if slam < 1: print('You slam your body against the door with all your might, though it barely budges. You do hear the snort of a man, which then shifts to a snore, from the otherside of the door. ') time.sleep(1.0) print('A pain spreads through your shoulder, that hurt. ') curse_growth += 2 current_health -= 1 slam += 1 time.sleep(2.0) slam_again = input('Do you want to slam it again? ').lower if slam_again == 'yes': print('You slam your body against the door, this time you hear the cracking of wood, the door is getting weaker...But you shoulder begs you to stop.') curse_growth += 1 current_health -= 1 slam += 1 slam_again = input('Perhaps one more slam would set you free? ').lower() if slam_again == 'yes': print('For a third time you slam your body against the door, you feel an intense heat surge through your body giving you great strength. It is at this moment the bursts open, no chance of being quiet.') curse_growth += 3 current_health -= 1 slam += 1 print('You find yourself in a small hallway leading to the right, a deadend on the left, with numerous cells. There is a shattered door now at your feet.') time.sleep(1.0) print('There is a guard no more than ten feet away from you, who has shot up from chair and desk. The abrupt noise has awoken him from his slumber, and he is quick to draw out his longsword.') print('\033[1m' + 'What on earth, get back in your cell!' + '\033[0m') guard_fight() continue else: print('You step back from the door, not willing to risk the noise or possible pain.') time.sleep(2.0) break adventure_2()

Turns out I figured out why I was looping, I put .upper instead of .upper() just before an if statement. Meaning it never tested as True!

Please glance at the code and give any general advice though!