コード例 #1
0
    def __init__(self, division: int, blue_bot: VersionedBot, orange_bot: VersionedBot, ladder: Ladder, versioned_map,
                 old_match_result: MatchResult, rr_bots: List[str], rr_results: List[MatchResult], message: str=''):
        self.division = division
        self.blue_config_path = blue_bot.bot_config.config_path if blue_bot is not None else None
        self.orange_config_path = orange_bot.bot_config.config_path if orange_bot is not None else None
        self.ladder = ladder.bots
        self.division_names = Ladder.DIVISION_NAMES[:ladder.division_count()]
        self.old_match_result = {
            'winner': old_match_result.winner,
            'loser': old_match_result.loser,
            'blue_goals': old_match_result.blue_goals,
            'orange_goals': old_match_result.orange_goals} if old_match_result is not None else None
        self.division_bots = ladder.round_robin_participants(division)
        self.rr_bots = rr_bots
        self.rr_results = [convert_match_result(mr) for mr in rr_results]
        self.blue_name = blue_bot.bot_config.name if blue_bot is not None else ''
        self.orange_name = orange_bot.bot_config.name if orange_bot is not None else ''
        self.message = message

        self.bot_map = {}
        for bot in ladder.bots:
            self.bot_map[bot] = {
                'name': versioned_map[bot].bot_config.name,
                'updated_date': (versioned_map[bot].updated_date + timedelta(seconds=0)).timestamp(),
            }
コード例 #2
0
def get_playing_division_indices(ladder: Ladder, odd_week: bool) -> List[int]:
    # Result is a list containing either even or odd indices.
    # If there is only one division always play that division (division 0, quantum).
    return range(
        ladder.division_count())[int(odd_week) %
                                 2::2] if ladder.division_count() > 1 else [0]