From 90221cf19f233e56358207e12d3e1bc15cbfcaff Mon Sep 17 00:00:00 2001 From: iopietro Date: Thu, 10 May 2018 17:45:27 +0200 Subject: [PATCH] Natars automation system +Natars will now spawn automatically, you can set how many day should pass before the spawn of Natars (and artifacts), WW Villages and WW building plans (Note: WW villages and WW building plans won't spawn until the creation of the natar account) +Added 3 timers under the left menu which indicate the spawn of Natars/Artifacts, WW villages and WW building plans +Added an option in the installation, to set the resource production of oasis +Fixed a bug that didn't permit to add multiple Units, Abtech and tech rows with one query +Added a new information to the Artifact of the fool, the next effect reroll will now be displayed in his informations (in the treasury) +Fixed a bug that dind't permit the correct timers flow in Dorf3.php (Warehouse tab), they'll now flow correctly +Timers and resources percentage of villages with a negative production of crop will now be marked in red (in the Warehouse tab, Dorf3.php) and will now be displayed in how much time the granary will be emptied +Fixed a possible bug that prevented to add raids to farm lists +Fixed a bug that didn't permit to create WW Villages from the Multihunter control panel +Reworked all timers, there will be only one timer field now (in Session.php) +Minor bug fixing and optimization NOTE: To play this version of the game, you need to reinstall the server OR you can simply add these lines of code into your "config.php" file: // ***** Natars Spawn Time define("NATARS_SPAWN_TIME",260); define("NATARS_WW_SPAWN_TIME",260); define("NATARS_WW_BUILDING_PLAN_SPAWN_TIME",260); // ***** Oasis production define("OASIS_WOOD_MULTIPLIER",40); define("OASIS_CLAY_MULTIPLIER",40); define("OASIS_IRON_MULTIPLIER",40); define("OASIS_CROP_MULTIPLIER",40); define("OASIS_WOOD_PRODUCTION",OASIS_WOOD_MULTIPLIER*SPEED); define("OASIS_CLAY_PRODUCTION",OASIS_CLAY_MULTIPLIER*SPEED); define("OASIS_IRON_PRODUCTION",OASIS_IRON_MULTIPLIER*SPEED); define("OASIS_CROP_PRODUCTION",OASIS_CROP_MULTIPLIER*SPEED); P.S: from the next version, the possibility to add manual WWs, WW building plans and to create the natar account will be REMOVED. --- GameEngine/Account.php | 113 ++--- GameEngine/Admin/Mods/natarend.php | 3 - GameEngine/Automation.php | 219 +++++++-- GameEngine/Database.php | 330 ++++++++++++-- GameEngine/Lang/en.php | 6 +- GameEngine/Technology.php | 40 +- Templates/Build/12_upgrades.tpl | 11 +- Templates/Build/13_upgrades.tpl | 13 +- Templates/Build/16.tpl | 537 ++++++++++++----------- Templates/Build/19.tpl | 7 +- Templates/Build/20.tpl | 4 +- Templates/Build/21.tpl | 4 +- Templates/Build/22_1.tpl | 8 +- Templates/Build/22_2.tpl | 8 +- Templates/Build/22_3.tpl | 8 +- Templates/Build/22_4.tpl | 8 +- Templates/Build/22_5.tpl | 8 +- Templates/Build/24_2.tpl | 10 +- Templates/Build/25_progress.tpl | 4 +- Templates/Build/26_progress.tpl | 4 +- Templates/Build/27_show.tpl | 23 +- Templates/Build/29.tpl | 4 +- Templates/Build/30.tpl | 4 +- Templates/Build/37.tpl | 2 +- Templates/Build/37_land.tpl | 13 +- Templates/Build/37_revive.tpl | 164 +++---- Templates/Build/37_train.tpl | 47 +- Templates/Build/42.tpl | 4 +- Templates/Building.tpl | 6 +- Templates/Profile/account.tpl | 2 +- Templates/dorf3/3.tpl | 175 ++++---- Templates/goldClub/farmlist_addraid.tpl | 41 +- Templates/goldClub/farmlist_editraid.tpl | 6 +- Templates/menu.tpl | 19 +- Templates/movement.tpl | 28 +- Templates/natars.tpl | 32 ++ create_account.php | 491 ++------------------- install/data/constant_format.tpl | 15 + install/process.php | 7 + install/templates/config.tpl | 30 +- 40 files changed, 1222 insertions(+), 1236 deletions(-) create mode 100644 Templates/natars.tpl diff --git a/GameEngine/Account.php b/GameEngine/Account.php index 816e545e..78eec917 100755 --- a/GameEngine/Account.php +++ b/GameEngine/Account.php @@ -200,62 +200,59 @@ class Account { } private function Login() { - global $database,$session,$form; + global $database, $session, $form; + $user = $_POST['user']; - if(!isset($_POST['user']) || $_POST['user'] == "") { - $form->addError("user",$user); + if(!isset($_POST['user']) || empty($_POST['user'])){ + $form->addError("user", $user); + }else if(!User::exists($database, $_POST['user'])){ + $form->addError("user", USR_NT_FOUND); } - else if(!User::exists($database,$_POST['user'])) { - $form->addError("user",USR_NT_FOUND); - } - if(!isset($_POST['pw']) || $_POST['pw'] == "") { - $form->addError("pw",LOGIN_PASS_EMPTY); - } - else if(!$database->login($_POST['user'],$_POST['pw']) && !$database->sitterLogin($_POST['user'],$_POST['pw'])) { - // try activation data if the user was not found - if (!$userData) { - $activateData = $database->getActivateField( $_POST['user'], 'act', 1 ); - - if ( $activateData != "" ) { - $form->addError( "activate", $_POST['user'] ); - } else { - $form->addError("pw",LOGIN_PW_ERROR); - } - } else { - $form->addError("pw",LOGIN_PW_ERROR); - } + if(!isset($_POST['pw']) || empty($_POST['pw'])){ + $form->addError("pw", LOGIN_PASS_EMPTY); + }else if(!$database->login($_POST['user'], $_POST['pw']) && !$database->sitterLogin($_POST['user'], $_POST['pw'])){ + // try activation data if the user was not found + if(!$userData){ + $activateData = $database->getActivateField($_POST['user'], 'act', 1); + + if(!empty($activateData)) $form->addError("activate", $_POST['user']); + + else $form->addError("pw", LOGIN_PW_ERROR); + } + else $form->addError("pw", LOGIN_PW_ERROR); } $userData = $database->getUserArray($_POST['user'], 0); - + // Vacation mode by Shadow - if($userData["vac_mode"] == 1 && $userData["vac_time"] > time()) { - $form->addError("vacation","Vacation mode is still enabled"); + if($userData["vac_mode"] == 1 && $userData["vac_time"] > time()){ + $form->addError("vacation", "Vacation mode is still enabled"); } - + // Vacation mode by Shadow - if($form->returnErrors() > 0) { + if($form->returnErrors() > 0){ $_SESSION['errorarray'] = $form->getErrors(); $_SESSION['valuearray'] = $_POST; - + header("Location: login.php"); - exit; - } else { - // Vacation mode by Shadow - $database->removevacationmode($userData['id']); - // Vacation mode by Shadow - if($database->login($_POST['user'],$_POST['pw'])){ - $database->UpdateOnline("login" ,$_POST['user'],time(),$userData['id']); - }else if($database->sitterLogin($_POST['user'],$_POST['pw'])){ - $database->UpdateOnline("sitter" ,$_POST['user'],time(),$userData['id']); - } - setcookie("COOKUSR",$_POST['user'],time()+COOKIE_EXPIRE,COOKIE_PATH); - $session->login($_POST['user']); + exit(); + }else{ + // Vacation mode by Shadow + $database->removevacationmode($userData['id']); + // Vacation mode by Shadow + if($database->login($_POST['user'], $_POST['pw'])){ + $database->UpdateOnline("login", $_POST['user'], time(), $userData['id']); + }else if($database->sitterLogin($_POST['user'], $_POST['pw'])){ + $database->UpdateOnline("sitter", $_POST['user'], time(), $userData['id']); + } + setcookie("COOKUSR", $_POST['user'], time() + COOKIE_EXPIRE, COOKIE_PATH); + $session->login($_POST['user']); } } private function Logout() { - global $session,$database; + global $session, $database; + unset($_SESSION['wid']); $database->activeModify(addslashes($session->username),1); $database->UpdateOnline("logout") or die(mysqli_error($database->dblink)); @@ -264,34 +261,18 @@ class Account { private function validEmail($email) { $regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; - if ( !preg_match($regexp, $email) ) { - return false; - } - return true; + return preg_match($regexp, $email); } - function generateBase($kid,$uid,$username) { - global $database,$message; - if($kid == 0) { - $kid = rand(1,4); - } - else{ - $kid = $_POST['kid']; - } - - $wid = $database->generateBase($kid,0); - $database->setFieldTaken($wid); - $database->addVillage($wid,$uid,$username,1); - $database->addResourceFields($wid,$database->getVillageType($wid)); - $database->addUnits($wid); - $database->addTech($wid); - $database->addABTech($wid); - $database->updateUserField($uid,"access",USER,1); - - $message = new Message(); - $message->sendWelcome($uid,$username); + function generateBase($kid, $uid, $username) { + global $database, $message; + + if($kid == 0) $kid = rand(1,4); + else $kid = $_POST['kid']; + + $database->generateVillages([['wid' => 0, 'kid' => $kid, 'capital' => 1]], $uid, $username); + $message->sendWelcome($uid, $username); } - }; $account = new Account; ?> diff --git a/GameEngine/Admin/Mods/natarend.php b/GameEngine/Admin/Mods/natarend.php index a3fd058f..86d0788c 100755 --- a/GameEngine/Admin/Mods/natarend.php +++ b/GameEngine/Admin/Mods/natarend.php @@ -11,7 +11,6 @@ ################################################################################# include_once("../../config.php"); include_once("../../Session.php"); -include_once("../../Automation.php"); // go max 5 levels up - we don't have folders that go deeper than that $autoprefix = ''; @@ -41,8 +40,6 @@ for($i=1;$i<=$amt;$i++) { mysqli_query($GLOBALS["link"], $q) or die(mysqli_error($database->dblink)); $q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid,0,1,0,4,0,1,0,3,0,2,0,2,0,3,0,4,0,4,0,3,0,3,0,4,0,4,0,1,0,4,0,2,0,1,0,2,20,17,20,11,20,15,20,10,10,22,10,25,0,0,0,0,10,19,0,0,0,0,0,0,10,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,0,0,0,40,'World Wonder')"; mysqli_query($GLOBALS["link"], $q); - $pop = $automation->recountPop($wid); - $cp = $automation->recountPop($wid); $addTechWrefs[] = $wid; $addABTechWrefs[] = $wid; $speed = NATARS_UNITS; diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index dc116c9b..6882726c 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -28,10 +28,6 @@ class Automation { private $bountyOinfoarray = []; private $bountyOproduction = []; private $bountyOpop = 1; - const bountyOWoodProd = 40 * SPEED; - const bountyOClayProd = 40 * SPEED; - const bountyOIronProd = 40 * SPEED; - const bountyOCropProd = 40 * SPEED; public function __construct() { $this->procNewClimbers(); @@ -91,6 +87,15 @@ class Automation { if(!file_exists("GameEngine/Prevention/settlers.txt") or time() - filemtime("GameEngine/Prevention/settlers.txt") > 50) { $this->sendSettlersComplete(); } + if(!file_exists("GameEngine/Prevention/spawnNatars.txt") or time() - filemtime("GameEngine/Prevention/spawnNatars.txt") > 120) { + $this->spawnNatars(); + } + if(!file_exists("GameEngine/Prevention/spawnWWVillages.txt") or time() - filemtime("GameEngine/Prevention/spawnWWVillages.txt") > 120) { + $this->spawnWWVillages(); + } + if(!file_exists("GameEngine/Prevention/spawnWWBuildingPlans.txt") or time() - filemtime("GameEngine/Prevention/spawnWWBuildingPlans.txt") > 120) { + $this->spawnWWBuildingPlans(); + } if(!file_exists("GameEngine/Prevention/artifacts.txt") or time() - filemtime("GameEngine/Prevention/artifacts.txt") > 60) { $this->activateArtifacts(); } @@ -247,7 +252,7 @@ class Automation { } public function getTypeLevel($tid, $vid) { - global $village, $database; + global $database; $keyholder = []; @@ -287,15 +292,21 @@ class Automation { } private function clearDeleting() { - global $autoprefix, $units; + global $autoprefix, $units, $database; + if(file_exists($autoprefix."GameEngine/Prevention/cleardeleting.txt")) { unlink($autoprefix."GameEngine/Prevention/cleardeleting.txt"); } - global $database; + $ourFileHandle = fopen($autoprefix."GameEngine/Prevention/cleardeleting.txt", 'w'); fclose($ourFileHandle); + $needDelete = $database->getNeedDelete(); if(count($needDelete) > 0) { + + //Remove the time limit, otherwise deleting players with 80 or more villages couldn't be deleted in one run + @set_time_limit(0); + foreach($needDelete as $need) { $needVillage = $database->getVillagesID($need['uid']); @@ -932,7 +943,7 @@ class Automation { } private function sendunitsComplete() { - global $bid19, $bid23, $bid34, $u99, $database, $battle, $village, $technology, $logging, $generator, $session, $units, $autoprefix; + global $bid19, $bid23, $bid34, $u99, $database, $battle, $technology, $logging, $generator, $units, $autoprefix; if(file_exists($autoprefix."GameEngine/Prevention/sendunits.txt")) { unlink($autoprefix."GameEngine/Prevention/sendunits.txt"); @@ -2748,7 +2759,7 @@ class Automation { } private function sendreinfunitsComplete() { - global $bid23,$database,$battle,$session,$autoprefix; + global $bid23, $database, $battle, $autoprefix; if(file_exists($autoprefix."GameEngine/Prevention/sendreinfunits.txt")) { unlink($autoprefix."GameEngine/Prevention/sendreinfunits.txt"); @@ -3004,7 +3015,7 @@ class Automation { } private function sendSettlersComplete() { - global $database, $building, $session, $autoprefix; + global $database, $building, $autoprefix; if(file_exists($autoprefix."GameEngine/Prevention/settlers.txt")) { unlink($autoprefix."GameEngine/Prevention/settlers.txt"); @@ -3093,6 +3104,160 @@ class Automation { } } + /** + * Create the Natars account and spawn artifacts + * + */ + + private function spawnNatars(){ + global $database, $autoprefix; + + if(file_exists($autoprefix."GameEngine/Prevention/spawnNatars.txt")) { + unlink($autoprefix."GameEngine/Prevention/spawnNatars.txt"); + } + + //Check if Natars account is already created and if the time + //is come and we have to create Natars and spawn their artifacts + if($database->areArtifactsSpawned() || COMMENCE + (NATARS_SPAWN_TIME * 86400) > time()) return; + + $ourFileHandle = fopen($autoprefix."GameEngine/Prevention/spawnNatars.txt", 'w'); + fclose($ourFileHandle); + + //Create the Natars account and his capital + $database->createNatars(); + + //Artifacts constants + $artifactArrays = [ARCHITECTS_DESC => [["type" => 1, "size" => 1, "name" => ARCHITECTS_SMALL, "vname" => ARCHITECTS_SMALLVILLAGE, "effect" => "(4x)", "quantity" => 6, "img" => 2], + ["type" => 1, "size" => 2, "name" => ARCHITECTS_LARGE, "vname" => ARCHITECTS_LARGEVILLAGE, "effect" => "(3x)", "quantity" => 4, "img" => 2], + ["type" => 1, "size" => 3, "name" => ARCHITECTS_UNIQUE,"vname" => ARCHITECTS_UNIQUEVILLAGE, "effect" => "(5x)", "quantity" => 1, "img" => 2]], + + HASTE_DESC => [["type" => 2, "size" => 1, "name" => HASTE_SMALL, "vname" => HASTE_SMALLVILLAGE, "effect" => "(2x)", "quantity" => 6, "img" => 4], + ["type" => 2, "size" => 2, "name" => HASTE_LARGE, "vname" => HASTE_LARGEVILLAGE, "effect" => "(1.5x)", "quantity" => 4, "img" => 4], + ["type" => 2, "size" => 3, "name" => HASTE_UNIQUE, "vname" => HASTE_UNIQUEVILLAGE, "effect" => "(3x)", "quantity" => 1, "img" => 4]], + + EYESIGHT_DESC => [["type" => 3, "size" => 1, "name" => EYESIGHT_SMALL, "vname" => EYESIGHT_SMALLVILLAGE, "effect" => "(5x)", "quantity" => 6, "img" => 5], + ["type" => 3, "size" => 2, "name" => EYESIGHT_LARGE, "vname" => EYESIGHT_LARGEVILLAGE, "effect" => "(3x)", "quantity" => 4, "img" => 5], + ["type" => 3, "size" => 3, "name" => EYESIGHT_UNIQUE, "vname" => EYESIGHT_UNIQUEVILLAGE, "effect" => "(10x)", "quantity" => 1, "img" => 5]], + + DIET_DESC => [["type" => 4, "size" => 1, "name" => DIET_SMALL, "vname" => DIET_SMALLVILLAGE, "effect" => "(50%)", "quantity" => 6, "img" => 6], + ["type" => 4, "size" => 2, "name" => DIET_LARGE, "vname" => DIET_LARGEVILLAGE, "effect" => "(25%)", "quantity" => 4, "img" => 6], + ["type" => 4, "size" => 3, "name" => DIET_UNIQUE, "vname" => DIET_UNIQUEVILLAGE, "effect" => "(50%)", "quantity" => 1, "img" => 6]], + + ACADEMIC_DESC => [["type" => 5, "size" => 1, "name" => ACADEMIC_SMALL, "vname" => ACADEMIC_SMALLVILLAGE, "effect" => "(50%)", "quantity" => 6, "img" => 8], + ["type" => 5, "size" => 2, "name" => ACADEMIC_LARGE, "vname" => ACADEMIC_LARGEVILLAGE, "effect" => "(25%)", "quantity" => 4, "img" => 8], + ["type" => 5, "size" => 3, "name" => ACADEMIC_UNIQUE, "vname" => ACADEMIC_UNIQUEVILLAGE, "effect" => "(50%)", "quantity" => 1, "img" => 8]], + + STORAGE_DESC => [["type" => 6, "size" => 1, "name" => STORAGE_SMALL, "vname" => STORAGE_SMALLVILLAGE, "effect" => "(50%)", "quantity" => 6, "img" => 9], + ["type" => 6, "size" => 2, "name" => STORAGE_LARGE, "vname" => STORAGE_LARGEVILLAGE, "effect" => "(25%)", "quantity" => 4, "img" => 9]], + + CONFUSION_DESC => [["type" => 7, "size" => 1, "name" => CONFUSION_SMALL, "vname" => CONFUSION_SMALLVILLAGE, "effect" => "(200)", "quantity" => 6, "img" => 10], + ["type" => 7, "size" => 2, "name" => CONFUSION_LARGE, "vname" => CONFUSION_LARGEVILLAGE, "effect" => "(100)", "quantity" => 4, "img" => 10], + ["type" => 7, "size" => 3, "name" => CONFUSION_UNIQUE, "vname" => CONFUSION_UNIQUEVILLAGE, "effect" => "(500)", "quantity" => 1, "img" => 10]], + + FOOL_DESC => [["type" => 8, "size" => 1, "name" => FOOL_SMALL, "vname" => FOOL_SMALLVILLAGE, "effect" => "", "quantity" => 5, "img" => "fool"], + ["type" => 8, "size" => 3, "name" => FOOL_UNIQUE, "vname" => FOOL_UNIQUEVILLAGE, "effect" => "", "quantity" => 1, "img" => "fool"]]]; + + //Add artifacts and their villages + $database->addArtifactVillages($artifactArrays); + + //Write the system message + $database->displaySystemMessage(ARTEFACT); + + if(file_exists("GameEngine/Prevention/spawnNatars.txt")) { + unlink("GameEngine/Prevention/spawnNatars.txt"); + } + } + + /** + * Spawn WW Villages + * + */ + + private function spawnWWVillages(){ + global $database, $autoprefix; + + if(file_exists($autoprefix."GameEngine/Prevention/spawnWWVillages.txt")) { + unlink($autoprefix."GameEngine/Prevention/spawnWWVillages.txt"); + } + + //Check if Natars account has already been created, if WW villages have already been spawned + //and if it's the time to spawn them or not + if(!$database->areArtifactsSpawned() || $database->areWWVillagesSpawned() || COMMENCE + (NATARS_WW_SPAWN_TIME * 86400) > time()) return; + + $ourFileHandle = fopen($autoprefix."GameEngine/Prevention/spawnWWVillages.txt", 'w'); + fclose($ourFileHandle); + + //WW village Natars' troops + $unitArrays = [41 => rand(50, 1200) * NATARS_UNITS, + 42 => rand(100 , 1400) * NATARS_UNITS, + 43 => rand(200, 1600) * NATARS_UNITS, + 44 => rand(10, 50) * NATARS_UNITS, + 45 => rand(48, 1700) * NATARS_UNITS, + 46 => rand(60, 1800) * NATARS_UNITS, + 47 => rand(200, 1600) * NATARS_UNITS, + 48 => rand(40, 200) * NATARS_UNITS, + 49 => rand(4, 20) * NATARS_UNITS, + 50 => rand(5, 25) * NATARS_UNITS]; + + //WW village buildings + $buildingArrays = ["f99t" => 40, "f99" => 0, "f39t" => 16, "f39" => 1, "f19t" => 17, "f19" => 20, "f20t" => 11, + "f20" => 20, "f21t" => 15, "f21" => 20, "f22t" => 10, "f22" => 20, "f23t" => 22, "f23" => 10, + "f24t" => 25, "f24" => 10, "f26t" => 0, "f26" => 0, "f27t" => 19, "f27" => 10, "f31t" => 23, "f31" => 10]; + + $villageArrays = $wids = []; + for($i = 1; $i <= 13; $i++) $villageArrays[] = ['wid' => 0, 'kid' => ($i == 13 ? rand(1, 4) : ($i % 4) + 1), 'capital' => 0]; + + $wids = $database->generateVillages($villageArrays, 3, "Natars"); + + foreach($wids as $wid){ + $database->modifyUnit($wid, array_keys($unitArrays), array_values($unitArrays), [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]); + $database->setVillageLevel($wid, array_keys($buildingArrays), array_values($buildingArrays)); + $database->setVillageFields($wid, ['natar', 'name'], [1, WWVILLAGE]); + $this->recountPop($wid); + } + + if(file_exists("GameEngine/Prevention/spawnWWVillages.txt")) { + unlink("GameEngine/Prevention/spawnWWVillages.txt"); + } + } + + /** + * Spawn WW Building plans + * + */ + + private function spawnWWBuildingPlans(){ + global $database, $autoprefix; + + if(file_exists($autoprefix."GameEngine/Prevention/spawnWWBuildingPlans.txt")) { + unlink($autoprefix."GameEngine/Prevention/spawnWWBuildingPlans.txt"); + } + + //Check if Natars account is already spawned, if WW building plans have already been spawned + //and if it's the time to spawn them or not + if(!$database->areArtifactsSpawned() || $database->areArtifactsSpawned(true) || COMMENCE + (NATARS_WW_BUILDING_PLAN_SPAWN_TIME * 86400) > time()) return; + + $ourFileHandle = fopen($autoprefix."GameEngine/Prevention/spawnWWBuildingPlans.txt", 'w'); + fclose($ourFileHandle); + + $artifactArrays = [PLAN_DESC => [["type" => 11, "size" => 1, "name" => PLAN,"vname" => PLANVILLAGE, "effect" => "", "quantity" => 13, "img" => 1]]]; + + //Add the artifacts and villages + $database->addArtifactVillages($artifactArrays); + + //Set the system message to contain the infos of the WW building plans + $database->displaySystemMessage(PLAN_INFO); + + if(file_exists("GameEngine/Prevention/spawnWWBuildingPlans.txt")) { + unlink("GameEngine/Prevention/spawnWWBuildingPlans.txt"); + } + } + + /** + * Automatically activate all artifacts that need to be activated + * + */ + private function activateArtifacts() { global $database, $autoprefix; @@ -3352,10 +3517,10 @@ class Automation { } private function bountycalculateOProduction($bountywid) { - $this->bountyOproduction['wood'] = self::bountyOWoodProd; - $this->bountyOproduction['clay'] = self::bountyOClayProd; - $this->bountyOproduction['iron'] = self::bountyOIronProd; - $this->bountyOproduction['crop'] = self::bountyOCropProd; + $this->bountyOproduction['wood'] = OASIS_WOOD_PRODUCTION; + $this->bountyOproduction['clay'] = OASIS_CLAY_PRODUCTION; + $this->bountyOproduction['iron'] = OASIS_IRON_PRODUCTION; + $this->bountyOproduction['crop'] = OASIS_CROP_PRODUCTION; } private function bountycalculateProduction($bountywid, $uid) { @@ -3596,7 +3761,7 @@ class Automation { } private function demolitionComplete() { - global $building,$database,$village,$autoprefix; + global $building, $database, $autoprefix; if(file_exists($autoprefix."GameEngine/Prevention/demolition.txt")) { unlink($autoprefix."GameEngine/Prevention/demolition.txt"); @@ -3636,7 +3801,7 @@ class Automation { if ($level == 1) $clear = ",f".$vil['buildnumber']."t=0"; else $clear = ""; - if ($village->natar == 1 && $type == 40) $clear = ""; //fix by ronix + 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']; $database->query($q); @@ -3656,10 +3821,12 @@ class Automation { } private function updateHero() { + global $database, $hero_levels; + if(file_exists("GameEngine/Prevention/updatehero.txt")) { - unlink("GameEngine/Prevention/updatehero.txt"); + unlink("GameEngine/Prevention/updatehero.txt"); } - global $database,$hero_levels; + $harray = $database->getHero(); if(!empty($harray)){ // first of all, prepare all unit data at once for these heroes @@ -4394,22 +4561,6 @@ class Automation { } } - private function checkReviveHero(){ - global $database, $session; - $herodata = $database->getHero($session->uid, 1); - if ($herodata[0]['dead'] == 1){ - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET hero = 0 WHERE vref = ".(int) $session->villages[0].""); - } - if($herodata[0]['trainingtime'] <= time()) { - if($herodata[0]['trainingtime'] != 0) { - if($herodata[0]['dead'] == 0) { - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET trainingtime = '0' WHERE heroid = " . $herodata[0]['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $session->villages[0]); - } - } - } - } - /** * Function for automate medals - by yi12345 and Shadow * diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 8af1f5fe..5cd941df 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -1274,34 +1274,31 @@ class MYSQLi_DB implements IDbConnection { $count_while = 0; // random position on the map - used when generating farms via Admin - if (!$respect_gametime) { - $rand = rand(1,4); - } + if (!$respect_gametime) $rand = rand(1,4); while (!$num_rows) { if (!$mode) { $gamesday = time() - COMMENCE; - // TODO: scale these with game speed? - if ((!$respect_gametime && $rand === 1) || ($respect_gametime && $gamesday<3600*24*10 && $count_while==0)) { //10 day - $wide1=1; - $wide2=20; - } elseif ((!$respect_gametime && $rand === 2) || ($respect_gametime && $gamesday<3600*24*20 && $count_while==1)) { //20 day - $wide1=20; - $wide2=40; - } elseif ((!$respect_gametime && $rand === 3) || ($respect_gametime && $gamesday<3600*24*30 && $count_while==2)) { //30 day - $wide1=40; - $wide2=80; - } else { // over 30 day - $wide1=80; - $wide2=WORLD_MAX; - } - } - else { - $wide1=1; - $wide2=WORLD_MAX; + // TODO: scale these with game speed? + if((!$respect_gametime && $rand === 1) || ($respect_gametime && $gamesday < 3600 * 24 * 10 && $count_while == 0)){ // 10 day + $wide1 = 1; + $wide2 = 20; + }elseif((!$respect_gametime && $rand === 2) || ($respect_gametime && $gamesday < 3600 * 24 * 20 && $count_while == 1)){ // 20 day + $wide1 = 20; + $wide2 = 40; + }elseif((!$respect_gametime && $rand === 3) || ($respect_gametime && $gamesday < 3600 * 24 * 30 && $count_while == 2)){ // 30 day + $wide1 = 40; + $wide2 = 80; + }else{ // over 30 day + $wide1 = 80; + $wide2 = WORLD_MAX; + } + }else { + $wide1 = 1; + $wide2 = WORLD_MAX; } - switch($sector) { + switch($sector){ case 1: $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x < -$wide1 and x > -$wide2) and (y > $wide1 and y < $wide2) and occupied = 0"; //x- y+ break; @@ -1314,13 +1311,14 @@ class MYSQLi_DB implements IDbConnection { default: $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and (x > $wide1 and x < $wide2) and (y < -$wide1 and y > -$wide2) and occupied = 0"; //x+ y- } + $result = mysqli_query($this->dblink,$q); $num_rows = mysqli_num_rows($result); $count_while++; } $result = $this->mysqli_fetch_all($result); - $base = rand(0, ($num_rows-1)); + $base = rand(0, ($num_rows - 1)); return $result[$base]['id']; } @@ -1338,15 +1336,41 @@ class MYSQLi_DB implements IDbConnection { return mysqli_query($this->dblink,$q); } + /** + * Creates new villages + * + * @param array $villageArrays The array of the villages which have to be created + * @param int $uid The user ID + * @param string $username The username of the future owner + * @return array Returns the created villages ID + */ + + function generateVillages($villageArrays, $uid, $username){ + list($villageArrays, $uid, $username) = $this->escape_input($villageArrays, (int) $uid, $username); + + $wids = []; + foreach($villageArrays as $village){ + if($village['wid'] == 0) $village['wid'] = $this->generateBase($village['kid'], 0); + $this->addVillage($village['wid'], $uid, $username, $village['capital']); + $this->addResourceFields($village['wid'], $this->getVillageType($village['wid'])); + $wids[] = $village['wid']; + } + + $this->setFieldTaken($wids); + $this->addUnits($wids); + $this->addTech($wids); + $this->addABTech($wids); + + return count($wids) > 1 ? $wids : $wids[0]; + } + function addVillage($wid, $uid, $username, $capital) { list($wid, $uid, $username, $capital) = $this->escape_input((int) $wid, (int) $uid, $username, (int) $capital); - $total = count($this->getVillagesID($uid)); - if($total >= 1) { - $vname = $username . "\'s village " . ($total + 1); - } else { - $vname = $username . "\'s village"; - } + $total = count($this->getVillagesID($uid)); + if($total >= 1) $vname = $username . "\'s village " . ($total + 1); + else $vname = $username . "\'s village"; + $time = time(); $q = "INSERT into " . TB_PREFIX . "vdata (wref, owner, name, capital, pop, cp, celebration, wood, clay, iron, maxstore, crop, maxcrop, lastupdate, created) values ($wid, $uid, '$vname', $capital, 2, 1, 0, 750, 750, 750, ".STORAGE_BASE.", 750, ".STORAGE_BASE.", $time, $time)"; return mysqli_query($this->dblink,$q); @@ -1771,7 +1795,7 @@ class MYSQLi_DB implements IDbConnection { case 0: $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE owner IN(".implode(', ', $uid).") ORDER BY capital DESC,pop DESC"; break; - // villages where owner is a real player (i.e. not Natars etc.) + // capital villages where owner is a real player (i.e. not Natars etc.) case 1: $q = "SELECT * FROM " . TB_PREFIX . "vdata WHERE capital = 1 and owner > 5"; break; @@ -5688,7 +5712,7 @@ References: User ID/Message ID, Mode $vid[$index] = (int) $vidValue; } - $q = "INSERT into " . TB_PREFIX . "units (vref) values (".implode(', ', $vid).")"; + $q = "INSERT into " . TB_PREFIX . "units (vref) values (".implode('),(', $vid).")"; return mysqli_query($this->dblink,$q); } @@ -5873,7 +5897,7 @@ References: User ID/Message ID, Mode $vid[$index] = (int) $vidValue; } - $q = "INSERT INTO " . TB_PREFIX . "tdata (vref) VALUES (".implode(', ', $vid).")"; + $q = "INSERT INTO " . TB_PREFIX . "tdata (vref) VALUES (".implode('),(', $vid).")"; return mysqli_query($this->dblink,$q); } @@ -5887,7 +5911,7 @@ References: User ID/Message ID, Mode } self::$abTechCache = []; - $q = "INSERT INTO " . TB_PREFIX . "abdata (vref) VALUES (".implode(', ', $vid).")"; + $q = "INSERT INTO " . TB_PREFIX . "abdata (vref) VALUES (".implode('),(', $vid).")"; return mysqli_query($this->dblink,$q); } @@ -6081,12 +6105,12 @@ References: User ID/Message ID, Mode $units=''; $number = count($array_unit); foreach($array_unit as $unit){ - if($unit == 230){$unit = 30;} - if($unit == 231){$unit = 31;} - if($unit == 120){$unit = 20;} - if($unit == 121){$unit = 21;} - if($unit =="hero"){$unit = 'hero';} - else{$unit = 'u' . $unit;} + if($unit == 230) $unit = 30; + if($unit == 231) $unit = 31; + if($unit == 120) $unit = 20; + if($unit == 121) $unit = 21; + if($unit =="hero") $unit = 'hero'; + else $unit = 'u' . $unit; ++$i; //Fixed part of negative troops (double troops) - by InCube @@ -6953,11 +6977,208 @@ References: User ID/Message ID, Mode return $this->mysqli_fetch_all($result)[0]; } + /** + * Creates villages and puts the desired artifacts in it + * + * @param array $artifactArrays The array containing the artifacts to insert + * @param int $uid The owner's user ID (Natars) + */ + + function addArtifactVillages($artifactArrays, $uid = 3) { + list($artifactArrays, $uid) = $this->escape_input($artifactArrays, (int) $uid); + + foreach($artifactArrays as $desc => $artifactType){ + foreach($artifactType as $artifact){ + for($i = 0; $i < $artifact['quantity']; $i++){ + $kid = rand(1, 4); + $wid = $this->generateBase($kid, 1); + $this->addArtefact($wid, $uid, $artifact['type'], $artifact['size'], $artifact['name'], $desc, $artifact['effect'], "type".$artifact['img'].".gif"); + $this->setFieldTaken($wid); + $this->addVillage($wid, $uid, $artifact['vname'], 0); + $this->addResourceFields($wid, $this->getVillageType($wid)); + $this->addUnits($wid); + $this->addTech($wid); + $this->addABTech($wid); + + //Set the population to 163 and the name of the village + $this->setVillageFields($wid, ['pop', 'name'], [163, $artifact['vname']]); + + //Set the unit arrays (1, 2 or 4) + $multiplier = $artifact['size'] == 3 ? 4 : $artifact['size']; + $unitArrays = [41 => rand(1000 * $multiplier, 2000 * $multiplier) * NATARS_UNITS, + 42 => rand(1500 * $multiplier, 2000 * $multiplier) * NATARS_UNITS, + 43 => rand(2300 * $multiplier, 2800 * $multiplier) * NATARS_UNITS, + 44 => rand(25 * $multiplier, 75 * $multiplier) * NATARS_UNITS, + 45 => rand(1200 * $multiplier, 1900 * $multiplier) * NATARS_UNITS, + 46 => rand(1500 * $multiplier, 2000 * $multiplier) * NATARS_UNITS, + 47 => rand(500 * $multiplier, 900 * $multiplier) * NATARS_UNITS, + 48 => rand(100 * $multiplier, 300 * $multiplier) * NATARS_UNITS, + 49 => rand(1 * $multiplier, 5 * $multiplier) * NATARS_UNITS, + 50 => rand(1 * $multiplier, 5 * $multiplier) * NATARS_UNITS]; + + //Set the buildings and their levels + $buildingArrays = ["f22t" => 27, "f22" => ($artifact['size'] == 1 ? 10 : 20), "f28t" => 25, "f28" => 10, "f19t" => 23, "f19" => 10, "f32t" => 23, "f32" => 10]; + + $this->modifyUnit($wid, array_keys($unitArrays), array_values($unitArrays), [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]); + $this->setVillageLevel($wid, array_keys($buildingArrays), array_values($buildingArrays)); + } + } + } + } + + /** + * Display a system message to all players + * + * @param string $message The text of the system message that will be written and displayed to all players + */ + + function displaySystemMessage($message){ + list($message) = $this->escape_input($message); + global $autoprefix; + + $myFile = $autoprefix."Templates/text.tpl"; + $fh = fopen($myFile, 'w'); + $text = file_get_contents($autoprefix."Templates/text_format.tpl"); + $text = preg_replace("'%TEKST%'", $message, $text); + fwrite($fh, $text); + + //Set "OK" to 1 to all players, so they can visualize the message + $this->setUsersOk(); + } + + /** + * Called when Natars account has been created + * + * @param int $wid The village ID of the Natars' capital + */ + + function scoutAllPlayers($wid){ + list($wid) = $this->escape_input((int) $wid); + + $array = $this->getProfileVillages(0, 1); + $refs = []; + $vils = []; + + foreach($array as $vill){ + $refs[] = $this->addAttack($wid, 0, 0, 0, 1500 * NATARS_UNITS, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 0); + $vils[] = $vill['wref']; + } + + $type = []; + $from = []; + $to = []; + $ref = []; + $time = []; + $timeValue = time(); + $endtime = []; + $endtimeValue = $timeValue + round(10000 / SPEED); + $counter = 0; + + foreach ($refs as $index => $refID) { + $type[] = 3; + $from[] = $wid; + $to[] = $vils[$index]; + $ref[] = $refID; + $time[] = $timeValue; + $endtime[] = $endtimeValue; + + // limit the insert, so it can push through any reasonable network limits imposed + if (++$counter > 25) { + $this->addMovement($type, $from, $to, $ref, $time, $endtime); + + $type = []; + $from = []; + $to = []; + $ref = []; + $time = []; + $endtime = []; + $counter = 0; + } + } + + if ($counter > 0) $this->addMovement($type, $from, $to, $ref, $time, $endtime); + } + + /** + * Called when Natars account have to be created, creates his account and capital village + * + */ + + function createNatars(){ + + //Create the Natars account + $username = "Natars"; + $password = $this->getUserField(5, 'password', 0); + $email = "natars@noreply.com"; + $uid = 3; + $tribe = 5; + $desc = "*************************** + [#natars] + ***************************"; + + $q = "INSERT INTO ".TB_PREFIX."users (id, username, password, access, email, timestamp, tribe, protect, desc2) VALUES ('$uid', '$username', '$password', ".USER.", '$email', ".time().", $tribe, 0, '$desc')"; + mysqli_query($this->dblink, $q); + + //Coordinate arrays of possible villages + $arrayXY = [[WORLD_MAX, WORLD_MAX], + [WORLD_MAX, -WORLD_MAX], + [-WORLD_MAX, -WORLD_MAX], + [WORLD_MAX - 1, WORLD_MAX], + [WORLD_MAX, WORLD_MAX - 1], + [-WORLD_MAX, WORLD_MAX - 1], + [WORLD_MAX - 1, -WORLD_MAX], + [WORLD_MAX - 1, WORLD_MAX - 1], + [WORLD_MAX, -WORLD_MAX + 1], + [WORLD_MAX - 1, -WORLD_MAX + 1], + [-WORLD_MAX + 1, -WORLD_MAX + 1], + [WORLD_MAX - 2, WORLD_MAX], + [WORLD_MAX - 2, -WORLD_MAX], + [WORLD_MAX - 2, WORLD_MAX - 1], + [WORLD_MAX - 1, WORLD_MAX - 2], + [-WORLD_MAX + 2, WORLD_MAX], + [-WORLD_MAX + 2, WORLD_MAX - 1], + [-WORLD_MAX + 2, -WORLD_MAX + 2]]; + + //Search if there's one spot left + for($i = 0; $i <= 17; $i++){ + $wid = $this->getVilWref($arrayXY[$i][0], $arrayXY[$i][1]); + $status = $this->getVillageState($wid); + if($status == 0){ + //The village isn't taken, let's occupy it + $this->generateVillages([['wid' => $wid, 'kid' => 0, 'capital' => 1]], $uid, $username); + break; + } + } + + //All villages are taken, then select a random village + if($status > 0) $wid = $this->generateVillages([['wid' => 0, 'kid' => 0, 'capital' => 1]], $uid, $username); + + //Set the capital pop to 834 + $this->setVillageField($wid, 'pop', 834); + + //Scouts all players + $this->scoutAllPlayers($wid); + } + + /** + * Called when a system message is sent or Natars/Artifacts have been spawned + * + * @param int $value 1 to make a system message visible to all users, 0 to hide it + * @return bool Returns true if the query was successful, false otherwise + */ + + function setUsersOk($value = 1){ + list($value) = $this->escape_input((int) $value); + + $q = "UPDATE " . TB_PREFIX . "users SET ok = $value"; + return mysqli_query($this->dblink, $q); + } + function addArtefact($vref, $owner, $type, $size, $name, $desc, $effect, $img) { list($vref, $owner, $type, $size, $name, $desc, $effect, $img) = $this->escape_input($vref, $owner, $type, $size, $name, $desc, $effect, $img); $q = "INSERT INTO `" . TB_PREFIX . "artefacts` (`vref`, `owner`, `type`, `size`, `conquered`, `name`, `desc`, `effect`, `img`, `active`) VALUES ('$vref', '$owner', '$type', '$size', '" . time() . "', '$name', '$desc', '$effect', '$img', '0')"; - return mysqli_query($this->dblink,$q); + return mysqli_query($this->dblink, $q); } // no need to cache this method @@ -7139,16 +7360,31 @@ References: User ID/Message ID, Mode $q = "INSERT INTO " . TB_PREFIX . "artefacts_chrono (artefactid, uid, vref, conqueredtime) VALUES ('$artifactID', '$uid', '$vref', '$conqueredTime')"; return mysqli_query($this->dblink, $q); } - + /** - * - * @return bool Returns if artefacts are already out or not + * @param bool $mode true: check if WW Building plans are already out, false: check if artifacts are already out + * @return int Returns if artifacts are already out or not */ - function areArtifactsSpawned(){ - $q = "SELECT Count(*) as Total FROM ".TB_PREFIX."artefacts LIMIT 1"; - $result = mysqli_fetch_array(mysqli_query($this->dblink, $q), MYSQLI_ASSOC); - return $result['Total'] > 0; + function areArtifactsSpawned($mode = false){ + list($mode) = $this->escape_input($mode); + + $q = "SELECT 1 FROM ".TB_PREFIX."artefacts".($mode ? " WHERE type = 11" : ""); + $result = mysqli_fetch_array(mysqli_query($this->dblink, $q), MYSQLI_ASSOC); + return $result; + } + + + /** + * Check if WW villages are already out or not + * + * @return int Returns if artifacts are already out or not + */ + + function areWWVillagesSpawned(){ + $q = "SELECT 1 FROM ".TB_PREFIX."vdata WHERE natar = 1"; + $result = mysqli_fetch_array(mysqli_query($this->dblink, $q), MYSQLI_ASSOC); + return $result; } /** diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php index e98a06c0..499caf54 100755 --- a/GameEngine/Lang/en.php +++ b/GameEngine/Lang/en.php @@ -707,6 +707,7 @@ define("WEST","West"); //other define("VILLAGE","Village"); define("OASIS","Oasis"); +define("NO_OASIS", "You do not own any oases."); define("PLAYER","Player"); //LOGIN.php @@ -987,7 +988,7 @@ define("PALACE_DESC","The king or queen of the empire lives in the palace. Only define("TREASURY","Treasury"); define("ARTIFACTS_AREA","Artefacts in your area"); -define("NO_ARTIFACTS_AREA","There is no artefacts in your area."); +define("NO_ARTIFACTS_AREA","There are no artefacts in your area."); define("OWN_ARTIFACTS","Own artefacts"); define("CONQUERED","Conquered"); define("DISTANCE","Distance"); @@ -995,13 +996,14 @@ define("EFFECT","Effect"); define("ACCOUNT","Account"); define("SMALL_ARTIFACTS","Small artefacts"); define("LARGE_ARTIFACTS","Large artefacts"); -define("NO_ARTIFACTS","There is no artefacts."); +define("NO_ARTIFACTS","There are no artefacts."); define("ANY_ARTIFACTS","You do not own any artefacts."); define("OWNER","Owner"); define("AREA_EFFECT","Area of effect"); define("REQUIRED_LEVEL","Required level"); define("TIME_CONQUER","Time of conquer"); define("TIME_ACTIVATION","Time of activation"); +define("NEXT_EFFECT"," Next effect"); define("FORMER_OWNER","Former owner(s)"); define("BUILDING_STRONGER","Building stronger with"); define("BUILDING_WEAKER","Building weaker with"); diff --git a/GameEngine/Technology.php b/GameEngine/Technology.php index a2fe6086..3e8ece38 100755 --- a/GameEngine/Technology.php +++ b/GameEngine/Technology.php @@ -40,9 +40,7 @@ class Technology { global $village; $holder = []; foreach($village->researching as $research) { - if(substr($research['tech'], 0, 1) == "t"){ - array_push($holder,$research); - } + if(substr($research['tech'], 0, 1) == "t") array_push($holder, $research); } return $holder; } @@ -51,29 +49,27 @@ class Technology { global $village; $holder = []; foreach($village->researching as $research) { - if(substr($research['tech'],0,1) == $type){ - array_push($holder,$research); - } + if(substr($research['tech'], 0, 1) == $type) array_push($holder, $research); } return $holder; } - public function isResearch($tech,$type) { + public function isResearch($tech, $type) { global $village; - if(count($village->researching) == 0) { - return false; - } - else { + + if(count($village->researching) == 0) return false; + else + { switch($type) { case 1: $string = "t"; break; case 2: $string = "a"; break; case 3: $string = "b"; break; } + foreach($village->researching as $research) { - if($research['tech'] == $string.$tech) { - return true; - } + if($research['tech'] == $string.$tech) return true; } + return false; } } @@ -435,24 +431,26 @@ class Technology { for ($i = $start; $i <= $end; $i ++) { $k = $i - $start + 1; - $unit = $prisoners == 0 ? "u" . $i : "t" . $k; + + $unit = "u".$i; + $index = $prisoners == 0 ? $unit : "t".$k; global $$unit; $dataarray = $$unit; if($horsedrinking > 0) { if (($i == 4 && $horsedrinking >= 10) || ($i == 5 && $horsedrinking >= 15) || ( $i == 6 && $horsedrinking == 20)) { - $upkeep += ($dataarray['pop'] - 1) * $array[$unit]; + $upkeep += ($dataarray['pop'] - 1) * $array[$index]; } - else $upkeep += ($dataarray['pop'] * $array[$unit]); + else $upkeep += ($dataarray['pop'] * $array[$index]); } - else $upkeep += ($dataarray['pop'] * $array[$unit]); + else $upkeep += ($dataarray['pop'] * $array[$index]); } - $unit = ($prisoners > 0) ? 't11' : 'hero'; + $index = $prisoners > 0 ? 't11' : 'hero'; - if(!isset($array[$unit])) $array[$unit] = 0; - $upkeep += $array[$unit] * 6; + if(!isset($array[$index])) $array[$index] = 0; + $upkeep += $array[$index] * 6; $who = $database->getVillageField($vid, "owner"); return ceil($database->getArtifactsValueInfluence($who, $vid, 4, $upkeep, false)); diff --git a/Templates/Build/12_upgrades.tpl b/Templates/Build/12_upgrades.tpl index 552bfaad..bf6e272b 100644 --- a/Templates/Build/12_upgrades.tpl +++ b/Templates/Build/12_upgrades.tpl @@ -80,20 +80,19 @@ if($totalUps > 0) { echo ""; - $timer = 1; foreach($ABups as $black) { - $ABUnit = substr($black['tech'],1,2); + $count++; + $ABUnit = substr($black['tech'], 1, 2); $abdata['b'.$ABUnit]++; - $unit = ($session->tribe-1)*10 + $ABUnit; + $unit = ($session->tribe - 1) * 10 + $ABUnit; echo ""; - echo ""; + echo ""; $date = $generator->procMtime($black['timestamp']); echo ""; echo ""; - $timer +=1; } echo "
".UPGRADING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit); echo " (".LEVEL." ".$abdata['b'.$ABUnit].")"; - if($timer > 1) echo " ".WAITING.""; + if($count > 1) echo " ".WAITING.""; echo "".$generator->getTimeFormat($black['timestamp']-time())."timer."\">".$generator->getTimeFormat($black['timestamp']-time())."".$date[1]." hrs
"; } diff --git a/Templates/Build/13_upgrades.tpl b/Templates/Build/13_upgrades.tpl index 4d98cae5..adb4090c 100644 --- a/Templates/Build/13_upgrades.tpl +++ b/Templates/Build/13_upgrades.tpl @@ -80,20 +80,19 @@ if($totalUps > 0) { echo ""; - $timer = 1; foreach($ABups as $arms) { - $ABUnit = substr($arms['tech'],1,2); - $abdata['a'.$ABUnit]++; - $unit = ($session->tribe-1)*10 + $ABUnit; + $count++; + $ABUnit = substr($arms['tech'], 1, 2); + $abdata['a' . $ABUnit]++; + $unit = ($session->tribe - 1) * 10 + $ABUnit; echo ""; - echo ""; + echo ""; $date = $generator->procMtime($arms['timestamp']); echo ""; echo ""; - $timer +=1; } echo "
".UPGRADING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit); echo " (".LEVEL." ".$abdata['a'.$ABUnit].")"; - if($timer > 1) echo " ".WAITING.""; + if($count > 1) echo " ".WAITING.""; echo "".$generator->getTimeFormat($arms['timestamp']-time())."timer."\">".$generator->getTimeFormat($arms['timestamp']-time())."".$date[1]." hrs
"; } diff --git a/Templates/Build/16.tpl b/Templates/Build/16.tpl index 6282abab..76bfd15f 100644 --- a/Templates/Build/16.tpl +++ b/Templates/Build/16.tpl @@ -1,310 +1,313 @@ unitarray = $database->getUnit($village->wid, false); - } -?>
-

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

-

+if(isset($_GET['refresh'])){ + $village->unitarray = $database->getUnit($village->wid, false); +} +?>
+ +

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

+

getMovement("34",$village->wid,1); -$settlers = $database->getMovement("7",$village->wid,1); +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)); + $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; +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 or $settlers_incoming > 0 or $oasis_incoming > 0){ -?> +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 "
vname; ?> + +
-"; - $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")."\">".TROOPSFROM." ".$database->getUserField($database->getVillageField($enforce['from'],"owner"),"username",0)." "; - }else{ echo "getVillageField($enforce['from'],"owner")."\">".$database->getUserField($database->getVillageField($enforce['from'],"owner"),"username",0)." ".TROOPSFROM.""; -} - 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 "
+include ("16_troops.tpl"); +?> + +
+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")."\">".TROOPSFROM." ".$database->getUserField($database->getVillageField($enforce['from'], "owner"), "username", 0)." "; + }else{ + echo "getVillageField($enforce['from'], "owner")."\">".$database->getUserField($database->getVillageField($enforce['from'], "owner"), "username", 0)." ".TROOPSFROM.""; + } + 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."
"; - } -} + echo " ".VILLAGE_OF_THE_ELDERS_TROOPS.""; + echo ""; + $tribe = 4; + $start = ($tribe - 1) * 10 + 1; + $end = ($tribe * 10); + echo " "; + for($i = $start; $i <= ($end); $i++){ + echo "getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />"; + } + if($enforce['hero'] != 0){ + echo "\"Hero\""; + } + echo "".TROOPS.""; + for($i = $start; $i <= ($start + 9); $i++){ + if($enforce['u'.$i] == 0){ + echo ""; + }else{ + echo ""; + } + echo $enforce['u'.$i].""; + } + if($enforce['hero'] != 0){ + echo "".$enforce['hero'].""; + } + echo " +".UPKEEP."
".$technology->getUpkeep($enforce, $tribe)."\"Crop\"".PER_HR."
".SEND_BACK."
"; + echo ""; + } + } } $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); - } +$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($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 " +if(count($enforcevill) > 0){ + echo "

".TROOPS_IN_OTHER_VILLAGE."

"; + foreach($enforcevill as $enforce){ + $colspan = 10 + $enforce['hero']; + echo "
-getMapCheck($enforce['from'])."\">".$database->getVillageField($enforce['from'],"name")."
"; - $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 ""; + echo "getMapCheck($enforce['vref'])."\">".REINFORCEMENTFOR." ".$database->getVillageField($enforce['vref'], "name")." "; + 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]."
 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($enforce['hero']!=0){ - echo "".$enforce['hero'].""; - } -echo " -".UPKEEP."
