summaryrefslogtreecommitdiff
path: root/includes/score.php
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-10-10 20:51:39 +0200
committerMinteck <contact@minteck.org>2022-10-10 20:51:39 +0200
commit108525534c28013cfe1897c30e4565f9893f3766 (patch)
treedd3e5132971f96ab5f05e7f3f8f6dbbf379a19bd /includes/score.php
parent2162eaa06f7e4764eb3dcfe130ec2c711d0c62ab (diff)
downloadpluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.gz
pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.bz2
pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.zip
Update
Diffstat (limited to 'includes/score.php')
-rw-r--r--includes/score.php81
1 files changed, 0 insertions, 81 deletions
diff --git a/includes/score.php b/includes/score.php
deleted file mode 100644
index cd8c389..0000000
--- a/includes/score.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-
-function calculateScore($metadata, $name) {
- $scoreHost = $metadata["host"] ? 10000 : 0;
- $scoreFictive = $metadata["fictive"] ? 200 : 0;
- $scoreLittle = $metadata["little"] === 2 ? 100 : ($metadata["little"] === 1 ? 50 : ($metadata["little"] === 3 ? 75 : 0));
- $scoreNotTalking = $metadata["not_talking"] ? -200 : 0;
- $scoreMedian = $metadata["median"] !== false ? -50 : 0;
- $scoreProtector = $metadata["protector"] ? 1000 : 0;
- $scoreSharedMemory = $metadata["shared_memory"] === 0 ? 200 : ($metadata["shared_memory"] === 1 ? 50 : 0);
- $scoreSpecies = (in_array("pegasus", $metadata["species"]) ? 100 : 0) + (in_array("unicorn", $metadata["species"]) ? 75 : 0) + (in_array("earth", $metadata["species"]) ? 50 : 0) + (in_array("alicorn", $metadata["species"]) ? 150 : 0) + (in_array("batpony", $metadata["species"]) ? 125 : 0) + (in_array("crystal", $metadata["species"]) ? 125 : 0);
- $scoreName = strlen($name) * 5;
- $relations = (count($metadata["marefriends"]) * ($metadata["little"] ? 1 : 2)) + count($metadata["sisters"]);
- $scoreRelations = $relations * 50;
-
- $scoreAdd = 0;
- if ($name === "Cloudy Dreams") $scoreAdd += 250;
- if ($name === "Scoots/Mia") $scoreAdd -= 495;
-
- $score = $scoreHost + $scoreFictive + $scoreLittle + $scoreNotTalking + $scoreProtector + $scoreSharedMemory + $scoreRelations + $scoreSpecies + $scoreName + $scoreMedian + $scoreAdd;
-
- return [
- "host" => $scoreHost,
- "fictive" => $scoreFictive,
- "little" => $scoreLittle,
- "median" => $scoreMedian,
- "not_talking" => $scoreNotTalking,
- "name" => $scoreName,
- "protector" => $scoreProtector,
- "shared_memory" => $scoreSharedMemory,
- "relations" => $scoreRelations,
- "species" => $scoreSpecies,
- "additional" => $scoreAdd,
- "total" => $score
- ];
-}
-
-function scoreOrder($members, $system) {
- $ordered = [];
- foreach ($members as $member) {
- if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($member["system"] ?? $system) . "-$member[id]-metadata.json")) {
- $systemID = $member["system"] ?? $system;
-
- $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$member[id]-metadata.json"), true));
- $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$member[id]-metadata.json"), true)), $member["display_name"] ?? $member["name"]);
- $ordered[] = $member;
- }
- }
-
- uasort($ordered, function($a, $b) {
- return $b["_score"]["total"] - $a["_score"]["total"];
- });
-
- return $ordered;
-}
-
-function scoreOrderGlobal() {
- $ordered = [];
- foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) {
- if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json")) {
- $member["_system"] = "gdapd";
- $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true));
- $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true)), $member["display_name"] ?? $member["name"]);
- $ordered[] = $member;
- }
- }
- foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) {
- if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json")) {
- $member["_system"] = "ynmuc";
- $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true));
- $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true)), $member["display_name"] ?? $member["name"]);
- $ordered[] = $member;
- }
- }
-
- uasort($ordered, function($a, $b) {
- return $b["_score"]["total"] - $a["_score"]["total"];
- });
-
- return $ordered;
-} \ No newline at end of file