Fix undefineds in statistics overview

This commit is contained in:
Florine W. Dekker 2020-08-09 02:01:37 +02:00
parent aa2923a245
commit 0078e94c3b
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
2 changed files with 12 additions and 14 deletions

View File

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

View File

@ -173,26 +173,24 @@ export class LocalStatistics implements Statistics {
* Generates an HTML report of the current statistics.
*/
generateHtmlReport(): string {
const stats = this.read();
return "" +
`<h3>Time and history</h3>
<table>
<tr>
<th>Actions undone</th>
<td>${stats["actionsUndone"]}</td>
<td>${this.actionsUndone}</td>
</tr>
<tr>
<th>Actions redone</th>
<td>${stats["actionsRedone"]}</td>
<td>${this.actionsRedone}</td>
</tr>
<tr>
<th>Losses undone</th>
<td>${stats["lossesUndone"]}</td>
<td>${this.lossesUndone}</td>
</tr>
<tr>
<th>Time spent</th>
<td>${formatTime(Math.floor(+stats["timeSpent"] / 1000), true, true)}</td>
<td>${formatTime(Math.floor(+this.timeSpent / 1000), true, true)}</td>
</tr>
</table>
@ -200,15 +198,15 @@ export class LocalStatistics implements Statistics {
<table>
<tr>
<th>Games started</th>
<td>${stats["gamesStarted"]}</td>
<td>${this.gamesStarted}</td>
</tr>
<tr>
<th>Games lost</th>
<td>${stats["gamesLost"]}</td>
<td>${this.gamesLost}</td>
</tr>
<tr>
<th>Games won</th>
<td>${stats["gamesWon"]}</td>
<td>${this.gamesWon}</td>
</tr>
</table>
@ -216,19 +214,19 @@ export class LocalStatistics implements Statistics {
<table>
<tr>
<th>Squares chorded</th>
<td>${stats["squaresChorded"]}</td>
<td>${this.squaresChorded}</td>
</tr>
<tr>
<th>Squares chorded leading to loss</th>
<td>${stats["squaresChordedLeadingToLoss"]}</td>
<td>${this.squaresChordedLeadingToLoss}</td>
</tr>
<tr>
<th>Squares flagged</th>
<td>${stats["squaresFlagged"]}</td>
<td>${this.squaresFlagged}</td>
</tr>
<tr>
<th>Squares uncovered</th>
<td>${stats["squaresUncovered"]}</td>
<td>${this.squaresUncovered}</td>
</tr>
</table>`;
}