".$technology->getUpkeep($enforce,$tribe)."\"Crop\"".PER_HR."
"; -echo ""; -} -} -if(count($enforceoasis) > 0) { - echo "

".TROOPS_IN_OASIS."

"; - foreach($enforceoasis as $enforce) { - $colspan = 10+$enforce['hero']; - echo " +if(count($enforceoasis) > 0){ + echo "

".TROOPS_IN_OASIS."

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

".PRISONERS."

"; - foreach($database->getPrisoners3($village->wid) as $prisoners) { - $colspan = 10+$prisoners['t11']; - $colspan2 = $colspan + 1; - echo " +if(count($database->getPrisoners3($village->wid)) > 0){ + echo "

".PRISONERS."

"; + foreach($database->getPrisoners3($village->wid) as $prisoners){ + $colspan = 10 + $prisoners['t11']; + $colspan2 = $colspan + 1; + echo "
-getMapCheck($prisoners['wref'])."\">".$database->getVillageField($prisoners['wref'],"name")."
"; - $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 ""; + echo "getMapCheck($prisoners['wref'])."\">".PRISONERSIN." ".$database->getVillageField($prisoners['wref'], "name").""; + 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]."
 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($prisoners['t11']!=0){ - echo "".$prisoners['t11'].""; - } -echo " -".UPKEEP."
".$technology->getUpkeep($prisoners,$tribe,0,1)."\"Crop\"".PER_HR."
"; -echo ""; -} -} -if(count($database->getPrisoners($village->wid)) > 0) { - echo "

".PRISONERS."

"; - foreach($database->getPrisoners($village->wid) as $prisoners) { - $colspan = 10 + $prisoners['t11']; - $colspan2 = $colspan + 1; - echo " +if(count($database->getPrisoners($village->wid)) > 0){ + echo "

".PRISONERS."

"; + foreach($database->getPrisoners($village->wid) as $prisoners){ + $colspan = 10 + $prisoners['t11']; + $colspan2 = $colspan + 1; + echo "
-getMapCheck($prisoners['from'])."\">".$database->getVillageField($prisoners['from'],"name")."
"; - $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'])."\">".PRISONERSFROM." ".$database->getVillageField($prisoners['from'], "name").""; + 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']."
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
".TROOPS.""; + } + else echo ""; + echo $prisoners['t'.$i]."".$prisoners['t11']."
\"Crop\"
"; -} + echo ""; + } } ?> getMovement("3",$village->wid,0); -$settlers = $database->getMovement("5",$village->wid,0); +$units_type = $database->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; +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"); + echo "

".TROOPS_ON_THEIR_WAY."

"; + include ("16_walking.tpl"); } -include("upgrade.tpl"); +include ("upgrade.tpl"); ?> -

\ No newline at end of file +

+
\ No newline at end of file diff --git a/Templates/Build/19.tpl b/Templates/Build/19.tpl index 565d8d7d..14163255 100644 --- a/Templates/Build/19.tpl +++ b/Templates/Build/19.tpl @@ -24,7 +24,6 @@ } $trainlist = $technology->getTrainingList(1); if(count($trainlist) > 0) { - //$timer = 2*count($trainlist); echo " @@ -41,7 +40,7 @@ echo $train['amt']." ".$train['name']." +
"; if ($TrainCount == 1 ) { $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "".$generator->getTimeFormat($train['timestamp']-time()).""; + echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; } else { echo $generator->getTimeFormat($train['eachtime']*$train['amt']); } @@ -52,9 +51,9 @@ } echo $time[1]; } ?> -
-

+

\ No newline at end of file diff --git a/Templates/Build/20.tpl b/Templates/Build/20.tpl index 0c854a89..d1a165c9 100644 --- a/Templates/Build/20.tpl +++ b/Templates/Build/20.tpl @@ -52,7 +52,7 @@ echo $train['amt']." ".$train['name'].""; if ($TrainCount == 1) { $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "".$generator->getTimeFormat($train['timestamp']-time()).""; + echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; } else { echo $generator->getTimeFormat($train['eachtime']*$train['amt']); } @@ -63,7 +63,7 @@ } echo $time[1]; } ?> - + diff --git a/Templates/Build/21.tpl b/Templates/Build/21.tpl index 32f3259b..525d0d63 100644 --- a/Templates/Build/21.tpl +++ b/Templates/Build/21.tpl @@ -93,7 +93,7 @@ echo $train['amt']." ".$train['name'].""; if ($TrainCount == 1 ) { $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "".$generator->getTimeFormat($train['timestamp']-time()).""; + echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; } else { echo $generator->getTimeFormat($train['eachtime']*$train['amt']); } @@ -104,7 +104,7 @@ } echo $time[1]; } ?> - + 0) { if(count($acares) > 0) { echo ""; - $timer = 1; foreach($acares as $aca) { $unit = substr($aca['tech'],1,2); echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; + echo ""; + $date = $generator->procMtime($aca['timestamp']); + echo ""; echo ""; - $timer +=1; } echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrstimer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; } diff --git a/Templates/Build/22_2.tpl b/Templates/Build/22_2.tpl index ed850bfa..f4ff9597 100644 --- a/Templates/Build/22_2.tpl +++ b/Templates/Build/22_2.tpl @@ -137,15 +137,13 @@ echo "
".RESEARCH_AVAILABL if(count($acares) > 0) { echo ""; - $timer = 1; foreach($acares as $aca) { $unit = substr($aca['tech'],1,2); echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; + echo ""; + $date = $generator->procMtime($aca['timestamp']); + echo ""; echo ""; - $timer +=1; } echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrstimer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; } diff --git a/Templates/Build/22_3.tpl b/Templates/Build/22_3.tpl index 6b1f568a..8fb6ffa0 100644 --- a/Templates/Build/22_3.tpl +++ b/Templates/Build/22_3.tpl @@ -140,15 +140,13 @@ $acares = $technology->grabAcademyRes(); if(count($acares) > 0) { echo ""; - $timer = 1; foreach($acares as $aca) { $unit = substr($aca['tech'],1,2); echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; + echo ""; + $date = $generator->procMtime($aca['timestamp']); + echo ""; echo ""; - $timer +=1; } echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrstimer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; } diff --git a/Templates/Build/22_4.tpl b/Templates/Build/22_4.tpl index cd52bb36..e97e1148 100644 --- a/Templates/Build/22_4.tpl +++ b/Templates/Build/22_4.tpl @@ -134,15 +134,13 @@ echo "
".RESEARCH_AVAILABL if(count($acares) > 0) { echo ""; - $timer = 1; foreach($acares as $aca) { $unit = substr($aca['tech'],1,2); echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; + echo ""; + $date = $generator->procMtime($aca['timestamp']); + echo ""; echo ""; - $timer +=1; } echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrstimer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; } diff --git a/Templates/Build/22_5.tpl b/Templates/Build/22_5.tpl index b3768776..4c102a96 100644 --- a/Templates/Build/22_5.tpl +++ b/Templates/Build/22_5.tpl @@ -130,15 +130,13 @@ echo "
".RESEARCH_AVAILABL if(count($acares) > 0) { echo ""; - $timer = 1; foreach($acares as $aca) { $unit = substr($aca['tech'],1,2); echo ""; - echo ""; - $date = $generator->procMtime($aca['timestamp']); - echo ""; + echo ""; + $date = $generator->procMtime($aca['timestamp']); + echo ""; echo ""; - $timer +=1; } echo "
".RESEARCHING."".DURATION."".COMPLETE."
\"".$technology-getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit)."".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrstimer."\">".$generator->getTimeFormat($aca['timestamp']-time())."".$date[1]." hrs
"; } diff --git a/Templates/Build/24_2.tpl b/Templates/Build/24_2.tpl index ef25aea0..f2ff076b 100644 --- a/Templates/Build/24_2.tpl +++ b/Templates/Build/24_2.tpl @@ -1,18 +1,14 @@ getVillageField($village->wid, 'celebration'); - if($timeleft > Time()){ + if($timeleft > time()){ echo '
'; echo ''; echo '"; echo ""; echo "
'; echo 'celebration still needs:'; - echo ""; - echo $generator->getTimeFormat($timeleft-time()); + echo "timer."\">"; + echo $generator->getTimeFormat($timeleft - time()); echo " hrs.done at ".date('H:i', $timeleft)."
"; - $timer +=1; } ?> \ No newline at end of file diff --git a/Templates/Build/25_progress.tpl b/Templates/Build/25_progress.tpl index 212c4df0..8b1baf41 100644 --- a/Templates/Build/25_progress.tpl +++ b/Templates/Build/25_progress.tpl @@ -17,7 +17,7 @@ echo $train['amt']." ".$train['name'].""; if ($TrainCount == 1 ) { $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "".$generator->getTimeFormat($train['timestamp']-time()).""; + echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; } else { echo $generator->getTimeFormat($train['eachtime']*$train['amt']); } @@ -28,7 +28,7 @@ } echo $time[1]; } ?> - + diff --git a/Templates/Build/26_progress.tpl b/Templates/Build/26_progress.tpl index 212c4df0..8b1baf41 100644 --- a/Templates/Build/26_progress.tpl +++ b/Templates/Build/26_progress.tpl @@ -17,7 +17,7 @@ echo $train['amt']." ".$train['name'].""; if ($TrainCount == 1 ) { $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "".$generator->getTimeFormat($train['timestamp']-time()).""; + echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; } else { echo $generator->getTimeFormat($train['eachtime']*$train['amt']); } @@ -28,7 +28,7 @@ } echo $time[1]; } ?> - + diff --git a/Templates/Build/27_show.tpl b/Templates/Build/27_show.tpl index 3fca5cab..fca0e1ca 100644 --- a/Templates/Build/27_show.tpl +++ b/Templates/Build/27_show.tpl @@ -1,5 +1,10 @@ getArtefactDetails($_GET['show']); +if(empty($artefact)){ + header("location: build.php?gid=27"); + exit; +} + if($artefact['size'] == 1 && $artefact['type'] != 11){ $reqlvl = 10; $effect = VILLAGE; @@ -9,11 +14,17 @@ if($artefact['size'] == 1 && $artefact['type'] != 11){ } $activationTime = 86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED)); +$time = time(); +$nextEffect = "-"; if($artefact['owner'] == 3) $active = "-"; -elseif(!$artefact['active'] && $artefact['conquered'] < time() - $activationTime) $active = "Can't be activated"; +elseif(!$artefact['active'] && $artefact['conquered'] < $time - $activationTime) $active = "Can't be activated"; elseif (!$artefact['active']) $active = date("Y-m-d H:i:s", $artefact['conquered'] + $activationTime); -else $active = "".ACTIVE.""; +else +{ + $active = "".ACTIVE.""; + $nextEffect = date("Y-m-d H:i:s", $artefact['lastupdate'] + (86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED)))); +} //// Added by brainiac - thank you if ($artefact['type'] == 8) @@ -120,6 +131,14 @@ $bonus = isset($betterorbadder) ? $betterorbadder." (".str_replace(["(", ")"] + + + + + + + + diff --git a/Templates/Build/29.tpl b/Templates/Build/29.tpl index f8757b2c..2fdb70c6 100644 --- a/Templates/Build/29.tpl +++ b/Templates/Build/29.tpl @@ -40,7 +40,7 @@ echo $train['amt']." ".$train['name']." +
"; if ($TrainCount == 1 ) { $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "".$generator->getTimeFormat($train['timestamp']-time()).""; + echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; } else { echo $generator->getTimeFormat($train['eachtime']*$train['amt']); } @@ -51,7 +51,7 @@ } echo $time[1]; } ?> -
"; if ($TrainCount == 1 ) { $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "".$generator->getTimeFormat($train['timestamp']-time()).""; + echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; } else { echo $generator->getTimeFormat($train['eachtime']*$train['amt']); } @@ -51,7 +51,7 @@ } echo $time[1]; } ?> - + - ".HERO_READY."" . $timeleft . ""; ?> + ".HERO_READY."timer.">" . $timeleft . ""; ?> diff --git a/Templates/Build/37_land.tpl b/Templates/Build/37_land.tpl index c7bb8299..44a9c609 100644 --- a/Templates/Build/37_land.tpl +++ b/Templates/Build/37_land.tpl @@ -27,8 +27,8 @@ if($session->access != BANNED){ getCoor($oasisarray[$i]['wref']); ?> @@ -78,6 +78,13 @@ if($session->access != BANNED){ } ?> - + + + + + \ No newline at end of file diff --git a/Templates/Build/37_revive.tpl b/Templates/Build/37_revive.tpl index 622970a7..26e5dd00 100644 --- a/Templates/Build/37_revive.tpl +++ b/Templates/Build/37_revive.tpl @@ -6,22 +6,6 @@ getOwnUniqueArtefactInfo2($session->uid,5,3,0)); - $artefact1 = count($database->getOwnUniqueArtefactInfo2($village->wid,5,1,1)); - $artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,5,2,0)); - if($artefact > 0){ - $artefact_bonus = 2; - $artefact_bonus2 = 1; - }else if($artefact1 > 0){ - $artefact_bonus = 2; - $artefact_bonus2 = 1; - }else if($artefact2 > 0){ - $artefact_bonus = 4; - $artefact_bonus2 = 3; - }else{ - $artefact_bonus = 1; - $artefact_bonus2 = 1; - } /*-------------------------------------------------------*\ | ********* DO NOT REMOVE THIS COPYRIGHT NOTICE ********* | +---------------------------------------------------------+ @@ -31,69 +15,63 @@ \*-------------------------------------------------------*/ // check if there is a hero in revive already - $reviving = false; - $training = false; + $reviving = $training = false; foreach ($heroes as $hero_datarow) { - if ($hero_datarow['inrevive']) { - $reviving = true; - } - - if ($hero_datarow['intraining']) { - $training = true; - } + if ($hero_datarow['inrevive']) $reviving = true; + if ($hero_datarow['intraining']) $training = true; } foreach ($heroes as $hero_datarow) { - - if($hero_datarow['unit'] == 1) { - $name = U1; - } else if($hero_datarow['unit'] == 2) { - $name = U2; - } else if($hero_datarow['unit'] == 3) { - $name = U3; - } else if($hero_datarow['unit'] == 5) { - $name = U5; - } else if($hero_datarow['unit'] == 6) { - $name = U6; - } else if($hero_datarow['unit'] == 11) { - $name = U11; - } else if($hero_datarow['unit'] == 12) { - $name = U12; - } else if($hero_datarow['unit'] == 13) { - $name = U13; - } else if($hero_datarow['unit'] == 15) { - $name = U15; - } else if($hero_datarow['unit'] == 16) { - $name = U16; - } else if($hero_datarow['unit'] == 21) { - $name = U21; - } else if($hero_datarow['unit'] == 22) { - $name = U22; - } else if($hero_datarow['unit'] == 24) { - $name = U24; - } else if($hero_datarow['unit'] == 25) { - $name = U25; - } else if($hero_datarow['unit'] == 26) { - $name = U26; - } - if($hero_datarow['level'] <= 60){ - $wood = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['wood']); - $clay = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['clay']); - $iron = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['iron']); - $crop = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['crop']); - $timeToTrain = round((${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['time']) / SPEED * $artefact_bonus2 / $artefact_bonus); - $training_time = $generator->getTimeFormat($timeToTrain); - $training_time2 = time() + $timeToTrain; - }else{ - $wood = (${'h'.$hero_datarow['unit'].'_full'}[60]['wood']); - $clay = (${'h'.$hero_datarow['unit'].'_full'}[60]['clay']); - $iron = (${'h'.$hero_datarow['unit'].'_full'}[60]['iron']); - $crop = (${'h'.$hero_datarow['unit'].'_full'}[60]['crop']); - $timeToTrain = round((${'h'.$hero_datarow['unit'].'_full'}[60]['time']) / SPEED * $artefact_bonus2 / $artefact_bonus); - $training_time = $generator->getTimeFormat($timeToTrain); - $training_time2 = time() + $timeToTrain; - } + if($hero_datarow['unit'] == 1){ + $name = U1; + }else if($hero_datarow['unit'] == 2){ + $name = U2; + }else if($hero_datarow['unit'] == 3){ + $name = U3; + }else if($hero_datarow['unit'] == 5){ + $name = U5; + }else if($hero_datarow['unit'] == 6){ + $name = U6; + }else if($hero_datarow['unit'] == 11){ + $name = U11; + }else if($hero_datarow['unit'] == 12){ + $name = U12; + }else if($hero_datarow['unit'] == 13){ + $name = U13; + }else if($hero_datarow['unit'] == 15){ + $name = U15; + }else if($hero_datarow['unit'] == 16){ + $name = U16; + }else if($hero_datarow['unit'] == 21){ + $name = U21; + }else if($hero_datarow['unit'] == 22){ + $name = U22; + }else if($hero_datarow['unit'] == 24){ + $name = U24; + }else if($hero_datarow['unit'] == 25){ + $name = U25; + }else if($hero_datarow['unit'] == 26){ + $name = U26; + } + + if($hero_datarow['level'] <= 60){ + $wood = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['wood']); + $clay = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['clay']); + $iron = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['iron']); + $crop = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['crop']); + $timeToTrain = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['time']) / SPEED); + $training_time = $generator->getTimeFormat($timeToTrain); + $training_time2 = time() + $timeToTrain; + }else{ + $wood = (${'h'.$hero_datarow['unit'].'_full'}[60]['wood']); + $clay = (${'h'.$hero_datarow['unit'].'_full'}[60]['clay']); + $iron = (${'h'.$hero_datarow['unit'].'_full'}[60]['iron']); + $crop = (${'h'.$hero_datarow['unit'].'_full'}[60]['crop']); + $timeToTrain = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, (${'h'.$hero_datarow['unit'].'_full'}[60]['time']) / SPEED); + $training_time = $generator->getTimeFormat($timeToTrain); + $training_time2 = time() + $timeToTrain; + } if($hero_datarow['inrevive'] == 1) { $timeleft = $generator->getTimeFormat($hero_datarow['trainingtime'] - time()); @@ -101,7 +79,7 @@ - "; ?> + "; ?> @@ -117,12 +95,12 @@
".HERO_READY." " . $timeleft . "
".HERO_READY." timer.">".$timeleft."
- +
<?php echo $name; ?> - +
Wood| @@ -142,15 +120,15 @@
-
+ awood < $wood OR $village->aclay < $clay OR $village->airon < $iron OR $village->acrop < $crop) { + if($village->awood < $wood || $village->aclay < $clay || $village->airon < $iron || $village->acrop < $crop) { echo "".NOT."".ENOUGH_RESOURCES.""; }else { echo "".REVIVE.""; } - ?>
+ ?> @@ -160,7 +138,7 @@
<?php echo $name; ?> - +
Wood| @@ -180,16 +158,16 @@
-
+ awood < $wood OR $village->aclay < $clay OR $village->airon < $iron OR $village->acrop < $crop) { + if($village->awood < $wood || $village->aclay < $clay || $village->airon < $iron || $village->acrop < $crop) { echo "".NOT."".ENOUGH_RESOURCES.""; }else { echo "".REVIVE.""; } ?> -
+ access != BANNED){ mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."hero SET `inrevive` = '1', `trainingtime` = '".(int) $training_time2."', `wref` = '".(int) $village->wid."' WHERE `heroid` = ".(int) $_GET['hid']." AND `uid` = '".(int) $session->uid."'"); - mysqli_query($database->dblink," - UPDATE " . TB_PREFIX . "vdata - SET - `wood` = `wood` - ".(int) $wood.", - `clay` = `clay` - ".(int) $clay.", - `iron` = `iron` - ".(int) $iron .", - `crop` = `crop` - ".(int) $crop." - WHERE - `wref` = '" . (int) $village->wid . "'"); + $database->modifyResource($village->wid, $wood, $clay, $iron, $crop, 0); header("Location: build.php?id=".$id.""); exit; } else { @@ -214,15 +184,11 @@ exit; } } - - } ?> - +
\ No newline at end of file diff --git a/Templates/Build/37_train.tpl b/Templates/Build/37_train.tpl index 92c69170..c810f67c 100644 --- a/Templates/Build/37_train.tpl +++ b/Templates/Build/37_train.tpl @@ -15,23 +15,6 @@ ## ## ################################################################################# - $artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,5,3,0)); - $artefact1 = count($database->getOwnUniqueArtefactInfo2($village->wid,5,1,1)); - $artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,5,2,0)); - if($artefact > 0){ - $artefact_bonus = 2; - $artefact_bonus2 = 1; - }else if($artefact1 > 0){ - $artefact_bonus = 2; - $artefact_bonus2 = 1; - }else if($artefact2 > 0){ - $artefact_bonus = 4; - $artefact_bonus2 = 3; - }else{ - $artefact_bonus = 1; - $artefact_bonus2 = 1; - } - //check if there is unit needed in the village $result = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."units WHERE `vref` = ".(int) $village->wid.""); @@ -63,7 +46,7 @@ if($session->tribe == 1) { \"Crop\"".$u1['crop']."| \"Crop6| \"Duration\""; - $output.=$generator->getTimeFormat(round($u1['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $output .= $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5,$u1['time'] / SPEED)*3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u1['wood'] + $u1['clay'] + $u1['iron'] + $u1['crop']); @@ -102,7 +85,7 @@ if($session->tribe == 1) { \"Crop\"".$u2['crop']."| \"Crop6| \"Duration\""; - $output.=$generator->getTimeFormat(round($u2['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $output.=$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u2['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u2['wood'] + $u2['clay'] + $u2['iron'] + $u2['crop']); @@ -142,7 +125,7 @@ if($session->tribe == 1) { \"Crop6| \"Duration\""; - $output.= $generator->getTimeFormat(round($u3['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $output.= $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u3['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u3['wood'] + $u3['clay'] + $u3['iron'] + $u3['crop']); @@ -180,7 +163,7 @@ if($session->tribe == 1) { \"Crop\"".$u5['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u5['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u5['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u5['wood'] + $u5['clay'] + $u5['iron'] + $u5['crop']); @@ -219,7 +202,7 @@ if($session->tribe == 1) { \"Crop\"".$u6['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u6['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u6['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u6['wood'] + $u6['clay'] + $u6['iron'] + $u6['crop']); @@ -261,7 +244,7 @@ $output.=" \"Crop\"".$u11['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u11['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u11['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u11['wood'] + $u11['clay'] + $u11['iron'] + $u11['crop']); @@ -300,7 +283,7 @@ $output.=" \"Crop\"".$u12['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u12['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u12['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u12['wood'] + $u12['clay'] + $u12['iron'] + $u12['crop']); @@ -341,7 +324,7 @@ $output.=" \"Crop6| \"Duration\""; - $generator->getTimeFormat(round($u13['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u13['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u13['wood'] + $u13['clay'] + $u13['iron'] + $u13['crop']); @@ -380,7 +363,7 @@ $output.=" \"Crop\"".$u15['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u15['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u15['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u15['wood'] + $u15['clay'] + $u15['iron'] + $u15['crop']); @@ -420,7 +403,7 @@ $output.=" \"Crop\"".$u16['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u16['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u16['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u16['wood'] + $u16['clay'] + $u16['iron'] + $u16['crop']); @@ -462,7 +445,7 @@ $output.=" \"Crop\"".$u21['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u21['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u21['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u21['wood'] + $u21['clay'] + $u21['iron'] + $u21['crop']); @@ -501,7 +484,7 @@ $output.=" \"Crop\"".$u22['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u22['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u22['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u22['wood'] + $u22['clay'] + $u22['iron'] + $u22['crop']); @@ -541,7 +524,7 @@ $output.=" \"Crop\"".$u24['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u24['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u24['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u24['wood'] + $u24['clay'] + $u24['iron'] + $u24['crop']); @@ -580,7 +563,7 @@ $output.=" \"Crop\"".$u25['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u25['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u25['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u25['wood'] + $u25['clay'] + $u25['iron'] + $u25['crop']); @@ -620,7 +603,7 @@ $output.=" \"Crop\"".$u26['crop']."| \"Crop6| \"Duration\"". - $generator->getTimeFormat(round($u26['time'] / SPEED * $artefact_bonus2 / $artefact_bonus)*3); + $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u26['time'] / SPEED) * 3); //-- If available resources combined are not enough, remove NPC button $total_required = (int)($u26['wood'] + $u26['clay'] + $u26['iron'] + $u26['crop']); diff --git a/Templates/Build/42.tpl b/Templates/Build/42.tpl index 0dde9ef7..879d2cb3 100644 --- a/Templates/Build/42.tpl +++ b/Templates/Build/42.tpl @@ -40,7 +40,7 @@ echo $train['amt']." ".$train['name'].""; if ($TrainCount == 1 ) { $NextFinished = $generator->getTimeFormat($train['timestamp2']-time()); - echo "".$generator->getTimeFormat($train['timestamp']-time()).""; + echo "timer.">".$generator->getTimeFormat($train['timestamp']-time()).""; } else { echo $generator->getTimeFormat($train['eachtime']*$train['amt']); } @@ -51,7 +51,7 @@ } echo $time[1]; } ?> - + loadBuilding(); buildArray as $jobs) { if($jobs['master'] == 0){ @@ -43,11 +40,10 @@ $building->loadBuilding(); if($jobs['loopcon'] == 1) { echo " (waiting loop)"; } - echo "in "; + echo "in timer."\">"; echo $generator->getTimeFormat($jobs['timestamp']-time()); echo " hrs."; echo "done at ".date('H:i', $jobs['timestamp']).""; - $timer +=1; }else{ echo "checker\">"; echo "\"cancel\""; diff --git a/Templates/Profile/account.tpl b/Templates/Profile/account.tpl index 771bdc62..b5392e0f 100644 --- a/Templates/Profile/account.tpl +++ b/Templates/Profile/account.tpl @@ -116,7 +116,7 @@ echo "uid."&a=1&e=4\"> "; $time=$generator->getTimeFormat(($timestamp-time())); echo "The account will be deleted in ".$time." ."; + id=\"timer".++$session->timer."\">".$time." ."; } else { ?> diff --git a/Templates/dorf3/3.tpl b/Templates/dorf3/3.tpl index 6accc1f3..4f2ffca8 100644 --- a/Templates/dorf3/3.tpl +++ b/Templates/dorf3/3.tpl @@ -1,22 +1,27 @@ - - - - - - - - - + + + + + + + + + + + + + + + getProfileVillages($session->uid); -$timer = 1; -foreach($varray as $vil){ +$varray = $database->getProfileVillages($session->uid); +foreach($varray as $vil){ $vid = $vil['wref']; - $vdata = $database->getVillage($vid); + $vdata = $database->getVillage($vid); $pop = $vdata['pop']; $wood = floor($vdata['wood']); $clay = floor($vdata['clay']); @@ -24,98 +29,104 @@ foreach($varray as $vil){ $crop = floor($vdata['crop']); $maxs = $vdata['maxstore']; $maxc = $vdata['maxcrop']; - + $vresarray = $database->getResourceLevel($vid); - $prod_wood = $sawmill = 0; - $prod_clay = $claypit = 0; - $prod_iron = $foundry = 0; - $prod_crop = $grainmill = $bakery = 0; - $woodholder = array(); - $clayholder = array(); - $ironholder = array(); - $cropholder = array(); - for($i=1;$i<=38;$i++) { - if($vresarray['f'.$i.'t'] == 1) { - array_push($woodholder,'f'.$i); - } elseif($vresarray['f'.$i.'t'] == 5) { - $sawmill = $vresarray['f'.$i]; - } elseif($vresarray['f'.$i.'t'] == 2) { - array_push($clayholder,'f'.$i); - } elseif($vresarray['f'.$i.'t'] == 6) { - $claypit = $vresarray['f'.$i]; - } elseif($vresarray['f'.$i.'t'] == 3) { - array_push($ironholder,'f'.$i); - } elseif($vresarray['f'.$i.'t'] == 7) { - $foundry = $vresarray['f'.$i]; - } elseif($vresarray['f'.$i.'t'] == 4) { - array_push($cropholder,'f'.$i); - } elseif($vresarray['f'.$i.'t'] == 8) { - $grainmill = $vresarray['f'.$i]; - } elseif($vresarray['f'.$i.'t'] == 9) { - $bakery = $vresarray['f'.$i]; - } + $prod_wood = $sawmill = $prod_clay = $claypit = $prod_iron = $foundry = $prod_crop = $grainmill = $bakery = 0; + $woodholder = $clayholder = $ironholder = $cropholder = []; + + for($i = 1; $i <= 38; $i++){ + if($vresarray['f'.$i.'t'] == 1) array_push($woodholder, 'f'.$i); + elseif($vresarray['f'.$i.'t'] == 5) $sawmill = $vresarray['f'.$i]; + elseif($vresarray['f'.$i.'t'] == 2) array_push($clayholder, 'f'.$i); + elseif($vresarray['f'.$i.'t'] == 6) $claypit = $vresarray['f'.$i]; + elseif($vresarray['f'.$i.'t'] == 3) array_push($ironholder, 'f'.$i); + elseif($vresarray['f'.$i.'t'] == 7) $foundry = $vresarray['f'.$i]; + elseif($vresarray['f'.$i.'t'] == 4) array_push($cropholder, 'f'.$i); + elseif($vresarray['f'.$i.'t'] == 8) $grainmill = $vresarray['f'.$i]; + elseif($vresarray['f'.$i.'t'] == 9) $bakery = $vresarray['f'.$i]; } - for($i=0;$i<=count($woodholder)-1;$i++) { $prod_wood+= $bid1[$vresarray[$woodholder[$i]]]['prod']; } - for($i=0;$i<=count($clayholder)-1;$i++) { $prod_clay+= $bid2[$vresarray[$clayholder[$i]]]['prod']; } - for($i=0;$i<=count($ironholder)-1;$i++) { $prod_iron+= $bid3[$vresarray[$ironholder[$i]]]['prod']; } - for($i=0;$i<=count($cropholder)-1;$i++) { $prod_crop+= $bid4[$vresarray[$cropholder[$i]]]['prod']; } - if($sawmill >= 1) { - $prod_wood += $prod_wood /100 * $bid5[$sawmill]['attri']; + for($i = 0; $i <= count($woodholder) - 1; $i++){ + $prod_wood += $bid1[$vresarray[$woodholder[$i]]]['prod']; } - if($claypit >= 1) { - $prod_clay += $prod_clay /100 * $bid6[$claypit]['attri']; + for($i = 0; $i <= count($clayholder) - 1; $i++){ + $prod_clay += $bid2[$vresarray[$clayholder[$i]]]['prod']; } - if($foundry >= 1) { - $prod_iron += $prod_iron /100 * $bid7[$foundry]['attri']; + for($i = 0; $i <= count($ironholder) - 1; $i++){ + $prod_iron += $bid3[$vresarray[$ironholder[$i]]]['prod']; } - if ($grainmill >= 1 || $bakery >= 1) { - $prod_crop += $prod_crop /100 * ((isset($bid8[$grainmill]['attri']) ? $bid8[$grainmill]['attri'] : 0) + (isset($bid9[$bakery]['attri']) ? $bid9[$bakery]['attri'] : 0)); + for($i = 0; $i <= count($cropholder) - 1; $i++){ + $prod_crop += $bid4[$vresarray[$cropholder[$i]]]['prod']; } + + if($sawmill >= 1) $prod_wood += $prod_wood / 100 * $bid5[$sawmill]['attri']; + if($claypit >= 1) $prod_clay += $prod_clay / 100 * $bid6[$claypit]['attri']; + if($foundry >= 1) $prod_iron += $prod_iron / 100 * $bid7[$foundry]['attri']; + + + if($grainmill >= 1 || $bakery >= 1){ + $prod_crop += $prod_crop / 100 * ((isset($bid8[$grainmill]['attri']) ? $bid8[$grainmill]['attri'] : 0) + (isset($bid9[$bakery]['attri']) ? $bid9[$bakery]['attri'] : 0)); + } + $oasisowned = $database->getOasis($vid); - //more oasis logic required - if($session->plus) { + // more oasis logic required + if($session->plus){ $prod_wood *= 1.25; $prod_clay *= 1.25; $prod_iron *= 1.25; $prod_crop *= 1.25; } + $prod_wood *= SPEED; $prod_clay *= SPEED; $prod_iron *= SPEED; $prod_crop *= SPEED; - + $prod_crop -= $pop; - $prod_crop -= $technology->getUpkeep($technology->getAllUnits($vid),0); + $prod_crop -= $technology->getUpkeep($technology->getAllUnits($vid), 0); + + $percentW = floor($wood / ($maxs / 100)); + $percentC = floor($clay / ($maxs / 100)); + $percentI = floor($iron / ($maxs / 100)); + $percentCr = floor($crop / ($maxc / 100)); + + if($vid == $village->wid) $class = 'hl'; + else $class = ''; + + $cr = 95; // warning percentage + if($percentW >= $cr) $critW = 'crit'; + else $critW = ''; - $percentW = floor($wood/($maxs/100)); - $percentC = floor($clay/($maxs/100)); - $percentI = floor($iron/($maxs/100)); - $percentCr = floor($crop/($maxc/100)); - - if($vid == $village->wid) {$class = 'hl';} else {$class = '';} - $cr = 95; //warning percentage - if($percentW >= $cr) {$critW = 'crit';} else {$critW = '';} - if($percentC >= $cr) {$critC = 'crit';} else {$critC = '';} - if($percentI >= $cr) {$critI = 'crit';} else {$critI = '';} - if($percentCr >= $cr) {$critCR = 'crit';} else {$critCR = '';} - - $timerwood = floor(($maxs-$wood)/$prod_wood*3600); - $timerclay = floor(($maxs-$clay)/$prod_clay*3600); - $timeriron = floor(($maxs-$iron)/$prod_iron*3600); - $timer1 = min($timerwood,$timerclay,$timeriron); - $timer2 = floor(($maxc-$crop)/$prod_crop*3600); - + if($percentC >= $cr) $critC = 'crit'; + else $critC = ''; + + if($percentI >= $cr) $critI = 'crit'; + else $critI = ''; + + if($percentCr >= $cr) $critCR = 'crit'; + else $critCR = ''; + + if($prod_crop < 0) $critCR = $critNCR = 'crit'; + else $critNCR = ''; + + $timerwood = floor(($maxs - $wood) / $prod_wood * 3600); + $timerclay = floor(($maxs - $clay) / $prod_clay * 3600); + $timeriron = floor(($maxs - $iron) / $prod_iron * 3600); + $timer1 = min($timerwood, $timerclay, $timeriron); + $timer2 = floor(($prod_crop >= 0 ? $maxc - $crop : $crop) / abs($prod_crop) * 3600); + + if($timer1 > 0) $session->timer++; echo ' - '; - if($timer1 >0) { $timer++; } + '; + + if($timer2 > 0) $session->timer++; echo ' - '; - if($timer1 >0) { $timer++; } + '; } ?> -
Warehouse
VillageWoodClayIronClockCropClock
Warehouse
VillageWoodClayIronClockCropClock
'.$vdata['name'].' '.$percentW.'% '.$percentC.'% '.$percentI.'%0?'id="timer'.$timer.'"':'').'>'.($timer1>=0?$generator->getTimeFormat($timer1):'never').' 0 ? 'id="timer'.$session->timer.'"' : '').'>'.($timer1 >= 0 ? $generator->getTimeFormat($timer1) : 'Never').''.$percentCr.'%0?'id="timer'.$timer.'"':'').'>'.($timer2>=0?$generator->getTimeFormat($timer2):'never').'
0 ? 'id="timer'.$session->timer.'"' : '').'>'.($timer2 >= 0 ? $generator->getTimeFormat($timer2) : 'Never').'
+ + diff --git a/Templates/goldClub/farmlist_addraid.tpl b/Templates/goldClub/farmlist_addraid.tpl index 97549a0f..8fc32860 100644 --- a/Templates/goldClub/farmlist_addraid.tpl +++ b/Templates/goldClub/farmlist_addraid.tpl @@ -1,6 +1,4 @@ getFLData($_GET['lid']); -if($FLData['owner'] == $session->uid){ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) { $troops = 0; @@ -56,7 +54,7 @@ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) { return round($dist, 1); } - $distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); + $distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); $database->addSlotFarm($_POST['lid'], $session->uid, $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']); header("Location: build.php?id=39&t=99"); @@ -71,7 +69,7 @@ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
-
+
@@ -81,17 +79,16 @@ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) { @@ -126,12 +123,11 @@ if(mysqli_num_rows(mysqli_query($database->dblink,$getwref)) != 0){ $towref = $row["towref"]; $tocoor = $database->getCoor($towref); $totype = $database->getVillageType2($towref); - $tooasistype = $type['oasistype']; - if($tooasistype == 0) $tovname = $database->getVillageField($towref, 'name'); + if($totype == 0) $tovname = $database->getVillageField($towref, 'name'); else $tovname = $database->getOasisField($towref, 'name'); if($vill[$towref] == 0){ - echo ''; + echo ''; } $vill[$towref] = 1; } @@ -147,13 +143,6 @@ if(mysqli_num_rows(mysqli_query($database->dblink,$getwref)) != 0){
- - + - diff --git a/Templates/goldClub/farmlist_editraid.tpl b/Templates/goldClub/farmlist_editraid.tpl index 07b8b82a..87f79d9e 100644 --- a/Templates/goldClub/farmlist_editraid.tpl +++ b/Templates/goldClub/farmlist_editraid.tpl @@ -135,14 +135,14 @@ if(mysqli_num_rows(mysqli_query($database->dblink, $getwref)) != 0){ $towref = $row["towref"]; $tocoor = $database->getCoor($towref); $totype = $database->getVillageType2($towref); - $tooasistype = $type['oasistype']; - if($tooasistype == 0) $tovname = $database->getVillageField($towref, 'name'); + if($totype == 0) $tovname = $database->getVillageField($towref, 'name'); else $tovname = $database->getOasisField($towref, 'name'); if($row["id"] == $_GET['eid']) $selected = 'selected=""'; else $selected = ''; + if($vill[$towref] == 0){ - echo ''; + echo ''; } $vill[$towref] = 1; } diff --git a/Templates/menu.tpl b/Templates/menu.tpl index 7f200ddf..5855f036 100644 --- a/Templates/menu.tpl +++ b/Templates/menu.tpl @@ -67,20 +67,23 @@ div.c1 {text-align: center}

isDeleting($session->uid); - if($timestamp) { + if($timestamp){ echo "

"; + + $time = $generator->getTimeFormat(($timestamp - time())); + echo " The account will be deleted in timer . "\">" . $time . " .
"; } ?> 0){ echo '
"; - if($timestamp > time()+48*3600) { - echo "uid."&a=1&e=4\">\"Cancel "; + + if($timestamp > time() + 172800){ + echo "uid . "&a=1&e=4\">\"Cancel "; } - $time=$generator->getTimeFormat(($timestamp-time())); - echo " The account will be deleted in ".$time." .
'; } -$NextArrival = array(); -$NextArrival1 = array(); -$NextArrival2 = array(); -$NextArrival3 = array(); -$NextArrival4 = array(); -$NextArrival5 = array(); -$NextArrival6 = array(); +$NextArrival = $NextArrival1 = $NextArrival2 = $NextArrival3 = $NextArrival4 = $NextArrival5 = $NextArrival6 = []; /* Units coming back from Reinf,attack,raid,evasion or reinf to my town */ $aantal = count($database->getMovement(4,$village->wid,1))+count($database->getMovement(7,$village->wid,1)); @@ -64,8 +58,7 @@ if($aantal > 0){ } } echo ' - '; - $timer += 1; + '; } /* attack/raid on you! */ @@ -89,8 +82,7 @@ if($aantal > 0){ } } echo ' - '; - $timer += 1; + '; } /* on attack, raid */ @@ -112,8 +104,7 @@ if($aantal > 0){ } } echo ' - '; - $timer += 1; + '; } /* Units send to reinf. (to other town) */ @@ -135,8 +126,7 @@ if($lala > 0){ } } echo ' - '; - $timer += 1; + '; } /* Found NEW VILLAGE by Shadow */ @@ -154,9 +144,7 @@ if($aantal > 0){ } echo ' - '; - $timer += 1; - + '; } /* Attacks on Oasis (to my oasis) by Shadow */ @@ -186,7 +174,5 @@ if($aantal > 0){ } echo ' - '; - $timer += 1; - + '; } \ No newline at end of file diff --git a/Templates/natars.tpl b/Templates/natars.tpl new file mode 100644 index 00000000..c282eebd --- /dev/null +++ b/Templates/natars.tpl @@ -0,0 +1,32 @@ + 0){ +?> +

