@kritvit/minesweeper-engine

1.0.1 • Public • Published

Minesweeper Engine

Install

$ npm install @kritvit/minesweeper-engine --save

Getting Started

import minesweeperEngine from '@kritvit/minesweeper-engine';

const gameState = {};

// 16 rows, 16 columns, 50 traps
gameState.minesweeperEngine = minesweeperEngine(16, 16, 50);

gameState.eachItem(item => {

    // Handle each item

});

// The methods clear, mark, create and reset will return a new state,
// use that state to overwrite the previous state.

gameState.minesweeperEngine = gameState.minesweeperEngine.reset();

API

Game methods

eachItem(cb = function)
clear(id = string)
mark(id = string)
create(rows, cols, traps) or ([rows, cols, traps])
reset()

Game properties

status          // string
rows            // number
cols            // number
items           // array
markersUsed     // number
markersRemain   // number
markersTotal    // number
itemsCleared    // number
itemsRemain     // number
itemsTotal      // number
status          // string

Game status strings

gameover
completed

Item status strings

cleared
marked
triggered
exposed
missmarked

Readme

Keywords

Package Sidebar

Install

npm i @kritvit/minesweeper-engine

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

9.85 kB

Total Files

4

Last publish

Collaborators

  • kritvit