diff options
author | Minteck <contact@minteck.org> | 2022-10-10 20:51:39 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-10-10 20:51:39 +0200 |
commit | 108525534c28013cfe1897c30e4565f9893f3766 (patch) | |
tree | dd3e5132971f96ab5f05e7f3f8f6dbbf379a19bd /includes/ai.inc | |
parent | 2162eaa06f7e4764eb3dcfe130ec2c711d0c62ab (diff) | |
download | pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.gz pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.bz2 pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.zip |
Update
Diffstat (limited to 'includes/ai.inc')
-rw-r--r-- | includes/ai.inc | 311 |
1 files changed, 311 insertions, 0 deletions
diff --git a/includes/ai.inc b/includes/ai.inc new file mode 100644 index 0000000..8f5f7ba --- /dev/null +++ b/includes/ai.inc @@ -0,0 +1,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>
\ No newline at end of file |