def directionality(self, from_coordinate): if from_coordinate == self.location: return 'this area' angle = Navigator.angle(from_coordinate, self.location) direction = Navigator.angle_to_direction(angle) return 'the {}'.format(direction.name.lower())
def valid_at(self, cmd, loc): lifeform = cmd.args['player_lifeform'] origin = lifeform.coordinates fog = lifeform.zones.fog_of_war if loc not in fog: return False if not Lunge.has_hostile_at(cmd, loc): return False dist = Navigator.distance(origin, loc) return dist <= self.max_range(cmd)
def compute_weapon_range(self, lifeform, weapon_slot): weapon = getattr(lifeform, weapon_slot, None) if not weapon or not isinstance(weapon, Weapon): return attack_range = weapon.attack_range(lifeform) for coord in self.fog_of_war: if Navigator.distance(coord, lifeform.coordinates) > attack_range: continue if coord not in self.weapon_ranges: self.weapon_ranges[coord] = [] if weapon not in self.weapon_ranges[coord]: self.weapon_ranges[coord].append(weapon)
def check_for_enemies_in_range(self, radius): for loc, enemy in self.enemies_in_fow(): dist = Navigator.distance(self.puppet.coordinates, loc) if dist <= radius: yield loc, enemy
def weapons_in_range(player, loc): dist = Navigator.distance(player.coordinates, loc) for weapon in Attack.valid_weapons(player): if dist <= weapon.attack_range(player): yield weapon
def is_in_valid_range(self, player, weapon, target): dist = Navigator.distance(player.coordinates, target.coordinates) return dist <= weapon.attack_range(player)
def actors_in_range(self, start, distance): for actor in self.actors: if Navigator.distance(start, actor.coordinates) <= distance: yield actor
def vision_penalty(self, other): light = self.world.lighting_at(other.coordinates) distance = Navigator.distance(self.coordinates, other.coordinates) l_penalty = self.light_penalty(light) d_penalty = self.distance_penalty(distance) return (1 - l_penalty) * (1 - d_penalty)
def distance(self, to_coordinate): return Navigator.distance(self.location, to_coordinate)