コード例 #1
0
ファイル: test_game.py プロジェクト: 0x647262/server
async def test_partial_stats_not_affecting_rating_persistence(
        custom_game, event_service, achievement_service, game_add_players,
        rating_service):
    from server.stats.game_stats_service import GameStatsService
    game = custom_game
    game._game_stats_service = GameStatsService(event_service,
                                                achievement_service)
    game.state = GameState.LOBBY
    players = game_add_players(game, 2)
    game.set_player_option(players[0].id, "Team", 2)
    game.set_player_option(players[1].id, "Team", 3)
    old_mean = players[0].ratings[RatingType.GLOBAL][0]

    await game.launch()
    game.launched_at = time.time() - 60 * 60
    await game.add_result(0, 0, "victory", 10)
    await game.add_result(0, 1, "defeat", -10)
    game.report_army_stats('{"stats": []}')
    await game.on_game_end()

    # await game being rated
    await rating_service._join_rating_queue()

    assert game.validity is ValidityState.VALID
    assert players[0].ratings[RatingType.GLOBAL][0] > old_mean
コード例 #2
0
async def test_partial_stats_not_affecting_rating_persistence(custom_game, event_service, achievement_service):
    from server.stats.game_stats_service import GameStatsService
    game = custom_game
    game._game_stats_service = GameStatsService(event_service, achievement_service)
    game.state = GameState.LOBBY
    players = add_players(game, 2)
    game.set_player_option(players[0].id, 'Team', 2)
    game.set_player_option(players[1].id, 'Team', 3)
    old_mean = players[0].global_rating[0]

    await game.launch()
    game.launched_at = time.time()-60*60
    await game.add_result(0, 0, 'victory', 10)
    await game.add_result(0, 1, 'defeat', -10)
    await game.report_army_stats({'stats': {'Player 1': {}}})
    await game.on_game_end()

    assert game.validity is ValidityState.VALID
    assert players[0].global_rating[0] > old_mean
コード例 #3
0
ファイル: server.py プロジェクト: b2ag/server
        signal.signal(signal.SIGINT, signal_handler)

        pool_fut = asyncio. async (server.db.connect(host=DB_SERVER,
                                                     port=int(DB_PORT),
                                                     user=DB_LOGIN,
                                                     password=DB_PASSWORD,
                                                     maxsize=10,
                                                     db=DB_NAME,
                                                     loop=loop))
        db_pool = loop.run_until_complete(pool_fut)

        players_online = PlayerService(db_pool)
        api_accessor = ApiAccessor()
        event_service = EventService(api_accessor)
        achievement_service = AchievementService(api_accessor)
        game_stats_service = GameStatsService(event_service,
                                              achievement_service)

        natpacket_server = NatPacketServer(
            addresses=config.LOBBY_NAT_ADDRESSES, loop=loop)
        loop.run_until_complete(natpacket_server.listen())
        server.NatPacketServer.instance = natpacket_server

        games = GameService(players_online, game_stats_service)
        matchmaker_queue = MatchmakerQueue('ladder1v1', players_online, games)
        players_online.ladder_queue = matchmaker_queue

        ctrl_server = loop.run_until_complete(
            server.run_control_server(loop, players_online, games))

        lobby_server = server.run_lobby_server(('', 8001), players_online,
                                               games, loop)
コード例 #4
0
ファイル: conftest.py プロジェクト: 46bit/faforever-server
def game_stats_service(event_service, achievement_service):
    from server.stats.game_stats_service import GameStatsService
    return GameStatsService(event_service, achievement_service)
コード例 #5
0
def game_stats_service(event_service, achievement_service):
    return GameStatsService(event_service, achievement_service)