Clean up score table, change score sorting
This commit is contained in:
parent
e64d20f3bd
commit
7f440a015e
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minesweeper",
|
||||
"version": "0.82.0",
|
||||
"version": "0.82.1",
|
||||
"description": "Just Minesweeper!",
|
||||
"author": "Felix W. Dekker",
|
||||
"browser": "dist/bundle.js",
|
||||
|
|
|
@ -43,7 +43,11 @@ export class HighScores {
|
|||
addScore(difficulty: Difficulty, score: Score): void {
|
||||
const scores = this.storage.getArray(difficulty.name, []);
|
||||
scores.push(score);
|
||||
scores.sort((a, b) => a.time - b.time);
|
||||
scores.sort((a, b) => {
|
||||
return Math.floor(a.time / 1000) !== Math.floor(b.time / 1000)
|
||||
? a.time - b.time
|
||||
: a.deaths - b.deaths;
|
||||
});
|
||||
this.storage.setArray(difficulty.name, scores.slice(0, HighScores.scoresToStore));
|
||||
}
|
||||
|
||||
|
@ -77,13 +81,15 @@ export class HighScores {
|
|||
report += "" +
|
||||
`<table>
|
||||
<tr>
|
||||
<th>Time (seconds)</th>
|
||||
<th></th>
|
||||
<th>Time</th>
|
||||
<th>Deaths</th>
|
||||
</tr>`;
|
||||
for (let j = 0; j < highScores.length; j++) {
|
||||
const score = highScores[j];
|
||||
report += "" +
|
||||
`<tr>
|
||||
<th>#${j}</th>
|
||||
<td>${formatTime(Math.floor(score.time / 1000), true, false)}</td>
|
||||
<td>${score.deaths}</td>
|
||||
</tr>`;
|
||||
|
|
Loading…
Reference in New Issue