mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
Phase B — pure behaviour-preserving extraction (issue #155). buildScoutReport(): extracts the scout-report (info_spy) HTML assembly (~25 lines) into a helper returning the info_spy string. Handles both spy modes: resources (spy=1) and defence/buildings (spy=2). The block's body is moved verbatim (multi-line strings with their exact embedded whitespace preserved). The reassigned $walllevel/$residencelevel/ $palacelevel were local to this block and never read downstream. No logic change. Co-authored-by: TravianZ Patcher <patcher@localhost> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Catalin Novgorodschi <cata7007@gmail.com>
This commit is contained in:
+30
-25
@@ -1228,6 +1228,35 @@ class Automation {
|
||||
$database->getABTech($vilIDs);
|
||||
}
|
||||
|
||||
private function buildScoutReport($data, $spy_pic, $isoasis, $targettribe, $crannySpy, $totwood, $totclay, $totiron, $totcrop) {
|
||||
global $database;
|
||||
$info_spy = "";
|
||||
if ($data['spy'] == 1){
|
||||
$info_spy = "".$spy_pic.",<div class=\"res\"><img class=\"r1\" src=\"img/x.gif\" alt=\"Lumber\" title=\"Lumber\" />".round($totwood)." |
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".round($totclay)." |
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".round($totiron)." |
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".round($totcrop)."</div>
|
||||
<div class=\"carry\"><img class=\"car\" src=\"img/x.gif\" alt=\"carry\" title=\"carry\" />Total Resources: ".round($totwood+$totclay+$totiron+$totcrop)."</div>
|
||||
";
|
||||
}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 = "<img src=\"".GP_LOCATE."img/g/g25.gif\" height=\"20\" width=\"15\" alt=\"Residence\" title=\"Residence\" />";
|
||||
$palaceimg = "<img src=\"".GP_LOCATE."img/g/g26.gif\" height=\"20\" width=\"15\" alt=\"Palace\" title=\"Palace\" />";
|
||||
$crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\" alt=\"Cranny\" title=\"Cranny\" />";
|
||||
$wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"20\" width=\"15\" alt=\"Wall\" title=\"Wall\" />";
|
||||
$info_spy = "".$spy_pic.",";
|
||||
if($residencelevel > 0) $info_spy .= $residenceimg." Residence level:<b>".$residencelevel."</b><br />";
|
||||
elseif($palacelevel > 0) $info_spy .= $palaceimg." Palace level: <b>".$palacelevel."</b><br />";
|
||||
|
||||
if($walllevel > 0) $info_spy .= $wallimg." Wall level: <b>".$walllevel."</b><br />";
|
||||
$info_spy .= $crannyimg." Total crannies capacity: <b>".$crannySpy."</b>";
|
||||
}
|
||||
else $info_spy = "".$spy_pic.", There are no informations to show";
|
||||
}
|
||||
return $info_spy;
|
||||
/**
|
||||
* Distribute the battle bounty across the resources actually available in
|
||||
* the target (after cranny protection) and return how much of each is taken.
|
||||
@@ -2318,31 +2347,7 @@ class Automation {
|
||||
if ($DefenderID == 0) $natar = 0;
|
||||
|
||||
if(!empty($scout)) {
|
||||
if ($data['spy'] == 1){
|
||||
$info_spy = "".$spy_pic.",<div class=\"res\"><img class=\"r1\" src=\"img/x.gif\" alt=\"Lumber\" title=\"Lumber\" />".round($totwood)." |
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".round($totclay)." |
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".round($totiron)." |
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".round($totcrop)."</div>
|
||||
<div class=\"carry\"><img class=\"car\" src=\"img/x.gif\" alt=\"carry\" title=\"carry\" />Total Resources: ".round($totwood+$totclay+$totiron+$totcrop)."</div>
|
||||
";
|
||||
}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 = "<img src=\"".GP_LOCATE."img/g/g25.gif\" height=\"20\" width=\"15\" alt=\"Residence\" title=\"Residence\" />";
|
||||
$palaceimg = "<img src=\"".GP_LOCATE."img/g/g26.gif\" height=\"20\" width=\"15\" alt=\"Palace\" title=\"Palace\" />";
|
||||
$crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\" alt=\"Cranny\" title=\"Cranny\" />";
|
||||
$wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"20\" width=\"15\" alt=\"Wall\" title=\"Wall\" />";
|
||||
$info_spy = "".$spy_pic.",";
|
||||
if($residencelevel > 0) $info_spy .= $residenceimg." Residence level:<b>".$residencelevel."</b><br />";
|
||||
elseif($palacelevel > 0) $info_spy .= $palaceimg." Palace level: <b>".$palacelevel."</b><br />";
|
||||
|
||||
if($walllevel > 0) $info_spy .= $wallimg." Wall level: <b>".$walllevel."</b><br />";
|
||||
$info_spy .= $crannyimg." Total crannies capacity: <b>".$crannySpy."</b>";
|
||||
}
|
||||
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{
|
||||
|
||||
Reference in New Issue
Block a user