mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-06 04:44:21 +00:00
improve farmlist (not 100%)
This commit is contained in:
+28
-230
@@ -2,13 +2,15 @@
|
||||
|
||||
if(isset($_GET['t'])==99 && isset($_GET['action'])==0) {
|
||||
|
||||
if(isset($_GET['t'])==99 && isset($_POST['action'])=='addList'){
|
||||
if(isset($_GET['t'])==99 && isset($_POST['action'])=='addList' && $_POST['did']!="" && $_POST['name']!=""){
|
||||
$database->createFarmList($_POST['did'], $session->uid, $_POST['name']);
|
||||
}else if(isset($_GET['t'])==99 && isset($_POST['action'])=='addList'){
|
||||
header("Location: build.php?gid=16&t=99&action=addList");
|
||||
}
|
||||
|
||||
$sql = mysql_query("SELECT * FROM ".TB_PREFIX."farmlist WHERE owner = $session->uid ORDER BY wref = $village->wid DESC");
|
||||
$query = mysql_num_rows($sql);
|
||||
while($row = mysql_fetch_array($sql)){
|
||||
while($row = mysql_fetch_array($sql)){
|
||||
$lid = $row["id"];
|
||||
$lname = $row["name"];
|
||||
$lowner = $row["owner"];
|
||||
@@ -68,9 +70,12 @@ $vdata = $database->getVillage($towref);
|
||||
?>
|
||||
<tr class="slotRow">
|
||||
<td class="checkbox">
|
||||
|
||||
<?php if($checked[$lid] == 0){ ?>
|
||||
<input id="slot<?php echo $id; ?>" name="slot[<?php echo $id; ?>]" type="checkbox" class="markSlot" onclick="Travian.Game.RaidList.markSlotForRaid(<?php echo $lid; ?>, <?php echo $id; ?>, this.checked);">
|
||||
</td>
|
||||
<?php }else{ ?>
|
||||
<input id="slot<?php echo $id; ?>" name="slot[<?php echo $id; ?>]" type="checkbox" class="markSlot" checked>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="village">
|
||||
<?php
|
||||
|
||||
@@ -96,9 +101,9 @@ $vdata = $database->getVillage($towref);
|
||||
<span class="coordinates coordinatesWithText">
|
||||
<span class="coordText">Oasis</span>
|
||||
<span class="coordinatesWrapper">
|
||||
<span class="coordinateY"><?php echo $y; ?>)</span>
|
||||
<span class="coordinateY">(<?php echo $x; ?></span>
|
||||
<span class="coordinatePipe">|</span>
|
||||
<span class="coordinateX">(<?php echo $x; ?></span>
|
||||
<span class="coordinateX"><?php echo $y; ?>)</span>
|
||||
</span></span>
|
||||
<?php }else{ ?>
|
||||
<span class="coordinates coordinatesWithText">
|
||||
@@ -109,7 +114,7 @@ $vdata = $database->getVillage($towref);
|
||||
<span class="clear"></span>
|
||||
</label>
|
||||
</td>
|
||||
<td class="ew"><?php echo $vdata['pop']; ?></td>
|
||||
<td class="ew"><?php if($oasistype == 0){ echo $vdata['pop']; }else{ echo "<center>-</center>"; }; ?></td>
|
||||
<td class="distance"><?php echo $distance; ?></td>
|
||||
<td class="troops">
|
||||
|
||||
@@ -187,9 +192,9 @@ $vdata = $database->getVillage($towref);
|
||||
<td class="lastRaid">
|
||||
<?php
|
||||
$noticeClass = array("Scout Report","Won as attacker without losses","Won as attacker with losses","Lost as attacker with losses","Won as defender without losses","Won as defender with losses","Lost as defender with losses","Lost as defender without losses","Reinforcement arrived","","Wood Delivered","Clay Delivered","Iron Delivered","Crop Delivered","","Won as defender without losses","Won as defender with losses","Lost as defender with losses","Won scouting as attacker","Lost scouting as attacker","Won scouting as defender","Lost scouting as defender");
|
||||
$limits = "ntype!=4 and ntype!=5 and ntype!=6 and ntype!=7";
|
||||
$limits = "(ntype=1 or ntype=2 or ntype=3 or ntype=18 or ntype=19 or ntype=22)";
|
||||
$getnotice = mysql_query("SELECT * FROM ".TB_PREFIX."ndata WHERE $limits AND toWref = ".$towref." ORDER BY time DESC Limit 1");
|
||||
|
||||
if(mysql_num_rows($getnotice) > 0){
|
||||
while($row2 = mysql_fetch_array($getnotice)){
|
||||
$dataarray = explode(",",$row2['data']);
|
||||
$type2 = $row2['ntype'];
|
||||
@@ -211,11 +216,12 @@ while($row2 = mysql_fetch_array($getnotice)){
|
||||
$date = $generator->procMtime($row2['time']);
|
||||
echo "<a href=\"berichte.php?id=".$row2['id']."\">".$date[0]." ".date('H:i',$row2['time'])."</a> ";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="clear"></div>
|
||||
</td>
|
||||
<td class="action">
|
||||
<a class="arrow" href="#" onclick="Travian.Game.RaidList.editSlot(<?php echo $lid; ?>, <?php echo $id; ?>); return false;">edit</a>
|
||||
<a class="arrow" href="build.php?id=39&t=99&action=showSlot&eid=<?php echo $id; ?>">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
@@ -226,12 +232,16 @@ while($row2 = mysql_fetch_array($getnotice)){
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="markAll">
|
||||
<input type="checkbox" id="raidListMarkAll<?php echo $lid; ?>" class="markAll" onclick="Travian.Game.RaidList.markAllSlotsOfAListForRaid(<?php echo $lid; ?>, this.checked);">
|
||||
<?php if($checked[$lid] == 0){ ?>
|
||||
<input type="checkbox" id="raidListMarkAll<?php echo $lid; ?>" class="markAll" onclick="window.location.href = '?gid=16&t=99&slid=<?php echo $lid; ?>';">
|
||||
<?php }else{ ?>
|
||||
<input type="checkbox" id="raidListMarkAll<?php echo $lid; ?>" class="markAll" onclick="window.location.href = '?gid=16&t=99';" checked>
|
||||
<?php } ?>
|
||||
<label for="raidListMarkAll<?php echo $lid; ?>">Select All</label>
|
||||
</div>
|
||||
|
||||
<div class="addSlot">
|
||||
<a href="build.php?id=39&t=99&action=showSlot&lid=">Add Raid</a>
|
||||
<a href="build.php?id=39&t=99&action=addraid&lid=<?php echo $lid; ?>">Add Raid</a>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
||||
@@ -253,7 +263,7 @@ for($i=$start;$i<=$end;$i++){
|
||||
<button type="submit" value="Start Raid"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">Start Raid</div></div></button> </div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<?php }else{ ?>
|
||||
<div id="list<?php echo $lid; ?>" class="listEntry">
|
||||
<div class="round spacer listTitle" onclick="Travian.Game.RaidList.toggleList(<?php echo $lid; ?>);">
|
||||
@@ -349,222 +359,10 @@ $NUM1++;
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
|
||||
|
||||
$troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+".$_POST['t5']."+".$_POST['t6']."+".$_POST['t7']."+".$_POST['t8']."+".$_POST['t9']."+".$_POST['t10']."";
|
||||
|
||||
if($_POST['x'] && $_POST['y']){
|
||||
$Wref = $database->getVilWref($_POST['y'], $_POST['x']);
|
||||
$type = $database->getVillageType2($Wref);
|
||||
$oasistype = $type['oasistype'];
|
||||
$vdata = $database->getVillage($Wref);
|
||||
}
|
||||
if(!$_POST['x'] && !$_POST['y']){
|
||||
$errormsg .= "Enter coordinates.";
|
||||
}elseif(!$_POST['x'] || !$_POST['y']){
|
||||
$errormsg .= "Enter the correct coordinates.";
|
||||
}elseif($oasistype == 0 && $vdata == 0){
|
||||
$errormsg .= "In this village there are no coordinates.";
|
||||
}elseif($troops == 0){
|
||||
$errormsg .= "No troops has been selected.";
|
||||
}else{
|
||||
|
||||
$Wref = $database->getVilWref($_POST['y'], $_POST['x']);
|
||||
$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'], $_POST['y'], $_POST['x']);
|
||||
|
||||
$database->addSlotFarm($_POST['lid'], $Wref, $_POST['x'], $_POST['y'], $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");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
var targets = {};
|
||||
|
||||
function fillTargets()
|
||||
{
|
||||
var targetId = $('target_id');
|
||||
|
||||
targetId.empty();
|
||||
|
||||
var option = new Element('option',
|
||||
{
|
||||
'html': 'Choose a village'
|
||||
});
|
||||
targetId.insert(option);
|
||||
|
||||
$each(targets[lid], function(data)
|
||||
{
|
||||
var option = new Element('option',
|
||||
{
|
||||
'value': data.did,
|
||||
'html': data.name
|
||||
});
|
||||
targetId.insert(option);
|
||||
});
|
||||
}
|
||||
|
||||
function getTargetsByLid()
|
||||
{
|
||||
var lidSelect = $('lid');
|
||||
lid = lidSelect.getSelected()[0].value;
|
||||
|
||||
if (targets[lid])
|
||||
{
|
||||
fillTargets();
|
||||
}
|
||||
else
|
||||
{
|
||||
Travian.ajax(
|
||||
{
|
||||
data:
|
||||
{
|
||||
cmd: 'raidListTargets',
|
||||
'lid': lid
|
||||
},
|
||||
onSuccess: function(data)
|
||||
{
|
||||
targets[data.lid] = data.targets;
|
||||
fillTargets();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function selectCoordinates()
|
||||
{
|
||||
var targetId = $('target_id');
|
||||
var did = targetId.getSelected()[0].value;
|
||||
|
||||
if (did == '')
|
||||
{
|
||||
$('xCoordInput').value = '';
|
||||
$('yCoordInput').value = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
var array;
|
||||
$each(targets[lid], function(data)
|
||||
{
|
||||
if (data.did == did)
|
||||
{
|
||||
array = data;
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('xCoordInput').value = array.x;
|
||||
$('yCoordInput').value = array.y;
|
||||
}
|
||||
}
|
||||
|
||||
var lid = <?php echo $_GET['lid']; ?>;targets[lid] = {};
|
||||
|
||||
</script>
|
||||
<?php if($create == 1){
|
||||
include("Templates/goldClub/farmlist_add.tpl");
|
||||
}else if($query > 1){ ?>
|
||||
<div id="raidListSlot">
|
||||
<h4>Add Raid</h4>
|
||||
<font color="#FF0000"><b>
|
||||
<?php echo $errormsg; ?>
|
||||
</b></font>
|
||||
|
||||
<form action="build.php?id=39&t=99&action=showSlot&lid=<?php echo $_GET['lid']; ?>" method="post">
|
||||
<div class="boxes boxesColor gray"><div class="boxes-tl"></div><div class="boxes-tr"></div><div class="boxes-tc"></div><div class="boxes-ml"></div><div class="boxes-mr"></div><div class="boxes-mc"></div><div class="boxes-bl"></div><div class="boxes-br"></div><div class="boxes-bc"></div><div class="boxes-contents cf">
|
||||
|
||||
<input type="hidden" name="action" value="addSlot">
|
||||
<input type="hidden" name="lid" value="<?php echo $_GET['lid']; ?>">
|
||||
|
||||
|
||||
<table cellpadding="1" cellspacing="1" class="transparent">
|
||||
<tbody><tr>
|
||||
<th>From List</th>
|
||||
<td>
|
||||
<select onchange="getTargetsByLid();" id="lid" name="lid">
|
||||
<?php
|
||||
|
||||
$sql = mysql_query("SELECT * FROM ".TB_PREFIX."farmlist WHERE owner = $session->uid ORDER BY name ASC");
|
||||
while($row = mysql_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>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Coordinates:</th>
|
||||
<td class="target">
|
||||
|
||||
<div class="coordinatesInput">
|
||||
<div class="xCoord">
|
||||
<label for="xCoordInput">X:</label>
|
||||
<input value="<?php echo $_POST['y']; ?>" name="y" id="xCoordInput" class="text coordinates y ">
|
||||
</div>
|
||||
<div class="yCoord">
|
||||
<label for="yCoordInput">Y:</label>
|
||||
<input value="<?php echo $_POST['x']; ?>" name="x" id="yCoordInput" class="text coordinates x ">
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="targetSelect">
|
||||
<label class="lastTargets" for="last_targets">Villiages</label>
|
||||
<select id="target_id" name="target_id" onchange="selectCoordinates()">
|
||||
<?php
|
||||
|
||||
$sql1 = mysql_query("SELECT * FROM ".TB_PREFIX."farmlist WHERE owner = $session->uid ORDER BY name ASC");
|
||||
while($row1 = mysql_fetch_array($sql1)){
|
||||
$lid1 = $row1["id"];
|
||||
$lname1 = $row1["name"];
|
||||
$lowner1 = $row1["owner"];
|
||||
$lwref1 = $row1["wref"];
|
||||
$lvname1 = $database->getVillageField($row1["wref"], 'name');
|
||||
if($_GET['lid']==$lid){
|
||||
$selected = 'selected=""';
|
||||
}else{ $selected = ''; }
|
||||
echo '<option value="'.$lwref1.'" '.$selected1.'>'.$lvname1.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</div>
|
||||
</div>
|
||||
<?php include "Templates/goldClub/trooplist.tpl"; ?>
|
||||
|
||||
|
||||
<button type="submit" value="Add" name="save" id="save"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">Add</div></div></button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
}else if($create == 2){
|
||||
include("Templates/goldClub/farmlist_addraid.tpl");
|
||||
}else if($create == 3){
|
||||
include("Templates/goldClub/farmlist_editraid.tpl");
|
||||
}
|
||||
@@ -1,18 +1,29 @@
|
||||
<?php
|
||||
|
||||
$FLData = $database->getFLData($_GET['lid']);
|
||||
if($FLData['owner'] == $session->uid){
|
||||
if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
|
||||
|
||||
$troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+".$_POST['t5']."+".$_POST['t6']."+".$_POST['t7']."+".$_POST['t8']."+".$_POST['t9']."+".$_POST['t10']."";
|
||||
|
||||
if($_POST['x'] && $_POST['y']){
|
||||
$Wref = $database->getVilWref($_POST['y'], $_POST['x']);
|
||||
$type = $database->getVillageType2($Wref);
|
||||
$oasistype = $type['oasistype'];
|
||||
$vdata = $database->getVillage($Wref);
|
||||
}
|
||||
if(!$_POST['x'] && !$_POST['y']){
|
||||
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']){
|
||||
$Wref = $database->getVilWref($_POST['x'], $_POST['y']);
|
||||
$WrefX = $_POST['x'];
|
||||
$WrefY = $_POST['y'];
|
||||
$type = $database->getVillageType2($Wref);
|
||||
$oasistype = $type['oasistype'];
|
||||
$vdata = $database->getVillage($Wref);
|
||||
}
|
||||
if(!$_POST['x'] && !$_POST['y'] && $_POST['target_id'] == ""){
|
||||
$errormsg .= "Enter coordinates.";
|
||||
}elseif(!$_POST['x'] || !$_POST['y']){
|
||||
}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.";
|
||||
@@ -20,7 +31,16 @@ $troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+"
|
||||
$errormsg .= "No troops has been selected.";
|
||||
}else{
|
||||
|
||||
$Wref = $database->getVilWref($_POST['y'], $_POST['x']);
|
||||
if($_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'];
|
||||
}
|
||||
$coor = $database->getCoor($village->wid);
|
||||
|
||||
function getDistance($coorx1, $coory1, $coorx2, $coory2) {
|
||||
@@ -35,119 +55,32 @@ $troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+"
|
||||
return round($dist, 1);
|
||||
}
|
||||
|
||||
$distance = getDistance($coor['x'], $coor['y'], $_POST['y'], $_POST['x']);
|
||||
$distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
|
||||
|
||||
$database->addSlotFarm($_POST['lid'], $Wref, $_POST['x'], $_POST['y'], $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
|
||||
$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");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
var targets = {};
|
||||
|
||||
function fillTargets()
|
||||
{
|
||||
var targetId = $('target_id');
|
||||
|
||||
targetId.empty();
|
||||
|
||||
var option = new Element('option',
|
||||
{
|
||||
'html': 'Select village'
|
||||
});
|
||||
targetId.insert(option);
|
||||
|
||||
$each(targets[lid], function(data)
|
||||
{
|
||||
var option = new Element('option',
|
||||
{
|
||||
'value': data.did,
|
||||
'html': data.name
|
||||
});
|
||||
targetId.insert(option);
|
||||
});
|
||||
}
|
||||
|
||||
function getTargetsByLid()
|
||||
{
|
||||
var lidSelect = $('lid');
|
||||
lid = lidSelect.getSelected()[0].value;
|
||||
|
||||
if (targets[lid])
|
||||
{
|
||||
fillTargets();
|
||||
}
|
||||
else
|
||||
{
|
||||
Travian.ajax(
|
||||
{
|
||||
data:
|
||||
{
|
||||
cmd: 'raidListTargets',
|
||||
'lid': lid
|
||||
},
|
||||
onSuccess: function(data)
|
||||
{
|
||||
targets[data.lid] = data.targets;
|
||||
fillTargets();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function selectCoordinates()
|
||||
{
|
||||
var targetId = $('target_id');
|
||||
var did = targetId.getSelected()[0].value;
|
||||
|
||||
if (did == '')
|
||||
{
|
||||
$('xCoordInput').value = '';
|
||||
$('yCoordInput').value = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
var array;
|
||||
$each(targets[lid], function(data)
|
||||
{
|
||||
if (data.did == did)
|
||||
{
|
||||
array = data;
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('xCoordInput').value = array.x;
|
||||
$('yCoordInput').value = array.y;
|
||||
}
|
||||
}
|
||||
|
||||
var lid = <?php echo $_GET['lid']; ?>;targets[lid] = {};
|
||||
|
||||
</script>
|
||||
|
||||
<div id="raidListSlot">
|
||||
<h4>Add Slot</h4>
|
||||
<font color="#FF0000"><b>
|
||||
<?php echo $errormsg; ?>
|
||||
</b></font>
|
||||
|
||||
<form action="build.php?id=39&t=99&action=showSlot&lid=<?php echo $_GET['lid']; ?>" method="post">
|
||||
<form action="build.php?id=39&t=99&action=addraid&lid=<?php echo $_GET['lid']; ?>" method="post">
|
||||
<div class="boxes boxesColor gray"><div class="boxes-tl"></div><div class="boxes-tr"></div><div class="boxes-tc"></div><div class="boxes-ml"></div><div class="boxes-mr"></div><div class="boxes-mc"></div><div class="boxes-bl"></div><div class="boxes-br"></div><div class="boxes-bc"></div><div class="boxes-contents cf">
|
||||
|
||||
<input type="hidden" name="action" value="addSlot">
|
||||
<input type="hidden" name="lid" value="<?php echo $_GET['lid']; ?>">
|
||||
|
||||
|
||||
<table cellpadding="1" cellspacing="1" class="transparent">
|
||||
<tbody><tr>
|
||||
<th>Farm Name:</th>
|
||||
<td>
|
||||
<select onchange="getTargetsByLid();" id="lid" name="lid">
|
||||
<select name="lid">
|
||||
<?php
|
||||
|
||||
$sql = mysql_query("SELECT * FROM ".TB_PREFIX."farmlist WHERE owner = $session->uid ORDER BY name ASC");
|
||||
@@ -182,10 +115,31 @@ $lvname = $database->getVillageField($row["wref"], 'name');
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="targetSelect">
|
||||
<label class="lastTargets" for="last_targets">Last targets:</label>
|
||||
<select id="target_id" name="target_id" onchange="selectCoordinates()">
|
||||
<option value="">Select village</option>
|
||||
</select>
|
||||
<label class="lastTargets">Last targets:</label>
|
||||
<select name="target_id">
|
||||
<?php
|
||||
$getwref = "SELECT * FROM ".TB_PREFIX."raidlist WHERE lid = ".$_GET['lid']."";
|
||||
$arraywref = $database->query_return($getwref);
|
||||
echo '<option value="">Select village</option>';
|
||||
if(mysql_num_rows(mysql_query($getwref)) != 0){
|
||||
foreach($arraywref as $row){
|
||||
$towref = $row["towref"];
|
||||
$tocoor = $database->getCoor($towref);
|
||||
$totype = $database->getVillageType2($towref);
|
||||
$tooasistype = $totype['oasistype'];
|
||||
if($tooasistype == 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>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</td>
|
||||
@@ -199,4 +153,9 @@ $lvname = $database->getVillageField($row["wref"], 'name');
|
||||
<button type="submit" value="save" name="save" id="save"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">save</div></div></button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}else{
|
||||
header("Location: build.php?id=39&t=99");
|
||||
}
|
||||
?>
|
||||
@@ -4,30 +4,50 @@ $eiddata = $database->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']);
|
||||
}
|
||||
|
||||
if(isset($_POST['action']) == 'editSlot' && $_POST['eid']) {
|
||||
|
||||
$Wref = $database->getVilWref($_POST['y'], $_POST['x']);
|
||||
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']){
|
||||
$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(!$_POST['x'] && !$_POST['y']){
|
||||
if(!$_POST['x'] && !$_POST['y'] && $_POST['target_id'] == ""){
|
||||
$errormsg .= "Enter coordinates.";
|
||||
}elseif(!$_POST['x'] || !$_POST['y']){
|
||||
}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{
|
||||
|
||||
$Wref = $database->getVilWref($_POST['y'], $_POST['x']);
|
||||
|
||||
if($_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'];
|
||||
}
|
||||
$coor = $database->getCoor($village->wid);
|
||||
|
||||
|
||||
function getDistance($coorx1, $coory1, $coorx2, $coory2) {
|
||||
$max = 2 * WORLD_MAX + 1;
|
||||
$x1 = intval($coorx1);
|
||||
@@ -39,103 +59,17 @@ $troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+"
|
||||
$dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2));
|
||||
return round($dist, 1);
|
||||
}
|
||||
$distance = getDistance($coor['x'], $coor['y'], $_POST['y'], $_POST['x']);
|
||||
$distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
|
||||
|
||||
$database->editSlotFarm($_GET['eid'], $_POST['lid'], $Wref, $_POST['x'], $_POST['y'], $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
|
||||
$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']);
|
||||
|
||||
header("Location: build.php?id=39&t=99");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($FLData['owner'] == $session->uid){
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
var targets = {};
|
||||
|
||||
function fillTargets()
|
||||
{
|
||||
var targetId = $('target_id');
|
||||
|
||||
targetId.empty();
|
||||
|
||||
var option = new Element('option',
|
||||
{
|
||||
'html': 'Select village'
|
||||
});
|
||||
targetId.insert(option);
|
||||
|
||||
$each(targets[lid], function(data)
|
||||
{
|
||||
var option = new Element('option',
|
||||
{
|
||||
'value': data.did,
|
||||
'html': data.name
|
||||
});
|
||||
targetId.insert(option);
|
||||
});
|
||||
}
|
||||
|
||||
function getTargetsByLid()
|
||||
{
|
||||
var lidSelect = $('lid');
|
||||
lid = lidSelect.getSelected()[0].value;
|
||||
|
||||
if (targets[lid])
|
||||
{
|
||||
fillTargets();
|
||||
}
|
||||
else
|
||||
{
|
||||
Travian.ajax(
|
||||
{
|
||||
data:
|
||||
{
|
||||
cmd: 'raidListTargets',
|
||||
'lid': lid
|
||||
},
|
||||
onSuccess: function(data)
|
||||
{
|
||||
targets[data.lid] = data.targets;
|
||||
fillTargets();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function selectCoordinates()
|
||||
{
|
||||
var targetId = $('target_id');
|
||||
var did = targetId.getSelected()[0].value;
|
||||
|
||||
if (did == '')
|
||||
{
|
||||
$('xCoordInput').value = '';
|
||||
$('yCoordInput').value = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
var array;
|
||||
$each(targets[lid], function(data)
|
||||
{
|
||||
if (data.did == did)
|
||||
{
|
||||
array = data;
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('xCoordInput').value = array.x;
|
||||
$('yCoordInput').value = array.y;
|
||||
}
|
||||
}
|
||||
|
||||
var lid = <?php echo $_GET['lid']; ?>;targets[lid] = {};
|
||||
|
||||
</script>
|
||||
|
||||
<div id="raidListSlot">
|
||||
<h4>Add Slot</h4>
|
||||
<font color="#FF0000"><b>
|
||||
@@ -190,9 +124,31 @@ $lvname = $database->getVillageField($row["wref"], 'name');
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="targetSelect">
|
||||
<label class="lastTargets" for="last_targets">Last targets:</label>
|
||||
<select id="target_id" name="target_id" onchange="selectCoordinates()">
|
||||
<option value="">Select village</option>
|
||||
<label class="lastTargets">Last targets:</label>
|
||||
<select name="target_id">
|
||||
<?php
|
||||
$getwref = "SELECT * FROM ".TB_PREFIX."raidlist WHERE lid = $lid2";
|
||||
$arraywref = $database->query_return($getwref);
|
||||
echo '<option value="">Select village</option>';
|
||||
if(mysql_num_rows(mysql_query($getwref)) != 0){
|
||||
foreach($arraywref as $row){
|
||||
$towref = $row["towref"];
|
||||
$tocoor = $database->getCoor($towref);
|
||||
$totype = $database->getVillageType2($towref);
|
||||
$tooasistype = $totype['oasistype'];
|
||||
if($tooasistype == 0){
|
||||
$tovname = $database->getVillageField($towref, 'name');
|
||||
}else{
|
||||
$tovname = $database->getOasisField($towref, 'name');
|
||||
}
|
||||
if($row["id"] == $_GET['eid']){ $selected = 'selected=""'; }else{ $selected = ''; }
|
||||
if($vill[$towref] == 0){
|
||||
echo '<option value="'.$towref.'" '.$selected.'>'.$tovname.'('.$tocoor['x'].'|'.$tocoor['y'].')</option>';
|
||||
}
|
||||
$vill[$towref] = 1;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
@@ -205,15 +161,11 @@ $lvname = $database->getVillageField($row["wref"], 'name');
|
||||
|
||||
|
||||
<button type="submit" value="save" name="save" id="save"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">Save</div></div></button>
|
||||
<button type="button" value="delete" name="delete" id="delete" onclick="return (function(){
|
||||
('Are you sure that you want to delete this list?').dialog(
|
||||
{
|
||||
onOkay: function(dialog, contentElement)
|
||||
{
|
||||
window.location.href = 'build.php?id=39&t=99&action=deleteSlot&eid=<?php echo $_GET['eid']; ?>'}
|
||||
});
|
||||
return false;
|
||||
})()">
|
||||
<div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">Delete</div></div></button>
|
||||
<button type="button" value="delete" name="delete" id="delete" onclick="window.location.href = '?gid=16&t=99&action=deleteSlot&eid=<?php echo $_GET["eid"]; ?>';"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">Delete</div></div></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}else{
|
||||
header("Location: build.php?id=39&t=99");
|
||||
}
|
||||
?>
|
||||
@@ -165,19 +165,24 @@ if($routeaccess = 1){
|
||||
}
|
||||
if($session->goldclub == 1 && $session->access != BANNED){
|
||||
if(isset($_GET['t'])==99) {
|
||||
|
||||
|
||||
if($_GET['action'] == 'addList') {
|
||||
$create = 1;
|
||||
}else{
|
||||
$create = 0;
|
||||
}else if($_GET['action'] == 'addraid') {
|
||||
$create = 2;
|
||||
}else if($_GET['action'] == 'showSlot' && $_GET['eid']) {
|
||||
$create = 3;
|
||||
}else{
|
||||
$create = 0;
|
||||
}
|
||||
|
||||
if($_GET['slid']) {
|
||||
$FLData = $database->getFLData($_GET['slid']);
|
||||
if($FLData['owner'] == $session->uid){
|
||||
$checked[$_GET['slid']] = 1;
|
||||
}
|
||||
|
||||
if($_GET['action'] == 'addraid') {
|
||||
include("Templates/goldClub/farmlist_addraid.tpl");
|
||||
}
|
||||
}elseif($_GET['action'] == 'showSlot' && $_GET['eid']) {
|
||||
include("Templates/goldClub/farmlist_editraid.tpl");
|
||||
}
|
||||
|
||||
if($_GET['action'] == 'deleteList') {
|
||||
$database->delFarmList($_GET['lid'], $session->uid);
|
||||
header("Location: build.php?id=39&t=99");
|
||||
@@ -185,6 +190,7 @@ if($session->goldclub == 1 && $session->access != BANNED){
|
||||
$database->delSlotFarm($_GET['eid']);
|
||||
header("Location: build.php?id=39&t=99");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$create = 0;
|
||||
if($session->access == BANNED){
|
||||
|
||||
+16
-15
@@ -43,16 +43,17 @@ if($session->access != BANNED){
|
||||
$getFLData = $database->getFLData($lid);
|
||||
$unitslist = $database->getFLData($lid);
|
||||
$sql = mysql_query("SELECT * FROM ".TB_PREFIX."raidlist WHERE lid = ".$lid."");
|
||||
$sql1 = mysql_query("SELECT * FROM ".TB_PREFIX."units WHERE vref = ".$getFLData['wref']);
|
||||
$sql1 = mysql_fetch_array(mysql_query("SELECT * FROM ".TB_PREFIX."units WHERE vref = ".$getFLData['wref']));
|
||||
while($row = mysql_fetch_array($sql)){
|
||||
$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'];
|
||||
$t11 = 0;
|
||||
if($tribe == 1){ $u = ""; } elseif($tribe == 2){ $u = "1"; } elseif($tribe == 3){ $u = "2"; }elseif($tribe == 4){ $u = "3"; }else {$u = "4"; }
|
||||
if($sql[$u.'1']>=$t1 && $sql[$u.'2']>=$t2 && $sql[$u.'3']>=$t3 && $sql[$u.'4']>=$t4 && $sql[$u.'5']>=$t5 && $sql[$u.'6']>=$t6 && $sql[$u.'7']>=$t7 && $sql[$u.'8']>=$t8 && $sql[$u.'9']>=$t9 && $sql[$u.'10']>=$t10 && $sql['hero']>=$t11){
|
||||
if($slots[$sid]=='on'){
|
||||
if($tribe == 1){ $u = "u"; } elseif($tribe == 2){ $u = "u1"; } elseif($tribe == 3){ $u = "u2"; }elseif($tribe == 4){ $u = "u3"; }else {$u = "u4"; }
|
||||
if($tribe == 1){ $u1 = "u1"; } elseif($tribe == 2){ $u1 = "u2"; } elseif($tribe == 3){ $u1 = "u3"; }elseif($tribe == 4){ $u1 = "u4"; }else {$u1 = "u5"; }
|
||||
if($tribe == 1){ $u2 = ""; } elseif($tribe == 2){ $u2 = "1"; } elseif($tribe == 3){ $u2 = "2"; }elseif($tribe == 4){ $u2 = "3"; }else {$u2 = "4"; }
|
||||
if($sql1[$u.'1']>=$t1 && $sql1[$u.'2']>=$t2 && $sql1[$u.'3']>=$t3 && $sql1[$u.'4']>=$t4 && $sql1[$u.'5']>=$t5 && $sql1[$u.'6']>=$t6 && $sql1[$u.'7']>=$t7 && $sql1[$u.'8']>=$t8 && $sql1[$u.'9']>=$t9 && $sql1[$u1.'0']>=$t10 && $sql1['hero']>=$t11){ if($slots[$sid]=='on'){
|
||||
$ckey = $generator->generateRandStr(6);
|
||||
$id = $database->addA2b($ckey,time(),$wref,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,4);
|
||||
|
||||
@@ -99,19 +100,19 @@ if($session->access != BANNED){
|
||||
$abdata = $database->getABTech($getFLData['wref']);
|
||||
$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'];
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'1'), array($data['u1']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'2'), array($data['u2']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'3'), array($data['u3']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'4'), array($data['u4']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'5'), array($data['u5']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'6'), array($data['u6']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'7'), array($data['u7']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'8'), array($data['u8']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'9'), array($data['u9']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u.'10'), array($data['u10']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'1'), array($data['u1']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'2'), array($data['u2']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'3'), array($data['u3']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'4'), array($data['u4']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'5'), array($data['u5']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'6'), array($data['u6']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'7'), array($data['u7']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'8'), array($data['u8']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'9'), array($data['u9']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array($u2.'10'), array($data['u10']), array(0));
|
||||
$database->modifyUnit($getFLData['wref'], array('hero'), array($data['u11']), array(0));
|
||||
|
||||
$database->addMovement(3,$getFLData['wref'],$data['to_vid'],$reference,0,($time+time()));
|
||||
$database->addMovement(3,$getFLData['wref'],$data['to_vid'],$reference,time(),($time+time()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user