Farmlist improvements and fixes

+Troops while adding/editing a raid lists are now inside of a table,
this is a graphic enhancement
+Reduced the X and Y textboxes size while adding/editing a raid list
+Fixed a bug that didn't permit to add a raid list
+Fixed a bug that did permit to insert spies in raid lists
+The farmlists graphic is now more clear, "Add raid" and "Start raid"
are now two general buttons, instead of having two buttons for raid list
+"Select all" checkbox, will select all raid without refreshing the page
(through JS)
+Moved the function "getDistance" to Database.php
+Removed a lot of redundant code from crop_finder.php
+Removed rams, catapults, chiefs and settlers from the raid list,
because the first three can't even loot resources
+Removed trooplist2.tpl because of a more general unique template file
(trooplist.tpl)
+Some minor improvements and bug fixing

IMPORTANT NOTE: if you don't want to reinstal the whole server, you can
simply run this little query (where "s1_" is the prefix of your server):

ALTER TABLE `s1_raidlist` DROP `t7`, DROP `t8`, DROP `t9`, DROP `t10`;
This commit is contained in:
iopietro
2018-05-16 16:49:25 +02:00
parent 656bd4f970
commit bdd3bfd41c
16 changed files with 340 additions and 863 deletions
+31 -41
View File
@@ -1,8 +1,16 @@
<?php
if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
$troops = 0;
for($i = 1; $i <= 10; $i++) $troops += $_POST['t'.$i];
//If the player has no farm lists, return
if(!$database->getVilFarmlist($session->uid)){
header("Location: build.php?id=39&t=99");
exit;
}
if(isset($_POST['action']) && $_POST['action'] == 'addSlot' && isset($_POST['lid']) && $database->getFLData($_POST['lid'])['owner'] == $session->uid) {
$troops = 0;
for($i = 1; $i <= 6; $i++){
if(!in_array($i + ($session->tribe - 1) * 10, [4, 14, 23])) $troops += $_POST['t'.$i];
}
if(!empty($_POST['target_id'])){
$Wref = $_POST['target_id'];
@@ -40,23 +48,10 @@ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
$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);
$database->addSlotFarm($_POST['lid'], $session->uid, $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
$coor = $database->getCoor($village->wid);
$distance = $database->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']);
header("Location: build.php?id=39&t=99");
exit;
}
@@ -83,12 +78,8 @@ $sql = mysqli_query($database->dblink, "SELECT id, name, owner, wref FROM ".TB_P
while($row = mysqli_fetch_array($sql)){
$lid = $row["id"];
$lname = $row["name"];
$lowner = $row["owner"];
$lwref = $row["wref"];
$lvname = $database->getVillageField($row["wref"], 'name');
if($_GET['lid'] == $lid) $selected = 'selected=""';
else $selected = '';
echo '<option value="'.$lid.'" '.$selected.'>'.$lvname.' - '.$lname.'</option>';
echo '<option value="'.$lid.'">'.$lvname.' - '.$lname.'</option>';
}
?>
</select>
@@ -115,22 +106,21 @@ $sql = mysqli_query($database->dblink, "SELECT id, name, owner, wref FROM ".TB_P
<label class="lastTargets">Last targets:</label>
<select name="target_id">
<?php
$getwref = "SELECT towref FROM ".TB_PREFIX."raidlist WHERE lid = ".$database->escape((int) $_GET['lid'])."";
$getwref = "SELECT movement.to, movement.ref, attacks.* FROM ".TB_PREFIX."movement as movement INNER JOIN ".TB_PREFIX."attacks as attacks ON attacks.id = movement.ref WHERE attacks.attack_type = 4 AND movement.proc = 1 AND movement.from = ".$village->wid;
$arraywref = $database->query_return($getwref);
echo '<option value="">Select village</option>';
if(mysqli_num_rows(mysqli_query($database->dblink,$getwref)) != 0){
foreach($arraywref as $row){
$towref = $row["towref"];
$tocoor = $database->getCoor($towref);
$totype = $database->getVillageType2($towref);
if($totype == 0) $tovname = $database->getVillageField($towref, 'name');
else $tovname = $database->getOasisField($towref, 'name');
if($vill[$towref] == 0){
echo '<option value="'.$towref.'">'.$tovname.' ('.$tocoor['x'].'|'.$tocoor['y'].')</option>';
}
$vill[$towref] = 1;
}
if(mysqli_num_rows(mysqli_query($database->dblink, $getwref)) != 0){
foreach($arraywref as $row){
$towref = $row["to"];
$vilInfo = $database->getVillageByWorldID($towref);
if($vilInfo['fieldtype'] > 0 && !$vilInfo['occupied']) continue;
$tocoor = $database->getCoor($towref);
if($vilInfo['oasistype'] == 0) $tovname = $database->getVillageField($towref, 'name');
else $tovname = $database->getOasisField($towref, 'name');
if($vill[$towref] == 0) echo '<option value="'.$towref.'">'.$tovname.' ('.$tocoor['x'].'|'.$tocoor['y'].')</option>';
$vill[$towref] = 1;
}
}
?>
</select>
@@ -141,7 +131,7 @@ if(mysqli_num_rows(mysqli_query($database->dblink,$getwref)) != 0){
</tbody></table>
</div>
</div>
<?php include("Templates/goldClub/trooplist2.tpl"); ?>
<?php include("Templates/goldClub/trooplist.tpl"); ?>
<br />
<button type="submit" value="save" name="save" id="save" class="trav_buttons">Create</button>
</form>