Mastermind

Mastermind backend and frontend as part of Axion-Zen's challenge at VanHackathon May 2016

Mastermind Web

Mastermind Web is a single page application developed using html5, css3, javascript, jquery, sweetalert, font-awesome and google font Raleway.

Mastermind Api

NewSinglePlayerGame


Create a new single player game.

  • URL

api/mastermind/newsingleplayergame

  • Method:

POST

  • Success Response:

    • Code: 200
      Content: {"token":"0debec05-a3d6-4c8e-8703-4c7c3124501f","colors":["R","B","G","Y","O","P","C","M"],"codeLength":8}
  • Sample Call:

$.ajax({
    type: "POST",
    url: domain + "api/mastermind/newsingleplayergame",
    dataType: "json",
    success: success
 });

NewMultiplayerGame


Create a new multiplayer game.

  • URL

api/mastermind/newmultiplayergame

  • Method:

POST

  • Success Response:

    • Code: 200
      Content: {"token":"0debec05-a3d6-4c8e-8703-4c7c3124501f","colors":["R","B","G","Y","O","P","C","M"],"codeLength":8}
  • Sample Call:

$.ajax({
    type: "POST",
    url: domain + "api/mastermind/newmultiplayergame",
    dataType: "json",
    success: success
 });

Guess


Guess a combination.

  • URL

api/mastermind/guess

  • Method:

PUT

  • Success Response:

    • Code: 200
      Content: {"game":{"token":"0debec05-a3d6-4c8e-8703-4c7c3124501f","colors":["P","O","Y","O","P","B","C","B"],"codeLength":8},"opponentSolved":false,"guessResult":{"guess":null,"exact":0,"near":0}}
  • Sample Call:

.ajax({
    type: "PUT",
    url: domain + "api/mastermind/guess",
    data: {
        token: token,
        code: code
    },
    dataType: "json",
    success: success
});

CrackCode


Crack the code. Lost the game.

  • URL

api/mastermind/crackcode

  • Method:

PUT

  • Success Response:

    • Code: 200
      Content: {"code":"CMBGYPGM"}
  • Sample Call:

$.ajax({
    type: "PUT",
    url: domain + "api/mastermind/crackcode?token=" + token,
    dataType: "json",
    success: success
});

Join


Join a random multiplayer game.

  • URL

api/mastermind/join

  • Method:

PUT

  • Success Response:

    • Code: 200
      Content: {"avaible":true,"game":{"token":"78f8f19d-04f9-481c-a487-b781d1e0c230","colors":["R","B","G","Y","O","P","C","M"],"codeLength":8}}
  • Sample Call:

$.ajax({
    type: "PUT",
    url: domain + "api/mastermind/join",
    dataType: "json",
    success: success
 });

IsMyTurn


Return if it is your turn.

  • URL

api/mastermind/ismyturn

  • Method:

GET

  • Success Response:

    • Code: 200
      Content: {"isMyTurn":true}
  • Sample Call:

$.getJSON(domain + "api/mastermind/ismyturn", {
    token: token
})
.done(function (data) { });

Building

  1. You must have visual studio installed. You can download it here:
  2. Setup multiple startup projects.
    1. In the Solution Explorer, select the solution (the very top node). Right-click the node to get the context menu.
    2. Select Properties. The Solution Property Pages dialog box opens.
    3. Expand the Common Properties node, and click Startup Project.
    4. Click Multiple Startup Projects.
    5. Choose web and api.
  3. You must configure the variable "domain" in "index.js" in your web project to point your api domain.

**Extra: You can change the lines(guesses) of the game changing the variable "numberLines" in the top of "index.js". *

Built With

Share this project:

Updates