#Final Project
#Group members: Moises, Nicholas, and Sean
#December 13, 2016
#CST 205

# ---------Change getSoundsDict and getImagesDict file paths---------
# ---------------------This will change all paths--------------------
soundsDir = "C:\\Users\\Moises\\Desktop\\GitHub\\Immersive-Text-Game-Project\\resources\\sounds\\"
imagesDir = "C:\\Users\\Moises\\Desktop\\GitHub\\Immersive-Text-Game-Project\\resources\\images\\"

#-------------------------------------------Game Code-------------------------------------------
# Adventure Game Updates
# This is the updated adventure game which asks for user input to move east, west, south, or north
def adventure():
  global name, validMoves, validActions, sounds, messages, images, inven
  # Room sounds
  sounds = getSoundsDict()
  play(sounds["start"])
  # Ask name
  name = askName()
  if(name == "exit"):
    i = 0
    for key, sound in sounds.iteritems():
      try:
        stopPlaying(sound)
      except:
        continue
    showInformation("~~You have quit the game.~~")
    return
  # Room messages
  messages = getMessagesDict()
  # Room messages
  images = getImagesDict()
  # Inventory
  inven = {"flashlight": false, "batteries": false, "keyHouse": false, "radio": false, "keyDiner": false, "notepad":false}
  # default values
  validMoves = ["north","south","east","west","left","right","n","s","e","w","l","r"]
  validActions = ["hide","jump","crawl","wait","h","j","c","w"]
  image = makeEmptyPicture(getWidth(images["bedroom"]), getHeight(images["bedroom"]), black)
  # Begin first stage
  result = firstStage(image)
  stopPlaying(sounds["start"])
  # Continue to next stage
  if result == "won":
    move = ""
    while move!="exit":
      # Begin next level
      showInformation("[Next Stage]")
      copyInto(images["startNext"], image, 0, 0)
      repaint(image)
      play(sounds["startNext"])
      showInformation(messages["startNext"])
      stopPlaying(sounds["startNext"])
      # Ask left/right
      move = askMove("lr", "You can go left or right.")
      if move == "l":
        result = leftStage(image)
        break
      elif move == "r":
        result = rightStage(image)
        break
      elif move == "help":
        showInformation(messages["help"])
      elif move in ["i","inventory"]:
        getInventory()
  if result == "quit":
    showInformation(messages["quitGame"])
  # End sounds
  for key, sound in sounds.iteritems():
      try:
        stopPlaying(sound)
      except:
        continue

#------------------------ First Stage ------------------------
def firstStage(image):
  global inven
  # Begin game
  showInformation(messages["help"])
  play(sounds["intro"])
  showInformation(messages["intro"])
  stopPlaying(sounds["intro"])
  move = ""
  flashlightOn = false
  location = 3 # bedroom
  while move != "exit":
    # Check flashlight
    if inven["flashlight"] == true and inven["batteries"] == true:
      flashlightOn = true
    else:
      flashlightOn = false
    # Check if user asked for help
    if move == "help":
      showInformation(messages["help"])
    # Show Inventory
    if move in ["i","inventory"]:
      getInventory()
    # Closet
    if location == 1:
      if inven["flashlight"] == true:
        copyInto(images["closetTook"], image, 0, 0)
        repaint(image)
      else:
        copyInto(images["closet"], image, 0, 0)
        repaint(image)
      play(sounds["closet"])
      showInformation(messages["closet"])
      stopPlaying(sounds["openClose"])
      stopPlaying(sounds["closet"])
      if inven["flashlight"] == false:
        response = askFL(image)
        if response == "true":
          copyInto(images["closetTook"], image, 0, 0)
          repaint(image)
          inven["flashlight"] = true
        if response in ["exit", "help", "i", "inventory"]:
          move = response
          continue
      move = askMove("n", "You can move north.")
      if move == "n":
        play(sounds["openClose"])
        location += 1
    # Bedroom South
    elif location == 2:
      copyInto(images["bedroomSouth"], image, 0, 0)
      repaint(image)
      play(sounds["bedroomSouth"])
      showInformation(messages["bedroomSouth"])
      stopPlaying(sounds["bedroomSouth"])
      stopPlaying(sounds["openClose"])
      move = askMove("ns", "You can move north or south.")
      if move == "n":
        location += 1
      elif move == "s":
        play(sounds["openClose"])
        location -= 1
    # Bedroom
    elif location == 3:
      copyInto(images["bedroom"], image, 0, 0)
      repaint(image)
      play(sounds["bedroom"])
      showInformation(messages["bedroom"])
      stopPlaying(sounds["bedroom"])
      move = askMove("ns", "You can move north or south.")
      if move == "n":
        location += 1
      elif move == "s":
        location -= 1
    # Bedroom North
    elif location == 4:
      copyInto(images["bedroomNorth"], image, 0, 0)
      repaint(image)
      play(sounds["bedroomNorth"])
      showInformation(messages["bedroomNorth"])
      stopPlaying(sounds["bedroomNorth"])
      stopPlaying(sounds["openClose"])
      move = askMove("nse","You can move north, south, or east.")
      if move == "n":
        play(sounds["openClose"])
        location += 2
      elif move == "s":
        location -= 1
      elif move == "e":
        play(sounds["openClose"])
        location += 1
    # Bathroom
    elif location == 5:
      if inven["keyHouse"] == true:
        if flashlightOn:
          copyInto(flashLightFilter(images["bathroomTook"]), image, 0, 0)
        else:
          copyInto(images["bathroomTook"], image, 0, 0)
        repaint(image)
      else:
        if flashlightOn:
          copyInto(flashLightFilter(images["bathroom"]), image, 0, 0)
        else:
          copyInto(images["bathroom"], image, 0, 0)
        repaint(image)
      play(sounds["bathroom"])
      showInformation(messages["bathroom"])
      stopPlaying(sounds["openClose"])
      stopPlaying(sounds["bathroom"])
      if inven["keyHouse"] == false:
        copyInto(images["bathroomFoundKey"], image, 0, 0)
        repaint(image)
        response = askKey()
        if response == "true":
          copyInto(images["bathroomFoundKeyTook"], image, 0, 0)
          repaint(image)
          inven["keyHouse"] = true
        if response in ["exit", "help", "i", "inventory"]:
          move = response
          continue
      move = askMove("w", "You can move west.")
      if move == "w":
        play(sounds["openClose"])
        location -= 1
    # Hall South
    elif location == 6:
      if flashlightOn:
        copyInto(flashlightFilter(images["hallSouth"]), image, 0, 0)
      else:
        copyInto(images["hallSouth"], image, 0, 0)
      repaint(image)
      play(sounds["hallSouth"])
      showInformation(messages["hallSouth"])
      stopPlaying(sounds["openClose"])
      stopPlaying(sounds["hallSouth"])
      move = askMove("ns","You can move north or south.")
      if move == "n":
        location += 1
      elif move == "s":
        location -= 2
    # Hall North
    elif location == 7:
      if flashlightOn:
        copyInto(flashlightFilter(images["hallNorth"]), image, 0, 0)
      else:
        copyInto(images["hallNorth"], image, 0, 0)
      repaint(image)
      play(sounds["hallNorth"])
      showInformation(messages["hallNorth"])
      stopPlaying(sounds["openClose"])
      stopPlaying(sounds["hallNorth"])
      move = askMove("nse", "You can move north, south, or east.")
      if move == "n":
        play(sounds["lockedDoor"])
        showInformation("\n~The door is locked.~")
        stopPlaying(sounds["lockedDoor"])
        if inven["keyHouse"]==true:
          response = askUseKey()
          if response == "true":
            play(sounds["useKey"])
            showInformation("You place the key in the lock. You struggle a bit...It works, you opened the door!")
            stopPlaying(sounds["useKey"])
            location += 1
          elif response in ["exit", "help", "i", "inventory"]:
            move = response
            continue
      elif move == "s":
        location -= 1
      elif move == "e":
        play(sounds["stairs"])
        showInformation("\n~You are walking down the curved stairs~")
        stopPlaying(sounds["stairs"])
        location += 3
    # Master Bedroom
    elif location == 8:
      if flashlightOn:
        copyInto(flashlightFilter(images["masterBedroom"]), image, 0, 0)
      else:
        copyInto(images["masterBedroom"], image, 0, 0)
      repaint(image)
      play(sounds["masterBedroom"])
      showInformation(messages["masterBedroom"])
      stopPlaying(sounds["balconyClose"])
      stopPlaying(sounds["masterBedroom"])
      move = askMove("sw", "You can move south or west.")
      if move == "s":
        play(sounds["lock"])
        showInformation("You make sure to lock the door before you leave the room.")
        stopPlaying(sounds["lock"])
        play(sounds["openClose"])
        location -= 1
      elif move == "w":
        location += 1
    # Balcony
    elif location == 9:
      if flashlightOn:
        copyInto(flashlightFilter(images["balcony"]), image, 0, 0)
      else:
        copyInto(images["balcony"], image, 0, 0)
      repaint(image)
      play(sounds["balcony"])
      showInformation(messages["balcony"]) # Clue
      stopPlaying(sounds["balcony"])
      move = askMove("e","You can move east.")
      if move == "e":
        play(sounds["balconyClose"])
        location -= 1
    # Stairs/Foyer
    elif location == 10:
      if inven["batteries"] == true:
        if flashlightOn:
          copyInto(flashlightFilter(images["foyerTook"]), image, 0, 0)
        else:
          copyInto(images["foyerTook"], image, 0, 0)
        repaint(image)
      else:
        if flashlightOn:
          copyInto(flashlightFilter(images["foyer"]), image, 0, 0)
        else:
          copyInto(images["foyer"], image, 0, 0)
        repaint(image)
      play(sounds["foyer"])
      showInformation(messages["foyer"])
      stopPlaying(sounds["openClose"])
      stopPlaying(sounds["foyer"])
      move = askMove("nsew", "You can move north, south, east, or west.")
      if move == "n":
        play(sounds["openClose"])
        location += 3
      elif move == "s":
        play(sounds["stairs"])
        showInformation("\n~You are walking up the curved stairs~")
        stopPlaying(sounds["stairs"])
        location -= 3
      elif move == "e":
        location += 2
      elif move == "w":
        location += 1
    # Broken Pots
    elif location == 11:
      copyInto(images["brokenLose"], image, 0, 0)
      repaint(image)
      play(sounds["brokenLose"])
      showInformation(messages["brokenLose"])
      stopPlaying(sounds["brokenLose"])
      copyInto(gameOver(image), image, 0, 0)
      play(sounds["gameOver"])
      repaint(image)
      showInformation(messages["loser"])
      stopPlaying(sounds["gameOver"])
      return "lost"
    # Archway
    elif location == 12:
      if inven["batteries"] == true:
        if flashlightOn:
          copyInto(flashlightFilter(images["archwayTook"]), image, 0, 0)
        else:
          copyInto(images["archwayTook"], image, 0, 0)
        repaint(image)
      else:
        if flashlightOn:
          copyInto(flashlightFilter(images["archway"]), image, 0, 0)
        else:
          copyInto(images["archway"], image, 0, 0)
        repaint(image)
      play(sounds["archway"])
      showInformation(messages["archway"])
      stopPlaying(sounds["openClose"])
      stopPlaying(sounds["archway"])
      if inven["batteries"] == false:
        response = askBatteries()
        if response == "true":
          copyInto(images["archwayTook"], image, 0, 0)
          repaint(image)
          inven["batteries"] = true
        if response in ["exit", "help", "i", "inventory"]:
          move = response
          continue
      move = askMove("w", "You can move west.")
      if move == "w":
        location -= 2
    # Wooden Doors
    elif location == 13:
      move = "exit"
      if inven["flashlight"] == true and inven["batteries"] == true:
        response = askUseFL()
        if response == "true":
          copyInto(images["woodenDoorsWin"], image, 0, 0)
          repaint(image)
          play(sounds["woodenDoors"])
          showInformation(messages["win"])
          stopPlaying(sounds["openClose"])
          stopPlaying(sounds["woodenDoors"])
          copyInto(levelComplete(image), image, 0, 0)
          play(sounds["levelComplete"])
          repaint(image)
          showInformation(messages["winnerHouse"])
          stopPlaying(sounds["levelComplete"])
          return "won"
        elif response in ["exit", "help", "i", "inventory"]:
          move = response
          continue
      copyInto(images["woodenDoorsLose"], image, 0, 0)
      repaint(image)
      play(sounds["woodenLose"])
      showInformation(messages["lose"])
      stopPlaying(sounds["openClose"])
      stopPlaying(sounds["woodenLose"])
      copyInto(gameOver(image), image, 0, 0)
      play(sounds["gameOver"])
      repaint(image)
      showInformation(messages["loser"])
      return "lost"
  return "quit"

