Esempio n. 1
0
async def test_add_game_connection_twice(game: Game, players,
                                         mock_game_connection):
    """
    When a player disconnects and reconnects to the same game, they should not
    be considered as 'in-lobby' until the new PlayerOptions are received.
    """
    game.state = GameState.LOBBY
    mock_game_connection.player = players.hosting
    mock_game_connection.state = GameConnectionState.CONNECTED_TO_HOST
    # Connect the host
    game.add_game_connection(mock_game_connection)
    game.set_player_option(players.hosting.id, 'Team', 1)
    assert game.players == {players.hosting}
    # Join a new player
    join_conn = add_connected_player(game, players.joining)
    assert game.players == {players.hosting, players.joining}
    # Player leaves
    await game.remove_game_connection(join_conn)
    assert game.players == {players.hosting}
    # Player joins again
    game.add_game_connection(join_conn)
    assert game.to_dict()["num_players"] == 1
    assert game.players == {players.hosting}
    game.set_player_option(players.joining.id, 'Team', 1)
    assert game.players == {players.hosting, players.joining}
    assert game.to_dict()["num_players"] == 2
Esempio n. 2
0
async def test_compute_rating_balanced_teamgame(game: Game, player_factory):
    game.state = GameState.LOBBY
    players = [(player_factory(login=f"{i}",
                               player_id=i,
                               global_rating=rating,
                               with_lobby_connection=False), result, team)
               for i, (rating, result, team) in enumerate([
                   (Rating(1500, 250), 0, 2),
                   (Rating(1700, 120), 0, 2),
                   (Rating(1200, 72), 0, 3),
                   (Rating(1200, 72), 0, 3),
               ], 1)]
    add_connected_players(game, [player for player, _, _ in players])
    for player, _, team in players:
        game.set_player_option(player.id, 'Team', team)
        game.set_player_option(player.id, 'Army', player.id - 1)
    await game.launch()
    for player, result, team in players:
        await game.add_result(player, player.id - 1,
                              'victory' if team == 2 else 'defeat', result)
    result = game.compute_rating()
    for team in result:
        for player, new_rating in team.items():
            assert player in game.players
            assert new_rating != Rating(*player.ratings[RatingType.GLOBAL])
Esempio n. 3
0
async def test_compute_rating_balanced_teamgame(game: Game, create_player):
    await game.clear_data()

    game.state = GameState.LOBBY
    players = [(
        create_player(**info), result, team
    ) for info, result, team in [
        (dict(login='******', id=1, global_rating=Rating(1500, 250.7)), 0,
         1),
        (dict(login='******', id=2, global_rating=Rating(1700, 120.1)), 0,
         1),
        (dict(login='******', id=3, global_rating=Rating(1200, 72.02)),
         0, 2),
        (dict(login='******', id=4, global_rating=Rating(1200, 72.02)), 0,
         2),
    ]]
    add_connected_players(game, [player for player, _, _ in players])
    for player, _, team in players:
        game.set_player_option(player.id, 'Team', team)
        game.set_player_option(player.id, 'Army', player.id - 1)
    await game.launch()
    for player, result, _ in players:
        await game.add_result(player, player.id - 1, 'score', result)
    result = game.compute_rating()
    for team in result:
        for player, new_rating in team.items():
            assert player in game.players
            assert new_rating != Rating(*player.global_rating)
Esempio n. 4
0
def add_connected_player(game: Game, player):
    game.game_service.player_service[player.id] = player
    gc = game_connection(state=GameConnectionState.CONNECTED_TO_HOST, player=player)
    game.set_player_option(player.id, 'Army', 0)
    game.set_player_option(player.id, 'StartSpot', 0)
    game.set_player_option(player.id, 'Team', 0)
    game.set_player_option(player.id, 'Faction', 0)
    game.set_player_option(player.id, 'Color', 0)
    game.add_game_connection(gc)
    return gc
Esempio n. 5
0
def add_connected_player(game: Game, player):
    game.game_service.player_service[player.id] = player
    gc = game_connection(state=GameConnectionState.CONNECTED_TO_HOST, player=player)
    game.set_player_option(player.id, 'Army', 0)
    game.set_player_option(player.id, 'StartSpot', 0)
    game.set_player_option(player.id, 'Team', 0)
    game.set_player_option(player.id, 'Faction', 0)
    game.set_player_option(player.id, 'Color', 0)
    game.add_game_connection(gc)
    return gc
