-
Notifications
You must be signed in to change notification settings - Fork 0
Web Server API
Version 0.3.
- General server information
- Accessible gameState versions
- Getting current gameState
- Updating the gameState
- Updating a phone's score
- Restarting gameState.json
- Getting leaderboard data
The web server functions as a very loose RESTful HTTP API. This means all communication with the server happens over HTTP.
Server: puppetmaster.pugetsound.edu
Port: 1730
NOTE: Port 4242 still has a test turret object which is being by the game engine. Once they have a chance to update their code, it will be taken offline.
There are three gameStates that you can access.
- gameState.json -- the main game state. Use this to actually play the game when all clients are connected.
- phoneSim.json -- a gameState that simulates two phone clients circling around the game board for the purpose of the game engine group testing.
- gameSim.json -- a gameState that simulates a player character running around the game board for the purpose of the phone group testing.
Here are the two sorts of requests you can make.
- None
- The entire updated gamestate JSON object
This will return a JSON object with the entire gamestate in it. Example data:
{
"message" : "Welcome to our game!",
"timeRemaining" : "120",
"robotStatus" : {
"mood" : "happy",
"hp" : "20"
}
}
- JSON object with your updates
- The entire updated gamestate JSON object
Your post data here will be a JSON object. The contents of this JSON object will merge with the gameState object, overriding any duplicated variables. That is to say, if the gamestate were:
{
"message" : "Welcome to our game!",
"gameStatus" : "normal",
"timeRemaining" : "120",
"robotStatus" : {
"mood" : "happy",
"hp" : "20"
}
}
And you POSTed a JSON object containing
{
"timeRemaining" : "0",
"gameStatus" : "overtime",
"robotStatus" : {
"mood" : "stressed"
}
}
The end result would be:
{
"message" : "Welcome to our game!",
"gameStatus" : "overtime"
"timeRemaining" : "0",
"robotStatus" : {
"mood" : "stressed",
"hp" : "20"
}
}
Check out tests/postRequest.py in the WebServerGroup repo to see a basic python script that makes a post request.
This is the API for modifying the score of the phones. Direct modification of the score object is discouraged, because concurrent modification is problematic.
- PHONE: The ID of the phone.
- SCORE: The amount by which to modify the score. score=-10 to remove ten points, score=500 to add 500.
- The entire updated gamestate JSON object
This is the API for reinitializing the gameState JSON, and (optionally) logging the scores from the current gameState. To just restart the JSON, only include the restartGame parameter. To restart it and log the current scores in the leaderboard, also include the logScores parameter.
- restartGame: true.
- logScores: true (optional).
- Nothing
- None
- JSON object containing leaderboard data