#------------------------ Left Stage ------------------------
def leftStage(image):
  global inven
  flashlightOn = true
  play(sounds["start"])
  play(sounds["leftIntro"])
  showInformation(messages["leftIntro"])
  stopPlaying(sounds["leftIntro"])
  copyInto(images["leftIntro2"], image, 0, 0)
  play(sounds["leftIntro2"])
  showInformation(messages["leftIntro2"])
  repaint(image)
  showInformation("You pull over the ever "
    + "fainting car and walk into the diner, hoping to find some answers, or at least a sandwich.")
  stopPlaying(sounds["leftIntro2"])
  move = ""
  levelStart = true
  location = 1 # Diner
  while move != "exit":
    # Check if user asked for help
    if move == "help":
      showInformation(messages["help"])
    # Show Inventory
    if move in ["i","inventory"]:
      getInventory()
    # Back to Car
    if location == 0:
      copyInto(images["backToCar"], image, 0, 0)
      repaint(image)
      play(sounds["backToCar"])
      showInformation(messages["backToCar"])
      copyInto(gameOver(images["backToCar"]), image, 0, 0)
      play(sounds["gameOver"])
      repaint(image)
      showInformation(messages["loser"])
      stopPlaying(sounds["backToCar"])
      return "lost"
    # Diner
    elif location == 1:
      if inven["radio"] == true:
        if flashlightOn:
          copyInto(flashlightFilter(images["dinerTook"]), image, 0, 0)
        else:
          copyInto(images["dinerTook"], image, 0, 0)
      else:
        if flashlightOn:
          copyInto(flashlightFilter(images["diner"]), image, 0, 0)
        else:
          copyInto(images["diner"], image, 0, 0)
      repaint(image)
      if levelStart:
        levelStart = false
        play(sounds["creakDiner"])
        play(sounds["diner"])
        showInformation("You press the creaking door open. " + messages["diner"])
      else:
        play(sounds["diner"])
        showInformation(messages["diner"])
      stopPlaying(sounds["creakDiner"])
      stopPlaying(sounds["diner"])
      move = askMove("nsew", "You can move north, south, east, or west.")
      if move == "s":#backToCar
        location -= 1
      elif move == "w":#keyDiner
        location += 1
      elif move == "n":#radio
        location += 2
      elif move == "e":#sideStreet
        showInformation(messages["padlock"])
        if flashlightOn:
          copyInto(flashlightFilter(images["padlock"]), image, 0, 0)
        else:
          copyInto(images["padlock"], image, 0, 0)
        repaint(image)
        play(sounds["lock"])
        showInformation("~The door is locked~")
        stopPlaying(sounds["lock"])
        if inven["keyDiner"] == true:
          response = askUseKey()
          if response == "true":
            play(sounds["useKey"])
            showInformation("You place the key in the lock. You struggle a bit...It works, you opened the door!")
            stopPlaying(sounds["useKey"])
            location += 3
          elif response in ["exit", "help", "i", "inventory"]:
            move = response
            continue
    # Key Diner
    elif location == 2:
      if flashlightOn:
        if inven["keyDiner"] == true:
          copyInto(flashlightFilter(images["keyDinerTook"]), image, 0, 0)
        else:
          copyInto(flashlightFilter(images["keyDiner"]), image, 0, 0)
      else:
        if inven["keyDiner"] == true:
          copyInto(images["keyDinerTook"], image, 0, 0)
        else:
          copyInto(images["keyDiner"], image, 0, 0)
      repaint(image)
      play(sounds["keyDiner"])
      if inven["keyDiner"] == true or flashlightOn == false:
        showInformation(messages["keyDinerTook"])
      else:
        showInformation(messages["keyDiner"])
        stopPlaying(sounds["keyDiner"])
        response = askKeyDiner()
        if response == "true":
          if flashlightOn:
            copyInto(flashlightFilter(images["keyDinerTook"]), image, 0, 0)
          else:
            copyInto(images["keyDinerTook"], image, 0, 0)
          repaint(image)
          inven["keyDiner"] = true
        if response in ["exit", "help", "i", "inventory"]:
          move = response
          continue
      move = askMove("e", "You can move East.")
      if move == "e":#diner
        location -= 1
    # Radio
    elif location == 3:
      if flashlightOn:
        if inven["radio"] == true:
          copyInto(flashlightFilter(images["radioTook"]), image, 0, 0)
        else:
          copyInto(flashlightFilter(images["radio"]), image, 0, 0)
      else:
        if inven["radio"] == true:
          copyInto(images["radioTook"], image, 0, 0)
        else:
          copyInto(images["radio"], image, 0, 0)
      repaint(image)
      play(sounds["radio"])
      if inven["radio"] == true:
        showInformation(messages["radioTook"])
        stopPlaying(sounds["radio"])
      else:
        showInformation(messages["radio"])
        stopPlaying(sounds["radio"])
        response = askRadio()
        if response == "true":
          copyInto(images["radioTook"], image, 0, 0)
          repaint(image)
          inven["radio"] = true
        if response in ["exit", "help", "i", "inventory"]:
          move = response
          continue
      move = askMove("s", "You can move south.")
      if move == "s":#diner
        location -= 2
    # Side Street
    elif location == 4:
      if flashlightOn:
        copyInto(flashlightFilter(images["sideStreet"]), image, 0, 0)
      else:
        copyInto(images["sideStreet"], image, 0, 0)
      repaint(image)
      play(sounds["sideStreet"])
      showInformation(messages["sideStreet"])
      stopPlaying(sounds["sideStreet"])
      move = askMove("ew", "You can move east or west.")
      if move == "w":#diner
        location -= 3
      elif move == "e":#seePolice
        if flashlightOn:
          copyInto(flashlightFilter(images["sideStreetTransition"]), image, 0, 0)
        else:
          copyInto(images["sideStreetTransition"], image, 0, 0)
        repaint(image)
        play(sounds["sideStreet"])
        showInformation("It is really foggy here.")
        stopPlaying(sounds["sideStreet"])
        location += 1
    # See Police
    elif location == 5:
      if flashlightOn:
        copyInto(flashlightFilter(images["policeCar"]), image, 0, 0)
      else:
        copyInto(images["policeCar"], image, 0, 0)
      if inven["notepad"] == true:
        repaint(image)
        play(sounds["policeCarTook"])
        showInformation(messages["policeCarTook"])
        stopPlaying(sounds["policeCarTook"])
      else:
        play(sounds["seePolice"])
        showInformation(messages["seePolice"])
        stopPlaying(sounds["seePolice"])
        repaint(image)
        play(sounds["policeCar"])
        showInformation(messages["policeCar"])
        stopPlaying(sounds["policeCar"])
        response = askNotepad()
        if response == "true":
          inven["notepad"] = true
        if response in ["exit", "help", "i", "inventory"]:
          move = response
          continue
      move = askMove("ew", "You can move east or west.")
      if move == "w":#sideStreet
        if flashlightOn:
          copyInto(flashlightFilter(images["sideStreetTransition"]), image, 0, 0)
        else:
          copyInto(images["sideStreetTransition"], image, 0, 0)
        repaint(image)
        play(sounds["sideStreet"])
        showInformation("It is really foggy here.")
        stopPlaying(sounds["sideStreet"])
        location -= 1
      elif move == "e":#keypad
        if flashlightOn:
          copyInto(flashlightFilter(images["keypad"]), image, 0, 0)
        else:
          copyInto(images["keypad"], image, 0, 0)
        repaint(image)
        play(sounds["keypad"])
        showInformation(messages["keypad"])
        stopPlaying(sounds["keypad"])
        response = askCode()
        if response == "true":
          play(sounds["correctCode"])
          showInformation(messages["correctCode"])
          stopPlaying(sounds["correctCode"])
          location += 1 #policeStation
        elif response == "exit":
          move = response
          continue
        else:
          play(sounds["wrongCode"])
          showInformation(messages["wrongCode"])
          stopPlaying(sounds["wrongCode"])
          showInformation("You start heading back.")
          if inven["radio"] == true:
            location += 2 #loseRadio
    # Police Station
    elif location == 6:
      copyInto(images["policeStation"], image, 0, 0)
      repaint(image)
      play(sounds["policeStation"])
      showInformation(messages["policeStation"])
      stopPlaying(sounds["policeStation"])
      copyInto(images["win2"], image, 0, 0)
      repaint(image)
      play(sounds["win2"])
      showInformation(messages["win2"])
      stopPlaying(sounds["win2"])
      copyInto(levelComplete(image), image, 0, 0)
      play(sounds["levelComplete"])
      repaint(image)
      showInformation(messages["winnerDiner"])
      stopPlaying(sounds["levelComplete"])
      return "won"
    # Lose Radio
    elif location == 7:
      #copyInto(images["radioSound"], image, 0, 0)
      #repaint(image)
      play(sounds["radioSound"])
      showInformation(messages["radioSound"])
      stopPlaying(sounds["radioSound"])
      #copyInto(images["loseRadio"], image, 0, 0)
      #repaint(image)
      play(sounds["loseRadio"])
      showInformation(messages["loseRadio"])
      stopPlaying(sounds["loseRadio"])
      copyInto(gameOver(image), image, 0, 0)
      repaint(image)
      play(sounds["gameOver"])
      showInformation(messages["loser"])
      stopPlaying(sounds["gameOver"])
      return "lost"

