@skumtron/minesweeper-engine
v2.0.1
Published
A Minesweeper Engine
Downloads
1
Readme
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