Esempio n. 6
0
async def test_compute_rating_raises_game_error(game: Game, players):
    game.state = GameState.LOBBY
    add_connected_players(game, [players.hosting, players.joining])
    # add_connected_players sets this, so we need to unset it again
    del game._player_options[players.hosting.id]["Team"]
    game.set_player_option(players.joining.id, "Team", 1)
    await game.launch()

    with pytest.raises(GameError):
        game.compute_rating(rating=RatingType.LADDER_1V1)
Esempio n. 7
0
async def test_add_game_connection(game: Game, players, mock_game_connection):
    game.state = GameState.LOBBY
    mock_game_connection.player = players.hosting
    mock_game_connection.state = GameConnectionState.CONNECTED_TO_HOST
    game.add_game_connection(mock_game_connection)
    # Players should not be considered as 'in lobby' until the host has sent
    # "PlayerOption" configuration for them
    assert game.to_dict()["num_players"] == 0
    assert game.players == set()
    game.set_player_option(players.hosting.id, 'Team', 1)
    assert players.hosting in game.players
Esempio n. 8
0
async def test_compute_rating_computes_ladder_ratings(game: Game, players):
    game.state = GameState.LOBBY
    players.hosting.ratings[RatingType.LADDER_1V1] = Rating(1500, 250)
    players.joining.ratings[RatingType.LADDER_1V1] = Rating(1500, 250)
    add_connected_players(game, [players.hosting, players.joining])
    await game.launch()
    await game.add_result(players.hosting.id, 0, 'victory', 1)
    await game.add_result(players.joining.id, 1, 'defeat', 0)
    game.set_player_option(players.hosting.id, 'Team', 1)
    game.set_player_option(players.joining.id, 'Team', 1)
    groups = game.compute_rating(rating=RatingType.LADDER_1V1)
    assert players.hosting in groups[0]
    assert players.joining in groups[1]
Esempio n. 9
0
async def test_compute_rating_computes_global_ratings(game: Game, players):
    await game.clear_data()

    game.state = GameState.LOBBY
    players.hosting.global_rating = Rating(1500, 250)
    players.joining.global_rating = Rating(1500, 250)
    add_connected_players(game, [players.hosting, players.joining])
    await game.launch()
    await game.add_result(players.hosting, 0, 'victory', 1)
    await game.add_result(players.joining, 1, 'defeat', 0)
    game.set_player_option(players.hosting.id, 'Team', 2)
    game.set_player_option(players.joining.id, 'Team', 3)
    groups = game.compute_rating()
    assert players.hosting in groups[0]
    assert players.joining in groups[1]
Esempio n. 10
0
async def test_game_outcomes_no_results(game: Game, players):
    await game.clear_data()

    game.state = GameState.LOBBY
    players.hosting.ladder_rating = Rating(1500, 250)
    players.joining.ladder_rating = Rating(1500, 250)
    add_connected_players(game, [players.hosting, players.joining])
    await game.launch()
    game.set_player_option(players.hosting.id, 'Team', 1)
    game.set_player_option(players.joining.id, 'Team', 1)

    host_outcome = game.outcome(players.hosting)
    guest_outcome = game.outcome(players.joining)
    assert host_outcome is None
    assert guest_outcome is None
Esempio n. 11
0
async def test_compute_rating_computes_ladder_ratings(game: Game, players):
    await game.clear_data()

    game.state = GameState.LOBBY
    players.hosting.ladder_rating = Rating(1500, 250)
    players.joining.ladder_rating = Rating(1500, 250)
    add_connected_players(game, [players.hosting, players.joining])
    await game.launch()
    await game.add_result(players.hosting, 0, 'victory', 1)
    await game.add_result(players.joining, 1, 'defeat', 0)
    game.set_player_option(players.hosting.id, 'Team', 1)
    game.set_player_option(players.joining.id, 'Team', 1)
    groups = game.compute_rating(rating='ladder')
    assert players.hosting in groups[0]
    assert players.joining in groups[1]