#------------------------ Right Stage ------------------------
def rightStage(image):
  global inven
  flashlightOn = true
  play(sounds["start"])
  play(sounds["rightIntro"])
  showInformation(messages["rightIntro"])
  stopPlaying(sounds["rightIntro"])
  copyInto(images["rightIntro2"], image, 0, 0)
  play(sounds["rightIntro2"])
  repaint(image)
  showInformation(messages["rightIntro2"])
  stopPlaying(sounds["rightIntro2"])
  move = ""
  location = 0 # Entryway
  while move != "exit":
    # Check if user asked for help
    if move == "help":
      showInformation(messages["help"])
    # Show Inventory
    if move in ["i","inventory"]:
      getInventory()
    # Entryway
    if location == 0:
      if flashlightOn:
        copyInto(flashlightFilter(images["entryway"]), image, 0, 0)
      else:
        copyInto(images["entryway"], image, 0, 0)
      repaint(image)
      play(sounds["entryway"])
      showInformation(messages["entryway"])
      stopPlaying(sounds["entryway"])
      move = askMove("new", "You can move north, east, or west.")
      if move == "w":#bathroomFactory
        location += 1
      elif move == "e":#supplyCloset
        location += 2
      elif move == "n":#factory
        location += 3
    # Factory Bathroom
    elif location == 1:
      if flashlightOn:
        copyInto(flashlightFilter(images["bathroomFactory"]), image, 0, 0)
      else:
        copyInto(images["bathroomFactory"], image, 0, 0)
      repaint(image)
      play(sounds["openClose"])
      play(sounds["bathroomFactory"])
      showInformation(messages["bathroomFactory"])
      stopPlaying(sounds["bathroomFactory"])
      stopPlaying(sounds["openClose"])
      move = askMove("e", "You can move East.")
      if move == "e":#entryway
        play(sounds["openClose"])
        location -= 1
    # Supply Closet
    elif location == 2:
      if flashlightOn:
        copyInto(flashlightFilter(images["supplyCloset"]), image, 0, 0)
      else:
        copyInto(images["supplyCloset"], image, 0, 0)
      repaint(image)
      play(sounds["openClose"])
      play(sounds["supplyCloset"])
      showInformation(messages["supplyCloset"])
      stopPlaying(sounds["openClose"])
      stopPlaying(sounds["supplyCloset"])
      move = askMove("w", "You can move west.")
      if move == "w":#entryway
        play(sounds["openClose"])
        location -= 2
    # Factory
    elif location == 3:
      if flashlightOn:
        copyInto(flashlightFilter(images["factory"]), image, 0, 0)
      else:
        copyInto(images["factory"], image, 0, 0)
      repaint(image)
      play(sounds["openClose"])
      play(sounds["factory"])
      showInformation(messages["factory"])
      stopPlaying(sounds["openClose"])
      stopPlaying(sounds["factory"])
      move = askMove("ns", "You can move north or south.")
      if move == "s":#entryway
        play(sounds["openClose"])
        location -= 3
      elif move == "n":#asklogs
        if flashlightOn:
          copyInto(flashlightFilter(images["outside"]), image, 0, 0)
        else:
          copyInto(images["outside"], image, 0, 0)
        repaint(image)
        play(sounds["outside"])
        showInformation(messages["outside"])
        stopPlaying(sounds["outside"])
        response = askLogs()
        if response == "true":
          location += 1#logs
        elif response in ["exit", "help", "i", "inventory"]:
          move = response
          continue
        else:
          showInformation("You start walking back inside.")
    # Logs
    elif location == 4:
      if flashlightOn:
        copyInto(flashlightFilter(images["logs"]), image, 0, 0)
      else:
        copyInto(images["logs"], image, 0, 0)
      repaint(image)
      play(sounds["logs"])
      showInformation(messages["logs"])
      stopPlaying(sounds["logs"])
      move = askActions("hj", "You can hide or jump.")
      if move == "j":#jump
        location += 1
      elif move == "h":#hide
        location += 2
    # Jump
    elif location == 5:
      if flashlightOn:
        copyInto(flashlightFilter(images["jump"]), image, 0, 0)
      else:
        copyInto(images["jump"], image, 0, 0)
      repaint(image)
      play(sounds["jump"])
      showInformation(messages["jump"])
      stopPlaying(sounds["jump"])
      copyInto(gameOver(images["jump"]), image, 0, 0)
      play(sounds["gameOver"])
      repaint(image)
      showInformation(messages["loser"])
      stopPlaying(sounds["gameOver"])
      return "lost"
    # Hide
    elif location == 6:
      copyInto(images["hide"], image, 0, 0)
      repaint(image)
      play(sounds["hide"])
      showInformation(messages["hide"])
      stopPlaying(sounds["hide"])
      move = askActions("cw", "You can crawl or wait.")
      if move == "c":#crawl
        copyInto(images["crawl"], image, 0, 0)
        repaint(image)
        play(sounds["crawl"])
        showInformation(messages["crawl"])
        stopPlaying(sounds["crawl"])
        copyInto(gameOver(images["crawl"]), image, 0, 0)
        play(sounds["gameOver"])
        repaint(image)
        showInformation(messages["loser"])
        stopPlaying(sounds["gameOver"])
      elif move == "w":#wait
        copyInto(images["wait"], image, 0, 0)
        repaint(image)
        play(sounds["wait"])
        showInformation(messages["wait"])
        stopPlaying(sounds["wait"])
        copyInto(gameOver(images["wait"]), image, 0, 0)
        play(sounds["gameOver"])
        repaint(image)
        showInformation(messages["loser"])
        stopPlaying(sounds["gameOver"])
      return "lost"
      
