Coder Social home page Coder Social logo

minesweeper-api's Introduction

Minesweeper

This is a description of the "Minesweeper Clone" API.

Group Game API

POST /game

Create a new game

  • Parameters

    • difficulty: 1 (number) - Permitted values are: - 0 (Easy - 8x8, 10 mines) - 1 (Intermediate - 16x16, 40 mines) - 2 (Expert - 24x24, 99 mines)
  • Response 201 (application/json)

      {
        "id": 1,
        "board": [
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "]
        ],
        "state": "new",
        "mines": 10
      }
    

GET /game/{id}

Retrieve an already created game.

The state will be one of "new", "playing", "won", or "lost".

Cell values:

  • (empty space) An unrevealed cell
  • _ An empty revealed cell
  • F An unrevealed flagged cell
  • * A cell with a bomb in it
  • 1-8 The number of neighboring cells that contain a mine.
  • Parameters

    • id: 1 (number) - The unique ID for the game
  • Response 200 (application/json)

      {
        "id": 1,
        "board": [
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", "1", "2", "1", "F", " ", " "],
          [" ", "1", "_", "_", "_", "2", " ", " "],
          [" ", "1", "_", "_", "_", "1", " ", " "],
          [" ", " ", "1", "_", "_", "2", " ", " "],
          [" ", " ", " ", "1", "1", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "]
        ],
        "state": "new",
        "mines": 9
      }
    

POST /game/{id}/check

  • Parameters

    • id: 1 (number) - The unique ID for the game
    • row: 5 (number) - The horizontal row the player is checking (zero based index).
    • col: 7 (number) - The vertical column the player is checking (zero based index).
  • Request (application/json)

      {
        "row": 4,
        "col": 3
      }
    
  • Response 200 (application/json)

      {
        "id": 1,
        "board": [
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", "1", "2", "1", "F", " ", " "],
          [" ", "1", "_", "_", "_", "2", " ", " "],
          [" ", "1", "_", "_", "_", "1", " ", " "],
          [" ", " ", "1", "_", "_", "2", " ", " "],
          [" ", " ", " ", "1", "1", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "]
        ],
        "state": "playing",
        "mines": 9
      }
    

POST /game/{id}/flag

  • Parameters

    • id: 1 (number) - The unique ID for the game
    • row: 5 (number) - The horizontal row the player is flagging (zero based index).
    • col: 5 (number) - The vertical column the player is flagging (zero based index).
  • Request (application/json)

      {
        "row": 5,
        "col": 5
      }
    
  • Response 200 (application/json)

      {
        "id": 1,
        "board": [
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", "1", "2", "1", "F", " ", " "],
          [" ", "1", "_", "_", "_", "2", " ", " "],
          [" ", "1", "_", "_", "_", "1", " ", " "],
          [" ", " ", "1", "_", "_", "2", " ", " "],
          [" ", " ", " ", "1", "1", "F", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "],
          [" ", " ", " ", " ", " ", " ", " ", " "]
        ],
        "state": "playing",
        "mines": 8
      }
    

minesweeper-api's People

Contributors

amandaporto avatar gstark avatar

Watchers

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