Exemplo n.º 1
0
Arquivo: tiles.py Projeto: riz5034/PSU
    def adjacent_moves(self):
        """Returns all move actions for adjacent tiles."""
        moves = []
        if world.tile_exists(self.x + 1, self.y):
            moves.append(actions.MoveEast())
        if world.tile_exists(self.x - 1, self.y):
            moves.append(actions.MoveWest())
        if world.tile_exists(self.x, self.y + 1):
            moves.append(actions.MoveSouth())

        # Modify room to allow player to enter Upper Class Area
        if self.blackouts == 2:
            display.slow_print("""
        Jack tells the guards he needs to go through to continue his
        search, but the they tell him to search around town first.
            """)
            if self.nonUpperClassRooms == self.playerVisits:
                if world.tile_exists(self.x, self.y - 1):
                    moves.append(actions.MoveNorth())
                display.slow_print("""
        After telling the guards that the missing piece is not in town,
        the guards exclaim, "You may pass".
                """)
            else:
                display.slow_print("""
        You must leave.
                """)

        return moves
Exemplo n.º 2
0
 def adjacent_moves(self):
     moves = []
     if world.tile_exists(self.x + 1, self.y):
         moves.append(actions.MoveEast())
     if world.tile_exists(self.x - 1, self.y):
         moves.append(actions.MoveWest())
     if world.tile_exists(self.x, self.y - 1):
         moves.append(actions.MoveNorth())
     if world.tile_exists(self.x, self.y + 1):
         moves.append(actions.MoveSouth())
Exemplo n.º 3
0
 def adjacentMoves(self):
     possibleMoves = []
     if world.tileExists(self.x + 1, self.y):
         possibleMoves.append(actions.MoveEast())
     if world.tileExists(self.x - 1, self.y):
         possibleMoves.append(actions.MoveWest())
     if world.tileExists(self.x, self.y - 1):
         possibleMoves.append(actions.MoveNorth())
     if world.tileExists(self.x, self.y + 1) and not self.isLocked:
         possibleMoves.append(actions.MoveSouth())
     return possibleMoves
Exemplo n.º 4
0
 def adjacent_moves(self):
     """Returns all move actions for adjacent tiles."""
     moves = []
     if MapTile.can_move_here(self.x + 1, self.y):
         moves.append(actions.MoveEast())
     if MapTile.can_move_here(self.x - 1, self.y):
         moves.append(actions.MoveWest())
     if MapTile.can_move_here(self.x, self.y - 1):
         moves.append(actions.MoveNorth())
     if MapTile.can_move_here(self.x, self.y + 1):
         moves.append(actions.MoveSouth())
     return moves
Exemplo n.º 5
0
 def available_directions(self):
     moves = []
     x, y = self.x, self.y
     if maze.get_location_if_valid(x, y - 1):
         moves.append(actions.MoveNorth())
     if maze.get_location_if_valid(x, y + 1):
         moves.append(actions.MoveSouth())
     if maze.get_location_if_valid(x + 1, y):
         moves.append(actions.MoveEast())
     if maze.get_location_if_valid(x - 1, y):
         moves.append(actions.MoveWest())
     return moves
 def adjacent_moves(self):
     """Returns all move actions for adjacent tiles."""
     moves = []
     if world.tile_exists(self.x + 1, self.y):
         moves.append(actions.MoveEast())
     if world.tile_exists(self.x - 1, self.y):
         moves.append(actions.MoveWest())
     if world.tile_exists(self.x, self.y - 1):
         moves.append(actions.MoveNorth())
     if world.tile_exists(self.x, self.y + 1):
         moves.append(actions.MoveSouth())
     return moves
Exemplo n.º 7
0
	def adjacent_moves(self):
		# tells player all move actions for adjacent tiles (?)
		moves = []
		if world.tile_exists(self.x+1,self.y):
			moves.append(actions.MoveEast())
		if world.tile_exists(self.x-1,self.y):
			moves.append(actions.MoveWest())
		if world.tile_exists(self.x,self.y-1):
			moves.append(actions.MoveNorth())
		if world.tile_exists(self.x,self.y+1):
			moves.append(actions.MoveSouth())  # is that right?
		return moves
