diff --git a/package.json b/package.json index f900abd..2147f08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minesweeper", - "version": "0.81.9", + "version": "0.81.10", "description": "Just Minesweeper!", "author": "Felix W. Dekker", "browser": "dist/bundle.js", diff --git a/src/main/js/Field.ts b/src/main/js/Field.ts index 0b5aaa0..185904d 100644 --- a/src/main/js/Field.ts +++ b/src/main/js/Field.ts @@ -405,8 +405,11 @@ export class Field { * @param amount the maximum amount of actions to redo, or all future actions if `undefined` */ redo(amount: number | undefined = undefined): void { + const wasLost = this.hasLost; + const redone = this.history.redo(amount); if (!this.isAutoSolving && redone > 0) this.statistics.actionsRedone++; + if (!this.isAutoSolving && !wasLost && this.hasLost) this.statistics.lossesRedone++; } /** diff --git a/src/main/js/Statistics.ts b/src/main/js/Statistics.ts index 17ddb85..03d1df3 100644 --- a/src/main/js/Statistics.ts +++ b/src/main/js/Statistics.ts @@ -9,6 +9,7 @@ export interface Statistics { actionsUndone: number; actionsRedone: number; lossesUndone: number; + lossesRedone: number; timeSpent: number; gamesStarted: number; @@ -68,6 +69,14 @@ export class LocalStatistics implements Statistics { this.storage.setNumber("lossesUndone", value); } + get lossesRedone(): number { + return this.storage.getNumber("lossesRedone", 0); + } + + set lossesRedone(value: number) { + this.storage.setNumber("lossesRedone", value); + } + get timeSpent(): number { return this.storage.getNumber("timeSpent", 0); } @@ -184,6 +193,7 @@ export class LocalStatistics implements Statistics { Losses undone ${this.lossesUndone} + ${this.lossesRedone > 0 ? `Losses redone${this.lossesRedone}` : ``} Time spent ${formatTime(Math.floor(+this.timeSpent / 1000), true, true)} @@ -199,13 +209,13 @@ export class LocalStatistics implements Statistics { Games completed - ${this.gamesWon} (${Math.round(100 * this.gamesWon / this.gamesStarted)}%) + ${this.gamesWon}${this.gamesStarted > 0 ? ` (${Math.round(100 * this.gamesWon / this.gamesStarted)}%)` : ``} Games completed without losing - ${this.gamesWonWithoutLosing} (${Math.round(100 * this.gamesWonWithoutLosing / this.gamesStarted)}%) + ${this.gamesWonWithoutLosing}${this.gamesStarted > 0 ? ` (${Math.round(100 * this.gamesWonWithoutLosing / this.gamesStarted)}%)` : ``} @@ -259,6 +269,7 @@ export class MemoryStatistics implements Statistics { actionsUndone: number = 0; actionsRedone: number = 0; lossesUndone: number = 0; + lossesRedone: number = 0; timeSpent: number = 0; gamesStarted: number = 0; gamesWon: number = 0; @@ -277,6 +288,7 @@ export class MemoryStatistics implements Statistics { this.actionsUndone = 0; this.actionsRedone = 0; this.lossesUndone = 0; + this.lossesRedone = 0; this.timeSpent = 0; this.gamesStarted = 0; this.gamesWon = 0;