about summary refs log tree commit diff stats
path: root/js/princess/game.js
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-05-13 10:16:41 -0400
committerelioat <elioat@tilde.institute>2024-05-13 10:16:41 -0400
commitbefcf49e74016d5719d717cd3ccd7fb587d46db9 (patch)
tree1e23b36726e2652d4e2090a6c8d0d2fa636d1fba /js/princess/game.js
parentc356ffb437e953122730ca23c7404f78fa2e714c (diff)
downloadtour-befcf49e74016d5719d717cd3ccd7fb587d46db9.tar.gz
*
Diffstat (limited to 'js/princess/game.js')
-rw-r--r--js/princess/game.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/js/princess/game.js b/js/princess/game.js
index aab427c..17d70e2 100644
--- a/js/princess/game.js
+++ b/js/princess/game.js
@@ -47,13 +47,33 @@ const levelUpPartyMember = (person, stat, amount) => {
     }
 };
 
+const addQuest = (quest) => {
+    if (!princess.activeQuests.includes(quest)) {
+        quest.start = new Date(); // Update the quest's start time to the current time
+        princess.activeQuests.push(quest);
+    }
+}
+
+const checkQuests = () => {
+    princess.activeQuests.forEach(quest => {
+        let currentTime = new Date();
+        let elapsedTime = currentTime - quest.start;
+        if (elapsedTime >= quest.duration) { // TODO: shooting from the hip, this'll need to be tested
+            princess.completedQuests.push(quest);
+            princess.activeQuests = princess.activeQuests.filter(q => q !== quest);
+        }
+    });
+}
+
 // the player character
 let princess = {
     finery: 10,
     knowledge: 10,
     spider: 100,
     treasure: 100,
-    party: [] // the princesses party of people (an array may not make sense for this, since I'd like to limit it's max size, but maybe I can have a bounding function)
+    party: [], // the princesses party of people (an array may not make sense for this, since I'd like to limit it's max size, but maybe I can have a bounding function)
+    activeQuests: [],
+    completedQuests: []
 }
 
 // the people the player can recruit
@@ -92,12 +112,14 @@ let quests = [
         name: "The Spider of the Silver Forest",
         description: "The princess must defeat the spider of the silver forest.",
         reward: "The treasure of the silver forest.",
-        duration: 2 * HOUR
+        duration: 2 * HOUR,
+        start: null
     },
     {
         name: "The Treasure of the Silver Forest",
         description: "The princess must find the treasure of the silver forest.",
         reward: "The spider of the silver forest.",
-        duration: 2 * HOUR
+        duration: 2 * HOUR,
+        start: null
     }
 ]
\ No newline at end of file