예제 #1
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
예제 #2
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
예제 #3
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