Esempio n. 12
0
async def test_game_outcomes_conflicting(game: Game, database, players):
    game.state = GameState.LOBBY
    players.hosting.ratings[RatingType.LADDER_1V1] = Rating(1500, 250)
    players.joining.ratings[RatingType.LADDER_1V1] = Rating(1500, 250)
    add_connected_players(game, [players.hosting, players.joining])
    await game.launch()
    await game.add_result(players.hosting.id, 0, 'victory', 1)
    await game.add_result(players.joining.id, 1, 'victory', 0)
    await game.add_result(players.hosting.id, 0, 'defeat', 1)
    await game.add_result(players.joining.id, 1, 'defeat', 0)
    game.set_player_option(players.hosting.id, 'Team', 1)
    game.set_player_option(players.joining.id, 'Team', 1)

    host_outcome = game.get_player_outcome(players.hosting)
    guest_outcome = game.get_player_outcome(players.joining)
    assert host_outcome is GameOutcome.CONFLICTING
    assert guest_outcome is GameOutcome.CONFLICTING
Esempio n. 13
0
async def test_game_outcomes(game: Game, players):
    await game.clear_data()

    game.state = GameState.LOBBY
    players.hosting.ladder_rating = Rating(1500, 250)
    players.joining.ladder_rating = Rating(1500, 250)
    add_connected_players(game, [players.hosting, players.joining])
    await game.launch()
    await game.add_result(players.hosting, 0, 'victory', 1)
    await game.add_result(players.joining, 1, 'defeat', 0)
    game.set_player_option(players.hosting.id, 'Team', 1)
    game.set_player_option(players.joining.id, 'Team', 1)

    host_outcome = game.outcome(players.hosting)
    guest_outcome = game.outcome(players.joining)
    assert host_outcome is GameOutcome.VICTORY
    assert guest_outcome is GameOutcome.DEFEAT
Esempio n. 14
0
async def test_players_exclude_observers(game: Game):
    game.state = GameState.LOBBY
    players = add_players(game, 2)

    obs = Player(id=3, login='******', global_rating=(1500, 500))

    game.game_service.player_service[obs.id] = obs
    gc = make_mock_game_connection(state=GameConnectionState.CONNECTED_TO_HOST, player=obs)
    game.set_player_option(obs.id, 'Army', -1)
    game.set_player_option(obs.id, 'StartSpot', -1)
    game.set_player_option(obs.id, 'Team', 0)
    game.set_player_option(obs.id, 'Faction', 0)
    game.set_player_option(obs.id, 'Color', 0)
    game.add_game_connection(gc)
    await game.launch()

    assert game.players == frozenset(players)
Esempio n. 15
0
async def test_game_outcomes_no_results(game: Game, database, players):
    game.state = GameState.LOBBY
    players.hosting.ratings[RatingType.LADDER_1V1] = Rating(1500, 250)
    players.joining.ratings[RatingType.LADDER_1V1] = Rating(1500, 250)
    add_connected_players(game, [players.hosting, players.joining])
    await game.launch()
    game.set_player_option(players.hosting.id, 'Team', 1)
    game.set_player_option(players.joining.id, 'Team', 1)

    host_outcome = game.get_player_outcome(players.hosting)
    guest_outcome = game.get_player_outcome(players.joining)
    assert host_outcome is GameOutcome.UNKNOWN
    assert guest_outcome is GameOutcome.UNKNOWN

    await game.on_game_end()
    expected_scores = {(players.hosting.id, 0), (players.joining.id, 0)}
    assert await game_player_scores(database, game) == expected_scores
Esempio n. 16
0
async def test_players_exclude_observers(game: Game):
    game.state = GameState.LOBBY
    players = add_players(game, 2)

    obs = Player(id=3, login='******', global_rating=(1500, 500))

    game.game_service.player_service[obs.id] = obs
    gc = mock_game_connection(state=GameConnectionState.CONNECTED_TO_HOST, player=obs)
    game.set_player_option(obs.id, 'Army', -1)
    game.set_player_option(obs.id, 'StartSpot', -1)
    game.set_player_option(obs.id, 'Team', 0)
    game.set_player_option(obs.id, 'Faction', 0)
    game.set_player_option(obs.id, 'Color', 0)
    game.add_game_connection(gc)
    await game.launch()

    assert game.players == frozenset(players)
Esempio n. 17
0
def add_connected_players(game: Game, players):
    """
    Utility to add players with army and StartSpot indexed by a list
    """
    for army, player in enumerate(players):
        add_connected_player(game, player)
        game.set_player_option(player.id, 'Army', army)
        game.set_player_option(player.id, 'StartSpot', army)
        game.set_player_option(player.id, 'Team', army)
        game.set_player_option(player.id, 'Faction', 0)
        game.set_player_option(player.id, 'Color', 0)
    game.host = players[0]
