diplomacy.client.network_game

Game object used on client side.

class diplomacy.client.network_game.NetworkGame(channel, received_game)[source]

Bases: diplomacy.engine.game.Game

NetworkGame class.

Properties:

  • channel: associated diplomacy.client.channel.Channel object.
  • notification_callbacks: Dict mapping a notification class name to a callback to be called when a corresponding game notification is received.
__init__(channel, received_game)[source]

Initialize network game object with a channel and a game object sent by server.

Parameters:
get_phase_history(**kwargs)

Send game request GetPhaseHistory with forced parameters ( with request parameters ) and additional request parameters kwargs. See GetPhaseHistory about request parameters and response.

leave(**kwargs)

Send game request LeaveGame with forced parameters ( with request parameters ) and additional request parameters kwargs. See LeaveGame about request parameters and response.

send_game_message(**kwargs)

Send game request SendGameMessage with forced parameters ( with request parameters ) and additional request parameters kwargs. See SendGameMessage about request parameters and response.

set_orders(**kwargs)

Send game request SetOrders with forced parameters ( with request parameters ) and additional request parameters kwargs. See SetOrders about request parameters and response.

clear_centers(**kwargs)

Send game request ClearCenters with forced parameters ( with request parameters ) and additional request parameters kwargs. See ClearCenters about request parameters and response.

clear_orders(**kwargs)

Send game request ClearOrders with forced parameters ( with request parameters ) and additional request parameters kwargs. See ClearOrders about request parameters and response.

clear_units(**kwargs)

Send game request ClearUnits with forced parameters ( with request parameters ) and additional request parameters kwargs. See ClearUnits about request parameters and response.

wait(**kwargs)

Send game request SetWaitFlag with forced parameters (wait=True) and additional request parameters kwargs. See SetWaitFlag about request parameters and response.

no_wait(**kwargs)

Send game request SetWaitFlag with forced parameters (wait=False) and additional request parameters kwargs. See SetWaitFlag about request parameters and response.

vote(**kwargs)

Send game request Vote with forced parameters ( with request parameters ) and additional request parameters kwargs. See Vote about request parameters and response.

save(**kwargs)

Send game request SaveGame with forced parameters ( with request parameters ) and additional request parameters kwargs. See SaveGame about request parameters and response.

synchronize()[source]

Send a Synchronize request to synchronize this game with associated server game.

delete(**kwargs)

Send game request DeleteGame with forced parameters ( with request parameters ) and additional request parameters kwargs. See DeleteGame about request parameters and response.

kick_powers(**kwargs)

Send game request SetDummyPowers with forced parameters ( with request parameters ) and additional request parameters kwargs. See SetDummyPowers about request parameters and response.

set_state(**kwargs)

Send game request SetGameState with forced parameters ( with request parameters ) and additional request parameters kwargs. See SetGameState about request parameters and response.

process(**kwargs)

Send game request ProcessGame with forced parameters ( with request parameters ) and additional request parameters kwargs. See ProcessGame about request parameters and response.

query_schedule(**kwargs)

Send game request QuerySchedule with forced parameters ( with request parameters ) and additional request parameters kwargs. See QuerySchedule about request parameters and response.

start(**kwargs)

Send game request SetGameStatus with forced parameters (status=active) and additional request parameters kwargs. See SetGameStatus about request parameters and response.

pause(**kwargs)

Send game request SetGameStatus with forced parameters (status=paused) and additional request parameters kwargs. See SetGameStatus about request parameters and response.

resume(**kwargs)

Send game request SetGameStatus with forced parameters (status=active) and additional request parameters kwargs. See SetGameStatus about request parameters and response.

cancel(**kwargs)

Send game request SetGameStatus with forced parameters (status=canceled) and additional request parameters kwargs. See SetGameStatus about request parameters and response.

draw(**kwargs)

Send game request SetGameStatus with forced parameters (status=completed) and additional request parameters kwargs. See SetGameStatus about request parameters and response.

add_on_cleared_centers(notification_callback)

