Add silly statistic
This commit is contained in:
parent
07f028d369
commit
11bc3f9be7
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "minesweeper",
|
"name": "minesweeper",
|
||||||
"version": "0.81.9",
|
"version": "0.81.10",
|
||||||
"description": "Just Minesweeper!",
|
"description": "Just Minesweeper!",
|
||||||
"author": "Felix W. Dekker",
|
"author": "Felix W. Dekker",
|
||||||
"browser": "dist/bundle.js",
|
"browser": "dist/bundle.js",
|
||||||
|
|
|
@ -405,8 +405,11 @@ export class Field {
|
||||||
* @param amount the maximum amount of actions to redo, or all future actions if `undefined`
|
* @param amount the maximum amount of actions to redo, or all future actions if `undefined`
|
||||||
*/
|
*/
|
||||||
redo(amount: number | undefined = undefined): void {
|
redo(amount: number | undefined = undefined): void {
|
||||||
|
const wasLost = this.hasLost;
|
||||||
|
|
||||||
const redone = this.history.redo(amount);
|
const redone = this.history.redo(amount);
|
||||||
if (!this.isAutoSolving && redone > 0) this.statistics.actionsRedone++;
|
if (!this.isAutoSolving && redone > 0) this.statistics.actionsRedone++;
|
||||||
|
if (!this.isAutoSolving && !wasLost && this.hasLost) this.statistics.lossesRedone++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,6 +9,7 @@ export interface Statistics {
|
||||||
actionsUndone: number;
|
actionsUndone: number;
|
||||||
actionsRedone: number;
|
actionsRedone: number;
|
||||||
lossesUndone: number;
|
lossesUndone: number;
|
||||||
|
lossesRedone: number;
|
||||||
timeSpent: number;
|
timeSpent: number;
|
||||||
|
|
||||||
gamesStarted: number;
|
gamesStarted: number;
|
||||||
|
@ -68,6 +69,14 @@ export class LocalStatistics implements Statistics {
|
||||||
this.storage.setNumber("lossesUndone", value);
|
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 {
|
get timeSpent(): number {
|
||||||
return this.storage.getNumber("timeSpent", 0);
|
return this.storage.getNumber("timeSpent", 0);
|
||||||
}
|
}
|
||||||
|
@ -184,6 +193,7 @@ export class LocalStatistics implements Statistics {
|
||||||
<th>Losses undone</th>
|
<th>Losses undone</th>
|
||||||
<td>${this.lossesUndone}</td>
|
<td>${this.lossesUndone}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
${this.lossesRedone > 0 ? `<tr><th>Losses redone</th><td>${this.lossesRedone}</td></tr>` : ``}
|
||||||
<tr>
|
<tr>
|
||||||
<th>Time spent</th>
|
<th>Time spent</th>
|
||||||
<td>${formatTime(Math.floor(+this.timeSpent / 1000), true, true)}</td>
|
<td>${formatTime(Math.floor(+this.timeSpent / 1000), true, true)}</td>
|
||||||
|
@ -199,13 +209,13 @@ export class LocalStatistics implements Statistics {
|
||||||
<tr>
|
<tr>
|
||||||
<th>Games completed</th>
|
<th>Games completed</th>
|
||||||
<td>
|
<td>
|
||||||
${this.gamesWon} (${Math.round(100 * this.gamesWon / this.gamesStarted)}%)
|
${this.gamesWon}${this.gamesStarted > 0 ? ` (${Math.round(100 * this.gamesWon / this.gamesStarted)}%)` : ``}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Games completed without losing</th>
|
<th>Games completed without losing</th>
|
||||||
<td>
|
<td>
|
||||||
${this.gamesWonWithoutLosing} (${Math.round(100 * this.gamesWonWithoutLosing / this.gamesStarted)}%)
|
${this.gamesWonWithoutLosing}${this.gamesStarted > 0 ? ` (${Math.round(100 * this.gamesWonWithoutLosing / this.gamesStarted)}%)` : ``}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -259,6 +269,7 @@ export class MemoryStatistics implements Statistics {
|
||||||
actionsUndone: number = 0;
|
actionsUndone: number = 0;
|
||||||
actionsRedone: number = 0;
|
actionsRedone: number = 0;
|
||||||
lossesUndone: number = 0;
|
lossesUndone: number = 0;
|
||||||
|
lossesRedone: number = 0;
|
||||||
timeSpent: number = 0;
|
timeSpent: number = 0;
|
||||||
gamesStarted: number = 0;
|
gamesStarted: number = 0;
|
||||||
gamesWon: number = 0;
|
gamesWon: number = 0;
|
||||||
|
@ -277,6 +288,7 @@ export class MemoryStatistics implements Statistics {
|
||||||
this.actionsUndone = 0;
|
this.actionsUndone = 0;
|
||||||
this.actionsRedone = 0;
|
this.actionsRedone = 0;
|
||||||
this.lossesUndone = 0;
|
this.lossesUndone = 0;
|
||||||
|
this.lossesRedone = 0;
|
||||||
this.timeSpent = 0;
|
this.timeSpent = 0;
|
||||||
this.gamesStarted = 0;
|
this.gamesStarted = 0;
|
||||||
this.gamesWon = 0;
|
this.gamesWon = 0;
|
||||||
|
|
Loading…
Reference in New Issue