Reports refactor Part 2

+Heroes are now divided by tribes in battle reports
+Added to every report the support to read heroes from the battle report
data

Automation.php:
+Added the hero data, to every battle reports
+Fixed a bug that didn't count own dead defensive troops for general
attacks, top 10 attackers, attackers and hero xp
+Fixed a bug that didn't permit to add the rat enforcement to the
village, from quest number 8

Battle.php:
+Fixed a bug with catapults/rams that permitted to destroy level 1
buildings with only one catapults (even against 1000000 defensive
troops)
+Added a new function, for more readability

+General minor improovementes and bug fixing
This commit is contained in:
iopietro
2018-04-20 21:23:57 +02:00
parent 882215cd2a
commit c2f4d43b7e
7 changed files with 226 additions and 227 deletions
+1 -1
View File
@@ -537,7 +537,7 @@ if ($ironL<2 || $clayL<2 || $woodL<2 || $cropL<2){?>
<?php } elseif($_SESSION['qst']== 10){
//comming soon
//Check rat is in villa
$rat = $database->getEnforce(0, $village->wid);
$rat = $database->getEnforce($village->wid, 0);
if ($rat['u31'] < 1){?>
{"markup":"\n\t\t<div id=\"qstd\"><h1> <img class=\"point\" src=\"img\/x.gif\" alt=\"\" title=\"\"\/> <?php echo Q25_10; ?><\/h1><br \/><i>&rdquo;<?php echo Q25_10_DESC; ?>&rdquo;<\/i><br \/><br \/><div class=\"rew\"><p class=\"ta_aw\"><?php echo Q25_10_ORDER; ?><\/div><br \/><span id=\"qst_accpt\"><\/span><\/div>\n\t\t<div id=\"qstbg\" class=\"army\"><\/div>\n\t\t","number":-10,"reward":false,"qgsrc":"q_l<?php echo $session->userinfo['tribe'];?>","msrc":"<?php echo $messagelol; ?>","altstep":99}
<?php $_SESSION['qstnew']='0'; }else{ $_SESSION['qstnew']='1'; ?>
+1 -1
View File
@@ -101,7 +101,7 @@ if ($units[$y]['sort_type']==3){
<td colspan=\"10\">";
echo "<a>".VILLAGE_OF_THE_ELDERS_TROOPS."</a>";
echo "</td></tr></thead><tbody class=\"units\">";
$tribe = $session->tribe;
$tribe = 4;
$start = ($tribe-1)*10+1;
$end = ($tribe*10);
echo "<tr><th>&nbsp;</th>";
+43 -42
View File
@@ -1,8 +1,7 @@
<?php
$dataarray = explode(",",$message->readingNotice['data']);
$colspan = (isset($dataarray[168]) && $dataarray[168] > 0) ? 11 : 10;
$colspan2 = (isset($dataarray[170]) && $dataarray[170] > 0) ? 11 : 10;
$spy = !empty($dataarray[167]) && !empty($dataarray[166]) && empty($dataarray[185]);
$colspan = (isset($dataarray[178]) && $dataarray[178] > 0) ? 11 : 10;
$spy = !empty($dataarray[177]) && !empty($dataarray[176]) && empty($dataarray[195]);
//Attacker
if ($database->getUserField($dataarray[0], 'username', 0) != "[?]") {
@@ -62,7 +61,7 @@ $start = ($tribe - 1) * 10 + 1;
for($i = $start; $i <= ($start + 9); $i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
if (isset($dataarray[168]) && $dataarray[168] > 0){
if (isset($dataarray[178]) && $dataarray[178] > 0){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
echo "</tr><tr><th>Troops</th>";
@@ -72,8 +71,8 @@ for($i = 3; $i <= 12; $i++) {
else echo "<td>".$dataarray[$i]."</td>";
}
if (isset($dataarray[168]) && $dataarray[168] > 0){
echo "<td>$dataarray[168]</td>";
if (isset($dataarray[178]) && $dataarray[178] > 0){
echo "<td>$dataarray[178]</td>";
}
echo "<tr><th>Casualties</th>";
@@ -82,88 +81,90 @@ for($i = 13; $i <= 22; $i++) {
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[168]) && $dataarray[168] > 0){
if ($dataarray[169] == 0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[169]</td>";
if(isset($dataarray[178]) && $dataarray[178] > 0){
if ($dataarray[179] == 0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[179]</td>";
}
if(!$spy && ($dataarray[172] > 0 || $dataarray[173] > 0 || $dataarray[174] > 0 || $dataarray[175] > 0 || $dataarray[176] > 0 || $dataarray[177] > 0 || $dataarray[178] > 0 || $dataarray[179] > 0 || $dataarray[180] > 0 || $dataarray[181] > 0 || $dataarray[182] > 0)){
if(!$spy && array_sum(array_slice($dataarray, 182, 11)) > 0){
echo "</tr><tr><th>Prisoners</th>";
for($i = 172; $i <= 181; $i++) {
for($i = 182; $i <= 191; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[168]) && $dataarray[168] > 0){
if ($dataarray[182] == 0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[182]</td>";
if(isset($dataarray[178]) && $dataarray[178] > 0){
if ($dataarray[192] == 0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[192]</td>";
}
}
echo "</tr></tbody>";
if (!empty($dataarray[160]) && !empty($dataarray[161])){ //ram
if (!empty($dataarray[170]) && !empty($dataarray[171])){ //ram
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[160]; ?>" src="img/x.gif" alt="Ram" title="Ram" />
<?php echo $dataarray[161]; ?>
<img class="unit u<?php echo $dataarray[170]; ?>" src="img/x.gif" alt="Ram" title="Ram" />
<?php echo $dataarray[171]; ?>
</td></tr></tbody>
<?php }
if (!empty($dataarray[162]) && !empty($dataarray[163])){ //cata
if (!empty($dataarray[172]) && !empty($dataarray[173])){ //cata
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[162]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" />
<?php echo $dataarray[163]; ?>
<img class="unit u<?php echo $dataarray[172]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" />
<?php echo $dataarray[173]; ?>
</td></tr></tbody>
<?php }
if (!empty($dataarray[164]) && !empty($dataarray[165])){ //chief
if (!empty($dataarray[174]) && !empty($dataarray[175])){ //chief
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[164]; ?>" src="img/x.gif" alt="Chief" title="Chief" />
<?php echo $dataarray[165]; ?>
<img class="unit u<?php echo $dataarray[174]; ?>" src="img/x.gif" alt="Chief" title="Chief" />
<?php echo $dataarray[175]; ?>
</td></tr></tbody>
<?php }
if ($spy){ //spy
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<?php echo $dataarray[167]; ?>
<?php echo $dataarray[177]; ?>
</td></tr></tbody>
<?php }
if (!empty($dataarray[183])){ //release prisoners
if (!empty($dataarray[193])){ //release prisoners
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<?php echo $dataarray[183]; ?>
<?php echo $dataarray[193]; ?>
</td></tr></tbody>
<?php }
if (!empty($dataarray[186]) && !empty($dataarray[187])){ //hero
if (!empty($dataarray[196]) && !empty($dataarray[197])){ //hero
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[186]; ?>" src="img/x.gif" alt="Hero" title="Hero" />
<?php echo $dataarray[187]; ?>
<img class="unit u<?php echo $dataarray[196]; ?>" src="img/x.gif" alt="Hero" title="Hero" />
<?php echo $dataarray[197]; ?>
</td></tr></tbody>
<?php }
if(isset($dataarray[185]) && !empty($dataarray[185])){ //No troops returned
if(isset($dataarray[195]) && !empty($dataarray[195])){ //No troops returned
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<?php echo $dataarray[185]; ?>
<?php echo $dataarray[195]; ?>
</td></tr></tbody>
<?php }elseif(empty($dataarray[166]) && empty($dataarray[167])){?>
<?php }elseif(empty($dataarray[176]) && empty($dataarray[177])){?>
<tbody class="goods"><tr><th>Bounty</th><td colspan="<?php echo $colspan; ?>">
<div class="res"><img class="r1" src="img/x.gif" alt="Lumber" title="Lumber" /><?php echo $dataarray[23]; ?> | <img class="r2" src="img/x.gif" alt="Clay" title="Clay" /><?php echo $dataarray[24]; ?> | <img class="r3" src="img/x.gif" alt="Iron" title="Iron" /><?php echo $dataarray[25]; ?> | <img class="r4" src="img/x.gif" alt="Crop" title="Crop" /><?php echo $dataarray[26]; ?></div><div class="carry"><img class="car" src="img/x.gif" alt="carry" title="carry" /><?php echo ($dataarray[23]+$dataarray[24]+$dataarray[25]+$dataarray[26])."/".$dataarray[27]; ?></div>
</td></tr></tbody></table>
<?php } //Defender(s)
$defArray = [1, $dataarray[55], $dataarray[76], $dataarray[97], $dataarray[118], $dataarray[139]];
$targetTribe = $dataarray[33];
$targetTribe = $dataarray[34];
foreach($defArray as $index => $value){
if($value == 0) continue;
$heroIndex = ($index == 0 ? 180 : 160 + ($index - 1));
$heroDeadIndex = ($index == 0 ? 1 : 5);
$target = ($index == 0 ? $targetTribe : $index) - 1;
$start = $target * 10 + 1;
$troopsStart = $index * 21 + 35 - ($index == 0 ? 1 : 0);
$troopsStart = $index * 21 + 35;
?>
<table cellpadding="1" cellspacing="1" class="defender">
<thead>
<tr>
<td class="role">Defender</td>
<td colspan="<?php echo $colspan2; ?>"><?php echo ($index == 0) ? $defuser_url." from the village ".$deffrom_url : "Reinforcement"; ?></td>
<td colspan="<?php echo $dataarray[$heroIndex] > 0 ? 11 : 10; ?>"><?php echo ($index == 0) ? $defuser_url." from the village ".$deffrom_url : "Reinforcement"; ?></td>
</tr></thead>
<tbody class="units">
<tr>
@@ -173,7 +174,7 @@ foreach($defArray as $index => $value){
for($i = $start; $i <= ($start + 9); $i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
if(isset($dataarray[170]) && $dataarray[170] > 0){
if(isset($dataarray[$heroIndex]) && $dataarray[$heroIndex] > 0){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
echo "</tr><tr><th>Troops</th>";
@@ -183,8 +184,8 @@ for($i = $troopsStart; $i <= $troopsStart + 9; $i++) {
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[170]) && $dataarray[170] > 0){
echo "<td>$dataarray[170]</td>";
if(isset($dataarray[$heroIndex]) && $dataarray[$heroIndex] > 0){
echo "<td>".$dataarray[$heroIndex]."</td>";
}
echo "<tr><th>Casualties</th>";
@@ -193,9 +194,9 @@ for($i = $troopsStart + 10; $i <= $troopsStart + 19; $i++) {
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[170]) && $dataarray[170] > 0){
if ($dataarray[171] == 0){$tdclass1='class="none"';}
echo "<td $tdclass1>$dataarray[171]</td>";
if(isset($dataarray[$heroIndex]) && $dataarray[$heroIndex] > 0){
if ($dataarray[$heroIndex + $heroDeadIndex] == 0) $tdclass1 = 'class="none"';
echo "<td $tdclass1>".$dataarray[$heroIndex + $heroDeadIndex]."</td>";
}
}
?>
+4 -4
View File
@@ -1,7 +1,7 @@
<?php
//reinforcement is underattack
$dataarray = explode(",",$message->readingNotice['data']);
$colspan = (isset($dataarray[24]) && $dataarray[24] > 0) ? 10 : 11;
$colspan = (isset($dataarray[24]) && $dataarray[24] > 0) ? 11 : 10;
if ($database->getUserField($dataarray[0], 'username', 0) != "[?]") {
$user_url = "<a href=\"spieler.php?uid=".$database->getUserField($dataarray[0], 'id', 0)."\">".$database->getUserField($dataarray[0], 'username', 0)."</a>";
}
@@ -46,23 +46,23 @@ for($i = $start; $i <= ($start + 9); $i++) {
if(isset($dataarray[24]) && $dataarray[24] > 0){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
echo "</tr><tr><th>Troops</th>";
echo "</tr><tr><th>Troops</th>";
for($i = 4; $i <= 13; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[24]) && $dataarray[24] > 0){
echo "<td>$dataarray[24]</td>";
}
echo "<tr><th>Casualties</th>";
for($i = 14; $i <= 23; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[24]) && $dataarray[24] > 0){
if ($dataarray[25] == 0){$tdclass = 'class="none"';}
if ($dataarray[25] == 0) $tdclass = 'class="none"';
echo "<td $tdclass>$dataarray[25]</td>";
}
?>
+27 -27
View File
@@ -6,7 +6,7 @@
## TRAVIANZ ##
############################################################
$dataarray = explode(",",$message->readingNotice['data']);
$colspan = (isset($dataarray[173]) && $dataarray[173] > 0) ? 11 : 10;
$colspan = (isset($dataarray[184]) && $dataarray[184] > 0) ? 11 : 10;
$colspan2 = 10;
//Attacker
@@ -66,7 +66,7 @@ $start = ($tribe - 1) * 10 + 1;
for($i = $start; $i <= ($start + 9); $i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
if(isset($dataarray[173]) && $dataarray[173] > 0){
if(isset($dataarray[184]) && $dataarray[184] > 0){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
echo "</tr><tr><th>Troops</th>";
@@ -76,70 +76,70 @@ for($i = 3; $i <= 12; $i++) {
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[173]) && $dataarray[173] > 0){
echo "<td>$dataarray[173]</td>";
if(isset($dataarray[184]) && $dataarray[184] > 0){
echo "<td>$dataarray[184]</td>";
}
echo "<tr><th>Casualties</th>";
for($i = 13; $i <= 22; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[173]) && $dataarray[173] > 0){
if ($dataarray[174] == 0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[174]</td>";
if(isset($dataarray[184]) && $dataarray[184] > 0){
if ($dataarray[185] == 0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[185]</td>";
}
if($dataarray[175] > 0 || $dataarray[176] > 0 || $dataarray[177] > 0 || $dataarray[178] > 0 || $dataarray[179] > 0 || $dataarray[180] > 0 || $dataarray[181] > 0 || $dataarray[182] > 0 || $dataarray[183] > 0 || $dataarray[184] > 0 || $dataarray[185] > 0){
if(array_sum(array_slice($dataarray, 186, 11)) > 0){
echo "</tr><tr><th>Prisoners</th>";
for($i = 175; $i <= 184; $i++) {
for($i = 186; $i <= 195; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[173]) && $dataarray[173] > 0){
if ($dataarray[185]==0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[185]</td>";
if(isset($dataarray[184]) && $dataarray[184] > 0){
if ($dataarray[196] == 0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[196]</td>";
}
}
if (!empty($dataarray[187]) && !empty($dataarray[188])){ //ram
if (!empty($dataarray[198]) && !empty($dataarray[199])){ //ram
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[187]; ?>" src="img/x.gif" alt="Ram" title="Ram" />
<?php echo $dataarray[188]; ?>
<img class="unit u<?php echo $dataarray[198]; ?>" src="img/x.gif" alt="Ram" title="Ram" />
<?php echo $dataarray[199]; ?>
</td></tr></tbody>
<?php }
if (!empty($dataarray[189]) && !empty($dataarray[190])){ //cata
if (!empty($dataarray[200]) && !empty($dataarray[201])){ //cata
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[189]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" />
<?php echo $dataarray[190]; ?>
<img class="unit u<?php echo $dataarray[200]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" />
<?php echo $dataarray[201]; ?>
</td></tr></tbody>
<?php }
if (!empty($dataarray[191]) && !empty($dataarray[192])){ //chief
if (!empty($dataarray[202]) && !empty($dataarray[203])){ //chief
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[191]; ?>" src="img/x.gif" alt="Chief" title="Chief" />
<?php echo $dataarray[192]; ?>
<img class="unit u<?php echo $dataarray[202]; ?>" src="img/x.gif" alt="Chief" title="Chief" />
<?php echo $dataarray[203]; ?>
</td></tr></tbody>
<?php }
if (!empty($dataarray[194]) && !empty($dataarray[195])){ //hero
if (!empty($dataarray[205]) && !empty($dataarray[206])){ //hero
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[194]; ?>" src="img/x.gif" alt="Hero" title="Hero" />
<?php echo $dataarray[195]; ?>
<img class="unit u<?php echo $dataarray[205]; ?>" src="img/x.gif" alt="Hero" title="Hero" />
<?php echo $dataarray[206]; ?>
</td></tr></tbody>
<?php }
if(isset($dataarray[193]) && !empty($dataarray[193])){ //No troops returned
if(isset($dataarray[204]) && !empty($dataarray[204])){ //No troops returned
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<?php echo $dataarray[193]; ?>
<?php echo $dataarray[204]; ?>
</td></tr></tbody>
<?php }?>
</td></tr></tbody>
</table>
<?php
$target = $dataarray[33] - 1;
$target = $dataarray[34] - 1;
$start = ($target * 10) + 1;
$troopsStart = ($target * 21) + 35;
?>