Esempio n. 18
0
def add_connected_players(game: Game, players):
    """
    Utility to add players with army and StartSpot indexed by a list
    """
    for army, player in enumerate(players):
        add_connected_player(game, player)
        game.set_player_option(player.id, 'Army', army)
        game.set_player_option(player.id, 'StartSpot', army)
        game.set_player_option(player.id, 'Team', army)
        game.set_player_option(player.id, 'Faction', 0)
        game.set_player_option(player.id, 'Color', 0)
    game.host = players[0]
Esempio n. 19
0
async def test_compute_rating_does_not_rate_double_win(game: Game,
                                                       player_factory):
    game.state = GameState.LOBBY
    players = [(player_factory(f"{i}", player_id=i,
                               global_rating=rating), result, team)
               for i, (rating, result, team) in enumerate([
                   (Rating(1500, 250), 10, 2),
                   (Rating(1700, 120), 0, 3),
               ], 1)]
    add_connected_players(game, [player for player, _, _ in players])
    for player, _, team in players:
        game.set_player_option(player.id, 'Team', team)
        game.set_player_option(player.id, 'Army', player.id - 1)
    await game.launch()

    for player, result, _ in players:
        await game.add_result(player, player.id - 1, 'victory', result)
    with pytest.raises(GameRatingError):
        game.compute_rating()
Esempio n. 20
0
async def test_single_wrong_report_still_rated_correctly(
        game: Game, player_factory):
    # based on replay with UID 11255492

    # Mocking out database calls, since not all player IDs exist.
    game.update_game_player_stats = CoroutineMock()

    game.state = GameState.LOBBY

    # Loading log data
    with open("tests/data/uid11255492.log.json", "r") as f:
        log_dict = json.load(f)

    old_rating = 1500
    players = {
        player_id: player_factory(
            login=f"{player_id}",
            player_id=player_id,
            global_rating=Rating(old_rating, 250),
            with_lobby_connection=False,
        )
        for team in log_dict["teams"].values() for player_id in team
    }

    add_connected_players(game, list(players.values()))
    for team_id, team_list in log_dict["teams"].items():
        for player_id in team_list:
            game.set_player_option(player_id, "Team", team_id)
            game.set_player_option(player_id, "Army", player_id - 1)
    await game.launch()

    for reporter, reportee, outcome, score in log_dict["results"]:
        await game.add_result(players[reporter], reportee, outcome, score)

    result = game.compute_rating()
    winning_ids = log_dict["teams"][str(log_dict["winning_team"])]
    for team in result:
        for player, new_rating in team.items():
            assert player in game.players
            player_is_on_winning_team = player.id in winning_ids
            rating_improved = new_rating.mu > old_rating
            assert rating_improved is player_is_on_winning_team
Esempio n. 21
0
async def test_compute_rating_only_one_surviver(game: Game, player_factory):
    """
    When a player dies their score is reported as "defeat", but this does not
    necessarily mean they lost the game, if their team mates went on and later
    reported a "victory".
    """
    game.state = GameState.LOBBY
    win_team = 2
    lose_team = 3
    players = [(player_factory(login=f"{i}",
                               player_id=i,
                               global_rating=Rating(1500, 200),
                               with_lobby_connection=False), outcome, result,
                team) for i, (outcome, result, team) in enumerate([
                    ("defeat", -10, lose_team),
                    ("defeat", -10, lose_team),
                    ("defeat", -10, lose_team),
                    ("defeat", -10, lose_team),
                    ("defeat", -10, win_team),
                    ("defeat", -10, win_team),
                    ("defeat", -10, win_team),
                    ("victory", 10, win_team),
                ], 1)]
    add_connected_players(game, [player for player, _, _, _ in players])
    for player, _, _, team in players:
        game.set_player_option(player.id, 'Team', team)
        game.set_player_option(player.id, 'Army', player.id - 1)
    await game.launch()

    for player, outcome, result, team in players:
        await game.add_result(player, player.id - 1, outcome, result)

    result = game.compute_rating()
    for team in result:
        for player, new_rating in team.items():
            old_rating = Rating(*player.ratings[RatingType.GLOBAL])
            # `team` index in result might not coincide with `team` index in players
            if player.id > 4:
                assert new_rating > old_rating
            else:
                assert new_rating < old_rating
