Add a “bomb” in the Dining Room. If the player types bomb in the Dining Room, the bomb goes in the hand. If the player types bomb in the upstairs where the Ogre is, the bomb is dropped and the Ogre is blasted to smithereens.
Note: This question assumes that the upstairs room has an ogre in it, so the answer will need to add that. Additionally, as its not possible to get up the stairs without the key and the play can only hold one object at a time, this question requires that a variable be added to check if the stairs have been unlocked.
```
#The variable to track if the stair has been unlocked
stairsUnlocked = false
#Whether or not ogre is alive or not
ogreAlive = true
#This method prints the description for the Kitchen
def showKitchen ():
global ghost
global stairsUnlocked
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" and not stairsUnlocked:
printNow("You notice a hidden, locked door to the west.")
printNow("Good thing you found that key.")
elif stairsUnlocked:
printNow("There's a hidden, unlocked door to the west.")
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.")
#showLR prints the description of the LivingRoom
def showLR():
printNow("You are in a living room.")
printNow("There are couches, chairs, and small tables.")
printNow("Everything is covered in dust and spider webs.")
printNow("You hear a crashing noise in another room.")
printNow("You can go north or west.")
if not hand=="Key" and not stairsUnlocked:
printNow("There is a key here.")
#showDR prints the description of the DiningRoom
def showDR():
printNow("You are in the dining room.")
printNow("There are remains of a meal on the table.")
printNow(" You can't tell what it is,")
printNow(" and maybe don't want to.")
printNow("Was that a thump to the west?")
printNow("You can go south or west")
if not hand == "Bomb" and ogreAlive:
printNow("You spot a bomb on the table.")
#showMR prints the description of the MysteryRoom
def showMR():
global ogreAlive
if not ogreAlive:
printNow("Smithereens that used to be an Orge are here.")
else:
printNow("A fearsome Orge sits at the top of the stairs.")
printNow("You can go down to the Stairs.")
#This method actually parses user directions to determine what changes should occur
def pickRoom(direction , room):
global hand
global stairsUnlocked
global ogreAlive
#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" or stairsUnlocked):
stairsUnlocked = true
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"
elif direction == "bomb" or direction=="Bomb":
hand = "Bomb"
return "DiningRoom"
#"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 direction == "Bomb" or direction=="bomb":
printNow("You drop the bomb, blasting the ogre into smithereens.")
ogreAlive = false
return "MysteryRoom"
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
```
You might also like to view...
Which of the following is NOT true in regard to crosstab queries?
A) Crosstab queries can be a useful way to present data in a compact and summarized format. B) Crosstab queries are the same type of query as those which perform aggregate functions. C) Crosstab queries are useful for summarizing data, calculating statistics, identifying bad data, and looking for trends. D) A crosstab query is a special type of query that can be created when you want to describe one number in terms of two other numbers.
A(n) ________ is a method you would use to organize text into levels of importance in a structure
A) gallery B) style C) hierarchy D) section