Prevent mine duplication

Fixes #37.
This commit is contained in:
Florine W. Dekker 2020-08-01 13:49:38 +02:00
parent 2c80abc226
commit e3b3228e59
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
3 changed files with 6 additions and 4 deletions

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "minesweeper",
"version": "0.0.45",
"version": "0.0.46",
"description": "Just Minesweeper!",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",
@ -16,7 +16,7 @@
"deploy": "grunt deploy"
},
"dependencies": {
"@fwdekker/template": "^0.0.19",
"@fwdekker/template": "^0.0.20",
"fast-random": "^2.0.4",
"fork-awesome": "^1.1.7"
},

View File

@ -134,8 +134,10 @@ export class Field {
this.started = true;
this.startTime = Date.now();
square.hasMine = false;
this.squareList.find(it => !it.hasMine && it !== square)!.hasMine = true;
if (square.hasMine) {
square.hasMine = false;
this.squareList.find(it => !it.hasMine && it !== square)!.hasMine = true;
}
square.getNeighbors()
.filter(it => it.hasMine)