Question: You are in the Kitchen Inventory: [ ] ] You see a Liquid Courage Make your next move. Beware The Goblin King! ( North ,
You are in the Kitchen
Inventory:
You see a Liquid Courage
Make your next move. Beware The Goblin King! North South, East, West, 'commands' for commands, 'get' to pick up an item, or 'inventory' to see inventory: move east
You swiftly and silently move East to Great Hall.
You are in the Great Hall
Inventory:
You see a The Goblin King
Make your next move. Beware The Goblin King! North South, East, West, 'commands' for commands, 'get' to pick up an item, or 'inventory' to see inventory:Text based game in python, in my loop, if you enter the room the great hall with out all the items, the king should kill you and end the game. If you have all the items and enter the great hall, you kill the king and end the game. South, south east quickly gets you to the great hall. When I enter with no items, nothing happens. here is the code:
# Rooms dictionary with items
rooms
'Barracks': North: 'Officer Quarters', 'East': 'Courtyard', 'South': 'Stables', 'West': 'Arsenal'
'Arsenal': East: 'Barracks', 'South': 'Armory', 'item': 'Sword'
'Armory': North: 'Arsenal', 'items': 'Armor'
'Stables': North: 'Barracks', 'South': 'Kitchen', 'item': 'Bolts'
'Kitchen': North: 'Stables', 'East': 'Great Hall', 'item': 'Liquid Courage'
'Officer Quarters': East: 'Lookout Tower', 'South': 'Barracks', 'item': 'Shield'
'Lookout Tower': East: 'Main Gate', 'South': 'Courtyard', 'West': 'Officer Quarters', 'item': 'Helmet'
'Main Gate': West: 'Lookout Tower', 'item': 'Spear'
'Courtyard': North: 'Lookout Tower', 'South': 'Great Hall', 'West': 'Barracks', 'item': 'Crossbow'
'Great Hall': North: 'Courtyard', 'West': 'Kitchen', 'villian': 'The Goblin King'
#game intro
multitext
The Goblin King has snuck into your outpost and captured the Lord Regent.
You are woken from your sleep in the barracks by the alarm bells.
Before confronting The Goblin King, you must visit various outpost areas to gather your weapons and arms to defeat The Goblin King and save the Lord Regent.
You do not know which room in the outpost The Goblin King has taken The Lord Regent to
Collect all the weapons and armor in the outpost before facing The Goblin King or he will surely kill you!
Good hunting brave soldier!
printmultitext
# Player inventory
inventory
def displaystatusplayerroom, inventory:
printYou are in the", playerroom
printInventory: inventory
if 'item' in roomsplayerroom:
printYou see a roomsplayerroomitem
print
# List commands
commandlist Move North', 'Move South', 'Move East', 'Move West', 'Get', 'Inventory'
printPlease use the following commands:", commandlist
# Player's starting point
playerroom 'Barracks'
#Gameover
gameover False
winlose
# Movement loop
while not gameover:
displaystatusplayerroom, inventory
# Get player command
move inputfMake your next move. Beware The Goblin King! North South, East, West, 'commands' for commands, 'get' to pick up an item, or 'inventory' to see inventory: striplower
# Commands
if move 'command':
printPlease use the following commands:", commandlist
elif move in move north', 'move south', 'move east', 'move west':
direction move.splitcapitalize
if direction in roomsplayerroom:
playerroom roomsplayerroomdirection
printfYou swiftly and silently move direction to playerroom
else:
printfYou bang your head on the wall. You can't go direction from the playerroom
elif move 'get':
if 'item' in roomsplayerroom and roomsplayerroomitem:
items roomsplayerroompopitem # Remove the item from the room
inventory.appenditems # Add the item to the inventory
printfYou have added, items to your inventory!"
else:
printThere are no items to pick up in this room."
elif move 'inventory':
printYour inventory:"
for item in inventory:
printitem
elif leninventory and playerroom 'Great Hall':
printfYou have slain The Goblin King! You have saved The Lord Regent! Huzzah!"
winlose
gameover True
elif leninventory and playerroom 'Great Hall':
printfThe Goblin King dispatches you with ease. The Lord Regent must wait for another braver soldier to attempt is rescue..."
winlose
gameover True
else:
printInvalid command. Please enter a valid command."
if winlose :
printYou smited your enemy! Thank you for playing"
if winlose :
printYou have been defeated! Learn from your mistakes and try again. Thank you for playing!"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
