Fixed some bugs

+Fixed a "division by zero" error, in Battle.php
+Reworked spied informations, now they're shown only if the building is
at least at level 1. Splitted residence/palace information in two
distinct informations. Now the total crannies capacity is displayed
(even if the capacity is 0) instead of the level of the greatest cranny
+Fixed "getFieldLevelInVillage" function in Database.php
-Removed an useless control in Units.php
This commit is contained in:
iopietro
2018-04-16 18:39:41 +02:00
parent e6449d20c6
commit 6f895f7d54
6 changed files with 22 additions and 25 deletions
+14 -15
View File
@@ -2767,22 +2767,21 @@ class Automation {
"; ";
}else if($data['spy'] == 2){ }else if($data['spy'] == 2){
if ($isoasis == 0){ if ($isoasis == 0){
$crannylevel = $database->getFieldLevelInVillage($data['to'], 23); $walllevel = $database->getFieldLevelInVillage($data['to'], 31);
$walllevel = $database->getFieldLevelInVillage($data['to'], '31, 32, 33'); $residencelevel = $database->getFieldLevelInVillage($data['to'], 25);
$rplevel = $database->getFieldLevelInVillage($data['to'], '25, 26'); $palacelevel = $database->getFieldLevelInVillage($data['to'], 26);
} else { $residenceimg = "<img src=\"".GP_LOCATE."img/g/g25.gif\" height=\"20\" width=\"15\" alt=\"Residence\" title=\"Residence\" />";
$crannylevel =0; $palaceimg = "<img src=\"".GP_LOCATE."img/g/g26.gif\" height=\"20\" width=\"15\" alt=\"Palace\" title=\"Palace\" />";
$walllevel =0; $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\" alt=\"Cranny\" title=\"Cranny\" />";
$rplevel =0; $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 />";
$palaceimg = "<img src=\"".GP_LOCATE."img/g/g26.gif\" height=\"20\" width=\"15\" alt=\"Palace\" title=\"Palace\" />"; elseif($palacelevel > 0) $info_spy .= $palaceimg." Palace level: <b>".$palacelevel."</b><br />";
$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.",".$palaceimg." Residance/Palace Level : ".$rplevel."
<br>".$crannyimg." Cranny level: ".$crannylevel."<br>".$wallimg." Wall level : ".$walllevel.""; if($walllevel > 0) $info_spy .= $wallimg." Wall level: <b>".$walllevel."</b><br />";
$info_spy .= $crannyimg." Total crannies capacity: <b>".$cranny."</b>";
}
else $info_spy = "".$spy_pic.", There are no informations to show";
} }
$data2 = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.',0,0,0,0,0,'.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$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].','.$info_ram.','.$info_cat.','.$info_chief.','.$info_spy.',,'.$data['t11'].','.$dead11.','.$herosend_def.','.$deadhero.','.$unitstraped_att; $data2 = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.',0,0,0,0,0,'.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$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].','.$info_ram.','.$info_cat.','.$info_chief.','.$info_spy.',,'.$data['t11'].','.$dead11.','.$herosend_def.','.$deadhero.','.$unitstraped_att;
+1 -1
View File
@@ -524,7 +524,7 @@ class Battle {
// Formula for calculating the Moral // Formula for calculating the Moral
if($attpop > $defpop) { if($attpop > $defpop) {
$moralbonus = 1 / round(max(0.667, pow($defpop / $attpop, 0.2 * min(1, $rap / $rdp))), 3); $moralbonus = 1 / round(max(0.667, pow($defpop / $attpop, 0.2 * min(1, $rap / ($rdp > 0 ? $rdp : 1)))), 3);
}else{ }else{
$moralbonus = 1.0; $moralbonus = 1.0;
} }
+1 -1
View File
@@ -3560,7 +3560,7 @@ class MYSQLi_DB implements IDbConnection {
) )
) as level ) as level
FROM FROM
".TB_PREFIX."fdata` ".TB_PREFIX."fdata
WHERE WHERE
vref = $vid vref = $vid
AND AND
-2
View File
@@ -367,8 +367,6 @@ class Units {
if ( $data['u11'] < 0 ) { if ( $data['u11'] < 0 ) {
$form->addError( "error", "You can't send negative units." ); $form->addError( "error", "You can't send negative units." );
} }
if($data['type'] < 1 || $data['type'] > 4) $form->addError("error", "Invalid attack type.");
if($data['type'] != 1 && $post['spy'] != 0) $post['spy'] = 0; if($data['type'] != 1 && $post['spy'] != 0) $post['spy'] = 0;
+3 -3
View File
@@ -333,14 +333,14 @@ $end = ($tribe*10);
?><tbody class="infos"> ?><tbody class="infos">
<tr> <tr>
<th>Destination:</th> <th>Destination:</th>
<td> colspan="<?php if(!empty($process['t11'])){ echo"11"; }else{ echo"10"; } ?>"> <td colspan="<?php echo !empty($process['t11']) ? 11 : 10; ?>">
<?PHP <?php
echo"Warning: Catapult will <b>ONLY</b> shoot with a normal attack (they dont shoot with raids!)"; echo"Warning: Catapult will <b>ONLY</b> shoot with a normal attack (they dont shoot with raids!)";
?> ?>
</td> </td>
</tr> </tr>
<?PHP <?php
} }
?> ?>
+3 -3
View File
@@ -317,15 +317,15 @@ $actionType = "Raid";
?><tbody class="infos"> ?><tbody class="infos">
<tr> <tr>
<th>Destination:</th> <th>Destination:</th>
<td> colspan="<?php if($process['t11'] != ''){ echo"11"; }else{ echo"10"; } ?>"> <td colspan="<?php echo !empty($process['t11']) ? 11 : 10; ?>">
<?PHP <?php
echo"Warning: Catapult will <b>ONLY</b> shoot with a normal attack (they dont shoot with raids!)"; echo"Warning: Catapult will <b>ONLY</b> shoot with a normal attack (they dont shoot with raids!)";
?> ?>
</td> </td>
</tr> </tr>
<?PHP <?php
} }
?> ?>