From dad574be1aced9836728970683c34c08f2a9202d Mon Sep 17 00:00:00 2001 From: Ferywir <65760459+Ferywir@users.noreply.github.com> Date: Tue, 9 Jun 2026 15:47:29 +0200 Subject: [PATCH] feat: reports for settling - new village founded & valley occupied (#178) (#190) --- GameEngine/Automation.php | 8 ++++++ GameEngine/Lang/en.php | 8 ++++++ GameEngine/Lang/fr.php | 4 +++ GameEngine/Lang/it.php | 4 +++ GameEngine/Lang/ro.php | 4 +++ GameEngine/Lang/zh.php | 4 +++ GameEngine/Message.php | 7 +++++- Templates/Notice/24.tpl | 51 +++++++++++++++++++++++++++++++++++++++ Templates/Notice/all.tpl | 12 +++++++++ 9 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 Templates/Notice/24.tpl diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index cc2c2278..0357945b 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -2990,6 +2990,10 @@ class Automation { } $database->setVillageField($data['from'], $exp, $value); + + // Report: new village founded (issue #178) + $ncoor = $database->getCoor($data['to']); + $database->addNotice($to['owner'], $data['to'], 0, 24, 'New village founded', ($ncoor['x'] ?? 0) . ',' . ($ncoor['y'] ?? 0), time()); }else{ // here must come movement from returning settlers $types[] = 4; @@ -2998,6 +3002,10 @@ class Automation { $refs[] = $data['ref']; $times[] = $time; $endtimes[] = $time + ($time - $data['starttime']); + + // Report: valley already occupied, settlers returning (issue #178) + $fcoor = $database->getCoor($data['to']); + $database->addNotice($to['owner'], $data['to'], 0, 25, 'Settlers returned - valley occupied', ($fcoor['x'] ?? 0) . ',' . ($fcoor['y'] ?? 0), time()); } } diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php index 236ee70c..cdcaf143 100755 --- a/GameEngine/Lang/en.php +++ b/GameEngine/Lang/en.php @@ -2333,6 +2333,12 @@ tz_def('TZ_RT_REINF_IN', "Reinforcement in"); tz_def('TZ_RT_ELDERS_REINF', "village of the elders reinforcement"); tz_def('TZ_RT_UNOCC_OASIS', "Unoccupied Oasis"); +// ===== settler reports (issue #178) ===== +tz_def('TZ_RT_NEW_VILLAGE', "New village founded"); +tz_def('TZ_RT_VALLEY_OCCUPIED', "Settling failed (valley occupied)"); +tz_def('TZ_NEW_VILLAGE_MSG', "You have founded a new village:"); +tz_def('TZ_VALLEY_OCCUPIED_MSG', "Your settlers could not settle here - the valley is already occupied by another player. They are on their way back."); + // ===== display-time localization of stored report topics ===== // Reports are generated server-side at battle resolution and stored in the DB // (column `topic`) with English connectors. This rewrites them to the viewing @@ -2350,6 +2356,8 @@ if (!function_exists('tz_loc_topic')) { ' attacks ' => ' '.TZ_RT_ATTACKS.' ', ' reinforcement ' => ' '.TZ_RT_REINFORCEMENT.' ', 'Unoccupied Oasis' => TZ_RT_UNOCC_OASIS, + 'New village founded' => TZ_RT_NEW_VILLAGE, + 'Settlers returned - valley occupied' => TZ_RT_VALLEY_OCCUPIED, ); return strtr($s, $map); } diff --git a/GameEngine/Lang/fr.php b/GameEngine/Lang/fr.php index cd2b792c..5f8a77fa 100644 --- a/GameEngine/Lang/fr.php +++ b/GameEngine/Lang/fr.php @@ -2337,5 +2337,9 @@ define('TZ_RT_WAS_ATTACKED', "a été attaqué"); define('TZ_RT_REINF_IN', "Renfort dans"); define('TZ_RT_ELDERS_REINF', "renfort du village des anciens"); define('TZ_RT_UNOCC_OASIS', "Oasis inoccupée"); +define('TZ_RT_NEW_VILLAGE', "Nouveau village fondé"); +define('TZ_RT_VALLEY_OCCUPIED', "Colonisation échouée (vallée occupée)"); +define('TZ_NEW_VILLAGE_MSG', "Vous avez fondé un nouveau village :"); +define('TZ_VALLEY_OCCUPIED_MSG', "Vos colons n'ont pas pu s'installer ici — la vallée est déjà occupée par un autre joueur. Ils sont sur le chemin du retour."); ?> diff --git a/GameEngine/Lang/it.php b/GameEngine/Lang/it.php index f9cfd77f..0f9ff5fb 100755 --- a/GameEngine/Lang/it.php +++ b/GameEngine/Lang/it.php @@ -2223,5 +2223,9 @@ define('TZ_RT_WAS_ATTACKED', "è stato attaccato"); define('TZ_RT_REINF_IN', "Rinforzo in"); define('TZ_RT_ELDERS_REINF', "rinforzo del villaggio degli anziani"); define('TZ_RT_UNOCC_OASIS', "Oasi non occupata"); +define('TZ_RT_NEW_VILLAGE', "Nuovo villaggio fondato"); +define('TZ_RT_VALLEY_OCCUPIED', "Colonizzazione fallita (valle occupata)"); +define('TZ_NEW_VILLAGE_MSG', "Hai fondato un nuovo villaggio:"); +define('TZ_VALLEY_OCCUPIED_MSG', "I tuoi coloni non hanno potuto insediarsi qui — la valle è già occupata da un altro giocatore. Stanno tornando indietro."); ?> diff --git a/GameEngine/Lang/ro.php b/GameEngine/Lang/ro.php index 095c8ab9..751329af 100644 --- a/GameEngine/Lang/ro.php +++ b/GameEngine/Lang/ro.php @@ -2326,3 +2326,7 @@ define('TZ_RT_WAS_ATTACKED', "a fost atacat"); define('TZ_RT_REINF_IN', "Întărire în"); define('TZ_RT_ELDERS_REINF', "întărire a satului bătrânilor"); define('TZ_RT_UNOCC_OASIS', "Oază neocupată"); +define('TZ_RT_NEW_VILLAGE', "Sat nou întemeiat"); +define('TZ_RT_VALLEY_OCCUPIED', "Colonizare eșuată (vale ocupată)"); +define('TZ_NEW_VILLAGE_MSG', "Ai întemeiat un sat nou:"); +define('TZ_VALLEY_OCCUPIED_MSG', "Coloniștii tăi nu s-au putut stabili aici — valea este deja ocupată de alt jucător. Se întorc acasă."); diff --git a/GameEngine/Lang/zh.php b/GameEngine/Lang/zh.php index 5ecc5d2d..a707cd3a 100644 --- a/GameEngine/Lang/zh.php +++ b/GameEngine/Lang/zh.php @@ -2319,3 +2319,7 @@ define('TZ_RT_WAS_ATTACKED', "遭到攻击"); define('TZ_RT_REINF_IN', "增援于"); define('TZ_RT_ELDERS_REINF', "长老村增援"); define('TZ_RT_UNOCC_OASIS', "无人占领的绿洲"); +define('TZ_RT_NEW_VILLAGE', "已建立新村庄"); +define('TZ_RT_VALLEY_OCCUPIED', "拓殖失败(山谷已被占领)"); +define('TZ_NEW_VILLAGE_MSG', "你已建立一个新村庄:"); +define('TZ_VALLEY_OCCUPIED_MSG', "你的拓荒者无法在此定居——该山谷已被其他玩家占领。他们正在返回途中。"); diff --git a/GameEngine/Message.php b/GameEngine/Message.php index 5567f63f..d2f6a9b7 100755 --- a/GameEngine/Message.php +++ b/GameEngine/Message.php @@ -130,7 +130,7 @@ class Message $type = [1, 2, 3, 4, 5, 6, 7]; break; case 4: - $type = [0, 18, 19, 20, 21]; + $type = [0, 18, 19, 20, 21, 24, 25]; break; case 5: if (!$session->plus) { @@ -442,6 +442,11 @@ class Message // Festive reports case 23: return 22; + + // Settler reports: new village founded / valley occupied (issue #178) + case 24: + case 25: + return 24; } return $type; } diff --git a/Templates/Notice/24.tpl b/Templates/Notice/24.tpl new file mode 100644 index 00000000..bceba800 --- /dev/null +++ b/Templates/Notice/24.tpl @@ -0,0 +1,51 @@ +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 = '(' . $x . '|' . $y . ')'; +?> + + + + + + + + + + + procMtime($message->readingNotice['time']); ?> + + + + + + + + + + +
:readingNotice['topic']); ?>
+ +getVillageField($wref, 'name'), ENT_QUOTES, 'UTF-8'); + echo TZ_NEW_VILLAGE_MSG . ' ' . $vname . ' ' . $coordLink; +} +?> + +
diff --git a/Templates/Notice/all.tpl b/Templates/Notice/all.tpl index 00f6bc1b..a0b97bd7 100644 --- a/Templates/Notice/all.tpl +++ b/Templates/Notice/all.tpl @@ -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 "\"".$noticeClass[$type]."\""; + } else { echo "