コード例 #1
0
    def test_hunter_wins(caplog: pytest.LogCaptureFixture,
                         large_game_roles: tuple[Role, ...]) -> None:
        """
        Should declare Village victory if no wolves are found,
        Hunter is killed, and Hunter voted for a true Wolf.
        """
        set_roles(*large_game_roles[::-1])
        guessed_wolf_inds = [0, 9]
        vote_inds = (7, 10, 0, 9, 7, 9, 7, 7, 7, 0, 0, 0)
        expected = (
            "Player 0 was chosen as a Wolf.",
            "Player 0 was a Hunter!\n",
            "(Player 0) Hunter died and killed Player 7 too!\n",
            "Player 9 was chosen as a Wolf.",
            "Player 9 was a Tanner!\n",
            "Player 7 was chosen as a Wolf.",
            "Player 7 was a Wolf!\n",
            "Village Team wins!",
        )

        result = one_night.eval_winning_team(const.ROLES, guessed_wolf_inds,
                                             vote_inds)

        assert result is Team.VILLAGE
        verify_output(caplog, expected)
コード例 #2
0
    def test_werewolf_wins(caplog: pytest.LogCaptureFixture,
                           medium_game_roles: tuple[Role, ...]) -> None:
        """Should declare Werewolf victory if no wolves are found, but one exists."""
        guessed_wolf_inds = list(range(const.NUM_PLAYERS))
        vote_inds = (1, ) * const.NUM_PLAYERS

        result = one_night.eval_winning_team(medium_game_roles,
                                             guessed_wolf_inds, vote_inds)

        expected = (
            "No wolves were found.",
            "But Player(s) [2] was a Wolf!\n",
            "Werewolf Team wins!",
        )
        assert result is Team.WEREWOLF
        verify_output(caplog, expected)
コード例 #3
0
    def test_village_wins_no_wolf(caplog: pytest.LogCaptureFixture,
                                  small_game_roles: tuple[Role, ...]) -> None:
        """
        Should declare Villager victory if no wolves are found, and there are none.
        """
        guessed_wolf_inds = list(range(const.NUM_PLAYERS))
        vote_inds = (1, ) * const.NUM_PLAYERS

        result = one_night.eval_winning_team(small_game_roles,
                                             guessed_wolf_inds, vote_inds)

        expected = (
            "No wolves were found.",
            "That was correct!\n",
            "Village Team wins!",
        )
        assert result is Team.VILLAGE
        verify_output(caplog, expected)
コード例 #4
0
    def test_village_wins_found_wolf(
            caplog: pytest.LogCaptureFixture,
            medium_game_roles: tuple[Role, ...]) -> None:
        """
        Should declare Villager victory if no wolves are found, and there are none.
        """
        guessed_wolf_inds = [2]
        vote_inds = (1, 2, 2, 2, 1)

        result = one_night.eval_winning_team(medium_game_roles,
                                             guessed_wolf_inds, vote_inds)

        expected = (
            "Player 2 was chosen as a Wolf.",
            "Player 2 was a Wolf!\n",
            "Village Team wins!",
        )
        assert result is Team.VILLAGE
        verify_output(caplog, expected)
コード例 #5
0
ファイル: stats_test.py プロジェクト: TylerYep/wolfbot
    def test_print_statistics(caplog: pytest.LogCaptureFixture,
                              example_medium_game_result: GameResult) -> None:
        """Should correctly print out the current statistics for the games."""
        stat_tracker = Statistics()
        stat_tracker.add_result(example_medium_game_result)

        stat_tracker.print_statistics()

        expected = (
            "\nNumber of Games: 1",
            "Accuracy for all predictions       : 4/6 (66.7%)",
            "Accuracy with lenient center scores: 4/6 (66.7%)",
            "S1: Found at least 1 Wolf player   : 0/1 (0.0%)",
            "S2: Found all Wolf players         : 0/1 (0.0%)",
            "Percentage of correct Wolf guesses : 0/1 (0.0%)",
            "Percentage of Villager Team wins   : 0/1 (0.0%)",
            "Percentage of Tanner Team wins     : 0/1 (0.0%)",
            "Percentage of Werewolf Team wins   : 1/1 (100.0%)",
        )
        verify_output(caplog, expected)
コード例 #6
0
    def test_tanner_wins(caplog: pytest.LogCaptureFixture,
                         large_game_roles: tuple[Role, ...]) -> None:
        """
        Should declare Tanner victory if no wolves are found, and Tanner was chosen.
        """
        guessed_wolf_inds = [2, 5]
        vote_inds = (8, 7, 1, 9, 5, 10, 5, 3, 3, 10, 10, 3)

        result = one_night.eval_winning_team(large_game_roles,
                                             guessed_wolf_inds, vote_inds)

        expected = (
            "Player 2 was chosen as a Wolf.",
            "Player 2 was a Robber!\n",
            "Player 5 was chosen as a Wolf.",
            "Player 5 was a Tanner!\n",
            "Tanner wins!",
        )
        assert result is Team.TANNER
        verify_output(caplog, expected)