Rest API that simulates the role of the Masterminds codemaker.
At the moment only the basic version is available with following features:
- 2 players (codemaker, codebreaker)
- Pattern / Code has four colors
- Colors availables:
- 'black': 'B',
- 'white': 'W',
- 'red': 'R',
- 'yellow': 'Y',
- 'purple': 'P'
- Unlimited chances
- Python >= 3.5
- Flask==1.0.2
- Flask-RESTful==0.3.7
- Flask-SQLAlchemy==2.3.2
$ git clone https://github.com/susanavazqz/mastermind
$ cd mastermind
$ pip install -r requirements.txt
$ python app.py
You can use curl from command line or postman to play mastermind
1.- Create a new game with POST request. Returns a JSON object with game id.
$ curl --request POST http://127.0.0.1:5000/game
Response (JSON):
{
"id": "1",
"message": "Game has been created"
}
2.- Guess the pattern. Send a PUT request adding the guess pattern as a json.
$ curl -X PUT http://127.0.0.1:5000/game/1 \
-H 'Content-Type: application/json' \
-d '{ "code": "P,R,W,B"}'
Response (JSON):
{
"id": "1",
"code": "P,R,W,B",
"result": {
"black_pegs": 1,
"white_pegs": 2
}
}
- Custom length of pattern / code
- Custom colors
- Get history of the game
- Susana Vázquez