Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

  • Hangman Api
  • create room (with specified word)
  • join room
  • guess letter (pass roomid, letter return guessed: true/false & guesses left)

Swagger can be found here.

How the API works

  1. You fill first need to create a room. For this you should use the POST /api/v1/room/create endpoint. This received a json object with the word you want to use for the game as well as the number of guesses you want to allow. The response will contain the room id. Note that the id will be automatically added by the backend so you can leave it out or null if you want.
{
  "id": "string",
  "word": "test",
  "allowedGuesses": 2
}
  1. To fetch the status of the room you can use the GET /api/v1/game/{roomId} endpoint. This will return the current status of the room, like this:
{
  "allowedGuesses": 2,
  "madeGuesses": 0,
  "word": "test",
  "guessedWord": "____"
}
  1. When the player enters a guess you can use the POST /api/v1/game/{roomId} endpoint, with the letter the user guessed in the request body, like this:
{
  "letter": "t"
}

This will return the status of the guess, like this, in the case of a correct guess:

{
  "correctGuessed": true,
  "gameEnded": false,
  "guessesLeft": 2
}

In the case of an incorrect guess:

{
  "correctGuessed": false,
  "gameEnded": false,
  "guessesLeft": 1
}

If the user won the game, the gameEnded field will be true. If the number in guessesLeft is <= 0 then the game should be ended. (i.e. no longer allow the player to make guesses). Be aware that the gameEnded field will stay false in this case.

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages