fix: alleviating the bad math, which is impossible to quick-fix for me

This commit is contained in:
Martin Ambrus
2017-11-13 19:03:59 +01:00
parent c6d9d264ce
commit bdfe99b7f6
+12
View File
@@ -1110,8 +1110,20 @@ class Automation {
// building/field was damaged, let's calculate the actual damage
{
//TODO: MUST TO BE FIX This part goes also below 0 if u have a lot of catapults
// TODO: this whole math seems incorrect, it needs a revision, and potentially a rewrite
$totallvl = round( sqrt( pow( ( $tblevel + 0.5 ), 2 ) - ( ( !$twoRowsCatapultSetup ? (int) $battlepart[4] : (int) $battlepart[4] / 2 ) * 8 ) ) );
// sometimes this goes above the actual level, so in that case we just reverse everything
// and take the buiding down so many levels
if ($totallvl > $tblevel) {
$totallvl = $tblevel - ($totallvl - $tblevel);
}
// don't allow this to go below 0
if ($totallvl <= 0) {
$totallvl = 1;
}
// no damage to the building/field
if ( $tblevel >= $totallvl ) {
$info_cata = " was not damaged.";