summaryrefslogtreecommitdiff
path: root/includes/system/compare.inc
blob: ea12582a2913c7ed1a6b4f0292454f88319e5b15 (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
<?php global $system; global $lang; global $pages; global $systemCommonName; global $systemID; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); $title = $pages["s:compare"]["name"][$lang["_name"]] . " · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; global $travelling;

$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true);

function getMember(string $id) {
    global $systemID;
    global $members;

    $member = null;

    foreach ($members as $m) {
        if ($m["id"] === $id) $member = $m;
    }

    return $member;
}

?>

    <br>
    <div class="container">
        <h2><?= $lang["compare"]["title"] ?> <?= $systemCommonName ?></h2>
        <div class="comparison">
            <span class="comparison-header comparison-item">
                <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][0] ?></abbr></span>
                <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][1] ?></abbr></span>
                <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][2] ?></abbr></span>
                <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][3] ?></abbr></span>
                <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][4] ?></abbr></span>
                <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][5] ?></abbr></span>
            </span>
            <span class="comparison-header comparison-item">
                <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][0] ?></abbr></span>
                <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][1] ?></abbr></span>
                <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][2] ?></abbr></span>
                <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][3] ?></abbr></span>
                <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][4] ?></abbr></span>
                <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][5] ?></abbr></span>
            </span>
            <span class="comparison-header comparison-item">
                <span class="comparison-header-l0"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
                <span class="comparison-header-l1"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
                <span class="comparison-header-l2"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
                <span class="comparison-header-l3"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
                <span class="comparison-header-l4"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
                <span class="comparison-header-l5"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
            </span>
            <span class="comparison-header comparison-item">
                <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][0] ?></abbr></span>
                <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][1] ?></abbr></span>
                <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][2] ?></abbr></span>
                <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][3] ?></abbr></span>
                <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][4] ?></abbr></span>
                <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][5] ?></abbr></span>
            </span>
            <span class="comparison-header comparison-item">
                <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][0] ?></abbr></span>
                <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][1] ?></abbr></span>
                <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][2] ?></abbr></span>
                <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][3] ?></abbr></span>
                <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][4] ?></abbr></span>
                <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][5] ?></abbr></span>
            </span>
            <span class="comparison-header comparison-item">
                <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][0] ?></abbr></span>
                <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][1] ?></abbr></span>
                <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][2] ?></abbr></span>
                <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][3] ?></abbr></span>
                <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][4] ?></abbr></span>
                <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][5] ?></abbr></span>
            </span>
            <span class="comparison-header comparison-item">
                <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][0] ?></abbr></span>
                <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][1] ?></abbr></span>
                <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][2] ?></abbr></span>
                <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][3] ?></abbr></span>
                <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][4] ?></abbr></span>
                <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][5] ?></abbr></span>
            </span>
            <span class="comparison-header comparison-item">
                <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][0] ?></abbr></span>
                <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][1] ?></abbr></span>
                <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][2] ?></abbr></span>
                <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][3] ?></abbr></span>
                <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][4] ?></abbr></span>
                <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][5] ?></abbr></span>
            </span>

            <?php foreach (scoreOrder($members, $systemID) as $member):

            $metadata = $member["_metadata"];

            ?>
                <a title="<?= $member["display_name"] ?? $member["name"] ?>" data-bs-toggle="tooltip" class="member-link comparison-item comparison-item-clickable" href="/<?= $member["name"] ?>">
                    <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <span style="vertical-align: middle;"><span class="comparison-name-full"><?= $member["display_name"] ?? $member["name"] ?></span><span class="comparison-name-small"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></span>
                    <span class="comparison-colors" style="background-color: #<?= $member["color"] ?? "ffffff" ?>; height: 16px; width: 16px;display: inline-block;vertical-align: middle;border-radius:2px;"></span>
                </a>
                <span class="comparison-item">
                    <?php foreach ($metadata["species"] ?? [] as $species): ?>
                        <img data-bs-toggle="tooltip" title="<?php switch ($species) {
                            case "earth":
                                if ($metadata["robot"]) echo $lang["species"]["earth"][0]; else if ($metadata["plush"]) echo $lang["species"]["earth"][1]; else echo $lang["species"]["earth"][2];
                                break;

                            case "alicorn":
                                if ($metadata["robot"]) echo $lang["species"]["alicorn"][0]; else if ($metadata["plush"]) echo $lang["species"]["alicorn"][1]; else echo $lang["species"]["alicorn"][2];
                                break;

                            case "crystal":
                                if ($metadata["robot"]) echo $lang["species"]["crystal"][0]; else if ($metadata["plush"]) echo $lang["species"]["crystal"][1]; else echo $lang["species"]["crystal"][2];
                                break;

                            case "pegasus":
                                if ($metadata["robot"]) echo $lang["species"]["pegasus"][0]; else if ($metadata["plush"]) echo $lang["species"]["pegasus"][1]; else echo $lang["species"]["pegasus"][2];
                                break;

                            case "batpony":
                                if ($metadata["robot"]) echo $lang["species"]["batpony"][0]; else if ($metadata["plush"]) echo $lang["species"]["batpony"][1]; else echo $lang["species"]["batpony"][2];
                                break;

                            case "unicorn":
                                if ($metadata["robot"]) echo $lang["species"]["unicorn"][0]; else if ($metadata["plush"]) echo $lang["species"]["unicorn"][1]; else echo $lang["species"]["unicorn"][2];
                                break;

                            default:
                                echo $species . "_" . $metadata["robot"];
                                break;
                        } ?>" style="width:24px;vertical-align: middle;position:relative;top:-5px;" src="/assets/species/<?= $species ?><?= $metadata["robot"] ? "-robot" : ($metadata["plush"] ? "-plush" : "") ?>.png" alt="<?= $species ?>">
                    <?php endforeach; ?>
                </span>
                <span class="comparison-item">
                    <?php if (isset($metadata["code"]) && trim($metadata["code"]) !== ""): ?>
                        <code style="color: white;"><?= strtoupper(substr($metadata["code"], 0, 3)) ?></code>
                    <?php else: ?>-<?php endif; ?>
                </span>
                <span class="comparison-item">
                    <?= count($metadata["marefriends"]) + count($metadata["sisters"]) + count($metadata["caretakers"]) === 0 ? "-" : "" ?>
                    <span class="comparison-relations-count">
                        <?= count($metadata["marefriends"]) + count($metadata["sisters"]) > 0 ? count($metadata["marefriends"]) + count($metadata["sisters"]) : "" ?>
                    </span>
                    <span class="comparison-relations-full">
                        <?php $index = 0; foreach ($metadata["marefriends"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) {
                            global $mfMemberID;
                            return $item["id"] === $mfMemberID;
                        }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br><?= $lang["compare"]["status"][0] ?>" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="<?= getAsset($mfSystem, $mfMember["id"], "heads") ?>" style="width:24px;"></a><?php $index++; endforeach; ?><?php $index = 0; foreach ($metadata["sisters"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) {
                            global $mfMemberID;
                            return $item["id"] === $mfMemberID;
                        }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br><?= $lang["compare"]["status"][1] ?>" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="<?= getAsset($mfSystem, $mfMember["id"], "heads") ?>" style="width:24px;"></a><?php $index++; endforeach; ?><?php $index = 0; foreach ($metadata["caretakers"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) {
                            global $mfMemberID;
                            return $item["id"] === $mfMemberID;
                        }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br><?= $lang["compare"]["status"][2] ?>" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="<?= getAsset($mfSystem, $mfMember["id"], "heads") ?>" style="width:24px;"></a><?php $index++; endforeach; ?>
                    </span>
                </span>
                <span class="comparison-item">
                    <?php if ($metadata["shared_memory"] > 0): ?>
                        <?php if ($metadata["shared_memory"] === 1): ?>
                            <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][1] ?>" src="/assets/icons/partial.svg" alt="<?= $lang["compare"]["state"][1] ?>" style="width:24px;">
                        <?php else: ?>
                            <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][0] ?>" src="/assets/icons/complete.svg" alt="<?= $lang["compare"]["state"][0] ?>" style="width:24px;">
                        <?php endif; ?>
                    <?php else: ?>
                        <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][2] ?>" src="/assets/icons/none.svg" alt="<?= $lang["compare"]["state"][2] ?>" style="width:24px;">
                    <?php endif; ?>
                </span>
                <span class="comparison-item">
                    <?php if ($metadata["fictive"]): ?>
                        <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][0] ?>" src="/assets/icons/complete.svg" alt="<?= $lang["compare"]["state"][0] ?>" style="width:24px;">
                    <?php else: ?>
                        <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][2] ?>" src="/assets/icons/none.svg" alt="<?= $lang["compare"]["state"][2] ?>" style="width:24px;">
                    <?php endif; ?>
                </span>
                <span class="comparison-item">
                    <?php if ($metadata["little"] === 2): ?>
                        <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][0] ?>" src="/assets/icons/complete.svg" alt="<?= $lang["compare"]["state"][0] ?>" style="width:24px;">
                    <?php elseif ($metadata["little"] === 3): ?>
                        <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][3] ?>" src="/assets/icons/partial.svg" alt="<?= $lang["compare"]["state"][1] ?>" style="width:24px;">
                    <?php else: ?>
                        <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][2] ?>" src="/assets/icons/none.svg" alt="<?= $lang["compare"]["state"][2] ?>" style="width:24px;">
                    <?php endif; ?>
                </span>
                <span class="comparison-item">
                    <?php if ($metadata["protector"]): ?>
                        <?php if ($travelling[$member["id"]]["travelling"]): ?>
                            <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][4] ?>" src="/assets/icons/partial.svg" alt="<?= $lang["compare"]["state"][4] ?>" style="width:24px;">
                        <?php else: ?>
                            <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][0] ?>" src="/assets/icons/complete.svg" alt="<?= $lang["compare"]["state"][0] ?>" style="width:24px;">
                        <?php endif; ?>
                    <?php else: ?>
                        <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][2] ?>" src="/assets/icons/none.svg" alt="<?= $lang["compare"]["state"][2] ?>" style="width:24px;">
                    <?php endif; ?>
                </span>
            <?php endforeach; ?>
        </div>
    </div>

<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>