当前位置: 首页>>代码示例>>Python>>正文


Python Game.set_player_option方法代码示例

本文整理汇总了Python中server.games.game.Game.set_player_option方法的典型用法代码示例。如果您正苦于以下问题:Python Game.set_player_option方法的具体用法?Python Game.set_player_option怎么用?Python Game.set_player_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在server.games.game.Game的用法示例。


在下文中一共展示了Game.set_player_option方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_connected_player

# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import set_player_option [as 别名]
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
开发者ID:yorick-ne,项目名称:server,代码行数:12,代码来源:test_game.py

示例2: test_compute_rating_computes_ladder_ratings

# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import set_player_option [as 别名]
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]
开发者ID:FAForever,项目名称:server,代码行数:17,代码来源:test_game.py

示例3: test_players_exclude_observers

# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import set_player_option [as 别名]
async def test_players_exclude_observers(game: Game):
    game.state = GameState.LOBBY
    players = add_players(game, 2)

    obs = Player(id=3, login='Zoidberg', 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)
开发者ID:FAForever,项目名称:server,代码行数:19,代码来源:test_game.py

示例4: add_connected_players

# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import set_player_option [as 别名]
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]
开发者ID:yorick-ne,项目名称:server,代码行数:14,代码来源:test_game.py

示例5: test_compute_rating_balanced_teamgame

# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import set_player_option [as 别名]
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='Paula_Bean', id=1, global_rating=Rating(1500, 250.7)), 0, 1),
            (dict(login='Some_Guy', id=2, global_rating=Rating(1700, 120.1)), 0, 1),
            (dict(login='Some_Other_Guy', id=3, global_rating=Rating(1200, 72.02)), 0, 2),
            (dict(login='That_Person', 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)
开发者ID:FAForever,项目名称:server,代码行数:26,代码来源:test_game.py

示例6: test_game_teams_represents_active_teams

# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import set_player_option [as 别名]
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}
开发者ID:FAForever,项目名称:server,代码行数:8,代码来源:test_game.py


注:本文中的server.games.game.Game.set_player_option方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。