def _merge_tribes(self, tribe1: Tribe, tribe2: Tribe, new_tribe_name: Text, gamedb: Database, engine: Engine) -> Tribe: log_message(message=f"Merging tribes into {new_tribe_name}.") with engine: new_tribe = gamedb.tribe(name=new_tribe_name) gamedb.batch_update_tribe(from_tribe=tribe1, to_tribe=new_tribe) gamedb.batch_update_tribe(from_tribe=tribe2, to_tribe=new_tribe) # after tribes merge, sweep the teams to ensure no size of 2 self._merge_teams(target_team_size=self._options.target_team_size, tribe=new_tribe, gamedb=gamedb, engine=engine) game = gamedb.game_from_id(gamedb.get_game_id()) game.count_tribes = 1 gamedb.save(game) return new_tribe
def _merge_tribes(self, tribe1: Tribe, tribe2: Tribe, new_tribe_name: Text, gamedb: Database) -> Tribe: new_tribe = gamedb.tribe(name=new_tribe_name) gamedb.batch_update_tribe(from_tribe=tribe1, to_tribe=new_tribe) gamedb.batch_update_tribe(from_tribe=tribe2, to_tribe=new_tribe) return new_tribe