add WWTRA mode #4
@ -108,7 +108,7 @@ class ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reduceScore() {
|
reduceScore() {
|
||||||
this.stats.incrementScore(-1);
|
this.stats.updateScore(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetScore() {
|
resetScore() {
|
||||||
|
@ -14,16 +14,26 @@ export class Stats {
|
|||||||
incrementScore(value = 1) {
|
incrementScore(value = 1) {
|
||||||
this.#score += value;
|
this.#score += value;
|
||||||
|
|
||||||
if (this.#highScore < this.#score) {
|
this.checkHighScore;
|
||||||
this.#highScore = this.#score;
|
|
||||||
localStorage.setItem(this.#highScoreStorageKey, this.#highScore.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetScore(): void {
|
resetScore(): void {
|
||||||
this.#score = 0;
|
this.#score = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateScore(value) {
|
||||||
|
this.#score += value;
|
||||||
|
|
||||||
|
this.checkHighScore;
|
||||||
|
}
|
||||||
|
|
||||||
|
private checkHighScore() {
|
||||||
|
if (this.#highScore < this.#score) {
|
||||||
|
this.#highScore = this.#score;
|
||||||
|
localStorage.setItem(this.#highScoreStorageKey, this.#highScore.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get highScore(): number {
|
get highScore(): number {
|
||||||
return this.#highScore;
|
return this.#highScore;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user