本文整理汇总了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
示例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]
示例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)
示例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]
示例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)
示例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}