First, create a .env file in the root directory of the repo with contents MONGOOSEURL = "<mongoose connection string>"
Then, run yarn, then yarn dev.
Make requests to /game. The two parameters you can include are game and move
To create a new game, make an emtpy post request. You will get an id back. To get the status of a game, include the id of the game in the game parameter. To make a move, include the id of the game, and in the move parameter include the position and the turn.
Getting status of a game:
{
"game": "5fcae94a8468041e40388c7f" //Id of game
}
Making a move:
{
"game": "5fcae94a8468041e40388c7f", //Id of game
"move": {
"position": "2",
"turn": "Y"
}
}
Put Game.java into the same directory as your code. Add gson to the java project. Change the static String url in Game.java to the url of the server. Methods are listed here
startNewGame: Returns a string with the game code.checkJoined: Returns void when another client has joined the same game. Takes stringgameCodeas a parameter.myTurn: Runs callback when it is that client's turn. Takes charplayer, stringgameCode, and a callback that returns a booleantrueGame.myTurn('X', "<gameCode>", (callback) -> { //Run code here })
makeMove: Posts move to server. Takes stringgameCode, intmove, charplayer, char[]board. Returns void.updateBoard: Gets board info from server. Takes stringgameCode, char[]board, with an optional callback.
Example code is in the /example folder.