Create a new adventure game based on this map. Think Lord of the Rings or maybe Game of Thrones. The player should start on the drawbridge.

Let’s start over with a new map. Below is a map of a castle.

Note: This question requires recreation of the entire adventure game in this new setting, meaning new variables and new methods, as seen below. Additionally, each room should have at least some manner of description.

```
#Different room string values
drawbridge = "Drawbridge"
gate = "Gate"
courtyard = "Courtyard"
kitchens = "Kitchens"
stables = "Stables"
hallway = "Hallway"
pr = "PrincessRoom"
kr = "KingsRoom"
wr = "WizardsRoom"
skr= "SirKnightsRoom"
exitLoc = "Exit"

def playGame ():
#The initial location of the player
location = drawbridge
showIntroduction() #Shows the intro text
#Continue to run the game until the exit is reached
#Each loop the current room is shown, a direction is requested,
#and a new location is determined based on the direction
while not (location == exitLoc) :
showRoom(location)
direction = requestString("Which direction?")
printNow("You typed: "+direction)
location = pickRoom(direction, location)

def showIntroduction ():
printNow("Welcome to the Dark Castle!")
printNow("In each room, you will be told")
printNow(" which directions you can go.")
printNow("You can move north, south, east, or west")
printNow(" by typing that direction.")
printNow("Type help to replay this introduction.")
printNow("Type quit or exit to end the program.")
#This method just prints out the description for the current rooms
def showRoom(room):
printNow("===========")
if room ==drawbridge:
showDrawbridge()
elif room == gate:
showGate()
elif room ==courtyard:
showCourtyard()
elif room==kitchens:
showKitchens()
elif room==stables:
showStables()
elif room==hallway:
showHallway()
elif room==pr:
showPR()
elif room == kr:
showKR()
elif room == skr:
showSKR()
elif room == wr:
showWR()

#This method prints the description for the Drawbridge
def showDrawbridge():
printNow("You are on the drawbridge before the Dark Castle.")
printNow("Towers like teeth jut into the sky above.")
printNow("You can go north to the castle gate. If you dare.")
#This method prints the description for the Gate
def showGate ():
printNow("You are at the castle gate.")
printNow("You feel a sense of dread.")

printNow("You can see a courtyard to the north")
printNow("The drawbridge is behind you to the south.")
#This method prints the description for the Courtyard
def showCourtyard ():
printNow("You are in the courtyard.")
printNow("There are tattered flags flying, each one ")
printNow(" depicting the wolf's head, the symbol of")
printNow(" the dark castle.")
printNow("To the west are the castle kitchens.")
printNow("To the east are the stables.")
printNow("To the south is the castle gate.")
printNow("To the north is the castle hallway.")

#showKitchens prints the description of the Kitchens
def showKitchens():
printNow("You are in the kitchens.")
printNow("Pots and pans litter the ground. ")
printNow("You can hear the skittering of a rat amongst ")
printNow(" sacks of grain along the wall. ")
printNow("To the east is the courtyard.")

#showStables prints the description of the Stables
def showStables():
printNow("You are in the stables.")
printNow("There's an old gray mare here.")
printNow("She's seen better days.")
printNow("You can go back west to the courtyard.")
#showHallway prints the description of the Hallway
def showHallway():
printNow("You are in a long hallway, suits of armor ")
printNow(" line the walls. You can't shake the feeling")
printNow(" that you're being watched.")
printNow("To the north is the Princess room.")
printNow("To the west is the King's room.")
printNow("To the east is the Sir Knight's room.")
printNow("To the south is the courtyard.")
#showPR prints the description of the PrincessRoom
def showPR():
printNow("You are in the Princess Room.")
printNow("The walls are drenched in bright red ")
printNow(" the Princess is here, and she is watching you.")
printNow("Her gaze is terror.")
printNow("You feel that you should leave.")
printNow("To the south is the hallway.")
#showKR prints the description of the King's Room
def showKR():
printNow("You are in the throneroom of the Dark King.")
printNow("The Dark King lays broken upon his throne of bones. ")
printNow(" He is no longer of the living, yet he is alive.")
printNow("To the east is the hallway.")
printNow("To the south is the Wizard's Room.")
#showSKR prints the description of Sir Knight's Room
def showSKR():
printNow("You are in Sir Knight's Room.")
printNow("A suit of empty armor, and nothing more.")
printNow("To the west is the hallway.")
#showWR prints the description of the Wizard's Room
def showWR():
printNow("You are in the Wizard's Room")
printNow("Cauldrons bubble, beakers fizz, and stacks of books")
printNow(" create dusty pillars. A crow screeches.")
printNow("You can go north to the King's room.")

#This method actually parses user directions to determine what changes should occur
def pickRoom(direction , room):
#Set the direction to the "lower" of the direction
direction = direction.lower()

#This code handles the command that quits the game
if (direction == "quit") or (direction == "exit"):
printNow("Goodbye!")
return exitLoc
#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
#"Drawbridge" room direction handling
if room == drawbridge:
if direction == "north":
return gate
#"Gate" room direction handling
elif room == gate:
if direction == "north":
return courtyard
elif direction == "south":
return drawbridge
#"Courtyard" room direction handling
elif room == courtyard:
if direction == "east":
return stables
elif direction == "south":
return gate
elif direction=="west":
return kitchens
elif direction=="north":
return hallway
#"Kitchens" room direction handling
elif room == kitchens:
if direction == "east":
return courtyard
#"Stables" room direction handling
elif room == stables:
if direction == "west":
return courtyard
#"Hallways" room direction handling
elif room==hallway:
if direction =="north":
return pr
elif direction == "east":
return skr
elif direction == "south":
return courtyard
elif direction == "west":
return kr
#Princess Room direction handling
elif room == pr:
if direction == "south":
return hallway
#Sir Knight's Room direction handling
elif room == skr:
if direction == "west":
return hallway
#King's Room direction handing
elif room == kr:
if direction =="south":
return wr
if direction == "east":
return hallway
#Wizard's Room direction handling
elif room == wr:
if direction =="north":
return kr

#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...

Discuss product assurance with respect to security reviews.

What will be an ideal response?

Computer Science & Information Technology

Write a Java statement to determine the length of a string variable called input. Store the result in an integer variable called strLength.

What will be an ideal response?

Computer Science & Information Technology