Create the ability to go down from the Porch, to explore a secret underground world.
What will be an ideal response?
Note: An answer does not need to include any hint in the porch description that the player can go down.
```
#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()
#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.")
#showUW prints the description of the secret Underground World (UndergroundWorld)
def showUW():
printNow("You are in a vast underground cavern.")
printNow("You can go up to the Porch.")
#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"
#"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"
#"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"
#This last section handles invalid commands
printNow("You can't (or don't want to) go in that direction.")
return room
```
You might also like to view...
Character literals are enclosed in __________ and string literals are enclosed in __________.
a. single quotes, double quotes b. double quotes, single quotes c. single quotes, single quotes d. double quotes, double quotes
A function can ______ a value to indicate success or failure.
a. pass b. set c. return d. none of the above
The ____________________ property provides an easy-to-use visual pathway to facilitate accurate data entry.
Fill in the blank(s) with the appropriate word(s).
A doubly linked list is a linked list structure in which each node has a pointer to both its successor and its successor's successor.
Answer the following statement true (T) or false (F)