コード例 #1
0
ファイル: player.py プロジェクト: omega128/blackout
def go (direction):
  """ makes the player move in a given direction. """
  global location
  here = places.getById(location)
  
  # complain if we can't go that way.
  if direction not in here.exits:
    print "You cannot go that way!"
    print
    return
    
  # Foxy only comes out if the player visits the closet.
  if location == 'CLOSET':
    things.getById('foxy').location = 'WEST HALLWAY'
      
  # if foxy is sprinting at you but there isn't any sauce, you cannot move fast enough to leave.
  if location == things.getById('foxy').location and 'mangled' not in things.getById('foxy').tags:
    print "You cannot move fast enough."
    print
    return
  
  # move us over that-a-ways!
  print "You go " + direction + "."
  print
  location = here.exits[direction]
コード例 #2
0
ファイル: bots.py プロジェクト: omega128/blackout
  def think (self):
    """ called each turn in the kitchen. """
    
    self.t += 1
    
    # You get one turn before Chica enters the room.
    
    if self.t == 2:
      print "You hear a rattling groan as Chica enters the room."
      print
      self.tags.remove ("hidden")

    elif self.t == 3:
      # have you dropped the cupcake?
      if things.getById('cupcake').location == self.location:
        print "With a shriek, Chica dives for the cupcake, knocking over several ladles and a saucepan that land on the ground with a deafening crash. She thrashes and scrabbles as she tries to get her claws on the cupcake."
        print
        things.getById('cupcake').tags.append ('hidden')
        
      else:
        print "With a shriek, Bonnie lunges at you. The last thing you see is the words 'let's eat,' and her oversized chicken jaws gaping open."
        print
        player.location = "DEAD"
    elif self.t == 4:
      print "Chica is holding the cupcake up. She is completely still, her eyes pointing in different directions. You swear the cupcake blinks."
      print
    elif self.t == 5:
        print "With a shriek, Bonnie lunges at you. The last thing you see is the cupcake, and her oversized chicken jaws gaping open."
        print
        player.location = "DEAD"
コード例 #3
0
def go(direction):
    """ makes the player move in a given direction. """
    global location
    here = places.getById(location)

    # complain if we can't go that way.
    if direction not in here.exits:
        print "You cannot go that way!"
        print
        return

    # Foxy only comes out if the player visits the closet.
    if location == 'CLOSET':
        things.getById('foxy').location = 'WEST HALLWAY'

    # if foxy is sprinting at you but there isn't any sauce, you cannot move fast enough to leave.
    if location == things.getById(
            'foxy').location and 'mangled' not in things.getById('foxy').tags:
        print "You cannot move fast enough."
        print
        return

    # move us over that-a-ways!
    print "You go " + direction + "."
    print
    location = here.exits[direction]
コード例 #4
0
    def think(self):
        """ called each turn near the exit. """
        # Freddy won't let you get close to the bathrooms and the exit.
        self.t += 1

        # Freddy doesn't like light, and will hide and wait until you turn it off before attacking.
        if things.getById('flashlight'
                          ).location == 'INVENTORY' and "on" in things.getById(
                              'flashlight').tags:
            # Freddy will stay away while you have the light on
            self.t = 0

            # hide or unhide freddy.
            if "hidden" not in self.tags:
                self.tags.append("hidden")
            else:
                if "hidden" in self.tags:
                    self.tags.remove("hidden")

        # Freddy will wait before lunging.
        if self.t == 2:
            print "Freddy's slow laughter echoes in the restaurant."
            print
        if self.t == 4:
            print "Without warning, Freddy Fazbear lunges at you, taking up your entire vision before everything mercifully goes black."
            player.location = "DEAD"
