diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index fa9c3c40..28598f37 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -112,59 +112,10 @@ class Automation { } } - public function procResType($ref,$mode=0,$isoasis=0) { - global $session; - switch($ref) { - case 1: $build = "Woodcutter"; break; - case 2: $build = "Clay Pit"; break; - case 3: $build = "Iron Mine"; break; - case 4: $build = "Cropland"; break; - case 5: $build = "Sawmill"; break; - case 6: $build = "Brickyard"; break; - case 7: $build = "Iron Foundry"; break; - case 8: $build = "Grain Mill"; break; - case 9: $build = "Bakery"; break; - case 10: $build = "Warehouse"; break; - case 11: $build = "Granary"; break; - case 12: $build = "Blacksmith"; break; - case 13: $build = "Armoury"; break; - case 14: $build = "Tournament Square"; break; - case 15: $build = "Main Building"; break; - case 16: $build = "Rally Point"; break; - case 17: $build = "Marketplace"; break; - case 18: $build = "Embassy"; break; - case 19: $build = "Barracks"; break; - case 20: $build = "Stable"; break; - case 21: $build = "Workshop"; break; - case 22: $build = "Academy"; break; - case 23: $build = "Cranny"; break; - case 24: $build = "Town Hall"; break; - case 25: $build = "Residence"; break; - case 26: $build = "Palace"; break; - case 27: $build = "Treasury"; break; - case 28: $build = "Trade Office"; break; - case 29: $build = "Great Barracks"; break; - case 30: $build = "Great Stable"; break; - case 31: $build = "City Wall"; break; - case 32: $build = "Earth Wall"; break; - case 33: $build = "Palisade"; break; - case 34: $build = "Stonemason's Lodge"; break; - case 35: $build = "Brewery"; break; - case 36: $build = "Trapper"; break; - case 37: $build = "Hero's Mansion"; break; - case 38: $build = "Great Warehouse"; break; - case 39: $build = "Great Granary"; break; - case 40: $build = "Wonder of the World"; break; - case 41: $build = "Horse Drinking Trough"; break; - case 42: $build = "Great Workshop"; break; - //default: $build = "Nothing had"; break; - } - - if ($build=="" && !$mode) { //capital or only 1 village left.. not destroy - $build="Village can't be"; - } - - return addslashes($build); + public function procResType($ref, $mode = 0) { + global $building; + //Capital or only 1 village left = cannot be destroyed + return addslashes(empty($build = $building->procResType($ref)) && !$mode ? "Village can't be" : $build); } function recountPop($vid, $use_cache = true){ @@ -187,7 +138,6 @@ class Automation { $this->procClimbers($owner); return $popTot; - } function recountCP($vid){ @@ -208,7 +158,6 @@ class Automation { mysqli_query($database->dblink,$q); return $popTot; - } function buildingPOP($f,$lvl){ @@ -248,37 +197,38 @@ class Automation { $ourFileHandle = fopen($autoprefix."GameEngine/Prevention/loyalty.txt", 'w'); fclose($ourFileHandle); global $database; - $array = array(); + + $array = []; $array = $database->getProfileVillages(0, 6); if(!empty($array)) { foreach($array as $loyalty) { if (($t25_level = $this->getTypeLevel(25, $loyalty['wref'])) >= 1) { $value = $t25_level; - }elseif(($t26_level = $this->getTypeLevel(26,$loyalty['wref'])) >= 1){ + }elseif(($t26_level = $this->getTypeLevel(26, $loyalty['wref'])) >= 1){ $value = $t26_level; - } else { - $value = 0; } - $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdate2'])/(60*60)); - $q = "UPDATE ".TB_PREFIX."vdata SET loyalty = $newloyalty, lastupdate2=".time()." WHERE wref = '".$loyalty['wref']."'"; - $database->query($q); + else $value = 0; + + if($value > 0){ + $newloyalty = min(100, $loyalty['loyalty'] + $value * (time() - $loyalty['lastupdate2']) / 3600); + $q = "UPDATE ".TB_PREFIX."vdata SET loyalty = $newloyalty, lastupdate2=".time()." WHERE wref = '".$loyalty['wref']."'"; + $database->query($q); + } } } - $array = array(); + + $array = []; $q = "SELECT conqured, loyalty, lastupdated, wref FROM ".TB_PREFIX."odata WHERE loyalty < 100"; $array = $database->query_return($q); if(!empty($array)) { foreach($array as $loyalty) { - if(($t25_level = $this->getTypeLevel(25,$loyalty['conqured'])) >= 1){ - $value = $t25_level; - }elseif(($t26_level = $this->getTypeLevel(26,$loyalty['conqured'])) >= 1){ - $value = $t26_level; - } else { - $value = 0; - } - $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdated'])/(60*60)); - $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty, lastupdated=".time()." WHERE wref = '".$loyalty['wref']."'"; - $database->query($q); + $value = $this->getTypeLevel(37, $loyalty['conqured']); + + if($value > 0){ + $newloyalty = min(100, $loyalty['loyalty'] + $value * (time() - $loyalty['lastupdated']) / 3600); + $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty, lastupdated=".time()." WHERE wref = '".$loyalty['wref']."'"; + $database->query($q); + } } } } @@ -991,7 +941,7 @@ class Automation { if ($isSecondRow) { if ($tbid > 0) { $info_cat .= "Information - \"Catapult\" ".$this->procResType($tbgid, $can_destroy, $isoasis)." destroyed."; + \"Catapult\" ".$this->procResType($tbgid, $can_destroy)." destroyed."; } // embassy level was changed @@ -1001,7 +951,7 @@ class Automation { $info_cat .= ""; } else { - $info_cat = "".$catp_pic.", ".$this->procResType($tbgid, $can_destroy, $isoasis)." destroyed."; + $info_cat = "".$catp_pic.", ".$this->procResType($tbgid, $can_destroy)." destroyed."; // embassy level was changed if ($tbgid==18){ @@ -1015,10 +965,10 @@ class Automation { if ($isSecondRow) { if ($tbid > 0) { $info_cat .= "Information - \"Catapult\" ".$this->procResType($tbgid, $can_destroy, $isoasis)." was not damaged."; + \"Catapult\" ".$this->procResType($tbgid, $can_destroy)." was not damaged."; } } else { - $info_cat = "".$catp_pic.",".$this->procResType($tbgid, $can_destroy, $isoasis)." was not damaged."; + $info_cat = "".$catp_pic.",".$this->procResType($tbgid, $can_destroy)." was not damaged."; } } else @@ -1057,7 +1007,7 @@ class Automation { if ($isSecondRow) { $info_cat .= "Information - \"Catapult\" ".$this->procResType($tbgid, $can_destroy, $isoasis).$info_cata; + \"Catapult\" ".$this->procResType($tbgid, $can_destroy).$info_cata; // embassy level was changed if ($tbgid == 18) { @@ -1066,7 +1016,7 @@ class Automation { $info_cat .= ""; } else { - $info_cat = "" . $catp_pic . "," . $this->procResType($tbgid, $can_destroy,$isoasis).$info_cata; + $info_cat = "" . $catp_pic . "," . $this->procResType($tbgid, $can_destroy).$info_cata; // embassy level was changed if ($tbgid == 18) { diff --git a/GameEngine/Database.php b/GameEngine/Database.php index a5e66b52..447a9e65 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -7411,10 +7411,10 @@ References: User ID/Message ID, Mode return mysqli_query($this->dblink,$q); } - function delSlotFarm($id) { - list($id) = $this->escape_input((int) $id); - - $q = "DELETE FROM " . TB_PREFIX . "raidlist where id = $id"; + function delSlotFarm($id, $owner, $lid) { + list($id, $owner, $lid) = $this->escape_input((int) $id, (int) $owner, (int) $lid); + + $q = "DELETE FROM " . TB_PREFIX . "raidlist WHERE id = $id AND lid = $lid AND EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $lid AND owner = $owner)"; return mysqli_query($this->dblink,$q); } diff --git a/GameEngine/Message.php b/GameEngine/Message.php index 8ec850b0..36eaa7d0 100755 --- a/GameEngine/Message.php +++ b/GameEngine/Message.php @@ -15,7 +15,7 @@ class Message { public $note; public $inbox, $inbox1, $sent, $sent1, $reading, $reply, $archived, $archived1, $noticearray, $notice, $readingNotice = array(); private $totalMessage, $totalNotice; - private $allNotice = array(); + private $allNotice = []; function __construct() { $req_file = basename($_SERVER['PHP_SELF']); @@ -118,6 +118,7 @@ class Message { $this->noticearray = $this->filter_by_value($database->getNotice($session->uid), "ntype", $type); $this->notice = $this->filter_by_value($database->getNotice3($session->uid, $session->alliance), "ntype", $type); } + if(isset($get['id'])) { $this->readingNotice = $this->getReadNotice($get['id']); } diff --git a/Templates/Build/16.tpl b/Templates/Build/16.tpl index 8263113b..6282abab 100644 --- a/Templates/Build/16.tpl +++ b/Templates/Build/16.tpl @@ -8,14 +8,8 @@

resarray['f'.$id]; ?>

-
- | - | - goldclub==1){ ?>| - Gold Club - -
getMovement("34",$village->wid,1); $settlers = $database->getMovement("7",$village->wid,1); $oasis_incoming = 0; diff --git a/Templates/Build/16_99.tpl b/Templates/Build/16_99.tpl index 1572722c..8e161902 100644 --- a/Templates/Build/16_99.tpl +++ b/Templates/Build/16_99.tpl @@ -1,78 +1,60 @@ goldclub) { - include "Templates/Build/16.tpl"; - }else{ +if(!$session->goldclub) include("Templates/Build/16.tpl"); +else +{ ?>

resarray['f'.$id]; ?>

+ -
- | - | - goldclub==1){ ?>| - Gold Club - -
- -
- -
+
+ +

- +
- - - - + - villages)-1;$i++) { - $wref = $session->villages[$i]; - $vname = $database->getVillageField($wref,"name"); - $vchecked = $database->getVillageField($wref,"evasion"); - $reinf = $database->getEnforceVillage($wref,0); - if($vchecked == 1){ $checked = 'checked'; }else{ $checked = ''; } + for($i = 0; $i <= count($session->villages) - 1; $i++) { + $wref = $session->villages[$i]; + $vname = $database->getVillageField($wref, "name"); + $vchecked = $database->getVillageField($wref, "evasion"); + $reinf = $database->getEnforceVillage($wref, 0); + + if($vchecked == 1) $checked = 'checked'; + else $checked = ''; ?> - - - - - + + getUserArray($session->uid, 1); ?> -
>getUnitsNumber($wref); ?>
getUnitsNumber($wref); ?>
+

- - - (: Gold2 ) - - - -

- - + + (: Gold2 ) +

\ No newline at end of file diff --git a/Templates/Build/16_menu.tpl b/Templates/Build/16_menu.tpl new file mode 100644 index 00000000..edf1c3c3 --- /dev/null +++ b/Templates/Build/16_menu.tpl @@ -0,0 +1,8 @@ +
+ goldclub)) echo "class=\"selected\""; ?> > | + | + + goldclub == 1){ ?>| + >Gold Club + +
\ No newline at end of file diff --git a/Templates/Build/25_menu.tpl b/Templates/Build/25_menu.tpl index 9de4eed7..388d2952 100644 --- a/Templates/Build/25_menu.tpl +++ b/Templates/Build/25_menu.tpl @@ -1,7 +1,7 @@
- > - | > - | > - | > + > + | > + | > + | >
\ No newline at end of file diff --git a/Templates/a2b/startRaid.tpl b/Templates/a2b/startRaid.tpl index 3d04db70..776c9fa0 100644 --- a/Templates/a2b/startRaid.tpl +++ b/Templates/a2b/startRaid.tpl @@ -10,8 +10,7 @@ $sql1 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."units WHERE vref = ".(int) $getFLData['wref'])); $sid = $row['id']; $wref = $row['towref']; - $t1 = $row['t1'];$t2 = $row['t2'];$t3 = $row['t3'];$t4 = $row['t4'];$t5 = $row['t5']; - $t6 = $row['t6'];$t7 = $row['t7'];$t8 = $row['t8'];$t9 = $row['t9'];$t10 = $row['t10']; + for($i = 1; $i <= 10; $i++) ${'t'.$i} = $row['t'.$i]; $t11 = 0; $villageOwner = $database->getVillageField($wref,'owner'); $userAccess = $database->getUserField($villageOwner,'access',0); @@ -60,7 +59,7 @@ $id = $database->addA2b( $ckey, $time_now, $wref, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, 4 ); $data = $database->getA2b( $ckey, $time_now ); - + $troopsTime = $units->getWalkingTroopsTime($getFLData['wref'], $data['to_vid'], $session->uid, $session->tribe, $data, 1, 'u'); $time = $database->getArtifactsValueInfluence($getFLData['owner'], $getFLData['wref'], 2, $troopsTime); @@ -69,7 +68,7 @@ $reference = $database->addAttack( ( $getFLData['wref'] ), $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], $data['u7'], $data['u8'], $data['u9'], $data['u10'], $data['u11'], $data['type'], $ctar1, $ctar2, 0, $abdata['b1'], $abdata['b2'], $abdata['b3'], $abdata['b4'], $abdata['b5'], $abdata['b6'], $abdata['b7'], $abdata['b8'] ); $totalunits = $data['u1'] + $data['u2'] + $data['u3'] + $data['u4'] + $data['u5'] + $data['u6'] + $data['u7'] + $data['u8'] + $data['u9'] + $data['u10'] + $data['u11']; - $units = []; + $troops = []; $amounts = []; $modes = []; @@ -80,16 +79,16 @@ $unitKey = $uname2 . ($u < 10 ? $u : 0); } - $units[] = $unitKey; + $troops[] = $unitKey; $amounts[] = $data[ 'u' . $u]; $modes[] = 0; } - $units[] = 'hero'; + $troops[] = 'hero'; $amounts[] = $data['u11']; $modes[] = 0; - $database->modifyUnit($getFLData['wref'], $units, $amounts, $modes); + $database->modifyUnit($getFLData['wref'], $troops, $amounts, $modes); $database->addMovement(3, $getFLData['wref'], $data['to_vid'], $reference, time(), ($time + time())); // prevent re-use of the same attack via re-POSTing the same data diff --git a/Templates/goldClub/farmlist.tpl b/Templates/goldClub/farmlist.tpl index b4ade065..c84f4a1e 100644 --- a/Templates/goldClub/farmlist.tpl +++ b/Templates/goldClub/farmlist.tpl @@ -1,10 +1,10 @@ createFarmList($_POST['did'], $session->uid, $_POST['name']); -}else if(isset($_GET['t'])==99 && isset($_POST['action'])=='addList'){ +}else if(isset($_GET['t']) == 99 && isset($_POST['action']) == 'addList'){ header("Location: build.php?gid=16&t=99&action=addList"); exit; } @@ -31,12 +31,12 @@ while($row = mysqli_fetch_array($sql)){ - Loading... -
+
-
-
- +
+
+
@@ -44,7 +44,7 @@ while($row = mysqli_fetch_array($sql)){ - + @@ -54,7 +54,7 @@ while($row = mysqli_fetch_array($sql)){ $sql2 = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."raidlist WHERE lid = ".(int) $lid." ORDER BY distance ASC"); $query2 = mysqli_num_rows($sql2); if($query2 == 0) { - echo ''; + echo ''; }else{ while($row = mysqli_fetch_array($sql2)){ $id= $row['id'];$lid = $row['lid'];$towref = $row['towref'];$x = $row['x'];$y = $row['y']; @@ -240,11 +240,12 @@ while($row2 = mysqli_fetch_array($getnotice)){ -
-Add Raid +

+ +
-
+


- -
+ diff --git a/Templates/goldClub/farmlist_addraid.tpl b/Templates/goldClub/farmlist_addraid.tpl index 7c23bd43..0a36c632 100644 --- a/Templates/goldClub/farmlist_addraid.tpl +++ b/Templates/goldClub/farmlist_addraid.tpl @@ -2,63 +2,62 @@ $FLData = $database->getFLData($_GET['lid']); if($FLData['owner'] == $session->uid){ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) { + + $troops = 0; + for($i = 1; $i <= 10; $i++) $troops += $_POST['t'.$i]; + + if(!empty($_POST['target_id'])){ + $Wref = $_POST['target_id']; + $WrefCoor = $database->getCoor($Wref); + $WrefX = $WrefCoor['x']; + $WrefY = $WrefCoor['y']; + $type = $database->getVillageType2($Wref); + $oasistype = $type; + $vdata = $database->getVillage($Wref); + }elseif(!empty($_POST['x']) && !empty($_POST['y']) && is_numeric($_POST['x']) && is_numeric($_POST['y']) && $_POST['x'] <= WORLD_MAX && $_POST['y'] <= WORLD_MAX){ + $Wref = $database->getVilWref($_POST['x'], $_POST['y']); + $WrefX = $_POST['x']; + $WrefY = $_POST['y']; + $type = $database->getVillageType2($Wref); + $oasistype = $type; + $vdata = $database->getVillage($Wref); + } -$troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+".$_POST['t5']."+".$_POST['t6']."+".$_POST['t7']."+".$_POST['t8']."+".$_POST['t9']."+".$_POST['t10'].""; + if(empty($_POST['x']) && empty($_POST['y']) && empty($_POST['target_id'])) $errormsg = "Enter coordinates."; + elseif((empty($_POST['x']) || empty($_POST['y'])) && empty($_POST['target_id'])) $errormsg = "Enter the correct coordinates."; + elseif($oasistype == 0 && $vdata == 0) $errormsg = "There is no village on those coordinates."; + elseif($troops == 0) $errormsg = "No troops has been selected."; + elseif($database->hasBeginnerProtection($Wref) == 1) $errormsg = "Player under protection."; + elseif($_POST['target_id'] == $village->wid || $vdata['wref'] == $village->wid) $errormsg = "You can't attack the same village you send troops from."; + else + { -if($_POST['target_id'] != ""){ -$Wref = $_POST['target_id']; -$WrefCoor = $database->getCoor($Wref); -$WrefX = $WrefCoor['x']; -$WrefY = $WrefCoor['y']; -$type = $database->getVillageType2($Wref); -$oasistype = $type['oasistype']; -$vdata = $database->getVillage($Wref); -}elseif($_POST['x']!="" && $_POST['y']!="" && is_numeric($_POST['x']) && is_numeric($_POST['y']) && $_POST['x']<= WORLD_MAX && $_POST['y']<= WORLD_MAX){ -$Wref = $database->getVilWref($_POST['x'], $_POST['y']); -$WrefX = $_POST['x']; -$WrefY = $_POST['y']; -$type = $database->getVillageType2($Wref); -$oasistype = $type; -$vdata = $database->getVillage($Wref); -} - if($_POST['x']=="" && $_POST['y']=="" && $_POST['target_id'] == ""){ - $errormsg .= "Enter coordinates."; - }elseif(($_POST['x']=="" || $_POST['y']=="") && $_POST['target_id'] == ""){ - $errormsg .= "Enter the correct coordinates."; - }elseif($oasistype == 0 && $vdata == 0){ - $errormsg .= "There is no village on those coordinates."; - }elseif($troops == "0"){ - $errormsg .= "No troops has been selected."; - }elseif($database->hasBeginnerProtection($Wref)==1){ - $errormsg .= "Player under protection."; - }else{ - - if($_POST['target_id'] != ""){ - $Wref = $_POST['target_id']; - $WrefCoor = $database->getCoor($Wref); - $WrefX = $WrefCoor['x']; - $WrefY = $WrefCoor['y']; + if(!empty($_POST['target_id'])){ + $Wref = $_POST['target_id']; + $WrefCoor = $database->getCoor($Wref); + $WrefX = $WrefCoor['x']; + $WrefY = $WrefCoor['y']; }else{ - $Wref = $database->getVilWref($_POST['x'], $_POST['y']); - $WrefX = $_POST['x']; - $WrefY = $_POST['y']; + $Wref = $database->getVilWref($_POST['x'], $_POST['y']); + $WrefX = $_POST['x']; + $WrefY = $_POST['y']; } + $coor = $database->getCoor($village->wid); - function getDistance($coorx1, $coory1, $coorx2, $coory2) { - $max = 2 * WORLD_MAX + 1; - $x1 = intval($coorx1); - $y1 = intval($coory1); - $x2 = intval($coorx2); - $y2 = intval($coory2); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); - return round($dist, 1); - } - - $distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); + function getDistance($coorx1, $coory1, $coorx2, $coory2) { + $max = 2 * WORLD_MAX + 1; + $x1 = intval($coorx1); + $y1 = intval($coory1); + $x2 = intval($coorx2); + $y2 = intval($coory2); + $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); + $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); + $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); + return round($dist, 1); + } + $distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); $database->addSlotFarm($_POST['lid'], $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']); header("Location: build.php?id=39&t=99"); @@ -79,9 +78,9 @@ $vdata = $database->getVillage($Wref); -
Pop Distance TroopsLastRaidLast raid
There is not any raid list.There are no village.
+
- + - +
Farm Name:List name:
Select target:Target village:
@@ -111,35 +110,35 @@ $lvname = $database->getVillageField($row["wref"], 'name');
+
+
@@ -150,10 +149,9 @@ $vill[$towref] = 1;
- - - - + +
+ diff --git a/Templates/goldClub/farmlist_editraid.tpl b/Templates/goldClub/farmlist_editraid.tpl index 69e7c9af..0709c9e3 100644 --- a/Templates/goldClub/farmlist_editraid.tpl +++ b/Templates/goldClub/farmlist_editraid.tpl @@ -1,65 +1,67 @@ getRaidList($_GET['eid']); -$x = $eiddata['x']; -$y = $eiddata['y']; -$t1 = $eiddata['t1'];$t2 = $eiddata['t2'];$t3 = $eiddata['t3'];$t4 = $eiddata['t4'];$t5 = $eiddata['t5'];$t6 = $eiddata['t6'];$t7 = $eiddata['t7'];$t8 = $eiddata['t8'];$t9 = $eiddata['t9'];$t10 = $eiddata['t10']; -$FLData = $database->getFLData($eiddata['lid']); + $eiddata = $database->getRaidList($_GET['eid']); + $x = $eiddata['x']; + $y = $eiddata['y']; + for($i = 1; $i <= 10; $i++) ${'t'.$i} = $eiddata['t'.$i]; + $FLData = $database->getFLData($eiddata['lid']); } if(isset($_POST['action']) == 'editSlot' && $_POST['eid']) { -if($_POST['target_id'] != ""){ -$Wref = $_POST['target_id']; -$WrefCoor = $database->getCoor($Wref); -$WrefX = $WrefCoor['x']; -$WrefY = $WrefCoor['y']; -$type = $database->getVillageType2($Wref); -$oasistype = $type['oasistype']; -$vdata = $database->getVillage($Wref); -}elseif($_POST['x']!="" && $_POST['y']!="" && is_numeric($_POST['x']) && is_numeric($_POST['y'])){ -$Wref = $database->getVilWref($_POST['x'], $_POST['y']); -$WrefX = $_POST['x']; -$WrefY = $_POST['y']; -$type = $database->getVillageType2($Wref); -$oasistype = $type['oasistype']; -$vdata = $database->getVillage($Wref); -} -$troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+".$_POST['t5']."+".$_POST['t6']."+".$_POST['t7']."+".$_POST['t8']."+".$_POST['t9']."+".$_POST['t10'].""; + if(!empty($_POST['target_id'])){ + $Wref = $_POST['target_id']; + $WrefCoor = $database->getCoor($Wref); + $WrefX = $WrefCoor['x']; + $WrefY = $WrefCoor['y']; + $type = $database->getVillageType2($Wref); + $oasistype = $type; + $vdata = $database->getVillage($Wref); + }elseif(!empty($_POST['x']) && !empty($_POST['y']) && is_numeric($_POST['x']) && is_numeric($_POST['y'])){ + $Wref = $database->getVilWref($_POST['x'], $_POST['y']); + $WrefX = $_POST['x']; + $WrefY = $_POST['y']; + $type = $database->getVillageType2($Wref); + $oasistype = $type; + $vdata = $database->getVillage($Wref); + } - if($_POST['x']=="" && $_POST['y']=="" && $_POST['target_id'] == ""){ - $errormsg .= "Enter coordinates."; - }elseif(($_POST['x']=="" || $_POST['y']=="") && $_POST['target_id'] == ""){ - $errormsg .= "Enter the correct coordinates."; - }elseif($oasistype == 0 && $vdata == 0){ - $errormsg .= "There is no village on those coordinates."; - }elseif($troops == "0"){ - $errormsg .= "No troops has been selected."; - }else{ + $troops = 0; + for($i = 1; $i <= 10; $i++) $troops += $_POST['t'.$i]; + + if(empty($_POST['x']) && empty($_POST['y']) && empty($_POST['target_id'])) $errormsg = "Enter coordinates."; + elseif((empty($_POST['x']) || empty($_POST['y'])) && empty($_POST['target_id'])) $errormsg = "Enter the correct coordinates."; + elseif($oasistype == 0 && $vdata == 0) $errormsg = "There is no village on those coordinates."; + elseif($troops == 0) $errormsg = "No troops has been selected."; + elseif($database->hasBeginnerProtection($Wref) == 1) $errormsg = "Player under protection."; + elseif($_POST['target_id'] == $village->wid || $vdata['wref'] == $village->wid) $errormsg = "You can't attack the same village you send troops from."; + else + { - if($_POST['target_id'] != ""){ - $Wref = $_POST['target_id']; - $WrefCoor = $database->getCoor($Wref); - $WrefX = $WrefCoor['x']; - $WrefY = $WrefCoor['y']; + if(!empty($_POST['target_id'])){ + $Wref = $_POST['target_id']; + $WrefCoor = $database->getCoor($Wref); + $WrefX = $WrefCoor['x']; + $WrefY = $WrefCoor['y']; }else{ - $Wref = $database->getVilWref($_POST['x'], $_POST['y']); - $WrefX = $_POST['x']; - $WrefY = $_POST['y']; + $Wref = $database->getVilWref($_POST['x'], $_POST['y']); + $WrefX = $_POST['x']; + $WrefY = $_POST['y']; } $coor = $database->getCoor($village->wid); - function getDistance($coorx1, $coory1, $coorx2, $coory2) { - $max = 2 * WORLD_MAX + 1; - $x1 = intval($coorx1); - $y1 = intval($coory1); - $x2 = intval($coorx2); - $y2 = intval($coory2); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); - return round($dist, 1); - } - $distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); + function getDistance($coorx1, $coory1, $coorx2, $coory2) { + $max = 2 * WORLD_MAX + 1; + $x1 = intval($coorx1); + $y1 = intval($coory1); + $x2 = intval($coorx2); + $y2 = intval($coory2); + $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); + $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); + $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); + return round($dist, 1); + } + + $distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); $database->editSlotFarm($_GET['eid'], $_POST['lid'], $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']); @@ -87,7 +89,7 @@ $lid2 = $getlid['lid']; - +
Farm Name: @@ -117,13 +119,14 @@ $lvname = $database->getVillageField($row["wref"], 'name'); +
-
+