Exemplo n.º 8
0
 def adjacent_moves(self):
     """ Devuelve todas las direcciones en las que el jugador puede moverse."""
     moves = []
     if world.tile_exists(self.x + 1, self.y):
         moves.append(actions.MoveEast())
     if world.tile_exists(self.x - 1, self.y):
         moves.append(actions.MoveWest())
     if world.tile_exists(self.x, self.y - 1):
         moves.append(actions.MoveNorth())
     if world.tile_exists(self.x, self.y + 1):
         moves.append(actions.MoveSouth())
     return moves
Exemplo n.º 9
0
 def adjacent_moves(self):
     """Returns all move actions for adjacent tiles."""
     moves = []
     if world.tile_exists(self.x + 1, self.y) and ('e' in self.directions or not self.locked):
         moves.append(actions.MoveEast())
     if world.tile_exists(self.x - 1, self.y) and ('w' in self.directions or not self.locked):
         moves.append(actions.MoveWest())
     if world.tile_exists(self.x, self.y - 1) and ('n' in self.directions or not self.locked):
         moves.append(actions.MoveNorth())
     if world.tile_exists(self.x, self.y + 1) and ('s' in self.directions or not self.locked):
         moves.append(actions.MoveSouth())
     return moves
Exemplo n.º 10
0
 def adjacent_moves(self):
     """Retourne les possibilités de déplacements dans les cases adjacentes."""
     moves = []
     if world.tile_exists(self.x + 1, self.y):
         moves.append(actions.MoveEast())
     if world.tile_exists(self.x - 1, self.y):
         moves.append(actions.MoveWest())
     if world.tile_exists(self.x, self.y - 1):
         moves.append(actions.MoveNorth())
     if world.tile_exists(self.x, self.y + 1):
         moves.append(actions.MoveSouth())
     return moves
Exemplo n.º 11
0
 def adjacent_moves(self):
     """Determines what moves are valid in your world"""
     moves = []
     if world.tile_exists(self._x, self._y - 1):
         moves.append(actions.MoveNorth())
     if world.tile_exists(self._x, self._y + 1):
         moves.append(actions.MoveSouth())
     if world.tile_exists(self._x + 1, self._y):
         moves.append(actions.MoveEast())
     if world.tile_exists(self._x - 1, self._y):
         moves.append(actions.MoveWest())
     return moves
Exemplo n.º 12
0
 def adjacent_moves(self):
     #Returns all move actions based of if there are adjacent tiles
     moves = []
     if world.tile_exists(self.x + 1, self.y):
         moves.append(actions.MoveEast())
     if world.tile_exists(self.x - 1, self.y):
         moves.append(actions.MoveWest())
     if world.tile_exists(self.x, self.y - 1):
         moves.append(actions.MoveNorth())
     if world.tile_exists(self.x, self.y + 1):
         moves.append(actions.MoveSouth())
     return moves
Exemplo n.º 13
0
 def adjacentMoves(self):
     # returns possible move actions and prints it to the user
     #maybe add locked door blocking here?
     possibleMoves = []
     if world.tileExists(self.x + 1, self.y):
         possibleMoves.append(actions.MoveEast())
     if world.tileExists(self.x - 1, self.y):
         possibleMoves.append(actions.MoveWest())
     if world.tileExists(self.x, self.y - 1):
         possibleMoves.append(actions.MoveNorth())
     if world.tileExists(self.x, self.y + 1):
         possibleMoves.append(actions.MoveSouth())
     return possibleMoves
Exemplo n.º 14
0
 def available_actions(self,player):
     moves = []
     moves.append(actions.MoveEast())
     moves.append(actions.ViewInventory())
     moves.append(actions.CheckHP())
     moves.append(actions.EquipWep())
     if player.Potion_Of_Life:
         moves.append(actions.Undead())
     if player.HealingPotions > 0:
         moves.append(actions.Heal())
     if player.beer > 0:
         moves.append(actions.Drink())
     return moves
