Add additional secret items to have in the player’s hand to allow different rooms to be accessed, such as a lantern to allow access to a tunnel under the Porch.

What will be an ideal response?


Note: An answer needs to have at least two items added. In this case the answer adds a lantern as described and a crowbar to access a secret storage area in the kitchen.

```
#This method just prints out the description for the current rooms
def showRoom(room):
printNow("===========")
if room =="Porch":
showPorch()
elif room == "Entryway":
showEntryway()
elif room =="Kitchen":
showKitchen()
elif room=="LivingRoom":
showLR()
elif room=="DiningRoom":
showDR()
elif room=="Stairs":
showStairs()
elif room=="MysteryRoom":
showMR()
elif room == "UndergroundWorld":
showUW()
elif room == "Tunnel":
showTunnel()
elif room == "Storage":
showStorage()

#This method prints the description for the Porch
def showPorch():
printNow("You are on the porch of a frightening looking house.")
printNow("The windows are broken. It's a dark and stormy night.")
printNow("You can go north into the house. If you dare.")
printNow("You can hear something down below.")
if not hand=="Lantern":
printNow("You see a lantern in a corner of the porch")
#This method prints the description for the Kitchen
def showKitchen ():
global ghost
printNow("You are in the kitchen. ")
printNow("All the surfaces are covered with pots,")
printNow(" pans, food pieces, and pools of blood.")
printNow("You think you hear something up the stairs")
printNow(" that go up the west side of the room.")
printNow("It's a scraping noise, like something being dragged")
printNow(" along the floor.")
#This section adds a description if the ghost is "in" the room
if ghost ==1:
printNow("You see the mist you saw earlier.")
printNow("But now it's darker, and red.")
printNow("The moan increases in pitch and volume")
printNow(" so now it sounds more like a yell!")
printNow("Then it's gone.")
#This sets the ghost to be "in" the Entryway
ghost = 0

if hand=="Key":
printNow("You notice a hidden, locked door to the west.")
printNow("Good thing you found that key.")
if not hand == "Crowbar":
printNow("You spot a crowbar among the pots")
else:
printNow("A chunk of wall to the north seems odd ")
printNow(" with the crowbar you may be able to open it.")
printNow("You can go to the south or east.")
#showUW prints the description of the secret Underground World (UndergroundWorld)
def showUW():
printNow("You are in a vast underground world.")
if hand == "Lantern":
printNow("The lantern reveals a tunnel to the north")
printNow("You can go up to the Porch.")

#showTunnel prints the description of the tunnel off the underground world
def showTunnel():
printNow("You are in a dark, twisting tunnel")
printNow("You can go south to the Underground World.")

#showStorage prints the description of the storage
def showStorage():
printNow("You are in a small storage area.")
printNow("You can go south to the Kitchen.")
#This method actually parses user directions to determine what changes should occur
def pickRoom(direction , room):
global hand
#This code handles the command that quits the game
if (direction == "quit") or (direction == "exit"):
printNow("Goodbye!")
return "Exit"
#This section handles the help command which displays the introduction text again
if direction == "help":
showIntroduction()
return room

#The section below checks each room, then checks the possible directions in the room

#"Porch" room direction handling
if room == "Porch":
if direction == "north":
return "Entryway"
elif direction == "down":
return "UndergroundWorld"
elif direction == "Lantern" or direction == "lantern":
hand = "Lantern"
return "Porch"
#"Entryway" room direction handling
elif room == "Entryway":
if direction == "north":
return "Kitchen"
elif direction == "east":
return "LivingRoom"
elif direction == "south":
return "Porch"
#"Kitchen" room direction handling
elif room == "Kitchen":
if direction == "east":
return "DiningRoom"
elif direction == "south":
return "Entryway"
elif direction=="west" and hand=="Key":
return "Stairs"
elif direction=="north" and hand=="Crowbar":
return "Storage"
elif direction == "Crowbar" or direction == "crowbar":
hand = "Crowbar"
return "Kitchen"
#"Livingroom" room direction handling
elif room == "LivingRoom":
if direction == "west":
return "Entryway"
elif direction == "north":
return "DiningRoom"
elif direction == "key" or direction == "Key":
hand = "Key"
return "LivingRoom"
#"DiningRoom" room direction handling
elif room == "DiningRoom":
if direction == "west":
return "Kitchen"
elif direction == "south":
return "LivingRoom"
#"Stairs" room direction handling
elif room=="Stairs":
if direction =="east":
return "Kitchen"
elif direction == "up":
return "MysteryRoom"
elif room == "MysteryRoom":
if direction == "down":
return "Stairs"
elif room == "UndergroundWorld":
if direction == "up":
return "Porch"
if direction =="north" and hand=="Lantern":
return "Tunnel"
elif room == "Tunnel":
if direction =="south":
return "UndergroundWorld"
elif room == "Storage":
if direction =="south":
return "Kitchen"

#This last section handles invalid commands
printNow("You can't (or don't want to) go in that direction.")
return room
```

Computer Science & Information Technology

You might also like to view...

To print more than one copy of a document, use the ____________________ spin box.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

The first thing you must do after creating a user is set the password.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

When a workbook is opened and the message "File in Use" appears, the workbook is ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

The default join type for a query with two tables in a one-to-many relationship is the outer join. _________________________

Answer the following statement true (T) or false (F)

Computer Science & Information Technology