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 - - | - | + + | + | * Gold2 diff --git a/Templates/Build/27_show.tpl b/Templates/Build/27_show.tpl index 3cd38be3..27687d9b 100644 --- a/Templates/Build/27_show.tpl +++ b/Templates/Build/27_show.tpl @@ -53,7 +53,7 @@ switch($kind){ break; } -$bonus = $betterorbadder." ".$effecty; +$bonus = $betterorbadder." (".str_replace(["(", ")"], "" , $effecty).")"; ?>
diff --git a/Templates/a2b/attack.tpl b/Templates/a2b/attack.tpl index b6e0268b..a5e7196f 100644 --- a/Templates/a2b/attack.tpl +++ b/Templates/a2b/attack.tpl @@ -1,107 +1,35 @@ getCoor($village->wid); - -$from = array('x'=>$eigen['x'], 'y'=>$eigen['y']); - -$to = array('x'=>$coor['x'], 'y'=>$coor['y']); - - $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,300,0)/$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); +$ckey = $generator->generateRandStr(6); + + if (!isset($process['t1']) || $process['t1'] == ''){ $t1 = 0; }else{ $t1 = $process['t1']; } + if (!isset($process['t2']) || $process['t2'] == ''){ $t2 = 0; }else{ $t2 = $process['t2']; } + if (!isset($process['t3']) || $process['t3'] == ''){ $t3 = 0; }else{ $t3 = $process['t3']; if ($session->tribe == 3) $scout=1; } + if (!isset($process['t4']) || $process['t4'] == ''){ $t4 = 0; }else{ $t4 = $process['t4']; if ($session->tribe == 1 || $session->tribe == 2 || $session->tribe == 4 || $session->tribe == 5) $scout=1; } + if (!isset($process['t5']) || $process['t5'] == ''){ $t5 = 0; }else{ $t5 = $process['t5']; } + if (!isset($process['t6']) || $process['t6'] == ''){ $t6 = 0; }else{ $t6 = $process['t6']; } + if (!isset($process['t7']) || $process['t7'] == ''){ $t7 = 0; }else{ $t7 = $process['t7']; } + if (!isset($process['t8']) || $process['t8'] == ''){ $t8 = 0; }else{ $t8 = $process['t8']; } + if (!isset($process['t9']) || $process['t9'] == ''){ $t9 = 0; }else{ $t9 = $process['t9']; } + if (!isset($process['t10']) || $process['t10'] == ''){ $t10 = 0; }else{ $t10 = $process['t10']; } + if (!isset($process['t11']) || $process['t11'] == ''){ $t11 = 0; }else{ $t11 = $process['t11']; $showhero=1; } + + +for($i = 1; $i <= 11; $i++){ + $totalunits += (($i != 3 && $session->tribe == 3) || + ($i != 4 && $session->tribe != 3)) ? (!empty($process['t'.$i]) ? $process['t'.$i] : 0) : 0; } -} -} - -// Temp - -$ckey= $generator->generateRandStr(6); - - - if (!isset($process['t1']) || $process['t1'] == ''){ $t1='0'; }else{ $t1=$process['t1']; } - if (!isset($process['t2']) || $process['t2'] == ''){ $t2='0'; }else{ $t2=$process['t2']; } - if (!isset($process['t3']) || $process['t3'] == ''){ $t3='0'; }else{ $t3=$process['t3']; if ($session->tribe == 3){ $scout=1; } } - if (!isset($process['t4']) || $process['t4'] == ''){ $t4='0'; }else{ $t4=$process['t4']; if ($session->tribe == 1 || $session->tribe == 2 || $session->tribe == 4 || $session->tribe == 5){ $scout=1;} } - if (!isset($process['t5']) || $process['t5'] == ''){ $t5='0'; }else{ $t5=$process['t5']; } - if (!isset($process['t6']) || $process['t6'] == ''){ $t6='0'; }else{ $t6=$process['t6']; } - if (!isset($process['t7']) || $process['t7'] == ''){ $t7='0'; }else{ $t7=$process['t7']; } - if (!isset($process['t8']) || $process['t8'] == ''){ $t8='0'; }else{ $t8=$process['t8']; } - if (!isset($process['t9']) || $process['t9'] == ''){ $t9='0'; }else{ $t9=$process['t9']; } - if (!isset($process['t10']) || $process['t10'] == ''){ $t10='0'; }else{ $t10=$process['t10']; } - if (!isset($process['t11']) || $process['t11'] == ''){ $t11='0'; }else{ $t11=$process['t11']; $showhero=1;} - if ($session->tribe == 3){ - $totalunits = (!empty($process['t1']) ? $process['t1'] : 0) + - (!empty($process['t2']) ? $process['t2'] : 0) + - (!empty($process['t4']) ? $process['t4'] : 0) + - (!empty($process['t5']) ? $process['t5'] : 0) + - (!empty($process['t6']) ? $process['t6'] : 0) + - (!empty($process['t7']) ? $process['t7'] : 0) + - (!empty($process['t8']) ? $process['t8'] : 0) + - (!empty($process['t9']) ? $process['t9'] : 0) + - (!empty($process['t10']) ? $process['t10'] : 0) + - (!empty($process['t11']) ? $process['t11'] : 0); - - }else{ - $totalunits = (!empty($process['t1']) ? $process['t1'] : 0) + - (!empty($process['t2']) ? $process['t2'] : 0) + - (!empty($process['t3']) ? $process['t3'] : 0) + - (!empty($process['t5']) ? $process['t5'] : 0) + - (!empty($process['t6']) ? $process['t6'] : 0) + - (!empty($process['t7']) ? $process['t7'] : 0) + - (!empty($process['t8']) ? $process['t8'] : 0) + - (!empty($process['t9']) ? $process['t9'] : 0) + - (!empty($process['t10']) ? $process['t10'] : 0) + - (!empty($process['t11']) ? $process['t11'] : 0); - } + if (isset($scout) && $scout == 1 && isset($totalunits) && $totalunits == 0 && $process['c'] != 2) { $process['c'] = 1; } - $id = $database->addA2b($ckey,time(),$process['0'],$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$process['c']); - - - -if ($process['c']==1){ - -$actionType = "Scout"; - -}else if ($process['c']==2){ - -$actionType = "Reinforcement"; - -}elseif ($process['c']==3){ - -$actionType = "Normal attack"; +$id = $database->addA2b($ckey, time(), $process['0'], $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $process['c']); -}else{ - -$actionType = "Raid"; - -} +$actionType = (["Scout", "Reinforcement", "Normal attack", "Raid"])[$process['c'] - 1]; $uid = $session->uid; - $tribe = $session->tribe; -$start = ($tribe-1)*10+1; -$end = ($tribe*10); +$start = ($tribe - 1) * 10 + 1; +$end = $tribe * 10; ?>

