Enumerations
|
GGZModState
|
STATE_CREATED,
STATE_CONNECTED,
STATE_WAITING,
STATE_PLAYING,
STATE_DONE
|
|
Table states.
More...
|
GGZModEvent
|
EVENT_STATE,
EVENT_SERVER,
EVENT_PLAYER,
EVENT_SEAT,
EVENT_SPECTATOR,
EVENT_CHAT,
EVENT_STATS,
EVENT_INFO,
EVENT_ERROR
|
|
Callback events from the GGZ core client.
More...
|
GGZSeatType
|
SEAT_NONE,
SEAT_OPEN,
SEAT_BOT,
SEAT_PLAYER,
SEAT_RESERVED,
SEAT_ABANDONED
|
|
Possible types of each seat.
More...
|
Functions |
None
|
setHandler
(GGZModEvent event, method)
|
|
Sets up a Python method callback for the given event.
|
|
boolean
|
connect ()
|
|
Connects to the GGZ core client.
|
boolean
|
disconnect ()
|
|
Disconnects from the GGZ core client.
|
boolean
|
setState
(GGZModState state)
|
|
Changes the table's state.
|
GGZModState
|
getState ()
|
|
Get the current state of the table.
|
boolean
|
autonetwork ()
|
|
Checks for messages from the GGZ core client and the game server.
|
int/socket
|
getFd ()
|
|
Get the file descriptor of the game server connection.
|
|
int
|
getNumSeats ()
|
|
Get the total number of seats at the table.
|
int
|
getNumSpectators ()
|
|
Get the current number of spectators, which may change constantly.
|
(int, GGZModSeatType, string)
|
getSeat (int number)
|
|
Get all data for the specified seat.
|
(int, string)
|
getSpectator (int number)
|
|
Get a spectator's data.
|
(string, boolean, int)
|
getPlayer ()
|
|
Get data about this player.
|
|
None
|
requestStand ()
|
|
Stand up (move from your seat into a spectator seat).
|
None
|
requestSit (int number)
|
|
Sit down (move from a spectator seat into a player seat).
|
None
|
requestBoot (string name)
|
|
Boot a player. Only the game host may do this.
|
None
|
requestBot (int number)
|
|
Change the requested seat from an opean seat to a bot.
|
None
|
requestOpen (int number)
|
|
Change the requested seat from a bot to an open seat.
|
|
None
|
requestChat (string message)
|
|
Chat! This initiates a table chat.
|
boolean
|
requestInfo (int number)
|
|
Request extended player information for one or more players.
|
|
(int, string, string, string)
|
getInfo (int number)
|
|
Get the extended information for the specified seat.
|
(int, int, int, int)
|
getRecord (int number)
|
|
Get the player's win-loss record.
|
(int)
|
getRating (int number)
|
|
Get the player's rating.
|
(int)
|
getRanking (int number)
|
|
Get the player's ranking.
|
(int)
|
getHighscore (int number)
|
|
Get the player's highscore.
|
This module contains wrappers for all libggzmod functions used by game clients
to interface with GGZ server events as received by the GGZ core clients, and
to get the connection to the game server.
Just import the ggzmod module and use the module-level functions below as
appropriate.
GGZmod currently provides an event-driven interface.
Data from communication sockets is read in by the library, and a handler method
(registered as a callback) is invoked to handle any events such as joining players,
chat messages and statistics updates.
GGZMod provides one file desriptor for communicating (TCP) to each client.
If data is ready to be read by one of these file descriptors ggzmod may invoke the
appropriate handler (see below), but will never actually read any data.
In essence, a game client will check first whether it runs in GGZ mode at all.
If this is the case, the environment variable GGZMODE=true is set, even
though games might opt to use command line parameters to determine this.
Then, the game will set up some event handlers using
setHandler.
None of these is required, but
EVENT_SERVER
is recommended to know when the connection to the game server has been
established. At some point, the game will invoke
connect to enter in contact
with the GGZ core client, which in turn is connected to the GGZ server and
will establish the game connection, as described above.
The game client and server will then communicate over their protocol, and the
game client needs to call
autonetwork in order to
know when new messages have arrived. Sending and receiving messages happens
via a Python socket object on top of the game connection file descriptor,
which is returned by
getFd.
A good game will also keep track of the game or table state, which can be set
to STATE_WAITING
for the (optional) pregame phase, to
STATE_PLAYING
for the game itself, and finally to
STATE_DONE to indicate that
the game is over and no player wants to start another game on the same table.
|
Table states.
Each table has a current "state" that is tracked by ggzmod.
First the table is executed and begins running. Then it receives a launch
event from GGZ and begins waiting for players. At some point a game will be
started and played at the table, after which it may return to waiting.
Eventually the table will probably halt and then the program will exit.
More specifically, the game is in the CREATED state when it is first executed.
It moves to the CONNECTED state after GGZ first communicates with it, and to
WAITING after the connection is established with the game server.
After this, the game server may use
setState to change between
WAITING, PLAYING, and DONE states. A WAITING game is considered waiting for
players (or whatever), while a PLAYING game is actively being played
(this information may be, but currently is not, propogated back to GGZ for
display purposes). Once the state is changed to DONE, the table is
considered dead and will exit shortly thereafter.
Each time the game state changes, an EVENT_STATE event will be
propogated to the game server.
- Enumeration values:
-
STATE_CREATED
|
Initial state. The game starts out in this state.
Once the state is changed it should never be changed back.
|
STATE_CONNECTED
|
Connected state. After the GGZ client and game client get connected,
the game changes into this state automatically.
Once this happens messages may be sent between these two.
Once the game leaves this state it should never be changed back.
|
STATE_WAITING
|
Waiting state. After the game client and game server are connected,
the client enters the waiting state. The game client may now call
setState to change
between WAITING, PLAYING, and DONE states.
|
STATE_PLAYING
|
Playing state. This state is only entered after the game client
changes state to it via
setState.
State may be changed back and forth between WAITING and PLAYING
as many times as are wanted.
|
STATE_DONE
|
Done state. Once the game client is done running,
setState should be called
to set the state to done. At this point nothing "new" can happen. The state
cannot be changed again after this. However the game client will not be
terminated by the GGZ client; GGZ just waits for it to exit of its own
volition.
|
|