Ejemplo n.º 1
0
    def test_stats(self):
        t1_skill = 10
        t2_skill = 0
        team1 = Team("T1", t1_skill, True, "1")
        team2 = Team("T2", t2_skill, True, "2")

        record1 = Record(1, team1, 1, 0, 0, 0, 0, 0, 0, "3")
        record2 = Record(1, team2, 1, 0, 0, 0, 0, 0, 0, "3")

        rules = GameRules("Rules", True, "4")

        for i in range(1000):
            game = Game(1, 1, team1, team2, 0, 0, False, False, rules, str(i))
            game.play()
            record1.process_game(game.home_score, game.away_score)
            record2.process_game(game.away_score, game.home_score)

        print()
        print("Results")
        print(RecordView.get_table_header())
        print(
            RecordView.get_table_row(
                RecordService.get_view_from_model(record1)))
        print(
            RecordView.get_table_row(
                RecordService.get_view_from_model(record2)))
Ejemplo n.º 2
0
    def test_process_game_tie(self):
        record = Record(-1, "Me", -1, 0, 0, 0, 0, 0, 0, "")

        record.process_game(2, 2)

        self.assertEqual(0, record.wins)
        self.assertEqual(0, record.loses)
        self.assertEqual(1, record.ties)
        self.assertEqual(2, record.goals_for)
        self.assertEqual(2, record.goals_against)