# This function tells the user there is a flashlight and asks if the user will take it
def askFL(image):
  copyInto(images["closetFoundFL"], image, 0, 0)
  repaint(image)
  play(sounds["closetFoundFL"])
  showInformation("You open the bag and notice a flashlight. You grab it but it has no batteries.")
  stopPlaying(sounds["closetFoundFL"])
  while true:
    userInput = requestString("Would you like to take it with you?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in ["yes", "y"]:
      showInformation("~~You now have a flashlight!~~")
      return "true"
    if userInput in ["no", "n"]:
      return "false"
    if userInput in ["exit", "help", "i", "inventory"]:
      return userInput
    showInformation("That's not a good answer " + name + ", you can either say yes or no.")

# This function tells the user there is a key and asks if the user will pick it up
def askKey():
  play(sounds["bathroomFoundKey"])
  showInformation("At the bottom of the tub you notice a shiny piece of metal. You walk over. It's a key!")
  stopPlaying(sounds["bathroomFoundKey"])
  while true:
    userInput = requestString("Would you like to get the key?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in ["yes", "y"]:
      play(sounds["bathroomGotKey"])
      showInformation("~~You now have a key!~~")
      stopPlaying(sounds["bathroomGotKey"])
      return "true"
    if userInput in ["no", "n"]:
      return "false"
    if userInput in ["exit", "help", "i", "inventory"]:
      return userInput
    showInformation("That's not a good answer " + name + ", you can either say yes or no.")

# This function tells the user there is a key and asks if the user will pick it up
def askKeyDiner():
  while true:
    userInput = requestString("Would you like to get the key?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in ["yes", "y"]:
      play(sounds["keyDinerGotKey"])
      showInformation("~~You now have a key!~~")
      stopPlaying(sounds["keyDinerGotKey"])
      return "true"
    if userInput in ["no", "n"]:
      return "false"
    if userInput in ["exit", "help", "i", "inventory"]:
      return userInput
    showInformation("That's not a good answer " + name + ", you can either say yes or no.")

# This function tells the user there are batteries and asks if the user will pick them up
def askBatteries():
  play(sounds["archwayFoundBatteries"])
  showInformation("Walking around you step on something. Its a couple of batteries lying on the floor.")
  stopPlaying(sounds["archwayFoundBatteries"])
  while true:
    userInput = requestString("Would you like to pick them up?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in ["yes", "y"]:
      showInformation("~~You now have batteries!~~")
      return "true"
    if userInput in ["no", "n"]:
      return "false"
    if userInput in ["exit", "help", "i", "inventory"]:
      return userInput
    showInformation("That's not a good answer " + name + ", you can either say yes or no.")

# This function tells the user there is a red radio and asks if the user will take it
def askRadio():
  while true:
    userInput = requestString("Would you like to take the red radio?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in ["yes", "y"]:
      showInformation("~~You now have a red radio!~~")
      return "true"
    if userInput in ["no", "n"]:
      return "false"
    if userInput in ["exit", "help", "i", "inventory"]:
      return userInput
    showInformation("That's not a good answer " + name + ", you can either say yes or no.")

# This function tells the user there is a notepad and asks if the user will take it
def askNotepad():
  while true:
    userInput = requestString("You reach and pick up the notepad. Would you like to take it with you?")
    try:
      userInput = userInput.lower()
    except:
      showInformation("You put the notepad back.")
      userInput = "exit"
    if userInput in ["yes", "y"]:
      showInformation("~~You now have a notepad!~~")
      return "true"
    showInformation("You put the notepad back.")
    if userInput in ["no", "n"]:
      return "false"
    if userInput in ["exit", "help", "i", "inventory"]:
      return userInput
    showInformation("That's not a good answer " + name + ", you can either say yes or no.")

# This function asks the user if they would like to use the key if they found the key
def askUseKey():
  while true:
    userInput = requestString("Would you like to try using the key?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in ["yes", "y"]:
      return "true"
    if userInput in ["no", "n"]:
      return "false"
    if userInput in ["exit", "help", "i", "inventory"]:
      return userInput
    showInformation("That's not a good answer " + name + ", you can either say yes or no.")

# This function asks the user if they would like to use the flashlight if they found it
def askUseFL():
  while true:
    userInput = requestString("Your flashlight switched off and it is incredibly dark out here. Would you like to turn the flashlight back on?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in ["yes", "y"]:
      return "true"
    if userInput in ["no", "n"]:
      return "false"
    if userInput in ["exit", "help", "i", "inventory"]:
      return userInput
    showInformation("That's not a good answer " + name + ", you can either say yes or no.")

# Asks the user for the their name.
def askName():
  while true:
    tempInput = requestString("Please enter your name:")
    try:
      userInput = tempInput.lower()
    except:
      userInput = "exit"
    if userInput == "":
      showInformation("Name must be at least one character.")
    elif userInput == "exit":
      return "exit"
    elif userInput == "help":
      showInformation(messages["help"])
    else:
      return tempInput

# Asks the user for keypad code.
def askCode():
  while(true):
    userInput = requestString("Please enter code:")
    try:
      userInput = userInput.lower()
    except:
      return "exit"
    if userInput == "4825":
      return "true"
    elif userInput in ["i", "inventory"]:
      getInventory()
      continue
    elif userInput == "help":
      showInformation(messages["help"])
      continue
    else:
      return userInput

# Asks the user to go to the logs
def askLogs():
  while true:
    userInput = requestString("Would you like to go into the logs?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in ["yes", "y"]:
      return "true"
    if userInput in ["no", "n"]:
      return "false"
    if userInput in ["exit","help", "i", "inventory"]:
      return userInput
    showInformation("That's not a good answer " + name + ", you can either say yes or no.")

# This function asks the user what direction he/she will move.
# The user may also ask for help or exit
def askMove(directions, text):
  userInput = ""
  while(userInput != "exit" and userInput != "help"):
    userInput = requestString(text + " Where do you want to move?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in validMoves:
      userInput = userInput[0]
      if userInput in directions:
        return userInput
    if userInput in ["i","inventory"]:
      return userInput
    if userInput != "help" and userInput != "exit":
      showInformation("That is not an option " + name + ".[If you're having trouble? type: help]")
  return userInput

# This function asks the user what direction he/she will move.
# The user may also ask for help or exit
def askActions(actions, text):
  userInput = ""
  while(userInput != "exit" and userInput != "help"):
    userInput = requestString(text + " What do you want to do?")
    try:
      userInput = userInput.lower()
    except:
      userInput = "exit"
    if userInput in validActions:
      userInput = userInput[0]
      if userInput in actions:
        return userInput
    if userInput in ["i","inventory"]:
      return userInput
    if userInput != "help" and userInput != "exit":
      showInformation("That is not an option " + name + ".[If you're having trouble? type: help]")
  return userInput
  
#------------------------ Image Code ------------------------
#Darkens all color values in a picture.
def darken(originalPic):
 pic = copy(originalPic)
 pixels = getPixels(pic)
 for p in pixels:
  darkColor = makeDarker(getColor(p))
  setColor(p, darkColor)
 return pic

#Lightens all color values in a circle in the center of an image.
def flashlightFilter(originalPic):
 pic = copy(originalPic)
 circleRadius = min(getHeight(pic), getWidth(pic)) / 2
 for x in range(0, getWidth(pic)):
  for y in range(0, getHeight(pic)):
   #Uses a circle function to detect pixels within a circle of the desired size, then lightens those pixels.
   if (x-(getWidth(pic)/2))**2 + (y-(getHeight(pic)/2))**2 <= (circleRadius-25)**2:
    p = getPixel(pic, x, y)
    lightColor = makeLighter(getColor(p))
    setColor(p, lightColor)
 return pic

#Blurs an image, makes it redder, and adds the text "GAME OVER" to the center.
def gameOver(pic):
 picCopy = copy(pic)
 gameOverPic = moveAndFade(pic, picCopy, 10, factor=4)
 gameOverPic = moreRed(gameOverPic, 50)
 gameOverPic = endText(gameOverPic, "GAME OVER")
 return gameOverPic

#Blurs an image, makes it more yellow, and adds the text "LEVEL COMPLETE" to the center. 
def levelComplete(pic):
 picCopy = copy(pic)
 levelCompletePic = moveAndFade(pic, picCopy, 10, factor=4)
 levelCompletePic = moreYellow(levelCompletePic, 10)
 levelCompletePic = winText(levelCompletePic, "LEVEL COMPLETE")
 return levelCompletePic

#Moves and fades image
def moveAndFade(source, target, distance = 0, moveLeft = false, factor=1):
  targetW = getWidth(target)
  targetH = getHeight(target)
  sourceW = getWidth(source)
  sourceH = getHeight(source)
  if(distance > targetW):
    return target    
  xMax = min(distance + sourceW, targetW)
  yMax = min(sourceH, targetH)
  fadeSize = 50
  x = 0
  for destX in range(distance, xMax):
    y = 0
    for destY in range(0, yMax):
      if(moveLeft):
        p = getPixel(source, xMax-x-1, yMax-y-1)
        destPixel = getPixel(target, xMax-destX-1, yMax-destY-1)
      else:
        p = getPixel(source, x, y)
        destPixel = getPixel(target, destX, destY)
      
      if(x<fadeSize*factor):
        # Create a fade in effect
        tempFactor = x-1
        r = (tempFactor*getRed(p)+fadeSize*getRed(destPixel))/(fadeSize+tempFactor)
        g = (tempFactor*getGreen(p)+fadeSize*getGreen(destPixel))/(fadeSize+tempFactor)
        b = (tempFactor*getBlue(p)+fadeSize*getBlue(destPixel))/(fadeSize+tempFactor)
      else:
        # Copy Average, transparent effect
        r = (factor*getRed(p)+getRed(destPixel))/(factor+1)
        g = (factor*getGreen(p)+getGreen(destPixel))/(factor+1)
        b = (factor*getBlue(p)+getBlue(destPixel))/(factor+1)
      setColor(destPixel, makeColor(r,g,b))
      y += 1
    x += 1
  return target

#Makes a copy of a picture
def copy(pic):
  w = getWidth(pic)
  h = getHeight(pic)
  mypic = makeEmptyPicture(w, h)
  for p in getPixels(pic):
    x = getX(p)
    y = getY(p)
    setColor(getPixel(mypic, x, y), getColor(p))
  return mypic

#Increases red value of pixels by n%.
def moreRed(pic, n):
 #Set n to a decimal number appropriate for increase. (100 increased by 75% is 100*1.75)
 n = (100+n) * 0.01
 pixels = getPixels(pic)
 for p in pixels:
  r = getRed(p)
  r = r * n
  #Max value of r is 255
  if r >= 255:
   setRed(p, 255)
  else:
   setRed(p, r)
 return pic

#Increases yellow color of pixels by n%.
def moreYellow(pic, n = 50.0):
  n = n*.01
  #Adds a yellow tint to a selected picture
  for p in getPixels(pic):
    r = getRed(p)
    g = getGreen(p)
    b = getBlue(p)
    setRed(p, r + (255 - r) * n)
    setGreen(p, g + (255 - g) * n)
    setBlue(p, b + (0 - b) * n)
  return pic


#Adds red "GAME OVER" text to the center of an image.
def endText(pic, string):
 x = (getWidth(pic)/2)-150
 y = (getHeight(pic)/2)-15
 s = makeStyle(sansSerif, italic+bold, 48)
 addTextWithStyle(pic, x, y, string, s, red)
 return pic

#Adds yellow "LEVEL COMPLETE" text to the center of an image.
def winText(pic, string):
 x = (getWidth(pic)/2)-220
 y = (getHeight(pic)/2)-15
 s = makeStyle(sansSerif, italic+bold, 48)
 addTextWithStyle(pic, x, y, string, s, yellow)
 return pic

#------------------------ Inventory ------------------------
def getInventory():
  global inven
  message = "Inventory \n" 
  allFalse = true
  if inven["flashlight"] == true:
    str = "\n A small handheld flashlight. Its light provides some slight comfort within the darkness. \n"
    allFalse = false
    message = message + str
  
  if inven["batteries"] == true:
    str = "\n AA batteries. These seeme to be the correct size for a small flashlight."
    allFalse = false
    message = message + str
  
  if inven["keyHouse"] == true:
    str = "\n \n A small key found in the bathtub. It seems like it might fit a door to a bedroom. \n"
    allFalse = false
    message = message + str
    
  if inven["keyDiner"] == true:
    str = "\n A small key found on a table in the diner. It is very small and seems to be for some type of metal door. \n"
    allFalse = false
    message = message + str
    
  if inven["radio"] == true:
    str = "\n A small red radio. There does not seems to be a way to open the radio to check the batteries. Oddly enough it still seems to make nosies from time to time. \n"
    allFalse = false
    message = message + str
    
  if inven["notepad"] == true:
    str = "\n A notepad. There are a few scribbles that are hard to read but you can clearly read the number 4825. \n"
    allFalse = false
    message = message + str
    
  if allFalse == true:
    str = "\n You do not have anything in your pockets besides lint. \n"
    message = message + str
  showInformation(message)

#------------------------ Sounds ------------------------
def getSoundsDict():
  # Room sounds
  start = makeSound(soundsDir+"Long_Note_Three.wav")
  openClose = makeSound(soundsDir+"openClose.wav")
  intro = makeSound(soundsDir+"intro.wav")
  bedroom = makeSound(soundsDir+"bedroom.wav")
  bedroomSouth = makeSound(soundsDir+"bedroomSouth.wav")
  bedroomNorth = makeSound(soundsDir+"bedroomNorth.wav")
  closet = makeSound(soundsDir+"closet.wav")
  closetFoundFL = makeSound(soundsDir+"closetFoundFL.wav")
  hallSouth = makeSound(soundsDir+"hallSouth.wav")
  hallNorth = makeSound(soundsDir+"hallNorth.wav")
  lockedDoor = makeSound(soundsDir+"lockedDoor.wav")
  lock = makeSound(soundsDir+"lock.wav")
  useKey = makeSound(soundsDir+"useKey.wav")
  bathroom = makeSound(soundsDir+"bathroom.wav")
  bathroomFoundKey = makeSound(soundsDir+"bathroomFoundKey.wav")
  bathroomGotKey = makeSound(soundsDir+"bathroomGotKey.wav")
  masterBedroom = makeSound(soundsDir+"masterBedroom.wav")
  stairs = makeSound(soundsDir+"stairs.wav")
  foyer = makeSound(soundsDir+"foyer.wav")
  balcony = makeSound(soundsDir+"balcony.wav")
  balconyClose = makeSound(soundsDir+"balconyClose.wav")
  archway = makeSound(soundsDir+"archway.wav")
  archwayFoundBatteries = makeSound(soundsDir+"archwayFoundBatteries.wav")
  brokenLose = makeSound(soundsDir+"brokenLose.wav")
  woodenDoors = makeSound(soundsDir+"woodenDoors.wav")
  woodenLose = makeSound(soundsDir+"woodenLose.wav")
  gameOver = makeSound(soundsDir+"gameOver.wav")
  startNext = makeSound(soundsDir+"startNext.wav")
  leftIntro = makeSound(soundsDir+"leftIntro.wav")
  leftIntro2 = makeSound(soundsDir+"leftIntro2.wav")
  creakDiner = makeSound(soundsDir+"creakDiner.wav")
  diner = makeSound(soundsDir+"diner.wav")
  backToCar = makeSound(soundsDir+"backToCar.wav")
  radio = makeSound(soundsDir+"radio.wav")
  keyDiner = makeSound(soundsDir+"keyDiner.wav")
  keyDinerGotKey = makeSound(soundsDir+"keyDinerGotKey.wav")
  sideStreet = makeSound(soundsDir+"sideStreet.wav")
  seePolice = makeSound(soundsDir+"seePolice.wav") 
  policeCar = makeSound(soundsDir+"policeCar.wav")
  policeCarTook = makeSound(soundsDir+"policeCarTook.wav")
  keypad = makeSound(soundsDir+"keypad.wav")
  wrongCode = makeSound(soundsDir+"wrongCode.wav")
  correctCode = makeSound(soundsDir+"correctCode.wav")
  policeStation = makeSound(soundsDir+"policeStation.wav")
  win2 = makeSound(soundsDir+"win2.wav")
  radioSound = makeSound(soundsDir+"radioSound.wav")
  loseRadio = makeSound(soundsDir+"loseRadio.wav")
  rightIntro = leftIntro
  rightIntro2 = makeSound(soundsDir+"rightIntro2.wav")
  entryway = makeSound(soundsDir+"entryway.wav")
  factory = makeSound(soundsDir+"factory.wav")
  supplyCloset = makeSound(soundsDir+"supplyCloset.wav")
  bathroomFactory = makeSound(soundsDir+"bathroomFactory.wav")
  outside = makeSound(soundsDir+"outside.wav")
  logs = makeSound(soundsDir+"logs.wav")
  jump = makeSound(soundsDir+"jump.wav")
  hide = makeSound(soundsDir+"hide.wav")
  crawl = makeSound(soundsDir+"crawl.wav")
  wait = makeSound(soundsDir+"wait.wav")
  levelComplete = makeSound(soundsDir+"levelComplete.wav")
  dict = {"start":start, "openClose": openClose, "closet":closet, "closetFoundFL":closetFoundFL, "bedroomSouth":bedroomSouth,
    "bedroom":bedroom, "bedroomNorth":bedroomNorth, "bathroom":bathroom, "bathroomFoundKey": bathroomFoundKey,
    "bathroomGotKey": bathroomGotKey, "hallSouth":hallSouth, "hallNorth":hallNorth, "lockedDoor":lockedDoor,"lock":lock,
    "useKey":useKey,"masterBedroom":masterBedroom, "balcony":balcony, "balconyClose":balconyClose, "stairs":stairs,
    "foyer":foyer, "brokenLose":brokenLose, "archway":archway, "archwayFoundBatteries":archwayFoundBatteries, "intro":intro,
    "woodenDoors":woodenDoors, "woodenLose":woodenLose, "gameOver":gameOver, "startNext":startNext, "leftIntro":leftIntro,
    "leftIntro2":leftIntro2, "creakDiner":creakDiner, "diner":diner, "backToCar":backToCar, "radio":radio, "keyDiner":keyDiner,
    "keyDinerGotKey":keyDinerGotKey, "rightIntro":rightIntro, "rightIntro2":rightIntro2, "sideStreet":sideStreet,
    "seePolice":seePolice, "policeCar":policeCar, "policeCarTook":policeCarTook, "keypad":keypad,
    "wrongCode":wrongCode, "correctCode":correctCode, "policeStation":policeStation, "win2":win2,
    "radioSound":radioSound, "loseRadio":loseRadio, "rightIntro":rightIntro, "rightIntro2":rightIntro2,
    "entryway":entryway, "factory":factory, "supplyCloset":supplyCloset, "bathroomFactory":bathroomFactory,
    "outside":outside, "logs":logs, "jump":jump, "hide":hide, "crawl":crawl, "wait":wait,
    "levelComplete":levelComplete}
    
  return dict

#------------------------ Images ------------------------
def getImagesDict():
  # Room Images
  bedroom = makePicture(imagesDir+"bedroom.jpg")
  bedroomSouth = makePicture(imagesDir+"bedroomSouth.jpg")
  bedroomNorth = makePicture(imagesDir+"bedroomNorth.jpg")
  closet = makePicture(imagesDir+"closet.jpg")
  closetTook = makePicture(imagesDir+"closetTook.jpg")
  closetFoundFL = makePicture(imagesDir+"closetFoundFL.jpg")
  hallSouth = makePicture(imagesDir+"hallSouth.jpg")
  hallNorth = makePicture(imagesDir+"hallNorth.jpg")
  bathroom = makePicture(imagesDir+"bathroom.jpg")
  bathroomTook = makePicture(imagesDir+"bathroomTook.jpg")
  bathroomFoundKey = makePicture(imagesDir+"bathroomFoundKey.jpg")
  bathroomFoundKeyTook = makePicture(imagesDir+"bathroomFoundKeyTook.jpg")
  masterBedroom = makePicture(imagesDir+"masterBedroom.jpg")
  foyer = makePicture(imagesDir+"foyer.jpg")
  foyerTook = makePicture(imagesDir+"foyerTook.jpg")
  balcony = makePicture(imagesDir+"balcony.jpg")
  archway = makePicture(imagesDir+"archway.jpg")
  archwayTook = makePicture(imagesDir+"archwayTook.jpg")
  brokenLose = makePicture(imagesDir+"brokenLose.jpg")
  woodenDoorsLose = makePicture(imagesDir+"woodenDoorsLose.jpg")
  woodenDoorsWin = makePicture(imagesDir+"woodenDoorsWin.jpg")
  backToCar = makePicture(imagesDir+"backToCar.jpg")
  diner  = makePicture(imagesDir+"diner.jpg")
  dinerTook = makePicture(imagesDir+"dinerTook.jpg")
  keyDiner = makePicture(imagesDir+"keyDiner.jpg")
  keyDinerTook = makePicture(imagesDir+"keyDinerTook.jpg")
  keypad = makePicture(imagesDir+"keypad.jpg")
  leftIntro2 = makePicture(imagesDir+"leftIntro2.jpg")
  padlock = makePicture(imagesDir+"padlock.jpg")
  policeCar = makePicture(imagesDir+"policeCar.jpg")
  policeStation = makePicture(imagesDir+"policeStation.jpg")
  sideStreet = makePicture(imagesDir+"sideStreet.jpg")
  sideStreetTransition = makePicture(imagesDir+"sideStreetTransition.jpg")
  startNext = makePicture(imagesDir+"startNext.jpg")
  radio = makePicture(imagesDir+"radio.jpg")
  radioTook = makePicture(imagesDir+"radioTook.jpg")
  bathroomFactory = makePicture(imagesDir+"bathroomFactory.jpg")
  crawl = makePicture(imagesDir+"crawl.jpg")
  entryway = makePicture(imagesDir+"entryway.jpg")
  factory = makePicture(imagesDir+"factory.jpg")
  hide = makePicture(imagesDir+"hide.jpg")
  jump = makePicture(imagesDir+"jump.jpg")
  logs = makePicture(imagesDir+"logs.jpg")
  outside = makePicture(imagesDir+"outside.jpg")
  policeStation = makePicture(imagesDir+"policeStation.jpg")
  supplyCloset = makePicture(imagesDir+"supplyCloset.jpg")
  supplyClosetTook = makePicture(imagesDir+"supplyClosetTook.jpg")
  wait = makePicture(imagesDir+"wait.jpg")
  rightIntro2 = makePicture(imagesDir+"rightIntro2.jpg")
  win2 = makePicture(imagesDir+"win2.jpg")
  dict = {"bedroom":bedroom, "bedroomSouth":bedroomSouth, "bathroomTook":bathroomTook, "bedroomNorth":bedroomNorth,
    "bathroomFoundKeyTook":bathroomFoundKeyTook, "closet":closet, "closetTook":closetTook, "closetFoundFL":closetFoundFL,
    "hallSouth":hallSouth, "hallNorth":hallNorth, "bathroom":bathroom, "bathroomFoundKey": bathroomFoundKey, "masterBedroom":masterBedroom,
    "foyer":foyer, "foyerTook":foyerTook,"balcony":balcony, "archway":archway, "archwayTook":archwayTook, "backToCar":backToCar,
    "diner":diner, "dinerTook":dinerTook, "keyDiner":keyDiner, "keyDinerTook":keyDinerTook, "keypad":keypad, "leftIntro2":leftIntro2,
    "padlock":padlock, "policeCar":policeCar, "policeStation":policeStation, "sideStreet":sideStreet, "sideStreetTransition":sideStreetTransition,
    "startNext":startNext, "radio":radio, "radioTook":radioTook, "bathroomFactory":bathroomFactory, "crawl":crawl, "entryway":entryway,
    "factory":factory, "hide":hide, "jump":jump, "logs":logs, "outside":outside,"policeStation":policeStation, "supplyCloset":supplyCloset,
    "supplyClosetTook":supplyClosetTook,"wait":wait, "rightIntro2":rightIntro2, "brokenLose":brokenLose,
    "woodenDoorsLose":woodenDoorsLose, "woodenDoorsWin":woodenDoorsWin, "win2":win2}
  
  return dict

#------------------------ Messages ------------------------
# Function to add all the string variables into a directory.  The function returns the directory.
def getMessagesDict():
  # Room messages
  help = "\n***Welcome to the house adventure %s***\n"%name\
    + "The directions that you are allowed to move will be displayed for you once you enter into a room "\
    + "(e.g., north, south, east or west). You must choose by typing the direction that you would like to move. "\
    + "In certain rooms, you may also be able to choose specified actions (e.g., jump, wait, hide). "\
    + "Typing help will display this explanation again. "\
    + "Typing inventory will display any items you currently have in your inventory. "\
    + "Typing exit will exit the game."
  intro = "\nThere is a loud creak of what sounds like wood which causes you to stir from your sleep. "\
    + "As you open your eyes you realize that you are not in your familiar bedroom, in fact you are not even on your bed. "\
    + "You jerk upwards and attempt to figure out where you are, though the room you seem to be in is dark and it is difficult to see. "\
    + "There is moonlight streaming through the windows to your right, which allows you to see what looks to be a switch on the side of the wall. "\
    + "You flip the switch."
  bedroom = "\n-----Bedroom-----\n"\
    + "You find yourself in a small bed room. "\
    + "There are three doors in the bedroom and a small window. "\
    + "There is a small bed and the room is covered in dust. "
  bedroomSouth = "\n-----Bedroom South-----\n"\
    + "You are now in the back of the room standing next to a small door(south). "\
    + "It looks too small to be another room. "\
    + "Across the room (north) are the two doors."
  bedroomNorth = "\n-----Bedroom North-----\n"\
    + "You feel a small cool breeze coming in from under the door to your north. "\
    + "To the east, you can see another door. "\
    + "Across the room (south) is another small door."
  closet = "\n-----Closet-----\n"\
    + "You open the door in the back of the room and find it to be a closet. "\
    + "Inside the closet are some moth eaten sweaters, one that seems to be the remains of one of those holiday sweaters. "\
    + "On the floor there seems to be a small bag."
  hallSouth = "\n-----Hallway South-----\n"\
    + "You find yourself in a dark hallway. The wooden floor is covered in dust and grim. It is very dark. "\
    + "There is a window halfway down the hall that is letting in a cool breeze. "\
    + "Its also letting in some moonlight which allows you to see a staircase going down. "\
    + "You can also faintly make out another door at the end of the hallway (north) past the stairs. "\
    + "You are standing by the bedroom door(south)."
  hallNorth = "\n-----Hallway North-----\n"\
    + "You are standing next to the open window. You can see some light coming out from under the door in front of you (north). "\
    + "The way down the staircase (east) is hard to see. Looks like the lights are off downstairs. "\
    + "Down the hall to the south is the door to the bedroom." 
  bathroom = "\n-----Bathroom-----\n"\
    + "Opening the door you walk into a very dark room. Faint light coming from the skylight allows you to see in the room. "\
    + "You are able to make out a tub, sink and a toilet. "
  masterBedroom = "\n-----Master Bedroom-----\n"\
    + "You find yourself in a large bedroom. Like everywhere else in the house there is dust everywhere. "\
    + "A large bed sits in the center of the room. Moonlight is illuminating the room. "\
    + "The moonlight is being let in by a set of ornate glass double doors that are to your west."
  foyer = "\n-----Foyer-----\n"\
    + "At the foot of the curving stairs you see a grand entryway with a very dusty chandelier hanging overhead. "\
    + "In front of you (north) is a large set of heavy wooden doors. "\
    + "To your left (west) are pedestals with broken pots lying in pieces around them. "\
    + "To your right (east), a large archway with nothing but darkness beyond it. "\
    + "Behind you (south), are the stairs."
  balcony = "\n-----Balcony-----\n"\
    + "A cold wind blows past as you stand out on the balcony. Below you is an unkept and overgrown garden. "\
    + "Off in the distance you can make out a forest of pine trees. Something else catches your eye. "\
    + "You notice three burly men standing outside the west entrance of the house."
  archway = "\n-----Archway-----\n"\
    + "You start walking in past the archway but it is completely black. "\
    + "You try to go further but the way seems to be blocked off."
  brokenLose = "\n-----West Entrance to the House-----\n"\
    + "You make a loud noise as you accidently step on the broken pieces lying on the ground. "\
    + "Three burly men are alerted and chase after you. "\
    + "You trip and one of the men catches you, attacking you. %s is left lying unconscious on the ground. " % name
  lose = "\n-----Outside to the North-----\n"\
    + "You open the doors and it is too dark to see anything. You hear loud footsteps. "\
    + "Suddenly, you are attacked and now lie unconscious. "\
    + "%s, you have led your character to a bad end." % name
  win = "\n-----Outside to the North-----\n"\
    + "You turn on the flashlight and are able to see a man standing to your right. "\
    + "At this moment the man runs towards you, so you run away. "\
    + "You notice a car with its engine running. You jump inside the car and drive away."
  startNext = "\n-----Driving Car-----\n"\
    +"Driving away from the house you see a fork in the road. You can continue to "\
    +"the right towards the forest or the left towards a lake."
  leftIntro = "Your vehicle breaks through the settling mist sounding the river. Passing through, "\
    +"the only thing visible is the towering packed forestry creeping to the sides of the "\
    +"narrow winding road. confused and shaking you continue the drive through the misting "\
    +"green scenery."
  leftIntro2 = "Suddenly you hear a noise from the engine, panicked you start pressing "\
    +"down harder on the gas paddle. Creeping into your mind is the worst thought possible..."\
    +"avoiding the glaze to the inevitable you see the orange glowing fate of your future...empty. "\
    +"Now that your fate is settling into your mind you keep pursuing on the last fumes of hope "\
    +"which you cling onto. You are able to get down the road a few miles until there is a "\
    +"clearing in the dense woods. The over towing cover from the trees disappear and you can "\
    +"see the clearing mist the sparkling stars above you. This clearing in the woods turned out "\
    +"to be a nestled town for what seems to be made for the working class. Here in this town "\
    +"you see and post office with a town hall adjacent, a steeple from a church so tall it "\
    +"seems to be point the stars above, and most of across from the church is the true hope "\
    +"in your heart...a diner. "
  diner = "\n-----Diner-----\n"\
    +"You see the checkered floor below your feet and are shocked that the "\
    +"diner is abandoned. Feeling overwhelmed by the contrasting colored floor you look straight ahead (north). "\
    +"In front of you is a cold bar top accompanied by a swiveling cushion chair. You look to the left (west) and more "\
    +"chairs and tables. To the right (east) you see an unlabeled door. There is no one to be seen and "\
    +"everything is covered in dust."
  backToCar = "\n-----Outside of Diner-----\n"\
    +"You leave the diner and head back to the car. You freeze as you see the man from the house, "\
    +"the one who chased you. You quickly turn back but two men grab hold of you and a third knocks you unconscious."
  radio = "\n-----Diner North-----\n"\
    +"Going behind the bar you search through the old items on the shelving. The only thing which "\
    +"appear useful to you is an old red radio."
  radioTook = "\n-----Diner North-----\n"\
    +"Going behind the bar you search through the old items on the shelving. You can't find anything useful."
  keyDiner = "\n-----Diner West-----\n"\
    +"You start approaching the tables and notice that the plates have been set up for a meal never had. "\
    +"On one plate closest to the you, your flashlight is reflecting back towards you. Walking closer you "\
    +"notice that your light is reflecting off of a key."
  keyDinerTook = "\n-----Diner West-----\n"\
    +"You start approaching the tables and notice that the plates have been set up for a meal never had. "
  padlock = "\n-----Diner East-----\n"\
    +"Heading towards the door you notice the cold metal framing on the imposing padlocked door. "\
    +"You try to open the door."
  sideStreet = "\n-----Side Street-----\n"\
    +"You feel the cold brisk air brushing against your face. You are outside on the side street "\
    +"of the diner. The fog has settled back down between the crevices of the buildings. Blanketing you "\
    +"in cold awareness."
  seePolice = "\n-----Street East-----\n"\
    +"The fog is very thick and it is difficult to see ahead of you as you move down the street. "\
    +"As you move down the street an abandoned police car attracts your attention."
  policeCar = "\n-----Police Car-----\n"\
    +"You walk up to the police car to investigate and notice that the window is broken in the back door "\
    +"windows. Peering into the car you notice a few things on the seat of the car. There seems to be a "\
    +"notepad. "
  policeCarTook = "\n-----Police Car-----\n"\
    +"You walk up to the police car to investigate and notice that the window is broken in the back door "\
    +"windows. Peering into the car you notice a few things on the seat of the car but nothing that gets your attention."
  keypad = "\n-----Keypad-----\n"\
    +"You continue to walk forward down the street and up ahead you see what looks to be a police "\
    +"station. You walk up to the door and find that the door is locked with what seems to be a keypad with "\
    +"a red light."
  wrongCode = "The keypad makes a buzzing noise and falls silent. The light continues to stay red. Seems "\
    +"like the code was incorrect. "
  correctCode = "The keypad light turns green and you can hear a faint click as the door opens. "
  policeStation = "\n-----Police Station-----\n"\
    +"Walking into the police station, you quickly close the door behind you and make sure that it locks "\
    +"behind you. Something about the building seems to fill you with ease. This is the first time you have "\
    +"felt completely safe since you first woke up in that house in the forest. An officer asks if you need "\
    +"something and you proceed to tell him what happened. You tell him your name. Turns out your name was "\
    +"all over the news. You had been abducted."
  win2 = "At that moment, a police officer walks in with a man in handcuffs. It is the man who chased you earlier. "\
    +"You tell the officer he was your kidnapper.\nSoon after, a few officers come in with three burly men who "\
    +"were also with your kidnapper. The officer said they were a group of criminals, wanted for robbery. "\
    +"And now, also for second-degree kidnapping."
  radioSound = "Traversing through the low visibility there is a low crackling sounds emanating from your body. "\
    +"With panic and tumbling hands, you look around and realize that this sound is from that red radio. The "\
    +"crackling sounds increase and faint shadows can be seen in the fog in front of you."
  loseRadio = "The static and crackling sounds are extremely loud and you see three shadows in the fog. They "\
    +"rush towards you and you see it is the three men that you had seen at the house. One of the men jumps "\
    +"forward and tackles you. As you fall your head hits the ground hard and you struggle to stay conscious. "\
    +"The last thing you remember is the men picking you up to take you away."
  rightIntro = "Turning the wheel to the right, you drive towards the forest. The tall pine trees line the road "\
    +"as it takes your deeper into the forest. After driving for a while you see that the gas tank is almost "\
    +"empty. In your rush to escape the house and those strange men you did not notice the amount of fuel left "\
    +"in the car. There is a road ahead that leads to a building. You hope it is a gas station."
  rightIntro2 = "The building turns out to be an old lumber mill. There does not seem to be much light coming "\
    +"from the building as you pull up. You get out of the car and walk up to the door. You try to open the door "\
    +"and to your surprise it opens right up."
  entryway ="\n-----Entryway-----\n"\
    +"You walk into the entryway of the factory, there is a reception desk in the center of the room with "\
    +"large doors behind the desk (north). There is also a small door to the right (east) that is tucked away in "\
    +"the corner. To the left (west) is another small door with the word 'Bathroom' written on a sign above it."
  factory ="\n-----Factory-----\n"\
    +"You see a large factory floor. You see large saw blades that are rusted and "\
    +"broken. Sawdust and wood chips are everywhere on the floor. You see on the far side (north) of the room a large "\
    +"set of wooden double doors that seem to lead outside."
  supplyCloset = "\n-----Supply Closet-----\n"\
    +"You open the door and there is are a few shelves with papers and office supplies stacked on top of "\
    +"them. As you look around for anything useful you see some batteries but you already have some, so you "\
    +"leave them there."
  bathroomFactory = "\n-----Factory Bathroom-----\n"\
    +"You walk into the bathroom and it is in complete shambles. The mirrors are shattered, the "\
    +"sinks are broken and the stall doors are on the floor. Looking around the room there does not seem to be "\
    +"anything useful."
  outside = "\n-----Outside Factory-----\n"\
    +"Outside there are many large piles of logs stacked. These are creating corridors and looking down "\
    +"across the top of the logs you see what looks to be the headlights of a car."
  logs = "\n-----By the Logs-----\n"\
    +"You begin to walk through the logs towards the lights. As you walk through the logs you begin to become "\
    +"lost as every pile of logs looks the same. As you continue to move forward you see a shadow move past your "\
    +"vision and then you hear the sound of wood creaking. Looking behind you, you see the logs beginning to "\
    +"topple over towards you. You begin to run away from the logs but you soon realize that you are not quick "\
    +"enough to outrun the avalanche of logs. Looking forward you see a large boulder up ahead that you could try "\
    +"to hide behind or you can try to jump to the left to avoid the logs."
  jump = "You quickly jump towards the left and attempt to dive away from the falling logs. As you land on the "\
    +"ground a log slides in front of you. Before you have time to react you crash into the log and fall to the "\
    +"ground. You lay there as logs continue past you and your consciousness fades."
  hide = "You decide to hide behind the large boulder. As you reach the boulder you quickly slip around and crouch "\
    +"behind it, while covering your head. You hear logs crashing around you and slamming into the boulder, which "\
    +"shifts slightly with each impact. Once the crashing is over you slowly look around and find it difficult to "\
    +"see. The logs have fallen all around you and have trapped you. Looking around you see that there is a small "\
    +"opening that you might be able to crawl through or you could wait to see if anyone notice what had happened. "\
    +"After all that must have created a large noise."
  crawl = "You attempt to crawl through the small opening but as you move forward the logs around you shift "\
    +"slightly and pin you in. You are not completely trapped. As you struggle to wiggle yourself free you see "\
    +"some motion. Looking closer you see it is a man dressed similar to the guy who chased you earlier. He looked "\
    +"down upon you and balls up his hand. He then swings a fist at you and you are knocked unconscious."
  wait = "You wait and after some time you hear commotion around your log prison. As you listen you can hear that "\
    +"it sounds like a man talking, definitely not English. It sounds like he is trying to dig you out. As he digs you out, you see that "\
    +"he is dressed similar to the guy who chased you earlier. He swings a fist towards you and you are "\
    +"knocked unconscious."

  quitGame = "\n~~%s has quit the game~~" % name
  loser = "Sorry %s, you lose." % name
  winnerHouse = "Congratulations %s, you made it through the first stage!" % name
  winnerDiner = "Congratulations %s, you have completed the game!" % name
  
  dict = {"closet":closet, "bedroomSouth":bedroomSouth, "bedroom":bedroom, "bedroomNorth":bedroomNorth, "bathroom":bathroom,
    "hallSouth":hallSouth, "hallNorth":hallNorth, "masterBedroom":masterBedroom, "balcony":balcony, "foyer":foyer, "brokenLose":brokenLose,
    "archway":archway, "lose":lose, "win":win, "intro":intro, "help":help, "startNext":startNext, "leftIntro":leftIntro,
    "leftIntro2":leftIntro2, "diner":diner, "backToCar":backToCar, "radio":radio, "radioTook":radioTook, "keyDiner":keyDiner,
    "padlock":padlock, "sideStreet":sideStreet, "seePolice":seePolice, "policeCar":policeCar, "policeCarTook":policeCarTook, "keypad":keypad,
    "keyDinerTook":keyDinerTook, "wrongCode":wrongCode, "correctCode":correctCode, "policeStation":policeStation, "win2":win2, "radioSound":radioSound,
    "loseRadio":loseRadio, "rightIntro":rightIntro, "rightIntro2":rightIntro2, "entryway":entryway, "factory":factory,
    "supplyCloset":supplyCloset, "bathroomFactory":bathroomFactory, "outside":outside, "logs":logs, "jump":jump,
    "hide":hide, "crawl":crawl, "wait":wait, "quitGame":quitGame, "loser":loser, "winnerHouse":winnerHouse, "winnerDiner":winnerDiner}
  return dict
  