コード例 #5
0
    def think(self):
        """ called each turn in the kitchen. """

        self.t += 1

        # You get one turn before Chica enters the room.

        if self.t == 2:
            print "You hear a rattling groan as Chica enters the room."
            print
            self.tags.remove("hidden")

        elif self.t == 3:
            # have you dropped the cupcake?
            if things.getById('cupcake').location == self.location:
                print "With a shriek, Chica dives for the cupcake, knocking over several ladles and a saucepan that land on the ground with a deafening crash. She thrashes and scrabbles as she tries to get her claws on the cupcake."
                print
                things.getById('cupcake').tags.append('hidden')

            else:
                print "With a shriek, Bonnie lunges at you. The last thing you see is the words 'let's eat,' and her oversized chicken jaws gaping open."
                print
                player.location = "DEAD"
        elif self.t == 4:
            print "Chica is holding the cupcake up. She is completely still, her eyes pointing in different directions. You swear the cupcake blinks."
            print
        elif self.t == 5:
            print "With a shriek, Bonnie lunges at you. The last thing you see is the cupcake, and her oversized chicken jaws gaping open."
            print
            player.location = "DEAD"
コード例 #6
0
ファイル: bots.py プロジェクト: omega128/blackout
 def think (self):
   """ called each turn in the northwest hallway. """
   self.t += 1
     
   if self.t == 1:
     print "Foxy is sprinting down the hallway directly at you."
     print
     
   elif self.t == 2:
     # have you used... THE SAUCE?
     sauce = things.getById('sauce')
     if sauce.location == self.location and "broken" in sauce.tags:
       print "As Foxy sprints towards you, his mechanical feet lose their traction and slip in the spilled pizza sauce. With a shriek, he crashes into the wall and lands in a mangled heap."
       print
       self.tags.append ('mangled')
       self.tags.remove ('hidden')
     else:
       print "With a shriek, Foxy lunges at you. The last thing you see are his sharp teeth and wicked hook."
       print
       player.location = "DEAD"
       
   elif self.t == 3: 
      print "As Foxy twitches and spasmically sorts out his tattered limbs, his head turns in your direction."
      print
      self.tags.remove ('mangled')
     
   elif self.t == 4:
       print "With a shriek, Foxy lunges at you. The last thing you see are his sharp teeth and wicked hook."
       print
       player.location = "DEAD"
コード例 #7
0
    def think(self):
        """ called each turn in the northwest hallway. """
        self.t += 1

        if self.t == 1:
            print "Foxy is sprinting down the hallway directly at you."
            print

        elif self.t == 2:
            # have you used... THE SAUCE?
            sauce = things.getById('sauce')
            if sauce.location == self.location and "broken" in sauce.tags:
                print "As Foxy sprints towards you, his mechanical feet lose their traction and slip in the spilled pizza sauce. With a shriek, he crashes into the wall and lands in a mangled heap."
                print
                self.tags.append('mangled')
                self.tags.remove('hidden')
            else:
                print "With a shriek, Foxy lunges at you. The last thing you see are his sharp teeth and wicked hook."
                print
                player.location = "DEAD"

        elif self.t == 3:
            print "As Foxy twitches and spasmically sorts out his tattered limbs, his head turns in your direction."
            print
            self.tags.remove('mangled')

        elif self.t == 4:
            print "With a shriek, Foxy lunges at you. The last thing you see are his sharp teeth and wicked hook."
            print
            player.location = "DEAD"
コード例 #8
0
ファイル: bots.py プロジェクト: omega128/blackout
  def think (self):
    """ called each turn near the exit. """
    # Freddy won't let you get close to the bathrooms and the exit.
    self.t += 1
    
    # Freddy doesn't like light, and will hide and wait until you turn it off before attacking.
    if things.getById('flashlight').location == 'INVENTORY' and "on" in things.getById('flashlight').tags:
      # Freddy will stay away while you have the light on
      self.t = 0
      
      # hide or unhide freddy.
      if "hidden" not in self.tags:
        self.tags.append ("hidden")
      else:
        if "hidden" in self.tags:
          self.tags.remove ("hidden")

    # Freddy will wait before lunging.
    if self.t == 2:
      print "Freddy's slow laughter echoes in the restaurant."
      print
    if self.t == 4:
      print "Without warning, Freddy Fazbear lunges at you, taking up your entire vision before everything mercifully goes black."
      player.location = "DEAD"
