Question: With this TextBasedGame.py script from yesterday, I already turned it in for grading last night. I just want to know how I might go about
With this TextBasedGame.py script from yesterday, I already turned it in for grading last night. I just want to know how I might go about stringing the items to be picked up by the user pressing 'x' rather than typing out 'First Aid Kit' or 'Winchester SXP Defender Shotgun' to add the items to their inventory. It makes the game take longer than need be for the items, but it is well worth it. Also, how can I save/extract the file to send to a friend for them to try out on their own PC? If that is possible at all. Thank you!
""" Dragon Themed Game """ # a dictionary for dragon text based game Unbound Nightmares # the dictionary links a room to other rooms rooms = { 'Sally Port': {'West': 'Detective Bureau'}, 'Detective Bureau': {'North': 'Main Lobby', 'East': 'Sally Port'}, 'Main Lobby': {'North': 'Detention Facility', 'South': 'Detective Bureau', 'East': 'Quartermaster', 'West': 'Records'}, 'Records': {'South': 'Evidence Room', 'East': 'Main Lobby'}, 'Evidence Room': {'North': 'Records'}, 'Detention Facility': {'East': 'Arraignment/Interview Room', 'West': 'Detention Facility'}, 'Quartermaster': {'North': 'Weapons Vault', 'West': 'Main Lobby'}, 'Weapons Vault': {'South': 'Quartermaster'}, 'Arraignment/Interview Room': {'West': 'Detention Facility'} } items = { 'Detective Bureau': 'First Aid Kit', 'Main Lobby': 'Vault Key', 'Records': '8x Shotgun Shells', 'Quartermaster': 'Winchester SXP Defender Shotgun', 'Weapons Vault': 'Red Sapphire', 'Detention Facility': 'Arraignment/Interview Room Key Card', 'Arraignment/Interview Room': 'Boss Ptazerack', 'Sally Port': 'NULL', 'Evidence Room': 'NULL' } state = 'Sally Port' inventory = [] # now we get into the games function def get_new_state(state, direction): new_state = state for i in rooms: if i == state: if direction in rooms[i]: # to assign a new room new_state = rooms[i][direction] Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