Exemplo n.º 15
0
 def act(self):
     self.select_target()
     if self.target is not None:
         if self.target[1] < self.y:
             actions.MoveNorth()(self)
         elif self.target[1] > self.y:
             actions.MoveSouth()(self)
         elif self.target[0] > self.x:
             actions.MoveEast()(self)
         elif self.target[0] < self.x:
             actions.MoveWest()(self)
         else:
             self.target[2](self)
Exemplo n.º 16
0
    def generic_moves(self, player):
        """Returns the standard moves that are available in every room.
        These include: -movement options
                       -choosing weapons
                       -viewing inventory
                       -using potions
                       -looking around at objects in room
        Args:
            player: an instance of the player class

        Returns:
            moves: dictionary mapping nouns to the verbs that can be applied to them.
            avail_actions: a list of actions from actions.py
            descriptors: dictionary mapping nouns to their respective descriptors
                        allow adjectives in commands
        """
        moves = dict() # the verbs associated with each noun
        descriptors = dict() # the adjectives associated with each noun
        avail_actions = [] # the availble actions from actions.py

        # determine the possible moves to other tiles (ie, move west)
        if world.tile_exists(self.x + 1, self.y):
            moves, avail_actions = self.update(moves, avail_actions, actions.MoveEast())

        if world.tile_exists(self.x - 1, self.y):
            moves, avail_actions = self.update(moves, avail_actions, actions.MoveWest())

        if world.tile_exists(self.x, self.y - 1):
            moves, avail_actions = self.update(moves, avail_actions, actions.MoveNorth())

        if world.tile_exists(self.x, self.y + 1):
            moves, avail_actions = self.update(moves, avail_actions, actions.MoveSouth())

        # look at inventory
        moves, avail_actions = self.update(moves, avail_actions, actions.ViewInventory())

        for potion in player.available_potions():
            moves, avail_actions = self.update(moves, avail_actions, actions.UsePotion(potion=potion, tile=self, enemy=None))

        # choose or change weapon
        moves, avail_actions = self.update(moves, avail_actions, actions.ChangeWeapon())

        moves, avail_actions = self.update(moves, avail_actions, actions.Look(noun=None, tile=self))

        for item in self.look_at:
            moves, avail_actions = self.update(moves, avail_actions, actions.Look(noun=item, tile=self))
            descriptors[item] = self.look_at[item]

        return moves, avail_actions, descriptors
Exemplo n.º 17
0
 def adjacent_moves(self):
     """Returns all move actions for adjacent tiles."""
     moves = []
     if self.universe.tile_exists(self.map, self.x + 1,
                                  self.y) and "east" not in self.block_exit:
         moves.append(actions.MoveEast())
     if self.universe.tile_exists(self.map, self.x - 1,
                                  self.y) and "west" not in self.block_exit:
         moves.append(actions.MoveWest())
     if self.universe.tile_exists(self.map, self.x, self.y -
                                  1) and "north" not in self.block_exit:
         moves.append(actions.MoveNorth())
     if self.universe.tile_exists(self.map, self.x, self.y +
                                  1) and "south" not in self.block_exit:
         moves.append(actions.MoveSouth())
     return moves
Exemplo n.º 18
0
 def flee_moves(self):
     """Tous les mouvements permis en cas de fuite"""
     moves = []
     tile = MapTile.can_move_here(self.x + 1, self.y)
     if tile and not isinstance(tile, LeavingTile):
         moves.append(actions.MoveEast())
     tile = MapTile.can_move_here(self.x - 1, self.y)
     if tile and not isinstance(tile, LeavingTile):
         moves.append(actions.MoveWest())
     tile = MapTile.can_move_here(self.x, self.y - 1)
     if tile and not isinstance(tile, LeavingTile):
         moves.append(actions.MoveNorth())
     tile = MapTile.can_move_here(self.x, self.y + 1)
     if tile and not isinstance(tile, LeavingTile):
         moves.append(actions.MoveSouth())
     return moves
