Beispiel #1
0
def test_game_check_winner_no_hope(mock_get_movable_spots):
    """
    Assert a winner when no players can catch leader
    """
    mock_get_movable_spots.return_value = [(0, 0), (0, 1), (0, 2)]

    a_game = Game()
    a_game.settings["player_count"] = 3
    a_game.add_player("player1")
    a_game.add_player("player2")
    a_game.add_player("player3")
    a_game.start()

    # Fudge the scores so there are just enough available spots
    a_game._scores = [
        {"controlled": 0},
        {"controlled": 10},
        {"controlled": 8},
        {"controlled": 3},
    ]
    assert not a_game._check_for_winners()

    # Fudge the scores so there are not enough available spots
    a_game._scores = [
        {"controlled": 0},
        {"controlled": 10},
        {"controlled": 4},
        {"controlled": 3},
    ]
    assert a_game._check_for_winners()
Beispiel #2
0
def test_game_check_winner_majority():
    """
    Assert a winner exists when a player controls the majority of spots
    """
    a_game = Game()
    a_game.settings["player_count"] = 2
    a_game.add_player("player1")
    a_game.add_player("player2")
    a_game.start()

    # Fudge the scores so we have just under majority
    a_game._scores = [{"controlled": 0}, {"controlled": 199}, {"controlled": 53}]
    assert not a_game._check_for_winners()

    # Fudge the scores so we now have a majority
    a_game._scores = [{"controlled": 0}, {"controlled": 201}, {"controlled": 53}]
    assert a_game._check_for_winners()
Beispiel #3
0
def test_game_check_winner_no_availability(mock_get_movable_spots):
    """
    Assert a winner exists when no spots are available
    """
    mock_get_movable_spots.return_value = []

    a_game = Game()
    a_game.settings["player_count"] = 2
    a_game.add_player("player1")
    a_game.add_player("player2")
    a_game.start()

    assert a_game._check_for_winners()