diff options
author | elioat <elioat@tilde.institute> | 2024-05-12 21:21:07 -0400 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-05-12 21:21:07 -0400 |
commit | 628411e777bb5ed25b49ad67e8c897c1891a4223 (patch) | |
tree | 5ae31e6e4ffcbd784b1c5142c68919684835417d /js/princess/game.js | |
parent | 4e466a30285e06b7f36a0a2b89f5e1271a2fe13a (diff) | |
download | tour-628411e777bb5ed25b49ad67e8c897c1891a4223.tar.gz |
*
Diffstat (limited to 'js/princess/game.js')
-rw-r--r-- | js/princess/game.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/js/princess/game.js b/js/princess/game.js index e69de29..0415b70 100644 --- a/js/princess/game.js +++ b/js/princess/game.js @@ -0,0 +1,62 @@ + +let now = new Date(); +const MINUTE = 60 * 1000; +const HOUR = 60 * MINUTE; +const DAY = 24 * HOUR; + +const futureTime = (now, hours, minutes = 0) => { + return new Date(now.getTime() + hours * HOUR + minutes * MINUTE); +} + + +const prettyTime = (time) => { + return time.toLocaleTimeString('en-US', { hour: 'numeric', minute: 'numeric' }); +} + +const prettyTimeFromNow = (time) => { + let diff = time - new Date(); + if (diff === 0) { + return 'now'; + } + let hours = Math.floor(diff / HOUR); + let minutes = Math.floor((diff % HOUR) / MINUTE); + let hoursText = hours === 1 ? 'hour' : 'hours'; + let minutesText = minutes === 1 ? 'minute' : 'minutes'; + return `${hours} ${hoursText} and ${minutes} ${minutesText}`; +} + +let princess = { + finery: 10, + knowledge: 10, + spider: 100, + treasure: 100 +} + +let party = [] + +let people = [ + { + name: "Hawk", + description: "Stable boy and goat herd.", + aspiration: "To be a knight.", + power: 1, + speed: 1, + spider: 2 + }, + { + name: "Bella", + description: "Scullery maid.", + aspiration: "To be a pirate.", + power: 2, + speed: 2, + spider: 1 + }, + { + name: "Silver Teeth in the Moonlight, aka Teeth", + description: "A rotund goblin doctor.", + aspiration: "To be the dentist for a king.", + power: 2, + speed: 5, + spider: 1 + } +] \ No newline at end of file |