From 628411e777bb5ed25b49ad67e8c897c1891a4223 Mon Sep 17 00:00:00 2001 From: elioat Date: Sun, 12 May 2024 21:21:07 -0400 Subject: * --- js/princess/game.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'js/princess/game.js') 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 -- cgit 1.4.1-2-gfad0