summaryrefslogtreecommitdiff
path: root/includes/score.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/score.php')
-rw-r--r--includes/score.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/includes/score.php b/includes/score.php
index 5367cd6..89b3d3c 100644
--- a/includes/score.php
+++ b/includes/score.php
@@ -3,7 +3,7 @@
function calculateScore($metadata, $name) {
$scoreHost = $metadata["host"] ? 10000 : 0;
$scoreFictive = $metadata["fictive"] ? 200 : 0;
- $scoreLittle = $metadata["little"] === 2 ? 100 : ($metadata["little"] === 1 ? 50 : 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;
@@ -34,8 +34,10 @@ function scoreOrder($members, $system) {
$ordered = [];
foreach ($members as $member) {
if ($member["name"] !== "unknown") {
- $member["_metadata"] = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-$member[id]-metadata.json"), true);
- $member["_score"] = calculateScore(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-$member[id]-metadata.json"), true), $member["display_name"] ?? $member["name"]);
+ $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;
}
}
@@ -52,16 +54,16 @@ function scoreOrderGlobal() {
foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) {
if ($member["name"] !== "unknown") {
$member["_system"] = "gdapd";
- $member["_metadata"] = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true);
- $member["_score"] = calculateScore(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true), $member["display_name"] ?? $member["name"]);
+ $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["_system"] = "ynmuc";
- $member["_metadata"] = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true);
- $member["_score"] = calculateScore(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true), $member["display_name"] ?? $member["name"]);
+ $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;
}
}