[Python] Can't encounter 'Villain' in text based game [closed]

Discussão em 'Python' iniciado por Stack, Outubro 27, 2024.

  1. Stack

    Stack Membro Participativo

    Extreme python newbie and currently taking a python class. Trying to do an adventure text game. I've got the directions and retrieving items part correctly but my if in inventory doesn't run and still adds item and I can't seem to encounter my "villain" when I enter that room.

    This is what I have to grab items:

    if 'item' in inventory:
    print('You already have the ', rooms[current_room]['item'])
    player_move = input('Enter your move: ')
    action = player_move.title().split()
    print('-------------------')
    elif action[1] == rooms[current_room]['item'] and 'item' not in inventory:
    inventory.append(action[1])
    print(rooms[current_room]['item'], 'retrieved')
    player_move = input('Enter your move: ')
    action = player_move.title().split()
    print('-------------------')


    I currently have this for the Villain but it never triggers

    if 'Villain' in rooms[current_room].keys():
    if len(inventory) < 6:
    print("You got caught before you could complete your mission! :(")
    break

    else:
    print("You successfully infiltrated the company!")
    break


    Instead it just acts like I entered another room, shows my inventory, and asks for my next move

    Continue reading...

Compartilhe esta Página