game only resets score when logged in
This commit is contained in:
parent
641af661b4
commit
a0a869781e
1 changed files with 9 additions and 9 deletions
|
|
@ -43,7 +43,7 @@ function setup() {
|
||||||
setupFont();
|
setupFont();
|
||||||
setupGame();
|
setupGame();
|
||||||
let originalSetItem = localStorage.setItem;
|
let originalSetItem = localStorage.setItem;
|
||||||
localStorage.setItem = function(){
|
localStorage.setItem = function () {
|
||||||
document.createEvent('Event').initEvent('itemInserted', true, true);
|
document.createEvent('Event').initEvent('itemInserted', true, true);
|
||||||
originalSetItem.apply(this, arguments);
|
originalSetItem.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
@ -189,7 +189,7 @@ function die(): void {
|
||||||
/**
|
/**
|
||||||
* Exports playTime, Score and if the game is running into localStorage
|
* Exports playTime, Score and if the game is running into localStorage
|
||||||
*/
|
*/
|
||||||
function exportToLocalStorage(){
|
function exportToLocalStorage() {
|
||||||
localStorage.setItem("game-playTime", String(playTime));
|
localStorage.setItem("game-playTime", String(playTime));
|
||||||
localStorage.setItem("game-score", String(score));
|
localStorage.setItem("game-score", String(score));
|
||||||
localStorage.setItem("game-isRunning", String(!hasDied));
|
localStorage.setItem("game-isRunning", String(!hasDied));
|
||||||
|
|
@ -249,13 +249,13 @@ function checkRaspberryScore(): void {
|
||||||
* Resets the score if game is started
|
* Resets the score if game is started
|
||||||
*/
|
*/
|
||||||
function resetScore(): void {
|
function resetScore(): void {
|
||||||
if (hasDied) {
|
if (!hasDied || localStorage.getItem("frontend-ready") == "false") return;
|
||||||
|
|
||||||
hasDied = false;
|
hasDied = false;
|
||||||
score = 0;
|
score = 0;
|
||||||
hasAlreadyScored = false;
|
hasAlreadyScored = false;
|
||||||
startTime = Date.now();
|
startTime = Date.now();
|
||||||
exportToLocalStorage();
|
exportToLocalStorage();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue