From b79ee6185525fe67b540777f7694435d4e2410db Mon Sep 17 00:00:00 2001 From: novgorodschi catalin Date: Tue, 4 Aug 2026 11:05:54 +0300 Subject: [PATCH] Fix max donation Alliance Bonuses Fix max donation Alliance Bonuses - cannot donate over max --- GameEngine/AllianceBonus.php | 35 +++++++++++++++++++++++++++++++++- GameEngine/Lang/en.php | 5 +++++ GameEngine/Lang/fr.php | 5 +++++ GameEngine/Lang/ro.php | 5 +++++ Templates/Alliance/bonuses.tpl | 10 ++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/GameEngine/AllianceBonus.php b/GameEngine/AllianceBonus.php index b054ef88..f3aecac4 100644 --- a/GameEngine/AllianceBonus.php +++ b/GameEngine/AllianceBonus.php @@ -49,6 +49,11 @@ class AllianceBonus const DONATE_RESOURCES = 5; const DONATE_INVALID = 6; const DONATE_NO_GOLD = 7; + /** Ultimul nivel: s-a donat mai mult decat mai era nevoie. */ + const DONATE_OVER_MAX = 8; + + /** Cat se putea dona de fapt; citit de interfata cand primeste DONATE_OVER_MAX. */ + public static $overMaxAllowed = 0; private $db; @@ -442,8 +447,36 @@ class AllianceBonus return self::DONATE_INVALID; } - // valoarea contorizata (triplata sau nu) si plafonul zilnic + // valoarea contorizata (triplata sau nu) $counted = $triple ? $total * 3 : $total; + + /** + * ULTIMUL NIVEL: nu se accepta mai mult decat mai e nevoie. + * + * La nivelurile intermediare surplusul e util - ramane in fond si + * finanteaza nivelul urmator. Dar la trecerea spre nivelul MAXIM nu mai + * exista nivel urmator: ce depaseste costul ar ramane blocat in fond + * pentru totdeauna, fara sa mai poata fi folosit sau recuperat. + * + * Asa ca aici oprim donatia si spunem exact cat se poate dona. Nu + * plafonam automat: jucatorul ar plati fara sa stie cat, iar cu triplare + * diferenta ar fi si mai greu de urmarit. + */ + if ($state[$btype]['level'] === self::MAX_LEVEL - 1) { + + $needed = self::costFor($state[$btype]['level']) - (float) $state[$btype]['pool']; + $needed = max(0, $needed); + + if ($counted > $needed) { + // cat trebuie sa introduca in casute (inainte de triplare) + self::$overMaxAllowed = $triple + ? (float) floor($needed / 3) + : $needed; + + return self::DONATE_OVER_MAX; + } + } + $limit = self::dailyLimit($this->highestLevel($aid)); $already = $this->donatedToday($uid); diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php index b67c20ec..e88c3728 100755 --- a/GameEngine/Lang/en.php +++ b/GameEngine/Lang/en.php @@ -4355,3 +4355,8 @@ tz_def('ADM_WW_IMAGE_TIP', 'Each tribe sees its own World Wonder artwork, both o // MINUNEA LUMII - satul nu poate fi capitala ////////////////////////////////////////////////////////////////////////////////////////////////////// tz_def('TZ_WW_NO_CAPITAL', 'The World Wonder village cannot become your capital.'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// BONUSURI DE ALIANTA - donatie peste necesarul ultimului nivel +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('ALLYBONUS_MSG_OVERMAX', 'This is the final level: you can donate at most %s more resources.'); diff --git a/GameEngine/Lang/fr.php b/GameEngine/Lang/fr.php index 75635cb0..7bdab332 100644 --- a/GameEngine/Lang/fr.php +++ b/GameEngine/Lang/fr.php @@ -4298,3 +4298,8 @@ tz_def('ADM_WW_IMAGE_TIP', 'Chaque tribu voit sa propre Merveille du Monde, sur // MINUNEA LUMII - satul nu poate fi capitala ////////////////////////////////////////////////////////////////////////////////////////////////////// tz_def('TZ_WW_NO_CAPITAL', 'Le village de la Merveille du Monde ne peut pas devenir votre capitale.'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// BONUSURI DE ALIANTA - donatie peste necesarul ultimului nivel +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('ALLYBONUS_MSG_OVERMAX', 'Ceci est le dernier niveau : vous pouvez donner au maximum %s ressources supplementaires.'); diff --git a/GameEngine/Lang/ro.php b/GameEngine/Lang/ro.php index 7a8cd220..375e3588 100644 --- a/GameEngine/Lang/ro.php +++ b/GameEngine/Lang/ro.php @@ -4095,3 +4095,8 @@ tz_def('ADM_WW_IMAGE_TIP', 'Fiecare trib isi vede propria Minune a Lumii, atat p // MINUNEA LUMII - satul nu poate fi capitala ////////////////////////////////////////////////////////////////////////////////////////////////////// tz_def('TZ_WW_NO_CAPITAL', 'Satul Minunii Lumii nu poate deveni capitala.'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// BONUSURI DE ALIANTA - donatie peste necesarul ultimului nivel +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('ALLYBONUS_MSG_OVERMAX', 'Acesta e ultimul nivel: poti dona cel mult %s resurse.'); diff --git a/Templates/Alliance/bonuses.tpl b/Templates/Alliance/bonuses.tpl index c5ec9fe9..2c3010e0 100644 --- a/Templates/Alliance/bonuses.tpl +++ b/Templates/Alliance/bonuses.tpl @@ -71,6 +71,16 @@ if (isset($_POST['ab_donate'])) { : 'Not enough resources in this village.'; $abError = true; break; + case AllianceBonus::DONATE_OVER_MAX: + // La ultimul nivel surplusul ar ramane blocat, deci spunem exact + // cat se mai poate dona. + $abMessage = sprintf( + defined('ALLYBONUS_MSG_OVERMAX') ? ALLYBONUS_MSG_OVERMAX + : 'This is the final level: you can donate at most %s more resources.', + number_format(AllianceBonus::$overMaxAllowed) + ); + $abError = true; + break; case AllianceBonus::DONATE_NO_GOLD: $abMessage = defined('ALLYBONUS_MSG_NOGOLD') ? ALLYBONUS_MSG_NOGOLD : 'Not enough gold to triple this donation.';