Skip to content

API Documentation for Players

Jeffrey Leung edited this page Jul 25, 2019 · 3 revisions

Select a Player

Description

Selects a Player at the given location (represented by a latitude/longitude pair).

If the game is not in progress or finished, then the The Player's state is changed from UNINITIALIZED to READY. If the game is in progress, then the Player's state is changed from UNINITIALIZED to ACTIVE.

The Player should not have already been selected or else an error will be returned.

See the possible names for a Player.

Request

Method

POST

Mapping

/player/{player_name}

Headers

Field Value(s)
Content-Type application/json

JSON body

{
	"latitude" : 12345.54321,
	"longitude" : 54321.12345
}

Response

Codes

HTTP Status Code Meanings
200 OK Selected Player successfully
400 Bad Request The request body was incorrectly formed
404 Not Found The given name was invalid
409 Conflict The Player has already been selected
500 Internal Server Error The server crapped itself

JSON body

{
}

Example cURL call

Deselect a Player

Description

Deselects the given player, allowing it to be selectable by another team.

The Player's state is changed from any other state to UNINITIALIZED. The Player have already been selected.

See the possible names for a Player.

The Player's location will be reset to (0.0, 0.0).

Request

Method

DELETE

Mapping

/player/{player_name}

Response

Codes

HTTP Status Code Meanings
200 OK Deselected Player successfully
400 Bad Request The Player has not been selected
404 Not Found The given name was invalid
500 Internal Server Error The server crapped itself

JSON body

{
}

Example cURL call

Get a Player's location

Description

Returns the current location of the Player as a latitude/longitude pair.

See the possible names for a Player.

If a player is at the location (0.0, 0.0), they are in theUNINITIALIZED state.

Request

Method

GET

Mapping

/player/{player_name}/location

Response

Codes

HTTP Status Code Meanings
200 OK Retrieved Player's location successfully
404 Not Found The given name was invalid
500 Internal Server Error The server crapped itself

JSON body

{
	"latitude" : 135.79,
	"longitude" : 246.80
}

Example cURL call

Get all Players' locations

Description

Returns a list of all Players' names and locations, as latitude/longitude pairs.

If a player is at the location (0.0, 0.0), they are in theUNINITIALIZED state.

Request

Method

GET

Mapping

/player/locations

Response

Codes

HTTP Status Code Meanings
200 OK Retrieved all Players' locations successfully
500 Internal Server Error The server crapped itself

JSON body

[
	{
		"name" : "Pacman",
		"location" : {
			"latitude" : 999.999,
			"longitude" : 888.888
		}
	},
	{
		"name" : "Blinky",
		"location" : {
			"latitude" : 777.777,
			"longitude" : 666.666
		}
	},
	{
		"name" : "Inky",
		"location" : {
			"latitude" : 555.555,
			"longitude" : 444.444
		}
	},
	{
		"name" : "Pinky",
		"location" : {
			"latitude" : 333.333,
			"longitude" : 222.222
		}
	}
	{
		"name" : "Clyde",
		"location" : {
			"latitude" : 111.111,
			"longitude" : 222.222
		}
	}
]

Example cURL call

Get a Player's state

Description

Returns the current state of the Player.

See the possible names for a Player.

See the possible states for a Player.

Request

Method

GET

Mapping

/player/{player_name}/state

Response

Codes

HTTP Status Code Meanings
200 OK Retrieved Player's state successfully
404 Not Found The given name was invalid
500 Internal Server Error The server crapped itself

JSON body

{
	"state" : "UNINITIALIZED"
}

Example cURL call

Get all Players' states

Description

Returns a list of all Players' names and states.

See the possible names for a Player.

See the possible states for a Player.

Request

Method

GET

Mapping

/player/states

Response

Codes

HTTP Status Code Meanings
200 OK Retrieved states of all Players successfully
500 Internal Server Error The server crapped itself

JSON body

[
	{
		"name" : "Pacman",
		"state" : "ACTIVE"
	},
	{
		"name" : "Blinky",
		"state" : "CAPTURED"
	},
	{
		"name" : "Inky",
		"state" : "ACTIVE"
	},
	{
		"name" : "Pinky",
		"state" : "ACTIVE"
	}
	{
		"name" : "Clyde",
		"state" : "CAPTURED"
	}
]

Example cURL call

Get all Players' Details

Description

Returns a list of all Players' details (i.e. name, state, location).

See the possible names for a Player.

See the possible states for a Player.

Request

Method

GET

Mapping

/player/details

Response

Codes

HTTP Status Code Meanings
200 OK Retrieved details of all Players successfully
500 Internal Server Error The server crapped itself

JSON body

[
	{
		"name" : "Pacman",
		"state" : "POWERUP",
		"location" : {
			"latitude" : 999.999,
			"longitude" : 888.888
		}
	},
	{
		"name" : "Blinky",
		"state" : "UNINITIALIZED",
		"location" : {
			"latitude" : 0.0,
			"longitude" : 0.0
		}
	},
	{
		"name" : "Inky",
		"state" : "CAPTURED",
		"location" : {
			"latitude" : 555.555,
			"longitude" : 444.444
		}
	},
	{
		"name" : "Pinky",
		"state" : "ACTIVE",
		"location" : {
			"latitude" : 333.333,
			"longitude" : 222.222
		}
	}
	{
		"name" : "Clyde",
		"state" : "ACTIVE",
		"location" : {
			"latitude" : 111.111,
			"longitude" : 222.222
		}
	}
]

Example cURL call

Set a Player's location

Description

Updates the location of a Player to a new latitude/longitude pair.

Updating Pacman's location while the game state is IN_PROGRESS and the Pacman is in the ACTIVE state will eat any Pacdots and Powerdots within a set distance (0.0005°; 40 metres; length of a mid-sized building) of the new location. If a Powerdot is eaten, the Pacman will be placed in the POWERUP state for a set period of time (60 seconds).

See the possible names for a Player.

The Player must be not be unselected (i.e. UNINITIALIZED).

This operation is idempotent (i.e. a Player may be set to the same location they are currently at).

Request

Method

PUT

Mapping

/player/{player_name}/location

Headers

Field Value(s)
Content-Type application/json

JSON body

{
	"latitude" : 12345.54321,
	"longitude" : 54321.12345
}

Response

Codes

HTTP Status Code Meanings
200 OK Changed Player's location successfully
400 Bad Request Request body was incorrectly formed
404 Not Found The given name was invalid
409 Conflict The Player has not been selected/initialized yet
500 Internal Server Error The server crapped itself

JSON body

{
}

Example cURL call