parent
a167922c00
commit
793da19c00
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "minesweeper",
|
"name": "minesweeper",
|
||||||
"version": "0.0.27",
|
"version": "0.0.28",
|
||||||
"description": "Just Minesweeper!",
|
"description": "Just Minesweeper!",
|
||||||
"author": "Felix W. Dekker",
|
"author": "Felix W. Dekker",
|
||||||
"browser": "dist/bundle.js",
|
"browser": "dist/bundle.js",
|
||||||
|
|
|
@ -698,14 +698,18 @@ class Field {
|
||||||
* @param square {Square} the square that was clicked on
|
* @param square {Square} the square that was clicked on
|
||||||
*/
|
*/
|
||||||
onUncover(square) {
|
onUncover(square) {
|
||||||
if (!this.started) this.startTime = Date.now();
|
if (!this.started) {
|
||||||
if (!this.started && square.hasMine) {
|
this.started = true;
|
||||||
square.hasMine = false;
|
this.startTime = Date.now();
|
||||||
const target = this.squareList
|
|
||||||
.filter(it => !it.hasMine && it !== square)[0];
|
const squareAndNeighs = [square].concat(square.getNeighbors());
|
||||||
target.hasMine = true;
|
squareAndNeighs
|
||||||
|
.filter(it => it.hasMine)
|
||||||
|
.forEach(it => {
|
||||||
|
it.hasMine = false;
|
||||||
|
this.squareList.filter(it => !it.hasMine && squareAndNeighs.indexOf(it) < 0)[0].hasMine = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.started = true;
|
|
||||||
|
|
||||||
if (!square.hasMine) {
|
if (!square.hasMine) {
|
||||||
this.coveredRemaining = this.squareList.filter(it => !it.hasMine && it.isCovered).length;
|
this.coveredRemaining = this.squareList.filter(it => !it.hasMine && it.isCovered).length;
|
||||||
|
|
Loading…
Reference in New Issue