diff --git a/Templates/Ranking/general.tpl b/Templates/Ranking/general.tpl index b3101be5..2a293a17 100644 --- a/Templates/Ranking/general.tpl +++ b/Templates/Ranking/general.tpl @@ -16,57 +16,6 @@ mysqli_report(MYSQLI_REPORT_OFF); -// ========================= -// SERVER MILESTONES (NEW_FUNCTIONS_MILESTONES) -// "First player on the server to..." achievements. Data is recorded by -// hooks placed at the relevant game events (see GameEngine/Database.php's -// recordMilestoneIfFirst()/getMilestones(), and the hooks in -// GameEngine/Automation.php, GameEngine/Alliance.php). This section only -// READS what's already been recorded — it never writes anything itself. -// ========================= -$milestonesEnabled = defined('NEW_FUNCTIONS_MILESTONES') && NEW_FUNCTIONS_MILESTONES; -$milestonesData = $milestonesEnabled ? $database->getMilestones() : []; - -// Lightens ($percent > 0) or darkens ($percent < 0) a "#rrggbb" color, used -// to build each badge's radial-gradient inline (kept as plain computed hex -// stops rather than CSS color-mix()/custom properties, for broader browser -// compatibility with this project's existing baseline). -function tzms_shade($hex, $percent) { - $hex = ltrim($hex, '#'); - $r = hexdec(substr($hex, 0, 2)); - $g = hexdec(substr($hex, 2, 2)); - $b = hexdec(substr($hex, 4, 2)); - $adjust = function ($c) use ($percent) { - $c = $percent < 0 ? $c * (1 + $percent / 100) : $c + (255 - $c) * ($percent / 100); - return max(0, min(255, (int) round($c))); - }; - return sprintf('#%02x%02x%02x', $adjust($r), $adjust($g), $adjust($b)); -} - -// Simple line-icon set (inline SVG, no external image files, so there's -// nothing that can 404 regardless of where this is deployed). -$milestoneIcons = [ - 'village' => '', - 'population' => '', - 'artifact' => '', - 'wonder' => '', - 'plan' => '', - 'alliance' => '', - 'conquest' => '', - 'five_villages' => '', -]; - -$milestoneDefs = [ - 'second_village' => ['label' => TZ_MILESTONE_SECOND_VILLAGE, 'icon' => 'village', 'color' => '#c0783c'], - 'population_1000' => ['label' => TZ_MILESTONE_POPULATION_1000, 'icon' => 'population', 'color' => '#3c78c0'], - 'first_artifact' => ['label' => TZ_MILESTONE_FIRST_ARTIFACT, 'icon' => 'artifact', 'color' => '#8a4fc0'], - 'first_ww' => ['label' => TZ_MILESTONE_FIRST_WW, 'icon' => 'wonder', 'color' => '#c0a030'], - 'first_ww_plan' => ['label' => TZ_MILESTONE_FIRST_WW_PLAN, 'icon' => 'plan', 'color' => '#2f9e8f'], - 'first_alliance' => ['label' => TZ_MILESTONE_FIRST_ALLIANCE, 'icon' => 'alliance', 'color' => '#3fa14a'], - 'first_pvp_conquest' => ['label' => TZ_MILESTONE_FIRST_PVP_CONQUEST, 'icon' => 'conquest', 'color' => '#b6362f'], - 'five_villages' => ['label' => TZ_MILESTONE_FIVE_VILLAGES, 'icon' => 'five_villages', 'color' => '#7a6030'], -]; - // ========================= // TRIBES COUNT // ========================= @@ -214,120 +163,6 @@ return isset($units[$k])? (int)$units[$k] : 0; $isStaff = isset($session) && $session->access >= 8; // MH si Admin ?> - - -
-
-
- $mdef): - $achieved = $milestonesData[$mkey] ?? null; - $light = tzms_shade($mdef['color'], 28); - $dark = tzms_shade($mdef['color'], -32); - $bg = $achieved - ? sprintf('background:radial-gradient(circle at 32%% 28%%, %s, %s 55%%, %s 100%%);border-color:rgba(255,255,255,0.35);', $light, $mdef['color'], $dark) - : 'background:#d8d8d8;border-color:rgba(0,0,0,0.08);'; - $title = htmlspecialchars($mdef['label'], ENT_QUOTES, 'UTF-8'); - - // Caption text under badge: - // - first_alliance shows the alliance name/tag (stored in `extra`) - // - all others show the player username - if ($achieved) { - if ($mkey === 'first_alliance') { - $caption = htmlspecialchars($achieved['extra'] ?: $achieved['username'] ?: '', ENT_QUOTES, 'UTF-8'); - } else { - $caption = htmlspecialchars($achieved['username'] ?: '', ENT_QUOTES, 'UTF-8'); - } - } else { - $caption = ''; - } - - // Tooltip meta line: - // - first_alliance: shows alliance name on first line, founder + date on second - // - all others: "Username — dd.mm.yy H:i:s" - if ($achieved) { - if ($mkey === 'first_alliance') { - $meta = htmlspecialchars( - ($achieved['extra'] ?: '-') . "\n" . - TZ_MILESTONE_FOUNDED_BY . ' ' . ($achieved['username'] ?: '-') . ' — ' . date('d.m.y G:i:s', (int)$achieved['achieved_time']), - ENT_QUOTES, 'UTF-8' - ); - } else { - $meta = htmlspecialchars( - ($achieved['username'] ?: '-') . ' — ' . date('d.m.y G:i:s', (int)$achieved['achieved_time']), - ENT_QUOTES, 'UTF-8' - ); - } - } else { - $meta = htmlspecialchars(TZ_MILESTONE_NOT_YET, ENT_QUOTES, 'UTF-8'); - } - ?> -
- - - -
-
- -
-
-
- - - - - diff --git a/Templates/Ranking/milestones.tpl b/Templates/Ranking/milestones.tpl new file mode 100644 index 00000000..dc631fd6 --- /dev/null +++ b/Templates/Ranking/milestones.tpl @@ -0,0 +1,186 @@ +getMilestones() : []; + +// Lightens ($percent > 0) or darkens ($percent < 0) a "#rrggbb" color, used +// to build each badge's radial-gradient inline (kept as plain computed hex +// stops rather than CSS color-mix()/custom properties, for broader browser +// compatibility with this project's existing baseline). +function tzms_shade($hex, $percent) { + $hex = ltrim($hex, '#'); + $r = hexdec(substr($hex, 0, 2)); + $g = hexdec(substr($hex, 2, 2)); + $b = hexdec(substr($hex, 4, 2)); + $adjust = function ($c) use ($percent) { + $c = $percent < 0 ? $c * (1 + $percent / 100) : $c + (255 - $c) * ($percent / 100); + return max(0, min(255, (int) round($c))); + }; + return sprintf('#%02x%02x%02x', $adjust($r), $adjust($g), $adjust($b)); +} + +// Simple line-icon set (inline SVG, no external image files, so there's +// nothing that can 404 regardless of where this is deployed). +$milestoneIcons = [ + 'village' => '', + 'population' => '', + 'artifact' => '', + 'wonder' => '', + 'plan' => '', + 'alliance' => '', + 'conquest' => '', + 'five_villages' => '', +]; + +$milestoneDefs = [ + 'second_village' => ['label' => TZ_MILESTONE_SECOND_VILLAGE, 'icon' => 'village', 'color' => '#c0783c'], + 'population_1000' => ['label' => TZ_MILESTONE_POPULATION_1000, 'icon' => 'population', 'color' => '#3c78c0'], + 'first_artifact' => ['label' => TZ_MILESTONE_FIRST_ARTIFACT, 'icon' => 'artifact', 'color' => '#8a4fc0'], + 'first_ww' => ['label' => TZ_MILESTONE_FIRST_WW, 'icon' => 'wonder', 'color' => '#c0a030'], + 'first_ww_plan' => ['label' => TZ_MILESTONE_FIRST_WW_PLAN, 'icon' => 'plan', 'color' => '#2f9e8f'], + 'first_alliance' => ['label' => TZ_MILESTONE_FIRST_ALLIANCE, 'icon' => 'alliance', 'color' => '#3fa14a'], + 'first_pvp_conquest' => ['label' => TZ_MILESTONE_FIRST_PVP_CONQUEST, 'icon' => 'conquest', 'color' => '#b6362f'], + 'five_villages' => ['label' => TZ_MILESTONE_FIVE_VILLAGES, 'icon' => 'five_villages', 'color' => '#7a6030'], +]; +?> + + + +
+
+
+ $mdef): + $achieved = $milestonesData[$mkey] ?? null; + $light = tzms_shade($mdef['color'], 28); + $dark = tzms_shade($mdef['color'], -32); + $bg = $achieved + ? sprintf('background:radial-gradient(circle at 32%% 28%%, %s, %s 55%%, %s 100%%);border-color:rgba(255,255,255,0.35);', $light, $mdef['color'], $dark) + : 'background:#d8d8d8;border-color:rgba(0,0,0,0.08);'; + $title = htmlspecialchars($mdef['label'], ENT_QUOTES, 'UTF-8'); + + // Caption text under badge: + // - first_alliance shows the alliance name/tag (stored in `extra`) + // - all others show the player username + if ($achieved) { + if ($mkey === 'first_alliance') { + $caption = htmlspecialchars($achieved['extra'] ?: $achieved['username'] ?: '', ENT_QUOTES, 'UTF-8'); + } else { + $caption = htmlspecialchars($achieved['username'] ?: '', ENT_QUOTES, 'UTF-8'); + } + } else { + $caption = ''; + } + + // Tooltip meta line: + // - first_alliance: shows alliance name on first line, founder + date on second + // - all others: "Username — dd.mm.yy H:i:s" + if ($achieved) { + if ($mkey === 'first_alliance') { + $meta = htmlspecialchars( + ($achieved['extra'] ?: '-') . "\n" . + TZ_MILESTONE_FOUNDED_BY . ' ' . ($achieved['username'] ?: '-') . ' — ' . date('d.m.y G:i:s', (int)$achieved['achieved_time']), + ENT_QUOTES, 'UTF-8' + ); + } else { + $meta = htmlspecialchars( + ($achieved['username'] ?: '-') . ' — ' . date('d.m.y G:i:s', (int)$achieved['achieved_time']), + ENT_QUOTES, 'UTF-8' + ); + } + } else { + $meta = htmlspecialchars(TZ_MILESTONE_NOT_YET, ENT_QUOTES, 'UTF-8'); + } + ?> +
+ + + +
+
+ +
+
+
+ + + + + + +
\ No newline at end of file diff --git a/statistiken.php b/statistiken.php index 0e2582e3..b3b54ad3 100644 --- a/statistiken.php +++ b/statistiken.php @@ -82,6 +82,9 @@ if (!empty($_GET['id'])) { case '1': echo PLAYERS; break; + case '3': + echo MILESTONES; + break; } } else { echo PLAYERS; @@ -134,6 +137,9 @@ if (!empty($_GET['id'])) { | > | > | > + + | > +> @@ -153,6 +159,9 @@ if(isset($_GET['id'])) { case 2: include("Templates/Ranking/villages.tpl"); break; + case 3: + include("Templates/Ranking/milestones.tpl"); + break; case 4: include("Templates/Ranking/alliance.tpl"); break;