feat: reports for settling - new village founded & valley occupied (#178) (#190)

This commit is contained in:
Ferywir
2026-06-09 15:47:29 +02:00
committed by GitHub
parent 20804d9182
commit dad574be1a
9 changed files with 101 additions and 1 deletions
+51
View File
@@ -0,0 +1,51 @@
<?php
#################################################################################
# Settler reports (24.tpl) - issue #178
# Handles ntype 24 (new village founded) and ntype 25 (valley occupied).
# Title is stored in English and localized at display via tz_loc_topic().
# Body is built from localized constants + coordinates stored in `data`.
#################################################################################
$ntype = (int)($message->readingNotice['ntype'] ?? 24);
$coords = explode(',', (string)($message->readingNotice['data'] ?? ''));
$x = (int)($coords[0] ?? 0);
$y = (int)($coords[1] ?? 0);
$wref = (int)($message->readingNotice['toWref'] ?? 0);
$mapCheck = $generator->getMapCheck($wref);
$coordLink = '<a href="karte.php?d=' . $wref . '&c=' . $mapCheck . '">(' . $x . '|' . $y . ')</a>';
?>
<table cellpadding="1" cellspacing="1" id="report_surround">
<thead>
<tr>
<th><?php echo SUBJECT; ?>:</th>
<th><?php echo tz_loc_topic($message->readingNotice['topic']); ?></th>
</tr>
<tr>
<?php $date = $generator->procMtime($message->readingNotice['time']); ?>
<td class="sent"><?php echo TZ_SENT; ?></td>
<td><?php echo ON; ?> <span><?php echo $date[0] . " " . $date[1]; ?></span></td>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<?php
if ($ntype == 25) {
// Settlers could not settle - the valley is already occupied
echo TZ_VALLEY_OCCUPIED_MSG . ' ' . $coordLink;
} else {
// New village founded
$vname = htmlspecialchars((string)$database->getVillageField($wref, 'name'), ENT_QUOTES, 'UTF-8');
echo TZ_NEW_VILLAGE_MSG . ' <b>' . $vname . '</b> ' . $coordLink;
}
?>
</td></tr>
</tbody>
</table>
+12
View File
@@ -35,6 +35,10 @@ $noticeClass = [
TZ_RPT_SCOUT
];
// Settler reports (issue #178) - sparse indices 24/25
$noticeClass[24] = TZ_RT_NEW_VILLAGE;
$noticeClass[25] = TZ_RT_VALLEY_OCCUPIED;
// ======================== GOLD CHECK (cached query) ========================
$uid = (int)$session->uid;
@@ -178,6 +182,14 @@ for ($i = (1 + $s); $i <= (10 + $s); $i++) {
alt=\"".$noticeClass[$type]."\"
title=\"".$noticeClass[$type]."\" />";
} elseif ($type == 24 || $type == 25) {
// Settler reports (issue #178): no dedicated gpack icon, reuse an existing one
$iconType = ($type == 24) ? 8 : 3;
echo "<img src=\"img/x.gif\" class=\"iReport iReport".$iconType."\"
alt=\"".$noticeClass[$type]."\"
title=\"".$noticeClass[$type]."\" />";
} else {
echo "<img src=\"img/x.gif\" class=\"iReport iReport".$type."\"