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