@@ -204,12 +132,12 @@ $end = ($tribe*10); - + - + Destination: - "> + hasBeginnerProtection($village->wid)==1)&&($database->hasBeginnerProtection($process['0'])==0)){ - echo"Caution: Attacking a player will lose the protection!"; + if($database->hasBeginnerProtection($village->wid) == 1 && $database->hasBeginnerProtection($process['0']) == 0){ + echo"Caution: Attacking a player will lose the protection!"; } - if($database->hasBeginnerProtection($process['0'])==1) { + if($database->hasBeginnerProtection($process['0']) == 1) { echo"User presently has beginners protection"; } else { ?> diff --git a/Templates/a2b/attack_5.tpl b/Templates/a2b/attack_5.tpl deleted file mode 100644 index db0bc100..00000000 --- a/Templates/a2b/attack_5.tpl +++ /dev/null @@ -1,450 +0,0 @@ -getCoor($village->wid); - -$from = array('x'=>$eigen['x'], 'y'=>$eigen['y']); - -$to = array('x'=>$coor['x'], 'y'=>$coor['y']); - - $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,300,0)/$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); -} -} -} -// Temp - -$ckey= $generator->generateRandStr(6); - - - if (!isset($process['t1']) || $process['t1'] == ''){ $t1='0'; }else{ $t1=$process['t1']; } - if (!isset($process['t2']) || $process['t2'] == ''){ $t2='0'; }else{ $t2=$process['t2']; } - if (!isset($process['t3']) || $process['t3'] == ''){ $t3='0'; }else{ $t3=$process['t3']; $scout=1; } - if (!isset($process['t4']) || $process['t4'] == ''){ $t4='0'; }else{ $t4=$process['t4']; } - if (!isset($process['t5']) || $process['t5'] == ''){ $t5='0'; }else{ $t5=$process['t5']; } - if (!isset($process['t6']) || $process['t6'] == ''){ $t6='0'; }else{ $t6=$process['t6']; } - if (!isset($process['t7']) || $process['t7'] == ''){ $t7='0'; }else{ $t7=$process['t7']; } - if (!isset($process['t8']) || $process['t8'] == ''){ $t8='0'; }else{ $t8=$process['t8']; } - if (!isset($process['t9']) || $process['t9'] == ''){ $t9='0'; }else{ $t9=$process['t9']; } - if (!isset($process['t10']) || $process['t10'] == ''){ $t10='0'; }else{ $t10=$process['t10']; } - if (!isset($process['t11']) || $process['t11'] == ''){ $t11='0'; }else{ $t11=$process['t11']; } - $totalunits =$process['t1']+$process['t2']+$process['t4']+$process['t5']+$process['t6']+$process['t7']+$process['t8']+$process['t9']+$process['t10']+$process['t11']; - if ($scout==1 && $totalunits==0) { - -$process['c'] = 1; - -} - $id = $database->addA2b($ckey,time(),$process['0'],$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$process['c']); - - - -if ($process['c']==1){ - -$actionType = "Scout"; - -}else if ($process['c']==2){ - - -$actionType = "Normal attack"; - -}else{ - -$actionType = "Raid"; - -} - -?> - -

