From eee3d6f355f04f6e754221d9a9cc709fdb869782 Mon Sep 17 00:00:00 2001 From: Ferywir <65760459+Ferywir@users.noreply.github.com> Date: Wed, 1 Jul 2026 15:13:57 +0200 Subject: [PATCH] fix(combat): match building type by 't' suffix in Battle::getTypeLevel [#294] (#323) --- GameEngine/Battle.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/GameEngine/Battle.php b/GameEngine/Battle.php index f4394c8d..fa994310 100644 --- a/GameEngine/Battle.php +++ b/GameEngine/Battle.php @@ -390,15 +390,19 @@ class Battle { ******************************************************************/ foreach ($resourcearray as $key => $value) { - // faster than array_keys + strpos + preg_replace + // The building TYPE is stored in the 'ft' columns of fdata (e.g. the + // Brewery on slot 20 is 'f20t' == 35); the matching level lives in 'f'. + // Match on the 't' SUFFIX, not the first character — a previous rewrite + // tested $key[0] === 't', which never matched 'ft' and made this + // return 0 for every building (issue #294: Brewery bonus never applied). + // Mirrors Building::getTypeLevel()/Automation::getTypeLevel(). if ( isset($value) && $value == $tid - && isset($key[0]) - && $key[0] === 't' + && strpos($key, 't') !== false ) { - $keyholder[] = (int)substr($key, 1); + $keyholder[] = (int)preg_replace('/[^0-9]/', '', $key); } } $element = count($keyholder);