about summary refs log tree commit diff stats
path: root/tangle.mu
Commit message (Expand)AuthorAgeFilesLines
* 4134 - 'input' = 'ingredient'Kartik K. Agaram2017-12-031-1/+1
* 4002Kartik K. Agaram2017-09-231-13/+12
* 3483Kartik K. Agaram2016-10-081-1/+1
* 3380Kartik K. Agaram2016-09-171-5/+5
* 3302Kartik K. Agaram2016-09-071-1/+2
* 2746Kartik K. Agaram2016-03-091-1/+1
* 2735 - define recipes using 'def'Kartik K. Agaram2016-03-081-3/+3
* 2426Kartik K. Agaram2015-11-111-4/+3
* 2235Kartik K. Agaram2015-10-021-4/+4
* 1880 - switch .mu files to new type-deducing idiomKartik K. Agaram2015-07-291-6/+6
* 1868 - start using naked literals everywhereKartik K. Agaram2015-07-281-4/+4
* 1780 - now we always reclaim local scopesKartik K. Agaram2015-07-131-1/+1
* 1773 - update all mu recipes to new-default-spaceKartik K. Agaram2015-07-131-1/+1
* 1363 - rename 'integer' to 'number'Kartik K. Agaram2015-05-131-8/+8
* 1345Kartik K. Agaram2015-05-111-3/+6
* 1298 - better ingredient/product handlingKartik K. Agaram2015-05-071-3/+1
* 1278 - support before/after tangle directivesKartik K. Agaram2015-05-051-0/+36
* 1276 - make C++ version the defaultKartik K. Agaram2015-05-051-35/+0
* 690 - convention: '$' commands for debugging onlyKartik K. Agaram2015-02-011-2/+2
* 578 - switch to non-polymorphic 'print' functionsKartik K. Agaram2015-01-171-1/+1
* 574 - printing string literals is a hack; hard-code it in for nowKartik K. Agaram2015-01-161-2/+2
* 571 - screen primitives take an explicit terminalKartik K. Agaram2015-01-151-3/+3
* 497 - strengthen the concept of 'space'Kartik K. Agaram2015-01-021-1/+1
* 428 - cleanup odds and endsKartik K. Agaram2014-12-141-13/+13
* 403 - 'function' is more clear than 'def'Kartik K. Agaram2014-12-121-2/+2
* 401 - stop abbreviating opsKartik K. Agaram2014-12-121-4/+4
* 321 - before/after can now come anywhereKartik K. Agaram2014-11-241-24/+9
* 319 - ack, forgot to handle blocks when tanglingKartik K. Agaram2014-11-241-0/+50
e> 2024-05-13 10:16:41 -0400 *' href='/elioat/tour/commit/js/princess/game.js?id=befcf49e74016d5719d717cd3ccd7fb587d46db9'>befcf49 ^
c356ffb ^




befcf49 ^

628411e ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127








                                                                     















                                                                                    
 











                                                                        
 









                                                                              
 

















                                                                                                      
 
                       



                  
                  
                                                                                                                                                                       

                       

 
                                    






                                                 

                                                                           






                                      

                  






                                                         









                                                                                 

                           




                                                                                 

                           

     
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}`;
}


const addPartyPerson = (person) => {
    if (princess.party.length < 5 && !princess.party.includes(person)) {
        princess.party.push(person);
    }
}

const removePartyPerson = (person) => {
    if (princess.party.includes(person)) {
        princess.party = princess.party.filter(p => p !== person);
    }
}


const levelUpPrincess = (stat, amount) => {
    princess[stat] += amount;
}

const levelUpPartyMember = (person, stat, amount) => {
    if (princess.party.includes(person) && typeof person[stat] === 'number') {
        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 princess' 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
let people = [
    {
        name: "Hawk",
        description: "Stable boy and goat herd.",
        aspiration: "To be a knight.",
        power: 1,
        speed: 1,
        spider: 2,
        loyalty: 3 // loyalty increases whenever the princess pays a person
    },
    {
        name: "Bella",
        description: "Scullery maid.",
        aspiration: "To be a pirate.",
        power: 2,
        speed: 2,
        spider: 1,
        loyalty: 3
    },
    {
        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,
        loyalty: 3
    }
]

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,
        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,
        start: null
    }
]