コード例 #9
0
ファイル: bots.py プロジェクト: omega128/blackout
 def think (self):
   """ called each turn in the closet. """
   
   # Bonnie enters the room when you have already been there, and will kill you UNLESS you are wearing the mask.
   self.t += 1
   
   if self.t == 2:
     print "With heavy footfalls, Bonnie enters the room."
     print
     self.tags.remove ('hidden')
   
   if things.getById('mask').location != 'WORN' and self.t > 3:
     print "With a shriek, Bonnie lunges at you, taking up your whole view before everything mercifully goes black."
     print
     player.location = "DEAD"
   else:
     self.t == 3
コード例 #10
0
    def think(self):
        """ called each turn in the closet. """

        # Bonnie enters the room when you have already been there, and will kill you UNLESS you are wearing the mask.
        self.t += 1

        if self.t == 2:
            print "With heavy footfalls, Bonnie enters the room."
            print
            self.tags.remove('hidden')

        if things.getById('mask').location != 'WORN' and self.t > 3:
            print "With a shriek, Bonnie lunges at you, taking up your whole view before everything mercifully goes black."
            print
            player.location = "DEAD"
        else:
            self.t == 3
コード例 #11
0
ファイル: __main__.py プロジェクト: omega128/blackout
def gameLoop():
    """ the main game loop, where we get the whole feedback, input, and command parsing. """

    done = False
    while not done:
        # first, make sure the game isn't over.
        if player.location == "TRYING TO LEAVE":
            # the player is trying to leave the building. Is the flashlight in their hand, and is it turned on?
            if things.getById("flashlight").location == "INVENTORY" and "on" in things.getById("flashlight").tags:
                showGoodEnding()
                done = True
                continue
            else:
                # woops. You haven't won yet.
                showBadEnding()
                done = True
                continue

        # There's also the option you died last round.
        elif player.location == "DEAD":
            done = True
            continue

        # Every once inawhile, spookiness happens.
        ghosts.playSpookyFlavorText()

        # Does anyone know you're here? If so, they get to act.
        for thing in things.getByLocation(player.location):
            if "alive" in thing.tags:
                thing.think()

        # ...did someone just kill you?
        if player.location == "DEAD":
            done = True
            continue

        # Tell us where we are:
        player.look()

        # get input from the user
        userInput = raw_input("What do you do? ")

        # then strip the leading whitespace, convert everything to lowerspace, and split input into individual words we can parse:
        words = userInput.strip().lower().split()

        # did they actually say anything? If not, we don't need to go further.
        if len(words) < 1:
            continue

        # So, does the player want to ...

        # quit the game?
        if words[0] in ["quit", "exit", "end", "q"]:
            # Looks like we're done here.
            done = True

        # read instructions again?
        if words[0] in ["instructions", "help", "?"] or (words[0] in ["show"] and words[1] in ["instructions", "help"]):
            showInstructions()

        # check inventory
        if words[0] in ["i", "inv", "inventory"] or (words[0] == "show" and words[1] == "inventory"):
            player.showInventory()

        # move?
        if words[0] in ["n", "north"] or (words[0] in ["go", "move"] and words[1] == "north"):
            player.go(NORTH)
        if words[0] in ["s", "south"] or (words[0] in ["go", "move"] and words[1] == "south"):
            player.go(SOUTH)
        if words[0] in ["w", "west"] or (words[0] in ["go", "move"] and words[1] == "east"):
            player.go(WEST)
        if words[0] in ["e", "east"] or (words[0] in ["go", "move"] and words[1] == "west"):
            player.go(EAST)
        if words[0] in ["go", "move"] and len(words) != 2:
            print ("Go where? Please specify a direction.")
            continue

        # all of these take a single argument.
        checkForTwoWordCommand(words, ["take", "get"], player.take)
        checkForTwoWordCommand(words, ["drop"], player.drop)
        checkForTwoWordCommand(words, ["throw"], player.throw)
        checkForTwoWordCommand(words, ["examine", "x"], player.examine)
        checkForTwoWordCommand(words, ["wear"], player.wear)
        checkForTwoWordCommand(words, ["unwear"], player.unwear)

        # flashlight verbs!
        if words[0] == "turn":
            # turn something on?
            if words[1] == "on":
                if len(words) == 3:
                    player.turnOn(words[2])
                else:
                    print "Turn on what? Please specify a single noun."

            # maybe turn it off?
            if words[1] == "off":
                if len(words) == 3:
                    player.turnOff(words[2])
                else:
                    print "Turn on what? Please specify a single noun."
