@skumtron/minesweeper-engine

2.0.1 • Public • Published

Minesweeper Engine

An easy to use Minesweeper Engine.

Installation

Only lib/minesweeper.js is needed. Either download and add it locally or embed it through CDN:

<script src="https://unpkg.com/@skumtron/minesweeper-engine/lib/minesweeper.js"></script>

Alternatively install it through npm:

npm install @skumtron/minesweeper-engine -S

Usage

Create a game by calling the global Minesweeper function.

game = Minesweeper(rows, columns, mines);

Reveal tile(s).

game.reveal(row, column);

Add/remove flag.

game.flag(row, column);

Checking the state of the game. Returns a string with possible values: 'PENDING' - Initial game state. 'LOST' - Stepped on a mine. 'WON' - Revealed all tiles without mines.

game.state;

Get a tile.

tile = game.board.getTile(row, col);

Get board dimensions.

game.board.getBoardHeight();
game.board.getBoardWidth();

Tile properties.

tile.isRevealed;
tile.isMine;    
tile.isFlagged;
tile.minesBordering; // Amout of mines bordering that particular tile.

License

This project is licensed under the MIT License - see the LICENSE file for details

Readme

Keywords

Package Sidebar

Install

npm i @skumtron/minesweeper-engine

Weekly Downloads

1

Version

2.0.1

License

MIT

Last publish

Collaborators

  • skumtron