0

So, i'm currently writing a script for a simple Text Based Adventure Game, I made a pathway function that randomly selects the place the player will go, when the place is select for example "Almighty Mountain" it executes the loot_room function even tho the heal_room function is selected for "almighty Mountain", why does it executes the Loot_room funktion? There is nothing that could execute the loot_room function in the heal_room function. Here is the code:

Right and left doesnt matter right now.

def pathway():
    
    while True:
        
        pathway_input = input("Where at a turn. Should we go left or right? L/R: ")
        if pathway_input == "L" or "Left":
            pathway_choice = random.choice(path_selection)
            if pathway_choice == "Mando Town" or "Crossover Mountains":
                sleep(2)
                print("Ok. Were going to " + pathway_choice + ".")
                loot_room(Player_stats)
            elif pathway_choice == "Almighty Mountain":
                sleep(2)
                print("Ok. Were going to " + pathway_choice + ".")
                heal_room(Player_stats)
            elif pathway_choice == "Sleeping Edges":
                sleep(2)
                print("Ok. Were going to " + pathway_choice + ".")
                fight_room(Player_stats)
        elif pathway_input == "R" or "Right":
            pathway_choice = random.choice(path_selection)
            if pathway_choice == "Almighty Mountain":
                print("Ok. Were going to " + pathway_choice + ".")
                heal_room(Player_stats)   
            elif pathway_choice == "Sleeping Edges":
                sleep(2)
                print("Ok. Were going to " + pathway_choice + ".")
                fight_room(Player_stats)
            elif pathway_choice == "Mando Town" or "Crossover Mountains":
                sleep(2)
                print("Ok. Were going to " + pathway_choice + ".")
                loot_room(Player_stats)
        else:
            sleep(1)
            print("please Say something understandable Bro")
            continue

Heal_room and loot_room functions are under the rest.

L30n2UwU
  • 1
  • 1
  • 2
    `if pathway_input == "L" or "Left":` does not what you think it does. – Maurice Meyer Jan 24 '23 at 19:55
  • what does it then? Sorry for some stupid errors in my code, im just starting. – L30n2UwU Jan 24 '23 at 19:59
  • So I edited my code like @radhadman described it, but It still only executes the loot_room function. – L30n2UwU Jan 24 '23 at 20:08
  • From the above code it should execute heal_room() if the pathway choice is 'Almighty Mountain'. You might have an issue elsewhere – radhadman Jan 24 '23 at 20:14
  • @PaulM. you're right. mb! – radhadman Jan 24 '23 at 20:19
  • Ok. So checked out the linked Question out and it seems that writing like 'if pathway_choice == "Mando Town" or pathway_choice == "Crossover Mountains:" instead of "if pathway_choice == "Mando town" or "Crossover Mountains:" seems to be fixing it. Thanks for Help!!! – L30n2UwU Jan 24 '23 at 20:36

0 Answers0