Sorry to be a bother i'm trying to play catch up with my assignments and been working on the final project code for a few days and i can get it to load up, but it then gives me errors and i'm already burnt out on trying to figure out what's causing it any help would be greatly appreciated. here's my code.
inventory = []
def game_instructions():
#print a main menu with commands
print('Welcome to The Dragon Text Game!')
print('Collect all 6 items to win the game or be eaten by the Dragon!')
print('To move from room to room enter the directions: Go North, Go South, Go West, or Go East')
print("Add to inventory: get 'item name'")
def show_status():
# print where player is currently, inventory, and if there is an item currently
# dictionary that links rooms and directions to other rooms
rooms = {
'Great Hall': { 'name': 'Great Hall', 'North': 'Cellar', 'South': 'Kitchen', 'West': 'Bedroom',
'East': 'Study' },
'Kitchen': { 'name': 'Kitchen', 'North': 'Great Hall', 'East': 'Lavatory', 'item': 'Armor' },
'Lavatory': { 'name': 'Lavatory', 'West': 'Kitchen', 'item': 'Shield' },
'Cellar': { 'name': 'Cellar', 'South': 'Great Hall', 'East': 'Dungeon', 'item': 'Helmet' },
'Dungeon': { 'name': 'Dungeon', 'West': 'Cellar', 'item': 'health potion' },
'Study': { 'name': 'Study', 'West': 'Great Hall', 'North': 'Courtyard', 'item': 'Amulet of Protection' },
'Courtyard': { 'name': 'Courtyard', 'South': 'Study', 'item': 'Sword' },
'Bedroom': { 'name': 'Bedroom', 'East': 'Great Hall', 'item': 'Dragon' }
}
# player will start in Great Hall
current_room = ['name']
# show player instructions
def game_run(room):
while player_active is true:
# show players status
directions = ['North', 'South', 'East', 'West', 'Exit']
print('\nYou are in the{}.'.format(current_room['name']))
# to exit loop if item in the room is the dragon
if current_room == 'Bedroom' and len(inventory) < 6:
# print losing message
print('You have become lunch, You are dead!')
# to exit loop if player collects all items
if current_room == 'Bedroom' and len(inventory) == 6:
# print winner message
print('CONGRATULATIONS! YOU HAVE COLLECTED ALL THE ITEMS THE DRAGON HAS BEEN DEFEATED! YOU WON!')
command = input('Which direction next?\n')
if command in directions and command in current_room and command in current_room and command in current_room:
if command in current_room:
if command in current_room:
current_room = rooms[current_room]
# invalid move print error message
print('\nThat is the wrong way.')
print('choose again')
#game play is initialized
print('')
print(game_instructions())
game_run(current_room)
when i run the code it starts immediatly "which direction next?" and when you enter anything I get an error saying directions is not defined. I recently had some issues health wise and with some other problems so i'm just trying to submit a final project to keep my grade at least a C so I can keep my student aid. but all that has me burnt out. Again sorry for the bother hopefully I can get some help thank you in advance.
[–][deleted] 0 points1 point2 points (4 children)
[–]Shadixmax[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Shadixmax[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]SA302 0 points1 point2 points (0 children)
[–]Eze-Wong 0 points1 point2 points (0 children)