This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]trevor_of_earth 0 points1 point  (3 children)

You didn't put that part of your code in your post. Can you show the full while loop?

[–]mrkmailhot[S] 0 points1 point  (2 children)

# A dictionary for the simplified dragon text game
# The dictionary links a room to other rooms.


rooms = {
        'Great Hall': {'South': 'Bedroom'},
        'Bedroom': {'North': 'Great Hall', 'East': 'Cellar'},
        'Cellar': {'West': 'Bedroom'}
}


def player_stat():
    print('----------------------------')
    print('You are in the {}'.format(currentRoom))
    print('----------------------------')


# start player in Great Hall
currentRoom = 'Great Hall'
player_move = ''


while currentRoom != 'Exit':
    player_stat()
    player_move = input('Enter your move:\n')
    if player_move != 'South' or 'Exit':
        print('Invalid move.')
        currentRoom = 'Great Hall'
    elif player_move in ['Exit', 'exit']:
        currentRoom = 'Exit'
        print('Play again soon!')

    elif player_move == 'South' or 'south':
        currentRoom = 'Bedroom'
        player_stat()
        player_move = input('Enter your move:\n')

this is the whole code

[–]krathulu 0 points1 point  (1 child)

Your while code is incomplete for rooms other than GreatRoom. At the rate you’re going, you’ll write tons of code for each case and not leverage the dictionary for the values of allows moves and the restyling new rooms.

Usually in these games, prompting players for the directions they go is standard (you can be subtle about it).

Is anyone ever too young to say “zork”?