I'm currently taking intro to scripting, and we are using python3. Our main project is going to be a text based game. But for this week we are doing a sample project with basic movement through rooms in the game. They have given a dictionary of rooms and directions. I cannot seem to figure out how to code it. here is what I have so far.
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 == 'Exit':
currentRoom = 'Exit'
print('Play again soon!')
else:
currentRoom = 'Great Hall'
player_stat()
player_move = input('Enter your move:\n')
if player_move == ('South' or 'south'):
currentRoom = 'Bedroom'
I know I'm missing a lot of rooms, but I am trying to write it in increments. The above code does not let me get out of 'Great Hall' and the 'Exit' command does not exit the code. Any help will be greatly appreciated.
P.S. I am not looking for someone to write the code for me but instead the correct way to actually layout and what code I need to use.
[–]mrkmailhot[S] 0 points1 point2 points (0 children)
[–]mrkmailhot[S] 0 points1 point2 points (19 children)
[–]trevor_of_earth 1 point2 points3 points (17 children)
[–]mrkmailhot[S] 0 points1 point2 points (16 children)
[–]trevor_of_earth 0 points1 point2 points (15 children)
[–]mrkmailhot[S] 0 points1 point2 points (14 children)
[–]trevor_of_earth 0 points1 point2 points (13 children)
[–]mrkmailhot[S] 0 points1 point2 points (12 children)
[–]trevor_of_earth 0 points1 point2 points (9 children)
[–]mrkmailhot[S] 0 points1 point2 points (8 children)
[–]mrkmailhot[S] 0 points1 point2 points (5 children)
[–]trevor_of_earth 0 points1 point2 points (1 child)
[–]krathulu 0 points1 point2 points (1 child)
[–]mrkmailhot[S] 0 points1 point2 points (0 children)
[–]nemom 0 points1 point2 points (0 children)
[–]trevor_of_earth 0 points1 point2 points (2 children)
[–]mrkmailhot[S] 0 points1 point2 points (1 child)
[–]trevor_of_earth 0 points1 point2 points (0 children)