mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-06 21:04:20 +00:00
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.
This commit is contained in:
+47
-66
@@ -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;
|
||||
?>
|
||||
|
||||
@@ -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;
|
||||
|
||||
+185
-34
@@ -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
|
||||
*
|
||||
|
||||
+283
-47
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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");
|
||||
|
||||
+19
-21
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user