From 55e6dd60b52fd1d455afd163aef3fed7d2009861 Mon Sep 17 00:00:00 2001 From: novgorodschi catalin Date: Mon, 18 May 2026 09:18:35 +0300 Subject: [PATCH] Refactor + BugFix 1. Fix a bug in Admin Panel that you can edit by yourself your rank, now you cannot edit your rank anymore. 2. Now Alliance Leader can edit his own Position 3. Fix negative value on Demolition Building, now in database at lvl is appear new level not -1 4. Refactor Ajax map, now all is alligned (Ajax folder and Map folder) 5. Fix bug from Palace (when change capital now Automation recount population automaticaly on old capital and new capital) --- Admin/Templates/editAdditional.tpl | 33 +- Admin/Templates/home.tpl | 2 +- GameEngine/Alliance.php | 1354 ++++++++------------ GameEngine/Automation.php | 20 +- GameEngine/Building.php | 2 +- GameEngine/Database.php | 9 +- Templates/Ajax/mapscroll.tpl | 346 +++-- Templates/Ajax/mapscroll2.tpl | 364 ++++-- Templates/Alliance/changepos.tpl | 118 +- Templates/Build/1.tpl | 98 +- Templates/Build/10.tpl | 77 +- Templates/Build/11.tpl | 78 +- Templates/Build/12.tpl | 41 +- Templates/Build/12_upgrades.tpl | 238 ++-- Templates/Build/13.tpl | 40 +- Templates/Build/13_upgrades.tpl | 237 ++-- Templates/Build/14.tpl | 76 +- Templates/Build/15.tpl | 85 +- Templates/Build/15_1.tpl | 244 ++-- Templates/Build/16.tpl | 511 +++----- Templates/Build/16_99.tpl | 107 +- Templates/Build/16_incomming.tpl | 453 ++----- Templates/Build/16_menu.tpl | 20 +- Templates/Build/16_troops.tpl | 66 +- Templates/Build/16_walking.tpl | 230 +--- Templates/Build/17.tpl | 529 ++++---- Templates/Build/17_1.tpl | 291 +++-- Templates/Build/17_2.tpl | 235 ++-- Templates/Build/17_3.tpl | 411 ++---- Templates/Build/17_4.tpl | 160 +-- Templates/Build/17_create.tpl | 151 ++- Templates/Build/17_edit.tpl | 101 +- Templates/Build/17_menu.tpl | 36 +- Templates/Build/18.tpl | 124 +- Templates/Build/18_create.tpl | 91 +- Templates/Build/19.tpl | 137 +- Templates/Build/19_train.tpl | 92 +- Templates/Build/2.tpl | 93 +- Templates/Build/20.tpl | 151 ++- Templates/Build/20_train.tpl | 86 +- Templates/Build/21.tpl | 210 ++- Templates/Build/22.tpl | 34 +- Templates/Build/22_1.tpl | 248 ++-- Templates/Build/22_2.tpl | 241 ++-- Templates/Build/22_3.tpl | 247 ++-- Templates/Build/22_4.tpl | 238 ++-- Templates/Build/22_5.tpl | 234 ++-- Templates/Build/23.tpl | 50 +- Templates/Build/24.tpl | 35 +- Templates/Build/24_1.tpl | 144 +-- Templates/Build/24_2.tpl | 30 +- Templates/Build/25.tpl | 49 +- Templates/Build/25_2.tpl | 60 +- Templates/Build/25_3.tpl | 27 +- Templates/Build/25_4.tpl | 104 +- Templates/Build/25_create.tpl | 115 +- Templates/Build/25_menu.tpl | 15 +- Templates/Build/25_progress.tpl | 64 +- Templates/Build/25_train.tpl | 11 +- Templates/Build/26.tpl | 72 +- Templates/Build/26_2.tpl | 74 +- Templates/Build/26_3.tpl | 32 +- Templates/Build/26_4.tpl | 129 +- Templates/Build/26_create.tpl | 155 ++- Templates/Build/26_menu.tpl | 28 +- Templates/Build/26_progress.tpl | 91 +- Templates/Build/26_train.tpl | 138 +- Templates/Build/28.tpl | 61 +- Templates/Build/29.tpl | 106 +- Templates/Build/29_train.tpl | 67 +- Templates/Build/3.tpl | 92 +- Templates/Build/30.tpl | 106 +- Templates/Build/30_train.tpl | 78 +- Templates/Build/31.tpl | 52 +- Templates/Build/32.tpl | 52 +- Templates/Build/33.tpl | 52 +- Templates/Build/34.tpl | 3 + Templates/Build/35.tpl | 66 +- Templates/Build/36.tpl | 227 ++-- Templates/Build/38.tpl | 62 +- Templates/Build/39.tpl | 63 +- Templates/Build/4.tpl | 96 +- Templates/Build/41.tpl | 65 +- Templates/Build/42.tpl | 113 +- Templates/Build/42_train.tpl | 82 +- Templates/Build/5.tpl | 76 +- Templates/Build/6.tpl | 76 +- Templates/Build/7.tpl | 76 +- Templates/Build/8.tpl | 76 +- Templates/Build/9.tpl | 76 +- Templates/Build/avaliable/availupgrade.tpl | 165 ++- Templates/Build/next.tpl | 9 +- Templates/Build/upgrade.tpl | 219 ++-- Templates/Build/ww.tpl | 74 +- Templates/Build/wwupgrade.tpl | 217 ++-- Templates/header.tpl | 20 +- 96 files changed, 6176 insertions(+), 6763 deletions(-) diff --git a/Admin/Templates/editAdditional.tpl b/Admin/Templates/editAdditional.tpl index 55fa440f..6c1b4afd 100644 --- a/Admin/Templates/editAdditional.tpl +++ b/Admin/Templates/editAdditional.tpl @@ -38,19 +38,26 @@ function go_url(url) { - - - Change Access - - - - - + + Change Access + + + + + + + 'Banned', 2=>'Normal User', 8=>'Multihunter', 9=>'Admin']; + echo ''.$names[$user['access']].' - Nu îți poți modifica propriul acces'; + ?> + + + Edit Gold diff --git a/Admin/Templates/home.tpl b/Admin/Templates/home.tpl index e900d5c2..b1a7bc4e 100644 --- a/Admin/Templates/home.tpl +++ b/Admin/Templates/home.tpl @@ -71,5 +71,5 @@ if ($_SESSION['access'] == MULTIHUNTER) { Credits: Akakori & Elmar
Fixed, remade and new features added by Dzoki
Reworked by aggenkeech
- Remaked by Shadow + Refactored by Shadow \ No newline at end of file diff --git a/GameEngine/Alliance.php b/GameEngine/Alliance.php index 37f92f7d..20d2d556 100755 --- a/GameEngine/Alliance.php +++ b/GameEngine/Alliance.php @@ -4,10 +4,10 @@ ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## --------------------------------------------------------------------------- ## ## Project: TravianZ ## -## Version: 30.04.2026 ## +## Version: 30.04.2026 ## ## Filename Alliance.php ## -## Developed by: Dzoki ## -## Refactored by: Shadow (cata7007@gmail.com) ## +## Developed by: Dzoki ## +## Refactored by: Shadow (cata7007@gmail.com) ## ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## ## URLs: https://travianz.org ## @@ -19,10 +19,7 @@ use App\Entity\User; global $autoprefix; -// even with autoloader created, we can't use it here yet, as it's not been created -// ... so, let's see where it is and include it $autoloader_found = false; -// go max 5 levels up - we don't have folders that go deeper than that $autoprefix = ''; for ($i = 0; $i < 5; $i++) { $autoprefix = str_repeat('../', $i); @@ -32,935 +29,620 @@ for ($i = 0; $i < 5; $i++) { break; } } - if (!$autoloader_found) { die('Could not find autoloading class.'); } class Alliance { - public $gotInvite = false; - public $inviteArray = []; - public $allianceArray = []; - public $userPermArray = []; - - public function procAlliance($get) { - global $session, $database; - - // ==================== SANITIZARE GET ==================== - $get['a'] = isset($get['a']) ? (int)$get['a'] : 0; - $get['o'] = isset($get['o']) ? (int)$get['o'] : 0; - $get['d'] = isset($get['d']) ? (int)$get['d'] : 0; // dacă folosești și 'd' - - // ==================== ÎNCĂRCARE DATE ALIANȚĂ SAU INVITAȚII ==================== - if ($session->alliance > 0) { - // Utilizatorul este membru al unei alianțe - $this->allianceArray = $database->getAlliance($session->alliance); - - // Permissions Array - $this->userPermArray = $database->getAlliPermissions($session->uid, $session->alliance); - } else { - // Utilizatorul NU este într-o alianță → încarcă invitațiile primite - $this->inviteArray = $database->getInvitation($session->uid); - $this->gotInvite = count($this->inviteArray) > 0; - } - - // ==================== PROCESARE ACȚIUNI DIN URL (GET) ==================== - if ($get['a'] > 0) { - switch ($get['a']) { - case 2: - $this->rejectInvite($get); - break; - case 3: - $this->acceptInvite($get); - break; + public $gotInvite = false; + public $inviteArray = []; + public $allianceArray = []; + public $userPermArray = []; + + public function procAlliance(array $get): void { + global $session, $database; + // ==================== SANITIZARE GET ==================== + $get['a'] = isset($get['a']) ? (int)$get['a'] : 0; + $get['o'] = isset($get['o']) ? (int)$get['o'] : 0; + $get['d'] = isset($get['d']) ? (int)$get['d'] : 0; + // ==================== ÎNCĂRCARE DATE ALIANȚĂ SAU INVITAȚII ==================== + if ($session->alliance > 0) { + // Utilizatorul este membru al unei alianțe + $this->allianceArray = $database->getAlliance($session->alliance); + // Permissions Array + $this->userPermArray = $database->getAlliPermissions($session->uid, $session->alliance); + } else { + // Utilizatorul NU este într-o alianță → încarcă invitațiile primite + $this->inviteArray = $database->getInvitation($session->uid); + $this->gotInvite = count($this->inviteArray) > 0; } - } - if ($get['o'] > 0) { - switch ($get['o']) { - case 4: - $this->delInvite($get); - break; - } - } -} - -/** - * Determines if a forum is accessible or not - * - * @param int $forumID The forum ID - * @return bool Returns if the forum is accessible or not - */ - public function isForumAccessible($forumID) { - global $session; - - // Căutăm forumul în lista de forumuri partajate - foreach ($session->sharedForums as $forums) { - foreach ($forums as $forum) { - if ($forum['id'] == $forumID) { - return true; + // ==================== PROCESARE ACȚIUNI DIN URL (GET) ==================== + if ($get['a'] > 0) { + switch ($get['a']) { + case 2: $this->rejectInvite($get); break; + case 3: $this->acceptInvite($get); break; } } - } - return false; -} - -/** - * Determines if a player can act with the forum (edit/delete/create things, etc.) - * - * @param array $datas The array which contains: [aid, alliance, forum_perm, admin, owner, forum_owner] - * @return bool Returns true if you are able to act, false otherwise - */ - - public static function canAct($datas, $mode = 0) { - global $database, $session; - $hasSwitchedToAdmin = isset($datas['admin']) - && !empty($datas['admin']) - && $datas['admin'] === "switch_admin"; - - // ==================== CONDIȚII DE ACCES ==================== - $isAllianceOwner = $database->isAllianceOwner($session->uid) == $datas['alliance']; - $hasForumPerm = $datas['forum_perm'] == 1 && $session->alliance == $datas['alliance']; - $isForumOwner = $datas['owner'] == $session->uid && $session->access != ADMIN; - $isGlobalAdmin = $session->access == ADMIN; - $canActInAlliance = $datas['alliance'] > 0 && ($isAllianceOwner || $hasForumPerm); - $canActAsOwner = $isForumOwner; - $canActAsAdmin = $isGlobalAdmin; - - // Logica exactă din original - return (($canActInAlliance || $canActAsOwner || $canActAsAdmin)) && ($mode || $hasSwitchedToAdmin); -} - -/** - * Generează două string-uri cu ID-urile alianțelor și utilizatorilor care pot vedea un forum specific. - * - * Exclut automat: - * - propria alianță a jucătorului - * - relațiile de diplomație existente - * - utilizatorii șterși ([?]) - * - * @param array $alliancesID Lista de ID-uri de alianțe - * @param array $alliancesName Lista de nume de alianțe - * @param array $usersID Lista de ID-uri de utilizatori - * @param array $usersName Lista de nume de utilizatori - * @return array ['alliances' => '1,2,5', 'users' => '10,23,45'] - */ - public function createForumVisiblity($alliancesID, $alliancesName, $usersID, $usersName) { - global $database, $session; - $visibleAlliances = []; - $visibleUsers = []; - - // ==================== ALIANȚE VIZIBILE ==================== - // Procesăm atât ID-urile cât și numele (deduplicate automat prin array keys) - if (!empty($alliancesID)) { - foreach ($alliancesID as $alliance) { - if ($this->isValidAllianceForForum($alliance, $session->alliance, $database)) { - $visibleAlliances[$alliance] = true; - } - } - } - if (!empty($alliancesName)) { - foreach ($alliancesName as $allianceName) { - $allianceID = $database->getAllianceID($allianceName); - if ($this->isValidAllianceForForum($allianceID, $session->alliance, $database)) { - $visibleAlliances[$allianceID] = true; + if ($get['o'] > 0) { + switch ($get['o']) { + case 4: $this->delInvite($get); break; } } } - // ==================== UTILIZATORI VIZIBILI ==================== - if (!empty($usersID)) { - foreach ($usersID as $user) { - if ($this->isValidUserForForum($user, $session->alliance, $session->uid, $database)) { - $visibleUsers[$user] = true; + public function isForumAccessible(int $forumID): bool { + global $session; + // Căutăm forumul în lista de forumuri partajate + foreach ($session->sharedForums as $forums) { + foreach ($forums as $forum) { + if ($forum['id'] == $forumID) { + return true; + } } } - } - if (!empty($usersName)) { - foreach ($usersName as $username) { - $userID = $database->getUserField($username, 'id', 1); - if ($this->isValidUserForForum($userID, $session->alliance, $session->uid, $database)) { - $visibleUsers[$userID] = true; - } - } - } - - // ==================== RETURN ==================== - return [ - 'alliances' => implode(',', array_keys($visibleAlliances)), - 'users' => implode(',', array_keys($visibleUsers)) - ]; -} - -/** - * Verifică dacă o alianță poate fi adăugată la vizibilitatea forumului - */ - - private function isValidAllianceForForum($allianceID, $myAllianceID, $database) { - if (empty($allianceID) || !is_numeric($allianceID)) { return false; } - if (!$database->aExist($allianceID, 'id')) { - return false; - } - if ($allianceID == $myAllianceID) { - return false; - } - return empty($database->diplomacyExistingRelationships($allianceID)); -} -/** - * Verifică dacă un utilizator poate fi adăugat la vizibilitatea forumului - */ - private function isValidUserForForum($userID, $myAllianceID, $myUserID, $database) { - if (empty($userID) || !is_numeric($userID)) { - return false; + public static function canAct(array $datas, int $mode = 0): bool { + global $database, $session; + $hasSwitchedToAdmin = isset($datas['admin']) && !empty($datas['admin']) && $datas['admin'] === "switch_admin"; + // ==================== CONDIȚII DE ACCES ==================== + $isAllianceOwner = $database->isAllianceOwner($session->uid) == $datas['alliance']; + $hasForumPerm = $datas['forum_perm'] == 1 && $session->alliance == $datas['alliance']; + $isForumOwner = $datas['owner'] == $session->uid && $session->access != ADMIN; + $isGlobalAdmin = $session->access == ADMIN; + $canActInAlliance = $datas['alliance'] > 0 && ($isAllianceOwner || $hasForumPerm); + return (($canActInAlliance || $isForumOwner || $isGlobalAdmin)) && ($mode || $hasSwitchedToAdmin); } - $userAlliance = $database->getUserAllianceID($userID); - $username = $database->getUserField($userID, 'username', 0); - return ( - $userAlliance > 0 && - $userAlliance != $myAllianceID && - $username !== "[?]" && - $userID != $myUserID && - empty($database->diplomacyExistingRelationships($userAlliance)) - ); -} - -/** - * Redirecționează către pagina de selecție forum (allianz.php?s=2) - * - * Construiește URL-ul cu parametrii opționali fid și switch_admin, - * respectând exact condițiile din codul original. - * - * @param array|null $get Datele din cererea GET (poate fi null) - */ - - public function redirect($get = null) { - $get = $get ?? []; // protecție împotriva null - $url = "allianz.php?s=2"; + + public function createForumVisiblity(array $alliancesID, array $alliancesName, array $usersID, array $usersName): array { + global $database, $session; + $visibleAlliances = []; + $visibleUsers = []; + // ==================== ALIANȚE VIZIBILE ==================== + // Procesăm atât ID-urile cât și numele (deduplicate automat prin array keys) + if (!empty($alliancesID)) { + foreach ($alliancesID as $alliance) { + if ($this->isValidAllianceForForum($alliance, $session->alliance, $database)) { + $visibleAlliances[$alliance] = true; + } + } + } + if (!empty($alliancesName)) { + foreach ($alliancesName as $allianceName) { + $allianceID = $database->getAllianceID($allianceName); + if ($this->isValidAllianceForForum($allianceID, $session->alliance, $database)) { + $visibleAlliances[$allianceID] = true; + } + } + } + // ==================== UTILIZATORI VIZIBILI ==================== + if (!empty($usersID)) { + foreach ($usersID as $user) { + if ($this->isValidUserForForum($user, $session->alliance, $session->uid, $database)) { + $visibleUsers[$user] = true; + } + } + } + if (!empty($usersName)) { + foreach ($usersName as $username) { + $userID = $database->getUserField($username, 'id', 1); + if ($this->isValidUserForForum($userID, $session->alliance, $session->uid, $database)) { + $visibleUsers[$userID] = true; + } + } + } + // ==================== RETURN ==================== + return [ + 'alliances' => implode(',', array_keys($visibleAlliances)), + 'users' => implode(',', array_keys($visibleUsers)) + ]; + } + + /** + * Verifică dacă o alianță poate fi adăugată la vizibilitatea forumului + */ - // Adaugă &fid=... doar dacă fid este setat, nu gol și admin != 'pos' - if (isset($get['fid']) && !empty($get['fid']) && ($get['admin'] ?? '') !== 'pos') { - $url .= "&fid=" . $get['fid']; + private function isValidAllianceForForum($allianceID, $myAllianceID, $database): bool { + if (empty($allianceID) || !is_numeric($allianceID)) return false; + if (!$database->aExist($allianceID, 'id')) return false; + if ($allianceID == $myAllianceID) return false; + return empty($database->diplomacyExistingRelationships($allianceID)); } - // Adaugă &admin=switch_admin dacă parametrul admin este prezent și nu gol - if (isset($get['admin']) && !empty($get['admin'])) { - $url .= "&admin=switch_admin"; + + /** + * Verifică dacă un utilizator poate fi adăugat la vizibilitatea forumului + */ + + private function isValidUserForForum($userID, $myAllianceID, $myUserID, $database): bool { + if (empty($userID) || !is_numeric($userID)) return false; + $userAlliance = $database->getUserAllianceID($userID); + $username = $database->getUserField($userID, 'username', 0); + return ( + $userAlliance > 0 && + $userAlliance != $myAllianceID && + $username !== "[?]" && + $userID != $myUserID && + empty($database->diplomacyExistingRelationships($userAlliance)) + ); } - header("Location: " . $url); - exit; -} - + + /** + * Redirecționează către pagina de selecție forum (allianz.php?s=2) + * + * Construiește URL-ul cu parametrii opționali fid și switch_admin, + * respectând exact condițiile din codul original. + * + * @param array|null $get Datele din cererea GET (poate fi null) + */ + + public function redirect(?array $get = null): void { + $get = $get ?? []; + $url = "allianz.php?s=2"; + if (isset($get['fid']) && !empty($get['fid']) && ($get['admin'] ?? '') !== 'pos') { + $url .= "&fid=" . $get['fid']; + } + if (isset($get['admin']) && !empty($get['admin'])) { + $url .= "&admin=switch_admin"; + } + header("Location: " . $url); + exit; + } + /***************************************** Function to process of sending Forms *****************************************/ - - public function procAlliForm($post) { - // ==================== TIP FORMULAR (ft) ==================== - if (isset($post['ft'])) { - switch ($post['ft']) { - case "ali1": - $this->createAlliance($post); - break; + + public function procAlliForm(array $post): void { + // ==================== TIP FORMULAR (ft) ==================== + if (isset($post['ft'])) { + switch ($post['ft']) { + case "ali1": $this->createAlliance($post); break; + } + } + // ==================== SCHIMBARE DIPLOMAȚIE ==================== + if (isset($post['dipl']) && isset($post['a_name'])) { + $this->changediplomacy($post); + } + // ==================== ACȚIUNI GENERALE (s + o) ==================== + if (isset($post['s']) && isset($post['o'])) { + switch ($post['o']) { + case 1: // Schimbare permisiuni utilizator + if (isset($post['a'])) $this->changeUserPermissions($post); + break; + case 2: // Kick utilizator din alianță + if (isset($post['a_user'])) $this->kickAlliUser($post); + break; + case 4: // Trimitere invitație + if (isset($post['a']) && $post['a'] == 4) $this->sendInvite($post); + break; + case 3: // Actualizare profil alianță + $this->updateAlliProfile($post); + break; + case 11: // Părăsire alianță + $this->quitally($post); + break; + case 100: // Schimbare nume alianță + $this->changeAliName($post); + break; + } } } - - // ==================== SCHIMBARE DIPLOMAȚIE ==================== - if (isset($post['dipl']) && isset($post['a_name'])) { - $this->changediplomacy($post); - } - - // ==================== ACȚIUNI GENERALE (s + o) ==================== - if (isset($post['s']) && isset($post['o'])) { - switch ($post['o']) { - case 1: // Schimbare permisiuni utilizator - if (isset($_POST['a'])) { - $this->changeUserPermissions($post); - } - break; - case 2: // Kick utilizator din alianță - if (isset($_POST['a_user'])) { - $this->kickAlliUser($post); - } - break; - case 4: // Trimitere invitație - if (isset($_POST['a']) && $_POST['a'] == 4) { - $this->sendInvite($post); - } - break; - case 3: // Actualizare profil alianță - $this->updateAlliProfile($post); - break; - case 11: // Părăsire alianță - $this->quitally($post); - break; - case 100: // Schimbare nume alianță - $this->changeAliName($post); - break; - } - } -} - + /***************************************** Function to process of sending invitations *****************************************/ - public function sendInvite($post) { - global $form, $database, $session; - - // ==================== DATE DE INTRARE ==================== - $invitedUsername = stripslashes($post['a_name'] ?? ''); - - // Obținem datele utilizatorului invitat (comportament exact ca în original) - $UserData = $database->getUserArray($invitedUsername, 0); - - // ==================== VERIFICĂRI DE PERMISIUNI ȘI VALIDĂRI ==================== - if ($this->userPermArray['opt4'] == 0) { - $form->addError("name", NO_PERMISSION); - } elseif (!isset($post['a_name']) || $post['a_name'] === '') { - $form->addError("name", NAME_EMPTY); - } elseif (!User::exists($database, $post['a_name'])) { - $form->addError("name", NAME_NO_EXIST . stripslashes(stripslashes($post['a_name']))); - } elseif ($UserData['id'] == $session->uid) { - $form->addError("name", SAME_NAME); - } elseif ($database->getInvitation2($UserData['id'], $session->alliance)) { - $form->addError("name", $post['a_name'] . ALREADY_INVITED); - } elseif ($UserData['alliance'] == $session->alliance) { - $form->addError("name", $post['a_name'] . ALREADY_IN_ALLY); - } elseif ($UserData['alliance'] > 0) { - $form->addError("name", $post['a_name'] . ALREADY_IN_AN_ALLY); - } else { - // ==================== TOATE VERIFICĂRILE AU TRECUT → TRIMITE INVITAȚIA ==================== - $aid = $session->alliance; - - // Inserăm invitația în baza de date - $database->sendInvitation($UserData['id'], $aid, $session->uid); - - // Log notice în alianță - $database->insertAlliNotice( - $session->alliance, - '' . - addslashes($session->username) . - ' has invited ' . - addslashes($UserData['username']) . - ' into the alliance.' - ); - - // Trimite invitație și prin mesaj în joc (dacă este activată funcționalitatea nouă) - if (NEW_FUNCTIONS_ALLIANCE_INVITATION) { - $messageBody = "Hi, " . $UserData['username'] . "!\n\n" . - "This is to inform you that you have been invited to join an alliance. " . - "To accept this invitation, please visit your Embassy.\n\n" . - "Yours sincerely,\nServer Robot :)"; - $database->sendMessage( - $UserData['id'], - 4, - 'Invitation to Alliance', - $database->escape($messageBody), - 0, - 0, - 0, - 0, - 0, - true + public function sendInvite(array $post): void { + global $form, $database, $session; + // ==================== DATE DE INTRARE ==================== + $invitedUsername = stripslashes($post['a_name'] ?? ''); + // Obținem datele utilizatorului invitat (comportament exact ca în original) + $UserData = $database->getUserArray($invitedUsername, 0); + // ==================== VERIFICĂRI DE PERMISIUNI ȘI VALIDĂRI ==================== + if ($this->userPermArray['opt4'] == 0) { + $form->addError("name", NO_PERMISSION); + } elseif (!isset($post['a_name']) || $post['a_name'] === '') { + $form->addError("name", NAME_EMPTY); + } elseif (!User::exists($database, $post['a_name'])) { + $form->addError("name", NAME_NO_EXIST . stripslashes(stripslashes($post['a_name']))); + } elseif ($UserData['id'] == $session->uid) { + $form->addError("name", SAME_NAME); + } elseif ($database->getInvitation2($UserData['id'], $session->alliance)) { + $form->addError("name", $post['a_name'] . ALREADY_INVITED); + } elseif ($UserData['alliance'] == $session->alliance) { + $form->addError("name", $post['a_name'] . ALREADY_IN_ALLY); + } elseif ($UserData['alliance'] > 0) { + $form->addError("name", $post['a_name'] . ALREADY_IN_AN_ALLY); + } else { + // ==================== TOATE VERIFICĂRILE AU TRECUT → TRIMITE INVITAȚIA ==================== + $aid = $session->alliance; + // Inserăm invitația în baza de date + $database->sendInvitation($UserData['id'], $aid, $session->uid); + // Log notice în alianță + $database->insertAlliNotice( + $session->alliance, + '' . + addslashes($session->username) . + ' has invited ' . + addslashes($UserData['username']) . + ' into the alliance.' ); + // Trimite invitație și prin mesaj în joc (dacă este activată funcționalitatea nouă) + if (NEW_FUNCTIONS_ALLIANCE_INVITATION) { + $messageBody = "Hi, " . $UserData['username'] . "!\n\n" . + "This is to inform you that you have been invited to join an alliance. " . + "To accept this invitation, please visit your Embassy.\n\n" . + "Yours sincerely,\nServer Robot :)"; + $database->sendMessage($UserData['id'], 4, 'Invitation to Alliance', $database->escape($messageBody), 0, 0, 0, 0, 0, true); + } } } -} - + /***************************************** Function to reject an invitation *****************************************/ - - private function rejectInvite($get) { - global $database, $session; - $inviteID = $get['d'] ?? 0; - // ==================== CĂUTARE ȘI RESPINGERE INVITAȚIE ==================== - foreach ($this->inviteArray as $invite) { - if ($invite['id'] == $inviteID && $invite['uid'] == $session->uid) { - - // Ștergem invitația din baza de date - $database->removeInvitation($inviteID); - - // Adăugăm notice în logul alianței - $notice = '' . - addslashes($session->username) . - ' has rejected the invitation.'; - $database->insertAlliNotice($invite['alliance'], $notice); - break; // am găsit și procesat invitația → nu mai continuăm bucla + private function rejectInvite(array $get): void { + global $database, $session; + $inviteID = $get['d'] ?? 0; + // ==================== CĂUTARE ȘI RESPINGERE INVITAȚIE ==================== + foreach ($this->inviteArray as $invite) { + if ($invite['id'] == $inviteID && $invite['uid'] == $session->uid) { + // Ștergem invitația din baza de date + $database->removeInvitation($inviteID); + // Adăugăm notice în logul alianței + $notice = '' . addslashes($session->username) . ' has rejected the invitation.'; + $database->insertAlliNotice($invite['alliance'], $notice); + break; // am găsit și procesat invitația → nu mai continuăm bucla + } } + // ==================== REDIRECȚIONARE ==================== + // (întotdeauna se face redirect, chiar dacă invitația nu a fost găsită) + header("Location: build.php?gid=18"); + exit; } - - // ==================== REDIRECȚIONARE ==================== - // (întotdeauna se face redirect, chiar dacă invitația nu a fost găsită) - header("Location: build.php?gid=18"); - exit; -} - + /***************************************** Function to del an invitation *****************************************/ - - private function delInvite($get) { - global $database, $session; - $inviteID = $get['d'] ?? 0; - - // Încărcăm lista de invitații trimise de alianța curentă - $inviteArray = $database->getAliInvitations($session->alliance); - - // ==================== CĂUTARE ȘI ȘTERGERE INVITAȚIE ==================== - foreach ($inviteArray as $invite) { - if ($invite['id'] == $inviteID - && $invite['alliance'] == $session->alliance - && $this->userPermArray['opt4'] == 1) { - - // Obținem numele utilizatorului invitat - $invitename = $database->getUserArray($invite['uid'], 1); - - // Ștergem invitația - $database->removeInvitation($inviteID); - - // Adăugăm notice în logul alianței - $notice = '' . - addslashes($session->username) . - ' has deleted the invitation for ' . - addslashes($invitename['username']) . - '.'; - $database->insertAlliNotice($session->alliance, $notice); - break; // am procesat invitația → ieșim din buclă + + private function delInvite(array $get): void { + global $database, $session; + $inviteID = $get['d'] ?? 0; + // Încărcăm lista de invitații trimise de alianța curentă + $inviteArray = $database->getAliInvitations($session->alliance); + // ==================== CĂUTARE ȘI ȘTERGERE INVITAȚIE ==================== + foreach ($inviteArray as $invite) { + if ($invite['id'] == $inviteID && $invite['alliance'] == $session->alliance && $this->userPermArray['opt4'] == 1) { + // Obținem numele utilizatorului invitat + $invitename = $database->getUserArray($invite['uid'], 1); + // Ștergem invitația + $database->removeInvitation($inviteID); + // Adăugăm notice în logul alianței + $notice = '' . addslashes($session->username) . ' has deleted the invitation for ' . addslashes($invitename['username']) . '.'; + $database->insertAlliNotice($session->alliance, $notice); + break; // am procesat invitația → ieșim din buclă + } } + // ==================== REDIRECȚIONARE ==================== + // (întotdeauna se face redirect, chiar dacă invitația nu a fost găsită) + header("Location: allianz.php?delinvite"); + exit; } - - // ==================== REDIRECȚIONARE ==================== - // (întotdeauna se face redirect, chiar dacă invitația nu a fost găsită) - header("Location: allianz.php?delinvite"); - exit; -} - + /***************************************** Function to accept an invitation *****************************************/ - private function acceptInvite($get) { - global $form, $database, $session; - - $inviteID = $get['d'] ?? 0; - $acceptError = false; - $maxMembers = 0; - - // ==================== PROCESARE INVITAȚII ==================== - foreach ($this->inviteArray as $invite) { - if ($session->alliance == 0 - && $invite['id'] == $inviteID - && $invite['uid'] == $session->uid) { - $memberlist = $database->getAllMember($invite['alliance']); - $alliance_info = $database->getAlliance($invite['alliance']); - if (count($memberlist) < $alliance_info['max']) { - // Acceptăm invitația - $database->removeInvitation($inviteID); - $database->updateUserField($invite['uid'], "alliance", $invite['alliance'], 1); - $database->createAlliPermissions($invite['uid'], $invite['alliance'], '', 0, 0, 0, 0, 0, 0, 0, 0); - - // Log notice în alianță - $notice = '' . - addslashes($session->username) . - ' has joined the alliance.'; - $database->insertAlliNotice($invite['alliance'], $notice); - - } else { - // Alianța este plină - $acceptError = true; - $maxMembers = $alliance_info['max']; + private function acceptInvite(array $get): void { + global $form, $database, $session; + $inviteID = $get['d'] ?? 0; + $acceptError = false; + $maxMembers = 0; + // ==================== PROCESARE INVITAȚII ==================== + foreach ($this->inviteArray as $invite) { + if ($session->alliance == 0 && $invite['id'] == $inviteID && $invite['uid'] == $session->uid) { + $memberlist = $database->getAllMember($invite['alliance']); + $alliance_info = $database->getAlliance($invite['alliance']); + if (count($memberlist) < $alliance_info['max']) { + // Acceptăm invitația + $database->removeInvitation($inviteID); + $database->updateUserField($invite['uid'], "alliance", $invite['alliance'], 1); + $database->createAlliPermissions($invite['uid'], $invite['alliance'], '', 0, 0, 0, 0, 0, 0, 0, 0); + // Log notice în alianță + $notice = '' . addslashes($session->username) . ' has joined the alliance.'; + $database->insertAlliNotice($invite['alliance'], $notice); + } else { + // Alianța este plină + $acceptError = true; + $maxMembers = $alliance_info['max']; + } + break; } - break; // am găsit și procesat invitația → ieșim din buclă + } + // ==================== REZULTAT FINAL ==================== + if ($acceptError) { + $form->addError("ally_accept", "The alliance can contain only " . $maxMembers . " members at this moment."); + } else { + header("Location: build.php?gid=18"); + exit; } } - // ==================== REZULTAT FINAL ==================== - if ($acceptError) { - $form->addError( - "ally_accept", - "The alliance can contain only " . $maxMembers . " members at this moment." - ); - } else { - header("Location: build.php?gid=18"); - exit; - } -} /***************************************** Function to create an alliance *****************************************/ - - private function createAlliance($post) { - global $form, $database, $session, $bid18, $building; - $tag = $post['ally1'] ?? ''; - $name = $post['ally2'] ?? ''; - - // ==================== VALIDĂRI ==================== - if ($tag === '') { - $form->addError("ally1", ATAG_EMPTY); - } - if ($name === '') { - $form->addError("ally2", ANAME_EMPTY); - } - if ($database->aExist($tag, "tag")) { - $form->addError("ally1", ATAG_EXIST); - } - if ($database->aExist($name, "name")) { - $form->addError("ally2", ANAME_EXIST); - } - if ($session->alliance != 0) { - $form->addError("ally3", ALREADY_ALLY_MEMBER); - } - if ($building->getTypeLevel(18) < 3) { - $form->addError("ally4", ALLY_TOO_LOW); - } - - // ==================== ERORI ? ==================== - if ($form->returnErrors() != 0) { - $_SESSION['errorarray'] = $form->getErrors(); - $_SESSION['valuearray'] = $post; - - // Redirect în funcție de existența ambasadei (comportament original) - if ($building->getTypeLevel(18) > 0) { - header("Location: build.php?gid=18"); - } else { - header("Location: dorf2.php"); + private function createAlliance(array $post): void { + global $form, $database, $session, $bid18, $building; + $tag = $post['ally1'] ?? ''; + $name = $post['ally2'] ?? ''; + // ==================== VALIDĂRI ==================== + if ($tag === '') $form->addError("ally1", ATAG_EMPTY); + if ($name === '') $form->addError("ally2", ANAME_EMPTY); + if ($database->aExist($tag, "tag")) $form->addError("ally1", ATAG_EXIST); + if ($database->aExist($name, "name")) $form->addError("ally2", ANAME_EXIST); + if ($session->alliance != 0) $form->addError("ally3", ALREADY_ALLY_MEMBER); + if ($building->getTypeLevel(18) < 3) $form->addError("ally4", ALLY_TOO_LOW); + if ($form->returnErrors() != 0) { + // ==================== ERORI ? ================ + $_SESSION['errorarray'] = $form->getErrors(); + $_SESSION['valuearray'] = $post; + // Redirect în funcție de existența ambasadei (comportament original) + header("Location: " . ($building->getTypeLevel(18) > 0 ? "build.php?gid=18" : "dorf2.php")); + exit; } + $maxMembers = $bid18[$building->getTypeLevel(18)]['attri']; + $aid = $database->createAlliance($tag, $name, $session->uid, $maxMembers); + $database->updateUserField($session->uid, "alliance", $aid, 1); + $database->procAllyPop($aid); + $database->createAlliPermissions($session->uid, $aid, 'Alliance founder', '1', '1', '1', '1', '1', '1', '1', '1'); + $notice = 'The alliance has been founded by ' . addslashes($session->username) . '.'; + $database->insertAlliNotice($aid, $notice); + header("Location: build.php?gid=18"); exit; } - - // ==================== CREARE ALIANȚĂ ==================== - $maxMembers = $bid18[$building->getTypeLevel(18)]['attri']; - $aid = $database->createAlliance($tag, $name, $session->uid, $maxMembers); - - // Actualizăm alianța utilizatorului - $database->updateUserField($session->uid, "alliance", $aid, 1); - - // Procesăm populația inițială - $database->procAllyPop($aid); - - // Creăm permisiuni complete pentru fondator - $database->createAlliPermissions( - $session->uid, - $aid, - 'Alliance founder', - '1', '1', '1', '1', '1', '1', '1', '1' - ); - - // Log notice în alianță - $notice = 'The alliance has been founded by ' . - addslashes($session->username) . - '.'; - $database->insertAlliNotice($aid, $notice); - header("Location: build.php?gid=18"); - exit; -} - + /***************************************** Function to change the alliance name *****************************************/ - private function changeAliName($get) { - global $form, $database, $session; - $newTag = $get['ally1'] ?? ''; - $newName = $get['ally2'] ?? ''; - - // Încărcăm datele actuale ale alianței - $userAlly = $database->getAlliance($session->alliance); - - // ==================== VALIDĂRI ==================== - if ($newTag === '') { - $form->addError("ally1", ATAG_EMPTY); + private function changeAliName(array $get): void { + global $form, $database, $session; + $newTag = $get['ally1'] ?? ''; + $newName = $get['ally2'] ?? ''; + $userAlly = $database->getAlliance($session->alliance); + // ==================== VALIDĂRI ==================== + if ($newTag === '') $form->addError("ally1", ATAG_EMPTY); + if ($newName === '') $form->addError("ally2", ANAME_EMPTY); + if ($newTag !== $userAlly['tag'] && $database->aExist($newTag, "tag")) $form->addError("ally1", ATAG_EXIST); + if ($newName !== $userAlly['name'] && $database->aExist($newName, "name")) $form->addError("ally2", ANAME_EXIST); + if ($this->userPermArray['opt3'] == 0) $form->addError("perm", NO_PERMISSION); + // ==================== ERORI ? ==================== + if ($form->returnErrors() == 0) { + $database->setAlliName($session->alliance, $newName, $newTag); + $notice = '' . addslashes($session->username) . ' has changed the alliance name.'; + $database->insertAlliNotice($session->alliance, $notice); + $form->addError("perm", NAME_OR_TAG_CHANGED); + $_SESSION['errorarray'] = $form->getErrors(); + $_SESSION['valuearray'] = $get; + header("Location: allianz.php?s=5"); + exit; + } } - if ($newName === '') { - $form->addError("ally2", ANAME_EMPTY); - } - - // Verificăm existența tag-ului doar dacă s-a modificat - if ($newTag !== $userAlly['tag'] && $database->aExist($newTag, "tag")) { - $form->addError("ally1", ATAG_EXIST); - } - - // Verificăm existența numelui doar dacă s-a modificat - if ($newName !== $userAlly['name'] && $database->aExist($newName, "name")) { - $form->addError("ally2", ANAME_EXIST); - } - if ($this->userPermArray['opt3'] == 0) { - $form->addError("perm", NO_PERMISSION); - } - - // ==================== PROCESARE LA SUCCES ==================== - if ($form->returnErrors() == 0) { - // Actualizăm numele și tag-ul alianței - $database->setAlliName($session->alliance, $newName, $newTag); - - // Log notice în alianță - $notice = '' . - addslashes($session->username) . - ' has changed the alliance name.'; - $database->insertAlliNotice($session->alliance, $notice); - - // Mesaj de succes prin sistemul de erori (comportament original) - $form->addError("perm", NAME_OR_TAG_CHANGED); - $_SESSION['errorarray'] = $form->getErrors(); - $_SESSION['valuearray'] = $get; - header("Location: allianz.php?s=5"); - exit; - } -} - + /***************************************** Function to create/change the alliance description *****************************************/ - - private function updateAlliProfile($post) { - global $database, $session, $form; - // ==================== VERIFICARE PERMISIUNI ==================== - if ($this->userPermArray['opt3'] == 0) { - $form->addError("perm", NO_PERMISSION); - } - - // ==================== REZULTAT ==================== - if ($form->returnErrors() > 0) { - // Salvăm erorile în sesiune (comportament original - fără redirect aici) - $_SESSION['errorarray'] = $form->getErrors(); - $_SESSION['valuearray'] = $post; - } else { - // ==================== ACTUALIZARE PROFIL ==================== - $description = $post['be1'] ?? ''; - $rules = $post['be2'] ?? ''; - - $database->submitAlliProfile($session->alliance, $rules, $description); - - // Log notice în alianță - $notice = '' . - addslashes($session->username) . - ' has changed the alliance description.'; - $database->insertAlliNotice($session->alliance, $notice); - } -} - - /***************************************** - Function to change the user permissions - *****************************************/ - - private function changeUserPermissions($post) { - global $database, $session, $form; - - $targetUID = (int)($post['a_user'] ?? 0); - $rankTitle = $post['a_titel'] ?? ''; - - // ==================== VERIFICĂRI DE PERMISIUNI ȘI VALIDĂRI ==================== - if ($this->userPermArray['opt1'] == 0) { - $form->addError("perm", NO_PERMISSION); - } elseif ($database->getUserField($targetUID, "alliance", 0) != $session->alliance) { - $form->addError("perm", USER_NOT_IN_YOUR_ALLY); - } elseif ($targetUID == $session->uid) { - $form->addError("perm", CANT_EDIT_YOUR_PERMISSIONS); - } elseif ($database->isAllianceOwner($targetUID)) { - $form->addError("perm", CANT_EDIT_LEADER_PERMISSIONS); - } else { - // ==================== NORMALIZARE CHECKBOX-URI (CRITICAL FIX) ==================== - $opt1 = isset($post['e1']) ? 1 : 0; - $opt2 = isset($post['e2']) ? 1 : 0; - $opt3 = isset($post['e3']) ? 1 : 0; - $opt4 = isset($post['e4']) ? 1 : 0; - $opt5 = isset($post['e5']) ? 1 : 0; - $opt6 = isset($post['e6']) ? 1 : 0; - $opt7 = isset($post['e7']) ? 1 : 0; - - // Actualizăm permisiunile în baza de date - $ok = $database->updateAlliPermissions( - $targetUID, - (int)$session->alliance, - $rankTitle, - $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7 - ); - if (!$ok) { - $form->addError("perm", "DB UPDATE FAILED"); + private function updateAlliProfile(array $post): void { + global $database, $session, $form; + // ==================== VERIFICARE PERMISIUNI ==================== + if ($this->userPermArray['opt3'] == 0) $form->addError("perm", NO_PERMISSION); + // ==================== REZULTAT ==================== + if ($form->returnErrors() > 0) { + $_SESSION['errorarray'] = $form->getErrors(); + $_SESSION['valuearray'] = $post; } else { - // Log notice în alianță - $username = $database->getUserField($targetUID, "username", 0); - $notice = '' . - addslashes($session->username) . - ' has changed permissions of ' . - addslashes($username) . '.'; + // ==================== ACTUALIZARE PROFIL ==================== + $database->submitAlliProfile($session->alliance, $post['be2'] ?? '', $post['be1'] ?? ''); + // Log notice în alianță + $notice = '' . addslashes($session->username) . ' has changed the alliance description.'; $database->insertAlliNotice($session->alliance, $notice); - - // Mesaj de succes (comportament original) - $_SESSION['success'] = ALLY_PERMISSIONS_UPDATED; } } - // ==================== REDIRECȚIONARE LA ERORI ==================== - if ($form->returnErrors() > 0) { - $_SESSION['errorarray'] = $form->getErrors(); - $_SESSION['valuearray'] = $post; - header("Location: allianz.php?s=5"); - exit; - } -} + /***************************************** + Function to change the user permissions + MODIFICAT - permite liderului sa-si editeze rank-ul + *****************************************/ + private function changeUserPermissions(array $post): void { + global $database, $session, $form; + $targetUID = (int)($post['a_user'] ?? 0); + $rankTitle = $post['a_titel'] ?? ''; + // ==================== VERIFICĂRI DE PERMISIUNI ȘI VALIDĂRI ==================== + $isLeader = $database->isAllianceOwner($session->uid) == $session->alliance; + $isSelf = ($targetUID == $session->uid); + $isTargetLeader = $database->isAllianceOwner($targetUID) == $session->alliance; + + if ($this->userPermArray['opt1'] == 0) { + $form->addError("perm", NO_PERMISSION); + } elseif ($database->getUserField($targetUID, "alliance", 0) != $session->alliance) { + $form->addError("perm", USER_NOT_IN_YOUR_ALLY); + } elseif ($isSelf && !$isLeader) { + $form->addError("perm", CANT_EDIT_YOUR_PERMISSIONS); + } elseif ($isTargetLeader && !$isSelf) { + $form->addError("perm", CANT_EDIT_LEADER_PERMISSIONS); + } else { + // ==================== NORMALIZARE CHECKBOX-URI ==================== + if ($isLeader && $isSelf) { + $opt1 = $opt2 = $opt3 = $opt4 = $opt5 = $opt6 = $opt7 = 1; + } else { + $opt1 = isset($post['e1']) ? 1 : 0; + $opt2 = isset($post['e2']) ? 1 : 0; + $opt3 = isset($post['e3']) ? 1 : 0; + $opt4 = isset($post['e4']) ? 1 : 0; + $opt5 = isset($post['e5']) ? 1 : 0; + $opt6 = isset($post['e6']) ? 1 : 0; + $opt7 = isset($post['e7']) ? 1 : 0; + } + // Actualizăm permisiunile în baza de date + $ok = $database->updateAlliPermissions($targetUID, (int)$session->alliance, $rankTitle, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7); + if (!$ok) { + $form->addError("perm", "DB UPDATE FAILED"); + } else { + // Log notice în alianță + $username = $database->getUserField($targetUID, "username", 0); + $notice = '' . addslashes($session->username) . ' has changed permissions of ' . addslashes($username) . '.'; + $database->insertAlliNotice($session->alliance, $notice); + // Mesaj de succes (comportament original) + $_SESSION['success'] = ALLY_PERMISSIONS_UPDATED; + } + } + // ==================== REDIRECȚIONARE LA ERORI ==================== + if ($form->returnErrors() > 0) { + $_SESSION['errorarray'] = $form->getErrors(); + $_SESSION['valuearray'] = $post; + header("Location: allianz.php?s=5"); + exit; + } + } + /***************************************** Function to kick a user from alliance REFACTORIZAT 14.05.2026 - blochează kick la fondator *****************************************/ - private function kickAlliUser($post) { - global $database, $session, $form; - $targetUID = (int)($post['a_user'] ?? 0); - $UserData = $database->getUserArray($targetUID, 1); - $allyId = (int)$session->alliance; - - // ==================== VERIFICĂRI ==================== - if ($this->userPermArray['opt2'] == 0) { - $form->addError("perm", NO_PERMISSION); - return; + private function kickAlliUser(array $post): void { + global $database, $session, $form; + $targetUID = (int)($post['a_user'] ?? 0); + $UserData = $database->getUserArray($targetUID, 1); + $allyId = (int)$session->alliance; + // ==================== VERIFICĂRI ==================== + if ($this->userPermArray['opt2'] == 0) { + $form->addError("perm", NO_PERMISSION); return; + } + if ($database->getUserField($targetUID, "alliance", 0) != $allyId) { + $form->addError("perm", USER_NOT_IN_YOUR_ALLY); return; + } + if ($UserData['id'] == $session->uid) { + $form->addError("perm", CANT_EDIT_YOUR_PERMISSIONS); return; + } + if ($database->isAllianceOwner($targetUID) == $allyId) { + $form->addError("perm", CANT_REMOVE_LEADER); return; + } + // ==================== EXECUTARE KICK ==================== + $kickedUsername = $UserData['username']; + $database->evictUserFromAlliance($targetUID); + $database->deleteAlliPermissions($targetUID); + $notice = '' . addslashes($kickedUsername) . ' has been expelled from the alliance by ' . addslashes($session->username) . '.'; + $database->insertAlliNotice($allyId, $notice); + $database->deleteAlliance($allyId); + $form->addError("perm", $kickedUsername . ALLY_USER_KICKED); } - if ($database->getUserField($targetUID, "alliance", 0) != $allyId) { - $form->addError("perm", USER_NOT_IN_YOUR_ALLY); - return; - } - if ($UserData['id'] == $session->uid) { - $form->addError("perm", CANT_EDIT_YOUR_PERMISSIONS); - return; - } - // === NOU: nu poți da kick fondatorului === - if ($database->isAllianceOwner($targetUID) == $allyId) { - $form->addError("perm", CANT_REMOVE_LEADER); - return; - } - - // ==================== EXECUTARE KICK ==================== - $kickedUsername = $UserData['username']; - - $database->evictUserFromAlliance($targetUID); - $database->deleteAlliPermissions($targetUID); - - $notice = '' . - addslashes($kickedUsername) . - ' has been expelled from the alliance by ' . addslashes($session->username) . '.'; - $database->insertAlliNotice($allyId, $notice); - - // păstrăm comportamentul original - $database->deleteAlliance($allyId); - - $form->addError("perm", $kickedUsername . ALLY_USER_KICKED); -} + /***************************************** Function to set forum link *****************************************/ - - public function setForumLink($post) { - global $database, $session, $form; - - if ($this->userPermArray['opt5'] == 0) { - $form->addError("perm", NO_PERMISSION); - } else { - $forumLink = $post['f_link'] ?? ''; - $database->setAlliForumdblink($session->alliance, $forumLink); - - // Mesaj de succes (comportament exact ca în original) - $form->addError("perm", ALLY_FORUM_LINK_UPDATED); + + public function setForumLink(array $post): void { + global $database, $session, $form; + if ($this->userPermArray['opt5'] == 0) { + $form->addError("perm", NO_PERMISSION); + } else { + $database->setAlliForumdblink($session->alliance, $post['f_link'] ?? ''); + $form->addError("perm", ALLY_FORUM_LINK_UPDATED); + } } -} - - /***************************************** - Function to vote on forum survey - *****************************************/ - - public function Vote($post) { - global $database, $session; - - $surveyID = (int)($post['tid'] ?? 0); - $voteOption = (int)($post['vote'] ?? 0); - $fid2 = (int)($post['fid2'] ?? 0); - - // ==================== VERIFICĂRI ==================== - if ($database->checkSurvey($surveyID) && !$database->checkVote($surveyID, $session->uid)) { - $survey = $database->getSurvey($surveyID); - - // Construim noul string cu utilizatorii care au votat (exact ca în original) - $votedText = $survey['voted'] . ',' . $session->uid . ','; - $database->Vote($surveyID, $voteOption, $votedText); + + public function Vote(array $post): void { + global $database, $session; + $surveyID = (int)($post['tid'] ?? 0); + $voteOption = (int)($post['vote'] ?? 0); + $fid2 = (int)($post['fid2'] ?? 0); + if ($database->checkSurvey($surveyID) && !$database->checkVote($surveyID, $session->uid)) { + $survey = $database->getSurvey($surveyID); + $votedText = $survey['voted'] . ',' . $session->uid . ','; + $database->Vote($surveyID, $voteOption, $votedText); + } + header("Location: allianz.php?s=2&fid2=" . $fid2 . "&tid=" . $surveyID); + exit; } - - // ==================== REDIRECȚIONARE ==================== - // (întotdeauna se face redirect, chiar dacă votul nu a fost înregistrat) - header("Location: allianz.php?s=2&fid2=" . $fid2 . "&tid=" . $surveyID); - exit; -} - + /***************************************** Function to quit from alliance REFACTORIZAT 14.05.2026 - folosește Database v7 - *****************************************/ - private function quitally($post) { - global $database, $session, $form; - - // ==================== VERIFICARE PAROLĂ ==================== - if (!isset($post['pw']) || $post['pw'] === '') { - $form->addError("pw", PW_EMPTY); - return; - } - if (!password_verify($post['pw'], $session->userinfo['password'])) { - $form->addError("pw", LOGIN_PW_ERROR); - return; - } - - // Parola corectă → continuăm - $allyId = (int)$session->alliance; - $uid = (int)$session->uid; - $isFounder = $allyId && $database->isAllianceOwner($uid) == $allyId; - $memberCount = $database->countAllianceMembers($allyId); - - // ==================== CAZ SPECIAL: LIDERUL PLEACĂ ==================== - if ($isFounder && $memberCount > 1) { - if (empty($post['new_founder'])) { - $form->addError("founder", FOUNDER_LEAVE_NEW); - return; - } - $newFounderID = (int)$post['new_founder']; - - // Validăm că noul fondator e în alianță și nu ești tu - $members = $database->getAllMember($allyId); - $valid = false; - foreach ($members as $m) { - if ($m['id'] == $newFounderID && $newFounderID != $uid) { - $valid = true; - $newFounderName = $m['username']; - break; + *****************************************/ + + private function quitally(array $post): void { + global $database, $session, $form; + // ==================== VERIFICARE PAROLĂ ==================== + if (!isset($post['pw']) || $post['pw'] === '') { $form->addError("pw", PW_EMPTY); return; } + if (!password_verify($post['pw'], $session->userinfo['password'])) { $form->addError("pw", LOGIN_PW_ERROR); return; } + // Parola corectă → continuăm + $allyId = (int)$session->alliance; + $uid = (int)$session->uid; + $isFounder = $allyId && $database->isAllianceOwner($uid) == $allyId; + $memberCount = $database->countAllianceMembers($allyId); + // ==================== CAZ SPECIAL: LIDERUL PLEACĂ ==================== + if ($isFounder && $memberCount > 1) { + if (empty($post['new_founder'])) { $form->addError("founder", FOUNDER_LEAVE_NEW); return; } + $newFounderID = (int)$post['new_founder']; + $members = $database->getAllMember($allyId); + $valid = false; + foreach ($members as $m) { + if ($m['id'] == $newFounderID && $newFounderID != $uid) { $valid = true; $newFounderName = $m['username']; break; } } + if (!$valid) { $form->addError("founder", FOUNDER_LEAVE_INVALID); return; } + // Mesaj specific pentru quit voluntar + $messageBody = "Hi!\n\nThis is to inform you that the former leader of your alliance - " . $database->escape($session->username) . ", has decided to quit and elected you as his replacement. You now gain full access, administration and responsibilities to your alliance.\n\nGood luck!\n\nYours sincerely,\nServer Robot :)"; + // Folosim metoda centralizată cu mesaj custom + $database->promoteNewAllianceLeader($allyId, $newFounderID, $uid, $newFounderName, ['username' => $session->username, 'id' => $uid], $messageBody); + $_SESSION['alliance_user'] = 0; } - if (!$valid) { - $form->addError("founder", FOUNDER_LEAVE_INVALID); - return; - } - - // Mesaj specific pentru quit voluntar - $messageBody = "Hi!\n\n" . - "This is to inform you that the former leader of your alliance - " . - "" . - $database->escape($session->username) . - ", has decided to quit and elected you as his replacement. " . - "You now gain full access, administration and responsibilities to your alliance.\n\n" . - "Good luck!\n\nYours sincerely,\nServer Robot :)"; - - // Folosim metoda centralizată cu mesaj custom - $database->promoteNewAllianceLeader( - $allyId, - $newFounderID, - $uid, - $newFounderName, - ['username' => $session->username, 'id' => $uid], - $messageBody - ); - - $_SESSION['alliance_user'] = 0; + // ==================== PĂRĂSIRE ALIANȚĂ ==================== + $database->updateUserField($uid, 'alliance', 0, 1); + $database->deleteAlliPermissions($uid); + // șterge alianța dacă e goală (comportament original) + $database->deleteAlliance($allyId); + $notice = '' . addslashes($session->username) . ' has quit the alliance.'; + $database->insertAlliNotice($allyId, $notice); + header("Location: spieler.php?uid=" . $uid); + exit; } - - // ==================== PĂRĂSIRE ALIANȚĂ ==================== - $database->updateUserField($uid, 'alliance', 0, 1); - $database->deleteAlliPermissions($uid); - - // șterge alianța dacă e goală (comportament original) - $database->deleteAlliance($allyId); - - $notice = '' . - addslashes($session->username) . - ' has quit the alliance.'; - $database->insertAlliNotice($allyId, $notice); - - header("Location: spieler.php?uid=" . $uid); - exit; -} - + /***************************************** Function for change diplomacy *****************************************/ - private function changediplomacy($post) { - global $database, $session, $form; + private function changediplomacy(array $post): void { + global $database, $session, $form; + if ($this->userPermArray['opt6'] == 0) { $form->addError("name", NO_PERMISSION); return; } + $targetAllianceName = $post['a_name'] ?? ''; + $diplType = (int)($post['dipl'] ?? 0); + if (empty($targetAllianceName) || $diplType === 0) { $form->addError("name", NAME_OR_DIPL_EMPTY); return; } + if (!$database->aExist($targetAllianceName, "tag")) { $form->addError("name", ALLY_DOESNT_EXISTS); return; } + $targetAllianceID = $database->getAllianceID($targetAllianceName); + if ($targetAllianceID == $session->alliance) { $form->addError("name", CANNOT_INVITE_SAME_ALLY); return; } + if ($diplType < 1 || $diplType > 3) { $form->addError("name", WRONG_DIPLOMACY); return; } + if ($database->diplomacyInviteCheck2($session->alliance, $targetAllianceID)) { $form->addError("name", INVITE_ALREADY_SENT); return; } + if (!$database->diplomacyCheckLimits($session->alliance, $diplType)) { $form->addError("name", ALLY_TOO_MUCH_PACTS); return; } - // ==================== VERIFICARE PERMISIUNI ==================== - if ($this->userPermArray['opt6'] == 0) { - $form->addError("name", NO_PERMISSION); - return; + $database->diplomacyInviteAdd($session->alliance, $targetAllianceID, $diplType); + if ($diplType == 1) $noticeText = OFFERED_CONFED_TO; + elseif ($diplType == 2) $noticeText = OFFERED_NON_AGGRESION_PACT_TO; + elseif ($diplType == 3) $noticeText = DECLARED_WAR_ON; + else $noticeText = ''; + $myAllianceName = $database->getAllianceName($session->alliance); + $database->insertAlliNotice($session->alliance, '' . $myAllianceName . ' ' . $noticeText . ' ' . $targetAllianceName . '.'); + $database->insertAlliNotice($targetAllianceID, '' . $myAllianceName . ' ' . $noticeText . ' ' . $targetAllianceName . '.'); + $form->addError("name", INVITE_SENT); } - $targetAllianceName = $post['a_name'] ?? ''; - $diplType = (int)($post['dipl'] ?? 0); - - // ==================== VALIDĂRI DE INTRARE ==================== - if (empty($targetAllianceName) || $diplType === 0) { - $form->addError("name", NAME_OR_DIPL_EMPTY); - return; - } - if (!$database->aExist($targetAllianceName, "tag")) { - $form->addError("name", ALLY_DOESNT_EXISTS); - return; - } - $targetAllianceID = $database->getAllianceID($targetAllianceName); - if ($targetAllianceID == $session->alliance) { - $form->addError("name", CANNOT_INVITE_SAME_ALLY); - return; - } - if ($diplType < 1 || $diplType > 3) { - $form->addError("name", WRONG_DIPLOMACY); - return; - } - if ($database->diplomacyInviteCheck2($session->alliance, $targetAllianceID)) { - $form->addError("name", INVITE_ALREADY_SENT); - return; - } - if (!$database->diplomacyCheckLimits($session->alliance, $diplType)) { - $form->addError("name", ALLY_TOO_MUCH_PACTS); - return; - } - - // ==================== TRIMITE INVITAȚIA ==================== - $database->diplomacyInviteAdd($session->alliance, $targetAllianceID, $diplType); - - // Textul notice-ului (compatibil PHP 7) - if ($diplType == 1) { - $noticeText = OFFERED_CONFED_TO; - } elseif ($diplType == 2) { - $noticeText = OFFERED_NON_AGGRESION_PACT_TO; - } elseif ($diplType == 3) { - $noticeText = DECLARED_WAR_ON; - } else { - $noticeText = ''; - } - $myAllianceName = $database->getAllianceName($session->alliance); - - // Notice în alianța noastră - $database->insertAlliNotice( - $session->alliance, - '' . $myAllianceName . - ' ' . $noticeText . ' ' . - $targetAllianceName . '.' - ); - - // Notice în alianța țintă - $database->insertAlliNotice( - $targetAllianceID, - '' . $myAllianceName . - ' ' . $noticeText . ' ' . - $targetAllianceName . '.' - ); - - // Mesaj de succes - $form->addError("name", INVITE_SENT); -} } $alliance = new Alliance; - -?> +?> \ No newline at end of file diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index e2a5e8bc..cf80f9fd 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -3383,11 +3383,15 @@ class Automation { $varray = $database->getDemolition(); foreach($varray as $vil) { +if ($vil['lvl'] < 0) { + $database->delDemolition($vil['vref'], true); + continue; +} if ($vil['timetofinish'] <= time()) { $type = $database->getFieldType($vil['vref'],$vil['buildnumber']); $level = $database->getFieldLevel($vil['vref'],$vil['buildnumber']); - if ($level < 0) $level = 0; + $newLevel = max(0, $level - 1); $buildarray = $GLOBALS["bid".$type]; @@ -3395,7 +3399,7 @@ class Automation { $database->query(" UPDATE ".TB_PREFIX."vdata SET - `maxstore` = IF(`maxstore` - ".$buildarray[$level]['attri']." <= ".STORAGE_BASE.", ".STORAGE_BASE.", `maxstore` - ".$buildarray[$level]['attri']."), + `maxstore` = IF(`maxstore` - ".$buildarray[$level]['attri']." <= ".STORAGE_BASE.", ".STORAGE_BASE.", `maxstore` - ".$buildarray[$level]['attri'].") WHERE wref=".(int) $vil['vref']); } @@ -3404,7 +3408,7 @@ class Automation { $database->query(" UPDATE ".TB_PREFIX."vdata SET - `maxcrop` = IF(`maxcrop` - ".$buildarray[$level]['attri']." <= ".STORAGE_BASE.", ".STORAGE_BASE.", `maxcrop` - ".$buildarray[$level]['attri']."), + `maxcrop` = IF(`maxcrop` - ".$buildarray[$level]['attri']." <= ".STORAGE_BASE.", ".STORAGE_BASE.", `maxcrop` - ".$buildarray[$level]['attri'].") WHERE wref=".(int) $vil['vref']); } @@ -3414,10 +3418,16 @@ class Automation { if ($database->getVillageField($vil['vref'], 'natar') == 1 && $type == 40) $clear = ""; //fix by ronix - fixed by iopietro - $q = "UPDATE ".TB_PREFIX."fdata SET f".$vil['buildnumber']."=".(($level - 1 >= 0) ? $level - 1 : 0).$clear." WHERE vref=".(int) $vil['vref']; +$q = " +UPDATE ".TB_PREFIX."fdata +SET + f".$vil['buildnumber']."=".$newLevel." + ".$clear." +WHERE + vref=".(int)$vil['vref']; $database->query($q); - $pop = $this->getPop($type, $level - 1); + $pop = $this->getPop($type, $newLevel); $database->modifyPop($vil['vref'], $pop[0], 1); $this->procClimbers($database->getVillageField($vil['vref'], 'owner')); $database->delDemolition($vil['vref'], true); diff --git a/GameEngine/Building.php b/GameEngine/Building.php index 0f3734b0..2918277d 100755 --- a/GameEngine/Building.php +++ b/GameEngine/Building.php @@ -2022,4 +2022,4 @@ class Building { } }; -?> +?> \ No newline at end of file diff --git a/GameEngine/Database.php b/GameEngine/Database.php index e6d47ded..83ca37fb 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -4774,7 +4774,14 @@ References: User ID/Message ID, Mode $q = "DELETE FROM ".TB_PREFIX."bdata WHERE field=$field AND wid=$wid"; mysqli_query($this->dblink,$q); $uprequire = $building->resourceRequired($field,$village->resarray['f'.$field.'t'],0); - $q = "INSERT INTO ".TB_PREFIX."demolition VALUES (".$wid.",".$field.",".($fLevel-1).",".(time()+floor($uprequire['time']/2)).")"; +$newLevel = max(0, $fLevel - 1); + +$q = "INSERT INTO ".TB_PREFIX."demolition VALUES ( + ".$wid.", + ".$field.", + ".$newLevel.", + ".(time() + floor($uprequire['time'] / 2))." +)"; mysqli_query($this->dblink,$q); return true; diff --git a/Templates/Ajax/mapscroll.tpl b/Templates/Ajax/mapscroll.tpl index f222771e..881d235f 100644 --- a/Templates/Ajax/mapscroll.tpl +++ b/Templates/Ajax/mapscroll.tpl @@ -1,157 +1,271 @@ WORLD_MAX)? $x-WORLD_MAX*2-1 : $x; -$y = ($y < -WORLD_MAX)? $y+WORLD_MAX*2+1 : $y; -$y = ($y > WORLD_MAX)? $y-WORLD_MAX*2-1 : $y; -$xm3 = ($x-3) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-2 : $x-3; -$xm2 = ($x-2) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-1 : $x-2; -$xm1 = ($x-1) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX : $x-1; -$xp1 = ($x+1) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX : $x+1; -$xp2 = ($x+2) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+1 : $x+2; -$xp3 = ($x+3) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+2: $x+3; -$ym3 = ($y-3) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-2 : $y-3; -$ym2 = ($y-2) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-1 : $y-2; -$ym1 = ($y-1) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX : $y-1; -$yp1 = ($y+1) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX : $y+1; -$yp2 = ($y+2) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+1 : $y+2; -$yp3 = ($y+3) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+2: $y+3; -$xarray = array($xm3,$xm2,$xm1,$x,$xp1,$xp2,$xp3); -$yarray = array($ym3,$ym2,$ym1,$y,$yp1,$yp2,$yp3); -$maparray = array(); -$xcount = 0; + +/* ========================= + WORLD WRAP (original +1 logic preserved) +========================= */ +$x = ($x < -$W)? $x + $W * 2 + 1 : $x; +$x = ($x > $W)? $x - $W * 2 - 1 : $x; +$y = ($y < -$W)? $y + $W * 2 + 1 : $y; +$y = ($y > $W)? $y - $W * 2 - 1 : $y; + +/* ========================= + MAP COORDINATES CALCULATION +========================= */ +$xm3 = ($x - 3) < -$W? $x + $W + $W - 2 : $x - 3; +$xm2 = ($x - 2) < -$W? $x + $W + $W - 1 : $x - 2; +$xm1 = ($x - 1) < -$W? $x + $W + $W : $x - 1; + +$xp1 = ($x + 1) > $W? $x - $W - $W : $x + 1; +$xp2 = ($x + 2) > $W? $x - $W - $W + 1 : $x + 2; +$xp3 = ($x + 3) > $W? $x - $W - $W + 2 : $x + 3; + +$ym3 = ($y - 3) < -$W? $y + $W + $W - 2 : $y - 3; +$ym2 = ($y - 2) < -$W? $y + $W + $W - 1 : $y - 2; +$ym1 = ($y - 1) < -$W? $y + $W + $W : $y - 1; + +$yp1 = ($y + 1) > $W? $y - $W - $W : $y + 1; +$yp2 = ($y + 2) > $W? $y - $W - $W + 1 : $y + 2; +$yp3 = ($y + 3) > $W? $y - $W - $W + 2 : $y + 3; + +/* ========================= + MAP GRID ARRAYS +========================= */ +$xarray = array($xm3, $xm2, $xm1, $x, $xp1, $xp2, $xp3); +$yarray = array($ym3, $ym2, $ym1, $y, $yp1, $yp2, $yp3); $maparray = ''; $maparray2 = ''; -for($i=0; $i<=6; $i++){ - if($xcount != 7){ - $maparray .= '\''.$generator->getBaseID($xarray[$xcount],$yarray[$i]).'\','; - $maparray2 .= $generator->getBaseID($xarray[$xcount],$yarray[$i]).','; - if($i==6){ - $i = -1; - $xcount +=1; - } - } + +$xcount = 0; + +for ($i = 0; $i <= 6; $i++) { + if ($xcount!= 7) { + $id = $generator->getBaseID($xarray[$xcount], $yarray[$i]); + + $maparray.= "'". $id. "',"; + $maparray2.= $id. ","; + + if ($i == 6) { + $i = -1; + $xcount++; + } + } } + +$maparray = substr($maparray, 0, -1); + header("Content-Type: application/json;"); -$maparray = (substr($maparray, 0, -1)); +/* ========================= + MAIN MAP QUERY + (formatted only, same logic) +========================= */ +$query2 = " +SELECT + ". TB_PREFIX. "wdata.id AS map_id, + ". TB_PREFIX. "wdata.fieldtype AS map_fieldtype, + ". TB_PREFIX. "wdata.oasistype AS map_oasis, + ". TB_PREFIX. "wdata.x AS map_x, + ". TB_PREFIX. "wdata.y AS map_y, + ". TB_PREFIX. "wdata.occupied AS map_occupied, + ". TB_PREFIX. "wdata.image AS map_image, -$query2 = "SELECT - ".TB_PREFIX."wdata.id AS map_id, - ".TB_PREFIX."wdata.fieldtype AS map_fieldtype, - ".TB_PREFIX."wdata.oasistype AS map_oasis, - ".TB_PREFIX."wdata.x AS map_x, - ".TB_PREFIX."wdata.y AS map_y, - ".TB_PREFIX."wdata.occupied AS map_occupied, - ".TB_PREFIX."wdata.image AS map_image, + ". TB_PREFIX. "odata.conqured AS oasis_conqured, + info_user_oasis.username AS oasis_user, + info_user_oasis.tribe AS oasis_tribe, + info_alliance_oasis.tag AS oasis_alli_name, - ".TB_PREFIX."odata.conqured AS oasis_conqured, - info_user_oasis.username AS oasis_user, - info_user_oasis.tribe AS oasis_tribe, - info_alliance_oasis.tag AS oasis_alli_name, + ". TB_PREFIX. "vdata.wref AS ville_id, + ". TB_PREFIX. "vdata.owner AS ville_user, + ". TB_PREFIX. "vdata.name AS ville_name, + ". TB_PREFIX. "vdata.capital AS ville_capital, + ". TB_PREFIX. "vdata.pop AS ville_pop, - ".TB_PREFIX."vdata.wref AS ville_id, - ".TB_PREFIX."vdata.owner AS ville_user, - ".TB_PREFIX."vdata.name AS ville_name, - ".TB_PREFIX."vdata.capital AS ville_capital, - ".TB_PREFIX."vdata.pop AS ville_pop, + ". TB_PREFIX. "users.id AS user_id, + ". TB_PREFIX. "users.username AS user_username, + ". TB_PREFIX. "users.tribe AS user_tribe, + ". TB_PREFIX. "users.alliance AS user_alliance, - ".TB_PREFIX."users.id AS user_id, - ".TB_PREFIX."users.username AS user_username, - ".TB_PREFIX."users.tribe AS user_tribe, - ".TB_PREFIX."users.alliance AS user_alliance, + ". TB_PREFIX. "alidata.id AS aliance_id, + ". TB_PREFIX. "alidata.tag AS aliance_name - ".TB_PREFIX."alidata.id AS aliance_id, - ".TB_PREFIX."alidata.tag AS aliance_name +FROM ((((((". TB_PREFIX. "wdata + LEFT JOIN ". TB_PREFIX. "vdata ON ". TB_PREFIX. "vdata.wref = ". TB_PREFIX. "wdata.id) + LEFT JOIN ". TB_PREFIX. "odata ON ". TB_PREFIX. "odata.wref = ". TB_PREFIX. "wdata.id) + LEFT JOIN ". TB_PREFIX. "users AS info_user_oasis ON info_user_oasis.id = ". TB_PREFIX. "odata.owner) + LEFT JOIN ". TB_PREFIX. "alidata AS info_alliance_oasis ON info_alliance_oasis.id = info_user_oasis.alliance) + LEFT JOIN ". TB_PREFIX. "users ON ". TB_PREFIX. "users.id = ". TB_PREFIX. "vdata.owner) + LEFT JOIN ". TB_PREFIX. "alidata ON ". TB_PREFIX. "alidata.id = ". TB_PREFIX. "users.alliance) - FROM ((((((".TB_PREFIX."wdata - LEFT JOIN ".TB_PREFIX."vdata ON ".TB_PREFIX."vdata.wref = ".TB_PREFIX."wdata.id ) - LEFT JOIN ".TB_PREFIX."odata ON ".TB_PREFIX."odata.wref = ".TB_PREFIX."wdata.id ) - LEFT JOIN ".TB_PREFIX."users AS info_user_oasis ON info_user_oasis.id = ".TB_PREFIX."odata.owner ) - LEFT JOIN ".TB_PREFIX."alidata AS info_alliance_oasis ON info_alliance_oasis.id = info_user_oasis.alliance ) - LEFT JOIN ".TB_PREFIX."users ON ".TB_PREFIX."users.id = ".TB_PREFIX."vdata.owner ) - LEFT JOIN ".TB_PREFIX."alidata ON ".TB_PREFIX."alidata.id = ".TB_PREFIX."users.alliance ) - where ".TB_PREFIX."wdata.id IN ($maparray) - ORDER BY FIND_IN_SET(".TB_PREFIX."wdata.id,'$maparray2')"; +WHERE ". TB_PREFIX. "wdata.id IN ($maparray) +ORDER BY FIND_IN_SET(". TB_PREFIX. "wdata.id,'$maparray2') +"; -$result2 = mysqli_query($database->dblink,$query2) or die(mysqli_error($database->dblink)); +$result2 = mysqli_query($database->dblink, $query2) or die(mysqli_error($database->dblink)); -$i=0; -//Load coor array +/* ========================= + OUTPUT PREPARATION +========================= */ +$i = 0; $yrow = 0; +$map_js = ''; -$map_js =''; -while ($donnees = mysqli_fetch_assoc($result2)){ +/* ========================= + MAIN LOOP (UNCHANGED LOGIC) +========================= */ +while ($donnees = mysqli_fetch_assoc($result2)) { -$targetalliance=$donnees["aliance_id"]; -$friendarray=$database->getAllianceAlly($donnees["aliance_id"],1); -$neutralarray=$database->getAllianceAlly($donnees["aliance_id"],2); -$enemyarray=$database->getAllianceWar2($donnees["aliance_id"]); + $targetalliance = $donnees["aliance_id"]; -$friend = ((isset($friendarray[0]) && isset($friendarray[0]['alli1']) && isset($friendarray[0]['alli2']) && $friendarray[0]['alli1']>0 and $friendarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($friendarray[0]['alli1']==$_SESSION['alliance_user'] or $friendarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0'; + /* ========================= + RELATION STATUS (session based) + ========================= */ + $friendarray = $database->getAllianceAlly($donnees["aliance_id"], 1); + $neutralarray = $database->getAllianceAlly($donnees["aliance_id"], 2); + $enemyarray = $database->getAllianceWar2($donnees["aliance_id"]); -$war = ((isset($enemyarray[0]) && isset($enemyarray[0]['alli1']) && isset($enemyarray[0]['alli2']) && $enemyarray[0]['alli1']>0 and $enemyarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($enemyarray[0]['alli1']==$_SESSION['alliance_user'] or $enemyarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0'; + $sessionAlliance = $_SESSION['alliance_user']; -$neutral = ((isset($neutralarray[0]) && isset($neutralarray[0]['alli1']) && isset($neutralarray[0]['alli2']) && $neutralarray[0]['alli1']>0 and $neutralarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($neutralarray[0]['alli1']==$_SESSION['alliance_user'] or $neutralarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0'; + $friend = ((isset($friendarray[0]) && isset($friendarray[0]['alli1']) && isset($friendarray[0]['alli2']) && $friendarray[0]['alli1'] > 0 && $friendarray[0]['alli2'] > 0 && $donnees["aliance_id"] > 0) && ($friendarray[0]['alli1'] == $sessionAlliance || $friendarray[0]['alli2'] == $sessionAlliance) && ($sessionAlliance!= $targetalliance && $sessionAlliance && $targetalliance))? '1' : '0'; + $war = ((isset($enemyarray[0]) && isset($enemyarray[0]['alli1']) && isset($enemyarray[0]['alli2']) && $enemyarray[0]['alli1'] > 0 && $enemyarray[0]['alli2'] > 0 && $donnees["aliance_id"] > 0) && ($enemyarray[0]['alli1'] == $sessionAlliance || $enemyarray[0]['alli2'] == $sessionAlliance) && ($sessionAlliance!= $targetalliance && $sessionAlliance && $targetalliance))? '1' : '0'; -$image = ($donnees['map_occupied'] == 1 && $donnees['map_fieldtype'] > 0)?(($donnees['ville_user'] == $_SESSION['id_user'])? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b30': 'b20' :'b10' : 'b00') : (($targetalliance != 0)? ($friend==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b31': 'b21' :'b11' : 'b01') : ($war==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b32': 'b22' :'b12' : 'b02') : ($neutral==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b35': 'b25' :'b15' : 'b05') : ($targetalliance == $_SESSION['alliance_user']? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b33': 'b23' :'b13' : 'b03') : ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b34': 'b24' :'b14' : 'b04'))))) : ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b34': 'b24' :'b14' : 'b04'))) : $donnees['map_image']; -if($donnees['ville_user']==3 && $donnees['ville_name']==PLANVILLAGE){ -$image = "o99"; -} + $neutral = ((isset($neutralarray[0]) && isset($neutralarray[0]['alli1']) && isset($neutralarray[0]['alli2']) && $neutralarray[0]['alli1'] > 0 && $neutralarray[0]['alli2'] > 0 && $donnees["aliance_id"] > 0) && ($neutralarray[0]['alli1'] == $sessionAlliance || $neutralarray[0]['alli2'] == $sessionAlliance) && ($sessionAlliance!= $targetalliance && $sessionAlliance && $targetalliance))? '1' : '0'; + /* ========================= + IMAGE DECISION (UNCHANGED) + ========================= */ + $image = ($donnees['map_occupied'] == 1 && $donnees['map_fieldtype'] > 0) + ? (($donnees['ville_user'] == $_SESSION['id_user']) + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b30' : 'b20') + : 'b10') + : 'b00') + : (($targetalliance!= 0) + ? ($friend == 1 + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b31' : 'b21') + : 'b11') + : 'b01') + : ($war == 1 + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b32' : 'b22') + : 'b12') + : 'b02') + : ($neutral == 1 + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b35' : 'b25') + : 'b15') + : 'b05') + : ($targetalliance == $sessionAlliance + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b33' : 'b23') + : 'b13') + : 'b03') + : ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b34' : 'b24') + : 'b14') + : 'b04'))))) + : ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b34' : 'b24') + : 'b14') + : 'b04'))) + : $donnees['map_image']; + + if ($donnees['ville_user'] == 3 && $donnees['ville_name'] == PLANVILLAGE) { + $image = "o99"; + } + + /* ========================= + ATTACK MARKERS (numeric for JSON) + ========================= */ $att = ""; - if(isset($_SESSION['troops_movement'])) { + + if (isset($_SESSION['troops_movement'])) { if (isset($_SESSION['troops_movement']['attacks']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['attacks'])) { $att = 3; - }elseif (isset($_SESSION['troops_movement']['scouts']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['scouts'])) { + } elseif (isset($_SESSION['troops_movement']['scouts']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['scouts'])) { $att = 6; - }elseif (isset($_SESSION['troops_movement']['enforcements']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['enforcements'])) { + } elseif (isset($_SESSION['troops_movement']['enforcements']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['enforcements'])) { $att = 9; } } - //Javascript map info - $regcount=0; - if($yrow!=7){ - $map_js .= "[".$donnees['map_x'].",".$donnees['map_y'].",".$donnees['map_fieldtype'].",". ((!empty($donnees['map_oasis'])) ? $donnees['map_oasis'] : 0) .",\"d=".$donnees['map_id']."&c=".$generator->getMapCheck($donnees['map_id'])."\",\"".$image."\",\"".$att."\""; - if($donnees['map_occupied']){ - if($donnees['map_fieldtype'] != 0){ - $map_js.= ",\"".$donnees['ville_name']."\",\"".$donnees['user_username']."\",\"".$donnees['ville_pop']."\",\"".$donnees['aliance_name']."\",\"".$donnees['user_tribe']."\"]\n"; - } - } - elseif($donnees['map_oasis'] != 0){ - if ($donnees['oasis_conqured'] != 0){ - $map_js.= ",\"\",\"".$donnees['oasis_user']."\",\"-\",\"".$donnees['oasis_alli_name']."\",\"".$donnees['oasis_tribe']."\"]"; - } - else{ - $map_js.="]"; - } - } - else{$map_js .= "]";} + /* ========================= + JS MAP DATA + ========================= */ + if ($yrow!= 7) { + $map_js.= "[". $donnees['map_x']. ",". $donnees['map_y']. ",". $donnees['map_fieldtype']. ",". ((!empty($donnees['map_oasis']))? $donnees['map_oasis'] : 0). ",\"d=". $donnees['map_id']. "&c=". $generator->getMapCheck($donnees['map_id']). "\",\"". $image. "\",\"". $att. "\""; - if($i == 6 && $yrow !=6){ - $i = -1; - $yrow +=1; - $map_js .= "],["; - } - else { - if($yrow == 6 && $i == 6) {$map_js .= "]";} - else {$map_js .= ",";} - } - $regcount += 1; - } - else {$map_js .= "]";} - ++$i; + if ($donnees['map_occupied']) { + if ($donnees['map_fieldtype']!= 0) { + $map_js.= ",\"". $donnees['ville_name']. "\",\"". $donnees['user_username']. "\",\"". $donnees['ville_pop']. "\",\"". $donnees['aliance_name']. "\",\"". $donnees['user_tribe']. "\"]\n"; + } + } elseif ($donnees['map_oasis']!= 0) { + if ($donnees['oasis_conqured']!= 0) { + $map_js.= ",\"\",\"". $donnees['oasis_user']. "\",\"-\",\"". $donnees['oasis_alli_name']. "\",\"". $donnees['oasis_tribe']. "\"]"; + } else { + $map_js.= "]"; + } + } else { + $map_js.= "]"; + } + + if ($i == 6 && $yrow!= 6) { + $i = -1; + $yrow++; + $map_js.= "],["; + } else { + $map_js.= ($yrow == 6 && $i == 6)? "]" : ","; + } + } else { + $map_js.= "]"; + } + + $i++; } -echo '[['.$map_js.']'; + +echo '[['. $map_js. ']'; \ No newline at end of file diff --git a/Templates/Ajax/mapscroll2.tpl b/Templates/Ajax/mapscroll2.tpl index db81d269..739548d9 100644 --- a/Templates/Ajax/mapscroll2.tpl +++ b/Templates/Ajax/mapscroll2.tpl @@ -1,174 +1,272 @@ WORLD_MAX)? $x-WORLD_MAX*2-1 : $x; -$y = ($y < -WORLD_MAX)? $y+WORLD_MAX*2+1 : $y; -$y = ($y > WORLD_MAX)? $y-WORLD_MAX*2-1 : $y; -$xm6 = ($x-6) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-5 : $x-6; -$xm5 = ($x-5) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-4 : $x-5; -$xm4 = ($x-4) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-3 : $x-4; -$xm3 = ($x-3) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-2 : $x-3; -$xm2 = ($x-2) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-1 : $x-2; -$xm1 = ($x-1) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX : $x-1; -$xp1 = ($x+1) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX : $x+1; -$xp2 = ($x+2) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+1 : $x+2; -$xp3 = ($x+3) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+2: $x+3; -$xp4 = ($x+4) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+3 : $x+4; -$xp5 = ($x+5) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+4 : $x+5; -$xp6 = ($x+6) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+5: $x+6; -$ym6 = ($y-6) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-5 : $y-6; -$ym5 = ($y-5) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-4 : $y-5; -$ym4 = ($y-4) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-3 : $y-4; -$ym3 = ($y-3) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-2 : $y-3; -$ym2 = ($y-2) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-1 : $y-2; -$ym1 = ($y-1) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX : $y-1; -$yp1 = ($y+1) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX : $y+1; -$yp2 = ($y+2) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+1 : $y+2; -$yp3 = ($y+3) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+2: $y+3; -$yp4 = ($y+4) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+3: $y+4; -$yp5 = ($y+5) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+4 : $y+5; -$yp6 = ($y+6) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+5: $y+6; -$xarray = array($xm6,$xm5,$xm4,$xm3,$xm2,$xm1,$x,$xp1,$xp2,$xp3,$xp4,$xp5,$xp6); -$yarray = array($ym6,$ym5,$ym4,$ym3,$ym2,$ym1,$y,$yp1,$yp2,$yp3,$yp4,$yp5,$yp6); -$maparray = array(); -$xcount = 0; +/* ========================= + WORLD WRAP (original +1 logic preserved) +========================= */ +$x = ($x < -$W)? $x + $W * 2 + 1 : $x; +$x = ($x > $W)? $x - $W * 2 - 1 : $x; +$y = ($y < -$W)? $y + $W * 2 + 1 : $y; +$y = ($y > $W)? $y - $W * 2 - 1 : $y; + +/* ========================= + MAP COORDINATES CALCULATION (13x13) +========================= */ +$xm6 = ($x - 6) < -$W? $x + $W + $W - 5 : $x - 6; +$xm5 = ($x - 5) < -$W? $x + $W + $W - 4 : $x - 5; +$xm4 = ($x - 4) < -$W? $x + $W + $W - 3 : $x - 4; +$xm3 = ($x - 3) < -$W? $x + $W + $W - 2 : $x - 3; +$xm2 = ($x - 2) < -$W? $x + $W + $W - 1 : $x - 2; +$xm1 = ($x - 1) < -$W? $x + $W + $W : $x - 1; + +$xp1 = ($x + 1) > $W? $x - $W - $W : $x + 1; +$xp2 = ($x + 2) > $W? $x - $W - $W + 1 : $x + 2; +$xp3 = ($x + 3) > $W? $x - $W - $W + 2 : $x + 3; +$xp4 = ($x + 4) > $W? $x - $W - $W + 3 : $x + 4; +$xp5 = ($x + 5) > $W? $x - $W - $W + 4 : $x + 5; +$xp6 = ($x + 6) > $W? $x - $W - $W + 5 : $x + 6; + +$ym6 = ($y - 6) < -$W? $y + $W + $W - 5 : $y - 6; +$ym5 = ($y - 5) < -$W? $y + $W + $W - 4 : $y - 5; +$ym4 = ($y - 4) < -$W? $y + $W + $W - 3 : $y - 4; +$ym3 = ($y - 3) < -$W? $y + $W + $W - 2 : $y - 3; +$ym2 = ($y - 2) < -$W? $y + $W + $W - 1 : $y - 2; +$ym1 = ($y - 1) < -$W? $y + $W + $W : $y - 1; + +$yp1 = ($y + 1) > $W? $y - $W - $W : $y + 1; +$yp2 = ($y + 2) > $W? $y - $W - $W + 1 : $y + 2; +$yp3 = ($y + 3) > $W? $y - $W - $W + 2 : $y + 3; +$yp4 = ($y + 4) > $W? $y - $W - $W + 3 : $y + 4; +$yp5 = ($y + 5) > $W? $y - $W - $W + 4 : $y + 5; +$yp6 = ($y + 6) > $W? $y - $W - $W + 5 : $y + 6; + +/* ========================= + MAP GRID ARRAYS +========================= */ +$xarray = array($xm6, $xm5, $xm4, $xm3, $xm2, $xm1, $x, $xp1, $xp2, $xp3, $xp4, $xp5, $xp6); +$yarray = array($ym6, $ym5, $ym4, $ym3, $ym2, $ym1, $y, $yp1, $yp2, $yp3, $yp4, $yp5, $yp6); + $maparray = ''; $maparray2 = ''; -for($i=0; $i<=12; $i++){ - if($xcount != 13){ - $maparray .= '\''.$generator->getBaseID($xarray[$xcount],$yarray[$i]).'\','; - $maparray2 .= $generator->getBaseID($xarray[$xcount],$yarray[$i]).','; - if($i==12){ - $i = -1; - $xcount +=1; - } - } + +$xcount = 0; + +for ($i = 0; $i <= 12; $i++) { + if ($xcount!= 13) { + $id = $generator->getBaseID($xarray[$xcount], $yarray[$i]); + + $maparray.= "'". $id. "',"; + $maparray2.= $id. ","; + + if ($i == 12) { + $i = -1; + $xcount++; + } + } } -$maparray = (substr($maparray, 0, -1)); -$maparray2 = (substr($maparray2, 0, -1)); -//echo $maparray; +$maparray = substr($maparray, 0, -1); +$maparray2 = substr($maparray2, 0, -1); -$query2 = "SELECT - ".TB_PREFIX."wdata.id AS map_id, - ".TB_PREFIX."wdata.fieldtype AS map_fieldtype, - ".TB_PREFIX."wdata.oasistype AS map_oasis, - ".TB_PREFIX."wdata.x AS map_x, - ".TB_PREFIX."wdata.y AS map_y, - ".TB_PREFIX."wdata.occupied AS map_occupied, - ".TB_PREFIX."wdata.image AS map_image, +/* ========================= + MAIN MAP QUERY +========================= */ +$query2 = " +SELECT + ". TB_PREFIX. "wdata.id AS map_id, + ". TB_PREFIX. "wdata.fieldtype AS map_fieldtype, + ". TB_PREFIX. "wdata.oasistype AS map_oasis, + ". TB_PREFIX. "wdata.x AS map_x, + ". TB_PREFIX. "wdata.y AS map_y, + ". TB_PREFIX. "wdata.occupied AS map_occupied, + ". TB_PREFIX. "wdata.image AS map_image, - ".TB_PREFIX."odata.conqured AS oasis_conqured, - info_user_oasis.username AS oasis_user, - info_user_oasis.tribe AS oasis_tribe, - info_alliance_oasis.tag AS oasis_alli_name, + ". TB_PREFIX. "odata.conqured AS oasis_conqured, + info_user_oasis.username AS oasis_user, + info_user_oasis.tribe AS oasis_tribe, + info_alliance_oasis.tag AS oasis_alli_name, - ".TB_PREFIX."vdata.wref AS ville_id, - ".TB_PREFIX."vdata.owner AS ville_user, - ".TB_PREFIX."vdata.name AS ville_name, - ".TB_PREFIX."vdata.capital AS ville_capital, - ".TB_PREFIX."vdata.pop AS ville_pop, + ". TB_PREFIX. "vdata.wref AS ville_id, + ". TB_PREFIX. "vdata.owner AS ville_user, + ". TB_PREFIX. "vdata.name AS ville_name, + ". TB_PREFIX. "vdata.capital AS ville_capital, + ". TB_PREFIX. "vdata.pop AS ville_pop, - ".TB_PREFIX."users.id AS user_id, - ".TB_PREFIX."users.username AS user_username, - ".TB_PREFIX."users.tribe AS user_tribe, - ".TB_PREFIX."users.alliance AS user_alliance, + ". TB_PREFIX. "users.id AS user_id, + ". TB_PREFIX. "users.username AS user_username, + ". TB_PREFIX. "users.tribe AS user_tribe, + ". TB_PREFIX. "users.alliance AS user_alliance, - ".TB_PREFIX."alidata.id AS aliance_id, - ".TB_PREFIX."alidata.tag AS aliance_name + ". TB_PREFIX. "alidata.id AS aliance_id, + ". TB_PREFIX. "alidata.tag AS aliance_name - FROM ((((((".TB_PREFIX."wdata - LEFT JOIN ".TB_PREFIX."vdata ON ".TB_PREFIX."vdata.wref = ".TB_PREFIX."wdata.id ) - LEFT JOIN ".TB_PREFIX."odata ON ".TB_PREFIX."odata.wref = ".TB_PREFIX."wdata.id ) - LEFT JOIN ".TB_PREFIX."users AS info_user_oasis ON info_user_oasis.id = ".TB_PREFIX."odata.owner ) - LEFT JOIN ".TB_PREFIX."alidata AS info_alliance_oasis ON info_alliance_oasis.id = info_user_oasis.alliance ) - LEFT JOIN ".TB_PREFIX."users ON ".TB_PREFIX."users.id = ".TB_PREFIX."vdata.owner ) - LEFT JOIN ".TB_PREFIX."alidata ON ".TB_PREFIX."alidata.id = ".TB_PREFIX."users.alliance ) - where ".TB_PREFIX."wdata.id IN ($maparray) - ORDER BY FIND_IN_SET(".TB_PREFIX."wdata.id,'$maparray2')"; +FROM ((((((". TB_PREFIX. "wdata + LEFT JOIN ". TB_PREFIX. "vdata ON ". TB_PREFIX. "vdata.wref = ". TB_PREFIX. "wdata.id) + LEFT JOIN ". TB_PREFIX. "odata ON ". TB_PREFIX. "odata.wref = ". TB_PREFIX. "wdata.id) + LEFT JOIN ". TB_PREFIX. "users AS info_user_oasis ON info_user_oasis.id = ". TB_PREFIX. "odata.owner) + LEFT JOIN ". TB_PREFIX. "alidata AS info_alliance_oasis ON info_alliance_oasis.id = info_user_oasis.alliance) + LEFT JOIN ". TB_PREFIX. "users ON ". TB_PREFIX. "users.id = ". TB_PREFIX. "vdata.owner) + LEFT JOIN ". TB_PREFIX. "alidata ON ". TB_PREFIX. "alidata.id = ". TB_PREFIX. "users.alliance) -//echo $query2; -$result2 = mysqli_query($database->dblink,$query2) or die(mysqli_error($database->dblink)); +WHERE ". TB_PREFIX. "wdata.id IN ($maparray) +ORDER BY FIND_IN_SET(". TB_PREFIX. "wdata.id,'$maparray2') +"; -$i=0; -$i2=0; +$result2 = mysqli_query($database->dblink, $query2) or die(mysqli_error($database->dblink)); + +/* ========================= + OUTPUT PREPARATION +========================= */ +$i = 0; $yrow = 0; -$row = 0; -$coorindex = 0; -$map_js =''; +$map_js = ''; -while ($donnees = mysqli_fetch_assoc($result2)){ +/* ========================= + MAIN LOOP (UNCHANGED LOGIC) +========================= */ +while ($donnees = mysqli_fetch_assoc($result2)) { -$targetalliance=$donnees["aliance_id"]; -$friendarray=$database->getAllianceAlly($donnees["aliance_id"],1); -$neutralarray=$database->getAllianceAlly($donnees["aliance_id"],2); -$enemyarray=$database->getAllianceWar2($donnees["aliance_id"]); + $targetalliance = $donnees["aliance_id"]; -$friend = ((isset($friendarray[0]) && isset($friendarray[0]['alli1']) && isset($friendarray[0]['alli2']) && $friendarray[0]['alli1']>0 and $friendarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($friendarray[0]['alli1']==$_SESSION['alliance_user'] or $friendarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0'; + $friendarray = $database->getAllianceAlly($donnees["aliance_id"], 1); + $neutralarray = $database->getAllianceAlly($donnees["aliance_id"], 2); + $enemyarray = $database->getAllianceWar2($donnees["aliance_id"]); -$war = ((isset($enemyarray[0]) && isset($enemyarray[0]['alli1']) && isset($enemyarray[0]['alli2']) && $enemyarray[0]['alli1']>0 and $enemyarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($enemyarray[0]['alli1']==$_SESSION['alliance_user'] or $enemyarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0'; + $sessionAlliance = $_SESSION['alliance_user']; -$neutral = ((isset($neutralarray[0]) && isset($neutralarray[0]['alli1']) && isset($neutralarray[0]['alli2']) && $neutralarray[0]['alli1']>0 and $neutralarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($neutralarray[0]['alli1']==$_SESSION['alliance_user'] or $neutralarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0'; + $friend = ((isset($friendarray[0]) && isset($friendarray[0]['alli1']) && isset($friendarray[0]['alli2']) && $friendarray[0]['alli1'] > 0 && $friendarray[0]['alli2'] > 0 && $donnees["aliance_id"] > 0) && ($friendarray[0]['alli1'] == $sessionAlliance || $friendarray[0]['alli2'] == $sessionAlliance) && ($sessionAlliance!= $targetalliance && $sessionAlliance && $targetalliance))? '1' : '0'; + $war = ((isset($enemyarray[0]) && isset($enemyarray[0]['alli1']) && isset($enemyarray[0]['alli2']) && $enemyarray[0]['alli1'] > 0 && $enemyarray[0]['alli2'] > 0 && $donnees["aliance_id"] > 0) && ($enemyarray[0]['alli1'] == $sessionAlliance || $enemyarray[0]['alli2'] == $sessionAlliance) && ($sessionAlliance!= $targetalliance && $sessionAlliance && $targetalliance))? '1' : '0'; -$image = ($donnees['map_occupied'] == 1 && $donnees['map_fieldtype'] > 0)?(($donnees['ville_user'] == $_SESSION['id_user'])? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b30': 'b20' :'b10' : 'b00') : (($targetalliance != 0)? ($friend==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b31': 'b21' :'b11' : 'b01') : ($war==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b32': 'b22' :'b12' : 'b02') : ($neutral==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b35': 'b25' :'b15' : 'b05') : ($targetalliance == $_SESSION['alliance_user']? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b33': 'b23' :'b13' : 'b03') : ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b34': 'b24' :'b14' : 'b04'))))) : ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b34': 'b24' :'b14' : 'b04'))) : $donnees['map_image']; -if($donnees['ville_user']==3 && $donnees['ville_name']==PLANVILLAGE){ -$image = "o99"; -} + $neutral = ((isset($neutralarray[0]) && isset($neutralarray[0]['alli1']) && isset($neutralarray[0]['alli2']) && $neutralarray[0]['alli1'] > 0 && $neutralarray[0]['alli2'] > 0 && $donnees["aliance_id"] > 0) && ($neutralarray[0]['alli1'] == $sessionAlliance || $neutralarray[0]['alli2'] == $sessionAlliance) && ($sessionAlliance!= $targetalliance && $sessionAlliance && $targetalliance))? '1' : '0'; + /* IMAGE DECISION */ + $image = ($donnees['map_occupied'] == 1 && $donnees['map_fieldtype'] > 0) + ? (($donnees['ville_user'] == $_SESSION['id_user']) + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b30' : 'b20') + : 'b10') + : 'b00') + : (($targetalliance!= 0) + ? ($friend == 1 + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b31' : 'b21') + : 'b11') + : 'b01') + : ($war == 1 + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b32' : 'b22') + : 'b12') + : 'b02') + : ($neutral == 1 + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b35' : 'b25') + : 'b15') + : 'b05') + : ($targetalliance == $sessionAlliance + ? ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b33' : 'b23') + : 'b13') + : 'b03') + : ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b34' : 'b24') + : 'b14') + : 'b04'))))) + : ($donnees['ville_pop'] >= 100 + ? ($donnees['ville_pop'] >= 250 + ? ($donnees['ville_pop'] >= 500? 'b34' : 'b24') + : 'b14') + : 'b04'))) + : $donnees['map_image']; + + if ($donnees['ville_user'] == 3 && $donnees['ville_name'] == PLANVILLAGE) { + $image = "o99"; + } + + /* ATTACK MARKERS */ $att = ""; - if(isset($_SESSION['troops_movement'])) { + if (isset($_SESSION['troops_movement'])) { if (isset($_SESSION['troops_movement']['attacks']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['attacks'])) { $att = 3; - }elseif (isset($_SESSION['troops_movement']['scouts']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['scouts'])) { + } elseif (isset($_SESSION['troops_movement']['scouts']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['scouts'])) { $att = 6; - }elseif (isset($_SESSION['troops_movement']['enforcements']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['enforcements'])) { + } elseif (isset($_SESSION['troops_movement']['enforcements']) && in_array($donnees['map_id'], $_SESSION['troops_movement']['enforcements'])) { $att = 9; } } - //Javascript map info - $regcount=0; - if($yrow!=13){ - $map_js .= "[".$donnees['map_x'].",".$donnees['map_y'].",".$donnees['map_fieldtype'].",". ((!empty($donnees['map_oasis'])) ? $donnees['map_oasis'] : 0) .",\"d=".$donnees['map_id']."&c=".$generator->getMapCheck($donnees['map_id'])."\",\"".$image."\",\"".$att."\""; - if($donnees['map_occupied']){ - if($donnees['map_fieldtype'] != 0){ - $map_js.= ",\"".$donnees['ville_name']."\",\"".$donnees['user_username']."\",\"".$donnees['ville_pop']."\",\"".$donnees['aliance_name']."\",\"".$donnees['user_tribe']."\"]\n"; - } - } - elseif($donnees['map_oasis'] != 0){ - if ($donnees['oasis_conqured'] != 0){ - $map_js.= ",\"\",\"".$donnees['oasis_user']."\",\"-\",\"".$donnees['oasis_alli_name']."\",\"".$donnees['oasis_tribe']."\"]"; - } - else{ - $map_js.="]"; - } - } - else{$map_js .= "]";} + /* JS MAP DATA */ + if ($yrow!= 13) { + $map_js.= "[". $donnees['map_x']. ",". $donnees['map_y']. ",". $donnees['map_fieldtype']. ",". ((!empty($donnees['map_oasis']))? $donnees['map_oasis'] : 0). ",\"d=". $donnees['map_id']. "&c=". $generator->getMapCheck($donnees['map_id']). "\",\"". $image. "\",\"". $att. "\""; - if($i == 12 && $yrow !=12){ - $i = -1; - $yrow +=1; - $map_js .= "],["; - } - else { - if($yrow == 12 && $i == 12) {$map_js .= "]";} - else {$map_js .= ",";} - } - $regcount += 1; - } - else {$map_js .= "]";} - ++$i; + if ($donnees['map_occupied']) { + if ($donnees['map_fieldtype']!= 0) { + $map_js.= ",\"". $donnees['ville_name']. "\",\"". $donnees['user_username']. "\",\"". $donnees['ville_pop']. "\",\"". $donnees['aliance_name']. "\",\"". $donnees['user_tribe']. "\"]\n"; + } + } elseif ($donnees['map_oasis']!= 0) { + if ($donnees['oasis_conqured']!= 0) { + $map_js.= ",\"\",\"". $donnees['oasis_user']. "\",\"-\",\"". $donnees['oasis_alli_name']. "\",\"". $donnees['oasis_tribe']. "\"]"; + } else { + $map_js.= "]"; + } + } else { + $map_js.= "]"; + } + + if ($i == 12 && $yrow!= 12) { + $i = -1; + $yrow++; + $map_js.= "],["; + } else { + $map_js.= ($yrow == 12 && $i == 12)? "]" : ","; + } + } else { + $map_js.= "]"; + } + + $i++; } -echo '[['.$map_js.']'; + +echo '[['. $map_js. ']'; \ No newline at end of file diff --git a/Templates/Alliance/changepos.tpl b/Templates/Alliance/changepos.tpl index df864aae..009a22a8 100644 --- a/Templates/Alliance/changepos.tpl +++ b/Templates/Alliance/changepos.tpl @@ -4,26 +4,56 @@ ## --------------------------------------------------------------------------- ## ## Project: TravianZ (Refactor incremental) ## ## File: changepos.tpl ## -## Description: Alliance member permissions ## +## Description: Alliance member permissions ## ## Improvements: ## ## - Fixed PHP 5.3 compatibility (no [] arrays) ## -## - Removed invalid array syntax ## +## - Removed invalid array syntax ## ## - Input validation & casting ## ## - XSS protection ## ## - Cleaner checkbox rendering ## +## - Allow leader to edit own rank only ## ################################################################################# // secure input -$aUser = isset($_POST['a_user']) ? (int)$_POST['a_user'] : 0; +$aUser = isset($_POST['a_user'])? (int)$_POST['a_user'] : 0; + +// fallback alliance id +if (!isset($aid)) { + $aid = $session->alliance; +} + +// load data +$playerData = $database->getAlliPermissions($aUser, $aid); +$playername = $database->getUserField($aUser, 'username', 0); +$allianceinfo = $database->getAlliance($aid); + +// status checks +$isLeader = $database->isAllianceOwner($session->uid); +$isSelfEdit = ($aUser == $session->uid); +$isTargetLeader = $database->isAllianceOwner($aUser); +$allowOnlyRank = ($isLeader && $isSelfEdit); // liderul se editeaza pe sine + +// Permission map - definit aici ca sa-l folosim si pentru hidden inputs +$map = array( + array('e1','opt1','Assign to position'), + array('e2','opt2','Kick player'), + array('e3','opt3','Change alliance description'), + array('e6','opt6','Alliance diplomacy'), + array('e7','opt7','IGMs to every alliance member'), + array('e4','opt4','Invite a player into the alliance'), + array('e5','opt5','Manage forums') +); // validation checks -if ($database->getUserField($aUser, "alliance", 0) != $session->alliance) { +if ($database->getUserField($aUser, "alliance", 0)!= $session->alliance) { $form->addError("perm", USER_NOT_IN_YOUR_ALLY); -} elseif ($aUser == $session->uid) { +} elseif ($isSelfEdit &&!$isLeader) { + // membrii normali nu au voie sa-si editeze singuri permisiunile $form->addError("perm", CANT_EDIT_YOUR_PERMISSIONS); -} elseif ($database->isAllianceOwner($aUser)) { +} elseif ($isTargetLeader &&!$isSelfEdit) { + // nu poti edita un alt lider $form->addError("perm", CANT_EDIT_LEADER_PERMISSIONS); } @@ -36,20 +66,10 @@ if ($form->returnErrors() > 0) { exit; } -// fallback alliance id -if (!isset($aid)) { - $aid = $session->alliance; -} - -// load data -$playerData = $database->getAlliPermissions($aUser, $aid); -$playername = $database->getUserField($aUser, 'username', 0); -$allianceinfo = $database->getAlliance($aid); - // header -echo "

" . htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') . - " - " . - htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') . +echo "

". htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8'). + " - ". + htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8'). "

"; include("alli_menu.tpl"); @@ -58,76 +78,44 @@ include("alli_menu.tpl");
- - - - + - -
Assign to position
Name:
Position:
- + + - - - "; } ?> -
Assign rights
@@ -136,16 +124,28 @@ foreach ($map as $r) {
+ + +

As a leader, you can only change your title. Your rights remain at their maximum.

+'."\n"; +} +?> +

- + diff --git a/Templates/Build/1.tpl b/Templates/Build/1.tpl index 1da5c52a..7dcd2a7b 100644 --- a/Templates/Build/1.tpl +++ b/Templates/Build/1.tpl @@ -1,53 +1,49 @@ resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentProd = $bid1[$currentLevel]['prod'] * SPEED; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = ($village->capital == 1) ? 20 : 10; + +// calculează nivelul următor luând în calcul queue-urile +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextProd = $bid1[$nextLevel]['prod'] * SPEED; ?> -

-

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

-

- - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($village->capital == 1) { - if($next<=20){ - ?> - - - - - - - - - - - - - - - - - - - - -
:resarray['f'.$id]]['prod']* SPEED; ?>
:
:
:
:
- -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/10.tpl b/Templates/Build/10.tpl index ebe51fd6..c7e6188b 100644 --- a/Templates/Build/10.tpl +++ b/Templates/Build/10.tpl @@ -1,38 +1,47 @@ -
-

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

-

+// WAREHOUSE - - - - - - -isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next<=20){ - ?> - - - - - - - -
resarray['f'.$id]]['attri']*STORAGE_MULTIPLIER; ?>
: 20:
- resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentCapacity = $bid10[$currentLevel]['attri'] * STORAGE_MULTIPLIER; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = 20; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextCapacity = $bid10[$nextLevel]['attri'] * STORAGE_MULTIPLIER; ?> -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/11.tpl b/Templates/Build/11.tpl index 0ea0d379..d9ca9f6c 100644 --- a/Templates/Build/11.tpl +++ b/Templates/Build/11.tpl @@ -1,39 +1,47 @@ -
-

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

-

+// GRANARY - - - - - - - -isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next<=20){ - ?> - - - - - - - -
resarray['f'.$id]]['attri']*STORAGE_MULTIPLIER; ?>
: 20:
-resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentCapacity = $bid11[$currentLevel]['attri'] * STORAGE_MULTIPLIER; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = 20; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextCapacity = $bid11[$nextLevel]['attri'] * STORAGE_MULTIPLIER; ?> -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/12.tpl b/Templates/Build/12.tpl index fdd98911..2e4ed325 100644 --- a/Templates/Build/12.tpl +++ b/Templates/Build/12.tpl @@ -1,16 +1,29 @@ -
-

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

-

getTypeLevel(12) > 0) { - include("12_upgrades.tpl"); - } else { - echo "


\n"; - } -include("upgrade.tpl"); + +// BLACKSMITH + +// nu ai next.tpl aici în original, îl las așa +$field = 'f' . $id; +$currentLevel = (int) ($village->resarray[$field] ?? 0); +$hasBlacksmith = $building->getTypeLevel(12) > 0; ?> -

-
+
+ + +

+ + +

+ +

+ + + + +

+ + + +
\ No newline at end of file diff --git a/Templates/Build/12_upgrades.tpl b/Templates/Build/12_upgrades.tpl index 8c33c809..077ae147 100644 --- a/Templates/Build/12_upgrades.tpl +++ b/Templates/Build/12_upgrades.tpl @@ -1,99 +1,145 @@ +getABTech($village->wid); +$ABups = $technology->getABUpgrades('b'); +$totalUps = count($ABups); +$blacksmithLevel = $building->getTypeLevel(12); +$bsAttri = $bid12[$blacksmithLevel]['attri'] / 100; + +$start = $session->tribe * 10 - 9; +$end = $session->tribe * 10 - 2; +?> - - - - - - - - - getABTech($village->wid); - $ABups = $technology->getABUpgrades('b'); - $totalUps = count($ABups); - for($i=($session->tribe*10-9);$i<=($session->tribe*10-2);$i++) { - $j = $i % 10 ; - if ( $technology->getTech($i) || $j == 1 ) { - - echo ""; - } - else if ($building->getTypeLevel(12) <= $abdata['b'.$j]+$ups) { - echo ""; - } - else if(${'ab'.$i}[$abdata['b'.$j]+1+$ups]['wood'] > $village->maxstore || ${'ab'.$i}[$abdata['b'.$j]+1+$ups]['clay'] > $village->maxstore || ${'ab'.$i}[$abdata['b'.$j]+1+$ups]['iron'] > $village->maxstore) { - echo ""; - } - else if (${'ab'.$i}[$abdata['b'.$j]+1+$ups]['crop'] > $village->maxcrop) { - echo ""; - } - else if (${'ab'.$i}[$abdata['b'.$j]+1+$ups]['wood'] > $village->awood || ${'ab'.$i}[$abdata['b'.$j]+1+$ups]['clay'] > $village->aclay || ${'ab'.$i}[$abdata['b'.$j]+1+$ups]['iron'] > $village->airon || ${'ab'.$i}[$abdata['b'.$j]+1+$ups]['crop'] > $village->acrop) { - if($village->getProd("crop")>0 || $village->acrop > ${'ab'.$i}[$abdata['b'.$j]+1+$ups]['crop']){ - $time = $technology->calculateAvaliable(12,${'ab'.$i}[$abdata['b'.$j]+1+$ups]); - echo "
".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1].""; - } else { - echo "
".CROP_NEGATIVE.""; - } - echo ""; - } - else if ($totalUps == 1 && !$session->plus || $totalUps > 1) { - echo ""; - } - else if($session->access != BANNED){ - echo ""; - }else{ - echo ""; - } - } - } - ?> - + + + + + + + + getTech($i) || $j == 1)) continue; + + $unitName = $technology->getUnitName($i); + $current = (int)$abdata['b'.$j]; + + // câte upgrade-uri sunt deja în coadă pentru unitatea asta + $ups = 0; + foreach ($ABups as $up) { + if (in_array('b'.$j, $up)) $ups++; + } + $shownLevel = $current + $ups; + $nextLevel = $shownLevel + 1; + $ab = ${'ab'.$i}; + $next = $ab[$nextLevel]?? null; + ?> + + + + + + +
-\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> -".$technology->getUnitName($i)." (Level ".$abdata['b'.$j]; - $ups = 0; - if($totalUps > 0){ - foreach($ABups as $upgrade){ - if(in_array(("b".$j), $upgrade)) $ups++; - } - if($ups > 0) echo "+".$ups; - } - echo ")
"; - - if($abdata['b'.$j]+$ups != 20) { - echo "
\"Lumber\"".${'ab'.$i}[$abdata['b'.$j]+1+$ups]['wood']."|\"Clay\"".${'ab'.$i}[$abdata['b'.$j]+1+$ups]['clay']."|\"Iron\"".${'ab'.$i}[$abdata['b'.$j]+1+$ups]['iron']."|\"Crop\"".${'ab'.$i}[$abdata['b'.$j]+1+$ups]['crop']."|\"duration\""; - echo $generator->getTimeFormat(round(${'ab'.$i}[$abdata['b'.$j]+1+$ups]['time']*($bid12[$building->getTypeLevel(12)]['attri'] / 100)/SPEED)); - - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(${'ab'.$i}[$abdata['b'.$j]+1+$ups]['wood'] + ${'ab'.$i}[$abdata['b'.$j]+1+$ups]['clay'] + ${'ab'.$i}[$abdata['b'.$j]+1+$ups]['iron'] + ${'ab'.$i}[$abdata['b'.$j]+1+$ups]['crop']); - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } - } - if($abdata['b'.$j] == 20) { - echo "
".MAXIMUM_LEVEL."
".UPGRADE_BLACKSMITH."
".EXPAND_WAREHOUSE."
".EXPAND_GRANARY."
".TOO_FEW_RESOURCES."
".UPGRADE_IN_PROGRESS."
mchecker."\">".UPGRADE.""; - if($totalUps != 0) echo " ".WAITING.""; - echo"
".UPGRADE.""; - if($totalUps != 0) echo " ".WAITING.""; - echo"
+
+ <?= $unitName?> + + ( 0? '+'.$ups : ''?>) +
+ + +
+ Lumber | + Clay | + Iron | + Crop | + duration + getTimeFormat(round($next['time'] * $bsAttri / SPEED))?> + + userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $totalRequired; + ?> + + | + NPC trade + + + + $village->awood || $next['clay'] > $village->aclay || $next['iron'] > $village->airon || $next['crop'] > $village->acrop) { + if ($village->getProd('crop') > 0 || $village->acrop > $next['crop']) { + $time = $technology->calculateAvaliable(12, $next); + echo '
'.ENOUGH_RESOURCES.' '.$time[0].' at '.$time[1].''; + } else { + echo '
'.CROP_NEGATIVE.''; + } + } + ?> +
+ +
+ = 20):?> +
+ + +
+ + $village->maxstore || $next['clay'] > $village->maxstore || $next['iron'] > $village->maxstore)):?> +
+ + $village->maxcrop):?> +
+ + $village->awood || $next['clay'] > $village->aclay || $next['iron'] > $village->airon || $next['crop'] > $village->acrop)):?> +
+ + plus || $totalUps > 1):?> +
+ + access!= BANNED):?> + + + + + + + +
- 0) { - echo " -"; - foreach($ABups as $black) { - $count++; - $ABUnit = substr($black['tech'], 1, 2); - $abdata['b'.$ABUnit]++; - $unit = ($session->tribe - 1) * 10 + $ABUnit; - echo ""; - echo ""; - $date = $generator->procMtime($black['timestamp']); - echo ""; - echo ""; - } - echo "
".UPGRADING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit); - echo " (".LEVEL." ".$abdata['b'.$ABUnit].")"; - if($count > 1) echo " ".WAITING.""; - echo "timer."\">".$generator->getTimeFormat($black['timestamp']-time())."".$date[1]." hrs
"; - } -?> + 0):?> + + + + + + + + + + tribe - 1) * 10 + $ABUnit; + $unitName = $technology->getUnitName($unit); + $date = $generator->procMtime($black['timestamp']); + ?> + + + + + + + +
+ <?= $unitName?> + + ( ) + 1):?> + getTimeFormat($black['timestamp'] - time())?> hrs
+ \ No newline at end of file diff --git a/Templates/Build/13.tpl b/Templates/Build/13.tpl index cf21d0cf..02d873d8 100644 --- a/Templates/Build/13.tpl +++ b/Templates/Build/13.tpl @@ -1,16 +1,28 @@ -
-

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

-

getTypeLevel(13) > 0) { - include("13_upgrades.tpl"); - } else { - echo "

Upgrades can commence when armoury is completed.
\n"; - } -include("upgrade.tpl"); + +// ARMOURY + +$field = 'f' . $id; +$currentLevel = isset($village->resarray[$field]) ? (int)$village->resarray[$field] : 0; +$hasArmoury = $building->getTypeLevel(13) > 0; ?> -

-
+
+ + +

+ + +

+ +

+ + + + +

+ + + +
\ No newline at end of file diff --git a/Templates/Build/13_upgrades.tpl b/Templates/Build/13_upgrades.tpl index c0c66527..0155dffb 100644 --- a/Templates/Build/13_upgrades.tpl +++ b/Templates/Build/13_upgrades.tpl @@ -1,99 +1,144 @@ +getABTech($village->wid); +$ABups = $technology->getABUpgrades('a'); +$totalUps = count($ABups); +$armouryLevel = $building->getTypeLevel(13); +$arAttri = $bid13[$armouryLevel]['attri'] / 100; + +$start = $session->tribe * 10 - 9; +$end = $session->tribe * 10 - 2; +?> - - - - - - - - - getABTech($village->wid); - $ABups = $technology->getABUpgrades('a'); - $totalUps = count($ABups); - for($i=($session->tribe*10-9);$i<=($session->tribe*10-2);$i++) { - $j = $i % 10 ; - if ( $technology->getTech($i) || $j == 1 ) { - - echo ""; - } - else if ($building->getTypeLevel(13) <= $abdata['a'.$j]+$ups) { - echo ""; - } - else if(${'ab'.$i}[$abdata['a'.$j]+1+$ups]['wood'] > $village->maxstore || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['clay'] > $village->maxstore || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['iron'] > $village->maxstore) { - echo ""; - } - else if (${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop'] > $village->maxcrop) { - echo ""; - } - else if (${'ab'.$i}[$abdata['a'.$j]+1+$ups]['wood'] > $village->awood || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['clay'] > $village->aclay || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['iron'] > $village->airon || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop'] > $village->acrop) { - if($village->getProd("crop")>0 || $village->acrop > ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop']){ - $time = $technology->calculateAvaliable(13,${'ab'.$i}[$abdata['a'.$j]+1+$ups]); - echo "
".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1].""; - } else { - echo "
".CROP_NEGATIVE.""; - } - echo ""; - } - else if ($totalUps == 1 && !$session->plus || $totalUps > 1) { - echo ""; - } - else if($session->access != BANNED){ - echo ""; - }else{ - echo ""; - } - } - } - ?> - + + + + + + + + getTech($i) || $j == 1)) continue; + + $unitName = $technology->getUnitName($i); + $current = (int)$abdata['a'.$j]; + + // câte upgrade-uri sunt deja în coadă pentru unitatea asta + $ups = 0; + foreach ($ABups as $up) { + if (in_array('a'.$j, $up)) $ups++; + } + $shownLevel = $current + $ups; + $nextLevel = $shownLevel + 1; + $ab = ${'ab'.$i}; + $next = $ab[$nextLevel]?? null; + ?> + + + + + + +
-\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> -".$technology->getUnitName($i)." (Level ".$abdata['a'.$j]; - $ups = 0; - if($totalUps > 0){ - foreach($ABups as $upgrade){ - if(in_array(("a".$j), $upgrade)) $ups++; - } - if($ups > 0) echo "+".$ups; - } - echo ")
"; - - if($abdata['a'.$j]+$ups != 20) { - echo "
\"Lumber\"".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['wood']."|\"Clay\"".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['clay']."|\"Iron\"".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['iron']."|\"Crop\"".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop']."|\"duration\""; - echo $generator->getTimeFormat(round(${'ab'.$i}[$abdata['a'.$j]+1+$ups]['time']*($bid13[$building->getTypeLevel(13)]['attri'] / 100)/SPEED)); - - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(${'ab'.$i}[$abdata['a'.$j]+1+$ups]['wood'] + ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['clay'] + ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['iron'] + ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop']); - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } - } - if($abdata['a'.$j] == 20) { - echo "
".MAXIMUM_LEVEL."
".UPGRADE_ARMOURY."
".EXPAND_WAREHOUSE."
".EXPAND_GRANARY."
".TOO_FEW_RESOURCES."
".UPGRADE_IN_PROGRESS."
mchecker."\">".UPGRADE.""; - if($totalUps != 0) echo " ".WAITING.""; - echo"
".UPGRADE.""; - if($totalUps != 0) echo " ".WAITING.""; - echo"
+
+ <?= $unitName?> + + ( 0? '+'.$ups : ''?>) +
+ + +
+ Lumber | + Clay | + Iron | + Crop | + duration + getTimeFormat(round($next['time'] * $arAttri / SPEED))?> + + userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $totalRequired; + ?> + + | + NPC trade + + + + $village->awood || $next['clay'] > $village->aclay || $next['iron'] > $village->airon || $next['crop'] > $village->acrop) { + if ($village->getProd('crop') > 0 || $village->acrop > $next['crop']) { + $time = $technology->calculateAvaliable(13, $next); + echo '
'.ENOUGH_RESOURCES.' '.$time[0].' at '.$time[1].''; + } else { + echo '
'.CROP_NEGATIVE.''; + } + } + ?> +
+ +
+ = 20):?> +
+ + +
+ + $village->maxstore || $next['clay'] > $village->maxstore || $next['iron'] > $village->maxstore)):?> +
+ + $village->maxcrop):?> +
+ + $village->awood || $next['clay'] > $village->aclay || $next['iron'] > $village->airon || $next['crop'] > $village->acrop)):?> +
+ + plus || $totalUps > 1):?> +
+ + access!= BANNED):?> + + + + + + + +
- 0) { - echo " -"; - foreach($ABups as $arms) { - $count++; - $ABUnit = substr($arms['tech'], 1, 2); - $abdata['a' . $ABUnit]++; - $unit = ($session->tribe - 1) * 10 + $ABUnit; - echo ""; - echo ""; - $date = $generator->procMtime($arms['timestamp']); - echo ""; - echo ""; - } - echo "
".UPGRADING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit); - echo " (".LEVEL." ".$abdata['a'.$ABUnit].")"; - if($count > 1) echo " ".WAITING.""; - echo "timer."\">".$generator->getTimeFormat($arms['timestamp']-time())."".$date[1]." hrs
"; - } -?> + 0):?> + + + + + + + + + + tribe - 1) * 10 + $ABUnit; + $unitName = $technology->getUnitName($unit); + $date = $generator->procMtime($arms['timestamp']); + ?> + + + + + + + +
+ <?= $unitName?> + + ( ) + 1):?> + getTimeFormat($arms['timestamp'] - time())?> hrs
+ \ No newline at end of file diff --git a/Templates/Build/14.tpl b/Templates/Build/14.tpl index 52e2ff77..b41ce62b 100644 --- a/Templates/Build/14.tpl +++ b/Templates/Build/14.tpl @@ -1,37 +1,47 @@ -
-

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

-

+// TOURNAMENT SQUARE - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next <= 20){ - ?> - - - - - - - -
resarray['f'.$id] > 0 ? $bid14[$village->resarray['f'.$id]]['attri'] : 100; ?>
: 20:
-resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentSpeed = $currentLevel > 0 ? $bid14[$currentLevel]['attri'] : 100; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = 20; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextSpeed = $bid14[$nextLevel]['attri']; ?> -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/15.tpl b/Templates/Build/15.tpl index 279fa6de..150ff0b2 100644 --- a/Templates/Build/15.tpl +++ b/Templates/Build/15.tpl @@ -1,41 +1,52 @@ -
-

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

-

+// MAIN BUILDING - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id] + 1 + $loopsame + $doublebuild + $master; - if($next <= 20){ - ?> - - - - - - - -
resarray['f'.$id] > 0 ? round($bid15[$village->resarray['f'.$id]]['attri']) : 300; ?>
: 20:
- -resarray['f'.$id] >= 10){ - include("Templates/Build/15_1.tpl"); -} -include("upgrade.tpl"); +include 'next.tpl'; + +$field = 'f' . $id; +$currentLevel = (int)($village->resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentTime = $currentLevel > 0 ? round($bid15[$currentLevel]['attri']) : 300; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = 20; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextTime = round($bid15[$nextLevel]['attri']); ?> -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + = 10) { + include 'Templates/Build/15_1.tpl'; + } + include 'upgrade.tpl'; + ?> +
\ No newline at end of file diff --git a/Templates/Build/15_1.tpl b/Templates/Build/15_1.tpl index 3940231b..7a758201 100644 --- a/Templates/Build/15_1.tpl +++ b/Templates/Build/15_1.tpl @@ -1,123 +1,147 @@ delDemolition($village->wid); header("Location: build.php?gid=15&ty=$ty&cancel=0&demolish=0"); - exit; + exit; } -if($session->alliance) $memberCount = $database->countAllianceMembers($session->alliance); -else $memberCount = 0; +$memberCount = $session->alliance? $database->countAllianceMembers($session->alliance) : 0; +$VillageLevels = $database->getResourceLevel($village->wid); -if(!empty($_REQUEST["demolish"]) && $_REQUEST["c"] == $session->mchecker) { - if($_REQUEST["type"] != null && ($_REQUEST["type"] >= 19 && $_REQUEST["type"] <= 40 || $_REQUEST["type"] == 99)) { - $type = $_REQUEST['type']; - $demolish_permitted = $database->addDemolition($village->wid,$type); - if ($demolish_permitted === true) { - $session->changeChecker(); - header("Location: build.php?gid=15&ty=$type&cancel=0&demolish=0"); - } - else header("Location: build.php?gid=15&ty=$type&nodemolish=".$demolish_permitted); - exit; +// start demolition +if (!empty($_REQUEST['demolish']) && $_REQUEST['c'] == $session->mchecker) { + $type = (int)($_REQUEST['type']?? 0); + $instant = isset($_POST['instant']) && $_POST['instant'] == '1'; + + if ($type >= 19 && $type <= 40 || $type == 99) { + $field = 'f'.$type; + $buildType = $VillageLevels[$field.'t']; + $currentLvl = $VillageLevels[$field]; + + // blocaj ambasada - la fel ca originalul + if($buildType == 18 && $session->alliance && $database->isAllianceOwner($session->uid) == $session->alliance && $memberCount > 1){ + header("Location: build.php?gid=15&ty=$type&nodemolish=18"); + exit; + } + + if($instant){ + // DEMOLARE COMPLETA CU GOLD + if($session->gold < 10){ + header("Location: build.php?gid=15&ty=$type¬enoughgold=1"); + exit; + } + if($currentLvl > 0){ + // sterge orice demolare in curs + $database->delDemolition($village->wid); + // setare nivel 0 direct in DB + $database->query("UPDATE ".TB_PREFIX."fdata SET `$field` = 0, `{$field}t` = 0 WHERE `vref` = ".$village->wid); + // scade gold + $database->modifyGold($session->uid, -10, 0); + $session->gold -= 10; + $session->changeChecker(); + header("Location: build.php?gid=15&ty=$type&demolished=1"); + exit; + } + }else{ + // DEMOLARE CLASICA + $ok = $database->addDemolition($village->wid, $type); + if ($ok === true) { + $session->changeChecker(); + header("Location: build.php?gid=15&ty=$type&cancel=0&demolish=0"); + } else { + header("Location: build.php?gid=15&ty=$type&nodemolish=$ok"); + } + exit; + } } } -if($village->resarray['f'.$id] >= DEMOLISH_LEVEL_REQ) { - echo "

".DEMOLITION_BUILDING.""; - $VillageResourceLevels = $database->getResourceLevel($village->wid); - $DemolitionProgress = $database->getDemolition($village->wid); - if (!empty($DemolitionProgress)) { - $Demolition = $DemolitionProgress[0]; - echo ""; - echo "cancel "; - echo "".DEMOLITION_OF." ".$building->procResType($VillageResourceLevels['f'.$Demolition['buildnumber'].'t']).": ".$generator->getTimeFormat($Demolition['timetofinish']-time()).""; - if($session->gold >= 2) { - ?> - Finish all construction and research orders in this village immediately for 2 Gold? - "; -} else { - if (isset($_GET['nodemolish'])) { - switch ($_GET['nodemolish']) { - case 18: - echo '

- Because you are the leader of your alliance, demolition of your current Embassy cannot be started, - since it still holds all of your '.$memberCount.' alliance members. - You can, however quit the alliance, while selecting a new leader - in the "quit alliance" form, then continue the demolition. -

'; - break; - } - } +if ($village->resarray['f'.$id] < DEMOLISH_LEVEL_REQ) return; - echo " -mchecker."\" method=\"POST\" style=\"display:inline\"> -"; -} -} -?> +$Demolition = $database->getDemolition($village->wid); +$inProgress =!empty($Demolition)? $Demolition[0] : null; +?> +

- \ No newline at end of file diff --git a/Templates/Build/16.tpl b/Templates/Build/16.tpl index 015b9ab0..f0740cae 100644 --- a/Templates/Build/16.tpl +++ b/Templates/Build/16.tpl @@ -1,315 +1,204 @@ unitarray = $database->getUnit($village->wid, false); + +// RALLY POINT + +if (isset($_GET['refresh'])) { + $village->unitarray = $database->getUnit($village->wid, false); } -?>
- -

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

-

- -resarray['f39'] > 0){ - include_once ("16_menu.tpl"); - $units_type = $database->getMovement(34, $village->wid, 1); - $settlers = $database->getMovement(7, $village->wid, 1); - $oasis_incoming = 0; - $array = $database->getOasis($village->wid); - foreach($array as $conqured) $oasis_incoming += count($database->getMovement(6, $conqured['wref'], 0)); - - $units_incoming = count($units_type); - $settlers_incoming = count($settlers); - for($i = 0; $i < $units_incoming; $i++){ - if($units_type[$i]['attack_type'] == 1 && $units_type[$i]['sort_type'] == 3) $units_incoming -= 1; - } - if($units_incoming > 0 || $settlers_incoming > 0 || $oasis_incoming > 0){ - ?> -

()

- - -

- - - - - - - - - - -
vname; ?> - -
- enforcetome) > 0){ - foreach($village->enforcetome as $enforce){ - $colspan = 10 + $enforce['hero']; - if($enforce['from'] != 0){ - echo " -"; - $tribe = $database->getUserField($database->getVillageField($enforce['from'], "owner"), "tribe", 0); - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - if($enforce['hero'] != 0){ - echo ""; - } - echo ""; - for($i = $start; $i <= ($start + 9); $i++){ - if($enforce['u'.$i] == 0){ - echo ""; - } - if($enforce['hero'] != 0){ - echo ""; - } - echo " -"; - echo "
-getMapCheck($enforce['from'])."\">".$database->getVillageField($enforce['from'], "name").""; - if(LANG == "es"){ - echo "getVillageField($enforce['from'], "owner")."\">".TROOPS." ".$database->getUserField($database->getVillageField($enforce['from'], "owner"), "username", 0)." "; - }else{ - echo "getVillageField($enforce['from'], "owner")."\">".$database->getUserField($database->getVillageField($enforce['from'], "owner"), "username", 0)." ".TROOPS.""; - } - echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
".TROOPS.""; - }else{ - echo ""; - } - echo $enforce['u'.$i]."".$enforce['hero']."
".UPKEEP."
".$technology->getUpkeep($enforce, $tribe)."\"Crop\"".PER_HR."
"; - }else{ - echo " -"; - $tribe = 4; - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - if($enforce['hero'] != 0){ - echo ""; - } - echo ""; - for($i = $start; $i <= ($start + 9); $i++){ - if($enforce['u'.$i] == 0){ - echo ""; - } - if($enforce['hero'] != 0){ - echo ""; - } - echo " -"; - echo "
-".TASKMASTER.""; - echo " ".VILLAGE_OF_THE_ELDERS_TROOPS.""; - echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
".TROOPS.""; - }else{ - echo ""; - } - echo $enforce['u'.$i]."".$enforce['hero']."
".UPKEEP."
".$technology->getUpkeep($enforce, $tribe)."\"Crop\"".PER_HR."
".SEND_BACK."
"; - } - } - } - $enforcevill = array(); - $enforceoasis = array(); - $allenforce = $village->enforcetoyou; - $enforcemeoasis = $village->enforceoasis; - if(count($allenforce) > 0){ - foreach($allenforce as $enforce){ - $conquredvid = $database->getOasisField($enforce['vref'], "conqured"); - if($conquredvid > 0){ - $enforce['conqured'] = $conquredvid; - array_push($enforceoasis, $enforce); - }else{ - array_push($enforcevill, $enforce); - } - } - } - if(count($enforcemeoasis) > 0){ - foreach($enforcemeoasis as $enforce){ - array_push($enforceoasis, $enforce); - } - } - if(count($enforcevill) > 0){ - echo "

".TROOPS_IN_OTHER_VILLAGE."

"; - foreach($enforcevill as $enforce){ - $colspan = 10 + $enforce['hero']; - echo " -"; - $tribe = $database->getUserField($database->getVillageField($enforce['from'], "owner"), "tribe", 0); - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - if($enforce['hero'] != 0){ - echo ""; - } - echo ""; - for($i = $start; $i <= ($start + 9); $i++){ - if($enforce['u'.$i] == 0){ - echo ""; - } - if($enforce['hero'] != 0){ - echo ""; - } - echo " -"; - echo "
-getMapCheck($enforce['from'])."\">".$database->getVillageField($enforce['from'], "name").""; - echo "getMapCheck($enforce['vref'])."\">".REINFORCEMENTFOR." ".$database->getVillageField($enforce['vref'], "name")." "; - echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
".TROOPS.""; - }else{ - echo ""; - } - echo $enforce['u'.$i]."".$enforce['hero']."
".UPKEEP."
".$technology->getUpkeep($enforce, $tribe)."\"Crop\"".PER_HR."
"; - } - } - if(count($enforceoasis) > 0){ - echo "

".TROOPS_IN_OASIS."

"; - foreach($enforceoasis as $enforce){ - $colspan = 10 + $enforce['hero']; - echo " -"; - $tribe = $database->getUserField($database->getVillageField($enforce['from'], "owner"), "tribe", 0); - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - if($enforce['hero'] != 0){ - echo ""; - } - echo ""; - for($i = $start; $i <= ($start + 9); $i++){ - if($enforce['u'.$i] == 0){ - echo ""; - } - if($enforce['hero'] != 0){ - echo ""; - } - echo " -"; - echo "
-getMapCheck($enforce['vref'])."\">".$database->getVillageField($enforce['conqured'], "name").""; - if(LANG == "es"){ - echo "getVillageField($enforce['from'], "owner")."\">".TROOPS." ".$database->getUserField($database->getVillageField($enforce['from'], "owner"), "username", 0)." ".FROM." getMapCheck($enforce['from'])."\">".$database->getVillageField($enforce['from'], "name").""; - }else{ - echo "getVillageField($enforce['from'], "owner")."\">".$database->getUserField($database->getVillageField($enforce['from'], "owner"), "username", 0)." ".TROOPS." ".FROM." getMapCheck($enforce['from'])."\">".$database->getVillageField($enforce['from'], "name").""; - } - echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
".TROOPS.""; - }else{ - echo ""; - } - echo $enforce['u'.$i]."".$enforce['hero']."
".UPKEEP."
".$technology->getUpkeep($enforce, $tribe)."\"Crop\"".PER_HR."
"; - } - } - if(count($database->getPrisoners3($village->wid)) > 0){ - echo "

".PRISONERS."

"; - foreach($database->getPrisoners3($village->wid) as $prisoners){ - $colspan = 10 + $prisoners['t11']; - $colspan2 = $colspan + 1; - echo " -"; - $tribe = $database->getUserField($database->getVillageField($prisoners['from'], "owner"), "tribe", 0); - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - if($prisoners['t11'] != 0){ - echo ""; - } - echo ""; - for($i = 1; $i <= 10; $i++){ - if($prisoners['t'.$i] == 0){ - echo ""; - } - if($prisoners['t11'] > 0) echo ""; - echo " -"; - echo "
-getMapCheck($prisoners['wref'])."\">".$database->getVillageField($prisoners['wref'], "name").""; - echo "getMapCheck($prisoners['wref'])."\">".PRISONERSIN." ".$database->getVillageField($prisoners['wref'], "name").""; - echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
".TROOPS.""; - }else - echo ""; - echo $prisoners['t'.$i]."".$prisoners['t11']."
".UPKEEP."
".$technology->getUpkeep($prisoners, $tribe, 0, 1)."\"Crop\"".PER_HR."
"; - } - } - if(count($database->getPrisoners($village->wid)) > 0){ - echo "

".PRISONERS."

"; - foreach($database->getPrisoners($village->wid) as $prisoners){ - $colspan = 10 + $prisoners['t11']; - $colspan2 = $colspan + 1; - echo " -"; - $tribe = $database->getUserField($database->getVillageField($prisoners['from'], "owner"), "tribe", 0); - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - if($prisoners['t11'] != 0){ - echo ""; - } - echo ""; - for($i = 1; $i <= 10; $i++){ - if($prisoners['t'.$i] == 0){ - echo ""; - } - if($prisoners['t11'] > 0) echo ""; - - echo " -"; - echo "
-getMapCheck($prisoners['from'])."\">".$database->getVillageField($prisoners['from'], "name").""; - echo "getMapCheck($prisoners['from'])."\">".PRISONERSFROM." ".$database->getVillageField($prisoners['from'], "name").""; - echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
".TROOPS.""; - }else - echo ""; - echo $prisoners['t'.$i]."".$prisoners['t11']."
\"Crop\"
"; - } - } - ?> - -getMovement(3, $village->wid, 0); - $settlers = $database->getMovement(5, $village->wid, 0); - $units_incoming = count($units_type); - for($i = 0; $i < $units_incoming; $i++){ - if($units_type[$i]['vref'] != $village->wid) $units_incoming -= 1; - } - $units_incoming += count($settlers); - - if($units_incoming >= 1){ - echo "

".TROOPS_ON_THEIR_WAY."

"; - include ("16_walking.tpl"); - } -} -else echo ''.RALLYPOINT_COMMENCE.'
'; - -include ("upgrade.tpl"); +$hasRally = $village->resarray['f39'] > 0; ?> -

+
+ +

resarray['f'.$id] ?>

+

+ + + + + getMovement(34, $village->wid, 1); + $settlers = $database->getMovement(7, $village->wid, 1); + $oasis_incoming = 0; + foreach ($database->getOasis($village->wid) as $o) { + $oasis_incoming += count($database->getMovement(6, $o['wref'], 0)); + } + $units_incoming = count($units_type); + foreach ($units_type as $u) if ($u['attack_type'] == 1 && $u['sort_type'] == 3) $units_incoming--; + $totalIncoming = $units_incoming + count($settlers) + $oasis_incoming; + ?> + + 0): ?> +

()

+ + + + +

+ + + + + + + + +
vname ?>
+ + + enforcetome as $e): + $isTaskmaster = $e['from'] == 0; + $colspan = 10 + $e['hero']; + $tribe = $isTaskmaster ? 4 : $database->getUserField($database->getVillageField($e['from'],'owner'),'tribe',0); + $start = ($tribe-1)*10+1; + ?> + + + + + + + + + + +
+ + getVillageField($e['from'],'name') ?> + + + getVillageField($e['from'],'owner'); + $uname = $database->getUserField($owner,'username',0); + ?> + + +
 
+
getUpkeep($e,$tribe) ?>
+
+
+ + + enforcetoyou as $e) { + $conq = (int)$database->getOasisField($e['vref'],'conqured'); + if ($conq>0) { $e['conqured']=$conq; $enforceoasis[]=$e; } else $enforcevill[]=$e; + } + foreach ($village->enforceoasis as $e) $enforceoasis[]=$e; + ?> + + + +

+ getUserField($database->getVillageField($e['from'],'owner'),'tribe',0); $start=($tribe-1)*10+1; + ?> + + + + + + + + + + +
getVillageField($e['from'],'name') ?> getVillageField($e['vref'],'name') ?>
 
+
getUpkeep($e,$tribe) ?>
+
+
+ + + + + +

+ getVillageField($e['from'],'owner'); $tribe=$database->getUserField($owner,'tribe',0); $start=($tribe-1)*10+1; + ?> + + + + + + + + + + +
getVillageField($e['conqured'],'name') ?> + getUserField($owner,'username',0) ?> getVillageField($e['from'],'name') ?> +
 
+
getUpkeep($e,$tribe) ?>
+
+
+ + + + + getPrisoners3($village->wid); if($p3): ?> +

+ getUserField($database->getVillageField($p['from'],'owner'),'tribe',0); $start=($tribe-1)*10+1; + ?> + + + + + + + + + + +
getVillageField($p['wref'],'name') ?> getVillageField($p['wref'],'name') ?>
 
+
getUpkeep($p,$tribe,0,1) ?>
+
+
+ + + + + getPrisoners($village->wid); if($p): ?> +

+ getUserField($database->getVillageField($pr['from'],'owner'),'tribe',0); $start=($tribe-1)*10+1; + ?> + + + + + + + + + + +
getVillageField($pr['from'],'name') ?> getVillageField($pr['from'],'name') ?>
 
+
+
+
+ + + + getMovement(3,$village->wid,0); + $set = $database->getMovement(5,$village->wid,0); + $cnt = count($set); + foreach($out as $u) if($u['vref']==$village->wid) $cnt++; + ?> + =1): ?> +

+ + + + +
+ + +
\ No newline at end of file diff --git a/Templates/Build/16_99.tpl b/Templates/Build/16_99.tpl index e367dcd6..6ccc0234 100644 --- a/Templates/Build/16_99.tpl +++ b/Templates/Build/16_99.tpl @@ -1,60 +1,65 @@ goldclub) include("Templates/Build/16.tpl"); -else -{ -?> -
-

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

-

- -
- -
-
- - +// RALLY POINT GOLD CLUB + +if (!$session->goldclub) { + include 'Templates/Build/16.tpl'; + return; +} + +$hideEvasion = isset($hideevasion) ? (int)$hideevasion : 0; +$user = $database->getUserArray($session->uid, 1); +?> +
+ +

resarray['f'.$id] ?>

+

+ + + +
+ +
+
+ + +
- - - + - - - + + + - - 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 = ''; - ?> + + villages as $wref): + $vname = $database->getVillageField($wref, 'name'); + $vchecked = $database->getVillageField($wref, 'evasion'); + $reinf = $database->getEnforceVillage($wref, 0); + $checked = $vchecked == 1 ? 'checked' : ''; + ?> - - - - + + + + - getUserArray($session->uid, 1); - ?> - -
>
getUnitsNumber($wref); ?>
>
getUnitsNumber($wref) ?>
-
-
- - (: Gold2 ) -

- -
- \ No newline at end of file + + + + +
+
+ + + + (: Gold2 ) +
+

+
+ +
\ No newline at end of file diff --git a/Templates/Build/16_incomming.tpl b/Templates/Build/16_incomming.tpl index 598836bc..0d4f8356 100644 --- a/Templates/Build/16_incomming.tpl +++ b/Templates/Build/16_incomming.tpl @@ -1,328 +1,141 @@ getMovement(34, $village->wid, 1); -$total_for = count($units); -$send = $database->getMovement(1, $village->wid, 1); -$total_for2 = count($send); $artifactsSum = $database->getArtifactsSumByKind($session->uid, $village->wid, 3); -for($y = 0; $y < $total_for; $y++){ - $session->timer++; - if($units[$y]['sort_type'] == 3){ - if($units[$y]['attack_type'] == 2) $actionType = REINFORCEMENTFOR; - elseif($units[$y]['attack_type'] == 3) $actionType = ATTACK_ON; - elseif($units[$y]['attack_type'] == 4) $actionType = RAID_ON; - - $reinfowner = $database->getVillageField($units[$y]['from'], "owner"); - if($units[$y]['attack_type'] != 1){ - if($units[$y]['from'] != 0){ - if($units[$y]['t11'] > 0 && $reinfowner == $session->uid) $colspan = 11; - else $colspan = 10; - - echo " - "; - $tribe = $database->getUserField($database->getVillageField($units[$y]['from'], "owner"), "tribe", 0); - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - if($units[$y]['t11'] != 0 && $reinfowner == $session->uid){ - echo ""; - } - echo ""; - for($i = 1; $i <= $colspan; $i++){ - $totalunits = $units[$y]['t1'] + $units[$y]['t2'] + $units[$y]['t3'] + $units[$y]['t4'] + $units[$y]['t5'] + $units[$y]['t6'] + $units[$y]['t7'] + $units[$y]['t8'] + $units[$y]['t9'] + $units[$y]['t10'] + $units[$y]['t11']; - if($units[$y]['attack_type'] == 2){ - if($reinfowner != $session->uid) echo ""; - else - { - if($units[$y]['t'.$i] == 0) echo ""; - else - { - echo ""; - } - } - }else{ - if($artifactsSum['totals'] == 0) echo ""; - else - { - if($units[$y]['t'.$i] == 0) echo ""; - else echo ""; - } - } - } - echo ""; - echo ' - - - - - - "; - echo "
- getMapCheck($units[$y]['from'])."\">".$database->getVillageField($units[$y]['from'], "name").""; - echo "getMapCheck($units[$y]['to'])."\">".$actionType." ".$database->getVillageField($units[$y]['to'], "name").""; - echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
".TROOPS."?0"; - echo $units[$y]['t'.$i]."?0?
'.ARRIVAL.' -
timer.'>'.$generator->getTimeFormat($units[$y]['endtime'] - time()).' h
'; - $datetime = $generator->procMtime($units[$y]['endtime']); - echo "
"; - if($datetime[0] != "today") echo "".ON." ".$datetime[0]." "; - echo "".AT." ".$datetime[1]." ".HRS."
- -
"; - }else{ - echo " - "; - $tribe = 4; - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - echo ""; - for($i = 1; $i <= 10; $i++){ - echo ""; - } - echo ""; - echo ' - - - - - - "; - echo "
- village of the elders"; - echo "".VILLAGE_OF_THE_ELDERS_TROOPS.""; - echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />
".TROOPS."?
'.ARRIVAL.' -
timer.'>'.$generator->getTimeFormat($units[$y]['endtime'] - time()).' h
'; - $datetime = $generator->procMtime($units[$y]['endtime']); - echo "
"; - if($datetime[0] != "today") echo "".ON." ".$datetime[0]." "; - echo "".AT." ".$datetime[1]."
- -
"; - } - } - }else if($units[$y]['sort_type'] == 4){ - $actionType = RETURNFROM; - - $isoasis = $database->isVillageOases($units[$y]['from']); - if($isoasis == 0) $from = $database->getMInfo($units[$y]['from']); - else $from = $database->getOMInfo($units[$y]['from']); - - $to = $database->getMInfo($units[$y]['vref']); - ?> - - - - - - - - - - tribe; - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - if($units[$y]['t11'] != 0){ - echo ""; - } - ?> - - - - 0"; - else - { - echo ""; - } - } - ?> - - - 0){ - ?> - - - +?> - - - - - - - - - - -
vname; ?>
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
"; - echo $units[$y]['t'.$i]."
- \"Lumber\"".$units[$y]['wood']." | \"Clay\"".$units[$y]['clay']." | \"Iron\"".$units[$y]['iron']." | \"Crop\"".$units[$y]['crop'].""; - echo "
\"carry\"".$totalres."/".$totalcarry."
"; - ?> -
- timer.">".$generator->getTimeFormat($units[$y]['endtime'] - time())." h"; - $datetime = $generator->procMtime($units[$y]['endtime']); - echo "
"; - if($datetime[0] != "today") echo "".ON." ".$datetime[0]." "; - echo "".AT." ".$datetime[1]."
"; - ?> - -
-getOasis($village->wid); -foreach($array as $conqured){ - $oasis = $database->getMovement("6", $conqured['wref'], 0); - $total_for = count($oasis); - for($y = 0; $y < $total_for; $y++){ - $session->timer++; - $to = $database->getOMInfo($oasis[$y]['to']); - if($oasis[$y]['attack_type'] == 2) $actionType = REINFORCEMENTFOR; - else if($oasis[$y]['attack_type'] == 3) $actionType = ATTACK_ON; - else if($oasis[$y]['attack_type'] == 4) $actionType = RAID_ON; - - $reinfowner = $database->getVillageField($oasis[$y]['from'], "owner"); - if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid) $colspan = 11; - else $colspan = 10; - - echo " - "; - $tribe = $database->getUserField($reinfowner, "tribe", 0); - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid){ - echo ""; - } - echo ""; - for($i = 1; $i <= $colspan; $i++){ - $totalunits = $oasis[$y]['t1'] + $oasis[$y]['t2'] + $oasis[$y]['t3'] + $oasis[$y]['t4'] + $oasis[$y]['t5'] + $oasis[$y]['t6'] + $oasis[$y]['t7'] + $oasis[$y]['t8'] + $oasis[$y]['t9'] + $oasis[$y]['t10'] + $oasis[$y]['t11']; - if($oasis[$y]['attack_type'] == 2){ - if($reinfowner != $session->uid) echo ""; - else - { - if($oasis[$y]['t'.$i] == 0) echo ""; - else - { - echo ""; - } - } - }else{ - if($artifactsSum['totals'] == 0) echo ""; - else - { - if($oasis[$y]['t'.$i] == 0) echo ""; - else echo ""; - } - } - } - echo ""; - echo ' - - - - - - "; - echo "
- getMapCheck($oasis[$y]['from'])."\">".$database->getVillageField($oasis[$y]['from'], "name").""; - echo "getMapCheck($oasis[$y]['to'])."\">".$actionType." ".$to['name'].""; - echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
".TROOPS."?0"; - echo $oasis[$y]['t'.$i]."?0?
'.ARRIVAL.' -
timer.'>'.$generator->getTimeFormat($oasis[$y]['endtime'] - time()).' h
'; - $datetime = $generator->procMtime($oasis[$y]['endtime']); - echo "
"; - if($datetime[0] != "today") echo "".ON." ".$datetime[0]." "; - echo "".AT." ".$datetime[1]." ".HRS."
- -
"; - } -} +timer++; + $sort = (int)$u['sort_type']; + $atk = (int)$u['attack_type']; -$settlers = $database->getMovement(7, $village->wid, 1); -$total_for3 = count($settlers); -for($x = 0; $x < $total_for3; $x++){ - $session->timer++; - $to = $database->getMInfo($settlers[$x]['to']); - ?> + if ($sort === 3 && $atk!= 1): + $action = ($atk == 2? REINFORCEMENTFOR : ($atk == 3? ATTACK_ON : RAID_ON)); + $from = (int)$u['from']; + $isElders = ($from === 0); + $owner = $isElders? 0 : $database->getVillageField($from, 'owner'); + $isMine = ($owner == $session->uid); + $colspan = ($u['t11'] > 0 && $isMine)? 11 : 10; + $tribe = $isElders? 4 : $database->getUserField($owner, 'tribe', 0); + $start = ($tribe - 1) * 10 + 1; + $end = $tribe * 10; + $dt = $generator->procMtime($u['endtime']); +?> - - - - - - - - tribe; - $start = ($tribe - 1) * 10 + 1; - $end = ($tribe * 10); - echo ""; - for($i = $start; $i <= ($end); $i++){ - echo ""; - } - ?> - - - - 0"; - else - { - echo ""; - } - } - ?> - - - - - - - - - + + + + + + + + + + + ?'; continue; } + if ($atk == 2) { + if (!$isMine) echo ''; + else echo ''; + } else { + if ($artifactsSum['totals']==0) echo ''; + else echo ''; + } + endfor;?> + + + + + +
vname; ?>
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />
"; - echo $settlers[$x]['t'.$i]."
- timer.">".$generator->getTimeFormat($settlers[$x]['endtime'] - time())." h"; - $datetime = $generator->procMtime($settlers[$x]['endtime']); - echo "
"; - if($datetime[0] != "today") echo "".ON." ".$datetime[0]." "; - echo "".AT." ".$datetime[1]."
"; - ?> - -
+ + getVillageField($from,'name')?> + village of the elders + + + getVillageField($u['to'],'name')?> + +
 
?'.($val==0?'0':$val).'?'.($val==0?'0':'?').'
+
getTimeFormat($u['endtime']-time())?> h
+
+
- \ No newline at end of file + +isVillageOases($u['from'])? $database->getOMInfo($u['from']) : $database->getMInfo($u['from']); + $colspan = $u['t11']? 11 : 10; + $tribe = $session->tribe; $start=($tribe-1)*10+1; + $totalRes = $u['wood']+$u['clay']+$u['iron']+$u['crop']; + $carry = 0; for($i=0;$i<10;$i++) { $t = isset($u['t'.($i+1)])? $u['t'.($i+1)] : 0; $carry += $t * ${'u'.($start+$i)}['cap']; } + $dt = $generator->procMtime($u['endtime']); +?> + + + + + + + + + + 0 && $atk!=1 && $atk!=2):?> + + + +
vname?>
 
+
| | |
+
/
+
+
getTimeFormat($u['endtime']-time())?> h
+
+
+ + +getOasis($village->wid) as $o): + foreach ($database->getMovement(6,$o['wref'],0) as $m): + $session->timer++; $owner=$database->getVillageField($m['from'],'owner'); $isMine=($owner==$session->uid); + $colspan=($m['t11']&&$isMine)?11:10; $tribe=$database->getUserField($owner,'tribe',0); $start=($tribe-1)*10+1; + $action=($m['attack_type']==2?REINFORCEMENTFOR:($m['attack_type']==3?ATTACK_ON:RAID_ON)); $dt=$generator->procMtime($m['endtime']); +?> + + + + + + + + '.($v?$v:'0').'' : ''; } + else { echo $artifactsSum['totals']==0? '' : ''; } + endfor;?> + + +
getVillageField($m['from'],'name')?> getOMInfo($m['to'])['name']?>
 
??'.($v==0?'0':'?').'
+
getTimeFormat($m['endtime']-time())?> h
+
+
+ + +getMovement(7,$village->wid,1) as $s): + $session->timer++; $tribe=$session->tribe; $start=($tribe-1)*10+1; $dt=$generator->procMtime($s['endtime']); +?> + + + + + + + + + + +
vname?>getMInfo($s['to'])['name']?>
 
+
getTimeFormat($s['endtime']-time())?> h
+
+
+ \ No newline at end of file diff --git a/Templates/Build/16_menu.tpl b/Templates/Build/16_menu.tpl index edf1c3c3..58c5f700 100644 --- a/Templates/Build/16_menu.tpl +++ b/Templates/Build/16_menu.tpl @@ -1,8 +1,16 @@ +goldclub); +$isGold = ($t === 99 && $session->goldclub); +?>
- goldclub)) echo "class=\"selected\""; ?> > | - | - - goldclub == 1){ ?>| - >Gold Club - + > | + | + + goldclub == 1): ?> | + >Gold Club +
\ No newline at end of file diff --git a/Templates/Build/16_troops.tpl b/Templates/Build/16_troops.tpl index 61929035..e2c08f2a 100644 --- a/Templates/Build/16_troops.tpl +++ b/Templates/Build/16_troops.tpl @@ -1,34 +1,34 @@ - tribe; - $start = ($tribe-1)*10+1; - $end = ($tribe*10); - echo " "; - for($i=$start;$i<=($end);$i++) { - echo "getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />"; - } - if($village->unitarray['hero'] != 0) { - echo "\"Hero\""; - } - - ?> - - unitarray['u'.$i] == 0) { - echo ""; - } - else { - echo ""; - } - echo $village->unitarray['u'.$i].""; - } +unitarray['hero'] != 0) { - echo ""; - echo $village->unitarray['hero'].""; - } - - ?> - - - ">getUpkeep($village->unitarray,0); ?>Crop +// RALLY POINT TROOPS + +$tribe = $session->tribe; +$start = ($tribe - 1) * 10 + 1; +$end = $tribe * 10; +$hasHero = $village->unitarray['hero'] != 0; +$colspan = $hasHero ? 11 : 10; +?> +  + + <?= $technology->getUnitName($i) ?> + + + Hero + + + + unitarray['u'.$i] ?? 0; + ?> + + + + unitarray['hero'] ?> + + + + + + + getUpkeep($village->unitarray, 0) ?>Crop + \ No newline at end of file diff --git a/Templates/Build/16_walking.tpl b/Templates/Build/16_walking.tpl index 6108dd40..c87a2042 100644 --- a/Templates/Build/16_walking.tpl +++ b/Templates/Build/16_walking.tpl @@ -1,170 +1,82 @@ getMovement(3,$village->wid,0); -$total_for = count($units); -for($y=0;$y<$total_for;$y++){ -$session->timer++; +// RALLY POINT WALKING -if($units[$y]['attack_type'] == 2){ - $attack_type = REINFORCEMENTFOR; - } -if($units[$y]['attack_type'] == 1){ - $attack_type = SCOUTING; - } -if($units[$y]['attack_type'] == 3){ - $attack_type = ATTACK_ON; - } -if($units[$y]['attack_type'] == 4){ - $attack_type = RAID_ON; - } -$isoasis = $database->isVillageOases($units[$y]['to']); -if ($isoasis ==0){ -$to = $database->getMInfo($units[$y]['to']); -} else { -$to = $database->getOMInfo($units[$y]['to']);} +$outgoing = $database->getMovement(3, $village->wid, 0); ?> - - - - - - - - - "; - for($i=($session->tribe-1)*10+1;$i<=$session->tribe*10;$i++) { - echo ""; - } - if($units[$y]['t11'] != 0) { - echo ""; - } - ?> - - - "; - } - else { - echo ""; - } - ?> - - 0 && $units[$y]['attack_type'] == 3 && !$database->isVillageOases($units[$y]['to'])){ ?> - - - - - - - - - - - - - - -
vname; ?>">
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
"; - } - echo $units[$y]['t'.$i]."
- - "> - -
"> - timer>".$generator->getTimeFormat($units[$y]['endtime']-time())." h"; - $datetime = $generator->procMtime($units[$y]['endtime']); - echo "
"; - if($datetime[0] != "today") { - echo "".ON." ".$datetime[0]." "; - } - echo "".AT." ".$datetime[1]."
"; - if (($units[$y]['starttime']+90)>time()){ - ?> - - - -
- - getMovement(5,$village->wid,0); - if($settlers){ - $total_for = count($settlers); - -for($y=0;$y<$total_for;$y++){ +timer++; + $atk = (int)$m['attack_type']; + if ($atk == 1) $action = SCOUTING; + elseif ($atk == 2) $action = REINFORCEMENTFOR; + elseif ($atk == 3) $action = ATTACK_ON; + elseif ($atk == 4) $action = RAID_ON; + else $action = ''; + $to = $database->isVillageOases($m['to'])? $database->getOMInfo($m['to']) : $database->getMInfo($m['to']); + $colspan = $m['t11']? 11 : 10; + $tribe = $session->tribe; + $start = ($tribe-1)*10+1; + $dt = $generator->procMtime($m['endtime']); ?> - - - - - - + + + + - tribe; - $start = ($tribe-1)*10+1; - $end = ($tribe*10); - echo ""; - for($i=$start;$i<=($end);$i++) { - echo ""; - } - ?> - - - 0"; - } - else { - echo ""; - } - } - ?> - - - - - - - + + + + + + + + + + 0 && $atk==3 &&!$database->isVillageOases($m['to'])):?> + + + + + + + + + + +
vname; ?>
vname?>
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />
"; - echo $units[$y]['t'.$i]."
"> - timer>".$generator->getTimeFormat($settlers[$y]['endtime']-time())." h"; - $datetime = $generator->procMtime($settlers[$y]['endtime']); - echo "
"; - if($datetime[0] != "today") { - echo "".ON." ".$datetime[0]." "; - } - echo "".AT." ".$datetime[1]."
"; - if (($settlers[$y]['starttime']+90)>time()){ - ?> - - - -
 
+
getTimeFormat($m['endtime']-time())?> h
+
+ time()):?> +
+ +
- + + +getMovement(5, $village->wid, 0); +foreach ($settlers as $s): + $session->timer++; $tribe=$session->tribe; $start=($tribe-1)*10+1; $dt=$generator->procMtime($s['endtime']); +?> + + + + + + + + + + + + +
vname?>
 
+
getTimeFormat($s['endtime']-time())?> h
+
+ time()):?> +
+ +
+ \ No newline at end of file diff --git a/Templates/Build/17.tpl b/Templates/Build/17.tpl index 44b0def5..3da813ac 100644 --- a/Templates/Build/17.tpl +++ b/Templates/Build/17.tpl @@ -1,307 +1,246 @@ -
-

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

-

-

- - - - merchantAvail(); +$maxcarry = (int)$market->maxcarry; +$totalMerchants = (int)$market->merchant; + +// --- POST sanitizat --- +$r = []; +for ($i = 1; $i <= 4; $i++) { + $r[$i] = isset($_POST['r'.$i])? max(0, (int)$_POST['r'.$i]) : 0; +} +$allres = array_sum($r); +$x = isset($_POST['x'])? trim($_POST['x']) : ''; +$y = isset($_POST['y'])? trim($_POST['y']) : ''; +$dname = isset($_POST['dname'])? trim($_POST['dname']) : ''; +$send3 = isset($_POST['send3'])? (int)$_POST['send3'] : 1; +$ft = $_POST['ft']?? ''; + +// --- target --- +$getwref = 0; +$checkexist = false; +$target = null; + +if ($x!== '' && $y!== '' && is_numeric($x) && is_numeric($y)) { + $getwref = (int)$database->getVilWref((int)$x, (int)$y); + $checkexist = $database->checkVilExist($getwref); +} elseif ($dname!== '') { + $getwref = (int)$database->getVillageByName($dname); + $checkexist = $database->checkVilExist($getwref); +} + +if ($checkexist) { + $villageOwner = (int)$database->getVillageField($getwref, 'owner'); + $userAccess = (int)$database->getUserField($villageOwner, 'access', 0); + $userVacation = (int)$database->getUserField($villageOwner, 'vac_mode', 0); + $userID = (int)$database->getUserField($villageOwner, 'id', 0); + + $target = [ + 'wref' => $getwref, + 'name' => $database->getVillageField($getwref, 'name'), + 'owner' => $villageOwner, + 'coor' => $database->getCoor($getwref), + ]; + $target['time'] = $generator->procDistanceTime($target['coor'], $village->coor, $session->tribe, 0); +} + +$maxTotalCarry = $maxcarry * $merchantAvail; +$canRepeat = ($send3 === 1) || ($send3 >= 2 && $send3 <= 3 && $session->goldclub); +$validTarget = $checkexist && $getwref!== $village->wid; +$validAccess = $checkexist && ($userAccess == 2 || $userAccess == MULTIHUNTER || (defined('ADMIN_ALLOW_INCOMING_RAIDS') && ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN)); + +$showConfirm = ($ft === 'check' && $canRepeat && $validTarget && $allres > 0 && $allres <= $maxTotalCarry && $validAccess && $userVacation == 0); + +// coordonate prefill din GET +$coor = ['x' => '', 'y' => '']; +if (isset($_GET['z'])) { + $coor = $database->getCoor((int)$_GET['z']); +} +?> +
+ +

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

+

+ + + + + + +
+ + + + + LUMBER,2=>CLAY,3=>IRON,4=>CROP]; + ?> + + + + + + + +
<?php echo $resNames[$i];?> /
+ + + + + + + + + + + + + + + + + + + + +
:(|)
:getUserField($target['owner'], 'username', 0));?>
:getTimeFormat($target['time']);?>
:
+ +
+

/>

+
+ + +
+ + + + LUMBER,2=>CLAY,3=>IRON,4=>CROP]; + ?> + + + + + + + +
<?php echo $resNames[$i];?>:()
+ + + + + + + + +
/
:
+ X: + Y: +
+
+ goldclub == 1):?> +

+ + + +

/>

+
+ + returnErrors() > 0) { + $error = ''.$form->getError("error").''; + } elseif (!$checkexist) { + $error = ''.NO_COORDINATES_SELECTED.''; + } elseif ($getwref == $village->wid) { + $error = ''.CANNOT_SEND_RESOURCES.''; + } elseif (!$canRepeat) { + $error = ''.INVALID_MERCHANTS_REPETITION.''; + } elseif (!$validAccess) { + $error = ''.BANNED_CANNOT_SEND_RESOURCES.'.'; + } elseif ($allres == 0) { + $error = ''.RESOURCES_NO_SELECTED.'.'; + } elseif ($userVacation == 1) { + $error = 'Player is on vacation mode. You cannot send resources to him.'; + } elseif ($x === '' && $y === '' && $dname === '') { + $error = ''.ENTER_COORDINATES.'.'; + } elseif ($allres > $maxTotalCarry) { + $error = ''.TOO_FEW_MERCHANTS.'.'; + } + echo $error; + } + ?> + + +

+ +recieving) > 0) { + echo "

".MERCHANT_COMING.":

"; + foreach ($market->recieving as $recieve) { + $villageowner = (int)$database->getVillageField($recieve['from'], "owner"); + echo ''; + echo ''; + echo ''; + echo '
'.htmlspecialchars($database->getUserField($villageowner,"username",0)).''.TRANSPORT_FROM.' '.htmlspecialchars($database->getVillageField($recieve['from'],"name")).'
'.ARRIVAL_IN.''; + echo '
'.$generator->getTimeFormat($recieve['endtime']-time()).' h
'; + $datetime = $generator->procMtime($recieve['endtime']); + echo '
'.($datetime[0]!= "today"? ON." ".$datetime[0]." " : "").AT." ".$datetime[1].'
'; + echo '
'.RESOURCES.''; + echo ''.LUMBER.''.$recieve['wood'].' | '; + echo ''.CLAY.''.$recieve['clay'].' | '; + echo ''.IRON.''.$recieve['iron'].' | '; + echo ''.CROP.''.$recieve['crop']; + echo '
'; } } -$allres = (int) $_POST['r1'] + (int) $_POST['r2'] + (int) $_POST['r3'] + (int) $_POST['r4']; -if(isset( $_POST['x'] ) && isset( $_POST['y'] ) && $_POST['x'] != "" && $_POST['y'] != "" && is_numeric($_POST['x']) && is_numeric($_POST['y'])){ - $getwref = $database->getVilWref($_POST['x'],$_POST['y']); - $checkexist = $database->checkVilExist($getwref); -} -else if(!empty($_POST['dname'])){ - $getwref = $database->getVillageByName($_POST['dname']); - $checkexist = $database->checkVilExist($getwref); -} -if(isset($checkexist) && $checkexist){ -$villageOwner = $database->getVillageField($getwref,'owner'); -$userAccess = $database->getUserField($villageOwner,'access',0); -$userVacation = $database->getUserField($villageOwner,'vac_mode',0); -$userID = $database->getUserField($villageOwner,'id',0); -} -$maxcarry = $market->maxcarry; -$maxcarry *= $market->merchantAvail(); -if(isset($_POST['ft'])=='check' && (($_POST['send3'] > 1 && $_POST['send3'] <= 3 && $session->goldclub) || $_POST['send3'] == 1) && $getwref != $village->wid && $allres!=0 && $allres <= $maxcarry && ($_POST['x']!="" && $_POST['y']!="" or $_POST['dname']!="") && $checkexist && ($userAccess == 2 || $userAccess == MULTIHUNTER || (ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN)) && $userVacation == 0){ -?> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lumber / maxcarry; ?>
Clay / maxcarry; ?>
Iron - / maxcarry; ?>
Crop - / maxcarry; ?>
- - - - getVilWref($_POST['x'],$_POST['y']); - $getvilname = $database->getVillageField($getwref, "name"); - $getvilowner = $database->getVillageField($getwref, "owner"); - $getvilcoor['y'] = $_POST['y']; - $getvilcoor['x'] = $_POST['x']; - $time = $generator->procDistanceTime($getvilcoor, $village->coor, $session->tribe, 0); - } - else if(!empty($_POST['dname'])){ - $getwref = $database->getVillageByName($_POST['dname']); - $getvilcoor = $database->getCoor($getwref); - $getvilname = $database->getVillageField($getwref, "name"); - $getvilowner = $database->getVillageField($getwref, "owner"); - $time = $generator->procDistanceTime($getvilcoor, $village->coor, $session->tribe, 0); - } - ?> - - - - - - - - - - - - - - - - - - -
:(|)
:getUserField($getvilowner,'username',0); ?>
:getTimeFormat($time); ?>
:maxcarry); ?>
-
- -
-

-

merchantAvail()) { echo "DISABLED"; }?>/>

- -
- - - - - - - - - - - - - - - - - - - - - - -
- Lumber - - : - - - - (maxcarry; ?>) -
- Clay - - : - - - - (maxcarry; ?>) -
- Iron - - : - - - - (maxcarry; ?>) -
- Crop - - : - - - - (maxcarry; ?>) -
- - - - - - - - - - -getCoor($_GET['z']); -} -else{ -$coor['x'] = ""; -$coor['y'] = ""; -} -?> - - -
merchantAvail(); ?>/merchant; ?>
- : - -
- X: - Y: -
-
-goldclub == 1){?> -

- - - -

merchantAvail()) { echo "DISABLED"; }?>/>

-returnErrors() > 0) $error = ''.$form->getError("error").''; - elseif(!$checkexist){ - $error = ''.NO_COORDINATES_SELECTED.''; - }elseif($getwref == $village->wid){ - $error = ''.CANNOT_SEND_RESOURCES.''; - }elseif($_POST['send3'] < 1 || $_POST['send3'] > 3 || ($_POST['send3'] > 1 && !$session->goldclub)){ - $error = ''.INVALID_MERCHANTS_REPETITION.''; - }elseif($userAccess == '0' or ($userAccess == MULTIHUNTER && $userID == 5) or (!ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN)){ - $error = ''.BANNED_CANNOT_SEND_RESOURCES.'.'; - }elseif($_POST['r1']==0 && $_POST['r2']==0 && $_POST['r3']==0 && $_POST['r4']==0){ - $error = ''.RESOURCES_NO_SELECTED.'.'; - }elseif($userVacation == '1') { - $error = 'Player is on vacation mode. You cannot send resources to him.'; - }elseif(!$_POST['x'] && !$_POST['y'] && !$_POST['dname']){ - $error = ''.ENTER_COORDINATES.'.'; - }elseif($allres > $maxcarry){ - $error = ''.TOO_FEW_MERCHANTS.'.'; - } - echo $error; -} -?> -

- -

maxcarry; ?>

-recieving) > 0) { -echo "

".MERCHANT_COMING.":

"; - foreach($market->recieving as $recieve) { - echo ""; - $villageowner = $database->getVillageField($recieve['from'],"owner"); - echo ""; - echo ""; - echo ""; - echo "
".$database->getUserField($villageowner,"username",0)."getMapCheck($recieve['from'])."\">".TRANSPORT_FROM." ".$database->getVillageField($recieve['from'],"name")."
".ARRIVAL_IN.""; - echo "
timer.">".$generator->getTimeFormat($recieve['endtime']-time())." h
"; - $datetime = $generator->procMtime($recieve['endtime']); - echo "
"; - if($datetime[0] != "today") { - echo "".ON." ".$datetime[0]." "; - } - echo "".AT." ".$datetime[1]."
"; - echo "
".RESOURCES." "; - echo "\"Lumber\"".$recieve['wood']." | \"Clay\"".$recieve['clay']." | \"Iron\"".$recieve['iron']." | \"Crop\"".$recieve['crop']."
"; - } -} -if(count($market->sending) > 0) { - echo "

".OWN_MERCHANTS_ONWAY.":

"; - foreach($market->sending as $send) { - $villageowner = $database->getVillageField($send['to'],"owner"); - $ownername = $database->getUserField($villageowner,"username",0); - echo ""; - echo ""; - echo ""; - echo "
$ownernamegetMapCheck($send['to'])."\">".TRANSPORT_TO." ".$database->getVillageField($send['to'],"name")."
".ARRIVAL_IN." "; - echo "
timer.">".$generator->getTimeFormat($send['endtime']-time())." h
"; +// --- comercianți trimiși --- +if (count($market->sending) > 0) { + echo "

".OWN_MERCHANTS_ONWAY.":

"; + foreach ($market->sending as $send) { + $villageowner = (int)$database->getVillageField($send['to'],"owner"); + echo ''; + echo ''; + echo ''; + echo '"; - echo "
'.htmlspecialchars($database->getUserField($villageowner,"username",0)).''.TRANSPORT_TO.' '.htmlspecialchars($database->getVillageField($send['to'],"name")).'
'.ARRIVAL_IN.''; + echo '
'.$generator->getTimeFormat($send['endtime']-time()).' h
'; $datetime = $generator->procMtime($send['endtime']); - echo "
"; - if($datetime[0] != "today") { - echo "".ON." ".$datetime[0]." "; - } - echo "".AT." ".$datetime[1]."
"; - echo "
".RESOURCES.""; - echo "\"Lumber\"".$send['wood']." | \"Clay\"".$send['clay']." | \"Iron\"".$send['iron']." | \"Crop\"".$send['crop']."
"; + echo '
'.($datetime[0]!= "today"? ON." ".$datetime[0]." " : "").AT." ".$datetime[1].'
'; + echo '
'.RESOURCES.''; + echo ''.LUMBER.''.$send['wood'].' | '; + echo ''.CLAY.''.$send['clay'].' | '; + echo ''.IRON.''.$send['iron'].' | '; + echo ''.CROP.''.$send['crop']; + echo '
'; } } -if(count($market->return) > 0) { - echo "

".MERCHANTS_RETURNING.":

"; - foreach($market->return as $return) { - $villageowner = $database->getVillageField($return['from'],"owner"); - $ownername = $database->getUserField($villageowner,"username",0); - echo ""; - echo ""; - echo ""; - echo "
$ownernamegetMapCheck($return['from'])."\">".RETURNFROM." ".$database->getVillageField($return['from'],"name")."
".ARRIVAL_IN." "; - echo "
timer.">".$generator->getTimeFormat($return['endtime']-time())." h
"; + +// --- comercianți care se întorc --- +if (count($market->return) > 0) { + echo "

".MERCHANTS_RETURNING.":

"; + foreach ($market->return as $return) { + $villageowner = (int)$database->getVillageField($return['from'],"owner"); + echo ''; + echo ''; + echo ''; + echo '"; - echo "
'.htmlspecialchars($database->getUserField($villageowner,"username",0)).''.RETURNFROM.' '.htmlspecialchars($database->getVillageField($return['from'],"name")).'
'.ARRIVAL_IN.''; + echo '
'.$generator->getTimeFormat($return['endtime']-time()).' h
'; $datetime = $generator->procMtime($return['endtime']); - echo "
"; - if($datetime[0] != "today") { - echo "".ON." ".$datetime[0]." "; - } - echo "".AT." ".$datetime[1]."
"; - echo "
"; + echo '
'.($datetime[0]!= "today"? ON." ".$datetime[0]." " : "").AT." ".$datetime[1].'
'; + echo '
'; } } + include("upgrade.tpl"); ?> -

+
\ No newline at end of file diff --git a/Templates/Build/17_1.tpl b/Templates/Build/17_1.tpl index 86be9343..2aad2def 100644 --- a/Templates/Build/17_1.tpl +++ b/Templates/Build/17_1.tpl @@ -1,146 +1,153 @@ +// 17_1.tpl - MARKETPLACE / OFFERS +global $database, $session, $village, $market, $generator, $id; -
-

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

-

-

- -plus) { +$u = isset($_GET['u']) ? max(0, (int)$_GET['u']) : 0; +$s = isset($_GET['s']) ? (int)$_GET['s'] : 0; +$b = isset($_GET['b']) ? (int)$_GET['b'] : 0; +$v = isset($_GET['v']) ? $_GET['v'] : ''; + +$resIcon = [ + 1 => ['class' => 'r1', 'name' => LUMBER], + 2 => ['class' => 'r2', 'name' => CLAY], + 3 => ['class' => 'r3', 'name' => IRON], + 4 => ['class' => 'r4', 'name' => CROP], +]; ?> - - - - - - - - - -
>Lumber>Clay>Iron>Crop
- - - - - -
>1:1
>1:x
- - - - - - - - - -
>Lumber>Clay>Iron>Crop
- -
-".NOT_ENOUGH_RESOURCES."

"; -} -elseif(isset($_GET['e2'])) -{ - echo "

".INVALID_OFFER."

"; -} -elseif(isset($_GET['e3'])) -{ - echo "

".NOT_ENOUGH_MERCHANTS."

"; -} -?> - - - - - - - - - - - -onsale) > 0) { -for($i=0+$u;$i<=40+$u;$i++) { -if(isset($market->onsale[$i])) { -echo ""; - echo ""; - if(($market->onsale[$i]['wtype'] == 1 && $village->awood <= $market->onsale[$i]['wamt']) ||($market->onsale[$i]['wtype'] == 2 && $village->aclay <= $market->onsale[$i]['wamt']) ||($market->onsale[$i]['wtype'] == 3 && $village->airon <= $market->onsale[$i]['wamt']) ||($market->onsale[$i]['wtype'] == 4 && $village->acrop <= $market->onsale[$i]['wamt'])) { - echo ""; - } - else if($reqMerc > $market->merchantAvail()) { - echo ""; - } - else if($session->access != BANNED){ - echo ""; - }else{ - echo ""; - } - echo""; - } -} -} -else { -echo ""; -} -?> - + + + + +
"; -$reqMerc = 1; -if($market->onsale[$i]['wamt'] > $market->maxcarry) { - $reqMerc = round($market->onsale[$i]['wamt']/$market->maxcarry); - if($market->onsale[$i]['wamt'] > $market->maxcarry*$reqMerc) { - $reqMerc += 1; - } - } -switch($market->onsale[$i]['gtype']) { - case 1: echo "\"Wood\""; break; - case 2: echo "\"Clay\""; break; - case 3: echo "\"Iron\""; break; - case 4: echo "\"Crop\""; break; - } - echo $market->onsale[$i]['gamt']; - echo " "; - switch($market->onsale[$i]['wtype']) { - case 1: echo "\"Wood\""; break; - case 2: echo "\"Clay\""; break; - case 3: echo "\"Iron\""; break; - case 4: echo "\"Crop\""; break; - } - echo $market->onsale[$i]['wamt']; - echo "getVillageField($market->onsale[$i]['vref'],"name")."\">"; - echo "onsale[$i]['vref']."&c=".$generator->getMapCheck($market->onsale[$i]['vref'])."\">".$database->getUserField($database->getVillageField($market->onsale[$i]['vref'],"owner"),"username",0)."".$generator->getTimeFormat($market->onsale[$i]['duration'])."".NOT_ENOUGH_RESOURCES."
".NOT_ENOUGH_MERCHANTS."
mchecker."&g=".$market->onsale[$i]['id']."\">Accept offer".ACCEP_OFFER."
".NO_AVAILABLE_OFFERS."
- -onsale) < 40) { - echo "«»"; - } - else if (!isset($_GET['u']) && count($market->onsale) > 40) { - echo "«&t=1&u=40\">»"; - } - else if(isset($_GET['u']) && count($market->onsale) > $_GET['u']) { - if(count($market->onsale) > ($_GET['u']+40) && $_GET['u']-40 < count($market->onsale) && $_GET['u'] != 0) { - echo "&t=1&u=".($_GET['u']-40)."\">«&t=1&u=".($_GET['u']+40)."\">»"; - } - else if(count($market->onsale) > $_GET['u']+40) { - echo "«&t=1&u=".($_GET['u']+40)."\">»"; - } - else { - echo "&t=1&u=".($_GET['u']-40)."\">«»"; +
+ +

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

+

+ + + + plus):?> + + + + + + + +
> + + <?php echo $resIcon[$i]['name'];?> + +
+ + + + + + +
>1:1
>1:x
+ + + + + + + + +
> + + <?php echo $resIcon[$i]['name'];?> + +
+ + +
+ + '.NOT_ENOUGH_RESOURCES.'

'; + elseif (isset($_GET['e2'])) echo '

'.INVALID_OFFER.'

'; + elseif (isset($_GET['e3'])) echo '

'.NOT_ENOUGH_MERCHANTS.'

'; + ?> + + + + + + + + + + + + + + onsale; + $totalOffers = count($offers); + + if ($totalOffers > 0) { + $end = min($u + 40, $totalOffers); + for ($i = $u; $i < $end; $i++) { + if (!isset($offers[$i])) continue; + $offer = $offers[$i]; + + $reqMerc = max(1, (int)ceil($offer['wamt'] / $market->maxcarry)); + $vref = (int)$offer['vref']; + $owner = (int)$database->getVillageField($vref, "owner"); + $username = htmlspecialchars($database->getUserField($owner, "username", 0)); + $villagename = htmlspecialchars($database->getVillageField($vref, "name")); + + $hasRes = true; + switch ($offer['wtype']) { + case 1: $hasRes = $village->awood > $offer['wamt']; break; + case 2: $hasRes = $village->aclay > $offer['wamt']; break; + case 3: $hasRes = $village->airon > $offer['wamt']; break; + case 4: $hasRes = $village->acrop > $offer['wamt']; break; + } + ?> + + + + + + + + $market->merchantAvail()):?> + + access != BANNED):?> + + + + + + '; } - } -?> - -
+ <?php echo $resIcon[$offer['gtype']]['name'];?> + + + <?php echo $resIcon[$offer['wtype']]['name'];?> + + + + getTimeFormat($offer['duration']);?>Accept offer
'.NO_AVAILABLE_OFFERS.'
\ No newline at end of file + ?> + +
+ «'; + else echo '«'; + + if ($next >= $totalOffers) echo '»'; + else echo '»'; + ?> +
+
\ No newline at end of file diff --git a/Templates/Build/17_2.tpl b/Templates/Build/17_2.tpl index 636e40db..eb03142a 100644 --- a/Templates/Build/17_2.tpl +++ b/Templates/Build/17_2.tpl @@ -1,125 +1,114 @@ -
-

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

-

- - -
- - - - - - - - - - - - - - - - -
- - :
- - - userinfo['alliance'] != 0) - { - echo " ".OWN_ALLIANCE_ONLY.""; - } - ?> -
+".NOT_ENOUGH_RESOURCES."

"; - } - elseif(isset($_GET['e2'])) - { - echo "

".INVALID_OFFER."

"; - } - elseif(isset($_GET['e3'])) - { - echo "

".NOT_ENOUGH_MERCHANTS."

"; - } - - echo "

".MERCHANT.": " .$market->merchantAvail()."/".$market->merchant."

"; - ?> - merchantAvail()) { echo "DISABLED"; }?>/>

-
-onmarket) > 0) -{ - echo ""; - foreach($market->onmarket as $offer) - { - if($session->access != BANNED) - { - echo ""; - echo ""; - echo ""; - } - echo "
".OWN_OFFERS."
 ".OFFER."ratio".SEARCH."".MERCHANT."".ALLIANCE."".DURATION."
\"Delete\""; - } - else - { - echo "
\"Delete\""; - } - switch($offer['gtype']) - { - case 1: echo "\"Wood\""; break; - case 2: echo "\"Clay\""; break; - case 3: echo "\"Iron\""; break; - case 4: echo "\"Crop\""; break; - } - echo $offer['gamt']; - $sss = ($offer['wamt']/$offer['gamt']); - $ratio = round($sss, 1); - if($ratio <= 1){ - $class = 'red'; - }elseif($ratio > 1 && $ratio < 2){ - $class = 'orange'; - }elseif($ratio >= 2){ - $class = 'green'; - } - echo " ".$ratio." "; - switch($offer['wtype']) - { - case 1: echo "\"Wood\""; break; - case 2: echo "\"Clay\""; break; - case 3: echo "\"Iron\""; break; - case 4: echo "\"Crop\""; break; - } - echo $offer['wamt']; - echo "".$offer['merchant']." "; - echo ($offer['alliance'] == 0)? 'No' : 'Yes'; - echo ""; - if($offer['maxtime'] != 0) - { - echo $offer['maxtime']/3600; - echo " hrs."; - } - else - { - echo "".ALL.""; - } - echo "
"; -} -?> +$res = [ + 1 => ['class' => 'r1', 'name' => LUMBER], + 2 => ['class' => 'r2', 'name' => CLAY], + 3 => ['class' => 'r3', 'name' => IRON], + 4 => ['class' => 'r4', 'name' => CROP], +]; + +$merchantAvail = (int)$market->merchantAvail(); +$totalMerchants = (int)$market->merchant; +?> +
+ +

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

+

+ + + +
+ + + + + + + + + + + + + + + + +
+ + + : + +
+ + + userinfo['alliance'] !== 0):?> + + +
+ + '.NOT_ENOUGH_RESOURCES.'

'; + elseif (isset($_GET['e2'])) echo '

'.INVALID_OFFER.'

'; + elseif (isset($_GET['e3'])) echo '

'.NOT_ENOUGH_MERCHANTS.'

'; + ?> + +

: /

+

/>

+
+ + onmarket) > 0):?> + + + + + + + + + + + + + + + onmarket as $offer): + $offerId = (int)$offer['id']; + $gtype = (int)$offer['gtype']; + $wtype = (int)$offer['wtype']; + $ratio = $offer['gamt'] > 0 ? round($offer['wamt'] / $offer['gamt'], 1) : 0; + $ratioClass = $ratio <= 1 ? 'red' : ($ratio < 2 ? 'orange' : 'green'); + $delLink = $session->access != BANNED ? "build.php?id=".(int)$id."&t=2&a=5&del=".$offerId : "banned.php"; + ?> + + + + + + + + + + + +
 ratio
Delete + <?php echo $res[$gtype]['name'];?> + + + <?php echo $res[$wtype]['name'];?> + +
+
diff --git a/Templates/Build/17_3.tpl b/Templates/Build/17_3.tpl index 9da79ff6..7412dd2e 100644 --- a/Templates/Build/17_3.tpl +++ b/Templates/Build/17_3.tpl @@ -1,271 +1,144 @@ -gold > 2){ ?> -
-

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

-

-

- - - -

. 3Gold

- - - -

- - - - -
- - - - getResourceLevel($village->wid); - if($wwvillage['f99t']!=40){ - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Lumber - awood); ?> - - Clay - aclay); ?> - - Iron - airon); ?> - - Crop - acrop); ?> - awood+$village->acrop+$village->airon+$village->aclay); ?>
- /> - - - /> - - - /> - - - /> - -
- awood); ?> - - aclay); ?> - - airon); ?> - - acrop); ?> - - awood+$village->acrop+$village->airon+$village->aclay)-($_GET['r1']+$_GET['r2']+$_GET['r3']+$_GET['r4']); - } else { echo floor($village->awood+$village->acrop+$village->airon+$village->aclay); } ?>
-

- userinfo['gold'] >= 3) { ?>) (: Gold3)".TRADE_RESOURCES.") (".COSTS.": Gold3)"; }?>

-

-
- - - -

- -
gold <= 2) { + header("Location: build.php?id=".(int)$_GET['id']); + exit; } -?> \ No newline at end of file + +$level = (int)$village->resarray['f'.$id]; +$totalRes = floor($village->awood + $village->aclay + $village->airon + $village->acrop); +$maxstore = (int)$village->maxstore; +$maxcrop = (int)$village->maxcrop; + +// valori prefill din GET +$r = []; +for ($i = 1; $i <= 4; $i++) { + $r[$i] = isset($_GET['r'.$i])? max(0, (int)$_GET['r'.$i]) : ''; +} +$newsum = ($r[1]!=='' && $r[2]!=='' && $r[3]!=='' && $r[4]!=='')? array_sum($r) : 0; +$remain = $totalRes - $newsum; + +$wwvillage = $database->getResourceLevel($village->wid); +$isWW = ($wwvillage['f99t'] == 40); +$completed = isset($_GET['c']); +?> +
+ +

+

+ + + + +

. 3Gold

+ + + +

+ + + + + +
+ + + + + + + + + awood, 'r1', LUMBER], + ['clay', $village->aclay, 'r2', CLAY], + ['iron', $village->airon, 'r3', IRON], + ['crop', $village->acrop, 'r4', CROP], + ]; + foreach ($resData as $idx => $rd):?> + + + + + + + + + + + + + + + + + + + +
+ <?php echo $rd[3];?> + +
+ + +
+ +

+ userinfo['gold'] >= 3):?> + + (: Gold3) + + (: Gold3) + +

+

+
+ + + +

+ + + +
\ No newline at end of file diff --git a/Templates/Build/17_4.tpl b/Templates/Build/17_4.tpl index d8c6d1e2..cea46097 100644 --- a/Templates/Build/17_4.tpl +++ b/Templates/Build/17_4.tpl @@ -1,79 +1,87 @@ -goldclub == 1 && count($database->getProfileVillages($session->uid)) > 1) { ?> -
-

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

-

-

- -gold > 1){ -$routeaccess = 1; -include("17_create.tpl"); -}else if(isset($_POST['action']) && $_POST['action'] == 'editRoute' && isset($_POST['routeid']) && !empty($_POST['routeid']) && $database->getTradeRouteUid($_POST['routeid']) == $session->uid){ -include("17_edit.tpl"); -}else{ -?> + Gold2.

-
- - - - - - - - - -getTradeRoute($village->wid); - if(empty($routes)) { - echo ""; - }else{ -foreach($routes as $route){ -?> - - - - - - - - - - -
".NO_TRADE_ROUTES.".
-getMapCheck($route['wid']).">".$database->getVillageField($route['wid'],"name").""; -?> - 9){ echo $route['start'];}else{ echo "0".$route['start'];} echo ":00"; ?>
- - - - | - | -
-
- * Gold2 -
-
- » -
-
- -goldclub == 1 && count($database->getProfileVillages($session->uid)) > 1)) { + header("Location: build.php?id=".(int)$_GET['id']); + exit; } + +$action = $_POST['action'] ?? ''; +$routeid = isset($_POST['routeid']) ? (int)$_POST['routeid'] : 0; +$create = isset($_GET['create']) && $session->gold > 1; +$edit = ($action === 'editRoute' && $routeid > 0 && $database->getTradeRouteUid($routeid) == $session->uid); ?> +
+ +

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

+

+ + + + + + + + + + +

Gold2.

+ +
+ + + + + + + + + + + + getTradeRoute($village->wid); + if (empty($routes)): + ?> + + getVillageField($wid, "name")); + $start = str_pad((int)$route['start'], 2, '0', STR_PAD_LEFT).":00"; + $deliveries = (int)$route['deliveries']."x".(int)$route['merchant']; + $daysLeft = max(0, ceil(($route['timeleft'] - time()) / 86400)); + ?> + + + + + + + + + + + + + + + +
.
+ + | + | +
+
+ + * Gold2 +
+
+ » +
+ +
\ No newline at end of file diff --git a/Templates/Build/17_create.tpl b/Templates/Build/17_create.tpl index 78defb60..b892dd14 100644 --- a/Templates/Build/17_create.tpl +++ b/Templates/Build/17_create.tpl @@ -1,78 +1,77 @@ -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- : - - -
- : - Lumber Clay Iron Crop -
- : - -
- : - -
- : - Gold 2 -
- : - 7 -
+// 17_create.tpl - MARKETPLACE / CREATE ROUTE +global $database, $session, $village; -
-
-

-
-
\ No newline at end of file +$villages = $session->villages?? []; +$firstSelect = ($villages[0]?? 0) == $village->wid? 1 : 0; +?> +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
: + +
: + '1',2=>'2',3=>'3',4=>'4']; $names = [1=>LUMBER,2=>CLAY,3=>IRON,4=>CROP]; + foreach ($icons as $i => $img):?> + <?php echo $names[$i];?> + + +
: + +
: + +
:Gold 2
:7
+
+

+
\ No newline at end of file diff --git a/Templates/Build/17_edit.tpl b/Templates/Build/17_edit.tpl index f6d4ef40..b2da490b 100644 --- a/Templates/Build/17_edit.tpl +++ b/Templates/Build/17_edit.tpl @@ -1,40 +1,63 @@ -getTradeRoute2($_POST['routeid']); ?> -
-
- - - - - - - - - - - - - - - - - - - - - -
- : - Lumber Clay Iron Crop -
- : - -
- : - -
+ -
-

- -
\ No newline at end of file +$routeid = isset($_POST['routeid'])? (int)$_POST['routeid'] : 0; +$edited_route = $database->getTradeRoute2($routeid); + +$wood = (int)($edited_route['wood']??0); +$clay = (int)($edited_route['clay']??0); +$iron = (int)($edited_route['iron']??0); +$crop = (int)($edited_route['crop']??0); +$start = (int)($edited_route['start']??0); +$deliveries = (int)($edited_route['deliveries']??1); +?> +
+
+ + + + + + + + + + + + + + + + + + + + +
: + + <?php echo $r[3];?> + + +
: + +
: + +
+
+

+
\ No newline at end of file diff --git a/Templates/Build/17_menu.tpl b/Templates/Build/17_menu.tpl index 354b5347..2f4ba9ce 100644 --- a/Templates/Build/17_menu.tpl +++ b/Templates/Build/17_menu.tpl @@ -1,17 +1,19 @@ -
- "> - | > - | > - userinfo['gold'] > 2) { - ?> - | > - - goldclub == 1 && count($database->getProfileVillages($session->uid)) > 1) { - ?> - | > - -
\ No newline at end of file +userinfo['gold'] > 2; +$hasRoutes = $session->goldclub == 1 && count($database->getProfileVillages($session->uid)) > 1; +?> +
+ > + | > + | > + + | > + + + | > + +
\ No newline at end of file diff --git a/Templates/Build/18.tpl b/Templates/Build/18.tpl index 609586cc..929b22ba 100644 --- a/Templates/Build/18.tpl +++ b/Templates/Build/18.tpl @@ -1,66 +1,64 @@ -
-

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

-

- resarray['f'.$id] >= 3 && $session->alliance == 0) { -include("18_create.tpl"); -} -if($session->alliance != 0) { -echo " - - - - +// 18.tpl - EMBESSY +global $village, $session, $id, $alliance, $database, $form; - - - - - - - - ".$form->getError("ally3")." - - - - - - - -
".ALLIANCE."
".TAG."".$alliance->allianceArray['tag']."
".NAME."".$alliance->allianceArray['name']."
 » ".TO_THE_ALLIANCE."
"; - } - else if($village->resarray['f'.$id] >= 1) { - ?> - - - - - - - - - gotInvite) { - foreach($alliance->inviteArray as $invite) { - echo " - - "; - } - } - else { - echo ""; - } - ?> -
\"refuse\" ".$database->getAllianceName($invite['alliance'])." ".ACCEPT."".NO_INVITATIONS."
-

getError("ally4"); ?>

- gotInvite) { - echo "

".$form->getError("ally_accept")."

"; - } - } -include("upgrade.tpl"); +$level = (int)$village->resarray['f'.$id]; +$inAlliance = (int)$session->alliance !== 0; ?> -

+
+ +

+

+ + = 3 && !$inAlliance) include("18_create.tpl");?> + + + + + + + + + + + + + + + + +
allianceArray['tag']);?>
+ allianceArray['name']);?> + getError("ally3");?> +
 »
+ + = 1):?> + + + + gotInvite && !empty($alliance->inviteArray)): + foreach ($alliance->inviteArray as $invite): + $invId = (int)$invite['id']; + $allyId = (int)$invite['alliance']; + $allyName = htmlspecialchars($database->getAllianceName($allyId)); + ?> + + + + + + + + + +
refuse  
+

getError("ally4");?>

+ gotInvite):?> +

getError("ally_accept");?>

+ + + + +
\ No newline at end of file diff --git a/Templates/Build/18_create.tpl b/Templates/Build/18_create.tpl index 0f5c2336..f1a8e9f8 100644 --- a/Templates/Build/18_create.tpl +++ b/Templates/Build/18_create.tpl @@ -1,55 +1,40 @@ -access!=BANNED){ ?> +access == BANNED; +$disabled = $isBanned ? 'disabled' : ''; +$tagValue = htmlspecialchars($form->getValue("ally1")); +$nameValue = htmlspecialchars($form->getValue("ally2")); +$maxTag = $isBanned ? 8 : 15; +$maxName = $isBanned ? 25 : 50; +?> - - - - - - - - - - - - + + + + + + + + + + + + + +
- " maxlength="15"> - getError("ally1"); ?> -
- " maxlength="50"> - getError("ally2"); ?> -
+ > + getError("ally1");?> +
+ > + getError("ally2");?> +
- - - -

- - -
- - - - - - - - - - - - - - -
- " maxlength="8"> - getError("ally1"); ?> -
- " maxlength="25"> - getError("ally2"); ?> -
-
- + +

+ + + +

+ \ No newline at end of file diff --git a/Templates/Build/19.tpl b/Templates/Build/19.tpl index 14163255..161f4bc2 100644 --- a/Templates/Build/19.tpl +++ b/Templates/Build/19.tpl @@ -1,59 +1,82 @@ -
-

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

-

+getTypeLevel(19) > 0) { ?> -
- - - - - - - - -
-

- ".TRAINING_COMMENCE_BARRACKS."

\n"; - } - $trainlist = $technology->getTrainingList(1); - if(count($trainlist) > 0) { - echo " - - - - - - - "; - $TrainCount = 0; - foreach($trainlist as $train) { - $TrainCount++; - echo " -
".TRAINING."".DURATION."".FINISHED."
"; - echo "\"".$train['name']."\""; - echo $train['amt']." ".$train['name'].""; - if ($TrainCount == 1 ) { - $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; - } else { - echo $generator->getTimeFormat($train['eachtime']*$train['amt']); - } - echo ""; - $time = $generator->procMTime($train['timestamp']); - if($time[0] != "today") { - echo "on ".$time[0]." at "; - } - echo $time[1]; - } ?> -
- resarray['f'.$id]; +$canTrain = $building->getTypeLevel(19) > 0; +$trainlist = $technology->getTrainingList(1); ?> -

\ No newline at end of file +
+ +

+

+ + +
+ + + + + + + + + + + +
+

+
+ +
+ + + 0): + $NextFinished = ''; + ?> + + + + + + + + + + + + + + + + +
+ <?php echo $name;?> + + + getTimeFormat($train['timestamp2'] - time()); + $timerId = ++$session->timer; + ?> + getTimeFormat($train['timestamp'] - time());?> + + getTimeFormat($train['eachtime'] * $amt);?> + + + procMTime($train['timestamp']); + if ($time[0]!== "today") echo "on ".$time[0]." at "; + echo $time[1]; + ?> +
+ + + +
\ No newline at end of file diff --git a/Templates/Build/19_train.tpl b/Templates/Build/19_train.tpl index 641fe1fd..9bb320db 100644 --- a/Templates/Build/19_train.tpl +++ b/Templates/Build/19_train.tpl @@ -1,50 +1,52 @@ tribe != 4){ - for ($i=($session->tribe-1)*10+1;$i<=($session->tribe-1)*10+4;$i++) { - if ($i <> 4 && $i <> 23 && $i <> 24 && ($technology->getTech($i) || $i%10 == 1)) { - -echo " -
-\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." (".AVAILABLE.": ".$village->unitarray['u'.$i].") -
-
-\"Wood\"".(${'u'.$i}['wood'])."|\"Clay\"".(${'u'.$i}['clay'])."|\"Iron\"".(${'u'.$i}['iron'])."|\"Crop\"".(${'u'.$i}['crop'])."|\"Crop".${'u'.$i}['pop']."|\"Duration\""; -$dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(${'u'.$i}['time'] * ($bid19[$village->resarray['f'.$id]]['attri'] / 100) / SPEED)); -echo $generator->getTimeFormat($dur); +// 19_train.tpl - UNIT LIST BARRAKS +global $session, $technology, $village, $database, $generator, $building, $bid19, $id; -//-- If available resources combined are not enough, remove NPC button -$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']); +$tribe = (int)$session->tribe; +$units = ($tribe !== 4) ? range(($tribe-1)*10+1, ($tribe-1)*10+4) : range(31, 40); -if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|maxUnitPlus($i))."&r2=".((${'u'.$i}['clay'])*$technology->maxUnitPlus($i))."&r3=".((${'u'.$i}['iron'])*$technology->maxUnitPlus($i))."&r4=".((${'u'.$i}['crop'])*$technology->maxUnitPlus($i))."\" title=\"NPC trade\">\"NPC"; - } -echo "
- - -maxUnit($i,false)."; return false;\">(".$technology->maxUnit($i,false).")"; - } - } - }else{ - for ($i=31;$i<=40;$i++) { - -echo " -
-\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." (".AVAILABLE.": ".$village->unitarray['u'.$i].") -
-
-\"Wood\"".(${'u'.$i}['wood'])."|\"Clay\"".(${'u'.$i}['clay'])."|\"Iron\"".(${'u'.$i}['iron'])."|\"Crop\"".(${'u'.$i}['crop'])."|\"Crop".${'u'.$i}['pop']."|\"Duration\""; -$dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(${'u'.$i}['time'] * ($bid19[$village->resarray['f'.$id]]['attri'] / 100) / SPEED)); -echo $generator->getTimeFormat($dur); +foreach ($units as $i) { + // skip unități invalide + if ($tribe !== 4 && ($i == 4 || $i == 23 || $i == 24)) continue; + if (!($technology->getTech($i) || $i % 10 == 1)) continue; -if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { - echo "|maxUnitPlus($i))."&r2=".((${'u'.$i}['clay'])*$technology->maxUnitPlus($i))."&r3=".((${'u'.$i}['iron'])*$technology->maxUnitPlus($i))."&r4=".((${'u'.$i}['crop'])*$technology->maxUnitPlus($i))."\" title=\"NPC trade\">\"NPC"; - } -echo "
- - -maxUnit($i,false)."; return false;\">(".$technology->maxUnit($i,false).")"; - } - } + $unitData = ${'u'.$i}; + $name = $technology->getUnitName($i); + $maxTrain = $technology->maxUnit($i, false); + $maxPlus = $technology->maxUnitPlus($i); + $available = (int)($village->unitarray['u'.$i] ?? 0); + + $dur = $database->getArtifactsValueInfluence( + $session->uid, + $village->wid, + 5, + round($unitData['time'] * ($bid19[$village->resarray['f'.$id]]['attri'] / 100) / SPEED) + ); + $timeFormatted = $generator->getTimeFormat($dur); + + $total_required = (int)($unitData['wood'] + $unitData['clay'] + $unitData['iron'] + $unitData['crop']); + $showNpc = $session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required; ?> + + +
+ <?php echo htmlspecialchars($name);?> + + (: ) +
+
+ Wood| + Clay| + Iron| + Crop| + Crop consumption| + Duration + + |NPC trade + +
+ + + () + + \ No newline at end of file diff --git a/Templates/Build/2.tpl b/Templates/Build/2.tpl index f3909efd..579425ab 100644 --- a/Templates/Build/2.tpl +++ b/Templates/Build/2.tpl @@ -1,55 +1,48 @@ resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentProd = $bid2[$currentLevel]['prod'] * SPEED; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = ($village->capital == 1) ? 20 : 10; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextProd = $bid2[$nextLevel]['prod'] * SPEED; ?> -
-

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

-

+
+ - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($village->capital == 1) { - if($next<=20){ - ?> - - - - - - - - - - - - - - - - - - - - -
:resarray['f'.$id]]['prod']* SPEED; ?>
:
:
:
:
+

+ + +

-

+

+ + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/20.tpl b/Templates/Build/20.tpl index d1a165c9..5de1af67 100644 --- a/Templates/Build/20.tpl +++ b/Templates/Build/20.tpl @@ -1,72 +1,81 @@ -
- -

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

-


- -getTypeLevel(20) > 0) { ?> - -
- - - - - - - - - - - - tribe != 4){ - include("20_train.tpl"); - } - ?> - -
-

- -

- -
".TRAINING_COMMENCE_STABLE."
\n"; - } - $trainlist = $technology->getTrainingList(2); - if(count($trainlist) > 0) { - echo " - - - - - - - "; - $TrainCount = 0; - foreach($trainlist as $train) { - $TrainCount++; - echo " -
".TRAINING."".DURATION."".FINISHED."
"; - echo "\"".$train['name']."\""; - echo $train['amt']." ".$train['name'].""; - if ($TrainCount == 1) { - $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; - } else { - echo $generator->getTimeFormat($train['eachtime']*$train['amt']); - } - echo ""; - $time = $generator->procMTime($train['timestamp']); - if($time[0] != "today") { - echo "on ".$time[0]." at "; - } - echo $time[1]; - } ?> -
- -

+// 20.tpl - STABLE +global $village, $building, $technology, $generator, $session, $id; + +$level = (int)$village->resarray['f'.$id]; +$canTrain = $building->getTypeLevel(20) > 0; +$trainlist = $technology->getTrainingList(2); +?> +
+ +

+


+ + +
+ + + + + + + + + + tribe!= 4) include("20_train.tpl");?> + +
+

+
+ +
+ + + 0): + $NextFinished = ''; + ?> + + + + + + + + + + + + + + + + +
+ <?php echo $name;?> + + + getTimeFormat($train['timestamp2'] - time()); + ?> + getTimeFormat($train['timestamp'] - time());?> + + getTimeFormat($train['eachtime'] * $amt);?> + + + procMTime($train['timestamp']); + if ($time[0]!== "today") echo "on ".$time[0]." at "; + echo $time[1]; + ?> +
+ + + +
\ No newline at end of file diff --git a/Templates/Build/20_train.tpl b/Templates/Build/20_train.tpl index 5bbde8e9..8cf5bce8 100644 --- a/Templates/Build/20_train.tpl +++ b/Templates/Build/20_train.tpl @@ -1,41 +1,57 @@ tribe; +$start = ($tribe - 1) * 10 + 4 - ($tribe == 3 ? 1 : 0) + ($tribe == 2 ? 1 : 0); +$end = $tribe * 10 - 4; $success = 0; -$start = ($session->tribe - 1) * 10 + 4 - (($session->tribe == 3) ? 1 : 0) + (($session->tribe == 2) ? 1 : 0); -$end = $session->tribe * 10 - 4; +$horseTrough = $building->getTypeLevel(41); -for($i = $start; $i <= $end; $i++) { - if($technology->getTech($i)) { - echo "
\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." (".AVAILABLE.": ".$village->unitarray['u'.$i].")
"; - if(${'u'.$i}['drinking'] <= $building->getTypeLevel(41)) { - echo "
- \"Wood\"".${'u'.$i}['wood']."|\"Clay\"".${'u'.$i}['clay']."|\"Iron\"".${'u'.$i}['iron']."|\"Crop\"".${'u'.$i}['crop']."|\"Crop".(${'u'.$i}['pop']-1)."|\"Duration\""; -}else{ - echo "
- \"Wood\"".${'u'.$i}['wood']."|\"Clay\"".${'u'.$i}['clay']."|\"Iron\"".${'u'.$i}['iron']."|\"Crop\"".${'u'.$i}['crop']."|\"Crop".(${'u'.$i}['pop'])."|\"Duration\""; -} - $dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(${'u'.$i}['time'] * ($bid20[$village->resarray['f'.$id]]['attri'] / 100) * ($building->getTypeLevel(41)>=1?(1/$bid41[$building->getTypeLevel(41)]['attri']):1) / SPEED)); - echo $generator->getTimeFormat($dur); - - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']); +for ($i = $start; $i <= $end; $i++) { + if (!$technology->getTech($i)) continue; - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|maxUnitPlus($i))."&r2=".((${'u'.$i}['clay'])*$technology->maxUnitPlus($i))."&r3=".((${'u'.$i}['iron'])*$technology->maxUnitPlus($i))."&r4=".((${'u'.$i}['crop'])*$technology->maxUnitPlus($i))."\" title=\"NPC trade\">\"NPC"; - } - echo "
- - - + $unitData = ${'u'.$i}; + $name = $technology->getUnitName($i); + $maxTrain = $technology->maxUnit($i); + $maxPlus = $technology->maxUnitPlus($i); + $available = (int)($village->unitarray['u'.$i] ?? 0); - - maxUnit($i)."; return false;\">(".$technology->maxUnit($i).") - - "; - $success += 1; - } -} -if($success == 0) { - echo "
".AVAILABLE_ACADEMY."
"; -} + $pop = (int)$unitData['pop'] - ($unitData['drinking'] <= $horseTrough ? 1 : 0); + + $baseTime = $unitData['time'] * ($bid20[$village->resarray['f'.$id]]['attri'] / 100); + if ($horseTrough >= 1) $baseTime *= (1 / $bid41[$horseTrough]['attri']); + $dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round($baseTime / SPEED)); + $timeFormatted = $generator->getTimeFormat($dur); + + $total_required = (int)($unitData['wood'] + $unitData['clay'] + $unitData['iron'] + $unitData['crop']); + $showNpc = $session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required; + $success++; ?> + + +
+ <?php echo htmlspecialchars($name);?> + + (: ) +
+
+ Wood| + Clay| + Iron| + Crop| + Crop consumption| + Duration + + |NPC trade + +
+ + + () + + + + +
+ \ No newline at end of file diff --git a/Templates/Build/21.tpl b/Templates/Build/21.tpl index 525d0d63..71263176 100644 --- a/Templates/Build/21.tpl +++ b/Templates/Build/21.tpl @@ -1,114 +1,104 @@ -
- -

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

-

-getTypeLevel(21) > 0) { ?> - -
- - - - - - - - - - - - tribe == 1)? 7 : (($session->tribe == 2)? 17 : 27); - if ($session->tribe == 1){ - $start = 7; - }else if ($session->tribe == 2){ - $start = 17; - }else if ($session->tribe == 3){ - $start = 27; - }else if ($session->tribe == 5){ - $start = 47; - } - if($session->tribe != 4){ - for($i=$start;$i<=($start+1);$i++) { - if($technology->getTech($i)) { - echo " - - - - "; - $success += 1; - } - } - if($success == 0) { - echo ""; - } - } - ?> - -
\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." (".AVAILABLE.": ".$village->unitarray['u'.$i].")
"; - echo "
- \"Wood\"".${'u'.$i}['wood']."|\"Clay\"".${'u'.$i}['clay']."|\"Iron\"".${'u'.$i}['iron']."|\"Crop\"".${'u'.$i}['crop']."|\"Crop".${'u'.$i}['pop']."|\"Duration\""; - $dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(${'u'.$i}['time'] * ($bid21[$village->resarray['f'.$id]]['attri'] / 100) / SPEED)); - echo $generator->getTimeFormat($dur); - - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']); - - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|maxUnitPlus($i))."&r2=".((${'u'.$i}['clay'])*$technology->maxUnitPlus($i))."&r3=".((${'u'.$i}['iron'])*$technology->maxUnitPlus($i))."&r4=".((${'u'.$i}['crop'])*$technology->maxUnitPlus($i))."\" title=\"NPC trade\">\"NPC"; - } - echo "
- - - maxUnit($i)."; return false;\">(".$technology->maxUnit($i).") -
".AVAILABLE_ACADEMY."
-

- - -

-
".TRAINING_COMMENCE_WORKSHOP."
\n"; - } +// 21.tpl - WORKSHOP +global $village, $building, $technology, $generator, $session, $database, $id, $bid21; - $trainlist = $technology->getTrainingList(3); - if(count($trainlist) > 0) { - //$timer = 2*count($trainlist); - echo " - - - - - - - "; - $TrainCount = 0; - foreach($trainlist as $train) { - $TrainCount++; - echo " -
".TRAINING."".DURATION."".FINISHED."
"; - echo "\"".$train['name']."\""; - echo $train['amt']." ".$train['name'].""; - if ($TrainCount == 1 ) { - $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; - } else { - echo $generator->getTimeFormat($train['eachtime']*$train['amt']); - } - echo ""; - $time = $generator->procMTime($train['timestamp']); - if($time[0] != "today") { - echo "on ".$time[0]." at "; - } - echo $time[1]; - } ?> -
- -

+$level = (int)$village->resarray['f'.$id]; +$canTrain = $building->getTypeLevel(21) > 0; +$trainlist = $technology->getTrainingList(3); +?> +
+ +

+

+ +
+ + + + + + + + + + tribe; + if ($tribe!== 4) { + $starts = [1=>7, 2=>17, 3=>27, 5=>47]; + $start = $starts[$tribe]?? 7; + for ($i = $start; $i <= $start+1; $i++) { + if (!$technology->getTech($i)) continue; + $unitData = ${'u'.$i}; + $name = $technology->getUnitName($i); + $maxTrain = $technology->maxUnit($i); + $maxPlus = $technology->maxUnitPlus($i); + $available = (int)($village->unitarray['u'.$i]?? 0); + $dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round($unitData['time'] * ($bid21[$level]['attri']/100) / SPEED)); + $timeFormatted = $generator->getTimeFormat($dur); + $total_required = (int)($unitData['wood']+$unitData['clay']+$unitData['iron']+$unitData['crop']); + $showNpc = $session->userinfo['gold']>=3 && $building->getTypeLevel(17)>=1 && $village->atotal >= $total_required; + $success++; + ?> + + + + + + + + + +
+
+ <?php echo htmlspecialchars($name);?> + + (: ) +
+
+ | + | + | + | + | + + + |NPC trade + +
+
()
+

+
+ +
+ + 0): + $NextFinished = ''; + ?> + + + + + + + + + + + + +
<?php echo $name;?> + getTimeFormat($train['timestamp2']-time());?> + getTimeFormat($train['timestamp']-time());?> + getTimeFormat($train['eachtime']*$amt); endif;?> + procMTime($train['timestamp']); if($time[0]!=="today") echo "on ".$time[0]." at "; echo $time[1];?>
+ + + +
\ No newline at end of file diff --git a/Templates/Build/22.tpl b/Templates/Build/22.tpl index a41e86e4..48bf5970 100644 --- a/Templates/Build/22.tpl +++ b/Templates/Build/22.tpl @@ -1,17 +1,23 @@ -
-

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

-

getTypeLevel(22) > 0) { - include("22_".$session->tribe.".tpl"); - } else { - echo "

".RESEARCH_COMMENCE_ACADEMY."
\n"; - } +// 22.tpl - ACADEMY +global $village, $building, $session, $id; - include("upgrade.tpl"); +$level = (int)$village->resarray['f'.$id]; +$hasAcademy = $building->getTypeLevel(22) > 0; +$tribe = (int)$session->tribe; ?> -

-
+
+ +

+

+ + + + +


+ + + +
\ No newline at end of file diff --git a/Templates/Build/22_1.tpl b/Templates/Build/22_1.tpl index 3bb7bb2e..b0dacf22 100644 --- a/Templates/Build/22_1.tpl +++ b/Templates/Build/22_1.tpl @@ -1,154 +1,100 @@ - - - - - - - -grabAcademyRes(); -for($i=2;$i<=9;$i++) { - if($technology->meetRRequirement($i) && !$technology->getTech($i) && !$technology->isResearch($i,1)) { - echo ""; - echo ""; - } - else if(${'r'.$i}['crop'] > $village->maxcrop) { - echo "
".EXPAND_GRANARY1.""; - echo ""; - } - else if(${'r'.$i}['wood'] > $village->awood || ${'r'.$i}['clay'] > $village->aclay || ${'r'.$i}['iron'] > $village->airon || ${'r'.$i}['crop'] > $village->acrop) { - if($village->getProd("crop")>0){ - $time = $technology->calculateAvaliable(22,${'r'.$i}); - echo "
".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1].""; - } else { - echo "
".CROP_NEGATIVE.""; - } - echo ""; - } - else if (count($acares) > 0) { - echo ""; - echo ""; - } - else if($session->access != BANNED){ - echo ""; - echo ""; - }else{ - echo ""; - echo ""; - } - $success += 1; - } - else { - $fail += 1; - } -} -if($success == 0) { -echo ""; -} -?> - -
-
- \"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." -
-
\"Lumber\"".${'r'.$i}['wood']."|\"Clay\"".${'r'.$i}['clay']."|\"Iron\"".${'r'.$i}['iron']."|\"Crop\"".${'r'.$i}['crop']."|\"duration\""; - echo $generator->getTimeFormat(round(${'r'.$i}['time'] * ($bid22[$village->resarray['f'.$id]]['attri'] / 100)/SPEED)); - - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(${'r'.$i}['wood'] + ${'r'.$i}['clay'] + ${'r'.$i}['iron'] + ${'r'.$i}['crop']); - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } - if(${'r'.$i}['wood'] > $village->maxstore || ${'r'.$i}['clay'] > $village->maxstore || ${'r'.$i}['iron'] > $village->maxstore) { - echo "
".EXPAND_WAREHOUSE1."
-
".EXPAND_WAREHOUSE."
-
-
".EXPAND_GRANARY."
-
".TOO_FEW_RESOURCES."
- ".RESEARCH_IN_PROGRESS."
- mchecker."\">".RESEARCH."
- ".RESEARCH."
".RESEARCH_AVAILABLE."
0) { - echo "

".SHOW_MORE."

- - "; - if(!$technology->meetRRequirement(2) && !$technology->getTech(2)) { - echo""; - } - if(!$technology->meetRRequirement(3) && !$technology->getTech(3)) { - echo""; - } - if(!$technology->meetRRequirement(4) && !$technology->getTech(4)) { - echo ""; - } - if(!$technology->meetRRequirement(5) && !$technology->getTech(5)) { - echo ""; - } - if(!$technology->meetRRequirement(6) && !$technology->getTech(6)) { - echo ""; - } - if(!$technology->meetRRequirement(7) && !$technology->getTech(7)) { - echo " - "; - } - if(!$technology->meetRRequirement(8) && !$technology->getTech(8)) { - echo " - "; - } - if(!$technology->meetRRequirement(9) && !$technology->getTech(9)) { - echo " "; - } - echo ""; - echo "
".PREREQUISITES."
".ACADEMY." -  ".LEVEL." 1
".ARMOURY."  ".LEVEL." 1
".ACADEMY." -  ".LEVEL." 5
".BLACKSMITH."  ".LEVEL." 1
- ".ACADEMY." ".LEVEL." 5
".STABLE." ".LEVEL." 1
- ".ACADEMY." ".LEVEL." 5
".STABLE." ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 15
- ".STABLE." ".LEVEL." 10
".ACADEMY." -  ".LEVEL." 10
".WORKSHOP." ".LEVEL." 1
".WORKSHOP." -  ".LEVEL." 10
".ACADEMY." ".LEVEL." 15
- ".RALLYPOINT." ".LEVEL." 10
- ".ACADEMY." ".LEVEL." 20
"; -} -//$acares = $technology->grabAcademyRes(); -if(count($acares) > 0) { - echo " - "; - foreach($acares as $aca) { - $unit = substr($aca['tech'],1,2); - echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; - echo ""; - } - echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."timer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; -} +$acares = $technology->grabAcademyRes(); +$success = $fail = 0; +$level = (int)$village->resarray['f'.$id]; ?> + + + + meetRRequirement($i) &&!$technology->getTech($i) &&!$technology->isResearch($i,1))) { $fail++; continue; } + $success++; + $res = ${'r'.$i}; + $name = $technology->getUnitName($i); + $time = $generator->getTimeFormat(round($res['time'] * ($bid22[$level]['attri']/100) / SPEED)); + $total_required = (int)($res['wood']+$res['clay']+$res['iron']+$res['crop']); + $showNpc = $session->userinfo['gold']>=3 && $building->getTypeLevel(17)>=1 && $village->atotal >= $total_required; + ?> + + + + + + + + +
+
<?php echo htmlspecialchars($name);?>
+
+ | + | + | + | + + | + $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE1.""; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY1.""; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) { + if ($village->getProd("crop")>0){ $t=$technology->calculateAvaliable(22,$res); echo "
".ENOUGH_RESOURCES." ".$t[0]." at ".$t[1].""; } + else echo "
".CROP_NEGATIVE.""; + } + ?> +
+
+ $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE."
"; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY."
"; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) echo "
".TOO_FEW_RESOURCES."
"; + elseif (count($acares)>0) echo RESEARCH_IN_PROGRESS; + elseif ($session->access!=BANNED) echo "mchecker."\">".RESEARCH.""; + else echo "".RESEARCH.""; + ?> +
+ +0):?> +

+ + + + meetRRequirement(2) &&!$technology->getTech(2)):?> + + + meetRRequirement(3) &&!$technology->getTech(3)):?> + + + meetRRequirement(4) &&!$technology->getTech(4)):?> + + + meetRRequirement(5) &&!$technology->getTech(5)):?> + + + meetRRequirement(6) &&!$technology->getTech(6)):?> + + + meetRRequirement(7) &&!$technology->getTech(7)):?> + + + meetRRequirement(8) &&!$technology->getTech(8)):?> + + + meetRRequirement(9) &&!$technology->getTech(9)):?> + + + +
1
1
5
1
5
1
5
5
15
10
10
1
10
15
10
20
+ + +0):?> + + + + getUnitName($unit); $date=$generator->procMtime($aca['timestamp']);?> + + + +
<?php echo htmlspecialchars($name);?>getTimeFormat($aca['timestamp']-time());?> hrs
+ \ No newline at end of file diff --git a/Templates/Build/22_2.tpl b/Templates/Build/22_2.tpl index f4ff9597..cb539844 100644 --- a/Templates/Build/22_2.tpl +++ b/Templates/Build/22_2.tpl @@ -1,150 +1,97 @@ - - - - - - +grabAcademyRes(); -for($i=12;$i<=19;$i++) { - if($technology->meetRRequirement($i) && !$technology->getTech($i) && !$technology->isResearch($i,1)) { - echo ""; - echo ""; - } - else if(${'r'.$i}['crop'] > $village->maxcrop) { - echo "
".EXPAND_GRANARY1.""; - echo ""; - } - else if(${'r'.$i}['wood'] > $village->awood || ${'r'.$i}['clay'] > $village->aclay || ${'r'.$i}['iron'] > $village->airon || ${'r'.$i}['crop'] > $village->acrop) { - if($village->getProd("crop")>0){ - $time = $technology->calculateAvaliable(22,${'r'.$i}); - echo "
".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1].""; - } else { - echo "
".CROP_NEGATIVE.""; - } - echo ""; - } - else if ( count($acares) > 0 ) { - echo ""; - echo ""; - } - else if($session->access != BANNED){ - echo ""; - echo ""; - }else{ - echo ""; - echo ""; - } - $success += 1; - } - else { - $fail += 1; - } -} -if($success == 0) { -echo ""; -} -?> - -
-
- \"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." -
-
\"Lumber\"".${'r'.$i}['wood']."|\"Clay\"".${'r'.$i}['clay']."|\"Iron\"".${'r'.$i}['iron']."|\"Crop\"".${'r'.$i}['crop']."|\"duration\""; - echo $generator->getTimeFormat(round(${'r'.$i}['time'] * ($bid22[$village->resarray['f'.$id]]['attri'] / 100)/SPEED)); - - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(${'r'.$i}['wood'] + ${'r'.$i}['clay'] + ${'r'.$i}['iron'] + ${'r'.$i}['crop']); - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } - if(${'r'.$i}['wood'] > $village->maxstore || ${'r'.$i}['clay'] > $village->maxstore || ${'r'.$i}['iron'] > $village->maxstore) { - echo "
".EXPAND_WAREHOUSE1."
-
".EXPAND_WAREHOUSE."
-
-
".EXPAND_GRANARY."
-
".TOO_FEW_RESOURCES."
- ".RESEARCH_IN_PROGRESS."
- mchecker."\">".RESEARCH."
- ".RESEARCH."
".RESEARCH_AVAILABLE."
- 0) { - echo "

".SHOW_MORE."

- - "; - if(!$technology->meetRRequirement(13) && !$technology->getTech(13)) { - echo""; - } - if(!$technology->meetRRequirement(14) && !$technology->getTech(14)) { - echo ""; - } - if(!$technology->meetRRequirement(15) && !$technology->getTech(15)) { - echo ""; - } - if(!$technology->meetRRequirement(16) && !$technology->getTech(16)) { - echo ""; - } - if(!$technology->meetRRequirement(17) && !$technology->getTech(17)) { - echo " - "; - } - if(!$technology->meetRRequirement(18) && !$technology->getTech(18)) { - echo " - "; - } - if(!$technology->meetRRequirement(19) && !$technology->getTech(19)) { - echo " "; - } - echo " "; - echo "
".PREREQUISITES."
".ACADEMY." - ".LEVEL." 3
".BLACKSMITH." ".LEVEL." 1
- ".ACADEMY." ".LEVEL." 1
".MAINBUILDING." - ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 5
".STABLE." - ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 15
- ".STABLE." ".LEVEL." 10
\"Ram\" - Ram
".ACADEMY." - ".LEVEL." 10
".WORKSHOP." ".LEVEL." 1
".WORKSHOP." - ".LEVEL." 10
".ACADEMY." ".LEVEL." 15
- ".RALLYPOINT." ".LEVEL." 5
- Academy ".LEVEL." 20
"; -} -//$acares = $technology->grabAcademyRes(); -if(count($acares) > 0) { - echo " - "; - foreach($acares as $aca) { - $unit = substr($aca['tech'],1,2); - echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; - echo ""; - } - echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."timer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; -} +$success = $fail = 0; +$level = (int)$village->resarray['f'.$id]; ?> + + + + meetRRequirement($i) &&!$technology->getTech($i) &&!$technology->isResearch($i,1))) { $fail++; continue; } + $success++; + $res = ${'r'.$i}; + $name = $technology->getUnitName($i); + $time = $generator->getTimeFormat(round($res['time'] * ($bid22[$level]['attri']/100) / SPEED)); + $total_required = (int)($res['wood']+$res['clay']+$res['iron']+$res['crop']); + $showNpc = $session->userinfo['gold']>=3 && $building->getTypeLevel(17)>=1 && $village->atotal >= $total_required; + ?> + + + + + + + + +
+
<?php echo htmlspecialchars($name);?>
+
+ | + | + | + | + + | + $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE1.""; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY1.""; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) { + if ($village->getProd("crop")>0){ $t=$technology->calculateAvaliable(22,$res); echo "
".ENOUGH_RESOURCES." ".$t[0]." at ".$t[1].""; } + else echo "
".CROP_NEGATIVE.""; + } + ?> +
+
+ $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE."
"; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY."
"; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) echo "
".TOO_FEW_RESOURCES."
"; + elseif (count($acares)>0) echo RESEARCH_IN_PROGRESS; + elseif ($session->access!=BANNED) echo "mchecker."\">".RESEARCH.""; + else echo "".RESEARCH.""; + ?> +
+ +0):?> +

+ + + + meetRRequirement(13) &&!$technology->getTech(13)):?> + + + meetRRequirement(14) &&!$technology->getTech(14)):?> + + + meetRRequirement(15) &&!$technology->getTech(15)):?> + + + meetRRequirement(16) &&!$technology->getTech(16)):?> + + + meetRRequirement(17) &&!$technology->getTech(17)):?> + + + meetRRequirement(18) &&!$technology->getTech(18)):?> + + + meetRRequirement(19) &&!$technology->getTech(19)):?> + + + +
3
1
1
5
5
5
15
10
10
1
10
15
5
Academy 20
+ + +0):?> + + + + getUnitName($unit); $date=$generator->procMtime($aca['timestamp']);?> + + + +
<?php echo htmlspecialchars($name);?>getTimeFormat($aca['timestamp']-time());?> hrs
+ \ No newline at end of file diff --git a/Templates/Build/22_3.tpl b/Templates/Build/22_3.tpl index 3fa63035..e1ea43e5 100644 --- a/Templates/Build/22_3.tpl +++ b/Templates/Build/22_3.tpl @@ -1,153 +1,100 @@ - - - - + - -grabAcademyRes(); -for($i=22;$i<=29;$i++) { - if($technology->meetRRequirement($i) && !$technology->getTech($i) && !$technology->isResearch($i,1)) { - echo ""; - echo ""; - } - else if(${'r'.$i}['crop'] > $village->maxcrop) { - echo "
".EXPAND_GRANARY1.""; - echo ""; - } - else if(${'r'.$i}['wood'] > $village->awood || ${'r'.$i}['clay'] > $village->aclay || ${'r'.$i}['iron'] > $village->airon || ${'r'.$i}['crop'] > $village->acrop) { - if($village->getProd("crop")>0){ - $time = $technology->calculateAvaliable(22,${'r'.$i}); - echo "
".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1].""; - } else { - echo "
".CROP_NEGATIVE.""; - } - echo ""; - } - else if ( count($acares) > 0 ) { - echo ""; - echo ""; - } - else if($session->access != BANNED){ - echo ""; - echo ""; - }else{ - echo ""; - echo ""; - } - $success +=1; - } - else { - $fail += 1; - } -} -if($success == 0) { -echo ""; -} -?> -
-
- \"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." -
-
\"Lumber\"".${'r'.$i}['wood']."|\"Clay\"".${'r'.$i}['clay']."|\"Iron\"".${'r'.$i}['iron']."|\"Crop\"".${'r'.$i}['crop']."|\"duration\""; - echo $generator->getTimeFormat(round(${'r'.$i}['time'] * ($bid22[$village->resarray['f'.$id]]['attri'] / 100)/SPEED)); - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(${'r'.$i}['wood'] + ${'r'.$i}['clay'] + ${'r'.$i}['iron'] + ${'r'.$i}['crop']); - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } - if(${'r'.$i}['wood'] > $village->maxstore || ${'r'.$i}['clay'] > $village->maxstore || ${'r'.$i}['iron'] > $village->maxstore) { - echo "
".EXPAND_WAREHOUSE1."
-
".EXPAND_WAREHOUSE."
-
-
".EXPAND_GRANARY."
-
".TOO_FEW_RESOURCES."
- ".RESEARCH_IN_PROGRESS."
- mchecker."\">".RESEARCH."
- ".RESEARCH."
".RESEARCH_AVAILABLE."
- 0) { - echo "

".SHOW_MORE."

- - "; - if(!$technology->meetRRequirement(22) && !$technology->getTech(22)) { - echo""; - } - if(!$technology->meetRRequirement(23) && !$technology->getTech(23)) { - echo""; - } - if(!$technology->meetRRequirement(24) && !$technology->getTech(24)) { - echo ""; - } - if(!$technology->meetRRequirement(25) && !$technology->getTech(25)) { - echo ""; - } - if(!$technology->meetRRequirement(26) && !$technology->getTech(26)) { - echo ""; - } - if(!$technology->meetRRequirement(27) && !$technology->getTech(27)) { - echo " - "; - } - if(!$technology->meetRRequirement(28) && !$technology->getTech(28)) { - echo " - "; - } - if(!$technology->meetRRequirement(29) && !$technology->getTech(29)) { - echo " "; - } - echo " "; - echo "
".PREREQUISITES."
".ACADEMY." -  ".LEVEL." 3
".BLACKSMITH."  ".LEVEL." 1
".ACADEMY." -  ".LEVEL." 5
".STABLE."  ".LEVEL." 1
- ".ACADEMY." ".LEVEL." 5
".STABLE." -  ".LEVEL." 3
- ".ACADEMY." ".LEVEL." 5
".STABLE." -  ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 15
- ".STABLE." ".LEVEL." 10
".ACADEMY." -  ".LEVEL." 10
".WORKSHOP." ".LEVEL." 1
".WORKSHOP." -  ".LEVEL." 10
".ACADEMY." ".LEVEL." 15
- ".RALLYPOINT." ".LEVEL." 10
- ".ACADEMY." ".LEVEL." 20
"; -} -$acares = $technology->grabAcademyRes(); -if(count($acares) > 0) { - echo " - "; - foreach($acares as $aca) { - $unit = substr($aca['tech'],1,2); - echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; - echo ""; - } - echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."timer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; -} +$success = $fail = 0; +$level = (int)$village->resarray['f'.$id]; ?> + + + + meetRRequirement($i) &&!$technology->getTech($i) &&!$technology->isResearch($i,1))) { $fail++; continue; } + $success++; + $res = ${'r'.$i}; + $name = $technology->getUnitName($i); + $time = $generator->getTimeFormat(round($res['time'] * ($bid22[$level]['attri']/100) / SPEED)); + $total_required = (int)($res['wood']+$res['clay']+$res['iron']+$res['crop']); + $showNpc = $session->userinfo['gold']>=3 && $building->getTypeLevel(17)>=1 && $village->atotal >= $total_required; + ?> + + + + + + + + +
+
<?php echo htmlspecialchars($name);?>
+
+ | + | + | + | + + | + $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE1.""; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY1.""; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) { + if ($village->getProd("crop")>0){ $t=$technology->calculateAvaliable(22,$res); echo "
".ENOUGH_RESOURCES." ".$t[0]." at ".$t[1].""; } + else echo "
".CROP_NEGATIVE.""; + } + ?> +
+
+ $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE."
"; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY."
"; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) echo "
".TOO_FEW_RESOURCES."
"; + elseif (count($acares)>0) echo RESEARCH_IN_PROGRESS; + elseif ($session->access!=BANNED) echo "mchecker."\">".RESEARCH.""; + else echo "".RESEARCH.""; + ?> +
+ +0):?> +

+ + + + meetRRequirement(22) &&!$technology->getTech(22)):?> + + + meetRRequirement(23) &&!$technology->getTech(23)):?> + + + meetRRequirement(24) &&!$technology->getTech(24)):?> + + + meetRRequirement(25) &&!$technology->getTech(25)):?> + + + meetRRequirement(26) &&!$technology->getTech(26)):?> + + + meetRRequirement(27) &&!$technology->getTech(27)):?> + + + meetRRequirement(28) &&!$technology->getTech(28)):?> + + + meetRRequirement(29) &&!$technology->getTech(29)):?> + + + +
<?php echo U22;?>
3
1
<?php echo U23;?>
5
1
<?php echo U24;?>
5
3
<?php echo U25;?>
5
5
<?php echo U26;?>
15
10
<?php echo U27;?>
10
1
<?php echo U28;?>
10
15
<?php echo U29;?>
10
20
+ + +0):?> + + + + getUnitName($unit); $date=$generator->procMtime($aca['timestamp']);?> + + + +
<?php echo htmlspecialchars($name);?>getTimeFormat($aca['timestamp']-time());?> hrs
+ \ No newline at end of file diff --git a/Templates/Build/22_4.tpl b/Templates/Build/22_4.tpl index 0652181a..7837c2be 100644 --- a/Templates/Build/22_4.tpl +++ b/Templates/Build/22_4.tpl @@ -1,147 +1,97 @@ - - - - - - +grabAcademyRes(); -for($i=32;$i<=39;$i++) { - if($technology->meetRRequirement($i) && !$technology->getTech($i) && !$technology->isResearch($i,1)) { - echo ""; - echo ""; - } - else if(${'r'.$i}['crop'] > $village->maxcrop) { - echo "
".EXPAND_GRANARY1.""; - echo ""; - } - else if(${'r'.$i}['wood'] > $village->awood || ${'r'.$i}['clay'] > $village->aclay || ${'r'.$i}['iron'] > $village->airon || ${'r'.$i}['crop'] > $village->acrop) { - $time = $technology->calculateAvaliable($i); - echo "
".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1].""; - echo ""; - } - else if ( count($acares) > 0 ) { - echo ""; - echo ""; - } - else if($session->access != BANNED){ - echo ""; - echo ""; - }else{ - echo ""; - echo ""; - } - $success += 1; - } - else { - $fail += 1; - } -} -if($success == 0) { -echo ""; -} -?> - -
-
- \"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." -
-
\"Lumber\"".${'r'.$i}['wood']."|\"Clay\"".${'r'.$i}['clay']."|\"Iron\"".${'r'.$i}['iron']."|\"Crop\"".${'r'.$i}['crop']."|\"duration\""; - echo $generator->getTimeFormat(round(${'r'.$i}['time'] * ($bid22[$village->resarray['f'.$id]]['attri'] / 100)/SPEED)); - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(${'r'.$i}['wood'] + ${'r'.$i}['clay'] + ${'r'.$i}['iron'] + ${'r'.$i}['crop']); - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } - if(${'r'.$i}['wood'] > $village->maxstore || ${'r'.$i}['clay'] > $village->maxstore || ${'r'.$i}['iron'] > $village->maxstore) { - echo "
".EXPAND_WAREHOUSE1."
-
".EXPAND_WAREHOUSE."
-
-
".EXPAND_GRANARY."
-
-
".TOO_FEW_RESOURCES."
-
- ".RESEARCH_IN_PROGRESS."
- mchecker."\">".RESEARCH."
- ".RESEARCH."
".RESEARCH_AVAILABLE."
- 0) { - echo "

".SHOW_MORE."

- - "; - if(!$technology->meetRRequirement(33) && !$technology->getTech(33)) { - echo""; - } - if(!$technology->meetRRequirement(34) && !$technology->getTech(34)) { - echo ""; - } - if(!$technology->meetRRequirement(35) && !$technology->getTech(35)) { - echo ""; - } - if(!$technology->meetRRequirement(36) && !$technology->getTech(36)) { - echo ""; - } - if(!$technology->meetRRequirement(17) && !$technology->getTech(17)) { - echo " - "; - } - if(!$technology->meetRRequirement(38) && !$technology->getTech(38)) { - echo " - "; - } - if(!$technology->meetRRequirement(39) && !$technology->getTech(39)) { - echo " "; - } - echo " "; - echo "
".PREREQUISITES."
".ACADEMY." - ".LEVEL." 3
".BLACKSMITH." ".LEVEL." 1
- ".ACADEMY." ".LEVEL." 1
".MAINBUILDING." - ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 5
".STABLE." - ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 15
- ".STABLE." ".LEVEL." 10
".ACADEMY." - ".LEVEL." 10
".WORKSHOP." ".LEVEL." 1
".WORKSHOP." - ".LEVEL." 10
".ACADEMY." ".LEVEL." 15
- ".RALLYPOINT." ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 20
"; -} -//$acares = $technology->grabAcademyRes(); -if(count($acares) > 0) { - echo " - "; - foreach($acares as $aca) { - $unit = substr($aca['tech'],1,2); - echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; - echo ""; - } - echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."timer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; -} +$success = $fail = 0; +$level = (int)$village->resarray['f'.$id]; ?> + + + + meetRRequirement($i) &&!$technology->getTech($i) &&!$technology->isResearch($i,1))) { $fail++; continue; } + $success++; + $res = ${'r'.$i}; + $name = $technology->getUnitName($i); + $time = $generator->getTimeFormat(round($res['time'] * ($bid22[$level]['attri']/100) / SPEED)); + $total_required = (int)($res['wood']+$res['clay']+$res['iron']+$res['crop']); + $showNpc = $session->userinfo['gold']>=3 && $building->getTypeLevel(17)>=1 && $village->atotal >= $total_required; +?> + + + + + + + + +
+
<?php echo htmlspecialchars($name);?>
+
+ | + | + | + | + + | + $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE1.""; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY1.""; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) { + if ($village->getProd("crop")>0){ $t=$technology->calculateAvaliable(22,$res); echo "
".ENOUGH_RESOURCES." ".$t[0]." at ".$t[1].""; } + else echo "
".CROP_NEGATIVE.""; + } + ?> +
+
+ $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE."
"; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY."
"; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) echo "
".TOO_FEW_RESOURCES."
"; + elseif (count($acares)>0) echo RESEARCH_IN_PROGRESS; + elseif ($session->access!=BANNED) echo "mchecker."\">".RESEARCH.""; + else echo "".RESEARCH.""; + ?> +
+ +0):?> +

+ + + + meetRRequirement(33) &&!$technology->getTech(33)):?> + + + meetRRequirement(34) &&!$technology->getTech(34)):?> + + + meetRRequirement(35) &&!$technology->getTech(35)):?> + + + meetRRequirement(36) &&!$technology->getTech(36)):?> + + + meetRRequirement(37) &&!$technology->getTech(37)):?> + + + meetRRequirement(38) &&!$technology->getTech(38)):?> + + + meetRRequirement(39) &&!$technology->getTech(39)):?> + + + +
<?php echo U33;?>
3
1
<?php echo U34;?>
1
5
<?php echo U35;?>
5
5
<?php echo U36;?>
15
10
<?php echo U37;?>
10
1
<?php echo U38;?>
10
15
<?php echo U39;?>
5
20
+ + +0):?> + + + + getUnitName($unit); $date=$generator->procMtime($aca['timestamp']);?> + + + +
<?php echo htmlspecialchars($name);?>getTimeFormat($aca['timestamp']-time());?> hrs
+ \ No newline at end of file diff --git a/Templates/Build/22_5.tpl b/Templates/Build/22_5.tpl index 58cc7b79..0a99718f 100644 --- a/Templates/Build/22_5.tpl +++ b/Templates/Build/22_5.tpl @@ -1,143 +1,97 @@ - - - - - - +grabAcademyRes(); -for($i=42;$i<=49;$i++) { - if($technology->meetRRequirement($i) && !$technology->getTech($i) && !$technology->isResearch($i,1)) { - echo ""; - echo ""; - } - else if(${'r'.$i}['crop'] > $village->maxcrop) { - echo "
".EXPAND_GRANARY1.""; - echo ""; - } - else if(${'r'.$i}['wood'] > $village->awood || ${'r'.$i}['clay'] > $village->aclay || ${'r'.$i}['iron'] > $village->airon || ${'r'.$i}['crop'] > $village->acrop) { - $time = $technology->calculateAvaliable($i); - echo "
".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1].""; - echo ""; - } - else if ( count($acares) > 0 ) { - echo ""; - echo ""; - } - else { - echo ""; - echo ""; - } - $success += 1; - } - else { - $fail += 1; - } -} -if($success == 0) { -echo ""; -} -?> - -
-
- \"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." -
-
\"Lumber\"".${'r'.$i}['wood']."|\"Clay\"".${'r'.$i}['clay']."|\"Iron\"".${'r'.$i}['iron']."|\"Crop\"".${'r'.$i}['crop']."|\"duration\""; - echo $generator->getTimeFormat(round(${'r'.$i}['time'] * ($bid22[$village->resarray['f'.$id]]['attri'] / 100)/SPEED)); - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(${'r'.$i}['wood'] + ${'r'.$i}['clay'] + ${'r'.$i}['iron'] + ${'r'.$i}['crop']); - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } - if(${'r'.$i}['wood'] > $village->maxstore || ${'r'.$i}['clay'] > $village->maxstore || ${'r'.$i}['iron'] > $village->maxstore) { - echo "
".EXPAND_WAREHOUSE1."
-
".EXPAND_WAREHOUSE."
-
-
".EXPAND_GRANARY."
-
-
".TOO_FEW_RESOURCES."
-
- ".RESEARCH_IN_PROGRESS."
- mchecker."\">".RESEARCH."
".RESEARCH_AVAILABLE."
- 0) { - echo "

".SHOW_MORE."

- - "; - if(!$technology->meetRRequirement(43) && !$technology->getTech(43)) { - echo""; - } - if(!$technology->meetRRequirement(44) && !$technology->getTech(44)) { - echo ""; - } - if(!$technology->meetRRequirement(45) && !$technology->getTech(45)) { - echo ""; - } - if(!$technology->meetRRequirement(46) && !$technology->getTech(46)) { - echo ""; - } - if(!$technology->meetRRequirement(47) && !$technology->getTech(47)) { - echo " - "; - } - if(!$technology->meetRRequirement(48) && !$technology->getTech(48)) { - echo " - "; - } - if(!$technology->meetRRequirement(49) && !$technology->getTech(49)) { - echo " "; - } - echo " "; - echo "
".PREREQUISITES."
".ACADEMY." - ".LEVEL." 3
".BLACKSMITH." ".LEVEL." 1
- ".ACADEMY." ".LEVEL." 1
".MAINBUILDING." - ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 5
".STABLE." - ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 15
- ".STABLE." ".LEVEL." 10
".ACADEMY." - ".LEVEL." 10
".WORKSHOP." ".LEVEL." 1
".WORKSHOP." - ".LEVEL." 10
".ACADEMY." ".LEVEL." 15
- ".RALLYPOINT." ".LEVEL." 5
- ".ACADEMY." ".LEVEL." 20
"; -} -//$acares = $technology->grabAcademyRes(); -if(count($acares) > 0) { - echo " - "; - foreach($acares as $aca) { - $unit = substr($aca['tech'],1,2); - echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; - echo ""; - } - echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."timer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; -} +$success = $fail = 0; +$level = (int)$village->resarray['f'.$id]; ?> + + + + meetRRequirement($i) &&!$technology->getTech($i) &&!$technology->isResearch($i,1))) { $fail++; continue; } + $success++; + $res = ${'r'.$i}; + $name = $technology->getUnitName($i); + $time = $generator->getTimeFormat(round($res['time'] * ($bid22[$level]['attri']/100) / SPEED)); + $total_required = (int)($res['wood']+$res['clay']+$res['iron']+$res['crop']); + $showNpc = $session->userinfo['gold']>=3 && $building->getTypeLevel(17)>=1 && $village->atotal >= $total_required; +?> + + + + + + + + +
+
<?php echo htmlspecialchars($name);?>
+
+ | + | + | + | + + | + $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE1.""; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY1.""; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) { + if ($village->getProd("crop")>0){ $t=$technology->calculateAvaliable(22,$res); echo "
".ENOUGH_RESOURCES." ".$t[0]." at ".$t[1].""; } + else echo "
".CROP_NEGATIVE.""; + } + ?> +
+
+ $village->maxstore||$res['clay']>$village->maxstore||$res['iron']>$village->maxstore) echo "
".EXPAND_WAREHOUSE."
"; + elseif ($res['crop']>$village->maxcrop) echo "
".EXPAND_GRANARY."
"; + elseif ($res['wood']>$village->awood||$res['clay']>$village->aclay||$res['iron']>$village->airon||$res['crop']>$village->acrop) echo "
".TOO_FEW_RESOURCES."
"; + elseif (count($acares)>0) echo RESEARCH_IN_PROGRESS; + elseif ($session->access!=BANNED) echo "mchecker."\">".RESEARCH.""; + else echo "".RESEARCH.""; + ?> +
+ +0):?> +

+ + + + meetRRequirement(43) &&!$technology->getTech(43)):?> + + + meetRRequirement(44) &&!$technology->getTech(44)):?> + + + meetRRequirement(45) &&!$technology->getTech(45)):?> + + + meetRRequirement(46) &&!$technology->getTech(46)):?> + + + meetRRequirement(47) &&!$technology->getTech(47)):?> + + + meetRRequirement(48) &&!$technology->getTech(48)):?> + + + meetRRequirement(49) &&!$technology->getTech(49)):?> + + + +
<?php echo U43;?>
3
1
<?php echo U44;?>
1
5
<?php echo U45;?>
5
5
<?php echo U46;?>
15
10
<?php echo U47;?>
10
1
<?php echo U48;?>
10
15
<?php echo U49;?>
5
20
+ + +0):?> + + + + getUnitName($unit); $date=$generator->procMtime($aca['timestamp']);?> + + + +
<?php echo htmlspecialchars($name);?>getTimeFormat($aca['timestamp']-time());?> hrs
+ \ No newline at end of file diff --git a/Templates/Build/23.tpl b/Templates/Build/23.tpl index 80cdbc21..c8f2ddef 100644 --- a/Templates/Build/23.tpl +++ b/Templates/Build/23.tpl @@ -1,27 +1,35 @@ tribe == 3) ? 2 : 1) * CRANNY_CAPACITY; -$actualLevel = $village->resarray['f'.$id]; +$actualLevel = (int)$village->resarray['f'.$id]; $level = min($actualLevel + 1 + $loopsame + $doublebuild + $master, 10); + +$currentHidden = $database->getArtifactsValueInfluence($session->uid, $village->wid, 7, $bid23[$actualLevel]['attri'] * $multiplier); +$nextHidden = $database->getArtifactsValueInfluence($session->uid, $village->wid, 7, $bid23[$level]['attri'] * $multiplier); ?> -
-

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

-

- - - - - - - - - - - -
getArtifactsValueInfluence($session->uid, $village->wid, 7, $bid23[$village->resarray['f'.$id]]['attri'] * $multiplier); ?>
:getArtifactsValueInfluence($session->uid, $village->wid, 7, $bid23[$level]['attri'] * $multiplier); ?>
- +
+ +

+

+ + + + + + + + + + + + +
:
+ +
\ No newline at end of file diff --git a/Templates/Build/24.tpl b/Templates/Build/24.tpl index 9e58b86f..a31bcf46 100644 --- a/Templates/Build/24.tpl +++ b/Templates/Build/24.tpl @@ -1,18 +1,21 @@ -
-

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

-

-

getTypeLevel(24) > 0) { - include("Templates/Build/24_1.tpl"); - include("Templates/Build/24_2.tpl"); - } else { - echo "

".CELEBRATIONS_COMMENCE_TOWNHALL."
\n"; - } - - include("upgrade.tpl"); - +// 24.tpl - Town Hall +global $village, $building, $id; +$level = (int)$village->resarray['f'.$id]; ?> -

+
+ +

+

+ + getTypeLevel(24) > 0):?> + + + +

+ + + +
\ No newline at end of file diff --git a/Templates/Build/24_1.tpl b/Templates/Build/24_1.tpl index 972d7e26..253e3608 100644 --- a/Templates/Build/24_1.tpl +++ b/Templates/Build/24_1.tpl @@ -1,82 +1,68 @@ - - - - - - - - + - resarray['f'.$id]; - $inuse = $database->getVillageField($village->wid, 'celebration'); - $time = Time(); - $i = 1; - echo ""; - } - else if($cel[$i]['wood'] > $village->awood || $cel[$i]['clay'] > $village->aclay || $cel[$i]['iron'] > $village->airon || $cel[$i]['crop'] > $village->acrop) { - if($village->getProd("crop")>0){ - $time = $technology->calculateAvaliable(24,$cel[$i]); - echo "
".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1].""; - } else { - echo "
".CROP_NEGATIVE.""; - } - echo ""; - } - else { - echo ""; - echo ""; - } - - if($level >= 10){ - $level = $village->resarray['f'.$id]; - echo ""; - } - else if(29700 > $village->awood || 33250 > $village->aclay || 32000 > $village->airon || 6700 > $village->acrop) { - if($village->getProd("crop")>0){ - $time = $technology->calculateAvaliable(24,$cel[2]); - echo "
".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1].""; - } else { - echo "
".CROP_NEGATIVE.""; - } - echo ""; - } - else { - echo ""; - echo ""; - } - } +$level = (int)$village->resarray['f'.$id]; +$inuse = (int)$database->getVillageField($village->wid, 'celebration'); +$now = time(); +$inProgress = $inuse > $now; ?> - -
".$cel[$i]['name']." (".$cel[$i]['attri']." ".CULTURE_POINTS.")
-
\"Lumber\"".$cel[$i]['wood']."|\"Clay\"".$cel[$i]['clay']."|\"Iron\"".$cel[$i]['iron']."|\"Crop\"".$cel[$i]['crop']."|\"duration\""; - echo $generator->getTimeFormat(round($cel[$i]['time'] * ($bid24[$building->getTypeLevel(24)]['attri'] / 100)/SPEED)); - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)($cel[$i]['wood'] + $cel[$i]['clay'] + $cel[$i]['iron'] + $cel[$i]['crop']); - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } - if($inuse > $time){ - echo "
-
".CELEBRATIONS_IN_PROGRESS."
-
".TOO_FEW_RESOURCES."
"; - echo "".HOLD."
-
- ".GREAT_CELEBRATIONS." (2000 ".CULTURE_POINTS.") -
-
\"Lumber\"29700|\"Clay\"33250|\"Iron\"32000|\"Crop\"6700|\"duration\""; - echo $generator->getTimeFormat(round($gc[$level]/SPEED)); - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)(29700 + 33250 + 32000 + 6700); - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } - if($inuse > $time){ - echo "
-
".CELEBRATIONS_IN_PROGRESS."
-
-
".TOO_FEW_RESOURCES."
-
- ".HOLD."
+ + + + getTimeFormat(round($c['time'] * ($bid24[$building->getTypeLevel(24)]['attri']/100) / SPEED)); + $total = $c['wood']+$c['clay']+$c['iron']+$c['crop']; + $showNpc = $session->userinfo['gold']>=3 && $building->getTypeLevel(17)>=1 && $village->atotal >= $total; + $canAfford = $c['wood']<=$village->awood && $c['clay']<=$village->aclay && $c['iron']<=$village->airon && $c['crop']<=$village->acrop; + ?> + + + + + = 10): + $gcTime = $generator->getTimeFormat(round($gc[$level]/SPEED)); + $gcTotal = 29700+33250+32000+6700; + $showNpc2 = $session->userinfo['gold']>=3 && $building->getTypeLevel(17)>=1 && $village->atotal >= $gcTotal; + $canAfford2 = 29700<=$village->awood && 33250<=$village->aclay && 32000<=$village->airon && 6700<=$village->acrop; + ?> + + + + + + +
+
( )
+
+ | + | + | + | + + | + getProd("crop")>0){ $t=$technology->calculateAvaliable(24,$c); echo "
".ENOUGH_RESOURCES." ".$t[0]." at ".$t[1].""; } else echo "
".CROP_NEGATIVE.""; endif;?> +
+
+
+
+ +
+
(2000 )
+
+ 29700| + 33250| + 32000| + 6700| + + | + getProd("crop")>0){ $t=$technology->calculateAvaliable(24,$cel[2]); echo "
".ENOUGH_RESOURCES." ".$t[0]." at ".$t[1].""; } else echo "
".CROP_NEGATIVE.""; endif;?> +
+
+
+
+ +
\ No newline at end of file diff --git a/Templates/Build/24_2.tpl b/Templates/Build/24_2.tpl index f2ff076b..adfb0a3b 100644 --- a/Templates/Build/24_2.tpl +++ b/Templates/Build/24_2.tpl @@ -1,14 +1,16 @@ -getVillageField($village->wid, 'celebration'); - if($timeleft > time()){ - echo '
'; - echo ''; - echo '"; - echo ""; - echo "
'; - echo 'celebration still needs:'; - echo "timer."\">"; - echo $generator->getTimeFormat($timeleft - time()); - echo " hrs.done at ".date('H:i', $timeleft)."
"; - } -?> \ No newline at end of file +getVillageField($village->wid, 'celebration'); +if ($timeleft > time()): +?> +
+ + + + + + +
celebration still needs:getTimeFormat($timeleft - time());?> hrs.done at
+ \ No newline at end of file diff --git a/Templates/Build/25.tpl b/Templates/Build/25.tpl index e71ffd2e..f0b8915e 100644 --- a/Templates/Build/25.tpl +++ b/Templates/Build/25.tpl @@ -1,26 +1,29 @@ -

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

-

- -

- capital == 1) { - echo "

".CAPITAL."

"; -} +// 25.tpl - Residence +global $village, $id; -include("25_menu.tpl"); - -if($village->resarray['f'.$id] >= 10){ - include ("25_train.tpl"); -} -else{ - echo '
'.RESIDENCE_TRAIN_DESC.'
'; -} - -include("upgrade.tpl"); +$level = (int)$village->resarray['f'.$id]; ?> -
+
+

+

+ + +

+ + capital == 1):?> +

+ + + + + = 10):?> + + +
+ + + +
\ No newline at end of file diff --git a/Templates/Build/25_2.tpl b/Templates/Build/25_2.tpl index fa9320ab..e9a35ced 100644 --- a/Templates/Build/25_2.tpl +++ b/Templates/Build/25_2.tpl @@ -1,28 +1,38 @@ -

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

-

- -

+ +$level = (int)$village->resarray['f'.$id]; +$isNatar = (int)$database->getVillageField($village->wid, 'natar') == 1; +$villageCp = $isNatar ? 0 : (int)$database->getVillageField($village->wid, 'cp'); +$accountCp = (int)$database->getVSumField($session->uid, 'cp'); +$totalVillages = count($database->getProfileVillages($session->uid)); -

+$mode = CP; +$nextCpNeeded = ${'cp'.$mode}[$totalVillages + 1]; +?> +
+

+

+ + +

- - - -getVillageField($village->wid, 'natar') == 0){ ?> - - - - - - - - - -
getVillageField($village->wid, 'cp'); ?> 0
getVSumField($session->uid, 'cp'); ?>

cp; ?> getProfileVillages($session->uid)); echo ${'cp'.$mode}[$total+1]; ?> .

-
+ + +

+ + + + + + + + + + +
+

cp;?> .

+
\ No newline at end of file diff --git a/Templates/Build/25_3.tpl b/Templates/Build/25_3.tpl index 21ac6297..623992a4 100644 --- a/Templates/Build/25_3.tpl +++ b/Templates/Build/25_3.tpl @@ -1,13 +1,20 @@ -

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

-

- -

+resarray['f'.$id]; +$loyalty = floor((float)$database->getVillageField($village->wid, 'loyalty')); +?> +
+

+

+ + +

- + - getVillageField($village->wid,'loyalty')); ?> .
+

.

+
\ No newline at end of file diff --git a/Templates/Build/25_4.tpl b/Templates/Build/25_4.tpl index a3c315a3..16b0cc88 100644 --- a/Templates/Build/25_4.tpl +++ b/Templates/Build/25_4.tpl @@ -1,54 +1,56 @@ -

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

-

- -

- - - - - - - - - - - - - - -getVillageField($village->wid, 'exp1'); -$slot2 = $database->getVillageField($village->wid, 'exp2'); -$slot3 = $database->getVillageField($village->wid, 'exp3'); +// 25_4.tpl - RESIDENCE EXPANSION +global $village, $database, $generator, $id; -if($slot1 != 0 || $slot2 != 0 || $slot3 != 0){ - for($i=1; $i <= 3; $i++){ - if (${'slot'.$i}<>0) { - $coor = $database->getCoor(${'slot'.$i}); - $vname = $database->getVillageField(${'slot'.$i},'name'); - $owner = $database->getVillageField(${'slot'.$i},'owner'); - $pop = $database->getVillageField(${'slot'.$i},'pop'); - $vcreated = $database->getVillageField(${'slot'.$i},'created'); - $ownername = $database->getUserField($owner,'username',0); -echo ' - - - - - - - -'; - } - } -} -else{ -echo ''; -} +$level = (int)$village->resarray['f'.$id]; +$slots = [ + (int)$database->getVillageField($village->wid, 'exp1'), + (int)$database->getVillageField($village->wid, 'exp2'), + (int)$database->getVillageField($village->wid, 'exp3'), +]; ?> -
'.$i.'.'.$vname.''.$ownername.''.$pop.'
('.$coor['x'].'
|
'.$coor['y'].')
'.date('d.m.Y',$vcreated).'
'.NONE_CONQUERED_BY_VILLAGE.'
+
+

+

+ + +

+ + + + + + + + + + + + + + + + $slotId): if ($slotId == 0) continue; $hasSlots = true; + $coor = $database->getCoor($slotId); + $vname = $database->getVillageField($slotId, 'name'); + $owner = $database->getVillageField($slotId, 'owner'); + $pop = $database->getVillageField($slotId, 'pop'); + $vcreated = $database->getVillageField($slotId, 'created'); + $ownername = $database->getUserField($owner, 'username', 0); + ?> + + + + + + + + + + + + +
.
(
|
)
+
\ No newline at end of file diff --git a/Templates/Build/25_create.tpl b/Templates/Build/25_create.tpl index a033e521..6c7bccdb 100644 --- a/Templates/Build/25_create.tpl +++ b/Templates/Build/25_create.tpl @@ -1,68 +1,55 @@ -
- - - - - - - - - - - - - - "; - ?> +$i = 20; // Settler (sau 19 pentru Chief la Palace) +$unit = ${'u'.$i}; +$available = (int)$village->unitarray['u'.$i]; +$maxTrain = $technology->maxUnit($i); +$trainlist = $technology->getTrainingList(20); +?> + + + - -
NaamAantalmax
-
- \"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." (Available: ".$village->unitarray['u'.$i].") -
-
\"Lumber\"".${'u'.$i}['wood']."|\"Clay\"".${'u'.$i}['clay']."|\"Iron\"".${'u'.$i}['iron']."|\"Crop\"".${'u'.$i}['crop']."|\"duration\""; - echo $generator->getTimeFormat(round(${'u'.$i}['time']/SPEED)); - //-- If available resources combined are not enough, remove NPC button - //$total_required = (int)(${'r'.$i}['wood'] + ${'r'.$i}['clay'] + ${'r'.$i}['iron'] + ${'r'.$i}['crop']); +// 25_create.tpl - RESIDENCE TRAIN UNITS +global $id, $technology, $village, $generator; - //if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - //echo "|\"NPC"; - //} - echo " -
maxUnit($i)."; return false;\">(".$technology->maxUnit($i).")
-

- -

+ + + + + + + + + +
NaamAantalmax
+
+ <?php echo $technology->getUnitName($i);?> + getUnitName($i);?> + (Available: ) +
+
+ | + | + | + | + getTimeFormat(round($unit['time']/SPEED));?> +
+
()
+

- getTrainingList(20); - if(count($trainlist) > 0) { - $timer = 2*count($trainlist); - echo " - - - - - - - "; - foreach($trainlist as $train) { - echo " - "; - } - echo "
TrainingDurationFinished
"; - echo "\"".$train['name']."\"".$train['amt']." ".$train['name']."".$generator->getTimeFormat(($train['commence']+($train['eachtime']*$train['amt']))-time()).""; - $timer -= 1; - $time = $generator->procMTime($train['commence']+(1*$train['amt'])); - if($time[0] != "today") { - echo "on ".$time[0]." at"; - } - echo $time[1]." o'clock
The next unit will be finished in ".$generator->getTimeFormat(($train['commence']+$train['eachtime'])-time())."
"; - } - ?> - -
+ 0): $timer = 2*count($trainlist);?> + + + + + + + + + + + + +
TrainingDurationFinished
<?php echo $train['name'];?> getTimeFormat(($train['commence']+($train['eachtime']*$train['amt']))-time());?>procMTime($train['commence']+$train['amt']); if($time[0]!="today") echo "on ".$time[0]." at "; echo $time[1];?> o'clock
The next unit will be finished in getTimeFormat(($train['commence']+$train['eachtime'])-time());?>
+ + \ No newline at end of file diff --git a/Templates/Build/25_menu.tpl b/Templates/Build/25_menu.tpl index 388d2952..05915d78 100644 --- a/Templates/Build/25_menu.tpl +++ b/Templates/Build/25_menu.tpl @@ -1,7 +1,12 @@ -
- > - | > - | > - | > + +
+ > + | > + | > + | >
\ No newline at end of file diff --git a/Templates/Build/25_progress.tpl b/Templates/Build/25_progress.tpl index 8b1baf41..d5bc893e 100644 --- a/Templates/Build/25_progress.tpl +++ b/Templates/Build/25_progress.tpl @@ -1,34 +1,32 @@ - getTrainingList(4); - if(count($trainlist) > 0) { - echo " - - - - - - - "; - $TrainCount = 0; - foreach($trainlist as $train) { - $TrainCount++; - echo " -
".TRAINING."".DURATION."".FINISHED."
"; - echo "\"".$train['name']."\""; - echo $train['amt']." ".$train['name'].""; - if ($TrainCount == 1 ) { - $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; - } else { - echo $generator->getTimeFormat($train['eachtime']*$train['amt']); - } - echo ""; - $time = $generator->procMTime($train['timestamp']); - if($time[0] != "today") { - echo "on ".$time[0]." at "; - } - echo $time[1]; - } ?> -
- getTrainingList(4); +if (count($trainlist) > 0): + $TrainCount = 0; + $NextFinished = ''; ?> + + + + + + + + + + + + +
+ <?php echo $train['name'];?> + + + getTimeFormat($train['timestamp2']-time());?> + getTimeFormat($train['timestamp']-time());?> + + getTimeFormat($train['eachtime']*$train['amt']);?> + + procMTime($train['timestamp']); if($time[0]!="today") echo "on ".$time[0]." at "; echo $time[1];?>
+ \ No newline at end of file diff --git a/Templates/Build/25_train.tpl b/Templates/Build/25_train.tpl index db0224f1..a38fd454 100644 --- a/Templates/Build/25_train.tpl +++ b/Templates/Build/25_train.tpl @@ -1,13 +1,6 @@ getAvailableExpansionTraining(); diff --git a/Templates/Build/26.tpl b/Templates/Build/26.tpl index ec774b3a..071a4dc6 100644 --- a/Templates/Build/26.tpl +++ b/Templates/Build/26.tpl @@ -1,38 +1,58 @@ 5){ $_SESSION['time_p'] = ''; $_SESSION['error_p'] = ''; } - -if($_POST and $_GET['action'] == 'change_capital' && !$village->capital){ - $pass = mysqli_escape_string($database->dblink, $_POST['pass']); +// --- LOGICA SCHIMBARE CAPITALA --- +if($_POST && $_GET['action'] == 'change_capital' && !$village->capital){ + $pass = $_POST['pass']; $query = mysqli_query($database->dblink, 'SELECT password FROM `'.TB_PREFIX.'users` WHERE `id` = '.(int)$session->uid); $data = mysqli_fetch_assoc($query); + // 1. Verifică parola if(password_verify($pass, $data['password'])){ $query1 = mysqli_query($database->dblink, 'SELECT wref FROM `'.TB_PREFIX.'vdata` WHERE `owner` = '.(int)$session->uid.' AND `capital` = 1'); $data1 = mysqli_fetch_assoc($query1); - $query2 = mysqli_query($database->dblink, 'SELECT * FROM `'.TB_PREFIX.'fdata` WHERE `vref` = '.(int)$data1['wref']); - $data2 = mysqli_fetch_assoc($query2); - if($data2['vref'] != $village->wid){ + $oldWid = (int)$data1['wref']; + $newWid = (int)$village->wid; + + if($oldWid != $newWid){ + // ia datele ambelor sate + $query2 = mysqli_query($database->dblink, 'SELECT * FROM `'.TB_PREFIX.'fdata` WHERE `vref` = '.$oldWid); + $data2 = mysqli_fetch_assoc($query2); + $query3 = mysqli_query($database->dblink, 'SELECT * FROM `'.TB_PREFIX.'fdata` WHERE `vref` = '.$newWid); + $data3 = mysqli_fetch_assoc($query3); + + // 1. taie resursele vechii capitale la nivel 10 for($i = 1; $i <= 18; ++$i){ if($data2['f'.$i] > 10){ - $query2 = mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'` = 10 WHERE `vref` = '.(int)$data2['vref']); + mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'` = 10 WHERE `vref` = '.$oldWid); } } + // 2. șterge Zidarul din vechea capitală for($i = 19; $i <= 40; ++$i){ if($data2['f'.$i.'t'] == 34){ - $query3 = mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'t` = 0, `f'.$i.'` = 0 WHERE `vref` = '.(int)$data2['vref']); + mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'t` = 0, `f'.$i.'` = 0 WHERE `vref` = '.$oldWid); + } + } + // 3. FIX: șterge clădirile specifice capitalei din NOUA capitală + $capitalOnly = [29,30,38,39,42]; + for($i = 19; $i <= 40; ++$i){ + if(in_array((int)$data3['f'.$i.'t'], $capitalOnly)){ + mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'t` = 0, `f'.$i.'` = 0 WHERE `vref` = '.$newWid); } } - for($i = 19; $i <= 40; ++$i){ - if($data2['f'.$i.'t'] == 29 || $data2['f'.$i.'t'] == 30 || $data2['f'.$i.'t'] == 38 || $data2['f'.$i.'t'] == 39 || $data2['f'.$i.'t'] == 42){ - $query3 = mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'t` = 0, `f'.$i.'` = 0 WHERE `vref` = '.(int)$village->wid); - } - } - - $database->changeCapital((int)$data1['wref'], 0); - $database->changeCapital($village->wid); + $database->changeCapital($oldWid, 0); + $database->changeCapital($newWid); + + // 4. FIX BUG-UL TĂU: recount populație instant + if(!isset($automation)){ + include_once("GameEngine/Automation.php"); + } + $automation->recountPop($oldWid, false); + $automation->recountPop($newWid, false); + header("location: build.php?gid=26"); exit; } @@ -40,37 +60,29 @@ if($_POST and $_GET['action'] == 'change_capital' && !$village->capital){ $error = '
'.LOGIN_PW_ERROR.'
'; $_SESSION['error_p'] = $error; $_SESSION['time_p'] = time(); - echo ''; + echo ''; + exit; } } ?>

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

- +

getTypeLevel(26) > 0) { - include("26_menu.tpl"); - if($village->resarray['f'.$id] >= 10) include ("26_train.tpl"); else echo '
'.PALACE_TRAIN_DESC.'
'; -?> - -capital == 1) { ?>

» '.CHANGE_CAPITAL.'

'; + print '

» '.CHANGE_CAPITAL.'

'; } else { print '

Are you sure, that you want to change your capital?
You can\'t undo this!
For security you must enter your password to confirm:

@@ -81,9 +93,7 @@ if($village->capital == 1) {

'; } } -} -else echo ""; - +} else echo "".PALACE_CONSTRUCTION.""; include("upgrade.tpl"); ?>
\ No newline at end of file diff --git a/Templates/Build/26_2.tpl b/Templates/Build/26_2.tpl index 8927c7d6..e013091c 100644 --- a/Templates/Build/26_2.tpl +++ b/Templates/Build/26_2.tpl @@ -1,27 +1,51 @@ -

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

-

- -

+ +$level = (int)$village->resarray['f'.$id]; +$isNatar = (int)$database->getVillageField($village->wid, 'natar') === 1; -

- - - -getVillageField($village->wid, 'natar') == 0){ ?> - - - - - - - - - -
getVillageField($village->wid, 'cp'); ?> 0
getVSumField($session->uid, 'cp'); ?>

cp; ?> getProfileVillages($session->uid)); echo ${'cp'.$mode}[$total+1]; ?> .

-
+// ia datele o singură dată +$cpVillage = $isNatar ? 0 : (int)$database->getVillageField($village->wid, 'cp'); +$cpTotal = (int)$database->getVSumField($session->uid, 'cp'); +$villages = $database->getProfileVillages($session->uid); +$totalVillages = count($villages); + +// calcul pentru următorul sat - fără variable variables +$cpMode = CP; // 0 = normal, 1 = speed +$cpArrayName = 'cp' . $cpMode; +$cpArray = $GLOBALS[$cpArrayName] ?? []; +$nextCpNeed = $cpArray[$totalVillages + 1] ?? 0; +$currentCp = (int)$session->cp; +?> +
+

+ +

+ + +

+ + + +

+ + + + + + + + + + +
+ +

+ + + . +

+
\ No newline at end of file diff --git a/Templates/Build/26_3.tpl b/Templates/Build/26_3.tpl index a1268d27..88d80dc1 100644 --- a/Templates/Build/26_3.tpl +++ b/Templates/Build/26_3.tpl @@ -1,13 +1,25 @@ -

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

-

- -

+resarray['f'.$id]; +$loyalty = floor((float)$database->getVillageField($village->wid, 'loyalty')); +$loyalty = max(0, min(100, $loyalty)); // siguranță: între 0-100% +?> +
+

+ +

+ + +

- + - getVillageField($village->wid,'loyalty')); ?> .
+

+ + . +

+
\ No newline at end of file diff --git a/Templates/Build/26_4.tpl b/Templates/Build/26_4.tpl index 7b01ec56..7581b169 100644 --- a/Templates/Build/26_4.tpl +++ b/Templates/Build/26_4.tpl @@ -1,55 +1,80 @@ -

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

-

- - - - - - - - - - - - - - - - - -getVillageField($village->wid, 'exp1'); -$slot2 = $database->getVillageField($village->wid, 'exp2'); -$slot3 = $database->getVillageField($village->wid, 'exp3'); +// 26_4.tpl - PALACE / CONQUERED VILLAGES +global $database, $village, $generator; -if($slot1 != 0 || $slot2 != 0 || $slot3 != 0){ - for($i=1; $i <= 3; $i++){ - if (${'slot'.$i}<>0) { - $coor = $database->getCoor(${'slot'.$i}); - $vname = $database->getVillageField(${'slot'.$i},'name'); - $owner = $database->getVillageField(${'slot'.$i},'owner'); - $pop = $database->getVillageField(${'slot'.$i},'pop'); - $vcreated = $database->getVillageField(${'slot'.$i},'created'); - $ownername = $database->getUserField($owner,'username',0); -echo ' - - - - - - - -'; - } - } -} -else{ -echo ''; -} +$level = (int)$village->resarray['f'.$id]; + +// ia toate 3 sloturile o singură dată +$slots = [ + (int)$database->getVillageField($village->wid, 'exp1'), + (int)$database->getVillageField($village->wid, 'exp2'), + (int)$database->getVillageField($village->wid, 'exp3'), +]; +$slots = array_filter($slots); // elimină 0 ?> -
'.$i.'.'.$vname.''.$ownername.''.$pop.'
('.$coor['x'].'
|
'.$coor['y'].')
'.date('d.m.Y',$vcreated).'
'.NONE_CONQUERED_BY_VILLAGE.'

+
+

+ +

+ + +

+ + + + + + + + + + + + + + + + + + getCoor($wid); + $villageData = $database->getVillage($wid); // conține name, owner, pop, created + $ownerName = $database->getUserField($villageData['owner'], 'username', 0); + $mapCheck = $generator->getMapCheck($wid); + ?> + + + + + + + + + + + + + + +
. + + + + + + + + +
(
+
|
+
)
+
+
\ No newline at end of file diff --git a/Templates/Build/26_create.tpl b/Templates/Build/26_create.tpl index a033e521..d2d59b50 100644 --- a/Templates/Build/26_create.tpl +++ b/Templates/Build/26_create.tpl @@ -1,68 +1,97 @@ - - - - - - - - - - - - - - - "; - ?> +$unitId = 20; // colonist +$unitName = $technology->getUnitName($unitId); +$costs = $GLOBALS['u'.$unitId]; // $u20 din config +$maxTrain = $technology->maxUnit($unitId); +$available = (int)($village->unitarray['u'.$unitId]?? 0); +$trainTime = $generator->getTimeFormat(round($costs['time'] / SPEED)); +$trainList = $technology->getTrainingList($unitId); +?> + + + - -
NaamAantalmax
-
- \"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." (Available: ".$village->unitarray['u'.$i].") -
-
\"Lumber\"".${'u'.$i}['wood']."|\"Clay\"".${'u'.$i}['clay']."|\"Iron\"".${'u'.$i}['iron']."|\"Crop\"".${'u'.$i}['crop']."|\"duration\""; - echo $generator->getTimeFormat(round(${'u'.$i}['time']/SPEED)); - //-- If available resources combined are not enough, remove NPC button - //$total_required = (int)(${'r'.$i}['wood'] + ${'r'.$i}['clay'] + ${'r'.$i}['iron'] + ${'r'.$i}['crop']); +// 26_create.tpl - PALACE / TRAIN SETTLERS +global $village, $technology, $generator, $id; - //if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - //echo "|\"NPC"; - //} - echo " -
maxUnit($i)."; return false;\">(".$technology->maxUnit($i).")
-

- -

+ + + + + + + + + + + + + + + +
NaamAantalmax
+
+ <?php echo htmlspecialchars($unitName);?> + + (Available: ) +
+
+ Lumber| + Clay| + Iron| + Crop| + duration +
+
+ + + () +
- getTrainingList(20); - if(count($trainlist) > 0) { - $timer = 2*count($trainlist); - echo " - - - - - - - "; - foreach($trainlist as $train) { - echo " - "; - } - echo "
TrainingDurationFinished
"; - echo "\"".$train['name']."\"".$train['amt']." ".$train['name']."".$generator->getTimeFormat(($train['commence']+($train['eachtime']*$train['amt']))-time()).""; - $timer -= 1; - $time = $generator->procMTime($train['commence']+(1*$train['amt'])); - if($time[0] != "today") { - echo "on ".$time[0]." at"; - } - echo $time[1]." o'clock
The next unit will be finished in ".$generator->getTimeFormat(($train['commence']+$train['eachtime'])-time())."
"; - } - ?> +

+ +

- + + + + + + + + + + + procMTime($totalFinish); + ?> + + + + + + + + + + +
TrainingDurationFinished
+ <?php echo htmlspecialchars($train['name']);?> + + + getTimeFormat($remainingTotal);?> + + o'clock +
+ The next unit will be finished in getTimeFormat($remainingNext);?> +
+ + \ No newline at end of file diff --git a/Templates/Build/26_menu.tpl b/Templates/Build/26_menu.tpl index 9de4eed7..b391769f 100644 --- a/Templates/Build/26_menu.tpl +++ b/Templates/Build/26_menu.tpl @@ -1,7 +1,25 @@ + - > - | > - | > - | > +$current = $_GET['s'] ?? ''; +$menu = [ + '' => TRAIN, + '2' => CULTURE_POINTS, + '3' => LOYALTY, + '4' => EXPANSION, +]; +?> +
+ $label): + if (!$first) echo ' | '; + $first = false; + + $url = 'build.php?id='.(int)$id.($s !== '' ? '&s='.$s : ''); + $selected = ($current === (string)$s) ? ' class="selected"' : ''; +?> + > +
\ No newline at end of file diff --git a/Templates/Build/26_progress.tpl b/Templates/Build/26_progress.tpl index 8b1baf41..b77b76df 100644 --- a/Templates/Build/26_progress.tpl +++ b/Templates/Build/26_progress.tpl @@ -1,34 +1,59 @@ - getTrainingList(4); - if(count($trainlist) > 0) { - echo " - - - - - - - "; - $TrainCount = 0; - foreach($trainlist as $train) { - $TrainCount++; - echo " -
".TRAINING."".DURATION."".FINISHED."
"; - echo "\"".$train['name']."\""; - echo $train['amt']." ".$train['name'].""; - if ($TrainCount == 1 ) { - $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; - } else { - echo $generator->getTimeFormat($train['eachtime']*$train['amt']); - } - echo ""; - $time = $generator->procMTime($train['timestamp']); - if($time[0] != "today") { - echo "on ".$time[0]." at "; - } - echo $time[1]; - } ?> -
- getTrainingList(4); // unit 4 = pentru chief? păstrez ID-ul tău +if (!empty($trainList)): + $trainCount = 0; + $nextFinished = ''; ?> + + + + + + + + + + procMTime((int)$train['timestamp']); + + if ($isFirst) { + $nextFinished = $generator->getTimeFormat(max(0, (int)$train['timestamp2'] - time())); + $timerMain = ++$session->timer; + } + ?> + + + + + + + + + + +
+ <?php echo htmlspecialchars($train['name']);?> + + + + getTimeFormat($remaining);?> + + getTimeFormat($duration);?> + + + +
+ + +
+ \ No newline at end of file diff --git a/Templates/Build/26_train.tpl b/Templates/Build/26_train.tpl index a986e758..f8e480e0 100644 --- a/Templates/Build/26_train.tpl +++ b/Templates/Build/26_train.tpl @@ -1,64 +1,86 @@ getAvailableExpansionTraining(); - - if ($slots['settlers'] + $slots['chiefs'] > 0) { ?> +$slots = $database->getAvailableExpansionTraining(); +$totalSlots = ($slots['settlers'] ?? 0) + ($slots['chiefs'] ?? 0); +if ($totalSlots > 0): ?>
- - + + - - - - - - - - - -tribe - 1) * 10 + 9; $i <= $session->tribe * 10; $i++) { - if ($slots['settlers'] > 0 && $i % 10 == 0 || $slots['chiefs'] > 0 && $i % 10 == 9 && $session->tribe != 4) { - $maxunit = MIN($technology->maxUnit($i), ($i % 10 == 0 ? $slots['settlers'] : $slots['chiefs'])); - -echo " -"; - } - } ?> - - -
-
-\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> -".$technology->getUnitName($i)." (".AVAILABLE.": ".$village->unitarray['u'.$i].")
-
\"Lumber\"".${'u'.$i}['wood']."|\"Clay\"".${'u'.$i}['clay']."|\"Iron\"".${'u'.$i}['iron']."|\"Crop\"".${'u'.$i}['crop']."|\"duration\""; -$dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(${'u'.$i}['time'] * ($bid26[$village->resarray['f'.$id]]['attri'] / 100) / SPEED)); -echo $generator->getTimeFormat($dur); - -//-- If available resources combined are not enough, remove NPC button -$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']); - -if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { -echo "|\"NPC"; - } -echo "
(".$maxunit.")
-

- -

+ + + + + + + + + + tribe - 1) * 10 + 9; + $end = $session->tribe * 10; + + for ($i = $start; $i <= $end; $i++): + $isSettler = ($i % 10 === 0); + $isChief = ($i % 10 === 9 && $session->tribe != 4); + + if (($isSettler && $slots['settlers'] > 0) || ($isChief && $slots['chiefs'] > 0)): + $unitName = $technology->getUnitName($i); + $costs = $GLOBALS['u'.$i]; + $maxByTech = $technology->maxUnit($i); + $slotLimit = $isSettler ? $slots['settlers'] : $slots['chiefs']; + $maxUnit = min($maxByTech, $slotLimit); + $available = (int)($village->unitarray['u'.$i] ?? 0); + + // timp cu bonus palat și artefacte + $baseTime = $costs['time'] * ($bid26[$village->resarray['f'.$id]]['attri'] / 100) / SPEED; + $duration = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round($baseTime)); + + $totalRequired = $costs['wood'] + $costs['clay'] + $costs['iron'] + $costs['crop']; + $canNpc = $session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $totalRequired; + ?> + + + + + + + +
+
+ <?php echo htmlspecialchars($unitName);?> + + (: ) +
+
+ <?php echo LUMBER;?>| + <?php echo CLAY;?>| + <?php echo IRON;?>| + <?php echo CROP;?>| + <?php echo DURATION;?>getTimeFormat($duration);?> + + | + NPC trade + + +
+
+ + + () +
+

+ +

-'.PALACE_TRAIN_DESC.'
'; - - include ("26_progress.tpl"); -?> + +
+ \ No newline at end of file diff --git a/Templates/Build/28.tpl b/Templates/Build/28.tpl index c58e4624..7aba6155 100644 --- a/Templates/Build/28.tpl +++ b/Templates/Build/28.tpl @@ -1,37 +1,34 @@ resarray['f'.$id]; +$current = $level > 0 ? (int)$bid28[$level]['attri'] : 100; ?> -
-

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

-

+
+ +

+

- - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id] + 1 + $loopsame + $doublebuild + $master; - if($next<=20){ - ?> - - - - - - + + + + + + isMax($village->resarray['f'.$id.'t'], $id)): + $next = $level + 1 + $loopsame + $doublebuild + $master; + $next = $next > 20 ? 20 : $next; ?> - -
resarray['f'.$id] > 0 ? $bid28[$village->resarray['f'.$id]]['attri'] : 100; ?>
: 20:
- -

+ : + + + + + + +
\ No newline at end of file diff --git a/Templates/Build/29.tpl b/Templates/Build/29.tpl index 2fdb70c6..b3ebddf1 100644 --- a/Templates/Build/29.tpl +++ b/Templates/Build/29.tpl @@ -1,59 +1,51 @@ -
-

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

-

+getTypeLevel(29) > 0) { ?> -
- - - - - - - - -
-

- ".TRAINING_COMMENCE_GREATBARRACKS."
\n"; - } - $trainlist = $technology->getTrainingList(5); - if(count($trainlist) > 0) { - echo " - - - - - - - "; - $TrainCount = 0; - foreach($trainlist as $train) { - $TrainCount++; - echo " -
".TRAINING."".DURATION."".FINISHED."
"; - echo "\"".$train['name']."\""; - echo $train['amt']." ".$train['name'].""; - if ($TrainCount == 1 ) { - $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; - } else { - echo $generator->getTimeFormat($train['eachtime']*$train['amt']); - } - echo ""; - $time = $generator->procMTime($train['timestamp']); - if($time[0] != "today") { - echo "on ".$time[0]." at "; - } - echo $time[1]; - } ?> -
- resarray['f'.$id]; ?> -

\ No newline at end of file +
+ +

+

+ + getTypeLevel(29) > 0):?> +
+ + + + + +
+

+
+ +
+ + + getTrainingList(5); if (count($trainlist) > 0): $TrainCount = 0; $NextFinished = '';?> + + + + + + + + + + + + +
<?php echo $train['name'];?> + getTimeFormat($train['timestamp2']-time());?> + getTimeFormat($train['timestamp']-time());?> + + getTimeFormat($train['eachtime']*$train['amt']);?> + + procMTime($train['timestamp']); if($time[0]!="today") echo "on ".$time[0]." at "; echo $time[1];?>
+ + + +
\ No newline at end of file diff --git a/Templates/Build/29_train.tpl b/Templates/Build/29_train.tpl index 9d0b40f0..4208082b 100644 --- a/Templates/Build/29_train.tpl +++ b/Templates/Build/29_train.tpl @@ -1,27 +1,48 @@ tribe-1)*10+1;$i<=($session->tribe-1)*10+4;$i++) { - if ($i <> 4 && $i <> 23 && $i <> 24 && ($technology->getTech($i) || $i%10 == 1)) { - -echo " -
-\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." (".AVAILABLE.": ".$village->unitarray['u'.$i].") -
-
-\"Wood\"".(${'u'.$i}['wood']*3)."|\"Clay\"".(${'u'.$i}['clay']*3)."|\"Iron\"".(${'u'.$i}['iron']*3)."|\"Crop\"".(${'u'.$i}['crop']*3)."|\"Crop".${'u'.$i}['pop']."|\"Duration\""; -$dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(${'u'.$i}['time'] * ($bid29[$village->resarray['f'.$id]]['attri'] / 100) / SPEED)); -echo $generator->getTimeFormat($dur); +// 29_train.tpl - GREATBARRACKS TRAIN +global $session, $technology, $village, $database, $building, $bid29, $generator, $id; -//-- If available resources combined are not enough, remove NPC button -$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']); +$start = ($session->tribe - 1) * 10 + 1; +$end = ($session->tribe - 1) * 10 + 4; +$level = (int)$village->resarray['f'.$id]; -if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|maxUnitPlus($i))."&r2=".((${'u'.$i}['clay'])*$technology->maxUnitPlus($i))."&r3=".((${'u'.$i}['iron'])*$technology->maxUnitPlus($i))."&r4=".((${'u'.$i}['crop'])*$technology->maxUnitPlus($i))."\" title=\"NPC trade\">\"NPC"; - } -echo "
- - -maxUnit($i,true)."; return false;\">(".$technology->maxUnit($i,true).")"; - } - } +for ($i = $start; $i <= $end; $i++): + if ($i == 4 || $i == 23 || $i == 24) continue; + if (!($technology->getTech($i) || $i % 10 == 1)) continue; + + $unit = ${'u'.$i}; + $costWood = (int)$unit['wood'] * 3; + $costClay = (int)$unit['clay'] * 3; + $costIron = (int)$unit['iron'] * 3; + $costCrop = (int)$unit['crop'] * 3; + $pop = (int)$unit['pop']; + $available = (int)$village->unitarray['u'.$i]; + $max = $technology->maxUnit($i, true); + $maxPlus = $technology->maxUnitPlus($i); + $time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round($unit['time'] * ($bid29[$level]['attri'] / 100) / SPEED)); + $totalRequired = (int)($unit['wood'] + $unit['clay'] + $unit['iron'] + $unit['crop']); + $showNpc = $session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $totalRequired; ?> + + +
+ <?php echo $technology->getUnitName($i);?> + getUnitName($i);?> + (: ) +
+
+ | + | + | + | + | + getTimeFormat($time);?> + + |NPC trade + +
+ + + () + + \ No newline at end of file diff --git a/Templates/Build/3.tpl b/Templates/Build/3.tpl index 82484d71..5c78523b 100644 --- a/Templates/Build/3.tpl +++ b/Templates/Build/3.tpl @@ -1,56 +1,48 @@ resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentProd = $bid3[$currentLevel]['prod'] * SPEED; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = ($village->capital == 1) ? 20 : 10; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextProd = $bid3[$nextLevel]['prod'] * SPEED; ?> -
-

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

-

+
+ +

+ + +

+

- - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($village->capital == 1) { - if($next<=20){ - ?> - - - - - - - - - - - - - - - - - - - - -
resarray['f'.$id]]['prod']* SPEED; ?> per hour
:
:
:
:
+ + + + + -

+ + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/30.tpl b/Templates/Build/30.tpl index 54b9b5db..2da3810a 100644 --- a/Templates/Build/30.tpl +++ b/Templates/Build/30.tpl @@ -1,59 +1,51 @@ -
-

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

-


+getTypeLevel(30) > 0) { ?> -
- - - - - - - - -
-

- ".TRAINING_COMMENCE_GREATSTABLE."
\n"; - } - $trainlist = $technology->getTrainingList(6); - if(count($trainlist) > 0) { - echo " - - - - - - - "; - $TrainCount = 0; - foreach($trainlist as $train) { - $TrainCount++; - echo " -
".TRAINING."".DURATION."".FINISHED."
"; - echo "\"".$train['name']."\""; - echo $train['amt']." ".$train['name'].""; - if ($TrainCount == 1 ) { - $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; - } else { - echo $generator->getTimeFormat($train['eachtime']*$train['amt']); - } - echo ""; - $time = $generator->procMTime($train['timestamp']); - if($time[0] != "today") { - echo "on ".$time[0]." at "; - } - echo $time[1]; - } ?> -
- resarray['f'.$id]; ?> -

\ No newline at end of file +
+ +

+


+ + getTypeLevel(30) > 0):?> +
+ + + + + +
+

+
+ +
+ + + getTrainingList(6); if (count($trainlist) > 0): $TrainCount = 0; $NextFinished = '';?> + + + + + + + + + + + + +
<?php echo $train['name'];?> + getTimeFormat($train['timestamp2']-time());?> + getTimeFormat($train['timestamp']-time());?> + + getTimeFormat($train['eachtime']*$train['amt']);?> + + procMTime($train['timestamp']); if($time[0]!="today") echo "on ".$time[0]." at "; echo $time[1];?>
+ + + +
\ No newline at end of file diff --git a/Templates/Build/30_train.tpl b/Templates/Build/30_train.tpl index afd7d0e6..a7866a53 100644 --- a/Templates/Build/30_train.tpl +++ b/Templates/Build/30_train.tpl @@ -1,31 +1,57 @@ tribe - 1) * 10 + 3; +$end = ($session->tribe - 1) * 10 + 6; +$level = (int)$village->resarray['f'.$id]; +$horseDrinking = $building->getTypeLevel(41); $success = 0; - for ($i=($session->tribe-1)*10+3;$i<=($session->tribe-1)*10+6;$i++) { - if ($i <> 3 && $i <> 13 && $i <> 14 && $technology->getTech($i)) { - $success ++; -echo " -
-\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." (".AVAILABLE.": ".$village->unitarray['u'.$i].") -
-
-\"Wood\"".(${'u'.$i}['wood']*3)."|\"Clay\"".(${'u'.$i}['clay']*3)."|\"Iron\"".(${'u'.$i}['iron']*3)."|\"Crop\"".(${'u'.$i}['crop']*3)."|\"Crop".(${'u'.$i}['pop']-($building->getTypeLevel(41)>=1?1:0))."|\"Duration\""; -$dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(${'u'.$i}['time'] * ($bid30[$village->resarray['f'.$id]]['attri'] * ($building->getTypeLevel(41)>=1?(1/$bid41[$building->getTypeLevel(41)]['attri']):1) / 100) / SPEED)); -echo $generator->getTimeFormat($dur); -//-- If available resources combined are not enough, remove NPC button -$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']); +for ($i = $start; $i <= $end; $i++): + if ($i == 3 || $i == 13 || $i == 14) continue; + if (!$technology->getTech($i)) continue; + $success++; -if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|maxUnitPlus($i))."&r2=".((${'u'.$i}['clay'])*$technology->maxUnitPlus($i))."&r3=".((${'u'.$i}['iron'])*$technology->maxUnitPlus($i))."&r4=".((${'u'.$i}['crop'])*$technology->maxUnitPlus($i))."\" title=\"NPC trade\">\"NPC"; - } -echo "
- - -maxUnit($i,true)."; return false;\">(".$technology->maxUnit($i,true).")"; - } - } -if($success == 0) { - echo "
".AVAILABLE_ACADEMY."
"; -} + $unit = ${'u'.$i}; + $costWood = (int)$unit['wood'] * 3; + $costClay = (int)$unit['clay'] * 3; + $costIron = (int)$unit['iron'] * 3; + $costCrop = (int)$unit['crop'] * 3; + $pop = (int)$unit['pop'] - ($horseDrinking >= 1 ? 1 : 0); + $available = (int)$village->unitarray['u'.$i]; + $max = $technology->maxUnit($i, true); + $maxPlus = $technology->maxUnitPlus($i); + + $speedMod = $bid30[$level]['attri'] / 100; + if ($horseDrinking >= 1) $speedMod *= (1 / $bid41[$horseDrinking]['attri']); + $time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round($unit['time'] * $speedMod / SPEED)); + + $totalRequired = (int)($unit['wood'] + $unit['clay'] + $unit['iron'] + $unit['crop']); + $showNpc = $session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $totalRequired; ?> + + +
+ <?php echo $technology->getUnitName($i);?> + getUnitName($i);?> + (: ) +
+
+ | + | + | + | + | + getTimeFormat($time);?> + + |NPC trade + +
+ + + () + + +
+ \ No newline at end of file diff --git a/Templates/Build/31.tpl b/Templates/Build/31.tpl index 08aa4c9a..2807c942 100644 --- a/Templates/Build/31.tpl +++ b/Templates/Build/31.tpl @@ -1,35 +1,31 @@ resarray['f'.$id]; +$current = $level > 0 ? (int)$bid31[$level]['attri'] : 0; ?>
-

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

-

+

+

- - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id] + 1 + $loopsame + $doublebuild + $master; - if($next <= 20){ +
resarray['f'.$id] > 0 ? $bid31[$village->resarray['f'.$id]]['attri'] : 0; ?>
+ + + + + isMax($village->resarray['f'.$id.'t'], $id)): + $next = $level + 1 + $loopsame + $doublebuild + $master; + $next = $next > 20 ? 20 : $next; ?> - + + + + + +
:
:
- - - 20: - - - - -

-
\ No newline at end of file + +
\ No newline at end of file diff --git a/Templates/Build/32.tpl b/Templates/Build/32.tpl index 653c981f..a07c6970 100644 --- a/Templates/Build/32.tpl +++ b/Templates/Build/32.tpl @@ -1,35 +1,31 @@ resarray['f'.$id]; +$current = $level > 0 ? (int)$bid32[$level]['attri'] : 0; ?>
-

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

-

+

+

- - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id] + 1 + $loopsame + $doublebuild + $master; - if($next <= 20){ +
resarray['f'.$id] > 0 ? $bid32[$village->resarray['f'.$id]]['attri'] : 0; ?>
+ + + + + isMax($village->resarray['f'.$id.'t'], $id)): + $next = $level + 1 + $loopsame + $doublebuild + $master; + $next = $next > 20 ? 20 : $next; ?> - + + + + + +
:
:
- - - 20: - - - - -

-
\ No newline at end of file + +
\ No newline at end of file diff --git a/Templates/Build/33.tpl b/Templates/Build/33.tpl index 13c7dce3..a9963fdb 100644 --- a/Templates/Build/33.tpl +++ b/Templates/Build/33.tpl @@ -1,35 +1,31 @@ resarray['f'.$id]; +$current = $level > 0 ? (int)$bid33[$level]['attri'] : 0; ?>
-

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

-

+

+

- - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id] + 1 + $loopsame + $doublebuild + $master; - if($next <= 20){ +
resarray['f'.$id] > 0 ? $bid33[$village->resarray['f'.$id]]['attri'] : 0; ?>
+ + + + + isMax($village->resarray['f'.$id.'t'], $id)): + $next = $level + 1 + $loopsame + $doublebuild + $master; + $next = $next > 20 ? 20 : $next; ?> - + + + + + +
:
:
- - - 20: - - - - -

-
\ No newline at end of file + +
\ No newline at end of file diff --git a/Templates/Build/34.tpl b/Templates/Build/34.tpl index b53a6c2c..67c49e41 100644 --- a/Templates/Build/34.tpl +++ b/Templates/Build/34.tpl @@ -1,4 +1,7 @@
-

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

-

- - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id] + 1 + $loopsame + $doublebuild + $master; - if($next <= 10){ - ?> - - - - - - - -
resarray['f'.$id] > 0 ? $bid35[$village->resarray['f'.$id]]['attri'] : 0; ?>
: 10:
-resarray['f'.$id]; +$current = $level > 0 ? (int)$bid35[$level]['attri'] : 0; ?> -

\ No newline at end of file +
+ +

+

+ + + + + + + isMax($village->resarray['f'.$id.'t'], $id)): + $next = $level + 1 + $loopsame + $doublebuild + $master; + $next = $next > 10 ? 10 : $next; + ?> + + + + + +
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/36.tpl b/Templates/Build/36.tpl index 48348d4d..829c71a5 100644 --- a/Templates/Build/36.tpl +++ b/Templates/Build/36.tpl @@ -1,135 +1,110 @@ resarray['f'.$id]; +$currentCap = $level > 0? (int)$bid36[$level]['attri'] * TRAPPER_CAPACITY : 0; ?> -

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

-

- -

+
+

+

+ + +

- - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next<=20){ - ?> - - - - - - +
resarray['f'.$id]]['attri'] * TRAPPER_CAPACITY; ?>
: 20:
+ + + + + isMax($village->resarray['f'.$id.'t'], $id)): + $next = $level + 1 + $loopsame + $doublebuild + $master; + $next = $next > 20? 20 : $next; + ?> + + + + + +
:
- - -

unitarray['u99']; ?> , unitarray['u99o']; ?>

-getTypeLevel(36) > 0) { ?> -
- - - - +

unitarray['u99'];?> , unitarray['u99o'];?>

- - - - - - - + getTypeLevel(36) > 0): + $trainlist = $technology->getTrainingList(8); + $train_amt = 0; + foreach ($trainlist as $t) $train_amt += (int)$t['amt']; - - - getTrainingList(8); - foreach($trainlist as $train) $train_amt += $train['amt']; - - $max = $technology->maxUnit(99, false); - $max1 = 0; - for($i = 19; $i < 41; $i++){ - if($village->resarray['f'.$i.'t'] == 36){ - $max1 += $bid36[$village->resarray['f'.$i]]['attri'] * TRAPPER_CAPACITY; - } - } + $time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(($bid19[$level]['attri'] / 100) * ${'u99'}['time'] / SPEED)); + ?> + + + +
-
Trap (: unitarray['u99']; ?>) -
-
- Lumber20|Clay30|Iron10|Crop20|Crop consumption0|Duration - getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(($bid19[$village->resarray['f'.$id]]['attri'] / 100) * ${'u99'}['time'] / SPEED))); ?> - + $max = $technology->maxUnit(99, false); + $max1 = 0; + for ($i = 19; $i < 41; $i++) { + if ((int)$village->resarray['f'.$i.'t'] == 36) { + $max1 += (int)$bid36[(int)$village->resarray['f'.$i]]['attri'] * TRAPPER_CAPACITY; + } + } + $max = min($max, $max1 - ((int)$village->unitarray['u99'] + $train_amt)); + if ($max < 0) $max = 0; -
-
+ + + + + + + + +
+
+ Trap + + (: unitarray['u99'];?>) +
+
+ 20| + 30| + 10| + 20| + 0| + getTimeFormat($time);?> +
+
()
+

+
+ +
+ - if (!isset($train_amt)) $train_amt = 0; - - if($max > $max1 - ($village->unitarray['u99'] + $train_amt)){ - $max = $max1 - ($village->unitarray['u99'] + $train_amt); - } - - if($max < 0) $max = 0; - ?> - - () - - - -

- ".TRAINING_COMMENCE_TRAPPER."
\n"; - } - if(!empty($trainlist)) { - echo " - - - - - - - "; - $TrainCount = 0; - foreach($trainlist as $train) { - $TrainCount++; - echo " -
".TRAINING."".DURATION."".FINISHED."
"; - echo "\"".U99."\""; - echo $train['amt']." ".U99.""; - if ($TrainCount == 1) { - $NextFinished = $generator->getTimeFormat(($train['timestamp'] - time()) - ($train['amt'] - 1) * $train['eachtime']); - echo "".$generator->getTimeFormat($train['timestamp'] - time()).""; - } - else echo $generator->getTimeFormat($train['eachtime'] * $train['amt']); - - echo ""; - $time = $generator->procMTime($train['timestamp']); - if($time[0] != "today") echo "on ".$time[0]." at "; - echo $time[1]; - } ?> -
- -

\ No newline at end of file + + + + + + + + + + + + + +
<?php echo U99;?> + getTimeFormat(($train['timestamp'] - time()) - ($train['amt'] - 1) * $train['eachtime']);?> + getTimeFormat($train['timestamp'] - time());?> + + getTimeFormat($train['eachtime'] * $train['amt']);?> + + procMTime($train['timestamp']); if($time[0]!="today") echo "on ".$time[0]." at "; echo $time[1];?>
+ + + +
\ No newline at end of file diff --git a/Templates/Build/38.tpl b/Templates/Build/38.tpl index 324bda95..51165628 100644 --- a/Templates/Build/38.tpl +++ b/Templates/Build/38.tpl @@ -1,38 +1,34 @@ resarray['f'.$id]; +$current = $level > 0 ? (int)$bid38[$level]['attri'] * STORAGE_MULTIPLIER : 0; ?> -
-

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

-

+
+ +

+

- - - - - - - -isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next<=20){ +
resarray['f'.$id]]['attri']*STORAGE_MULTIPLIER; ?>
+ + + + + isMax($village->resarray['f'.$id.'t'], $id)): + $next = $level + 1 + $loopsame + $doublebuild + $master; + $next = $next > 20 ? 20 : $next; ?> - - - - - - - -
: 20:
- -

+ + : + + + + + + +
\ No newline at end of file diff --git a/Templates/Build/39.tpl b/Templates/Build/39.tpl index cd8e06be..d26bc2ce 100644 --- a/Templates/Build/39.tpl +++ b/Templates/Build/39.tpl @@ -1,39 +1,34 @@ resarray['f'.$id]; +$current = $level > 0 ? (int)$bid39[$level]['attri'] * STORAGE_MULTIPLIER : 0; ?> -
-

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

-

+
+ +

+

- - - - - - - - -isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next<=20){ +
resarray['f'.$id]]['attri']*STORAGE_MULTIPLIER; ?>
+ + + + + isMax($village->resarray['f'.$id.'t'], $id)): + $next = $level + 1 + $loopsame + $doublebuild + $master; + $next = $next > 20 ? 20 : $next; ?> - - - - - - - -
: 20:
- -

+ + : + + + + + + +
\ No newline at end of file diff --git a/Templates/Build/4.tpl b/Templates/Build/4.tpl index 2ac8d593..913c2358 100644 --- a/Templates/Build/4.tpl +++ b/Templates/Build/4.tpl @@ -1,56 +1,48 @@ resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentProd = $bid4[$currentLevel]['prod'] * SPEED; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = ($village->capital == 1) ? 20 : 10; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextProd = $bid4[$nextLevel]['prod'] * SPEED; ?> -
-

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

-

+
+ - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($village->capital == 1) { - if($next<=20){ - ?> - - - - - - - - - - - - - - - - - - - - - -
resarray['f'.$id]]['prod']* SPEED; ?>
:
:
:
:
+

+ + +

-

+

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/41.tpl b/Templates/Build/41.tpl index 6232e02c..45233b9f 100644 --- a/Templates/Build/41.tpl +++ b/Templates/Build/41.tpl @@ -1,32 +1,35 @@ -
-

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

-

- - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id] + 1 + $loopsame + $doublebuild + $master; - if($next <= 20){ - ?> - - - - - - - -
resarray['f'.$id] > 0 ? $bid41[$village->resarray['f'.$id]]['attri'] * 100 - 100 : 0; ?>
: 20:
-resarray['f'.$id]; +$current = $level > 0 ? (int)($bid41[$level]['attri'] * 100 - 100) : 0; ?> -

\ No newline at end of file +
+ +

+

+ + + + + + + isMax($village->resarray['f'.$id.'t'], $id)): + $next = $level + 1 + $loopsame + $doublebuild + $master; + $next = $next > 20 ? 20 : $next; + $nextBonus = (int)($bid41[$next]['attri'] * 100 - 100); + ?> + + + + + +
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/42.tpl b/Templates/Build/42.tpl index 879d2cb3..6826e4fb 100644 --- a/Templates/Build/42.tpl +++ b/Templates/Build/42.tpl @@ -1,59 +1,58 @@ -
-

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

-

+getTypeLevel(42) > 0) { ?> -
- - - - - - - - -
-

- ".TRAINING_COMMENCE_GREATWORKSHOP."
\n"; - } - $trainlist = $technology->getTrainingList(7); - if(count($trainlist) > 0) { - echo " - - - - - - - "; - $TrainCount = 0; - foreach($trainlist as $train) { - $TrainCount++; - echo " -
".TRAINING."".DURATION."".FINISHED."
"; - echo "\"".$train['name']."\""; - echo $train['amt']." ".$train['name'].""; - if ($TrainCount == 1 ) { - $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; - } else { - echo $generator->getTimeFormat($train['eachtime']*$train['amt']); - } - echo ""; - $time = $generator->procMTime($train['timestamp']); - if($time[0] != "today") { - echo "on ".$time[0]." at "; - } - echo $time[1]; - } ?> -
- resarray['f'.$id]; ?> -

\ No newline at end of file +
+ +

+

+ + getTypeLevel(42) > 0):?> +
+ + + + + + + +
+

+
+ +
+ + + getTrainingList(7); + if (!empty($trainlist)): $TrainCount = 0; $NextFinished = ''; + ?> + + + + + + + + + + + + +
<?php echo $train['name'];?> + getTimeFormat($train['timestamp2'] - time());?> + getTimeFormat($train['timestamp'] - time());?> + + getTimeFormat($train['eachtime'] * $train['amt']);?> + + procMTime($train['timestamp']); if($time[0]!="today") echo "on ".$time[0]." at "; echo $time[1];?>
+ + + +
\ No newline at end of file diff --git a/Templates/Build/42_train.tpl b/Templates/Build/42_train.tpl index f9f0a4f6..d182d121 100644 --- a/Templates/Build/42_train.tpl +++ b/Templates/Build/42_train.tpl @@ -1,31 +1,61 @@ tribe-1)*10+7;$i<=($session->tribe-1)*10+8;$i++) { - if ($technology->getTech($i)) { - $success++; -echo " -
-\"".$technology-getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" /> - ".$technology->getUnitName($i)." (".AVAILABLE.": ".$village->unitarray['u'.$i].") -
-
-\"Wood\"".(${'u'.$i}['wood']*3)."|\"Clay\"".(${'u'.$i}['clay']*3)."|\"Iron\"".(${'u'.$i}['iron']*3)."|\"Crop\"".(${'u'.$i}['crop']*3)."|\"Crop".${'u'.$i}['pop']."|\"Duration\""; -$dur = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(${'u'.$i}['time'] * ($bid42[$village->resarray['f'.$id]]['attri'] / 100) / SPEED)); -echo $generator->getTimeFormat($dur); +$start = ($session->tribe - 1) * 10 + 7; +$end = $start + 1; // ram + catapult -//-- If available resources combined are not enough, remove NPC button -$total_required = (int)(${'u'.$i}['wood'] + ${'u'.$i}['clay'] + ${'u'.$i}['iron'] + ${'u'.$i}['crop']); +for ($i = $start; $i <= $end; $i++) { + if (!$technology->getTech($i)) continue; + $success++; -if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|maxUnitPlus($i))."&r2=".((${'u'.$i}['clay'])*$technology->maxUnitPlus($i))."&r3=".((${'u'.$i}['iron'])*$technology->maxUnitPlus($i))."&r4=".((${'u'.$i}['crop'])*$technology->maxUnitPlus($i))."\" title=\"NPC trade\">\"NPC"; - } -echo "
- - -maxUnit($i,true)."; return false;\">(".$technology->maxUnit($i,true).")"; - } - } -if($success == 0) { - echo "
".AVAILABLE_ACADEMY."
"; + $unit = ${'u'.$i}; + $name = $technology->getUnitName($i); + $wood = $unit['wood'] * 3; + $clay = $unit['clay'] * 3; + $iron = $unit['iron'] * 3; + $crop = $unit['crop'] * 3; + $pop = $unit['pop']; + + $dur = $database->getArtifactsValueInfluence( + $session->uid, $village->wid, 5, + round($unit['time'] * ($bid42[$village->resarray['f'.$id]]['attri'] / 100) / SPEED) + ); + $max = $technology->maxUnit($i, true); +?> + + +
+ <?php echo $name;?> + + (: unitarray['u'.$i];?>) +
+
+ | + | + | + | + | + getTimeFormat($dur);?> + userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required): + $r1 = $unit['wood'] * $technology->maxUnitPlus($i); + $r2 = $unit['clay'] * $technology->maxUnitPlus($i); + $r3 = $unit['iron'] * $technology->maxUnitPlus($i); + $r4 = $unit['crop'] * $technology->maxUnitPlus($i); + ?> + |NPC trade + +
+ + + () + + \ No newline at end of file + +if ($success == 0): ?> +
+ \ No newline at end of file diff --git a/Templates/Build/5.tpl b/Templates/Build/5.tpl index 9a9e1c57..f18dc838 100644 --- a/Templates/Build/5.tpl +++ b/Templates/Build/5.tpl @@ -1,37 +1,47 @@ -
-

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

-

+// SAWMILL - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next<=5){ - ?> - - - - - - - -
resarray['f'.$id] > 0 ? $bid5[$village->resarray['f'.$id]]['attri'] : 0; ?>
: 5:
-resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentBonus = $currentLevel > 0 ? $bid5[$currentLevel]['attri'] : 0; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = 5; // sawmill e max 5 + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextBonus = $bid5[$nextLevel]['attri']; ?> -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/6.tpl b/Templates/Build/6.tpl index a73b728d..c1414c93 100644 --- a/Templates/Build/6.tpl +++ b/Templates/Build/6.tpl @@ -1,37 +1,47 @@ -
-

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

-

+// BRICKYARD - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next <= 5){ - ?> - - - - - - - -
resarray['f'.$id] > 0 ? $bid6[$village->resarray['f'.$id]]['attri'] : 0; ?>
: 5:
-resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentBonus = $currentLevel > 0 ? $bid6[$currentLevel]['attri'] : 0; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = 5; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextBonus = $bid6[$nextLevel]['attri']; ?> -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/7.tpl b/Templates/Build/7.tpl index 604d968c..a3336494 100644 --- a/Templates/Build/7.tpl +++ b/Templates/Build/7.tpl @@ -1,37 +1,47 @@ -
-

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

-

+// IRONFOUNDRY - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next<=5){ - ?> - - - - - - - -
resarray['f'.$id] > 0 ? $bid7[$village->resarray['f'.$id]]['attri'] : 0; ?>
: 5:
-resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentBonus = $currentLevel > 0 ? $bid7[$currentLevel]['attri'] : 0; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = 5; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextBonus = $bid7[$nextLevel]['attri']; ?> -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/8.tpl b/Templates/Build/8.tpl index a71d0ba7..5db9281e 100644 --- a/Templates/Build/8.tpl +++ b/Templates/Build/8.tpl @@ -1,37 +1,47 @@ -
-

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

-

+// GRAINMILL - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next <= 5){ - ?> - - - - - - - -
resarray['f'.$id] > 0 ? $bid8[$village->resarray['f'.$id]]['attri'] : 0; ?>
: 5:
-resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentBonus = $currentLevel > 0 ? $bid8[$currentLevel]['attri'] : 0; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = 5; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextBonus = $bid8[$nextLevel]['attri']; ?> -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/9.tpl b/Templates/Build/9.tpl index 329d01ce..701f60ac 100644 --- a/Templates/Build/9.tpl +++ b/Templates/Build/9.tpl @@ -1,37 +1,47 @@ -
-

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

-

+// BAKERY - - - - - - - isMax($village->resarray['f'.$id.'t'],$id)) { - $next = $village->resarray['f'.$id]+1+$loopsame+$doublebuild+$master; - if($next <= 5){ - ?> - - - - - - - -
resarray['f'.$id] > 0 ? $bid9[$village->resarray['f'.$id]]['attri'] : 0; ?>
: 5:
-resarray[$field] ?? 0); +$buildingType = $village->resarray[$field . 't'] ?? 0; + +$currentBonus = $currentLevel > 0 ? $bid9[$currentLevel]['attri'] : 0; + +$isMax = $building->isMax($buildingType, $id); +$maxLevel = 5; + +$nextLevelRaw = $currentLevel + 1 + $loopsame + $doublebuild + $master; +$nextLevel = min($nextLevelRaw, $maxLevel); +$nextBonus = $bid9[$nextLevel]['attri']; ?> -

+
+ + +

+ + +

+ +

+ + + + + + + + + + + + + +
:
:
+ + +
\ No newline at end of file diff --git a/Templates/Build/avaliable/availupgrade.tpl b/Templates/Build/avaliable/availupgrade.tpl index b299dee1..b50010a0 100644 --- a/Templates/Build/avaliable/availupgrade.tpl +++ b/Templates/Build/avaliable/availupgrade.tpl @@ -1,89 +1,84 @@ -canBuild($id,$bid); -$loopsame = ($building->isCurrent($id) || $building->isLoop($id))?1:0; -$doublebuild = ($building->isCurrent($id) && $building->isLoop($id))?1:0; +canBuild($id, $bid); $uprequire = $building->resourceRequired($id, $bid); + +// --- pregătim o singură dată HTML-ul pentru Master Builder --- +$masterBuilderHtml = ''; +if ($session->goldclub == 1) { + $canUse = ($session->gold >= 1 && $village->master == 0); + $checker = htmlspecialchars((string)$session->checker, ENT_QUOTES, 'UTF-8'); + $url = "dorf2.php?master={$bid}&id={$id}&c={$checker}"; + $label = htmlspecialchars(CONSTRUCTING_MASTER_BUILDER, ENT_QUOTES, 'UTF-8'); + $goldIcon = htmlspecialchars(GP_LOCATE. 'img/a/gold_g.gif', ENT_QUOTES, 'UTF-8'); + $cost = '(costs: Gold1)'; + + $masterBuilderHtml = $canUse + ? '
'.$label.' '.$cost + : '
'.$label.' '.$cost; +} + +$totalRequired = (int)($uprequire['wood'] + $uprequire['clay'] + $uprequire['iron'] + $uprequire['crop']); +$canNpc = ($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $totalRequired); ?> - Lumber | Clay | Iron | Crop | Crop consumption | durationgetTimeFormat($uprequire['time']); - - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)($uprequire['wood'] + $uprequire['clay'] + $uprequire['iron'] + $uprequire['crop']); - - if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } ?> - - - -" . WORKERS_ALREADY_WORK_WAITING . ""; - if($session->goldclub == 1){ -?>
-gold >= 1 && $village->master == 0){ - echo "checker\">" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(costs: Gold1)'; - }else{ - echo "" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(costs: Gold1)'; - } - } - } - else if($bindicator == 3) { - echo "The workers are already at work. (waiting loop)"; - if($session->goldclub == 1){ -?>
-gold >= 1 && $village->master == 0){ - echo "checker\">" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(costs: Gold1)'; - }else{ - echo "" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(costs: Gold1)'; - } - } - } - else if($bindicator == 4) { - echo "Not enough food. Expand cropland."; - } - else if($bindicator == 5) { - echo "Upgrade Warehouse."; - } - else if($bindicator == 6) { - echo "Upgrade Granary."; - } - else if($bindicator == 7) { - $neededtime = $building->calculateAvaliable($id,$bid); - echo "" .ENOUGH_RESOURCES . " " .$neededtime[0]." at ".$neededtime[1].""; - if($session->goldclub == 1){ -?>
-gold >= 1 && $village->master == 0){ - echo "checker\">" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(costs: Gold1)'; - }else{ - echo "" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(costs: Gold1)'; - } - } - } - else if($bindicator == 8) { - if($session->access!=BANNED){ - echo "checker."\">". CONSTRUCT_BUILD.""; - }else{ - echo "". CONSTRUCT_BUILD.""; - } - } - else if($bindicator == 9) { - if($session->access!=BANNED){ - echo "checker."\">Construct building. (waiting loop)"; - }else{ - echo "checker."\">Construct building. (waiting loop)"; - } - } - ?> + Lumber | + Clay | + Iron | + Crop | + Crop consumption | + durationgetTimeFormat($uprequire['time']), ENT_QUOTES, 'UTF-8')?> + + | + NPC trade + + + + + +'.htmlspecialchars(WORKERS_ALREADY_WORK_WAITING, ENT_QUOTES, 'UTF-8').''; + echo $masterBuilderHtml; + break; + case 3: + echo 'The workers are already at work. (waiting loop)'; + echo $masterBuilderHtml; + break; + case 4: + echo 'Not enough food. Expand cropland.'; + break; + case 5: + echo 'Upgrade Warehouse.'; + break; + case 6: + echo 'Upgrade Granary.'; + break; + case 7: + $needed = $building->calculateAvaliable($id, $bid); + echo ''.htmlspecialchars(ENOUGH_RESOURCES, ENT_QUOTES, 'UTF-8').' '.htmlspecialchars((string)$needed[0], ENT_QUOTES, 'UTF-8').' at '.htmlspecialchars((string)$needed[1], ENT_QUOTES, 'UTF-8').''; + echo $masterBuilderHtml; + break; + case 8: + $url = ($session->access!= BANNED) + ? "dorf2.php?a={$bid}&id={$id}&c={$session->checker}" + : "banned.php"; + echo ''.htmlspecialchars(CONSTRUCT_BUILD, ENT_QUOTES, 'UTF-8').''; + break; + case 9: + $url = ($session->access!= BANNED) + ? "dorf2.php?a={$bid}&id={$id}&c={$session->checker}" + : "banned.php?a={$bid}&id={$id}&c={$session->checker}"; + echo 'Construct building. (waiting loop)'; + break; +} +?> + \ No newline at end of file diff --git a/Templates/Build/next.tpl b/Templates/Build/next.tpl index 487ffea5..9b31db38 100644 --- a/Templates/Build/next.tpl +++ b/Templates/Build/next.tpl @@ -1,5 +1,8 @@ isCurrent($id) || $building->isLoop($id))?1:0; - $doublebuild = ($building->isCurrent($id) && $building->isLoop($id))?1:0; - $master = count($database->getMasterJobsByField($village->wid,$id)); +// next.tpl - calculează offset-ul pentru nivelul următor +global $building, $database, $village, $id; + +$loopsame = ($building->isCurrent($id) || $building->isLoop($id)) ? 1 : 0; +$doublebuild = ($building->isCurrent($id) && $building->isLoop($id)) ? 1 : 0; +$master = count($database->getMasterJobsByField($village->wid, $id)); ?> \ No newline at end of file diff --git a/Templates/Build/upgrade.tpl b/Templates/Build/upgrade.tpl index d2a75015..44c05c90 100644 --- a/Templates/Build/upgrade.tpl +++ b/Templates/Build/upgrade.tpl @@ -1,146 +1,87 @@ resarray['f'.$id.'t']; +$bid = (int)$village->resarray['f'.$id.'t']; $bindicate = $building->canBuild($id, $bid); -if($bindicate == 1) { - echo "

".MAX_LEVEL."

"; -} else if($bindicate == 10) { - echo "

".BUILDING_MAX_LEVEL_UNDER."

"; -} else if($bindicate == 11) { - echo "

".BUILDING_BEING_DEMOLISHED."

"; -} else { - $loopsame = ($building->isCurrent($id) || $building->isLoop($id)) ? 1 : 0; - $doublebuild = ($building->isCurrent($id) && $building->isLoop($id)) ? 1 : 0; - $master = count($database->getMasterJobsByField($village->wid,$id)); - // master and loopsame would have duplicated level display, - // so we need to decrease loopsame if master is the only job left - if ($master == 1 && $loopsame == 1) $loopsame = 0; - - //-- If available resources combined are not enough, remove NPC button - $uprequire = $building->resourceRequired($id,$village->resarray['f'.$id.'t'],1 + $loopsame + $doublebuild + $master); -?> - -

resarray['f'.$id]+1+$loopsame+$doublebuild+$master; ?>:
-Lumber | Clay | Iron | Crop | Crop consumption | durationgetTimeFormat($uprequire['time']); -if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { - echo "| \"NPC"; -} ?>
-".WORKERS_ALREADY_WORK.""; - if($session->goldclub == 1){ -?>
-gold >= 1 && $village->master == 0){ - echo "checker\">".CONSTRUCTING_MASTER_BUILDER." "; - echo '('.COSTS.': Gold1)'; - }else{ - echo "".CONSTRUCTING_MASTER_BUILDER.""; - echo '('.COSTS.': Gold1)'; - } - }else{ - if($session->gold >= 1 && $village->master == 0){ - echo "checker\">".CONSTRUCTING_MASTER_BUILDER." "; - echo '('.COSTS.': Gold1)'; - }else{ - echo "".CONSTRUCTING_MASTER_BUILDER.""; - echo '('.COSTS.': Gold1)'; - } - } - } - } - else if($bindicate == 3) { - echo "".WORKERS_ALREADY_WORK_WAITING.""; - if($session->goldclub == 1){ -?>
-gold >= 1 && $village->master == 0){ - echo "checker\">".CONSTRUCTING_MASTER_BUILDER." "; - echo '('.COSTS.': Gold1)'; - }else{ - echo "".CONSTRUCTING_MASTER_BUILDER.""; - echo '('.COSTS.': Gold1)'; - } - }else{ - if($session->gold >= 1 && $village->master == 0){ - echo "checker\">".CONSTRUCTING_MASTER_BUILDER." "; - echo '('.COSTS.': Gold1)'; - }else{ - echo "".CONSTRUCTING_MASTER_BUILDER.""; - echo '('.COSTS.': Gold1)'; - } - } - } - } - else if($bindicate == 4) { - echo "".ENOUGH_FOOD_EXPAND_CROPLAND.""; - } - else if($bindicate == 5) { - echo "".UPGRADE_WAREHOUSE."."; - } - else if($bindicate == 6) { - echo "".UPGRADE_GRANARY."."; - } - else if($bindicate == 7) { - if($village->allcrop - $village->pop - $technology->getUpkeep($village->unitall, 0) > 0){ - $neededtime = $building->calculateAvaliable($id,$village->resarray['f'.$id.'t'],1+$loopsame+$doublebuild+$master); - echo "".ENOUGH_RESOURCES." ".$neededtime[0]." at ".$neededtime[1].""; - }else{ - echo "".YOUR_CROP_NEGATIVE.""; - } - if($session->goldclub == 1){ -?>
-gold >= 1 && $village->master == 0){ - echo "checker\">".CONSTRUCTING_MASTER_BUILDER." "; - echo '('.COSTS.': Gold1)'; - }else{ - echo "".CONSTRUCTING_MASTER_BUILDER.""; - echo '('.COSTS.': Gold1)'; - } - }else{ - if($session->gold >= 1 && $village->master == 0){ - echo "checker\">".CONSTRUCTING_MASTER_BUILDER." "; - echo '('.COSTS.': Gold1)'; - }else{ - echo "".CONSTRUCTING_MASTER_BUILDER.""; - echo '('.COSTS.': Gold1)'; - } - } - } - } - else if($bindicate == 8) { - if($session->access==BANNED){ - echo "".UPGRADE_LEVEL." "; - } - else if($id <= 18) { - echo "checker\">".UPGRADE_LEVEL." "; - } - else { - echo "checker\">".UPGRADE_LEVEL." "; - } - echo $village->resarray['f'.$id]+1; - echo "."; - } - else if($bindicate == 9) { - if($session->access==BANNED){ - echo "".UPGRADE_LEVEL." "; - } - else if($id <= 18) { - echo "checker\">".UPGRADE_LEVEL." "; - } - else { - echo "checker\">".UPGRADE_LEVEL." "; - } - echo $village->resarray['f'.$id]+($loopsame > 0 ? 2:1); - echo ". ".WAITING." "; - } +if ($bindicate == 1) { + echo '

'.MAX_LEVEL.'

'; + return; +} +if ($bindicate == 10) { + echo '

'.BUILDING_MAX_LEVEL_UNDER.'

'; + return; +} +if ($bindicate == 11) { + echo '

'.BUILDING_BEING_DEMOLISHED.'

'; + return; } +$loopsame = ($building->isCurrent($id) || $building->isLoop($id))? 1 : 0; +$doublebuild = ($building->isCurrent($id) && $building->isLoop($id))? 1 : 0; +$master = count($database->getMasterJobsByField($village->wid, $id)); +if ($master == 1 && $loopsame == 1) $loopsame = 0; + +$nextLevel = (int)$village->resarray['f'.$id] + 1 + $loopsame + $doublebuild + $master; +$uprequire = $building->resourceRequired($id, $bid, 1 + $loopsame + $doublebuild + $master); +$total_required = (int)($uprequire['wood'] + $uprequire['clay'] + $uprequire['iron'] + $uprequire['crop']); ?> +

+ :
+ | + | + | + | + | + getTimeFormat($uprequire['time']);?> + userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required):?> + | NPC trade + +
+'.WORKERS_ALREADY_WORK.''; + break; + case 3: + echo ''.WORKERS_ALREADY_WORK_WAITING.''; + break; + case 4: + echo ''.ENOUGH_FOOD_EXPAND_CROPLAND.''; + break; + case 5: + echo ''.UPGRADE_WAREHOUSE.'.'; + break; + case 6: + echo ''.UPGRADE_GRANARY.'.'; + break; + case 7: + if ($village->allcrop - $village->pop - $technology->getUpkeep($village->unitall, 0) > 0) { + $neededtime = $building->calculateAvaliable($id, $bid, 1 + $loopsame + $doublebuild + $master); + echo ''.ENOUGH_RESOURCES.' '.$neededtime[0].' at '.$neededtime[1].''; + } else { + echo ''.YOUR_CROP_NEGATIVE.''; + } + break; + case 8: + case 9: + $href = $session->access == BANNED? 'banned.php' : (($id <= 18)? "dorf1.php?a=$id&c=$session->checker" : "dorf2.php?a=$id&c=$session->checker"); + $lvl = $bindicate == 8? $village->resarray['f'.$id] + 1 : $village->resarray['f'.$id] + ($loopsame > 0? 2 : 1); + echo ''.UPGRADE_LEVEL.' '.$lvl.'.'; + if ($bindicate == 9) echo ' '.WAITING.''; + break; +} + +if (in_array($bindicate, [2,3,7]) && $session->goldclub == 1) { + echo '
'; + $masterHref = ($id <= 18? 'dorf1.php' : 'dorf2.php'). "?master=$bid&id=$id&c=$session->checker"; + if ($session->gold >= 1 && $village->master == 0) { + echo ''.CONSTRUCTING_MASTER_BUILDER.''; + } else { + echo ''.CONSTRUCTING_MASTER_BUILDER.''; + } + echo ' ('.COSTS.': Gold1)'; +} +?> +

\ No newline at end of file diff --git a/Templates/Build/ww.tpl b/Templates/Build/ww.tpl index 02c07f3e..7d165832 100644 --- a/Templates/Build/ww.tpl +++ b/Templates/Build/ww.tpl @@ -1,46 +1,38 @@ isCurrent($id) || $building->isLoop($id))?1:0; - $doublebuild = ($building->isCurrent($id) && $building->isLoop($id))?1:0; -?> +$loopsame = ($building->isCurrent($id) || $building->isLoop($id)) ? 1 : 0; +$doublebuild = ($building->isCurrent($id) && $building->isLoop($id)) ? 1 : 0; -
-


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

-

-
-getWWName($vref); - -if($village->resarray['f'.$id] < 0){ -echo ''.WORLD_WONDER_CHANGE_NAME.'. -

'.WORLD_WONDER_NAME.':

'; -} else if($village->resarray['f'.$id] > 0 and $village->resarray['f'.$id] < 11) { -echo '

'.WORLD_WONDER_NAME.':

'; -} else if ($village->resarray['f'.$id] > 10){ -echo ''.WORLD_WONDER_NOTCHANGE_NAME.'. -

'.WORLD_WONDER_NAME.':

'; -}?> -
- '.WORLD_WONDER_NAME_CHANGED.'.

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

+
+ +


+

+ +
+ 10) ? 'disabled="disabled"' : ''; + $msg = $level < 0 ? WORLD_WONDER_CHANGE_NAME.'.' : ($level > 10 ? WORLD_WONDER_NOTCHANGE_NAME.'.' : ''); + if ($msg) echo $msg; + ?> +

: + value="" maxlength="20"> +
+

+ +

+
+ + +
.

+ + + +
\ No newline at end of file diff --git a/Templates/Build/wwupgrade.tpl b/Templates/Build/wwupgrade.tpl index 8dc367f0..0bdb6858 100644 --- a/Templates/Build/wwupgrade.tpl +++ b/Templates/Build/wwupgrade.tpl @@ -1,154 +1,81 @@ resarray[ 'f' . $id . 't' ]; -$bindicate = $building->canBuild( $id, $bid ); -$wwlevel = $village->resarray['f99']; -if ( $wwlevel >= 50 ) { - $needed_plan = 1; -} else { - $needed_plan = 0; +// wwupgrade.tpl +global $village, $building, $database, $generator, $session, $id; + +$bid = (int)$village->resarray['f'.$id.'t']; +$bindicate = $building->canBuild($id, $bid); +$wwlevel = (int)$village->resarray['f99']; +$needed_plan = $wwlevel >= 50? 1 : 0; + +if (!$building->allowWwUpgrade()) { + echo $needed_plan == 0 + ? '

'.NEED_WWCONSTRUCTION_PLAN.'.

' + : '

'.NEED_MORE_WWCONSTRUCTION_PLAN.'.

'; + return; } -if ( $building->allowWwUpgrade() ) { - if ( $bindicate == 1 ) { - echo "

" . MAX_LEVEL . "

"; - } else if ( $bindicate == 10 ) { - echo "

" . BUILDING_MAX_LEVEL_UNDER . "

"; - } else if ( $bindicate == 11 ) { - echo "

" . BUILDING_BEING_DEMOLISHED . "

"; - } else { - $loopsame = ( $building->isCurrent( $id ) || $building->isLoop( $id ) ) ? 1 : 0; - $doublebuild = ( $building->isCurrent( $id ) && $building->isLoop( $id ) ) ? 1 : 0; - $master = count( $database->getMasterJobsByField( $village->wid, $id ) ); - $uprequire = $building->resourceRequired( $id, $village->resarray[ 'f' . $id . 't' ], 1 + $loopsame + $doublebuild + $master ); +if ($bindicate == 1) { + echo '

'.MAX_LEVEL.'

'; return; +} +if ($bindicate == 10) { + echo '

'.BUILDING_MAX_LEVEL_UNDER.'

'; return; +} +if ($bindicate == 11) { + echo '

'.BUILDING_BEING_DEMOLISHED.'

'; return; +} + +$loopsame = ($building->isCurrent($id) || $building->isLoop($id))? 1 : 0; +$doublebuild = ($building->isCurrent($id) && $building->isLoop($id))? 1 : 0; +$master = count($database->getMasterJobsByField($village->wid, $id)); +$nextLevel = (int)$village->resarray['f'.$id] + 1 + $loopsame + $doublebuild + $master; +$uprequire = $building->resourceRequired($id, $bid, 1 + $loopsame + $doublebuild + $master); +$total_required = (int)($uprequire['wood'] + $uprequire['clay'] + $uprequire['iron'] + $uprequire['crop']); ?>

- resarray[ 'f' . $id ] + 1 + $loopsame + $doublebuild + $master; ?> - :
- Lumber | Clay | Iron | Crop | Crop consumption - | durationgetTimeFormat( $uprequire['time'] ); - //-- If available resources combined are not enough, remove NPC button - $total_required = (int)($uprequire['wood'] + $uprequire['clay'] + $uprequire['iron'] + $uprequire['crop']); - if ( $session->userinfo['gold'] >= 3 && $building->getTypeLevel( 17 ) >= 1 && $village->atotal >= $total_required) { - echo "|\"NPC"; - } ?>
- " . WORKERS_ALREADY_WORK . ""; - if ( $session->goldclub == 1 ) { - ?>
- gold >= 1 && $village->master == 0 ) { - echo "" . CONSTRUCTING_MASTER_BUILDER . " "; - echo '(' . COSTS . ': Gold1)'; - } else { - echo "" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(' . COSTS . ': Gold1)'; - } - } else { - if ( $session->gold >= 1 && $village->master == 0 ) { - echo "" . CONSTRUCTING_MASTER_BUILDER . " "; - echo '(' . COSTS . ': Gold1)'; - } else { - echo "" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(' . COSTS . ': Gold1)'; - } - } - } - } else if ( $bindicate == 3 ) { - echo "" . WORKERS_ALREADY_WORK_WAITING . ""; - if ( $session->goldclub == 1 ) { - ?>
- gold >= 1 && $village->master == 0 ) { - echo "" . CONSTRUCTING_MASTER_BUILDER . " "; - echo '(' . COSTS . ': Gold1)'; - } else { - echo "" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(' . COSTS . ': Gold1)'; - } - } else { - if ( $session->gold >= 1 && $village->master == 0 ) { - echo "" . CONSTRUCTING_MASTER_BUILDER . " "; - echo '(' . COSTS . ': Gold1)'; - } else { - echo "" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(' . COSTS . ': Gold1)'; - } - } - } - } else if ( $bindicate == 4 ) { - echo "" . ENOUGH_FOOD_EXPAND_CROPLAND . ""; - } else if ( $bindicate == 5 ) { - echo "" . UPGRADE_WAREHOUSE . "."; - } else if ( $bindicate == 6 ) { - echo "" . UPGRADE_GRANARY . "."; - } else if ( $bindicate == 7 ) { - if ( $village->allcrop > 0 ) { - $neededtime = $building->calculateAvaliable( $id, $village->resarray[ 'f' . $id . 't' ], 1 + $loopsame + $doublebuild + $master ); - echo "" . ENOUGH_RESOURCES . " " . $neededtime[0] . " at " . $neededtime[1] . ""; - } else { - echo "" . YOUR_CROP_NEGATIVE . ""; - } - if ( $session->goldclub == 1 ) { - ?>
- gold >= 1 && $village->master == 0 ) { - echo "" . CONSTRUCTING_MASTER_BUILDER . " "; - echo '(' . COSTS . ': Gold1)'; - } else { - echo "" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(' . COSTS . ': Gold1)'; - } - } else { - if ( $session->gold >= 1 && $village->master == 0 ) { - echo "" . CONSTRUCTING_MASTER_BUILDER . " "; - echo '(' . COSTS . ': Gold1)'; - } else { - echo "" . CONSTRUCTING_MASTER_BUILDER . ""; - echo '(' . COSTS . ': Gold1)'; - } - } - } - } else if ( $bindicate == 8 ) { - if ( $session->access == BANNED ) { - echo "" . UPGRADE_LEVEL . " "; - } else if ( $id <= 18 ) { - echo "checker\">" . UPGRADE_LEVEL . " "; + :
+ | + | + | + | + | + getTimeFormat($uprequire['time']);?> + userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required):?> + |
NPC trade + +
+'.WORKERS_ALREADY_WORK.''; break; + case 3: echo ''.WORKERS_ALREADY_WORK_WAITING.''; break; + case 4: echo ''.ENOUGH_FOOD_EXPAND_CROPLAND.''; break; + case 5: echo ''.UPGRADE_WAREHOUSE.'.'; break; + case 6: echo ''.UPGRADE_GRANARY.'.'; break; + case 7: + if ($village->allcrop > 0) { + $neededtime = $building->calculateAvaliable($id, $bid, 1 + $loopsame + $doublebuild + $master); + echo ''.ENOUGH_RESOURCES.' '.$neededtime[0].' at '.$neededtime[1].''; } else { - echo "checker\">" . UPGRADE_LEVEL . " "; + echo ''.YOUR_CROP_NEGATIVE.''; } - echo $village->resarray[ 'f' . $id ] + 1; - echo "."; - } else if ( $bindicate == 9 ) { - if ( $session->access == BANNED ) { - echo "" . UPGRADE_LEVEL . " "; - } else if ( $id <= 18 ) { - echo "checker\">" . UPGRADE_LEVEL . " "; - } else { - echo "checker\">" . UPGRADE_LEVEL . " "; - } - echo $village->resarray[ 'f' . $id ] + ( $loopsame > 0 ? 2 : 1 ); - echo ". " . WAITING . " "; - } - } + break; + case 8: + case 9: + $href = $session->access == BANNED? 'banned.php' : (($id <= 18)? "dorf1.php?a=$id&c=$session->checker" : "dorf2.php?a=$id&c=$session->checker"); + $lvl = $bindicate == 8? $village->resarray['f'.$id] + 1 : $village->resarray['f'.$id] + ($loopsame > 0? 2 : 1); + echo ''.UPGRADE_LEVEL.' '.$lvl.'.'; + if ($bindicate == 9) echo ' '.WAITING.''; + break; +} + +if (in_array($bindicate, [2,3,7]) && $session->goldclub == 1) { + echo '
'; + $masterHref = ($id <= 18? 'dorf1.php' : 'dorf2.php'). "?master=$bid&id=$id&c=$session->checker"; + if ($session->gold >= 1 && $village->master == 0) { + echo ''.CONSTRUCTING_MASTER_BUILDER.''; } else { - if ( $needed_plan == 0 ) { - echo "" . NEED_WWCONSTRUCTION_PLAN . "."; - } else { - echo "" . NEED_MORE_WWCONSTRUCTION_PLAN . "."; - } + echo ''.CONSTRUCTING_MASTER_BUILDER.''; } -?> \ No newline at end of file + echo ' ('.COSTS.': Gold1)'; +} +?> +

\ No newline at end of file diff --git a/Templates/header.tpl b/Templates/header.tpl index 168318c0..03cc7a98 100644 --- a/Templates/header.tpl +++ b/Templates/header.tpl @@ -241,6 +241,17 @@ if ($hour > 1759 || $hour < 500) { vertical-align:middle; position:static; } + + .dayNightIcon { + margin-top: 22px; /* aici cobori iconița */ + text-align: center; + } + + .dayNightIcon img { + width: 18px; + height: 18px; + display: inline-block; + } @@ -255,11 +266,10 @@ if ($hour > 1759 || $hour < 500) {

- - + +

+ +