diplomacy.communication.responses¶
Server -> Client responses sent by server as replies to requests.
-
class
diplomacy.communication.responses.
Error
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses._AbstractResponse
Error response sent when an error occurred on server-side while handling a request.
Properties:
- error_type: str - error type, containing the exception class name.
- message: str - error message
-
class
diplomacy.communication.responses.
Ok
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses._AbstractResponse
Ok response sent by default after handling a request. Contains nothing.
-
class
diplomacy.communication.responses.
NoResponse
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses._AbstractResponse
Placeholder response to indicate that no responses are required
-
class
diplomacy.communication.responses.
DataGameSchedule
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses._AbstractResponse
Response with info about current scheduling for a game.
Properties:
- game_id: str - game ID
- phase: str - game phase
- schedule:
SchedulerEvent
- scheduling information about the game
-
class
diplomacy.communication.responses.
DataGameInfo
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses._AbstractResponse
Response containing information about a game, to be used when no entire game object is required.
Properties:
- game_id: game ID
- phase: game phase
- timestamp: latest timestamp when data was saved into game on server (ie. game state or message)
- timestamp_created: timestamp when game was created on server
- map_name: (optional) game map name
- observer_level: (optional) highest observer level allowed for the user who sends
the request. Either
'observer_type'
,'omniscient_type'
or'master_type'
. - controlled_powers: (optional) list of power names controlled by the user who sends the request.
- rules: (optional) game rules
- status: (optional) game status
- n_players: (optional) number of powers currently controlled in the game
- n_controls: (optional) number of controlled powers required by the game to be active
- deadline: (optional) game deadline - time to wait before processing a game phase
- registration_password: (optional) boolean - if True, a password is required to join the game
-
class
diplomacy.communication.responses.
DataPossibleOrders
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses._AbstractResponse
Response containing information about possible orders for a game at its current phase.
Properties:
- possible_orders: dictionary mapping a location short name to all possible orders here
- orderable_locations: dictionary mapping a power name to its orderable locations
-
class
diplomacy.communication.responses.
UniqueData
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses._AbstractResponse
Response containing only 1 field named
data
. A derived class will contain a specific typed value in this field.
-
class
diplomacy.communication.responses.
DataToken
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing a token.
-
class
diplomacy.communication.responses.
DataMaps
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing maps info (dictionary mapping a map name to a dictionary with map information).
-
class
diplomacy.communication.responses.
DataPowerNames
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing a list of power names.
-
class
diplomacy.communication.responses.
DataGames
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing a list of
DataGameInfo
objects.
-
class
diplomacy.communication.responses.
DataPort
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing a DAIDE port (integer).
-
class
diplomacy.communication.responses.
DataTimeStamp
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing a timestamp (integer).
-
class
diplomacy.communication.responses.
DataGamePhases
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing a list of
GamePhaseData
objects.
-
class
diplomacy.communication.responses.
DataGame
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing a
Game
object.
-
class
diplomacy.communication.responses.
DataSavedGame
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing a game saved in JSON dictionary.
-
class
diplomacy.communication.responses.
DataGamesToPowerNames
(**kwargs)[source]¶ Bases:
diplomacy.communication.responses.UniqueData
Unique data containing a dictionary mapping a game ID to a list of power names.
-
diplomacy.communication.responses.
parse_dict
(json_response)[source]¶ Parse a JSON dictionary expected to represent a response. Raise an exception if either:
- parsing failed
- response received is an Error response. In such case, a ResponseException is raised with the error message.
Parameters: json_response – a JSON dict. Returns: a Response class instance.