From 5cc0c804442d06b1e30b75eb8775f37b00d57852 Mon Sep 17 00:00:00 2001 From: zyl Date: Tue, 25 Jun 2024 13:46:44 -0700 Subject: [PATCH] simulate pets upon reloading the page --- site/pages/pet.md | 12 +++++++++++- site/root/js/pet.js | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/site/pages/pet.md b/site/pages/pet.md index 43dd94a..e3bcec2 100644 --- a/site/pages/pet.md +++ b/site/pages/pet.md @@ -67,9 +67,19 @@ embed: tips!! + +
+ changelog +
+ 06/25/2024 +
    +
  • pets now are simulated even if the page is unloaded
  • +

    +
+
diff --git a/site/root/js/pet.js b/site/root/js/pet.js index 66e76b3..82badae 100644 --- a/site/root/js/pet.js +++ b/site/root/js/pet.js @@ -541,6 +541,13 @@ document.pet = pet; } + const updates = Math.floor( + (Date.now() - pet.lastUpdate) / (60000 / UPDATES_PER_MINUTE) + ); + for (let i = 0; i < updates; i++) { + pet.update(); + } + pet.updateDom(); console.log(pet);