- -
- - - - - - - - - - - - - - - - - - - - - - - -
Destination: (|)
Owner:getUserField($process['2'],'username',0); ?>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0) - - { - - $speeds[] = ${'u'.(($session->tribe-5)*10+$i)}['speed']; - - if($i != 4) - - $scout = 0; - - } - - - - } - - } - - - - if($scout) - - $process['c'] = 1; - - $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); - } - } - } - ?> - - - - - - - - - -
">
PikemanThorned WarriorGuardsmanBird of PreyAxeriderNatarian KnightWar ElephantBalistaNatarian EmperorSettler
Troops0"; }else{ echo ">".$process['t1'];} ?>0"; }else{ echo ">".$process['t2'];} ?>0"; }else{ echo ">".$process['t3'];} ?>0"; }else{ echo ">".$process['t4'];} ?>0"; }else{ echo ">".$process['t5'];} ?>0"; }else{ echo ">".$process['t6'];} ?>0"; }else{ echo ">".$process['t7'];} ?>0"; }else{ $kata='1'; echo ">".$process['t8'];} ?>0"; }else{ echo ">".$process['t9'];} ?>0"; }else{ echo ">".$process['t10'];} ?>
Options">Scout resources and troops
- Scout defences and troops
Destination:"> - getTypeLevel(16) == 20) { ?> - - - - (will be attacked by catapult(s)) -
Destination: - ONLY shoot with a normal attack (they dont shoot with raids!)"; - ?> -
Arrived:"> - -
in getTimeFormat($time); ?>
- -
at procMtime(date('U')+$time,9)?> hours
- -
- - - - - - - - - - - - -

- - -
- -
\ No newline at end of file diff --git a/Templates/a2b/sendback.tpl b/Templates/a2b/sendback.tpl new file mode 100644 index 00000000..a2642f37 --- /dev/null +++ b/Templates/a2b/sendback.tpl @@ -0,0 +1,170 @@ +getVillage($enforce['from']); +$fromcoor = $database->getCoor($enforce['from']); +$tocoor = $database->getCoor($enforce['vref']); + +$fromCor = ['x'=>$tocoor['x'], 'y'=>$tocoor['y']]; +$toCor = ['x'=>$fromcoor['x'], 'y'=>$fromcoor['y']]; + +$att_tribe = $database->getUserField($to['owner'],'tribe',0); +$start = ($att_tribe - 1) * 10 + 1; +$end = $att_tribe * 10; +?> + +

Send units back

