def build_base(self, x, y): # Custom log messages n = FilterFactory().attack_filter(AttackNearestFilter) Logger.log('Building base') base_pos = OffsetPosition(x, y).offset self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.BASE, base_pos, [n], [])) base_pos = OffsetPosition(-5, -5).offset self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.MAGICIAN, base_pos, [n], [])) base_pos = OffsetPosition(-4, -5).offset self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.MAGICIAN, base_pos, [n], [])) base_pos = OffsetPosition(-5, -4).offset self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.MAGICIAN, base_pos, [n], [])) base_pos = OffsetPosition(-4, -3).offset self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.ARCHER, base_pos, [n], [])) base_pos = OffsetPosition(-3, -5).offset self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.ARCHER, base_pos, [n], []))
def build_base(self, position_q: int, position_r: int): Logger.log('Building base') self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.BASE, OffsetPosition(int(position_q), int(position_r)), [], []))
def place_guard(self, z: int): Logger.log('Placing guards') troop = GameObjectType.ARCHER if z == 1: troop = GameObjectType.ARCHER if z == 2: troop = GameObjectType.KNIGHT if z == 3: troop = GameObjectType.DRUID x = CubicPosition(-1, 1, 0) self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], [])) x = CubicPosition(-1, 0, 1) self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], [])) x = CubicPosition(0, -1, 1) self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], [])) x = CubicPosition(0, 1, -1) self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], [])) x = CubicPosition(1, -1, 0) self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], [])) x = CubicPosition(1, 0, -1) self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], []))
def place_base(self): Logger.log('Place on 0 0 0') base_position = CubicPosition(0, 0, 0) self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.BASE, base_position, [], [])) self.place_guard(1)
def build_base_good(self, found_good): # Custom log messages n = FilterFactory().attack_filter(AttackNearestFilter) Logger.log('Building base') base_pos = found_good self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.BASE, base_pos, [n], []))
def filter(self, position: Position, tiles: List[Position]) -> List[Position]: """ :param position: Current positions of game object :param tiles: List of all tiles, where unit could attack (based on visibility, attack range, etc.) :return: List of position, that left after filtering """ Logger.log(self.log_text) return tiles
def build_ent(self, **kwargs): pos = None for key in ('ideal_tile', 'position_first_round', 'position_second_round', 'position_third_round'): if key in kwargs: pos = kwargs[key] Logger.log('Building ent') self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.ENT, pos, [], []))
def has_guards(self) -> bool: Logger.log('has_guards') base_position = CubicPosition(0, 0, 0) flag = True for z in base_position.get_all_neighbours(): if self.game_object_proxy.get_object_type( z) != GameObjectType.ARCHER: flag = False Logger.log('Not all guards') return flag
def place_extended(self): Logger.log('Placing extended soldiers') base_position = CubicPosition(0, 0, 0) for z in base_position.get_all_neighbours(): for x in z.get_all_neighbours(): if self.map_proxy.is_position_occupied(x): continue self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.KNIGHT, x, [], []))
def build_magician(self, allowed, **kwargs): pos = None for key in ('ideal_tile', 'position_first_round', 'position_second_round', 'position_third_round', 'pos'): if key in kwargs: pos = kwargs[key] if allowed == 0 or not isinstance(pos, OffsetPosition): pass else: Logger.log('Building magician') self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.MAGICIAN, pos, [], []))
def build_base(self, position_q: int, position_r: int): # Custom log messages Logger.log('Building base') empty_filter = FilterFactory().attack_filter(EmptyAttackFilter) dummy_filter = FilterFactory().attack_filter(DummyAttackFilter, 'Base attacking') # Create instance of default filter strongest_filter = FilterFactory().attack_filter(AttackStrongestFilter) self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.BASE, OffsetPosition(int(position_q), int(position_r)), [], []))
def build_druid(self, allowed, **kwargs): pos = None print("build druid nmb", allowed) for key in ('ideal_tile', 'position_first_round', 'position_second_round', 'position_third_round'): if key in kwargs: pos = kwargs[key] if allowed == 0: print("not allowed to build druid") pass else: Logger.log('Building druid') self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.DRUID, pos, [], []))
def place_druid_square(self): Logger.log('Placing druid in corner') x = CubicPosition(-2, 2, 0) troop = GameObjectType.DRUID if not self.map_proxy.is_position_occupied(x): self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], [])) x = CubicPosition(-2, 0, 2) if not self.map_proxy.is_position_occupied(x): self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], [])) x = CubicPosition(2, 0, -2) if not self.map_proxy.is_position_occupied(x): self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], [])) x = CubicPosition(2, -2, 0) if not self.map_proxy.is_position_occupied(x): self.game_control_proxy.spawn_unit( SpawnInformation(self.player, troop, x, [], []))
def build_magician(self, position_q: int, position_r: int): Logger.log('Building magician') self.game_control_proxy.spawn_unit( SpawnInformation(self.player, GameObjectType.MAGICIAN, OffsetPosition(int(position_q), int(position_r)), [], []))
def filter(self, position: Position, tiles: List[Position]) -> List[Position]: Logger.log(self.log_text) return tiles