integration.webdiplomacy_net.api

Contains an API class to send requests to webdiplomacy.net

class diplomacy.integration.webdiplomacy_net.api.API(api_key, connect_timeout=30, request_timeout=60)[source]

Bases: diplomacy.integration.base_api.BaseAPI

API to interact with webdiplomacy.net

list_games_with_players_in_cd()[source]

Lists the game on the standard map where a player is in CD (civil disorder) and the bots needs to submit orders

Returns:List of GameIdCountryId tuples [(game_id, country_id), (game_id, country_id)]
list_games_with_missing_orders()[source]

Lists of the game on the standard where the user has not submitted orders yet.

Returns:List of GameIdCountryId tuples [(game_id, country_id), (game_id, country_id)]
get_game_and_power(game_id, country_id, max_phases=None)[source]

Returns the game and the power we are playing

Parameters:
  • game_id (int) – The id of the game object (integer)
  • country_id (int) – The id of the country for which we want the game state (integer)
  • max_phases (int | None, optional) – Optional. If set, improve speed by generating game only using the last ‘x’ phases.
Returns:

A tuple consisting of

  1. The diplomacy.Game object from the game state or None if an error occurred
  2. The power name (e.g. ‘FRANCE’) referred to by country_id

set_orders(game, power_name, orders, wait=None)[source]

Submits orders back to the server

Parameters:
  • game (diplomacy.Game) – A diplomacy.engine.game.Game object representing the current state of the game
  • power_name (str) – The name of the power submitting the orders (e.g. ‘FRANCE’)
  • orders (List[str]) – A list of strings representing the orders (e.g. [‘A PAR H’, ‘F BRE - MAO’])
  • wait (bool | None, optional) – Optional. If True, sets ready=False, if False sets ready=True.
Returns:

True for success, False for failure