Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I know there is something Im overlooking, but I don't know what it is. I can't get my game to run correctly and start the
I know there is something Im overlooking, but I don't know what it is. I can't get my game to run correctly and start the player in the "West Gate Entrance" with no item in that room or in their inventory. rooms = { "West Gate Entrance":{ "East":"Great Hall" }, "Great Hall": { "North": "library", "South": "Solar", "East": "Kitchen", "West": "Start" }, "library": { "East": "Bed Chambers", "South": "Great Hall" }, "Bed Chambers": { "West": "Library" }, "Kitchen": { "West": "Great Hall", "North": "Lost Room" }, "Lost Room": { "South": "Kitchen" }, "Solar": { "North": "Great Hall", "East": "East Tower" }, } items = { 'Great Hall': 'Castle Map', 'Library': 'Sword', 'Bed Chambers': 'Lost Key', 'Lost Room': 'Heart Container', 'Kitchen': 'Potion', 'Solar': 'Shield', 'East Tower': 'Ghost Knight' } state = 'West Gate Entrance' inventory = [] # function def get_new_state(state, direction): new_state = state # declaring for i in rooms: # loop if i == state: # if if direction in rooms[i]: # if new_state = rooms[i][direction] # assigning new_state return new_state # return while 1: # gameplay loop print('You are now in the ', state) # printing state if state == 'East Tower': print('You have entered battle with the Ghost Knight!', end='') for i in range(50): for j in range(1000000): pass print(".", end='', flush=True) print() if len(inventory) == 6: print('Congratulations! You have located all 6 items and slain the Ghost Knight') else: print('You have succumbed to your wounds...GAME OVER!') break print('In this room you see a', items[state]) print('You now have', inventory) direction = input('Enter item you want OR direction to go OR exit to give up: ') # asking user if direction.lower() == items[state].lower(): if items[state] not in inventory: inventory.append(items[state]) continue direction = direction.capitalize() # making first character capital remaining lower if direction == 'Exit': # if exit(0) # exit function if direction == 'East' or direction == 'West' or direction == 'North' or direction == 'South': # if new_state = get_new_state(state, direction) # calling function if new_state == state: # if print('There is no move in that direction direction!') # print else: state = new_state # changing state value to new_state else: print('Please input a valid direction!') # print
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started