GithubHelp home page GithubHelp logo

mastermind-game-api's Introduction

mastermind-game-api

Installation

Use the Dockerfile provided in order to the API without use any virtual environments nor dependency management. To do so, use the following commands:

$ docker build -t mastermindgameapi:latest .

and

$ docker run -p 5000:5000 mastermindgameapi:latest 

Before start playing, some considerations:

  • A game finishes when:
    • A user finds out the secret color combination
    • Reached the maximum number of retries: 12
  • Allowed input colors: RED, ORANGE, YELLOW, GREEN, BLUE,INDIGO and VIOLET
  • No blanks allowed, guesses or secrets must be 4 lenght combinations og the colors above

Usage

Game creation (@POST /board/games)

New game is created with an HTTP/POST call to /v1/board/games specifying the secret color combination. i.e

{
  "secret": ["RED", "YELLOW", "RED", "BLUE"]
}

Turns (@POST /board/games/{game_id}/guess)

Each turn is played by doing an HTTP/POST call to /v1/board/games/{game_id}/guess specifying the guess color combination. i.e

{
  "guess": ["INDIGO", "YELLOW", "BLUE", "RED"]
}

The server will answer with the proper combination of WHITEs and BLACKs. i.e For the previous guess, the server response should be the following:

{
	"result": ["BLACK", "WHITE", "WHITE"]
}

Game information (@ GET /board/games/{id_game})

Game information

{
	"id": 2,
	"secret": ["RED", "GREEN", "GREEN", "BLUE"],
	"guesses": [
		{
			"id": 1,
			"value": ["YELLOW", "GREEN", "YELLOW", "RED"],
			"result": ["BLACK", "WHITE"]
		},
		...
		{
			"id": n,
			"value": ["RED", "GREEN", "GREEN", "BLUE"],
			"result": ["BLACK", "BLACK", "BLACK", "BLACK"]
		}
	]
}

Game historic (@GET /board)

Games list i.e

[
	{
  	"id": 1,
    "secret": ["RED", "GREEN", "BLUE", "YELLOW"],
    "guesses": []
  },
  {
  	"id": 2,
    "secret": ["RED", "GREEN", "GREEN", "BLUE"],
    "guesses": [
    	{
      	"id": 1,
        "value": ["YELLOW", "GREEN", "YELLOW", "RED"],
        "result": ["BLACK", "WHITE"]
      },
      ...
      {
      	"id": n,
        "value": ["RED", "GREEN", "GREEN", "BLUE"],
        "result": ["BLACK", "BLACK", "BLACK", "BLACK"]
			}
    ]
  }
]

Future

  • Improve environment management
  • Allow game variations
    • Game duration (turns)
    • Secret & Guess lenght
    • Define more colors

###TODOS

  • Game algorithm
  • Define HTTP Rest API
  • Implement HTTP Rest API
  • Define DB schema
  • Create game (given a user request)
  • Return feedback given a code guess
  • Check game historic
  • Game algorithm improvements (types, checks, ...)

Define HTTP Rest API

All responses are json formatted

**All resources, in case of server side error, return HTTP 500: Something went terribly wrong on server side **

  • @GET /board - Games historic

    • 200 - OK
    • 204 - No games played yet
  • @POST /board/games - Create new game

    • 201 - OK created (return Location header)
    • 400 - Invalid input
  • @GET /board/games/{id} - Return game info (secret and guesses)

    • 200 - OK (return game info)
    • 404 - Game not found
  • @POST /board/games/{id}/guesses - Create new guess

    • 201 - OK created
    • 404 - Game not found
    • 400 - Invalid input
  • @GET /board/games/{id}/guesses - Return guesses

    • 200 - OK
    • 204 - Empty
    • 404 - Game not found
  • @GET /board/games/{id}/guesses/{id} - Return guess

    • 200 - OK
    • 404 - Game or guess not found

mastermind-game-api's People

Contributors

marcjubero avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.