Add the ability for the player to lose the game (perhaps die). When the player loses, the game should print what happened, and then the game exits. Perhaps finding the Ogre without the bomb in the player’s hand will make the player lose the game.

What will be an ideal response?

Note: The only change necessary for this answer should be to pickRoom.

```
#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":
if hand=="Bomb":
return "MysteryRoom"
else:
printNow("===========")
printNow("You get to the top of the stairs ")
printNow(" only to find a hungry Ogre. Without a ")
printNow(" weapon to fend him off, he gobbles you up.")
printNow("The End.")
return "Exit"
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
```

Computer Science & Information Technology

You might also like to view...

Arduino boards are reasonably inexpensive

Indicate whether the statement is true or false

Computer Science & Information Technology

The ping command uses ARP requests. True or false?

a. True b. False

Computer Science & Information Technology