コード例 #12
0
def gameLoop():
    """ the main game loop, where we get the whole feedback, input, and command parsing. """

    done = False
    while not done:
        # first, make sure the game isn't over.
        if player.location == 'TRYING TO LEAVE':
            # the player is trying to leave the building. Is the flashlight in their hand, and is it turned on?
            if things.getById(
                    'flashlight'
            ).location == 'INVENTORY' and "on" in things.getById(
                    'flashlight').tags:
                showGoodEnding()
                done = True
                continue
            else:
                # woops. You haven't won yet.
                showBadEnding()
                done = True
                continue

        # There's also the option you died last round.
        elif player.location == 'DEAD':
            done = True
            continue

        # Every once inawhile, spookiness happens.
        ghosts.playSpookyFlavorText()

        # Does anyone know you're here? If so, they get to act.
        for thing in things.getByLocation(player.location):
            if "alive" in thing.tags:
                thing.think()

        # ...did someone just kill you?
        if player.location == 'DEAD':
            done = True
            continue

        # Tell us where we are:
        player.look()

        # get input from the user
        userInput = raw_input("What do you do? ")

        # then strip the leading whitespace, convert everything to lowerspace, and split input into individual words we can parse:
        words = userInput.strip().lower().split()

        # did they actually say anything? If not, we don't need to go further.
        if len(words) < 1:
            continue

        # So, does the player want to ...

        # quit the game?
        if words[0] in ["quit", "exit", "end", "q"]:
            # Looks like we're done here.
            done = True

        # read instructions again?
        if words[0] in [
                'instructions', 'help', '?'
        ] or (words[0] in ['show'] and words[1] in ['instructions', 'help']):
            showInstructions()

        # check inventory
        if words[0] in ['i', 'inv', 'inventory'
                        ] or (words[0] == 'show' and words[1] == 'inventory'):
            player.showInventory()

        # move?
        if words[0] in ['n', 'north'] or (words[0] in ['go', 'move']
                                          and words[1] == 'north'):
            player.go(NORTH)
        if words[0] in ['s', 'south'] or (words[0] in ['go', 'move']
                                          and words[1] == 'south'):
            player.go(SOUTH)
        if words[0] in ['w', 'west'] or (words[0] in ['go', 'move']
                                         and words[1] == 'east'):
            player.go(WEST)
        if words[0] in ['e', 'east'] or (words[0] in ['go', 'move']
                                         and words[1] == 'west'):
            player.go(EAST)
        if words[0] in ['go', 'move'] and len(words) != 2:
            print("Go where? Please specify a direction.")
            continue

        # all of these take a single argument.
        checkForTwoWordCommand(words, ["take", "get"], player.take)
        checkForTwoWordCommand(words, ["drop"], player.drop)
        checkForTwoWordCommand(words, ["throw"], player.throw)
        checkForTwoWordCommand(words, ["examine", "x"], player.examine)
        checkForTwoWordCommand(words, ["wear"], player.wear)
        checkForTwoWordCommand(words, ["unwear"], player.unwear)

        # flashlight verbs!
        if words[0] == 'turn':
            # turn something on?
            if words[1] == 'on':
                if len(words) == 3:
                    player.turnOn(words[2])
                else:
                    print "Turn on what? Please specify a single noun."

            # maybe turn it off?
            if words[1] == 'off':
                if len(words) == 3:
                    player.turnOff(words[2])
                else:
                    print "Turn on what? Please specify a single noun."