diplomacy.engine.message

Game message. Represent a message exchanged inside a game.

Possible messages exchanges:

  • power 1 -> power 2
  • power -> all game
  • system -> power
  • system -> all game
  • system -> observers
  • system -> omniscient observers

Sender system is identified with constant SYSTEM defined below.

Recipients all game, observers and omniscient observers are identified respectively with constants GLOBAL, OBSERVER and OMNISCIENT defined below.

Consider using Game methods to generate appropriate messages instead of this class directly:

  • Game.new_power_message() to send a message from a power to another.
  • Game.new_global_message() to send a message from a power to all game.
  • ServerGame.new_system_message() to send a server system message. Use constant names defined below to specify recipient for system message when it’s not a power name (GLOBAL, OBSERVER or OMNISCIENT).
class diplomacy.engine.message.Message(**kwargs)[source]

Bases: diplomacy.utils.jsonable.Jsonable

Message class.

Properties:

  • sender: message sender name: either SYSTEM or a power name.
  • recipient: message recipient name: either GLOBAL, OBSERVER, OMNISCIENT or a power name.
  • time_sent: message timestamp in microseconds.
  • phase: short name of game phase when message is sent.
  • message: message body.

Note about timestamp management:

We assume a message has an unique timestamp inside one game. To respect this rule, the server is the only one responsible for generating message timestamps. This allow to generate timestamp or only 1 same machine (server) instead of managing timestamps from many user machines, to prevent timestamp inconsistency when messages are stored on server. Therefore, message timestamp is the time when server stores the message, not the time when message was sent by any client.

is_global()[source]

Return True if this message is global.

for_observer()[source]

Return True if this message is sent to observers.