Coder Social home page Coder Social logo

minesweeper-api's Introduction

Minesweeper-api

Design and implement RESTful API for the game

Functionality

As API we defined support routes to be called

For User

post 'api/user/register' mandatory data {email: string, password: string}

post 'api/user/login' mandatory data {email: string, password: string}

It is recommended to encrypt the password. In any of this API call, the server response with a Token JWS that will be used in any GAMEs api request.

For Game

For any request below it's necessary to set in HEADER 'Authorization' the token obtained in previous User request

headers.common['Authorization'] = `Bearer ${token}`
get 'api/game/history'
get 'api/game/reset/:rows/:columns/:mines'
get 'api/game/:id/click/row/:row/col/:col'
get 'api/game/:id/to_click/row/:row/col/:col'
get 'api/game/:id/mark/row/:row/col/:col'
get 'api/game/:id/question/row/:row/col/:col'

When reset a game the API return data related to the new Game

{
  "message": "ok",
  "game": {
        "id": "GAME_ID",
        "timer": "TIMER in seg.",
        "state": "playing|loser|winner",
        "board": {
               "rows": "number_of_rows",
               "columns": "number_of_columns",
               "mines": "number_of_mines",
               "cells": [
                        {
                          "row": "row_value",
                          "col": "col_value",
                          "value": "number of mine around the cell or -1 if a mine",
                          "state": "click|unclicked|disputed|marked"
                        },
                        ....
                        ....
                     ]

For actions like to_click, mark & question the API return

{
 "cell": {
        "row": "row_value",
        "col": "col_value",
        "value": "number of mine around the cell or -1 if a mine",
        "state": "click|unclicked|disputed|marked"
      }
 "state": "playing|loser|winner",
 "timer": "TIMER in seg."
}

For each click action de API return a JSON with

{
  "cell": {
         "row": "row_value",
         "col": "col_value",
         "value": "number of mine around the cell or -1 if a mine",
         "state": click|unclicked|disputed|marked"
       },
  "was_clicked": "boolean (if the cell already 'clicked')",
  "neighbors": ["list_cell_neighbors to discover"],
  "state": "playing|looser|winner",
  "timer": "TIMER in seg."
}

TODO

  • Time tracking (One day is the limit to finish a board)
  • Ability to start a new game and preserve the old ones
  • Ability to resume an old game
  • Ability to support multiple users/accounts
  • Improve testing

minesweeper-api's People

Contributors

jeroig avatar

Watchers

 avatar James Cloos 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.