+
+ Artifacts will spawn in: + getTimeFormat($artifactsSpawn); ?> +
+ 0){ +?> +

+
+ WW villages will spawn in: + getTimeFormat($wwSpawn); ?> +
+ 0){ ?> +

+
+ WW building plans will spawn in: + getTimeFormat($wwBuildingPlansSpawn); ?> +
+ \ No newline at end of file diff --git a/create_account.php b/create_account.php index 1c2111ba..75cdbe1a 100644 --- a/create_account.php +++ b/create_account.php @@ -93,466 +93,59 @@ AccessLogger::logRequest(); /** * Functions */ -if(isset($_POST['password']) && $_POST['password'] != ""){ - function generateBase($kid, $uid, $username) { - global $database, $message; - if($kid == 0) { - $kid = rand(1, 4); - } else { - $kid = (isset($_POST['kid']) ? $_POST['kid'] : ''); - } - - $wid = $database->generateBase($kid); - $database->setFieldTaken($wid); - $database->addVillage($wid, $uid, $username, 1); - $database->addResourceFields($wid, $database->getVillageType($wid)); - $database->addUnits($wid); - $database->addTech($wid); - $database->addABTech($wid); - $database->updateUserField($uid, "access", USER, 1); - $message->sendWelcome($uid, $username); - } +if(!User::exists($database, 'Natars')){ /** - * Creating account & capital village - Fixed by Shadow - cata7007@gmail.com / Skype : cata7007 + * Creating account & capital village - Fixed by Shadow - cata7007@gmail.com / Skype : cata7007 - reworked by iopietro */ - $username = "Natars"; - $password = password_hash($_POST['password'], PASSWORD_BCRYPT,['cost' => 12]); - $email = "natars@noreply.com"; - $tribe = 5; - $desc = "*************************** - [#natars] - ***************************"; + $database->createNatars(); - $q = "INSERT INTO " . TB_PREFIX . "users (id,username,password,access,email,timestamp,tribe,location,act,protect) VALUES (3, '$username', '$password', " . USER . ", '$email', ".time().", $tribe, '', '', 0)"; - mysqli_query($database->dblink,$q); - unset($q); - $uid = $database->getUserField($username, 'id', 1); - $arrayXY=array(); - $arrayXY=array - ( - array(WORLD_MAX, WORLD_MAX), - array(WORLD_MAX, -WORLD_MAX), - array(-WORLD_MAX, -WORLD_MAX), - array(WORLD_MAX-1, WORLD_MAX), - array(WORLD_MAX, WORLD_MAX-1), - array(-WORLD_MAX, WORLD_MAX-1), - array(WORLD_MAX-1, -WORLD_MAX), - array(WORLD_MAX-1, WORLD_MAX-1), - array(WORLD_MAX, -WORLD_MAX+1), - array(WORLD_MAX-1, -WORLD_MAX+1), - array(-WORLD_MAX+1, -WORLD_MAX+1), - array(WORLD_MAX-2, WORLD_MAX), - array(WORLD_MAX-2, -WORLD_MAX), - array(WORLD_MAX-2, WORLD_MAX-1), - array(WORLD_MAX-1, WORLD_MAX-2), - array(-WORLD_MAX+2, WORLD_MAX), - array(-WORLD_MAX+2, WORLD_MAX-1), - array(-WORLD_MAX+2, -WORLD_MAX+2) - ); - $status=0; - $i=0; - while ($i<=17) { - $wid = $database->getVilWref($arrayXY[$i][0],$arrayXY[$i][1]); - $status = $database->getVillageState($wid); - $i++; - if ($status==0) break; - } - if($status != 0) { //have taken then random - generateBase(0, $uid, $username); - $status = 1; - } - if($status == 0) { - $database->setFieldTaken($wid); - $database->addVillage($wid, $uid, $username, 1); - $database->addResourceFields($wid, $database->getVillageType($wid)); - $database->addUnits($wid); - $database->addTech($wid); - $database->addABTech($wid); - $database->updateUserField($uid, "access", USER, 1); - } - - $wid = $database->getVillage($uid, 2); - $q = "UPDATE " . TB_PREFIX . "vdata SET pop = 834 WHERE owner = ".(int) $uid; - mysqli_query($database->dblink,$q) or die(mysqli_error($database->dblink)); - $q2 = "UPDATE " . TB_PREFIX . "users SET access = 2 WHERE id = ".(int) $uid; - mysqli_query($database->dblink,$q2) or die(mysqli_error($database->dblink)); - if(SPEED > 3) { - $speed = 5; - } else { - $speed = SPEED; - } - $q3 = "UPDATE " . TB_PREFIX . "units SET u41 = " . (64700 * $speed) . ", u42 = " . (295231 * $speed) . ", u43 = " . (180747 * $speed) . ", u44 = " . (20000 * $speed) . ", u45 = " . (364401 * $speed) . ", u46 = " . (217602 * $speed) . ", u47 = " . (2034 * $speed) . ", u48 = " . (1040 * $speed) . " , u49 = " . (1 * $speed) . ", u50 = " . (9 * $speed) . " WHERE vref = " . (int) $wid['wref'] . ""; - mysqli_query($database->dblink,$q3) or die(mysqli_error($database->dblink)); - $q4 = "UPDATE " . TB_PREFIX . "users SET desc2 = '$desc' WHERE id = ".(int) $uid; - mysqli_query($database->dblink,$q4) or die(mysqli_error($database->dblink)); - -/** - * SCOUTING ALL PLAYERS FIX BY MisterX - */ - $natar = $database->getVillage($uid, 3); - $multiplier = NATARS_UNITS; - $array = $database->getProfileVillages(0, 1); - $sendspytroops = 1500 * $multiplier; - $refs = []; - $vils = []; - foreach($array as $vill){ - $refs[] = $database->addAttack($natar['wref'], 0, 0, 0, $sendspytroops, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 0); - $vils[] = $vill['wref']; - } - - $type = []; - $from = []; - $to = []; - $ref = []; - $time = []; - $timeValue = time(); - $endtime = []; - $endtimeValue = $timeValue + 10000; - $counter = 0; - - foreach ($refs as $index => $refID) { - $type[] = 3; - $from[] = $natar['wref']; - $to[] = $vils[$index]; - $ref[] = $refID; - $time[] = $timeValue; - $endtime[] = $endtimeValue; - - // limit the insert, so it can push through any reasonable network limits imposed - if (++$counter > 25) { - $database->addMovement($type, $from, $to, $ref, $time, $endtime); - - $type = []; - $from = []; - $to = []; - $ref = []; - $time = []; - $endtime = []; - $counter = 0; - } - } - - if ($counter > 0) $database->addMovement($type, $from, $to, $ref, $time, $endtime); - -/** - * SMALL ARTEFACTS - */ - function Artefact($uid, $type, $size, $art_name, $village_name, $desc, $effect, $img) { - global $database; - $kid = rand(1, 4); - $wid = $database->generateBase($kid, 1); - $database->addArtefact($wid, $uid, $type, $size, $art_name, $desc, $effect, $img); - $database->setFieldTaken($wid); - $database->addVillage($wid, $uid, $village_name, '0'); - $database->addResourceFields($wid, $database->getVillageType($wid)); - $database->addUnits($wid); - $database->addTech($wid); - $database->addABTech($wid); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "vdata SET pop = 163 WHERE wref = ".(int) $wid); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "vdata SET name = '$village_name' WHERE wref = ".(int) $wid); - if(SPEED > 3) { - $speed = 5; - } else { - $speed = SPEED; - } - if($size == 1) { - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET u41 = " . (rand(1000, 2000) * $speed) . ", u42 = " . (rand(1500, 2000) * $speed) . ", u43 = " . (rand(2300, 2800) * $speed) . ", u44 = " . (rand(25, 75) * $speed) . ", u45 = " . (rand(1200, 1900) * $speed) . ", u46 = " . (rand(1500, 2000) * $speed) . ", u47 = " . (rand(500, 900) * $speed) . ", u48 = " . (rand(100, 300) * $speed) . " , u49 = " . (rand(1, 5) * $speed) . ", u50 = " . (rand(1, 5) * $speed) . " WHERE vref = " . (int) $wid . ""); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "fdata SET f22t = 27, f22 = 10, f28t = 25, f28 = 10, f19t = 23, f19 = 10, f32t = 23, f32 = 10 WHERE vref = ".(int) $wid); - } elseif($size == 2) { - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET u41 = " . (rand(2000, 4000) * $speed) . ", u42 = " . (rand(3000, 4000) * $speed) . ", u43 = " . (rand(4600, 5600) * $speed) . ", u44 = " . (rand(50, 150) * $speed) . ", u45 = " . (rand(2400, 3800) * $speed) . ", u46 = " . (rand(3000, 4000) * $speed) . ", u47 = " . (rand(1000, 1800) * $speed) . ", u48 = " . (rand(200, 600) * $speed) . " , u49 = " . (rand(2, 10) * $speed) . ", u50 = " . (rand(2, 10) * $speed) . " WHERE vref = " . (int) $wid . ""); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "fdata SET f22t = 27, f22 = 10, f28t = 25, f28 = 20, f19t = 23, f19 = 10, f32t = 23, f32 = 10 WHERE vref = ".(int) $wid); - } elseif($size == 3) { - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET u41 = " . (rand(4000, 8000) * $speed) . ", u42 = " . (rand(6000, 8000) * $speed) . ", u43 = " . (rand(9200, 11200) * $speed) . ", u44 = " . (rand(100, 300) * $speed) . ", u45 = " . (rand(4800, 7600) * $speed) . ", u46 = " . (rand(6000, 8000) * $speed) . ", u47 = " . (rand(2000, 3600) * $speed) . ", u48 = " . (rand(400, 1200) * $speed) . " , u49 = " . (rand(4, 20) * $speed) . ", u50 = " . (rand(4, 20) * $speed) . " WHERE vref = " . (int) $wid . ""); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "fdata SET f22t = 27, f22 = 10, f28t = 25, f28 = 20, f19t = 23, f19 = 10, f32t = 23, f32 = 10 WHERE vref = ".(int) $wid); - } - } - -/** - * THE ARCHITECTS - */ - - $desc = ARCHITECTS_DESC; - - - $vname = ARCHITECTS_SMALLVILLAGE; - $effect = '(4x)'; - for($i = 0; $i < 6; $i++) { - Artefact($uid, 1, 1, ARCHITECTS_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type2.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = ARCHITECTS_LARGEVILLAGE; - $effect = '(3x)'; - for($i = 0; $i < 4; $i++) { - Artefact($uid, 1, 2, ARCHITECTS_LARGE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type2.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = ARCHITECTS_UNIQUEVILLAGE; - $effect = '(5x)'; - for($i = 0; $i < 1; $i++) { - Artefact($uid, 1, 3, ARCHITECTS_UNIQUE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type2.gif'); - } - -/** - * MILITARY HASTE - */ - - - $desc = HASTE_DESC; - - unset($i); - unset($vname); - unset($effect); - $vname = HASTE_SMALLVILLAGE; - $effect = '(2x)'; - for($i = 0; $i < 6; $i++) { - Artefact($uid, 2, 1, HASTE_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type4.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = HASTE_LARGEVILLAGE; - $effect = '(1.5x)'; - for($i = 0; $i < 4; $i++) { - Artefact($uid, 2, 2, HASTE_LARGE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type4.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = HASTE_UNIQUEVILLAGE; - $effect = '(3x)'; - for($i = 0; $i < 1; $i++) { - Artefact($uid, 2, 3, HASTE_UNIQUE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type4.gif'); - } - -/** - * HAWK'S EYESIGHT - */ - - - $desc = EYESIGHT_DESC; - - unset($i); - unset($vname); - unset($effect); - $vname = EYESIGHT_SMALLVILLAGE; - $effect = '(5x)'; - for($i = 0; $i < 6; $i++) { - Artefact($uid, 3, 1, EYESIGHT_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type5.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = EYESIGHT_LARGEVILLAGE; - $effect = '(3x)'; - for($i = 0; $i < 4; $i++) { - Artefact($uid, 3, 2, EYESIGHT_LARGE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type5.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = EYESIGHT_UNIQUEVILLAGE; - $effect = '(10x)'; - for($i = 0; $i < 1; $i++) { - Artefact($uid, 3, 3, EYESIGHT_UNIQUE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type5.gif'); - } - -/** - * THE DIET - */ - - - $desc = DIET_DESC; - - unset($i); - unset($vname); - unset($effect); - $vname = DIET_SMALLVILLAGE; - $effect = '(50%)'; - for($i = 0; $i < 6; $i++) { - Artefact($uid, 4, 1, DIET_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type6.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = DIET_LARGEVILLAGE; - $effect = '(25%)'; - for($i = 0; $i < 4; $i++) { - Artefact($uid, 4, 2, DIET_LARGE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type6.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = DIET_UNIQUEVILLAGE; - $effect = '(50%)'; - for($i = 0; $i < 1; $i++) { - Artefact($uid, 4, 3, DIET_UNIQUE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type6.gif'); - } - - -/** - * ACADEMIC ADVANCEMENT - */ - - - $desc = ACADEMIC_DESC; - - unset($i); - unset($vname); - unset($effect); - $vname = ACADEMIC_SMALLVILLAGE; - $effect = '(50%)'; - for($i = 0; $i < 6; $i++) { - Artefact($uid, 5, 1, ACADEMIC_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type8.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = ACADEMIC_LARGEVILLAGE; - $effect = '(25%)'; - for($i = 0; $i < 4; $i++) { - Artefact($uid, 5, 2, ACADEMIC_LARGE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type8.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = ACADEMIC_UNIQUEVILLAGE; - $effect = '(50%)'; - for($i = 0; $i < 1; $i++) { - Artefact($uid, 5, 3, ACADEMIC_UNIQUE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type8.gif'); - } - - -/** - * STORAGE MASTER PLAN - */ - - - $desc = STORAGE_DESC; - - unset($i); - unset($vname); - unset($effect);; - $vname = STORAGE_SMALLVILLAGE; - $effect = '(GG&GW)'; - for($i = 0; $i < 6; $i++) { - Artefact($uid, 6, 1, STORAGE_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type9.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = STORAGE_LARGEVILLAGE; - $effect = '(GG&GW)'; - for($i = 0; $i < 4; $i++) { - Artefact($uid, 6, 2, STORAGE_LARGE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type9.gif'); - } - - -/** - * RIVAL'S CONFUSION - */ - - - $desc = CONFUSION_DESC; - - unset($i); - unset($vname); - unset($effect); - $vname = CONFUSION_SMALLVILLAGE; - $effect = '(200)'; - for($i = 0; $i < 6; $i++) { - Artefact($uid, 7, 1, CONFUSION_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type10.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = CONFUSION_LARGEVILLAGE; - $effect = '(100)'; - for($i = 0; $i < 4; $i++) { - Artefact($uid, 7, 2, CONFUSION_LARGE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type10.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = CONFUSION_UNIQUEVILLAGE; - $effect = '(500)'; - for($i = 0; $i < 1; $i++) { - Artefact($uid, 7, 3, CONFUSION_UNIQUE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type10.gif'); - } - - -/** - * ARTEFACT OF THE FOOL - */ - - - $desc = FOOL_DESC; - - unset($i); - unset($vname); - unset($effect); - $vname = FOOL_SMALLVILLAGE; - $effect = ''; - for($i = 0; $i < 5; $i++) { - Artefact($uid, 8, 1, FOOL_SMALL, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'typefool.gif'); - } - - unset($i); - unset($vname); - unset($effect); - $vname = FOOL_UNIQUEVILLAGE; - $effect = ''; - for($i = 0; $i < 1; $i++) { - Artefact($uid, 8, 3, FOOL_UNIQUE, '' . $vname . '', '' . $desc . '', '' . $effect . '', 'typefool.gif'); - } + $artifactArrays = [ARCHITECTS_DESC => [["type" => 1, "size" => 1, "name" => ARCHITECTS_SMALL, "vname" => ARCHITECTS_SMALLVILLAGE, "effect" => "(4x)", "quantity" => 6, "img" => 2], + ["type" => 1, "size" => 2, "name" => ARCHITECTS_LARGE, "vname" => ARCHITECTS_LARGEVILLAGE, "effect" => "(3x)", "quantity" => 4, "img" => 2], + ["type" => 1, "size" => 3, "name" => ARCHITECTS_UNIQUE,"vname" => ARCHITECTS_UNIQUEVILLAGE, "effect" => "(5x)", "quantity" => 1, "img" => 2]], + + HASTE_DESC => [["type" => 2, "size" => 1, "name" => HASTE_SMALL, "vname" => HASTE_SMALLVILLAGE, "effect" => "(2x)", "quantity" => 6, "img" => 4], + ["type" => 2, "size" => 2, "name" => HASTE_LARGE, "vname" => HASTE_LARGEVILLAGE, "effect" => "(1.5x)", "quantity" => 4, "img" => 4], + ["type" => 2, "size" => 3, "name" => HASTE_UNIQUE, "vname" => HASTE_UNIQUEVILLAGE, "effect" => "(3x)", "quantity" => 1, "img" => 4]], + + EYESIGHT_DESC => [["type" => 3, "size" => 1, "name" => EYESIGHT_SMALL, "vname" => EYESIGHT_SMALLVILLAGE, "effect" => "(5x)", "quantity" => 6, "img" => 5], + ["type" => 3, "size" => 2, "name" => EYESIGHT_LARGE, "vname" => EYESIGHT_LARGEVILLAGE, "effect" => "(3x)", "quantity" => 4, "img" => 5], + ["type" => 3, "size" => 3, "name" => EYESIGHT_UNIQUE, "vname" => EYESIGHT_UNIQUEVILLAGE, "effect" => "(10x)", "quantity" => 1, "img" => 5]], + + DIET_DESC => [["type" => 4, "size" => 1, "name" => DIET_SMALL, "vname" => DIET_SMALLVILLAGE, "effect" => "(50%)", "quantity" => 6, "img" => 6], + ["type" => 4, "size" => 2, "name" => DIET_LARGE, "vname" => DIET_LARGEVILLAGE, "effect" => "(25%)", "quantity" => 4, "img" => 6], + ["type" => 4, "size" => 3, "name" => DIET_UNIQUE, "vname" => DIET_UNIQUEVILLAGE, "effect" => "(50%)", "quantity" => 1, "img" => 6]], + + ACADEMIC_DESC => [["type" => 5, "size" => 1, "name" => ACADEMIC_SMALL, "vname" => ACADEMIC_SMALLVILLAGE, "effect" => "(50%)", "quantity" => 6, "img" => 8], + ["type" => 5, "size" => 2, "name" => ACADEMIC_LARGE, "vname" => ACADEMIC_LARGEVILLAGE, "effect" => "(25%)", "quantity" => 4, "img" => 8], + ["type" => 5, "size" => 3, "name" => ACADEMIC_UNIQUE, "vname" => ACADEMIC_UNIQUEVILLAGE, "effect" => "(50%)", "quantity" => 1, "img" => 8]], + + STORAGE_DESC => [["type" => 6, "size" => 1, "name" => STORAGE_SMALL, "vname" => STORAGE_SMALLVILLAGE, "effect" => "(50%)", "quantity" => 6, "img" => 9], + ["type" => 6, "size" => 2, "name" => STORAGE_LARGE, "vname" => STORAGE_LARGEVILLAGE, "effect" => "(25%)", "quantity" => 4, "img" => 9]], + + CONFUSION_DESC => [["type" => 7, "size" => 1, "name" => CONFUSION_SMALL, "vname" => CONFUSION_SMALLVILLAGE, "effect" => "(200)", "quantity" => 6, "img" => 10], + ["type" => 7, "size" => 2, "name" => CONFUSION_LARGE, "vname" => CONFUSION_LARGEVILLAGE, "effect" => "(100)", "quantity" => 4, "img" => 10], + ["type" => 7, "size" => 3, "name" => CONFUSION_UNIQUE, "vname" => CONFUSION_UNIQUEVILLAGE, "effect" => "(500)", "quantity" => 1, "img" => 10]], + + FOOL_DESC => [["type" => 8, "size" => 1, "name" => FOOL_SMALL, "vname" => FOOL_SMALLVILLAGE, "effect" => "", "quantity" => 5, "img" => "fool"], + ["type" => 8, "size" => 3, "name" => FOOL_UNIQUE, "vname" => FOOL_UNIQUEVILLAGE, "effect" => "", "quantity" => 1, "img" => "fool"]]]; - $myFile = "Templates/text.tpl"; - $fh = fopen($myFile, 'w') or die("


Can't open file: templates/text.tpl"); - $text = file_get_contents("Templates/text_format.tpl"); - $text = preg_replace("'%TEKST%'",ARTEFACT ,$text); - fwrite($fh, $text); - - $query = "UPDATE ".TB_PREFIX."users SET ok = 1"; - echo "Done"; -}elseif(User::exists($database, 'Natars')) { + //Add artefacts and their villages + $database->addArtifactVillages($artifactArrays); + + //Write the system message + $database->displaySystemMessage(ARTEFACT); + + echo '

Done: Natars created and artifacts spawned!

'; +}else{ ?>

-Error: Natar account already exist +Error: Natar account already exists

- - -

- Choose Password -

-
'.TROOP_MOVEMENTS.'
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival)-time()).' '.HOURS.'
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival)-time()).' '.HOURS.'
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival1)-time()).' '.HOURS.'
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival1)-time()).' '.HOURS.'
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival2)-time()).' '.HOURS.'
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival2)-time()).' '.HOURS.'
'.$title.'»
'.$lala.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival3)-time()).' '.HOURS.'
'.$lala.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival3)-time()).' '.HOURS.'
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival5)-time()).' '.HOURS.'
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival5)-time()).' '.HOURS.'
'.$title.'»
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival6)-time()).' '.HOURS.'
'.$aantal.' '.$short.'
in '.$generator->getTimeFormat(min($NextArrival6)-time()).' '.HOURS.'
- -
Password:
- -
-
- -




Error creating constant.php Natars Units Multiplier: - + + + + Natars Spawn (Days): + + + + WW building plan spawn (Days): + + + + WW spawn (Days): + World size: @@ -177,6 +189,22 @@ echo "
Error creating constant.php + + Oasis wood production multiplier: + + + + Oasis clay production multiplier: + + + + Oasis iron production multiplier: + + + + Oasis crop production multiplier: + + Medal Interval: