diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 79579dba..e2d15616 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -2063,6 +2063,7 @@ private function sendunitsComplete() { } //cranny efficiency + //TODO: Needs to be connected to a function $atk_bonus = ($owntribe == 2)? (4/5) : 1; $def_bonus = ($targettribe == 3)? 2 : 1; $to_owner = $database->getVillageField($data['to'],"owner"); @@ -2922,31 +2923,9 @@ private function sendunitsComplete() { //to here // If the dead units not equal the ammount sent they will return and report if($totalsend_att - ($totaldead_att + (isset($totaltraped_att) ? $totaltraped_att : 0)) > 0) - { - $artefact = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,3,0)); - $artefact1 = count($database->getOwnUniqueArtefactInfo2($from['wref'],2,1,1)); - $artefact2 = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,2,0)); - if($artefact > 0){ - $fastertroops = 3; - }else if($artefact1 > 0){ - $fastertroops = 2; - }else if($artefact2 > 0){ - $fastertroops = 1.5; - }else{ - $fastertroops = 1; - } - $endtime = round($this->procDistanceTime($from,$to,min($speeds),1)/$fastertroops); - $foolartefact2 = $database->getFoolArtefactInfo(2,$from['wref'],$from['owner']); - if(count($foolartefact2) > 0){ - foreach($foolartefact2 as $arte){ - if($arte['bad_effect'] == 1){ - $endtime *= $arte['effect2']; - }else{ - $endtime /= $arte['effect2']; - $endtime = round($endtime); - } - } - } + { + $troopsTime = $this->procDistanceTime($from, $to, min($speeds), 1); + $endtime = $database->getTroopsWalkingTime($from['owner'], $from['wref'], 2, $troopsTime); $endtime += $AttackArrivalTime; if($type == 1) { if($from['owner'] == 3) { //fix natar report by ronix @@ -3026,54 +3005,29 @@ private function sendunitsComplete() { $herosend_att = $data['t11']; $unitssend_att= $unitssend_att1.','.$herosend_att; - $speeds = array(); + $speeds = []; //find slowest unit. - for($i=1;$i<=10;$i++) + //TODO: Needs to be made as a function + for($i = 1; $i <= 10; $i++) { if ($data['t'.$i] > 0) { - if($unitarray) { reset($unitarray); } $unitarray = $GLOBALS["u".(($owntribe-1)*10+$i)]; $speeds[] = $unitarray['speed']; } } - if ($herosend_att>0){ + if ($herosend_att > 0){ $hero_unit = $database->getHeroField($from['owner'], 'unit'); $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; } - $artefact = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,3,0)); - $artefact1 = count($database->getOwnUniqueArtefactInfo2($from['vref'],2,1,1)); - $artefact2 = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,2,0)); - - if($artefact > 0){ - $fastertroops = 3; - }else if($artefact1 > 0){ - $fastertroops = 2; - }else if($artefact2 > 0){ - $fastertroops = 1.5; - }else{ - $fastertroops = 1; - } - - $endtime = round($this->procDistanceTime($from,$to,min($speeds),1)/$fastertroops); - $foolartefact3 = $database->getFoolArtefactInfo(2,$from['wref'],$from['owner']); - - if(count($foolartefact3) > 0){ - foreach($foolartefact3 as $arte){ - if($arte['bad_effect'] == 1){ - $endtime *= $arte['effect2']; - }else{ - $endtime /= $arte['effect2']; - $endtime = round($endtime); - } - } - } + $troopsTime = $this->procDistanceTime($from, $to, min($speeds), 1); + $endtime = $database->getTroopsWalkingTime($from['owner'], $from['wref'], 2, $troopsTime); $endtime += $AttackArrivalTime; - //$endtime += microtime(true); + $database->setMovementProc($data['moveid']); - $database->addMovement(4,$to['wref'],$from['wref'],$data['ref'],$AttackArrivalTime,$endtime); + $database->addMovement(4, $to['wref'], $from['wref'], $data['ref'], $AttackArrivalTime, $endtime); $peace = PEACE; $data2 = $from['owner'].','.$from['wref'].','.$to['owner'].','.$owntribe.','.$unitssend_att.','.$peace; $time = time(); @@ -5863,37 +5817,33 @@ function medals(){ private function artefactOfTheFool() { global $database; $time = time(); - $q = "SELECT id, size FROM " . TB_PREFIX . "artefacts where type = 8 and active = 1 and lastupdate <= ".($time - 86400); + $q = "SELECT id, size FROM " . TB_PREFIX . "artefacts where type = 8 AND active = 1 AND lastupdate <= ".($time - (86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED)))); $array = $database->query_return($q); if ($array) { foreach($array as $artefact) { - $kind = rand(1,7); + $kind = rand(1, 7); while($kind == 6){ - $kind = rand(1,7); - } - if($artefact['size'] != 3){ - $bad_effect = rand(0,1); - }else{ - $bad_effect = 0; + $kind = rand(1, 7); } + if($artefact['size'] != 3) $bad_effect = rand(0, 1); + else $bad_effect = 0; + switch($kind) { case 1: - $effect = rand(1,5); + $effect = rand(1, 5); break; case 2: - $effect = rand(1,3); + $effect = rand(1, 3); break; case 3: - $effect = rand(3,10); + $effect = rand(3, 10); break; case 4: - $effect = rand(2,4); - break; case 5: - $effect = rand(2,4); + $effect = rand(2, 4); break; case 7: - $effect = rand(1,6); + $effect = rand(1, 6); break; } mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."artefacts SET kind = ". (int) $kind. ", bad_effect = $bad_effect, effect2 = $effect, lastupdate = $time WHERE id = ".(int) $artefact['id']); diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 18389dfa..69b7614f 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -3504,7 +3504,11 @@ function getFieldLevelInVillage($vid, $fieldType, $use_cache = true) { IF( f40t IN ($fieldType), f40, - 0 + IF( + f99t IN ($fieldType), + f99, + 0 + ) ) ) ) @@ -3635,7 +3639,7 @@ function getFieldLevelInVillage($vid, $fieldType, $use_cache = true) { OR f40t IN ($fieldType) OR - f99 IN ($fieldType)) + f99t IN ($fieldType)) LIMIT 1 "); $row = mysqli_fetch_array($result, MYSQLI_ASSOC); @@ -6942,6 +6946,50 @@ public function getAvailableExpansionTraining() { return $slots; } + /** + * Calculates how much time troops spend to walk from a village to another, counting artifacts + * + * @param int $uid The User ID + * @param int $vid The village ID + * @param int $time The old time, without multipliers + * @return int Returns the new time, multiplied or divided by artifacts bonus or malus + */ + + function getTroopsWalkingTime($uid, $vid, $kind, $time){ + list($uid, $vid, $time) = $this->escape_input((int) $uid,(int) $vid, $time); + + $artefacts = $foolArefacts = []; + $multiplier = [2, 3, 1.5]; + + $artefacts[] = count($this->getOwnUniqueArtefactInfo2($vid, $kind, 1, 1)); //Village effect + $artefacts[] = count($this->getOwnUniqueArtefactInfo2($uid, $kind, 3, 0)); //Unique effect + $artefacts[] = count($this->getOwnUniqueArtefactInfo2($uid, $kind, 2, 0)); //Account effect + + $fasterTroops = 1; + for($i = 0; $i < count($artefacts); $i++) + { + if($artefacts[$i] > 0) { + $fasterTroops = $multiplier[$i]; + break; + } + } + + $foolArefacts[] = $this->getOwnUniqueArtefactInfo2($vid, 8, 1, 1); //Village effect + $foolArefacts[] = $this->getOwnUniqueArtefactInfo2($uid, 8, 3, 0); //Unique effect + + $foolEffect = 1; + for($i = 0; $i < count($foolArefacts); $i++) + { + if(count($foolArefacts[$i]) > 0 && $foolArefacts[$i]['kind'] == $kind) + { + $foolEffect = $foolArefacts[$i]['bad_effect'] == 1 ? $foolArefacts[$i]['effect2'] : 1 / $foolArefacts[$i]['effect2']; + break; + } + } + + return round(($time / $fasterTroops) * $foolEffect); + } + function addArtefact($vref, $owner, $type, $size, $name, $desc, $effect, $img) { list($vref, $owner, $type, $size, $name, $desc, $effect, $img) = $this->escape_input($vref, $owner, $type, $size, $name, $desc, $effect, $img); @@ -7067,8 +7115,8 @@ function getOwnUniqueArtefactInfo2($id, $type, $size, $mode, $use_cache = true) return (isset(self::$artefactDataCache[$id.$mode][$size.$type]) ? self::$artefactDataCache[$id.$mode][$size.$type] : []); } - function getFoolArtefactInfo($type,$vid,$uid, $use_cache = true) { - list($type,$vid,$uid) = $this->escape_input((int) $type,(int) $vid,(int) $uid); + function getFoolArtefactInfo($type, $vid, $uid, $use_cache = true) { + list($type, $vid, $uid) = $this->escape_input((int) $type, (int) $vid, (int) $uid); // first of all, check if we should be using cache and whether the field // required is already cached @@ -7199,7 +7247,7 @@ function areArtifactsSpawned(){ function getInactiveArtifacts($time){ list($time) = $this->escape_input($time); - $q = "SELECT * FROM ".TB_PREFIX."artefacts WHERE active = 0 AND owner > 5 AND conquered < $time ORDER BY conquered ASC, size ASC"; + $q = "SELECT * FROM ".TB_PREFIX."artefacts WHERE active = 0 AND owner > 5 AND conquered <= $time ORDER BY conquered ASC, size ASC"; $result = mysqli_query($this->dblink, $q); return $this->mysqli_fetch_all($result); } diff --git a/GameEngine/Units.php b/GameEngine/Units.php index 680b4c3f..b9a837dd 100755 --- a/GameEngine/Units.php +++ b/GameEngine/Units.php @@ -332,62 +332,42 @@ private function sendTroops($post) { global $form, $database, $village, $generator, $session; $data = $database->getA2b( $post['timestamp_checksum'], $post['timestamp'] ); - $Gtribe = ""; - - if ( $session->tribe == '2' ) { - $Gtribe = "1"; - } else if ( $session->tribe == '3' ) { - $Gtribe = "2"; - } else if ( $session->tribe == '4' ) { - $Gtribe = "3"; - } else if ( $session->tribe == '5' ) { - $Gtribe = "4"; - } + $Gtribe = ($session->tribe == 1) ? "" : $session->tribe - 1; - for ( $i = 1; $i < 10; $i ++ ) { - if ( isset( $data[ 'u' . $i ] ) ) { + for ($i = 1; $i < 10; $i++) { + if (isset($data['u'.$i])) { - if ( $data[ 'u' . $i ] > $village->unitarray[ 'u' . $Gtribe . $i ] ) { - $form->addError( "error", "You can't send more units than you have" ); + if ($data['u'.$i] > $village->unitarray['u'.$Gtribe.$i]) { + $form->addError("error", "You can't send more units than you have"); break; } - if ( $data[ 'u' . $i ] < 0 ) { - $form->addError( "error", "You can't send negative units." ); + if ($data[ 'u'.$i ] < 0) { + $form->addError("error", "You can't send negative units."); break; } } } - if ( $data['u11'] > $village->unitarray['hero'] ) { - $form->addError( "error", "You can't send more units than you have" ); + if ($data['u11'] > $village->unitarray['hero']) { + $form->addError( "error", "You can't send more units than you have"); } - if ( $data['u11'] < 0 ) { - $form->addError( "error", "You can't send negative units." ); + if ($data['u11'] < 0) { + $form->addError( "error", "You can't send negative units."); } if($data['type'] != 1 && $post['spy'] != 0) $post['spy'] = 0; - if ( $form->returnErrors() > 0 ) { + if ($form->returnErrors() > 0) { $_SESSION['errorarray'] = $form->getErrors(); $_SESSION['valuearray'] = $_POST; header( "Location: a2b.php" ); exit; } else { - if ( $session->access != BANNED ) { - if ( $session->tribe == 1 ) { - $u = ""; - } elseif ( $session->tribe == 2 ) { - $u = "1"; - } elseif ( $session->tribe == 3 ) { - $u = "2"; - } elseif ( $session->tribe == 4 ) { - $u = "3"; - } else { - $u = "4"; - } + if ($session->access != BANNED) { + $u = ($session->tribe == 1) ? "" : $session->tribe - 1; $database->modifyUnit( $village->wid, @@ -417,7 +397,7 @@ private function sendTroops($post) { $data['u10'], $data['u11'] ), - array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) + array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ); $fromcoor = $database->getCoor( $village->wid ); @@ -427,84 +407,49 @@ private function sendTroops($post) { $speeds = []; //find slowest unit. - for ( $i = 1; $i <= 10; $i ++ ) { - if ( isset( $data[ 'u' . $i ] ) ) { - if ( $data[ 'u' . $i ] != '' && $data[ 'u' . $i ] > 0 ) { - if ( $unitarray ) { - reset( $unitarray ); + for ($i = 1; $i <= 10; $i ++) { + if (isset( $data['u'.$i] ) ) { + if (!empty($data['u'.$i]) && $data['u'.$i] > 0) { + if ($unitarray) { + reset($unitarray); } - $unitarray = $GLOBALS[ "u" . ( ( $session->tribe - 1 ) * 10 + $i ) ]; + $unitarray = $GLOBALS["u".(($session->tribe - 1) * 10 + $i)]; $speeds[] = $unitarray['speed']; } } } - if ( isset( $data['u11'] ) ) { - if ( $data['u11'] != '' && $data['u11'] > 0 ) { - $heroarray = $database->getHero( $session->uid ); - $herodata = $GLOBALS[ "u" . $heroarray[0]['unit'] ]; + if (isset($data['u11'])) { + if (!empty($data['u11']) && $data['u11'] > 0) { + $heroarray = $database->getHero( $session->uid); + $herodata = $GLOBALS['u'.$heroarray[0]['unit']]; $speeds[] = $herodata['speed']; } } - $artefact = count( $database->getOwnUniqueArtefactInfo2( $session->uid, 2, 3, 0 ) ); - $artefact1 = count( $database->getOwnUniqueArtefactInfo2( $village->wid, 2, 1, 1 ) ); - $artefact2 = count( $database->getOwnUniqueArtefactInfo2( $session->uid, 2, 2, 0 ) ); - if ( $artefact > 0 ) { - $fastertroops = 3; - } else if ( $artefact1 > 0 ) { - $fastertroops = 2; - } else if ( $artefact2 > 0 ) { - $fastertroops = 1.5; - } else { - $fastertroops = 1; - } - $time = round( $generator->procDistanceTime( $from, $to, min( $speeds ), 1 ) / $fastertroops ); - $foolartefact = $database->getFoolArtefactInfo( 2, $village->wid, $session->uid ); - if ( count( $foolartefact ) > 0 ) { - foreach ( $foolartefact as $arte ) { - if ( $arte['bad_effect'] == 1 ) { - $time *= $arte['effect2']; - } else { - $time /= $arte['effect2']; - $time = round( $time ); - } - } - } - $to_owner = $database->getVillageField( $data['to_vid'], "owner" ); + + $troopsTime = $generator->procDistanceTime($from, $to, min($speeds), 1); + $time = $database->getTroopsWalkingTime($session->uid, $village->wid, 2, $troopsTime); + + $to_owner = $database->getVillageField($data['to_vid'], "owner"); + // Check if have WW owner have artefact Rivals great confusion or Artefact of the unique fool with that effect // If is a WW village you can target on WW , if is not a WW village catapults will target randomly. // Like it says : Exceptions are the WW which can always be targeted and the treasure chamber which can always be targeted, except with the unique artifact. - // Fixed by Advocaite and Shadow - $q = mysqli_fetch_array( mysqli_query( $database->dblink, "SELECT Count(*) as Total FROM " . TB_PREFIX . "fdata WHERE f99t = '40' AND vref = " . (int) $data['to_vid'] ), MYSQLI_ASSOC ); - $isThere = $q['Total']; - if ( $isThere > 0 ) { - $iswwvilla = 1; - $artefact_2 = count( $database->getOwnUniqueArtefactInfo2( $to_owner, 7, 3, 0 ) ); - $artefact1_2 = count( $database->getOwnUniqueArtefactInfo2( $data['to_vid'], 7, 1, 1 ) ); - $artefact2_2 = count( $database->getOwnUniqueArtefactInfo2( $to_owner, 7, 2, 0 ) ); - $foolartefact2 = $database->getFoolArtefactInfo( 7, $data['to_vid'], $to_owner ); - $good_artefact = 0; - if ( count( $foolartefact2 ) > 0 ) { - foreach ( $foolartefact2 as $arte ) { - if ( $arte['bad_effect'] == 0 ) { - $good_artefact = 1; - } - } - } - } else { - $artefact_2 = count( $database->getOwnUniqueArtefactInfo2( $to_owner, 7, 3, 0 ) ); - $artefact1_2 = count( $database->getOwnUniqueArtefactInfo2( $data['to_vid'], 7, 1, 1 ) ); - $artefact2_2 = count( $database->getOwnUniqueArtefactInfo2( $to_owner, 7, 2, 0 ) ); - $foolartefact2 = $database->getFoolArtefactInfo( 7, $data['to_vid'], $to_owner ); - $iswwvilla = 0; - $good_artefact = 0; - if ( count( $foolartefact2 ) > 0 ) { - foreach ( $foolartefact2 as $arte ) { - if ( $arte['bad_effect'] == 0 ) { - $good_artefact = 1; - } + // Fixed by Advocaite and Shadow - Optimized by iopietro + + $isThere = $database->getFieldLevelInVillage($data['to_vid'], 40); + $iswwvilla = $isThere > 0 ? 1 : 0; + $good_artefact = 0; + $artefact_2 = count($database->getOwnUniqueArtefactInfo2($to_owner, 7, 3, 0)); + $artefact1_2 = count($database->getOwnUniqueArtefactInfo2($data['to_vid'], 7, 1, 1)); + $artefact2_2 = count($database->getOwnUniqueArtefactInfo2($to_owner, 7, 2, 0)); + $foolartefact2 = $database->getFoolArtefactInfo(7, $data['to_vid'], $to_owner); + if(count($foolartefact2) > 0) { + foreach ($foolartefact2 as $arte) { + if ($arte['bad_effect'] == 0) { + $good_artefact = 1; } } - } + } $rallyPointLevel = ($village->resarray)['f39']; $invalidBuildings = []; @@ -540,61 +485,59 @@ private function sendTroops($post) { } } } + + //TODO: Check those strings I do think they're wrong - //TODO: check those instructions, i think that they're wrong - if ( isset( $post['ctar1'] ) ) { - if ( $artefact_2 > 0 or $artefact1_2 > 0 or $artefact2_2 > 0 or $good_artefact == 1 ) { - if ( $post['ctar1'] != 40 or $post['ctar1'] != 27 and $iswwvilla == 1 ) { + if (isset($post['ctar1'])) { + if ($artefact_2 > 0 || $artefact1_2 > 0 || $artefact2_2 > 0 || $good_artefact == 1) { + if ($post['ctar1'] != 40 || $post['ctar1'] != 27 && $iswwvilla == 1) { $post['ctar1'] = 99; } else { $post['ctar1'] = 99; } } - } else { - $post['ctar1'] = 0; - } + } + else $post['ctar1'] = 0; - if ( isset( $post['ctar2'] ) ) { - if ( $artefact_2 > 0 or $artefact1_2 > 0 or $artefact2_2 > 0 or $good_artefact == 1 ) { - if ( $post['ctar2'] != 40 or $post['ctar2'] != 27 and $iswwvilla == 1 ) { + if(isset( $post['ctar2'])) { + if ($artefact_2 > 0 || $artefact1_2 > 0 || $artefact2_2 > 0 || $good_artefact == 1) { + if ($post['ctar2'] != 40 || $post['ctar2'] != 27 && $iswwvilla == 1) { $post['ctar2'] = 99; } else { $post['ctar2'] = 99; } } - } else { - $post['ctar2'] = 0; } + else $post['ctar2'] = 0; - if (!isset($post['spy'])) { - $post['spy'] = 0; - } - $abdata = $database->getABTech( $village->wid ); - $reference = $database->addAttack( ( $village->wid ), $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], $data['u7'], $data['u8'], $data['u9'], $data['u10'], $data['u11'], $data['type'], $post['ctar1'], $post['ctar2'], $post['spy'], $abdata['b1'], $abdata['b2'], $abdata['b3'], $abdata['b4'], $abdata['b5'], $abdata['b6'], $abdata['b7'], $abdata['b8'] ); - $checkexist = $database->checkVilExist( $data['to_vid'] ); - $checkoexist = $database->checkOasisExist( $data['to_vid'] ); - if ( $checkexist or $checkoexist ) { - $database->addMovement( 3, $village->wid, $data['to_vid'], $reference, time(), ( $time + time() ) ); - if ( ( $database->hasBeginnerProtection( $village->wid ) == 1 ) && ( $checkexist ) ) { - mysqli_query( $database->dblink, "UPDATE " . TB_PREFIX . "users SET protect = 0 WHERE id = " . (int) $session->uid ); + if(!isset($post['spy'])) $post['spy'] = 0; + + $abdata = $database->getABTech($village->wid); + $reference = $database->addAttack(($village->wid), $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], $data['u7'], $data['u8'], $data['u9'], $data['u10'], $data['u11'], $data['type'], $post['ctar1'], $post['ctar2'], $post['spy'], $abdata['b1'], $abdata['b2'], $abdata['b3'], $abdata['b4'], $abdata['b5'], $abdata['b6'], $abdata['b7'], $abdata['b8']); + $checkexist = $database->checkVilExist($data['to_vid']); + $checkoexist = $database->checkOasisExist($data['to_vid']); + if($checkexist || $checkoexist) { + $database->addMovement(3, $village->wid, $data['to_vid'], $reference, time(), ($time + time())); + if ($database->hasBeginnerProtection($village->wid) == 1 && $checkexist) { + mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "users SET protect = 0 WHERE id = ".(int) $session->uid); } } - if ( $form->returnErrors() > 0 ) { + if($form->returnErrors() > 0) { $_SESSION['errorarray'] = $form->getErrors(); $_SESSION['valuearray'] = $_POST; - header( "Location: a2b.php" ); + header("Location: a2b.php" ); exit; } // prevent re-use of the same attack via re-POSTing the same data $database->remA2b($data['id']); - header( "Location: build.php?id=39" ); + header("Location: build.php?id=39"); exit; } else { - header( "Location: banned.php" ); + header("Location: banned.php"); exit; } } @@ -607,16 +550,7 @@ private function sendTroopsBack($post) { $enforceoasis = $database->getOasisEnforceArray( $post['ckey'], 0 ); if ( ( $enforce['from'] == $village->wid ) || ( $enforce['vref'] == $village->wid ) || ( $enforceoasis['conqured'] == $village->wid ) ) { $to = $database->getVillage( $enforce['from'] ); - $Gtribe = ""; - if ( $database->getUserField( $to['owner'], 'tribe', 0 ) == '2' ) { - $Gtribe = "1"; - } else if ( $database->getUserField( $to['owner'], 'tribe', 0 ) == '3' ) { - $Gtribe = "2"; - } else if ( $database->getUserField( $to['owner'], 'tribe', 0 ) == '4' ) { - $Gtribe = "3"; - } else if ( $database->getUserField( $to['owner'], 'tribe', 0 ) == '5' ) { - $Gtribe = "4"; - } + $Gtribe = ($ownerTribe = $database->getUserField( $to['owner'], 'tribe', 0)) == 1 ? "" : $ownerTribe - 1; for ( $i = 1; $i < 10; $i ++ ) { if ( isset( $post[ 't' . $i ] ) ) { @@ -705,36 +639,14 @@ private function sendTroopsBack($post) { if ( $post['t11'] != '' && $post['t11'] > 0 ) { $hero_unit = $database->getHeroField($from['owner'], 'unit'); $speeds[] = $GLOBALS[ 'u' . $hero_unit ]['speed']; - } else { - $post['t11'] = '0'; - } - } else { - $post['t11'] = '0'; - } - $artefact = count( $database->getOwnUniqueArtefactInfo2( $session->uid, 2, 3, 0 ) ); - $artefact1 = count( $database->getOwnUniqueArtefactInfo2( $village->wid, 2, 1, 1 ) ); - $artefact2 = count( $database->getOwnUniqueArtefactInfo2( $session->uid, 2, 2, 0 ) ); - if ( $artefact > 0 ) { - $fastertroops = 3; - } else if ( $artefact1 > 0 ) { - $fastertroops = 2; - } else if ( $artefact2 > 0 ) { - $fastertroops = 1.5; - } else { - $fastertroops = 1; - } - $time = round( $generator->procDistanceTime( $fromCor, $toCor, min( $speeds ), 1 ) / $fastertroops ); - $foolartefact2 = $database->getFoolArtefactInfo( 2, $village->wid, $session->uid ); - if ( count( $foolartefact2 ) > 0 ) { - foreach ( $foolartefact2 as $arte ) { - if ( $arte['bad_effect'] == 1 ) { - $time *= $arte['effect2']; - } else { - $time /= $arte['effect2']; - $time = round( $time ); - } } - } + else $post['t11'] = 0; + } + else $post['t11'] = 0; + + $troopsTime = $generator->procDistanceTime($fromCor, $toCor, min($speeds), 1); + $time = $database->getTroopsWalkingTime($session->uid, $village->wid, 2, $troopsTime); + $reference = $database->addAttack( $enforce['from'], $post['t1'], $post['t2'], $post['t3'], $post['t4'], $post['t5'], $post['t6'], $post['t7'], $post['t8'], $post['t9'], $post['t10'], $post['t11'], 2, 0, 0, 0, 0 ); $database->addMovement( 4, $village->wid, $enforce['from'], $reference, time(), ( $time + time() ) ); $technology->checkReinf( $post['ckey'], false ); diff --git a/Templates/Build/17_4.tpl b/Templates/Build/17_4.tpl index ee840e38..1f335e37 100644 --- a/Templates/Build/17_4.tpl +++ b/Templates/Build/17_4.tpl @@ -53,9 +53,9 @@ echo "".TRADE_ROUTE_TO." g