+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Destination: (|)
Owner:getUserField($to['owner'],'username',0); ?>
+ + + + + + + + + + +
Send units back to
+ + + "; + + ?> + + "; + + ?> + "; + + ?> + + + "; + + ?> + + + "; + + ?> + + "; + + ?> + "; + + ?> + "; + + ?> + + + "; + + ?> + "; + if($enforce['hero']>0){ + ?> + "; + } + ?> + + +
<?php echo $technology->getUnitName($start); ?> name="t1" value="" maxlength="6" type="text"> + (".$enforce['u'.$start].")<?php echo $technology->getUnitName($start + 3); ?> name="t4" value="" maxlength="6" type="text"> + (".$enforce['u'.($start + 3)].")<?php echo $technology->getUnitName($start + 6); ?> name="t7" value="" maxlength="6" type="text"> + (".$enforce['u'.($start + 6)].")<?php echo $technology->getUnitName($start + 8); ?> name="t9" value="" maxlength="6" type="text"> + (".$enforce['u'.($start + 8)].")
<?php echo $technology->getUnitName($start + 1); ?> name="t2" value="" maxlength="6" type="text"> + (".$enforce['u'.($start + 1)].")<?php echo $technology->getUnitName($start + 4); ?> name="t5" value="" maxlength="6" type="text"> + (".$enforce['u'.($start + 4)].")<?php echo $technology->getUnitName($start + 7); ?> name="t8" value="" maxlength="6" type="text"> + (".$enforce['u'.($start + 7)].")<?php echo $technology->getUnitName($start + 9); ?> name="t10" value="" maxlength="6" type="text"> + (".$enforce['u'.($start + 9)].")
<?php echo $technology->getUnitName($start + 2); ?> name="t3" value="" maxlength="6" type="text"> + (".$enforce['u'.($start + 2)].")<?php echo $technology->getUnitName($start + 5); ?> name="t6" value="" maxlength="6" type="text"> + (".$enforce['u'.($start + 5)].")Hero + (".$enforce['hero'].")
+ + + + + + + 0) + { + $speeds[] = ${'u'.$i}['speed']; + } + } + } + + if ($enforce['hero']>0){ + $qh = "SELECT unit FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0"; + $resulth = mysqli_query($database->dblink,$qh); + $hero_f=mysqli_fetch_array($resulth); + $hero_unit=$hero_f['unit']; + $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; + } + + $troopsTime = $generator->procDistanceTime($fromCor, $toCor, min($speeds), 1); + $time = $database->getTroopsWalkingTime($session->uid, $village->wid, 2, $troopsTime); + ?> + + + + +
Arrived: +
in getTimeFormat($time); ?>
+
at hours
+
+ + + + + + + + +

+ +
+ diff --git a/Templates/a2b/sendback_1.tpl b/Templates/a2b/sendback_1.tpl deleted file mode 100644 index 844d6c42..00000000 --- a/Templates/a2b/sendback_1.tpl +++ /dev/null @@ -1,190 +0,0 @@ -getVillage($enforce['from']); -$fromcoor = $database->getCoor($enforce['from']); -$tocoor = $database->getCoor($enforce['vref']); - - $fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']); - $toCor = array('x'=>$fromcoor['x'], 'y'=>$fromcoor['y']); -?> - -

Send units back

