summaryrefslogtreecommitdiff
path: root/includes/ai.php
blob: 8f5f7baf3eb74c10e7f2667052f7ed9f1941794e (plain)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?php

global $memberData;
global $metadata;
global $systemCommonName;
global $system;

$profile = [
    hexdec(substr(md5($memberData["id"]), 0, 1)),
    hexdec(substr(sha1($memberData["id"]), 0, 1)),
    hexdec(substr(md5(strrev($memberData["id"])), 0, 1)),
    hexdec(substr(sha1(strrev($memberData["id"])), 0, 1)),
    hexdec(substr(md5(strtoupper($memberData["id"])), 0, 1)),
    hexdec(substr(sha1(strtoupper($memberData["id"])), 0, 1)),
    hexdec(substr(md5(strtoupper(strrev($memberData["id"]))), 0, 1)),
    hexdec(substr(sha1(strtoupper(strrev($memberData["id"]))), 0, 1)),
];

if (!function_exists("component")) {
    function component(int $parts, int $num, int $index = 0): bool {
        global $profile;

        $item = round(15 / $parts);
        $split = (int)round($profile[$index] / $item);

        return $split === $num;
    }
}

if (!function_exists("shouldHaveAn")) {
    function shouldHaveAn(string $str): bool {
        if (in_array(substr(strtolower($str), 0, 1), ["a", "e", "i", "o", "u", "y", "h"])) {
            return true;
        } else {
            return false;
        }
    }
}

