I'm sure there are better ways to code this. I spent a lot of time re-working the code to get it as clean as possible. I would appreciate any input on what I could change to have the program run more efficiently and look cleaner.
outer = False
while outer == False:
room_list = []
room = ["This place stinks, better get moving. Door to the N or E", 1, 8, None, None]
room_list.append(room)
room = ["You are in a safe room. There are doors to the N,E,S and W", 2, 9, 0, 4]
room_list.append(room)
room = ["This room is filled with garbage. There is a door to the S", None, None, 1, None]
room_list.append(room)
room = ["You encounter goblins and die!"]
room_list.append(room)
room = ["You encounter orcs and kill them all! There is a door to the N,E and S", 3, 1, 5, None]
room_list.append(room)
room = ["You encounter rats, easy fight. Theres a door to the N", 4, None, 7, None]
room_list.append(room)
room = ["You found a companion! Theres a door to the S", None, None, 9, None]
room_list.append(room)
room = ["You found the treasure! Congratulations!"]
room_list.append(room)
room = ["Ouch, you were hit by a fireball! There's a door to the W", None, None, None, 0]
room_list.append(room)
room = ["You found a treasure map! It says 'Rats dwell, south it lies'. Theres a door to the N and W",6,None,None,1]
room_list.append(room)
current_room = 0
print (room_list[current_room][0])
inner = False
new_room = 0
while inner == False:
user_choice = input ("What would you like to do? ")
print ()
if user_choice in('north','n','North','N'):
new_room = room_list[current_room][1]
elif user_choice in('east','e','East','E'):
new_room = room_list[current_room][2]
elif user_choice in('south','s','South','S'):
new_room = room_list[current_room][3]
elif user_choice in('west','w','West','W'):
new_room = room_list[current_room][4]
else:
print ("I don't know what", user_choice, "means")
if new_room == None:
print ("You can't go that way.")
else:
current_room = new_room
print (room_list[new_room][0])
if current_room == 3:
play_again = input("Would you like to play again? ")
if play_again in("y","Y","Yes","yes"):
print()
break
else:
outer = True
break
if current_room == 7:
outer = True
break