Fix erroneous trigger for first mine move

This commit is contained in:
Florine W. Dekker 2020-07-28 21:20:51 +02:00
parent 4feb43786b
commit 18d17cbe3b
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
2 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "minesweeper",
"version": "0.0.8",
"version": "0.0.9",
"description": "Just Minesweeper!",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",

View File

@ -517,12 +517,12 @@ class Field {
onUncover(square) {
if (!this.started && square.hasMine) {
square.hasMine = false;
this.squareList
.filter(it => it.hasMine && it !== square)[0]
.hasMine = true;
this.started = true;
const target = this.squareList
.filter(it => it.hasMine && it !== square)[0];
target.hasMine = true;
log(`Moved mine from (${square.x}, ${square.y}) to (${target.x}, ${target.y}).`)
}
this.started = true;
if (!square.hasMine) {
this.coveredRemaining = this.squareList.filter(it => !it.hasMine && it.isCovered).length;