def berserker_initiate_battle(self, clearing: Clearing) -> None: potential_targets = clearing.get_all_other_players_in_location(self) # Sort in reverse order from our tie-breaking priority: Setup order -> most pieces potential_targets = sort_players_by_setup_order(potential_targets) potential_targets = sort_players_by_pieces_in_clearing(potential_targets, clearing) if potential_targets: self.battle(clearing, potential_targets[0])
def get_battle_target(self) -> Optional[Player]: sorted_players = sort_players_by_setup_order(self.game.players) sorted_players = sort_players_by_victory_points(sorted_players) for player in sorted_players: valid_battle_clearings = [clearing for clearing in self.game.clearings() if clearing.is_player_in_location(player)] if valid_battle_clearings: return player
def aid_step(self) -> None: players_with_crafted_items = [player for player in self.game.players if player.crafted_items] sorted_players_with_crafted_items = sort_players_by_setup_order(players_with_crafted_items) sorted_players_with_crafted_items = sort_players_by_victory_points(sorted_players_with_crafted_items, descending=False) valid_aid_clearings = [clearing for clearing in self.game.clearings() if any(clearing.is_player_in_location(player) for player in players_with_crafted_items)] if not valid_aid_clearings: if self.has_trait(TRAIT_HELPER): return self.helper_aid_step() else: return self.travel_to_target_clearings(valid_aid_clearings, sorting_methods=[sort_paths_by_lexicographic_priority, sort_paths_by_destination_priority, sort_paths_by_destination_player_list, sort_paths_by_distance], arguments=[[], [], [sorted_players_with_crafted_items], []]) if self.get_pawn_location() in valid_aid_clearings: valid_aid_players = [player for player in self.get_pawn_location().get_all_other_players_in_location(self) if player.crafted_items] sorted_valid_aid_players = sort_players_by_setup_order(valid_aid_players) sorted_valid_aid_players = sort_players_by_victory_points(sorted_valid_aid_players) if sorted_valid_aid_players and self.satchel.exhaust_items_if_possible(): item_taken = sorted_valid_aid_players[0].crafted_items.pop() self.get_item(item_taken) self.add_victory_points(1) if not isinstance(sorted_valid_aid_players[0], Player): sorted_valid_aid_players[0].add_card_to_hand(self.game.draw_card()) sorted_valid_aid_players[0].add_victory_points(1)
def perform_special_action(self) -> None: pawn_location = self.player.piece_stock.get_pawn_location() if not isinstance(pawn_location, Clearing): return players_in_clearing = [ player for player in pawn_location.get_all_other_players_in_location(self.player) if player.hand ] sorted_players_in_clearing = sort_players_by_setup_order( players_in_clearing) sorted_players_in_clearing = sort_players_by_pieces_in_clearing( sorted_players_in_clearing, pawn_location) sorted_players_in_clearing = sort_players_by_victory_points( sorted_players_in_clearing) if not sorted_players_in_clearing: return stolen_card = sorted_players_in_clearing[0].take_random_card_from_hand( ) if stolen_card: self.player.game.discard_card(stolen_card) self.player.add_victory_points(1)