def free_locations_around(level, location): """ Get passable nodes around given location """ # TODO: eventually remove this return [node for node in area_4_around(location) if not blocks_movement(level, location)]
def free_locations_around(level, location): """ Get passable nodes around given location """ # TODO: eventually remove this return [ node for node in area_4_around(location) if not blocks_movement(level, location) ]
def get_target_in_direction(level, location, direction, attack_range=100): """ Get target of the attack :param level: level to operate :type level: Level :param location: start location :type location: (int, int) :param direction: direction to follow :type direction: int :returns: target character if found, otherwise None :rtype: Character """ target = None target_location = location target_data = None if direction == 9: return TargetData('void', None, None, None) off_sets = [(0, 0), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1)] while (target is None and distance_between(location, target_location) <= attack_range): target_location = tuple([x for x in map(sum, zip(target_location, off_sets[direction]))]) if blocks_movement(level, target_location): target_data = TargetData('wall', target_location, None, target_data) target = target_data else: target = get_character(level, target_location) if target: target_data = TargetData('character', target_location, target, target_data) target = target_data else: target_data = TargetData('void', target_location, None, target_data) return target_data
def get_target_in_direction(level, location, direction, attack_range=100): """ Get target of the attack :param level: level to operate :type level: Level :param location: start location :type location: (int, int) :param direction: direction to follow :type direction: int :returns: target character if found, otherwise None :rtype: Character """ target = None target_location = location target_data = None if direction == 9: return TargetData('void', None, None, None) off_sets = [(0, 0), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1)] while (target is None and distance_between(location, target_location) <= attack_range): target_location = tuple( [x for x in map(sum, zip(target_location, off_sets[direction]))]) if blocks_movement(level, target_location): target_data = TargetData('wall', target_location, None, target_data) target = target_data else: target = get_character(level, target_location) if target: target_data = TargetData('character', target_location, target, target_data) target = target_data else: target_data = TargetData('void', target_location, None, target_data) return target_data