+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
| List name: |
|
+
| Target village: |
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Templates/goldClub/farmlist_editraid.tpl b/Templates/goldClub/farmlist_editraid.tpl
index 62994e17..89c04488 100644
--- a/Templates/goldClub/farmlist_editraid.tpl
+++ b/Templates/goldClub/farmlist_editraid.tpl
@@ -1,158 +1,301 @@
getRaidList($_GET['eid']);
+
+$eid = isset($_GET['eid']) ? (int)$_GET['eid'] : 0;
+$action = $_GET['action'] ?? null;
+
+$errormsg = $errormsg ?? null;
+
+/* =====================================================
+ LOAD SLOT DATA (EDIT MODE)
+===================================================== */
+if ($action === 'editSlot' && $eid) {
+
+ $eiddata = $database->getRaidList($eid);
+
+ if (!$eiddata) {
+ header("Location: build.php?id=39&t=99");
+ exit;
+ }
+
$x = $eiddata['x'];
$y = $eiddata['y'];
- for($i = 1; $i <= 6; $i++) ${'t'.$i} = $eiddata['t'.$i];
+
+ for ($i = 1; $i <= 6; $i++) {
+ ${'t'.$i} = $eiddata['t'.$i];
+ }
+
$FLData = $database->getFLData($eiddata['lid']);
-
- //Check if we're editing one of ours raidlists
- if($FLData['owner'] != $session->uid){
- header("Location: build.php?id=39&t=99");
- exit;
- }
-}
-if(isset($_POST['action']) == 'editSlot' && isset($_GET['eid']) && !empty($_GET['eid']) && isset($_POST['lid']) && !empty($_POST['lid'])) {
-
- $FLData = $database->getFLData($_POST['lid']);
- 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($_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;
- $vdata = $database->getVillage($Wref);
- }
-
- $troops = 0;
- for($i = 1; $i <= 6; $i++){
- if(!in_array($i + ($session->tribe - 1) * 10, [4, 14, 23])) $troops += $_POST['t'.$i];
- }
-
- if($_POST['x'] == "" && $_POST['y'] == "" && empty($_POST['target_id'])) $errormsg = "Enter coordinates.";
- elseif(($_POST['x'] == "" || $_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'] == $FLData['wref'] || $vdata['wref'] == $FLData['wref']) $errormsg = "You can't attack the same village you're sending troops from.";
- else
- {
- 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'];
- }
-
- $coor = $database->getCoor($village->wid);
- $distance = $database->getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
- $database->editSlotFarm($_GET['eid'], $_POST['lid'], $database->getRaidList($_GET['eid'])['lid'], $session->uid, $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6']);
-
+ if ($FLData['owner'] != $session->uid) {
header("Location: build.php?id=39&t=99");
- exit;
+ exit;
+ }
}
+
+/* =====================================================
+ HANDLE EDIT SUBMIT
+===================================================== */
+$postAction = $_POST['action'] ?? null;
+
+if (
+ $postAction === 'editSlot' &&
+ $eid &&
+ !empty($_POST['lid'])
+) {
+
+ $FLData = $database->getFLData((int)$_POST['lid']);
+
+ /* ======================
+ TARGET RESOLVE
+ ====================== */
+ $Wref = null;
+ $WrefX = null;
+ $WrefY = null;
+ $vdata = null;
+ $oasistype = null;
+
+ $targetId = $_POST['target_id'] ?? '';
+ $px = $_POST['x'] ?? '';
+ $py = $_POST['y'] ?? '';
+
+ if (!empty($targetId)) {
+
+ $Wref = (int)$targetId;
+ $coor = $database->getCoor($Wref);
+
+ $WrefX = $coor['x'];
+ $WrefY = $coor['y'];
+
+ } elseif ($px !== '' && $py !== '' && is_numeric($px) && is_numeric($py)) {
+
+ $Wref = $database->getVilWref($px, $py);
+ $WrefX = (int)$px;
+ $WrefY = (int)$py;
+ }
+
+ if ($Wref) {
+ $oasistype = $database->getVillageType2($Wref);
+ $vdata = $database->getVillage($Wref);
+ }
+
+ /* ======================
+ TROOP COUNT
+ ====================== */
+ $troops = 0;
+ for ($i = 1; $i <= 6; $i++) {
+ $unitId = $i + ($session->tribe - 1) * 10;
+
+ if (!in_array($unitId, [4, 14, 23])) {
+ $troops += (int)($_POST['t'.$i] ?? 0);
+ }
+ }
+
+ /* ======================
+ VALIDATION
+ ====================== */
+ if (empty($px) && empty($py) && empty($targetId)) {
+ $errormsg = "Enter coordinates.";
+
+ } elseif (($px === '' || $py === '') && empty($targetId)) {
+ $errormsg = "Enter the correct coordinates.";
+
+ } elseif ($oasistype == 0 && !$vdata) {
+ $errormsg = "There is no village on those coordinates.";
+
+ } elseif ($troops == 0) {
+ $errormsg = "No troops has been selected.";
+
+ } elseif ($database->hasBeginnerProtection($Wref)) {
+ $errormsg = "Player under protection.";
+
+ } elseif (
+ $Wref == $FLData['wref'] ||
+ ($vdata['wref'] ?? null) == $FLData['wref']
+ ) {
+ $errormsg = "You can't attack the same village you're sending troops from.";
+
+ } else {
+
+ /* ======================
+ UPDATE SLOT
+ ====================== */
+ $coor = $database->getCoor($village->wid);
+ $distance = $database->getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
+
+ $oldLid = $database->getRaidList($eid)['lid'];
+
+ $database->editSlotFarm(
+ $eid,
+ (int)$_POST['lid'],
+ $oldLid,
+ $session->uid,
+ $Wref,
+ $WrefX,
+ $WrefY,
+ $distance,
+ (int)($_POST['t1'] ?? 0),
+ (int)($_POST['t2'] ?? 0),
+ (int)($_POST['t3'] ?? 0),
+ (int)($_POST['t4'] ?? 0),
+ (int)($_POST['t5'] ?? 0),
+ (int)($_POST['t6'] ?? 0)
+ );
+
+ header("Location: build.php?id=39&t=99");
+ exit;
+ }
}
+
?>
-
Edit Slot
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | List name: |
+
+
+ |
+
+
+
+ | Target village: |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Templates/goldClub/trooplist.tpl b/Templates/goldClub/trooplist.tpl
index 88758d0a..0ef26f99 100644
--- a/Templates/goldClub/trooplist.tpl
+++ b/Templates/goldClub/trooplist.tpl
@@ -1,30 +1,49 @@
-tribe - 1) * 10 + 1;
$end = $start + 5;
+
+/* build unit list once (keeps alignment safe) */
+$units = [];
+
+for ($i = $start; $i <= $end; $i++) {
+
+ if (in_array($i, [4, 14, 23])) {
+ continue;
+ }
+
+ $units[] = $i;
+}
+
?>
+
+
+
+
+ |
+
+ |
+
+
+
+
+
+
+
+ |
+
+ |
+
+
+
+
+
\ No newline at end of file