Add callback for notification ClearedCenters. Callback signature: callback(network_game, notification) -> None.

add_on_cleared_orders(notification_callback)

Add callback for notification ClearedOrders. Callback signature: callback(network_game, notification) -> None.

add_on_cleared_units(notification_callback)

Add callback for notification ClearedUnits. Callback signature: callback(network_game, notification) -> None.

add_on_game_deleted(notification_callback)

Add callback for notification GameDeleted. Callback signature: callback(network_game, notification) -> None.

add_on_game_message_received(notification_callback)

Add callback for notification GameMessageReceived. Callback signature: callback(network_game, notification) -> None.

add_on_game_processed(notification_callback)

Add callback for notification GameProcessed. Callback signature: callback(network_game, notification) -> None.

add_on_game_phase_update(notification_callback)

Add callback for notification GamePhaseUpdate. Callback signature: callback(network_game, notification) -> None.

add_on_game_status_update(notification_callback)

Add callback for notification GameStatusUpdate. Callback signature: callback(network_game, notification) -> None.

add_on_omniscient_updated(notification_callback)

Add callback for notification OmniscientUpdated. Callback signature: callback(network_game, notification) -> None.

add_on_power_orders_flag(notification_callback)

Add callback for notification PowerOrdersFlag. Callback signature: callback(network_game, notification) -> None.

add_on_power_orders_update(notification_callback)

Add callback for notification PowerOrdersUpdate. Callback signature: callback(network_game, notification) -> None.

add_on_power_vote_updated(notification_callback)

Add callback for notification PowerVoteUpdated. Callback signature: callback(network_game, notification) -> None.

add_on_power_wait_flag(notification_callback)

Add callback for notification PowerWaitFlag. Callback signature: callback(network_game, notification) -> None.

add_on_powers_controllers(notification_callback)

Add callback for notification PowersControllers. Callback signature: callback(network_game, notification) -> None.

add_on_vote_count_updated(notification_callback)

Add callback for notification VoteCountUpdated. Callback signature: callback(network_game, notification) -> None.

add_on_vote_updated(notification_callback)

Add callback for notification VoteUpdated. Callback signature: callback(network_game, notification) -> None.

clear_on_cleared_centers()

Clear callbacks for notification ClearedCenters..

clear_on_cleared_orders()

Clear callbacks for notification ClearedOrders..

clear_on_cleared_units()

Clear callbacks for notification ClearedUnits..

clear_on_game_deleted()

Clear callbacks for notification GameDeleted..

clear_on_game_message_received()

Clear callbacks for notification GameMessageReceived..

clear_on_game_processed()

Clear callbacks for notification GameProcessed..

clear_on_game_phase_update()

Clear callbacks for notification GamePhaseUpdate..

clear_on_game_status_update()

Clear callbacks for notification GameStatusUpdate..

clear_on_omniscient_updated()

Clear callbacks for notification OmniscientUpdated..

clear_on_power_orders_flag()

Clear callbacks for notification PowerOrdersFlag..

clear_on_power_orders_update()

Clear callbacks for notification PowerOrdersUpdate..

clear_on_power_vote_updated()

Clear callbacks for notification PowerVoteUpdated..

clear_on_power_wait_flag()

Clear callbacks for notification PowerWaitFlag..

clear_on_powers_controllers()

Clear callbacks for notification PowersControllers..

clear_on_vote_count_updated()

Clear callbacks for notification VoteCountUpdated..

clear_on_vote_updated()

Clear callbacks for notification VoteUpdated..

add_notification_callback(notification_class, notification_callback)[source]

Add a callback for a notification.

Parameters:
  • notification_class – a notification class. See diplomacy.communication.notifications about available notifications.
  • notification_callback – callback to add: callback(network_game, notification) -> None.
clear_notification_callbacks(notification_class)[source]

Remove all user callbacks for a notification.

Parameters:notification_class – a notification class
notify(notification)[source]

Notify game with given notification (call associated callbacks if defined).