igGameCenter API Developer Guide >> Creating a new game board | ||||||||||||||||||||||||||||||||||||||||||||||||||
The most important part of the igGameCenter API is a script, handling all the events within the game boards. This handler accepts commands like "JOIN" or "MOVE", executes them and returns a new state of the game board (i.e. a list of all new events, a list of players and guests joined to the board and an information about the game itself). In addition this handler is used for keep-alive purposes, i.e. the external application should send a special command ("REFRESH") on periodic basis when there are no requests for execution of other commands. For requesting an execution of a command an external application should send a POST request to the following API script: http://<server_prefix>.iggamecenter.com/api_handler.php
containing the following parameters:
Below is a list of acceptable commands: JOIN - this is a first command that should be sent by external application to any board. This command accepts the following parameter that should be included in a POST request in addition to the parameters mentioned above:
LEAVE - this command can be sent by external application for making the member to leave the board immediately. SETUP - this command can be sent by external application before the game is started for setting up the game options. The command is accepted by the handler just from players or the game board owner. This command accepts the following parameters:
Additional parameters are accepted depending on a game (i.e. a number of initial seeds in each pit can be set for Kalah game). For a list of all currently available games and their specific parameters refer to this page. START - this command should be sent by external application after placing the joined member on some side of the game board. The command indicates that the member is ready for starting the game with the current opponent. This command does not require any additional parameters. END - this command can be sent by external application when the member requests the end of the game either for himself (giving up) or for an opponent (claiming his loss). The command accepts the following parameter:
The move code format depends on the actual game.For a list of all currently available games and their specific move codes refer to this page.
REFRESH - this command is used for keep-alive purposes, i.e. the external application should send this command every 10-15 seconds when there are no requests for execution of other commands. RESTART - this command is used to start a new game on the same board with the same opponent when the current game is finished. After execution of the requested command the handler returns one of the following responses: Failure response:
where
<errorMessage>--Some error message--</errorMessage> Success response: <handlerData> <sessionInfo cmd="REFRESH" curtime="1185775602" status="FINISHED" owner="126" /> <memberInfo active="0" finished="0" place="0" /> <playerList> <player uid="126" name="welinton.borges" sex="M" score="302" place="2" stat="WIN" lastRefresh="1185293041" online="0" active="0" finished="1" /> <player uid="128" name="smokieye" sex="-" score="63" place="1" stat="LOST" lastRefresh="1185292981" online="0" active="0" finished="1" /> </playerList> <guestList> <guest uid="2" score="0" name="Arty" /> </guestList> <eventList> <event eid="43201" stamp="1185291587" uid="126" type="JOIN" data="welinton.borges" /> <event eid="43202" stamp="1185291590" uid="126" type="PLACE" data="2" /> <event eid="43227" stamp="1185292257" uid="128" type="JOIN" data="smokieye" /> <event eid="43228" stamp="1185292257" uid="128" type="PLACE" data="1" /> <event eid="43229" stamp="1185292269" uid="0" type="NOTICE" data="smokieye clicks START" /> <event eid="43238" stamp="1185292368" uid="0" type="NOTICE" data="welinton.borges clicks START" /> <event eid="43244" stamp="1185292524" uid="128" type="MOVE" data="NG1-F3" /> <event eid="43246" stamp="1185292554" uid="126" type="MOVE" data="NB8-C6" /> <event eid="43247" stamp="1185292565" uid="128" type="MOVE" data="NB1-C3" /> <event eid="43249" stamp="1185292573" uid="126" type="MOVE" data=" E7-E5" /> <event eid="43251" stamp="1185292598" uid="128" type="MOVE" data=" E2-E4" /> <event eid="43256" stamp="1185292618" uid="126" type="MOVE" data="BF8-B4" /> <event eid="43278" stamp="1185292841" uid="126" type="MOVE" data="QF6-G6" /> <event eid="43279" stamp="1185292852" uid="128" type="MOVE" data="NF3xE5" /> <event eid="43281" stamp="1185292865" uid="128" type="MSG" data="mistake" /> <event eid="43282" stamp="1185292867" uid="126" type="MOVE" data="QG6xG2 #" /> <event eid="43284" stamp="1185292981" uid="128" type="LEAVE" data="smokieye" /> <event eid="43285" stamp="1185293041" uid="126" type="LEAVE" data="welinton.borges" /> <event eid="49814" stamp="1185775602" uid="1" type="JOIN" data="Arty" /> </eventList> <gameData> <board>w20000w500w7w800 ... 100b70000b60000b2</board> <wCaptured>20120</wCaptured> <bCaptured>20210</bCaptured> </gameData> <gameOptions> <hidden>0</hidden> <scored>1</scored> </gameOptions> <elapsed>0.056</elapsed> </handlerData> |