コード例 #1
0
    def is_stoppable(self, tile, pos):
        """
        Returns whether or not a unit can stop on a certain tile.
        """
        dist = helper.manhattan_dist((self.tile_x, self.tile_y), pos)

        # Check if this is too close to stop in
        if (dist < self.min_move_distance):
            return False

        return super().is_stoppable(tile, pos)
コード例 #2
0
 def is_stoppable(self, tile, pos):
     """
     Returns whether or not a unit can stop on a certain tile.
     """
     dist = helper.manhattan_dist((self.tile_x, self.tile_y), pos)
     
     # Check if this is too close to stop in
     if (dist < self.min_move_distance and
         (not self.is_docked(pos))):
         return False
         
     return super().is_stoppable(tile, pos)
コード例 #3
0
    def is_docked(self, pos):
        """
        Checks if the given position is currently adjacent to a carrier of the
        same team.
        """
        for u in BaseUnit.active_units:
            if (u.team == self.team and isinstance(u, Carrier)
                    and helper.manhattan_dist((u.tile_x, u.tile_y), pos) <= 1):
                # This is an adjacent carrier! Rejoice!
                return True

        # No carriers
        return False
コード例 #4
0
 def is_tile_in_range(self, from_tile, from_pos, to_pos):
     """
     Checks to see if a tile is in attackable range from its current
     position. Takes tile range bonus into account.
     """
     # Get range
     r = self.max_atk_range
     # Add (or subtract) bonus range from occupied tile
     r += from_tile.range_bonus
     
     dist = helper.manhattan_dist(from_pos, to_pos)
     if dist <= r:
         return True
     return False
コード例 #5
0
ファイル: base_unit.py プロジェクト: dskrundz-school/A2
	def is_tile_in_range(self, from_tile, from_pos, to_pos):
		"""
		Checks to see if a tile is in attackable range from its current
		position. Takes tile range bonus into account.
		"""
		# Get range
		r = self.max_atk_range
		# Add (or subtract) bonus range from occupied tile
		r += from_tile.range_bonus

		dist = helper.manhattan_dist(from_pos, to_pos)
		if dist <= r:
			return True
		return False
コード例 #6
0
 def is_docked(self, pos):
     """
     Checks if the given position is currently adjacent to a carrier of the
     same team.
     """
     for u in BaseUnit.active_units:
         if (u.team == self.team and
             isinstance(u, Carrier) and
             helper.manhattan_dist((u.tile_x, u.tile_y), pos) <= 1):
             # This is an adjacent carrier! Rejoice!
             return True
     
     # No carriers
     return False
コード例 #7
0
 def is_tile_in_range(self, from_tile, from_pos, to_pos):
     """
     Checks to see if a tile is in attackable range from its current
     position. Takes tile range bonus into account.
     
     Overrides superclass method because planes are unaffected
     by terrain range bonus.
     """
     # Get range
     r = self.max_atk_range
     
     dist = helper.manhattan_dist(from_pos, to_pos)
     if dist <= r:
         return True
     return False
コード例 #8
0
    def is_tile_in_range(self, from_tile, from_pos, to_pos):
        """
        Checks to see if a tile is in attackable range from its current
        position. Takes tile range bonus into account.
        
        Overrides superclass method because planes are unaffected
        by terrain range bonus.
        """
        # Get range
        r = self.max_atk_range

        dist = helper.manhattan_dist(from_pos, to_pos)
        if dist <= r:
            return True
        return False
コード例 #9
0
 def is_tile_in_range(self, from_tile, from_pos, to_pos):
     """
     Checks to see if a tile is in attackable range from its current
     position. Takes tile range bonus into account.
     
     Overrides superclass method.
     """
     # Get range
     max_range = self.max_atk_range
     min_range = self.min_atk_range
     # Add (or subtract) bonus range from occupied tile
     max_range += from_tile.range_bonus
     
     dist = helper.manhattan_dist(from_pos, to_pos)
     if min_range <= dist and dist <= max_range:
         return True
     return False