项目作者: qasimkhalid

项目描述 :
Rock Paper Scissors Game
高级语言: Java
项目地址: git://github.com/qasimkhalid/RockPaperScissors.git
创建时间: 2021-03-08T19:05:10Z
项目社区:https://github.com/qasimkhalid/RockPaperScissors

开源协议:

下载


API to play Rock - Paper - Scissors - Lizard - Spock

alt text

Instructions

Configuration:

  1. Clone the repository.
  2. Open the application.properties file from /src/main/resources/application.properties.
  3. Add the name of your database here (add username and password, if necessary). spring.datasource.url=jdbc:postgresql://localhost:5432/{yourDatabaseName}.
  4. Run and Play it using any API client (e.g., Postman).
  5. Enjoy!

Game Play:

  1. Player sends API a move to play using POST request to the http://localhost:8080/rps/play/ endpoint in the following format with one of the possible legal moves (i.e., rock, paper, scissors, lizard, spock).
Sample Player Request Format:
  1. {
  2. "name": "Ponky",
  3. "move": "rock"
  4. }
  1. The game engine chooses a move in reaction to player’s choice and the player receives a game result in a following format.
Sample Game Result Format:
  1. {
  2. "moves": [
  3. {
  4. "name": "Ponky",
  5. "move": "rock"
  6. },
  7. {
  8. "name": "Bot",
  9. "move": "lizard"
  10. }
  11. ],
  12. "result": "Ponky wins"
  13. }

Accessing Results From Database:

As the game results are stored in the PostgreSQL, they can be accessed anytime using GET request to the http://localhost:8080/rps/result/ endpoint.


Tests:

  1. Unit Testing: Game Logic (e.g., MatchShouldDraw and PaperWinsAgainstRock).
  2. Postman for API testing.

TODO:

Unit tests for Game Controller.

  1. Routes should work! - test controller and urls - make custom http client and try to hit the API endpoints with proper and improper data.
  2. Make tests to check request body in proper JSON format.
  3. Make dummy json body to check if JSON is valid or not.
  4. Is the player move legal?