- -
- - - - - - - - - - - - - - - - - - - - - - - -
Destination: (|)
Owner:getUserField($to['owner'],'username',0); ?>
- - - - - - - - - - -
Send units back to
- - - "; - - ?> - - "; - - ?> - "; - - ?> - - - "; - - ?> - - - "; - - ?> - - "; - - ?> - "; - - ?> - "; - - ?> - - - "; - - ?> - "; - if($enforce['hero']>0){ - ?> - "; - } - ?> - - -
Legionnaire name="t1" value="" maxlength="6" type="text"> - (".$enforce['u1'].")Equites Legati name="t4" value="" maxlength="6" type="text"> - (".$enforce['u4'].")Battering Ram name="t7" value="" maxlength="6" type="text"> - (".$enforce['u7'].")Senator name="t9" value="" maxlength="6" type="text"> - (".$enforce['u9'].")
Praetorian name="t2" value="" maxlength="6" type="text"> - (".$enforce['u2'].")Equites Imperatoris name="t5" value="" maxlength="6" type="text"> - (".$enforce['u5'].")Fire Catapult name="t8" value="" maxlength="6" type="text"> - (".$enforce['u8'].")Settler name="t10" value="" maxlength="6" type="text"> - (".$enforce['u10'].")
Imperian name="t3" value="" maxlength="6" type="text"> - (".$enforce['u3'].")Equites Caesaris name="t6" value="" maxlength="6" type="text"> - (".$enforce['u6'].")Hero - (".$enforce['hero'].")
- - - - - - - getUserField($to['owner'],'tribe',0); - $start = ($att_tribe-1)*10+1; - $end = ($att_tribe*10); - $speeds = array(); - //find slowest unit. - for($i=$start;$i<=$end;$i++) - { - if (isset($enforce['u'.$i])) - { - if($enforce['u'.$i]!='' && $enforce['u'.$i]>0) - { - //$speeds[] = $unitspeeds[$i-2]; - $speeds[] = ${'u'.$i}['speed']; - } - } - } - if ($enforce['hero']>0){ - $qh = "SELECT unit FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0"; - $resulth = mysqli_query($database->dblink,$qh); - $hero_f=mysqli_fetch_array($resulth); - $hero_unit=$hero_f['unit']; - $speeds[] = $GLOBALS['u'.$hero_unit]['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($fromCor,$toCor,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); - } - } - } - ?> - - - - -
Arrived: -
in getTimeFormat($time); ?>
-
at hours
-
- - - - - - - - -

- -
- diff --git a/Templates/a2b/sendback_2.tpl b/Templates/a2b/sendback_2.tpl deleted file mode 100644 index 678d5676..00000000 --- a/Templates/a2b/sendback_2.tpl +++ /dev/null @@ -1,191 +0,0 @@ -getVillage($enforce['from']); -$fromcoor = $database->getCoor($enforce['from']); -$tocoor = $database->getCoor($enforce['vref']); - - $fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']); - $toCor = array('x'=>$fromcoor['x'], 'y'=>$fromcoor['y']); -?> - -

Send units back

- -
- - - - - - - - - - - - - - - - - - - - - - - -
Destination: (|)
Owner:getUserField($to['owner'],'username',0); ?>
- - - - - - - - - - -
Send units back to
- - - - "; - - ?> - - "; - - ?> - "; - - ?> - - - "; - - ?> - - - "; - - ?> - - "; - - ?> - "; - - ?> - "; - - ?> - - - "; - - ?> - "; - if($enforce['hero']>0){ - ?> - "; - } - ?> - - -
Clubswinger name="t1" value="" maxlength="6" type="text"> - (".$enforce['u11'].")Scout name="t4" value="" maxlength="6" type="text"> - (".$enforce['u14'].")Ram name="t7" value="" maxlength="6" type="text"> - (".$enforce['u17'].")Chief name="t9" value="" maxlength="6" type="text"> - (".$enforce['u19'].")
Spearman name="t2" value="" maxlength="6" type="text"> - (".$enforce['u12'].")Paladin name="t5" value="" maxlength="6" type="text"> - (".$enforce['u15'].")Catapult name="t8" value="" maxlength="6" type="text"> - (".$enforce['u18'].")Settler name="t10" value="" maxlength="6" type="text"> - (".$enforce['u20'].")
Axeman name="t3" value="" maxlength="6" type="text"> - (".$enforce['u13'].")Teutonic Knight name="t6" value="" maxlength="6" type="text"> - (".$enforce['u16'].")Hero - (".$enforce['hero'].")
- - - - - - - getUserField($to['owner'],'tribe',0); - $start = ($att_tribe-1)*10+1; - $end = ($att_tribe*10); - $speeds = array(); - //find slowest unit. - for($i=$start;$i<=$end;$i++) - { - if (isset($enforce['u'.$i])) - { - if($enforce['u'.$i]!='' && $enforce['u'.$i]>0) - { - //$speeds[] = $unitspeeds[$i-2]; - $speeds[] = ${'u'.$i}['speed']; - } - } - } - if ($enforce['hero']>0){ - $qh = "SELECT unit FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0"; - $resulth = mysqli_query($database->dblink,$qh); - $hero_f=mysqli_fetch_array($resulth); - $hero_unit=$hero_f['unit']; - $speeds[] = $GLOBALS['u'.$hero_unit]['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($fromCor,$toCor,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); - } - } - } - ?> - - - - -
Arrived: -
in getTimeFormat($time); ?>
-
at hours
-
- - - - - - - - -

- -
- diff --git a/Templates/a2b/sendback_3.tpl b/Templates/a2b/sendback_3.tpl deleted file mode 100644 index d65fa388..00000000 --- a/Templates/a2b/sendback_3.tpl +++ /dev/null @@ -1,190 +0,0 @@ -getVillage($enforce['from']); -$fromcoor = $database->getCoor($enforce['from']); -$tocoor = $database->getCoor($enforce['vref']); - - $fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']); - $toCor = array('x'=>$fromcoor['x'], 'y'=>$fromcoor['y']); -?> - -

Send units back

- -
- - - - - - - - - - - - - - - - - - - - - - - -
Destination: (|)
Owner:getUserField($to['owner'],'username',0); ?>
- - - - - - - - - - -
Send units back to
- - - - "; - - ?> - - "; - - ?> - "; - - ?> - - "; - - ?> - - - "; - - ?> - - "; - - ?> - "; - - ?> - "; - - ?> - - - "; - - ?> - "; - if($enforce['hero']>0){ - ?> - "; - } - ?> - - -
Phalanx name="t1" value="" maxlength="6" type="text"> - (".$enforce['u21'].")Theutates Thunder name="t4" value="" maxlength="6" type="text"> - (".$enforce['u24'].")Ram name="t7" value="" maxlength="6" type="text"> - (".$enforce['u27'].")Chieftain name="t9" value="" maxlength="6" type="text"> - (".$enforce['u29'].")
Swordsman name="t2" value="" maxlength="6" type="text"> - (".$enforce['u22'].")Druidrider name="t5" value="" maxlength="6" type="text"> - (".$enforce['u25'].")Trebuchet name="t8" value="" maxlength="6" type="text"> - (".$enforce['u28'].")Settler name="t10" value="" maxlength="6" type="text"> - (".$enforce['u30'].")
Pathfinder name="t3" value="" maxlength="6" type="text"> - (".$enforce['u23'].")Haeduan name="t6" value="" maxlength="6" type="text"> - (".$enforce['u26'].")Hero - (".$enforce['hero'].")
- - - - - - - getUserField($to['owner'],'tribe',0); - $start = ($att_tribe-1)*10+1; - $end = ($att_tribe*10); - $speeds = array(); - //find slowest unit. - for($i=$start;$i<=$end;$i++) - { - if (isset($enforce['u'.$i])) - { - if($enforce['u'.$i]!='' && $enforce['u'.$i]>0) - { - //$speeds[] = $unitspeeds[$i-2]; - $speeds[] = ${'u'.$i}['speed']; - } - } - } - if ($enforce['hero']>0){ - $qh = "SELECT unit FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0"; - $resulth = mysqli_query($database->dblink,$qh); - $hero_f=mysqli_fetch_array($resulth); - $hero_unit=$hero_f['unit']; - $speeds[] = $GLOBALS['u'.$hero_unit]['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($fromCor,$toCor,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); - } - } - } - ?> - - - - -
Arrived: -
in getTimeFormat($time); ?>
-
at hours
-
- - - - - - - - -

- -
- diff --git a/Templates/a2b/sendback_4.tpl b/Templates/a2b/sendback_4.tpl deleted file mode 100644 index 52f1c8c3..00000000 --- a/Templates/a2b/sendback_4.tpl +++ /dev/null @@ -1,191 +0,0 @@ -getVillage($enforce['from']); -$fromcoor = $database->getCoor($enforce['from']); -$tocoor = $database->getCoor($enforce['vref']); - - $fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']); - $toCor = array('x'=>$fromcoor['x'], 'y'=>$fromcoor['y']); -?> - -

Send units back

- -
- - - - - - - - - - - - - - - - - - - - - - - -
Destination: (|)
Owner:getUserField($to['owner'],'username',0); ?>
- - - - - - - - - - -
Send units back to
- - - - "; - - ?> - - "; - - ?> - "; - - ?> - - - "; - - ?> - - - "; - - ?> - - "; - - ?> - "; - - ?> - "; - - ?> - - - "; - - ?> - "; - if($enforce['hero']>0){ - ?> - "; - } - ?> - - -
Clubswinger name="t1" value="" maxlength="6" type="text"> - (".$enforce['u31'].")Scout name="t4" value="" maxlength="6" type="text"> - (".$enforce['u34'].")Ram name="t7" value="" maxlength="6" type="text"> - (".$enforce['u37'].")Chief name="t9" value="" maxlength="6" type="text"> - (".$enforce['u39'].")
Spearman name="t2" value="" maxlength="6" type="text"> - (".$enforce['u32'].")Paladin name="t5" value="" maxlength="6" type="text"> - (".$enforce['u35'].")Catapult name="t8" value="" maxlength="6" type="text"> - (".$enforce['u38'].")Settler name="t10" value="" maxlength="6" type="text"> - (".$enforce['u40'].")
Axeman name="t3" value="" maxlength="6" type="text"> - (".$enforce['u33'].")Teutonic Knight name="t6" value="" maxlength="6" type="text"> - (".$enforce['u36'].")Hero - (".$enforce['hero'].")
- - - - - - - getUserField($to['owner'],'tribe',0); - $start = ($att_tribe-1)*10+1; - $end = ($att_tribe*10); - $speeds = array(); - //find slowest unit. - for($i=$start;$i<=$end;$i++) - { - if (isset($enforce['u'.$i])) - { - if($enforce['u'.$i]!='' && $enforce['u'.$i]>0) - { - //$speeds[] = $unitspeeds[$i-2]; - $speeds[] = ${'u'.$i}['speed']; - } - } - } - if ($enforce['hero']>0){ - $qh = "SELECT unit FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0"; - $resulth = mysqli_query($database->dblink,$qh); - $hero_f=mysqli_fetch_array($resulth); - $hero_unit=$hero_f['unit']; - $speeds[] = $GLOBALS['u'.$hero_unit]['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($fromCor,$toCor,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); - } - } - } - ?> - - - - -
Arrived: -
in getTimeFormat($time); ?>
-
at hours
-
- - - - - - - - -

- -
- diff --git a/Templates/a2b/sendback_5.tpl b/Templates/a2b/sendback_5.tpl deleted file mode 100644 index 85641804..00000000 --- a/Templates/a2b/sendback_5.tpl +++ /dev/null @@ -1,191 +0,0 @@ -getVillage($enforce['from']); -$fromcoor = $database->getCoor($enforce['from']); -$tocoor = $database->getCoor($enforce['vref']); - - $fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']); - $toCor = array('x'=>$fromcoor['x'], 'y'=>$fromcoor['y']); -?> - -

Send units back

- -
- - - - - - - - - - - - - - - - - - - - - - - -
Destination: (|)
Owner:getUserField($to['owner'],'username',0); ?>
- - - - - - - - - - -
Send units back to
- - - "; - - ?> - - "; - - ?> - "; - - ?> - - - "; - - ?> - - - "; - - ?> - - "; - - ?> - "; - - ?> - "; - - ?> - - - "; - - ?> - "; - if($enforce['hero']>0){ - ?> - "; - } - ?> - - -
Pikeman name="t1" value="" maxlength="6" type="text"> - (".$enforce['u41'].")Bird of Prey name="t4" value="" maxlength="6" type="text"> - (".$enforce['u44'].")War Elephant name="t7" value="" maxlength="6" type="text"> - (".$enforce['u47'].")Natarian Emperor name="t9" value="" maxlength="6" type="text"> - (".$enforce['u49'].")
Thorned Warrior name="t2" value="" maxlength="6" type="text"> - (".$enforce['u42'].")Axerider name="t5" value="" maxlength="6" type="text"> - (".$enforce['u45'].")Balista name="t8" value="" maxlength="6" type="text"> - (".$enforce['u48'].")Settler name="t10" value="" maxlength="6" type="text"> - (".$enforce['u50'].")
Guardsman name="t3" value="" maxlength="6" type="text"> - (".$enforce['u3'].")Natarian Knight name="t6" value="" maxlength="6" type="text"> - (".$enforce['u6'].")Hero - (".$enforce['hero'].")
- - - - - - - tribe; - $start = ($att_tribe-1)*10+1; - $end = ($att_tribe*10); - $speeds = array(); - //find slowest unit. - for($i=$start;$i<=$end;$i++) - { - if (isset($enforce['u'.$i])) - { - if($enforce['u'.$i]!='' && $enforce['u'.$i]>0) - { - //$speeds[] = $unitspeeds[$i-2]; - $speeds[] = ${'u'.$i}['speed']; - } - } - } - if ($enforce['hero']>0){ - $qh = "SELECT unit FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0"; - $resulth = mysqli_query($database->dblink,$qh); - $hero_f=mysqli_fetch_array($resulth); - $hero_unit=$hero_f['unit']; - $speeds[] = $GLOBALS['u'.$hero_unit]['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($fromCor,$toCor,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); - } - } - } - ?> - - - - -
Arrived: -
in getTimeFormat($time); ?>
-
at hours
-
- - - - - - - - -

- -
- - diff --git a/a2b.php b/a2b.php index b678cf1d..2f61f134 100644 --- a/a2b.php +++ b/a2b.php @@ -154,7 +154,7 @@ if($enforce['vref'] == $village->wid) { $to = $database->getVillage($enforce['from']); $ckey = $w; - include ("Templates/a2b/sendback_" . $database->getUserField($to['owner'], 'tribe', 0) . ".tpl"); + include ("Templates/a2b/sendback.tpl"); } else { include ("Templates/a2b/units_" . $session->tribe . ".tpl"); include ("Templates/a2b/search.tpl"); @@ -166,7 +166,7 @@ if($enforce['from'] == $village->wid || $enforceoasis['conqured']==$village->wid) { $to = $database->getVillage($enforce['from']); $ckey = $r; - include ("Templates/a2b/sendback_" . $database->getUserField($to['owner'], 'tribe', 0) . ".tpl"); + include ("Templates/a2b/sendback.tpl"); } else { include ("Templates/a2b/units_" . $session->tribe . ".tpl"); include ("Templates/a2b/search.tpl"); @@ -201,20 +201,10 @@ $p_hero_unit=$p_hero_f['unit']; $p_speeds[] = $GLOBALS['u'.$p_hero_unit]['speed']; } - - $p_artefact = count($database->getOwnUniqueArtefactInfo2($p_owner,2,3,0)); - $p_artefact1 = count($database->getOwnUniqueArtefactInfo2($prisoner['from'],2,1,1)); - $p_artefact2 = count($database->getOwnUniqueArtefactInfo2($p_owner,2,2,0)); - if($p_artefact > 0){ - $p_fastertroops = 3; - }else if($p_artefact1 > 0){ - $p_fastertroops = 2; - }else if($p_artefact2 > 0){ - $p_fastertroops = 1.5; - }else{ - $p_fastertroops = 1; - } - $p_time = round($automation->procDistanceTime($p_to,$p_from,min($p_speeds),1)/$p_fastertroops); + + $troopsTime = $automation->procDistanceTime($p_to, $p_from, min($p_speeds), 1); + $p_time = $database->getTroopsWalkingTime($p_owner, $prisoner['from'], 2, $troopsTime); + $p_reference = $database->addAttack($prisoner['from'],$prisoner['t1'],$prisoner['t2'],$prisoner['t3'],$prisoner['t4'],$prisoner['t5'],$prisoner['t6'],$prisoner['t7'],$prisoner['t8'],$prisoner['t9'],$prisoner['t10'],$prisoner['t11'],3,0,0,0,0,0,0,0,0,0,0,0); $database->addMovement(4,$prisoner['wref'],$prisoner['from'],$p_reference,time(),($p_time+time())); $troops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11']; diff --git a/create_account.php b/create_account.php index 2c8f16e8..e3c47d57 100644 --- a/create_account.php +++ b/create_account.php @@ -517,15 +517,6 @@ function Artefact($uid, $type, $size, $art_name, $village_name, $desc, $effect, Artefact($uid, 8, 1, FOOL_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'typefool.gif'); } - unset($i); - unset($vname); - unset($effect); - $vname = FOOL_SMALLVILLAGE; - $effect = ''; - for($i = 0; $i < 5; $i++) { - Artefact($uid, 8, 2, FOOL_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'typefool.gif'); - } - unset($i); unset($vname); unset($effect); @@ -534,16 +525,16 @@ function Artefact($uid, $type, $size, $art_name, $village_name, $desc, $effect, for($i = 0; $i < 1; $i++) { Artefact($uid, 8, 3, FOOL_UNIQUE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'typefool.gif'); } + $myFile = "Templates/text.tpl"; $fh = fopen($myFile, 'w') or die("


Can't open file: templates/text.tpl"); $text = file_get_contents("Templates/text_format.tpl"); $text = preg_replace("'%TEKST%'",ARTEFACT ,$text); fwrite($fh, $text); - $query="UPDATE ".TB_PREFIX."users SET ok = 1"; - + $query = "UPDATE ".TB_PREFIX."users SET ok = 1"; echo "Done"; -}elseif(User::exists($database,'Natars')) { +}elseif(User::exists($database, 'Natars')) { ?>

Error: Natar account already exist