Esempio n. 22
0
async def test_compute_rating_sum_of_scores_edge_case(game: Game,
                                                      player_factory):
    """
    For certain scores, compute_rating was determining the winner incorrectly,
    see issue <https://github.com/FAForever/server/issues/485>.
    """
    game.state = GameState.LOBBY
    win_team = 2
    lose_team = 3
    players = [(player_factory(login=f"{i}",
                               player_id=i,
                               global_rating=rating,
                               with_lobby_connection=False), result, team)
               for i, (rating, result, team) in enumerate([
                   (Rating(1500, 200), 1, lose_team),
                   (Rating(1500, 200), 1, lose_team),
                   (Rating(1500, 200), 1, lose_team),
                   (Rating(1500, 200), -10, lose_team),
                   (Rating(1500, 200), 10, win_team),
                   (Rating(1500, 200), -10, win_team),
                   (Rating(1500, 200), -10, win_team),
                   (Rating(1500, 200), 2, win_team),
               ], 1)]
    add_connected_players(game, [player for player, _, _ in players])
    for player, _, team in players:
        game.set_player_option(player.id, 'Team', team)
        game.set_player_option(player.id, 'Army', player.id - 1)
    await game.launch()

    for player, result, team in players:
        outcome = 'victory' if team is win_team else 'defeat'
        await game.add_result(player, player.id - 1, outcome, result)

    result = game.compute_rating()
    for team in result:
        for player, new_rating in team.items():
            old_rating = Rating(*player.ratings[RatingType.GLOBAL])
            if player.id > 4:  # `team` index in result might not coincide with `team` index in players
                assert new_rating > old_rating
            else:
                assert new_rating < old_rating
Esempio n. 23
0
async def test_compute_rating_two_player_FFA(game: Game, player_factory):
    game.state = GameState.LOBBY
    players = [(player_factory(f"{i}", player_id=i,
                               global_rating=rating), result, team)
               for i, (rating, result, team) in enumerate([
                   (Rating(1500, 250), 0, 1),
                   (Rating(1700, 120), 0, 1),
               ], 1)]
    add_connected_players(game, [player for player, _, _ in players])
    for player, _, team in players:
        game.set_player_option(player.id, 'Team', team)
        game.set_player_option(player.id, 'Army', player.id - 1)
    await game.launch()

    for player, result, _ in players:
        outcome = 'victory' if player.id == 1 else 'defeat'
        await game.add_result(player, player.id - 1, outcome, result)
    result = game.compute_rating()
    for team in result:
        for player, new_rating in team.items():
            old_rating = Rating(*player.ratings[RatingType.GLOBAL])
            assert (new_rating > old_rating) is (player.id == 1)
Esempio n. 24
0
async def test_game_ends_in_mutually_agreed_draw(game: Game):
    await game.clear_data()
    game.state = GameState.LOBBY
    players = [
        Player(id=1, login='******', global_rating=(1500, 500)),
        Player(id=2, login='******', global_rating=(1500, 500))
    ]
    add_connected_players(game, players)
    await game.launch()

    for player in players:
        game.set_player_option(player.id, 'Team', 1)
        game.set_player_option(player.id, 'Army', player.id - 1)

    game.state = GameState.LIVE
    game.launched_at = time.time() - 60 * 60

    await game.add_result(players[0], 0, 'mutual_draw', 0)
    await game.add_result(players[1], 1, 'mutual_draw', 0)
    await game.on_game_end()

    assert game.validity is ValidityState.MUTUAL_DRAW
Esempio n. 25
0
async def test_compute_rating_treats_double_defeat_as_draw(
        game: Game, player_factory):
    game.state = GameState.LOBBY
    players = [(player_factory(f"{i}", player_id=i,
                               global_rating=rating), result, team)
               for i, (rating, result, team) in enumerate([
                   (Rating(1500, 250), 10, 2),
                   (Rating(1500, 250), 0, 3),
               ], 1)]
    add_connected_players(game, [player for player, _, _ in players])
    for player, _, team in players:
        game.set_player_option(player.id, 'Team', team)
        game.set_player_option(player.id, 'Army', player.id - 1)
    await game.launch()

    for player, result, _ in players:
        await game.add_result(player, player.id - 1, 'defeat', result)
    result = game.compute_rating()
    for team in result:
        for _, new_rating in team.items():
            old_rating = Rating(*player.ratings[RatingType.GLOBAL])
            assert new_rating.mu == old_rating.mu
            assert new_rating.sigma < old_rating.sigma
