Query 3: Start Game
Request Format: game.php endpoint with POST
parameters of startgame
(set to true
) and mypokemon
Request Type: POST
Returned Data Format: JSON
Description: The third request you will use initiates a game and passes
two parameters, startgame
and mypokemon
to game.php
.
In contrast to the first two “GET” requests, this request is a “POST” request. Upon
success, the request returns a JSON response of the initial game state (with information
for both players’ Pokemon) and unique game id (guid) and player id (pid) for the player
to use to access and update the current game state.
Example Request: POST
parameters of
startgame=true
and mypokemon=pikachu
Example Output:
{
"guid" : "game_12345abc",
"pid" : "player_cfe67890",
"p1" : {
"name" : "Pikachu",
"shortname" : "pikachu",
"hp" : 160,
"current-hp" : 160,
"images" : {
"photo" : "images/pikachu.jpg",
"typeIcon" : "icons/electric.jpg",
"weaknessIcon" : "icons/ground.jpg"
},
"info": {
"id": 25,
"type": "electric",
"weakness": "ground",
"description": "Melissa's favorite Pokemon! When several Pikachu gather,
their electricity could build and cause lightning storms."
},
"moves": [
{
"name": "Growl",
"type": "normal"
},
{
"name": "Quick Attack",
"dp": 40,
"type": "normal"
},
{
"name": "Thunderbolt",
"dp": 90,
"type": "electric"
}
],
"buffs": [],
"debuffs": []
},
"p2" : {
"name" : "Ditto",
"shortname" : "ditto",
"hp" : 206,
"current-hp" : 206,
"images": {
"photo": "images/ditto.jpg",
"typeIcon": "icons/normal.jpg",
"weaknessIcon": "icons/fighting.jpg"
},
"info": {
"id": 132,
"type": "normal",
"weakness": "fighting",
"description": "Duncan's favorite Pokemon (he has an awesome painting of Ditto on his wall). It can transform
into anything. When it sleeps, it changes into a stone to avoid being attacked."
},
"moves": [
{
"name": "Transform",
"dp": 40,
"type": "normal"
}
],
"buffs": [],
"debuffs": []
}
}
You may assume that the guid
and pid
attributes returned are
unique to the started game.
Query 4: Play a Move
Request Format: game.php endpoint with POST
parameters of guid
,
pid
, and movename
Request Type: POST
Returned Data Format: JSON
Description:This query submits a move played by your Pokemon on the current
turn and requires three parameters: move
as your Pokemon’s move name,
guid
as your unique game ID, and pid
as your unique player
id. The move name should be passed as an all-lowercase string, and if there are any spaces
in the move name (e.g., "Quick Attack"), they should be removed when passed as a parameter
(e.g., "Quick Attack" would be passed as "quickattack"). The game state is updated by
applying that move’s effects to either player (depending on the specific effects of the
move). The request will also call the opponent’s move, which may update the health or buffs
of your Pokemon. Upon success, the request returns the current game state, including each
player’s current Pokemon status and the results of the two moves (yours and the opponents),
as a JSON object. If your Pokemon wins the battle as a result of the move, "p2-move" and
"p2-result" will be returned as null
, indicating p2’s Pokemon did not make a
move (they are unable to play anymore in the current game). There is a special
case when movename is passed as "flee" (ignoring letter-casing). In this case, the
returned JSON will have its results defined as follows:
"results" : {
"p1-move" : "Flee",
"p2-move" : null,
"p1-result" : "lost",
"p2-result" : null
}
The rest of the result JSON will be the same structure as other moves.
An example return is given on the below, where the guid provided is
fictitious and you will need to provide the one retrieved from the previous startgame request:
Example Request: POST
parameters of
guid=game_12345abc
, pid=player_cfe67890
, and
movename=thunderbolt
Example Output:
{
"guid" : "game_12345abc",
"pid" : "player_cfe67890",
"results" : {
"p1-move" : "Thunderbolt",
"p2-move" : "Transform",
"p1-result" : "hit",
"p2-result" : "missed"
},
"p1" : {
"name" : "Pikachu",
"shortname" : "pikachu",
"type" : "electric",
"weakness" : "ground",
"hp" : 160,
"current-hp" : 60,
"moves" : [
{
"name": "Growl",
"type" : "normal"
},
{
"name": "Quick Attack",
"dp" : 40,
"type" : "normal"
},
{
"name": "Thunderbolt",
"dp" : 90,
"type" : "electric"
}
],
"buffs" : [],
"debuffs" : []
},
"p2" : {
"name" : "Ditto",
"shortname" : "ditto",
"type" : "normal",
"weakness" : "fighting",
"hp" : 206,
"current-hp" : 20,
"moves" : [
{
"name": "Transform",
"dp" : 40,
"type" : "normal"
}
],
"buffs" : [],
"debuffs" : ["attack", "attack"]
}
}