From a787929604b040b0215771b666a748ad5fa51a30 Mon Sep 17 00:00:00 2001 From: Ferywir <65760459+Ferywir@users.noreply.github.com> Date: Mon, 8 Jun 2026 05:45:51 +0200 Subject: [PATCH] Refactor(sendunitsComplete): wire up buildScoutReport(), drop duplicate [#155] (#183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #182 merge resolution left buildScoutReport() defined but never called, while the original inline scout-report block was kept at the call site — so the method was dead code and the scout-report logic was duplicated. This wires it up: the inline block in the `if (!empty($scout))` branch is replaced by a single `$info_spy = $this->buildScoutReport(...)` call. The method already exists and its body is identical to the removed inline block, so behaviour is unchanged — this just removes the duplication and makes the extraction actually take effect. Brace balance even (634/634). Co-authored-by: TravianZ Patcher Co-authored-by: Claude Opus 4.8 --- GameEngine/Automation.php | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 714afa6e..cc2c2278 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -2349,31 +2349,7 @@ class Automation { if ($DefenderID == 0) $natar = 0; if(!empty($scout)) { - if ($data['spy'] == 1){ - $info_spy = "".$spy_pic.",
\"Lumber\"".round($totwood)." | - \"Clay\"".round($totclay)." | - \"Iron\"".round($totiron)." | - \"Crop\"".round($totcrop)."
-
\"carry\"Total Resources: ".round($totwood+$totclay+$totiron+$totcrop)."
- "; - }else if($data['spy'] == 2){ - if ($isoasis == 0){ - $walllevel = $database->getFieldLevelInVillage($data['to'], '31, 32, 33'); - $residencelevel = $database->getFieldLevelInVillage($data['to'], 25); - $palacelevel = $database->getFieldLevelInVillage($data['to'], 26); - $residenceimg = "\"Residence\""; - $palaceimg = "\"Palace\""; - $crannyimg = "\"Cranny\""; - $wallimg = "\"Wall\""; - $info_spy = "".$spy_pic.","; - if($residencelevel > 0) $info_spy .= $residenceimg." Residence level:".$residencelevel."
"; - elseif($palacelevel > 0) $info_spy .= $palaceimg." Palace level: ".$palacelevel."
"; - - if($walllevel > 0) $info_spy .= $wallimg." Wall level: ".$walllevel."
"; - $info_spy .= $crannyimg." Total crannies capacity: ".$crannySpy.""; - } - else $info_spy = "".$spy_pic.", There are no informations to show"; - } + $info_spy = $this->buildScoutReport($data, $spy_pic, $isoasis, $targettribe, $crannySpy, $totwood, $totclay, $totiron, $totcrop); $data2 = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.',0,0,0,0,0,'.$to['owner'].','.$to['wref'].','.addslashes($to['name']).',,,,'.$targettribe.','.$unitssend_def[0].','.$unitsdead_def[0].','.$rom.','.$unitssend_def[1].','.$unitsdead_def[1].','.$ger.','.$unitssend_def[2].','.$unitsdead_def[2].','.$gal.','.$unitssend_def[3].','.$unitsdead_def[3].','.$nat.','.$unitssend_def[4].','.$unitsdead_def[4].','.$natar.','.$unitssend_def[5].','.$unitsdead_def[5].','.$DefenderHeroesTot.','.$DefenderHeroesDead.','.$info_ram.','.$info_cat.','.$info_chief.','.$info_spy.','.$data['t11'].','.$dead11.','.$herosend_def.','.$deadhero.',,'.$unitstraped_att; }else{ @@ -4522,4 +4498,4 @@ $automation = new Automation; // remove automation lock file @unlink( AUTOMATION_LOCK_FILE_NAME ); -?> \ No newline at end of file +?>