コード例 #1
0
 def test_get_current_round_results(self):
     signature = GameSignature(1, 1, 1, 1)
     game_results = {'player1': 1, 'player2': 2}
     round_results1 = {signature: game_results}
     self.ts.add_round_results(round_results1)
     signature = copy(signature)
     signature.round_id = 2
     game_results = {'player1': 3, 'player2': 4}
     round_results2 = {signature: game_results}
     self.ts.add_round_results(round_results2)
     self.assertEqual(self.ts.get_current_round_results(), round_results1)
コード例 #2
0
ファイル: tournament.py プロジェクト: dimatomp/play
    def run(self):
        '''
        Getting results of tournament.
        '''
        logger.info('running tournament #%d', self.tournament_id)

        game_signature = GameSignature(self.tournament_id)

        self.tournament_system = create()(self.players_list)
        for round_id, players in enumerate(self.tournament_system.get_rounds()):
            game_signature.round_id = round_id
            # If our tournament can give names to rounds, e.g. olympic,
            # we should also assign a name to the round. But it is also
            # possible, that get_round_name returns None.
            game_signature.round_name = self.tournament_system.get_round_name(
                round_id, len(list(self.tournament_system.get_rounds())))
            _round = Round(list(players), game_signature)
            _round.run()
            _round_results = _round.games_results
            self.tournament_system.add_round_results(_round_results)
        self.results = self.tournament_system.get_all_results()
        logger.info('tournament #%d finished', self.tournament_id)