From 6f895f7d54574c2e2cb9d1acbdcdbee5a03792b6 Mon Sep 17 00:00:00 2001 From: iopietro Date: Mon, 16 Apr 2018 18:39:41 +0200 Subject: [PATCH] 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 --- GameEngine/Automation.php | 29 ++++++++++++++--------------- GameEngine/Battle.php | 2 +- GameEngine/Database.php | 2 +- GameEngine/Units.php | 2 -- Templates/a2b/attack.tpl | 6 +++--- Templates/a2b/attack_5.tpl | 6 +++--- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index b5742f7f..d3595ec4 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -2767,22 +2767,21 @@ class Automation { "; }else if($data['spy'] == 2){ if ($isoasis == 0){ - $crannylevel = $database->getFieldLevelInVillage($data['to'], 23); - $walllevel = $database->getFieldLevelInVillage($data['to'], '31, 32, 33'); - $rplevel = $database->getFieldLevelInVillage($data['to'], '25, 26'); - } else { - $crannylevel =0; - $walllevel =0; - $rplevel =0; - } - - $palaceimg = "\"Palace\""; - $crannyimg = "\"Cranny\""; - $wallimg = "\"Wall\""; - $info_spy = "".$spy_pic.",".$palaceimg." Residance/Palace Level : ".$rplevel." + $walllevel = $database->getFieldLevelInVillage($data['to'], 31); + $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."
"; -
".$crannyimg." Cranny level: ".$crannylevel."
".$wallimg." Wall level : ".$walllevel.""; - + if($walllevel > 0) $info_spy .= $wallimg." Wall level: ".$walllevel."
"; + $info_spy .= $crannyimg." Total crannies capacity: ".$cranny.""; + } + 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; diff --git a/GameEngine/Battle.php b/GameEngine/Battle.php index 2382ec83..8f37bd02 100755 --- a/GameEngine/Battle.php +++ b/GameEngine/Battle.php @@ -524,7 +524,7 @@ class Battle { // Formula for calculating the Moral 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{ $moralbonus = 1.0; } diff --git a/GameEngine/Database.php b/GameEngine/Database.php index c8628adf..101b632e 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -3560,7 +3560,7 @@ class MYSQLi_DB implements IDbConnection { ) ) as level FROM - ".TB_PREFIX."fdata` + ".TB_PREFIX."fdata WHERE vref = $vid AND diff --git a/GameEngine/Units.php b/GameEngine/Units.php index 4bc5c006..680b4c3f 100755 --- a/GameEngine/Units.php +++ b/GameEngine/Units.php @@ -367,8 +367,6 @@ class Units { if ( $data['u11'] < 0 ) { $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; diff --git a/Templates/a2b/attack.tpl b/Templates/a2b/attack.tpl index 7d08d8a8..b6e0268b 100644 --- a/Templates/a2b/attack.tpl +++ b/Templates/a2b/attack.tpl @@ -333,14 +333,14 @@ $end = ($tribe*10); ?> Destination: - colspan=""> - "> + ONLY shoot with a normal attack (they dont shoot with raids!)"; ?> - diff --git a/Templates/a2b/attack_5.tpl b/Templates/a2b/attack_5.tpl index 85e40071..db0bc100 100644 --- a/Templates/a2b/attack_5.tpl +++ b/Templates/a2b/attack_5.tpl @@ -317,15 +317,15 @@ $actionType = "Raid"; ?> Destination: - colspan=""> - "> + ONLY shoot with a normal attack (they dont shoot with raids!)"; ?> -