Esempio n. 26
0
async def test_game_outcomes(game: Game, database, players):
    game.state = GameState.LOBBY
    players.hosting.ratings[RatingType.LADDER_1V1] = Rating(1500, 250)
    players.joining.ratings[RatingType.LADDER_1V1] = Rating(1500, 250)
    add_connected_players(game, [players.hosting, players.joining])
    await game.launch()
    await game.add_result(players.hosting.id, 0, 'victory', 1)
    await game.add_result(players.joining.id, 1, 'defeat', 0)
    game.set_player_option(players.hosting.id, 'Team', 1)
    game.set_player_option(players.joining.id, 'Team', 1)

    host_outcome = game.get_player_outcome(players.hosting)
    guest_outcome = game.get_player_outcome(players.joining)
    assert host_outcome is GameOutcome.VICTORY
    assert guest_outcome is GameOutcome.DEFEAT

    default_values_before_end = {(players.hosting.id, 0),
                                 (players.joining.id, 0)}
    assert await game_player_scores(database,
                                    game) == default_values_before_end

    await game.on_game_end()
    expected_scores = {(players.hosting.id, 1), (players.joining.id, 0)}
    assert await game_player_scores(database, game) == expected_scores
Esempio n. 27
0
async def test_compute_rating_works_with_partially_unknown_results(
        game: Game, player_factory):
    game.state = GameState.LOBBY
    players = [(player_factory(f"{i}", player_id=i,
                               global_rating=rating), result, team)
               for i, (rating, result, team) in enumerate([
                   (Rating(1500, 250), 10, 2),
                   (Rating(1700, 120), 0, 2),
                   (Rating(1200, 72), -10, 3),
                   (Rating(1200, 72), 0, 3),
               ], 1)]
    add_connected_players(game, [player for player, _, _ in players])
    for player, _, team in players:
        game.set_player_option(player.id, 'Team', team)
        game.set_player_option(player.id, 'Army', player.id - 1)
    await game.launch()

    for player, result, _ in players:
        outcome = 'victory' if result == 10 else 'unknown'
        await game.add_result(player, player.id - 1, outcome, result)
    result = game.compute_rating()
    for team in result:
        for player, new_rating in team.items():
            assert new_rating != Rating(*player.ratings[RatingType.GLOBAL])
Esempio n. 28
0
async def test_compute_rating_balanced_teamgame(game: Game, create_player):
    await game.clear_data()

    game.state = GameState.LOBBY
    players = [
        (create_player(**info), result, team) for info, result, team in [
            (dict(login='******', id=1, global_rating=Rating(1500, 250.7)), 0, 1),
            (dict(login='******', id=2, global_rating=Rating(1700, 120.1)), 0, 1),
            (dict(login='******', id=3, global_rating=Rating(1200, 72.02)), 0, 2),
            (dict(login='******', id=4, global_rating=Rating(1200, 72.02)), 0, 2),
        ]
    ]
    add_connected_players(game, [player for player, _, _ in players])
    for player, _, team in players:
        game.set_player_option(player.id, 'Team', team)
        game.set_player_option(player.id, 'Army', player.id - 1)
    await game.launch()
    for player, result, _ in players:
        await game.add_result(player, player.id - 1, 'score', result)
    result = game.compute_rating()
    for team in result:
        for player, new_rating in team.items():
            assert player in game.players
            assert new_rating != Rating(*player.global_rating)
Esempio n. 29
0
def test_game_teams_represents_active_teams(game: Game, players):
    game.state = GameState.LOBBY
    add_connected_players(game, [players.hosting, players.joining])
    game.set_player_option(players.hosting.id, 'Team', 1)
    game.set_player_option(players.joining.id, 'Team', 2)
    assert game.teams == {1, 2}
Esempio n. 30
0
def test_game_teams_represents_active_teams(game: Game, players):
    game.state = GameState.LOBBY
    add_connected_players(game, [players.hosting, players.joining])
    game.set_player_option(players.hosting.id, 'Team', 1)
    game.set_player_option(players.joining.id, 'Team', 2)
    assert game.teams == {1, 2}