if (!function_exists("getSpeciesName")) {
    function getSpeciesName(string $species, bool $canHaveMareSuffix = false): string {
        global $metadata;

        return match ($species) {
            "earth" => $metadata["robot"] ?
                "robot earth pony" :
                (!$metadata["plush"] ? "earth pony" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") :
                    "earth pony" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") . " plush"),
            "alicorn" => $metadata["robot"] ?
                "robot alicorn" :
                (!$metadata["plush"] ? "alicorn" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") :
                    "alicorn" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") . " plush"),
            "crystal" => $metadata["robot"] ?
                "robot crystal pony" :
                (!$metadata["plush"] ? "crystal pony" :
                    "crystal pony plush"),
            "pegasus" => $metadata["robot"] ?
                "robot pegasus" :
                (!$metadata["plush"] ? "pegasus" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") :
                    "pegasus" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") . " plush"),
            "batpony" => $metadata["robot"] ?
                "robot batpony" :
                (!$metadata["plush"] ? "batpony" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") :
                    "batpony" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") . " plush"),
            "unicorn" => $metadata["robot"] ?
                "robot unicorn" :
                (!$metadata["plush"] ? "unicorn" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") :
                    "unicorn" . (component(2, 2) && $canHaveMareSuffix ? " mare" : "") . " plush"),
            default => $species . "_" . $metadata["robot"]
        };
    }
}

if (!function_exists("listing")) {
    function listing(array $list): string {
        $out = "";

        foreach (array_values($list) as $index => $value) {
            $mem = getSystemMember(explode("/", $value)[0], explode("/", $value)[1]);
            $value = "<a href='/" . $mem["name"] . "'>" . getMiniName($mem["display_name"] ?? $mem["name"]) . "</a>";

            if ($index === 0) {
                $out = $value;
            } else if ($index < count(array_values($list)) - 1) {
                $out .= ", " . $value;
            } else {
                $out .= " and " . $value;
            }
        }

        return $out;
    }
}

$iam = 0;
$multipleNames = count(explode("/", $memberData["display_name"])) > 1;

$otherNames = explode("/", $memberData["display_name"]);
array_shift($otherNames);

if ($memberData["name"] === "scootaloo" && ((int)date('N') - 1) % 2 === 0) {
    $metadata["marefriends"] = array_reverse($metadata["marefriends"]);
}

?>

<!-- Intro -->
<p>
<?php if (component(4, 1)): ?>
    Hello,
<?php elseif (component(4, 2)): ?>
    Hi,
<?php elseif (component(4, 3)): ?>
    Hey,
<?php else: ?>
    Hey there!</p><p>
<?php endif; ?>

<!-- Name -->
<?= component(3, 2, 2) ? (component(4, 4) ? "My name is" : "my name is") : (component(3, 1, 2) ? "I am" : "I'm") ?> <?= explode("/", $memberData["display_name"] ?? $memberData["name"])[0] ?><?= $multipleNames && component(2, 1, 4) ? " (or " . implode("/", $otherNames) . ")" : "" ?>,

<!-- Role -->
<?= component(2, 2, 1) ? "I'm " : "I am " ?><?php $iam++; ?>
<?php if ($metadata["host"]): ?>the most common fronter
<?php elseif ($metadata["protector"]): ?>a protector
<?php else: ?><?= component(2, 2, 0) ? "part" : "a member" ?> <?php endif; ?>
of the <a href="/<?= $system ?>"><?= $systemCommonName ?></a>,<?php if (isset($metadata["median"])): ?>
    <?php if ($metadata["little"] > 0): $source = getMember($metadata["median"]); ?><?php $iam++; ?><?= component(2, 2, 2) ? "I'm " : "I am " ?><?php $iam++; ?><?= component(2, 2, 4) ? "an age regressed version of" : "age regressed from" ?> <a href="/<?= $source["name"] ?>"><?= getMiniName($source["display_name"] ?? $source["name"]) ?></a>,<?php endif; ?>
<?php endif; ?> <?= ($iam >= 3) ? "and" : (component(2, 2, 1) ? "I'm" : "I am") ?><?php $iam++; ?>

<!-- Species -->
<?php if ($iam >= 3 && component(2, 1, 4)): ?>also <?php endif; ?>
<?php if (count($metadata["species"]) === 2): ?>
<?= component(2, 1) ? "both " : "" ?>a<?= shouldHaveAn(getSpeciesName($metadata["species"][0])) ? "n" : "" ?> <?= getSpeciesName($metadata["species"][0]) ?> and a<?= shouldHaveAn(getSpeciesName($metadata["species"][1])) ? "n" : "" ?> <?= getSpeciesName($metadata["species"][1], true) ?>
<?php elseif (count($metadata["species"]) === 3): ?>
a<?= shouldHaveAn(getSpeciesName($metadata["species"][0])) ? "n" : "" ?> <?= getSpeciesName($metadata["species"][0]) ?>, a<?= shouldHaveAn(getSpeciesName($metadata["species"][1])) ? "n" : "" ?> <?= getSpeciesName($metadata["species"][1]) ?> and a<?= shouldHaveAn(getSpeciesName($metadata["species"][2])) ? "n" : "" ?> <?= getSpeciesName($metadata["species"][2], true) ?>
<?php else: ?>
a<?= shouldHaveAn(getSpeciesName($metadata["species"][0])) ? "n" : "" ?> <?= getSpeciesName($metadata["species"][0], true) ?><?php endif; ?><?php if ($iam >= 3 && component(2, 2, 4)): ?> too<?php endif; ?><!-- Pronouns --><?php if (isset($memberData["pronouns"]) && $memberData["pronouns"] !== "she/her"): ?>
, <?= component(3, 1, 3) ? "I use " . $memberData["pronouns"] . " pronouns" : (component(3, 2, 3) ? "my pronouns are " . $memberData["pronouns"] : "I go with " . $memberData["pronouns"]) ?>
<?php endif; ?>.

</p>

<p>
<!-- Shared memory -->
<?php $iamFacts = 0; $factGiven = false; if ($metadata["shared_memory"] === 1): ?>
    <?php $factGiven = true;
    if (component(3, 1, 4)): ?>
    Depending on the circumstances, I may not share memories with my headmates
    <?php elseif (component(3, 2, 4)): ?>
    I may not share memories with my headmates depending on the circumstances
    <?php else: ?>
    I sometimes <?= component(2, 2, 1) ? "don't" : "do not" ?> share memories with my headmates
    <?php endif; ?>
<?php elseif ($metadata["shared_memory"] === 0): ?>
    <?php $factGiven = true;
    if (component(3, 1, 4)):  ?>
    I <?= component(2, 2, 1) ? "don't" : "do not" ?> share memories with my headmates
    <?php elseif (component(3, 2, 4)): ?>
    I <?= component(2, 2, 1) ? "don't" : "do not" ?> have access to my headmates' memories
    <?php else: ?>
    I <?= component(2, 2, 1) ? "can't" : "cannot" ?> have access to my headmates' memories
    <?php endif; ?>
<?php endif; ?>

<!-- Fictive -->
<?php if ($metadata["fictive"]): ?>
    <?php if (component(3, 1, 5)): ?><?= $factGiven ? " and" : ""?>
    <?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; ?> a fictive
    <?php elseif (component(3, 2, 5)): ?><?= $factGiven ? " and" : ""?>
    <?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; ?> from Equestria
    <?php else: ?><?= $factGiven ? " and" : ""?>
    I come from Equestria
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

<!-- Less frequent -->
<?php if ($metadata["less_frequent"]): ?>
    <?php if (component(3, 1, 5)): ?><?= $factGiven ? " and" : ""?>
        <?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; ?> fronting less often
    <?php elseif (component(3, 2, 5)): ?><?= $factGiven ? " and" : ""?>
        <?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; ?> less often at front
    <?php else: ?><?= $factGiven ? " and" : ""?>
        I like to front less often
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

<!-- Non verbal IRL -->
<?php if ($metadata["nonverbal"]): ?>
    <?php if (component(3, 1, 5)): ?><?= $factGiven ? " and" : ""?>
        <?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; ?> nonverbal in real life
    <?php elseif (component(3, 2, 5)): ?><?= $factGiven ? " and" : ""?>
        <?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; ?> not talking in real life
    <?php else: ?><?= $factGiven ? " and" : ""?>
        I don't talk in real life
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

<!-- Age regression -->
<?php if ($metadata["little"] === 1): ?>
    <?php if (component(3, 1, 5)): ?><?= $factGiven ? " and" : ""?>
    <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
    an age regressor
    <?php elseif (component(3, 2, 5)): ?><?= $factGiven ? " and" : ""?>
    <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
    capable of age regression
    <?php else: ?><?= $factGiven ? " and" : ""?>
    I can age regress
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

<!-- Younger -->
<?php if ($metadata["little"] === 3): ?>
    <?php if (component(3, 1, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
        younger than the body is
    <?php elseif (component(3, 2, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
        younger but not enough to be considered a little
    <?php else: ?><?= $factGiven ? " and" : ""?>
        I feel <?= component(2, 2, 5) ? "kinda" : "kind of" ?> younger than my headmates
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

<!-- Age spells -->
<?php if ($metadata["age_spells"] && $metadata["little"] !== 1 && !(isset($metadata["median"]) && $metadata["little"] > 0)): ?>
    <?php if (component(3, 1, 4)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
        affected by spells to make me feel younger
    <?php elseif (component(3, 2, 4)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
        affected by age spells
    <?php else: ?><?= $factGiven ? " and" : ""?>
        age regression spells can affect me
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

<!-- Little -->
<?php if ($metadata["little"] === 2): ?>
    <?php if (component(3, 1, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
        a lot younger than the body is
    <?php elseif (component(3, 2, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
        a little
    <?php else: ?><?= $factGiven ? " and" : ""?>
        I feel a lot younger than my headmates
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

</p>

<p>

<!-- Marefriends -->
<?php $factGiven = false; $iamFacts = 0; if (count($metadata["marefriends"]) > 0): ?>
    <?php if (component(4, 1, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
        <?php if (count($metadata["marefriends"]) > 1): ?>in relationships with<?php else: ?>in a relationship with<?php endif; ?> <?= listing($metadata["marefriends"]) ?>
    <?php elseif (component(4, 2, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?php endif; ?>
        <?php if (count($metadata["marefriends"]) > 1): ?>My marefriends are<?php else: ?>My marefriend is<?php endif; ?> <?= listing($metadata["marefriends"]) ?>
    <?php elseif (component(4, 3, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?php endif; ?>
        <?= listing($metadata["marefriends"]) ?> <?php if (count($metadata["marefriends"]) > 1): ?>are my marefriends<?php else: ?>is my marefriend<?php endif; ?>
    <?php else: ?><?= $factGiven ? " and" : ""?>
        I love <?= listing($metadata["marefriends"]) ?>
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

<!-- Sisters -->
<?php if (count($metadata["sisters"]) > 0): ?>
    <?php if (component(4, 1, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
        <?php if (count($metadata["sisters"]) > 1): ?>in relationships with<?php else: ?>in a relationship with<?php endif; ?> <?= listing($metadata["sisters"]) ?>
    <?php elseif (component(4, 2, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?php endif; ?>
        <?= $factGiven ? "my" : "My"?><?php if (count($metadata["sisters"]) > 1): ?> sisters are<?php else: ?> sister is<?php endif; ?> <?= listing($metadata["sisters"]) ?>
    <?php elseif (component(4, 3, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?php endif; ?>
        <?= listing($metadata["sisters"]) ?> <?php if (count($metadata["sisters"]) > 1): ?>are my sisters<?php else: ?>is my sister<?php endif; ?>
    <?php else: ?><?= $factGiven ? " and" : ""?>
        <?php if ($factGiven): ?>
        I also love <?= listing($metadata["sisters"]) ?> as sister<?php if (count($metadata["sisters"]) > 1): ?>s<?php endif; ?>
        <?php else: ?>
        <?= listing($metadata["sisters"]) ?> <?php if (count($metadata["sisters"]) > 1): ?>are my family<?php else: ?>is my family<?php endif; ?>
        <?php endif; ?>
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

<!-- Caretakers -->
<?php if (count($metadata["caretakers"]) > 0): ?>
    <?php if (component(4, 1, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?= component(2, 2, 0) ? "I'm" : "I am" ?><?php $iamFacts++; endif; ?>
        being taken care of by <?= listing($metadata["caretakers"]) ?>
    <?php elseif (component(4, 2, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?php endif; ?>
        <?= $factGiven ? "the" : "The"?><?php if (count($metadata["caretakers"]) > 1): ?> mares who take care of me are<?php else: ?> mare who takes care of me is<?php endif; ?> <?= listing($metadata["caretakers"]) ?>
    <?php elseif (component(4, 3, 5)): ?><?= $factGiven ? " and" : ""?>
        <?php if ($iamFacts > 0): ?><?php else: ?><?php endif; ?>
        <?= listing($metadata["caretakers"]) ?> <?php if (count($metadata["caretakers"]) > 1): ?>are my caretakers<?php else: ?>is my caretaker<?php endif; ?>
    <?php else: ?><?= $factGiven ? " and" : ""?>
        <?php if ($factGiven): ?>
            I like having <?= listing($metadata["caretakers"]) ?> take care of me
        <?php else: ?>
            <?= listing($metadata["caretakers"]) ?> take care of me
        <?php endif; ?>
    <?php endif; ?>
<?php $factGiven = true; endif; ?>

</p>