Exemplo n.º 19
0
    def directions_to_travel(self):
        """Returns a list of the possible directions the player can travel
        along the road."""
        moves = [] # a list of directions, eg, east

        if world.tile_exists(self.x + 1, self.y):
            direction, verbs = actions.MoveEast().add_actions()
            moves.append(direction)
        if world.tile_exists(self.x - 1, self.y):
            direction, verbs = actions.MoveWest().add_actions()
            moves.append(direction)
        if world.tile_exists(self.x, self.y - 1):
            direction, verbs = actions.MoveNorth().add_actions()
            moves.append(direction)
        if world.tile_exists(self.x, self.y + 1):
            direction, verbs = actions.MoveSouth().add_actions()
            moves.append(direction)
        return moves
Exemplo n.º 20
0
    def adjacent_moves(self):

        directions = {
            actions.MoveNorth(): [self.x, self.y - 1],
            actions.MoveSouth(): [self.x, self.y + 1],
            actions.MoveEast(): [self.x + 1, self.y],
            actions.MoveWest(): [self.x - 1, self.y],
        }

        moves = []
        rooms = []
        for k, v in directions.items():
            room = world.tile_exists(v[0], v[1])

            if room != None:
                moves.append(k)
                rooms.append(room.__str__())
        return moves, rooms
Exemplo n.º 21
0
    def adjacent_moves(self):
        """Returns all move actions for adjacent tiles."""
        moves = []
        myroom = world.tile_exists(self.x, self.y)

        if world.tile_exists(self.x + 1, self.y):
            moves.append(actions.MoveEast())
        if world.tile_exists(self.x - 1, self.y):
            moves.append(actions.MoveWest())
        if world.tile_exists(self.x, self.y - 1):
            moves.append(actions.MoveNorth())
        # myroom= world.tile_exists(self.x + 1, self.y)
        # if type(myroom).__name__ == LockedNorth:
        #     pass
        # else:
        #     moves.append(actions.MoveNorth())

        if world.tile_exists(self.x, self.y + 1):
            moves.append(actions.MoveSouth())

        # myroom = world.tile_exists(self.x, self.y)
        # if isinstance(myroom, LockedDoorRoom):
        #      print "door is locked"
        #      print myroom.door

        if isinstance(myroom, LockedDoorRoom) and not myroom.solved:
            for move in moves:
                if isinstance(move,
                              actions.MoveNorth) and myroom.door == "north":
                    moves.remove(move)
                if isinstance(move,
                              actions.MoveSouth) and myroom.door == "south":
                    moves.remove(move)
                if isinstance(move,
                              actions.MoveEast) and myroom.door == "east":
                    moves.remove(move)
                if isinstance(move,
                              actions.MoveWest) and myroom.door == "west":
                    moves.remove(move)

#        print moves
        return moves
Exemplo n.º 22
0
 def adjacent_moves(self):
     #Returns all move actions for adjacent tiles.
     moves = []
     #UNUSED CODE, KEPT FOR REFERENCE
     '''
     if world.tile_exists(self.x + 1, self.y):
         moves.append(actions.MoveEast())
     if world.tile_exists(self.x - 1, self.y):
         moves.append(actions.MoveWest())
     if world.tile_exists(self.x, self.y - 1):
         moves.append(actions.MoveNorth())
     if world.tile_exists(self.x, self.y + 1):
         moves.append(actions.MoveSouth())
     '''
     if tile_at(self.x + 1, self.y):
         moves.append(actions.MoveEast())
     if tile_at(self.x - 1, self.y):
         moves.append(actions.MoveWest())
     if tile_at(self.x, self.y - 1):
         moves.append(actions.MoveNorth())
     if tile_at(self.x, self.y + 1):
         moves.append(actions.MoveSouth())
     return moves