本文整理汇总了Python中server.games.game.Game.add_game_connection方法的典型用法代码示例。如果您正苦于以下问题:Python Game.add_game_connection方法的具体用法?Python Game.add_game_connection怎么用?Python Game.add_game_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server.games.game.Game
的用法示例。
在下文中一共展示了Game.add_game_connection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove_game_connection
# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import add_game_connection [as 别名]
async def test_remove_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)
await game.remove_game_connection(mock_game_connection)
assert players.hosting not in game.players
示例2: test_add_game_connection_throws_if_not_lobby_state
# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import add_game_connection [as 别名]
def test_add_game_connection_throws_if_not_lobby_state(game: Game, players, mock_game_connection):
game.state = GameState.INITIALIZING
mock_game_connection.player = players.hosting
mock_game_connection.state = GameConnectionState.CONNECTED_TO_HOST
with pytest.raises(GameError):
game.add_game_connection(mock_game_connection)
assert players.hosting not in game.players
示例3: test_add_game_connection_throws_if_not_connected_to_host
# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import add_game_connection [as 别名]
def test_add_game_connection_throws_if_not_connected_to_host(game: Game, players, mock_game_connection):
game.state = GameState.LOBBY
mock_game_connection.player = players.hosting
mock_game_connection.state = GameConnectionState.INITIALIZED
with pytest.raises(GameError):
game.add_game_connection(mock_game_connection)
assert players.hosting not in game.players
示例4: test_game_end_when_no_more_connections
# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import add_game_connection [as 别名]
async def test_game_end_when_no_more_connections(game: Game, mock_game_connection):
game.state = GameState.LOBBY
game.on_game_end = CoroMock()
mock_game_connection.state = GameConnectionState.CONNECTED_TO_HOST
game.add_game_connection(mock_game_connection)
await game.remove_game_connection(mock_game_connection)
game.on_game_end.assert_any_call()
示例5: add_connected_player
# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import add_game_connection [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
示例6: test_players_exclude_observers
# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import add_game_connection [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)
示例7: test_add_game_connection
# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import add_game_connection [as 别名]
def test_add_game_connection(game: Game, players, game_connection):
game.state = GameState.LOBBY
game_connection.player = players.hosting
game_connection.state = GameConnectionState.CONNECTED_TO_HOST
game.add_game_connection(game_connection)
assert players.hosting in game.players