Artifacts update and optimizations

+Added the "Artifacts" section in the Admin Panel, which contains two
options: return a deleted artifact to the Natars and create new
Artifacts, assigned to a specified player
+Return to Natars coded, in the village section of the Admin Panel
+Moved a lot of functions and costants from Automation.php to the "new"
class Artifacts.php
+Optimized a lot the whole Natars creation process, decreased the number
of query of about 600
+Optimized a lot the function which deletes a player's account, it's now
executed almost instantly, even with players with a lot of villages
+Redesigned the map spawn system, using a more Travian-like village
distribution
+Fixed a bug that did show a broken village in the artifact chronology,
if that village was destroyed
+Reduced the amount of redundant code (about 230 lines) for
27_1.tpl/27_2.tpl and 27_3.tpl
+Fixed a bug that permitted to build the Great Granary and the Great
Warehouse in the whole account, with only a village effect artifact
+Fixed a bug in the Admin Panel map that didn't permit to show village
informations, if that village contained single quotes in its name
This commit is contained in:
iopietro
2018-07-24 03:04:25 +02:00
parent dc399437d0
commit 77136a9784
18 changed files with 1313 additions and 1195 deletions
+33 -32
View File
@@ -134,10 +134,10 @@ class Account {
}
}
else {
$uid = $database->register($_POST['name'],password_hash($_POST['pw'], PASSWORD_BCRYPT,['cost' => 12]),$_POST['email'],$_POST['vid'],$act);
$uid = $database->register($_POST['name'], password_hash($_POST['pw'], PASSWORD_BCRYPT, ['cost' => 12]), $_POST['email'], $_POST['vid'], $act);
if($uid) {
setcookie("COOKUSR",$_POST['name'],time()+COOKIE_EXPIRE,COOKIE_PATH);
setcookie("COOKEMAIL",$_POST['email'],time()+COOKIE_EXPIRE,COOKIE_PATH);
setcookie("COOKUSR" , $_POST['name'], time() + COOKIE_EXPIRE,COOKIE_PATH);
setcookie("COOKEMAIL" , $_POST['email'], time() + COOKIE_EXPIRE,COOKIE_PATH);
$database->updateUserField(
$uid,
["act", "invited"],
@@ -145,7 +145,7 @@ class Account {
1
);
$this->generateBase($_POST['kid'],$uid,$_POST['name']);
$this->generateBase($_POST['kid'], $uid, $_POST['name']);
header("Location: login.php");
exit;
}
@@ -154,37 +154,38 @@ class Account {
}
private function Activate() {
if(START_DATE < date('d.m.Y') or START_DATE == date('d.m.Y') && START_TIME <= date('H:i'))
{
global $database;
$q = "SELECT act, username, password, email, tribe, location FROM ".TB_PREFIX."activate where act = '".$database->escape($_POST['id'])."'";
$result = mysqli_query($database->dblink,$q);
$dbarray = mysqli_fetch_array($result);
if($dbarray['act'] == $_POST['id']) {
$uid = $database->register($dbarray['username'],$dbarray['password'],$dbarray['email'],$dbarray['tribe'],"");
if($uid) {
$database->unreg($dbarray['username']);
$this->generateBase($dbarray['location'],$uid,$dbarray['username']);
header("Location: activate.php?e=2");
exit;
}
}
else
{
header("Location: activate.php?e=3");
exit;
}
}
else
{
header("Location: activate.php");
exit;
}
global $database;
if(START_DATE < date('d.m.Y') or START_DATE == date('d.m.Y') && START_TIME <= date('H:i'))
{
$q = "SELECT act, username, password, email, tribe, location FROM ".TB_PREFIX."activate where act = '".$database->escape($_POST['id'])."'";
$result = mysqli_query($database->dblink,$q);
$dbarray = mysqli_fetch_array($result);
if($dbarray['act'] == $_POST['id']) {
$uid = $database->register($dbarray['username'], $dbarray['password'], $dbarray['email'], $dbarray['tribe'], "");
if($uid) {
$database->unreg($dbarray['username']);
$this->generateBase($dbarray['location'],$uid,$dbarray['username']);
header("Location: activate.php?e=2");
exit;
}
}
else
{
header("Location: activate.php?e=3");
exit;
}
}
else
{
header("Location: activate.php");
exit;
}
}
private function Unreg() {
global $database;
$q = "SELECT password, username FROM ".TB_PREFIX."activate where id = ".(int) $_POST['id'];
$result = mysqli_query($database->dblink,$q);
$dbarray = mysqli_fetch_array($result);
@@ -271,7 +272,7 @@ class Account {
if($kid == 0) $kid = rand(1,4);
else $kid = $_POST['kid'];
$database->generateVillages([['wid' => 0, 'kid' => $kid, 'capital' => 1]], $uid, $username);
$database->generateVillages([['wid' => 0, 'mode' => 0, 'type' => 3, 'kid' => $kid, 'capital' => 1, 'pop' => 2, 'name' => null, 'natar' => 0]], $uid, $username);
$message->sendWelcome($uid, $username);
}
};
+5 -5
View File
@@ -100,11 +100,11 @@ else
else
{
// Register them and build the village
$uid = $database->register($userName, password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]), $email, $tribe ,$act);
$uid = $database->register($userName, password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]), $email, $tribe, $act);
if($uid)
{
/*
* [MENTION=6887]Tod[/MENTION]O
* [MENTION=6887]Todo[/MENTION]
*
* Allow option to create (random) bigger villages,
* upgrade fields, granary, warehouse, wall etc
@@ -130,12 +130,12 @@ else
// already exists
$protection = time();
mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET
protect = '".$protection."'
WHERE id = ".(int) $uid) or die(mysqli_error($database->dblink));
protect = '".$protection."'
WHERE id = ".(int) $uid) or die(mysqli_error($database->dblink));
}
$database->updateUserField($uid,"act","",1);
$wid = $database->generateBase($kid);
$wid = $database->generateBase($kid, 1);
$database->setFieldTaken($wid);
//calculate random generate value and level building
+14 -22
View File
@@ -42,10 +42,10 @@ function aktiv() {this.srcElement.className='fl1'; }
function inaktiv() {event.srcElement.className='fl2'; }
function del(e,id){
if(e == 'did'){ var conf = confirm('Dou you really want delete village id '+id+'?'); }
if(e == 'arti'){ var conf = confirm('Dou you really want delete artifact id '+id+'?'); }
if(e == 'unban'){ var conf = confirm('Dou you really want unban player '+id+'?'); }
if(e == 'stopDel'){ var conf = confirm('Dou you really want stop deleting user '+id+'?'); }
if(e == 'did'){ var conf = confirm('Do you really want to delete village id '+id+'?'); }
if(e == 'arti'){ var conf = confirm('Do you really want to delete artifact id '+id+'?'); }
if(e == 'unban'){ var conf = confirm('Do you really want to unban player '+id+'?'); }
if(e == 'stopDel'){ var conf = confirm('Do you really want to stop deleting user '+id+'?'); }
return conf;
}
@@ -86,30 +86,22 @@ return conf;
if($funct->CheckLogin()){
if($_POST or $_GET){
if($_GET['p'] and $_GET['p']!="search"){
if($_GET['p'] && $_GET['p'] != "search"){
$filename = '../Templates/Admin/'.$_GET['p'].'.tpl';
if(file_exists($filename)){
include($filename);
}else{
include('../Templates/Admin/404.tpl');
}
}else{
include('../Templates/Admin/search.tpl');
if(file_exists($filename)) include($filename);
else include('../Templates/Admin/404.tpl');
}
if($_POST['p'] and $_POST['s']){
else include('../Templates/Admin/search.tpl');
if($_POST['p'] && $_POST['s']){
$filename = '../Templates/Admin/results_'.$_POST['p'].'.tpl';
if(file_exists($filename)){
include($filename);
}else{
include('../Templates/Admin/404.tpl');
}
if(file_exists($filename)) include($filename);
else include('../Templates/Admin/404.tpl');
}
}else{
include('../Templates/Admin/home.tpl');
}
}else{
include('../Templates/Admin/login.tpl');
else include('../Templates/Admin/home.tpl');
}
else include('../Templates/Admin/login.tpl');
?>
</div>
+61 -4
View File
@@ -17,6 +17,7 @@
// # Source code: https://github.com/Shadowss/TravianZ ##
// # ##
// ################################################################################
include_once("../GameEngine/Artifacts.php");
class funct
{
@@ -29,6 +30,8 @@ class funct
{
global $admin, $database;
$artifact = new Artifacts();
switch ($get['action']) {
case "recountPop":
$admin->recountPop($get['did']);
@@ -74,12 +77,66 @@ class funct
case "logout":
$this->LogOut();
break;
case "delArtifact":
if(isset($_GET['artid']) && is_numeric($_GET['artid'])) $database->deleteArtifact($_GET['artid']);
break;
case "returnArtifact":
case "delArtifact":
if(isset($_GET['artid']) && is_numeric($_GET['artid'])) $database->updateArtifactDetails($_GET['artid'], ['del' => 1]);
break;
case "returnArtifact":
//Check if the artifact id is valid
if(!isset($_GET['artid']) || !is_numeric($_GET['artid'])){
header("location: admin.php");
exit;
}
//Get the informations of the artifact
$artifactInfo = $database->getArtefactDetails($_GET['artid'], $_GET['del']);
//Check if the artifact exists
if(empty($artifactInfo) || $artifactInfo['owner'] == Artifacts::NATARS_UID) {
header("location: admin.php");
exit;
}
$artifact->returnArtifactToNatars($artifactInfo);
break;
case "addArtifacts":
$selectedArtifact = $_POST['selectedArtifact'];
$artifactQuantity = $_POST['artifactQuantity'];
$playerId = $_POST['playerId'];
//Check if the inputs are valid
if(!isset($selectedArtifact) || !isset($artifactQuantity) || !isset($playerId) || empty($selectedArtifact) ||
!is_numeric($artifactQuantity) || !is_numeric($playerId) || strpos($selectedArtifact, ':') === false ||
$database->getUserField($playerId, "username", 0) == "[?]"){
header("location: admin.php");
exit;
}
//The first element [0] is the type of the artifact, the second one [1] is the size of it
//and the third one, is the artifact description
$selectedArtifact = explode(":", $selectedArtifact);
//Add the chosen artifact(s)
$artifactsArray = array_merge(Artifacts::NATARS_ARTIFACTS, Artifacts::NATARS_WW_BUILDING_PLANS);
$chosenArtifact = $artifactsArray[$selectedArtifact[2]][$selectedArtifact[1] - 1];
//Check if the artifact has been found or if doesn't exist
if(empty($chosenArtifact)){
header("location: admin.php");
exit;
}
//Create the artifacts array
$chosenArtifact['quantity'] = $artifactQuantity;
$artifactArrays[$selectedArtifact[2]][] = $chosenArtifact;
//Add the artifacts
$artifact->addArtifactVillages($artifactArrays, $playerId);
break;
case "killHero":
$varray = $database->getProfileVillages($get['uid']);
$killhero = false;
+435 -1
View File
@@ -1,5 +1,439 @@
<?php
class Artifacts{
class Artifacts
{
public const
/**
* @var integer Default Natars' uid
*/
NATARS_UID = 3,
/**
* @var integer Default Natars' tribe
*/
NATARS_TRIBE = 5,
/**
* @var string Default Natars' email
*/
NATARS_EMAIL = TRIBE5."@noreply.com",
/**
* @var string Default Natars' description
*/
NATARS_DESC = "**************************
[#natars]
**************************",
/**
* @var array Possible Natars' capital locations
*/
NATARS_CAPITAL_COORDINATES = [[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]],
/**
* @var array Normal Natars' artifacts
*/
NATARS_ARTIFACTS = [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" => 10, "img" => "fool"],
2 => ["type" => 8, "size" => 3, "name" => FOOL_UNIQUE, "vname" => FOOL_UNIQUEVILLAGE, "effect" => "", "quantity" => 1, "img" => "fool"]]],
/**
* @var array WW building plans Natars' artifacts
*/
NATARS_WW_BUILDING_PLANS = [PLAN_DESC => [["type" => 11, "size" => 1, "name" => PLAN,"vname" => PLANVILLAGE, "effect" => "", "quantity" => 13, "img" => 1]]],
/**
* @var array Natars' normal artifacts buildings
*/
NATARS_ARTIFACTS_BUILDINGS = [
//Treasury of the 20th level, Residence of the 10th level, Rally Point of the 1th level
"f22t" => 27, "f22" => 20, "f28t" => 25, "f28" => 10, "f39t" => 16, "f39" => 1,
//18 Cranny of the 10th level
"f19t" => 23, "f19" => 10, "f20t" => 23, "f20" => 10, "f21t" => 23, "f21" => 10,
"f23t" => 23, "f23" => 10, "f24t" => 23, "f24" => 10, "f25t" => 23, "f25" => 10,
"f26t" => 23, "f26" => 10, "f27t" => 23, "f27" => 10, "f29t" => 23, "f29" => 10,
"f30t" => 23, "f30" => 10, "f31t" => 23, "f31" => 10, "f32t" => 23, "f32" => 10,
"f33t" => 23, "f33" => 10, "f34t" => 23, "f34" => 10, "f35t" => 23, "f35" => 10,
"f36t" => 23, "f36" => 10, "f37t" => 23, "f37" => 10, "f38t" => 23, "f38" => 10],
/**
* @var array Natars' WW villages buildings
*/
NATARS_WW_VILLAGES_BUILDINGS = [
//WW of the 0th level, Main Building of the 10th level, Marketplace of the 1th level
"f99t" => 40, "f99" => 0, "f22t" => 15, "f22" => 10, "f34t" => 17, "f34" => 1,
//Warehouse of the 20th & 10th level, Granary of the 20th & 10th level
"f20t" => 10, "f20" => 20, "f19t" => 10, "f19" => 10, "f23t" => 11, "f23" => 20, "f27t" => 11, "f27" => 10,
//All Woodcutter of the 5th level
"f1" => 5, "f3" => 5, "f14" => 5, "f17" => 5,
//All Clay Pit of the 5th level
"f5" => 5, "f6" => 5, "f16" => 5, "f18" => 5,
//All Iron Mine of the 5th level
"f4" => 5, "f7" => 5, "f10" => 5, "f11" => 5,
//All Cropland of the 6th level
"f2" => 6, "f8" => 6, "f9" => 6, "f12" => 6, "f13" => 6, "f15" => 6],
/**
* @var integer The base amount of Natars' spying units, used when Natars account is created
*/
NATARS_BASE_SPY = 1500;
public
/**
* @var funct Natars' troops for normal artifact
*/
$natarsArtifactsUnits,
/**
* @var funct WW villages Natars' troops
*/
$natarsWWVillagesUnits;
public function __construct(){
$this->natarsArtifactsUnits = function($multiplier){
return [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];
};
$this->natarsWWVillagesUnits = function(){
return [41 => rand(500, 12000) * NATARS_UNITS,
42 => rand(1000 , 14000) * NATARS_UNITS,
43 => rand(2000, 16000) * NATARS_UNITS,
44 => rand(100, 500) * NATARS_UNITS,
45 => rand(480, 17000) * NATARS_UNITS,
46 => rand(600, 18000) * NATARS_UNITS,
47 => rand(2000, 16000) * NATARS_UNITS,
48 => rand(400, 2000) * NATARS_UNITS,
49 => rand(40, 200) * NATARS_UNITS,
50 => rand(50, 250) * NATARS_UNITS];
};
}
/**
* Called when Natars account need to be created, creates his account and capital village
*
*/
public function createNatars(){
global $database;
//Register the Natars account, the Natars' password is the same as the MH's one
$password = $database->getUserField(5, 'password', 0);
$database->register(TRIBE5, $password, self::NATARS_EMAIL, self::NATARS_TRIBE, null, self::NATARS_UID, self::NATARS_DESC);
//Convert from coordinates to village IDs
$possibleWids = $database->getVilWrefs(self::NATARS_CAPITAL_COORDINATES);
//Check if the villages aren't already taken
$wid = $database->getFreeVillage($possibleWids);
//Generate the Natars' capital
$wid = $database->generateVillages([['wid' => $wid, 'mode' => 2, 'type' => 3, 'kid' => 0, 'capital' => 1, 'pop' => 834, 'name' => null, 'natar' => 0]], self::NATARS_UID, TRIBE5);
//Scouts all players
$this->scoutAllPlayers($wid);
//Add artifacts
$this->addArtifactVillages(self::NATARS_ARTIFACTS);
}
/**
* Called when Natars account has been created
*
* @param int $wid The village ID of the Natars' capital
*/
public function scoutAllPlayers($wid){
global $database;
$array = $database->getProfileVillages(0, 1);
$refs = [];
$vils = [];
foreach($array as $vill){
$refs[] = $database->addAttack($wid, 0, 0, 0, self::NATARS_BASE_SPY * 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) {
$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);
}
/**
* 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)
*/
public function addArtifactVillages($artifactArrays, $uid = self::NATARS_UID) {
global $database;
//Variables initialization
$artifactNumber = 0;
$artifactVillages = $artifactTroops = $artifactBuildings = $artifactsToAdd = $wids = [];
//Create the artifact villages array
foreach($artifactArrays as $desc => $artifactType){
foreach($artifactType as $artifact){
for($i = 0; $i < $artifact['quantity']; $i++){
//Generate the villages array
$artifactVillages[] = ['wid' => 0, 'mode' => $artifact['size'] + 1, 'type' => 3, 'kid' => rand(1, 4), 'capital' => 0, 'pop' => 163, 'name' => $artifact['vname'], 'natar' => 0];
//Set the unit arrays (1, 2 or 4)
$multiplier = $artifact['size'] == 3 ? 4 : $artifact['size'];
$unitArrays = ($this->natarsArtifactsUnits)($multiplier);
//Generate the unit arrays
$artifactTroops[1][] = array_values($unitArrays);
$artifactBuildings[1][] = array_values(self::NATARS_ARTIFACTS_BUILDINGS);
//Generate the artifacts array
$artifactsToAdd[] = ['owner' => $uid, 'type' => $artifact['type'], 'size' => $artifact['size'],
'name' => $artifact['name'], 'desc' => $desc, 'effect' => $artifact['effect'],
'img' => "type".$artifact['img'].".gif"];
}
}
}
//Set the unit types by using the last $unitArrays
$artifactTroops[0] = array_keys($unitArrays);
$artifactBuildings[0] = array_keys(self::NATARS_ARTIFACTS_BUILDINGS);
//Generate the wids
$wids = array_merge($wids, (array)$database->generateVillages($artifactVillages, $uid, TRIBE5, $artifactTroops, $artifactBuildings));
//Create the artifacts for the generated wids
$database->addArtefacts($wids, $artifactsToAdd);
}
/**
* Called when WW villages need to be created
*
*/
public function createWWVillages(){
global $database;
$villageArrays = $troopArrays = $buildingArrays = $wids = [];
for($i = 1; $i <= 13; $i++){
$villageArrays[] = ['wid' => 0, 'mode' => 5, 'type' => 3, 'kid' => ($i == 13 ? rand(1, 4) : ($i % 4) + 1), 'capital' => 0, 'pop' => 233, 'name' => WWVILLAGE, 'natar' => 1];
$troopArrays[1][] = array_values(($this->natarsWWVillagesUnits)());
$buildingArrays[1][] = array_values(self::NATARS_WW_VILLAGES_BUILDINGS);
}
$troopArrays[0] = array_keys(($this->natarsWWVillagesUnits)());
$buildingArrays[0] = array_keys(self::NATARS_WW_VILLAGES_BUILDINGS);
$wids = $database->generateVillages($villageArrays, self::NATARS_UID, TRIBE5, $troopArrays, $buildingArrays);
}
/**
* Called when WW building plans need to be created
*
*/
public function createWWBuildingPlans(){
//Add the artifacts and villages
$this->addArtifactVillages(self::NATARS_WW_BUILDING_PLANS);
}
/**
* Automatically activate all artifacts that need to be activated
*
*/
public function activateArtifacts(){
global $database;
//Get all inactive artifacts that have to be activated --> (24 hours / Speed of the server)
$time = time();
$artifacts = $database->getInactiveArtifacts(round($time - (86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED)))));
if(!empty($artifacts)){
//Cache inactive artifacts by owner
$inactiveArtifactsCache = [];
foreach($artifacts as $artifact) $inactiveArtifactsCache[$artifact['owner']][] = $artifact;
foreach($inactiveArtifactsCache as $owner => $inactiveArtifacts){
//Initialize the array
$activeArtifacts = [];
//Get cached active artifacts
$ownArtifacts = $database->getOwnArtifactsSum($owner, true);
//Activate activable artifacts
foreach($inactiveArtifacts as $artifact){
if($ownArtifacts['totals'] < 3){
if($artifact['size'] == 1){ //Village effect
$database->activateArtifact($artifact['id']);
$ownArtifacts['totals']++;
$ownArtifacts['small']++;
}elseif($artifact['size'] == 2 && !$ownArtifacts['unique'] && !$ownArtifacts['great']){ //Account effect
$database->activateArtifact($artifact['id']);
$ownArtifacts['totals']++;
$ownArtifacts['great']++;
}elseif($artifact['size'] == 3 && !$ownArtifacts['unique'] && !$ownArtifacts['great']){ //Unique effect
$database->activateArtifact($artifact['id']);
$ownArtifacts['totals']++;
$ownArtifacts['unique']++;
}
}elseif($ownArtifacts['small'] == 3 && $artifact['size'] > 1){
//If we've 3 village effect artifacts activated and at least one account/unique effect not activated
//then we need to deactivate the most recent village effect artifact and activate the oldest account
//or unique effect artifact
//Deactivate the most recent village effect artifact
$database->activateArtifact($database->getNewestArtifactBySize($owner, 1)['id'], 0);
//Activate the great/unique artifact
$database->activateArtifact($artifact['id']);
$ownArtifacts['small']--;
$ownArtifacts['totals']++;
if($artifact['size'] == 2) $ownArtifacts['great']++;
else $ownArtifacts['unique']++;
}
}
}
}
}
/**
* Return the selected artifact, to the Natars account, by creating a new village and
* by moving the artifact into it
*
* @param array $artifact The artifact array
*/
public function returnArtifactToNatars($artifactArray){
global $database;
//Set the village arrays
$villageArrays = [['wid' => 0, 'mode' => $artifactArray['size'] + 1, 'type' => 3,
'kid' => rand(1, 4), 'capital' => 0, 'pop' => 163,
'name' => self::NATARS_ARTIFACTS[$artifactArray['desc']][$artifactArray['size'] - 1]['vname'],
'natar' => $artifactArray['type'] != 11 ? 0 : 1]];
//Set the unit arrays
$multiplier = $artifactArray['size'] == 3 ? 4 : $artifactArray['size'];
$unitsArray = ($this->natarsArtifactsUnits)($multiplier);
//Set the unit types
$artifactTroops[1][] = array_values($unitsArray);
$artifactTroops[0] = array_keys($unitsArray);
//Set the buildings array
$artifactBuildings[1][] = array_values(self::NATARS_ARTIFACTS_BUILDINGS);
$artifactBuildings[0] = array_keys(self::NATARS_ARTIFACTS_BUILDINGS);
//Generate the village
$wid = $database->generateVillages($villageArrays, self::NATARS_UID, TRIBE5, $artifactTroops, $artifactBuildings);
//Update the artifact with the new village id and owner
$database->updateArtifactDetails($artifactArray['id'], ['vref' => $wid, 'owner' => self::NATARS_UID, 'active' => 0, 'del' => 0]);
}
/**
* Gets the artifact informations in plain text
+31 -235
View File
@@ -27,11 +27,21 @@ include_once("Ranking.php");
include_once("Generator.php");
include_once("Multisort.php");
include_once("Building.php");
include_once("Artifacts.php");
class Automation {
/**
* @var object The artifacts class, used to create Natars, artifacts and obtaining info about them
*/
private $artifacts;
public function __construct() {
//Classes initialization
$this->artifacts = new Artifacts();
$autoprefix = "";
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
@@ -238,13 +248,16 @@ class Automation {
@set_time_limit(0);
foreach($needDelete as $need) {
$needVillage = $database->getVillagesID($need['uid']);
$need['uid'] = (int) $need['uid'];
//Get the villages which have to be deleted
$needVillages = $database->getVillagesID($need['uid']);
//Delete all villages
foreach($needVillage as $village) $this->DelVillage((int) $village);
$database->DelVillage($needVillages);
for($i = 0;$i < 20; $i++){
$q = "SELECT id FROM ".TB_PREFIX."users where friend".$i." = ".(int) $need['uid']." or friend".$i."wait = ".(int) $need['uid']."";
$q = "SELECT id FROM ".TB_PREFIX."users where friend".$i." = ".$need['uid']." or friend".$i."wait = ".$need['uid']."";
$array = $database->query_return($q);
foreach($array as $friend){
$database->deleteFriend($friend['id'],"friend".$i);
@@ -264,25 +277,21 @@ class Automation {
Automation::updateMax($newleader);
}
if (isset($alliance)) {
$database->deleteAlliance($alliance);
}
$q = "UPDATE ".TB_PREFIX."artefacts where owner = ".(int) $need['uid']." SET del = 1";
$database->query($q);
if (isset($alliance)) $database->deleteAlliance($alliance);
$q = "DELETE FROM ".TB_PREFIX."hero where uid = ".(int) $need['uid'];
$q = "DELETE FROM ".TB_PREFIX."hero where uid = ".$need['uid'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."mdata where target = ".(int) $need['uid']." or owner = ".(int) $need['uid'];
$q = "DELETE FROM ".TB_PREFIX."mdata where target = ".$need['uid']." or owner = ".$need['uid'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."ndata where uid = ".(int) $need['uid'];
$q = "DELETE FROM ".TB_PREFIX."ndata where uid = ".$need['uid'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."users where id = ".(int) $need['uid'];
$q = "DELETE FROM ".TB_PREFIX."users where id = ".$need['uid'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."deleting where uid = ".(int) $need['uid'];
$q = "DELETE FROM ".TB_PREFIX."deleting where uid = ".$need['uid'];
$database->query($q);
}
}
@@ -2454,7 +2463,7 @@ class Automation {
}
//Delete the village
$this->DelVillage($data['to']);
$database->DelVillage($data['to']);
//Reassign the hero, if dead and assigned to the deleted village
$database->reassignHero($data['to']);
@@ -2569,96 +2578,6 @@ class Automation {
}
}
function DelVillage($wref){
global $database, $units;
$database->clearExpansionSlot($wref);
$wref = (int) $wref;
$q = "DELETE FROM ".TB_PREFIX."abdata where vref = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."bdata where wid = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."market where vref = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."research where vref = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."tdata where vref = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."fdata where vref = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."training where vref = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."units where vref = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."farmlist where wref = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."raidlist where towref = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."route where wid = $wref OR `from` = $wref";
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."movement where proc = 0 AND ((`to` = $wref AND sort_type=4) OR (`from` = $wref AND sort_type=3))";
$database->query($q);
$database->removeOases($wref, 1);
$getmovement = $database->getMovement(3, $wref, 1);
$moveIDs = [];
$time = microtime(true);
$types = [];
$froms = [];
$tos = [];
$refs = [];
$times = [];
$endtimes = [];
foreach($getmovement as $movedata) {
$time2 = $time - $movedata['starttime'];
$moveIDs[] = $movedata['moveid'];
$types[] = 4;
$froms[] = $movedata['to'];
$tos[] = $movedata['from'];
$refs[] = $movedata['ref'];
$times[] = $time;
$endtimes[] = $time+$time2;
}
$database->setMovementProc(implode(', ', $moveIDs));
$database->addMovement($types, $froms, $tos, $refs, $times, $endtimes);
$q = "DELETE FROM ".TB_PREFIX."enforcement WHERE `from` = $wref";
$database->query($q);
//check return enforcement from del village
$units->returnTroops($wref);
$q = "DELETE FROM ".TB_PREFIX."vdata WHERE `wref` = $wref";
$database->query($q);
if (mysqli_affected_rows($database->dblink) > 0) {
$q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = $wref";
$database->query($q);
// clear expansion slots, if this village is an expansion of any other village
$database->clearExpansionSlot($wref, 1);
$getprisoners = $database->getPrisoners($wref);
foreach($getprisoners as $pris) {
$troops = 0;
for($i = 1; $i < 12; $i++) $troops += $pris['t'.$i];
$database->modifyUnit($pris['wref'], ["99o"], [$troops], [0]);
$database->deletePrisoners($pris['id']);
}
$getprisoners = $database->getPrisoners3($wref);
foreach($getprisoners as $pris) {
$troops = 0;
for($i = 1;$i < 12; $i++) $troops += $pris['t'.$i];
$database->modifyUnit($pris['wref'], ["99o"], [$troops], [0]);
$database->deletePrisoners($pris['id']);
}
}
}
private function sendreinfunitsComplete() {
global $bid23, $database, $battle;
@@ -2983,41 +2902,7 @@ class Automation {
if($database->areArtifactsSpawned() || strtotime(START_DATE) + (NATARS_SPAWN_TIME * 86400) > time()) return;
//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" => 10, "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);
$this->artifacts->createNatars();
//Write the system message
$database->displaySystemMessage(ARTEFACT);
@@ -3035,44 +2920,8 @@ class Automation {
//and if it's the time to spawn them or not
if(!$database->areArtifactsSpawned() || $database->areWWVillagesSpawned() || strtotime(START_DATE) + (NATARS_WW_SPAWN_TIME * 86400) > time()) return;
//WW village Natars' troops
$unitArrays = [41 => rand(500, 12000) * NATARS_UNITS,
42 => rand(1000 , 14000) * NATARS_UNITS,
43 => rand(2000, 16000) * NATARS_UNITS,
44 => rand(100, 500) * NATARS_UNITS,
45 => rand(480, 17000) * NATARS_UNITS,
46 => rand(600, 18000) * NATARS_UNITS,
47 => rand(2000, 16000) * NATARS_UNITS,
48 => rand(400, 2000) * NATARS_UNITS,
49 => rand(40, 200) * NATARS_UNITS,
50 => rand(50, 250) * NATARS_UNITS];
//WW village buildings
$buildingArrays = [
//WW of the 0th level, Main Building of the 10th level, Marketplace of the 1th level, Delete Main Building of the 1th level
"f99t" => 40, "f99" => 0, "f22t" => 15, "f22" => 10, "f34t" => 17, "f34" => 1, "f26t" => 0, "f26" => 0,
//Warehouse of the 20th & 10th level, Granary of the 20th & 10th level
"f20t" => 10, "f20" => 20, "f19t" => 10, "f19" => 10, "f23t" => 11, "f23" => 20, "f27t" => 11, "f27" => 10,
//All Woodcutter of the 5th level
"f1t" => 1, "f1" => 5, "f3t" => 1, "f3" => 5, "f14t" => 1, "f14" => 5, "f17t" => 1, "f17" => 5,
//All Clay Pit of the 5th level
"f5t" => 2, "f5" => 5, "f6t" => 2, "f6" => 5, "f16t" => 2, "f16" => 5, "f18t" => 2, "f18" => 5,
//All Iron Mine of the 5th level
"f4t" => 3, "f4" => 5, "f7t" => 3, "f7" => 5, "f10t" => 3, "f10" => 5, "f11t" => 3, "f11" => 5,
//All Cropland of the 6th level
"f2t" => 4, "f2" => 6, "f8t" => 4, "f8" => 6, "f9t" => 4, "f9" => 6, "f12t" => 4, "f12" => 6, "f13t" => 4, "f13" => 6, "f15t" => 4, "f15" => 6];
$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', 'pop', 'name'], [1, 233, WWVILLAGE]);
// $this->recountPop($wid); //it is necessary to comment out otherwise the population will be 198
}
//Create WW villages
$this->artifacts->createWWVillages();
//Write the system message
$database->displaySystemMessage(WWVILLAGEMSG);
@@ -3090,10 +2939,8 @@ class Automation {
//and if it's the time to spawn them or not
if(!$database->areArtifactsSpawned() || $database->areArtifactsSpawned(true) || strtotime(START_DATE) + (NATARS_WW_BUILDING_PLAN_SPAWN_TIME * 86400) > time()) return;
$artifactArrays = [PLAN_DESC => [["type" => 11, "size" => 1, "name" => PLAN,"vname" => PLANVILLAGE, "effect" => "", "quantity" => 13, "img" => 1]]];
//Add the artifacts and villages
$database->addArtifactVillages($artifactArrays);
//Create WW building plans
$this->artifacts->createWWBuildingPlans();
//Set the system message to contain the infos of the WW building plans
$database->displaySystemMessage(PLAN_INFO);
@@ -3110,59 +2957,8 @@ class Automation {
//Check if there's at least one artifact, if not, return
if(!$database->areArtifactsSpawned()) return;
//Get all inactive artifacts that have to be activated --> (24 hours / Speed of the server)
$time = time();
$artifacts = $database->getInactiveArtifacts(round($time - (86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED)))));
if(!empty($artifacts)){
//Cache inactive artifacts by owner
$inactiveArtifactsCache = [];
foreach($artifacts as $artifact) $inactiveArtifactsCache[$artifact['owner']][] = $artifact;
foreach($inactiveArtifactsCache as $owner => $inactiveArtifacts){
//Initialize the array
$activeArtifacts = [];
//Get cached active artifacts
$ownArtifacts = $database->getOwnArtifactsSum($owner, true);
//Activate activable artifacts
foreach($inactiveArtifacts as $artifact){
if($ownArtifacts['totals'] < 3){
if($artifact['size'] == 1){ //Village effect
$database->activateArtifact($artifact['id']);
$ownArtifacts['totals']++;
$ownArtifacts['small']++;
}elseif($artifact['size'] == 2 && !$ownArtifacts['unique'] && !$ownArtifacts['great']){ //Account effect
$database->activateArtifact($artifact['id']);
$ownArtifacts['totals']++;
$ownArtifacts['great']++;
}elseif($artifact['size'] == 3 && !$ownArtifacts['unique'] && !$ownArtifacts['great']){ //Unique effect
$database->activateArtifact($artifact['id']);
$ownArtifacts['totals']++;
$ownArtifacts['unique']++;
}
}elseif($ownArtifacts['small'] == 3 && $artifact['size'] > 1){
//If we've 3 village effect artifacts activated and at least one account/unique effect not activated
//then we need to deactivate the most recent village effect artifact and activate the oldest account
//or unique effect artifact
//Deactivate the most recent village effect artifact
$database->activateArtifact($database->getNewestArtifactBySize($owner, 1)['id'], 0);
//Activate the great/unique artifact
$database->activateArtifact($artifact['id']);
$ownArtifacts['small']--;
$ownArtifacts['totals']++;
if($artifact['size'] == 2) $ownArtifacts['great']++;
else $ownArtifacts['unique']++;
}
}
}
}
//Activate the artifacts that need to be activated
$this->artifacts->activateArtifacts();
}
private function researchComplete() {
@@ -4837,7 +4633,7 @@ class Automation {
global $database;
$time = time();
$q = "SELECT id, size FROM " . TB_PREFIX . "artefacts where type = 8 AND active = 1 AND lastupdate <= ".($time - (86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED))));
$q = "SELECT id, size FROM " . TB_PREFIX . "artefacts where type = 8 AND active = 1 AND del = 0 AND lastupdate <= ".($time - (86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED))));
$array = $database->query_return($q);
if ($array) {
foreach($array as $artefact) {
+2 -2
View File
@@ -537,10 +537,10 @@ class Building {
case 37: return $this->getTypeLevel(15) >= 3 && $this->getTypeLevel(16) >= 1 && !$isBuilt;
// great warehouse can only be built with artefact or in Natar villages
case 38: return $this->getTypeLevel(15) >= 10 && (!$isBuilt || $this->getTypeLevel($id) == 20) && ($village->natar == 1 || count($database->getOwnUniqueArtefactInfo2($session->uid, 6, 1, 0)) || count($database->getOwnUniqueArtefactInfo2($session->uid, 6, 2, 0)));
case 38: return $this->getTypeLevel(15) >= 10 && (!$isBuilt || $this->getTypeLevel($id) == 20) && ($village->natar == 1 || count($database->getOwnUniqueArtefactInfo2($village->wid, 6, 1, 0)) || count($database->getOwnUniqueArtefactInfo2($session->uid, 6, 2, 0)));
// great granary can only be built with artefact or in Natar villages
case 39: return $this->getTypeLevel(15) >= 10 && (!$isBuilt || $this->getTypeLevel($id) == 20) && ($village->natar == 1 || count($database->getOwnUniqueArtefactInfo2($session->uid, 6, 1, 0)) || count($database->getOwnUniqueArtefactInfo2($session->uid, 6, 2, 0)));
case 39: return $this->getTypeLevel(15) >= 10 && (!$isBuilt || $this->getTypeLevel($id) == 20) && ($village->natar == 1 || count($database->getOwnUniqueArtefactInfo2($village->wid, 6, 1, 0)) || count($database->getOwnUniqueArtefactInfo2($session->uid, 6, 2, 0)));
case 40: return $this->allowWwUpgrade();
case 41: return $this->getTypeLevel(16) >= 10 && $this->getTypeLevel(20) == 20 && $session->tribe == 1 && !$isBuilt;
+483 -403
View File
File diff suppressed because it is too large Load Diff