+
+
+
![](../img/en/a/travian0.gif)
+
+
+
+
+
+CheckLogin()){
+ if($_POST or $_GET){
+ if($_GET['p'] and $_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($_POST['p'] and $_POST['s']){
+ $filename = '../Templates/Admin/results_'.$_POST['p'].'.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');
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GameEngine/Admin/ajax.js b/GameEngine/Admin/ajax.js
new file mode 100644
index 00000000..18f0b07e
--- /dev/null
+++ b/GameEngine/Admin/ajax.js
@@ -0,0 +1,70 @@
+var http_request = false;
+
+function macheRequest(url, id)
+{
+
+ http_request = false;
+
+ if (window.XMLHttpRequest)
+ { // Mozilla, Safari,...
+ http_request = new XMLHttpRequest();
+ if (http_request.overrideMimeType)
+ {
+ http_request.overrideMimeType('text/xml');
+ // zu dieser Zeile siehe weiter unten
+ }
+ }
+ else if (window.ActiveXObject)
+ { // IE
+ try
+ {
+ http_request = new ActiveXObject("Msxml2.XMLHTTP");
+ }
+ catch (e)
+ {
+ try
+ {
+ http_request = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ catch (e)
+ {
+ }
+ }
+ }
+
+ if (!http_request)
+ {
+ alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
+ return false;
+ }
+ http_request.onreadystatechange = function()
+ {
+ alertInhalt2(id);
+ };
+ http_request.open('GET', url, true);
+ http_request.send(null);
+
+}
+
+function alertInhalt2(id)
+{
+
+ if (http_request.readyState == 4)
+ {
+ if (http_request.status == 200)
+ {
+ // alert(http_request.responseText);
+ myElement = document.getElementById(id);
+ if (myElement != null)
+ {
+ myElement.innerHTML = http_request.responseText;
+ }
+
+ }
+ else
+ {
+ alert('Bei dem Request ist ein Problem aufgetreten.');
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/GameEngine/Admin/database.php b/GameEngine/Admin/database.php
new file mode 100644
index 00000000..5e66ef38
--- /dev/null
+++ b/GameEngine/Admin/database.php
@@ -0,0 +1,348 @@
+connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error());
+ mysql_select_db(SQL_DB, $this->connection) or die(mysql_error());
+ }
+
+ function Login($username,$password){
+ $q = "SELECT password FROM ".TB_PREFIX."users where username = '$username' and access >= ".MULTIHUNTER;
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ if($dbarray['password'] == md5($password)) {
+ mysql_query("Insert into ".TB_PREFIX."admin_log values (0,'X','$username logged in (IP:
".$_SERVER['REMOTE_ADDR'].")',".time().")");
+ return true;
+ }
+ else {
+ mysql_query("Insert into ".TB_PREFIX."admin_log values (0,'X','
IP: ".$_SERVER['REMOTE_ADDR']." tried to log in with username $username but access was denied!',".time().")");
+ return false;
+ }
+ }
+
+ function recountPopUser($uid){
+ global $database;
+ $villages = $database->getProfileVillages($uid);
+ for ($i = 0; $i <= count($villages)-1; $i++) {
+ $vid = $villages[$i]['wref'];
+ $this->recountPop($vid);
+ $this->recountCP($vid);
+ }
+ }
+
+ function recountPop($vid){
+ global $database;
+ $fdata = $database->getResourceLevel($vid);
+ $popTot = 0;
+ for ($i = 1; $i <= 40; $i++) {
+ $lvl = $fdata["f".$i];
+ $building = $fdata["f".$i."t"];
+ if($building){
+ $popTot += $this->buildingPOP($building,$lvl);
+ }
+ }
+ $q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
+ mysql_query($q, $this->connection);
+ }
+
+ function recountCP($vid){
+ global $database;
+ $fdata = $database->getResourceLevel($vid);
+ $popTot = 0;
+ for ($i = 1; $i <= 40; $i++) {
+ $lvl = $fdata["f".$i];
+ $building = $fdata["f".$i."t"];
+ if($building){
+ $popTot += $this->buildingCP($building,$lvl);
+ }
+ }
+ $q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid";
+ mysql_query($q, $this->connection);
+ }
+
+ function buildingPOP($f,$lvl){
+ $name = "bid".$f;
+ global $$name;
+ $popT = 0;
+ $dataarray = $$name;
+ for ($i = 0; $i <= $lvl; $i++) {
+ $popT += $dataarray[$i]['pop'];
+ }
+ return $popT;
+ }
+
+ function buildingCP($f,$lvl){
+ $name = "bid".$f;
+ global $$name;
+ $popT = 0;
+ $dataarray = $$name;
+
+ for ($i = 0; $i <= $lvl; $i++) {
+ $popT += $dataarray[$i]['cp'];
+ }
+ return $popT;
+ }
+
+ function getWref($x,$y) {
+ $q = "SELECT id FROM ".TB_PREFIX."wdata where x = $x and y = $y";
+ $result = mysql_query($q, $this->connection);
+ $r = mysql_fetch_array($result);
+ return $r['id'];
+ }
+
+ function AddVillage($post){
+ global $database;
+ $wid = $this->getWref($post['x'],$post['y']);
+ $uid = $post['uid'];
+ $status = $database->getVillageState($wid);
+ $status = 0;
+ if($status == 0){
+ mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Added new village
$wid to user
$uid',".time().")");
+ $database->setFieldTaken($wid);
+ $database->addVillage($wid,$uid,'new village','0');
+ $database->addResourceFields($wid,$database->getVillageType($wid));
+ $database->addUnits($wid);
+ $database->addTech($wid);
+ $database->addABTech($wid);
+ }
+ }
+
+ function Punish($post){
+ global $database;
+ $villages = $database->getProfileVillages($post['uid']);
+ $admid = $post['admid'];
+ $user = $database->getUserArray($post['uid'],1);
+ for ($i = 0; $i <= count($villages)-1; $i++) {
+ $vid = $villages[$i]['wref'];
+ if($post['punish']){
+ $popOld = $villages[$i]['pop'];
+ $proc = 100-$post['punish'];
+ $pop = floor(($popOld/100)*($proc));
+ if($pop <= 1 ){$pop = 2;}
+ $this->PunishBuilding($vid,$proc,$pop);
+
+ }
+ if($post['del_troop']){
+ if($user['tribe'] == 1) {
+ $unit = 1;
+ }else if($user['tribe'] == 2) {
+ $unit = 11;
+ }else if($user['tribe'] == 3) {
+ $unit = 21;
+ }
+ $this->DelUnits($villages[$i]['wref'],$unit);
+ }
+ if($post['clean_ware']){
+ $time = time();
+ $q = "UPDATE ".TB_PREFIX."vdata SET `wood` = '0', `clay` = '0', `iron` = '0', `crop` = '0', `lastupdate` = '$time' WHERE wref = $vid;";
+ mysql_query($q, $this->connection);
+ }
+ }
+ mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Punished user:
".$post['uid']." with
-".$post['punish']."% population',".time().")");
+ }
+
+ function PunishBuilding($vid,$proc,$pop){
+ global $database;
+ $q = "UPDATE ".TB_PREFIX."vdata set pop = $pop where wref = $vid;";
+ mysql_query($q, $this->connection);
+ $fdata = $database->getResourceLevel($vid);
+ for ($i = 1; $i <= 40; $i++) {
+ if($fdata['f'.$i]>1){
+ $zm = ($fdata['f'.$i]/100)*$proc;
+ if($zm < 1){$zm = 1;}else{$zm = floor($zm);}
+ $q = "UPDATE ".TB_PREFIX."fdata SET `f$i` = '$zm' WHERE `vref` = $vid;";
+ mysql_query($q, $this->connection);
+ }
+ }
+ }
+
+ function DelUnits($vid,$unit){
+ for ($i = $unit; $i <= 9+$unit; $i++) {
+ $this->DelUnits2($vid,$unit);
+ }
+ }
+
+ function DelUnits2($vid,$unit){
+ $q = "UPDATE ".TB_PREFIX."units SET `u$unit` = '0' WHERE `vref` = $vid;";
+ mysql_query($q, $this->connection);
+ }
+
+ function DelPlayer($uid,$pass){
+ global $database;
+ $ID = $_SESSION['id'];//$database->getUserField($_SESSION['username'],'id',1);
+ if($this->CheckPass($pass,$ID)){
+ $villages = $database->getProfileVillages($uid);
+ for ($i = 0; $i <= count($villages)-1; $i++) {
+ $this->DelVillage($villages[$i]['wref']);
+ }
+ $name = $database->getUserField($uid,"username",0);
+ mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$ID,'Deleted user
$name',".time().")");
+ $q = "DELETE FROM ".TB_PREFIX."users WHERE `id` = $uid;";
+ mysql_query($q, $this->connection);
+ }
+ }
+
+ function getUserActive() {
+ $time = time() - (60*5);
+ $q = "SELECT * FROM ".TB_PREFIX."users where timestamp > $time and username != 'support'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function CheckPass($password,$uid){
+ $q = "SELECT password FROM ".TB_PREFIX."users where id = '$uid' and access = ".ADMIN;
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ if($dbarray['password'] == md5($password)) {
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+ function DelVillage($wref){
+ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `wref` = $wref and capital = 0";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result) > 0){
+ mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Deleted village
$wref',".time().")");
+ $q = "DELETE FROM ".TB_PREFIX."vdata WHERE `wref` = $wref";
+ mysql_query($q, $this->connection);
+ $q = "DELETE FROM ".TB_PREFIX."units WHERE `vref` = $wref";
+ mysql_query($q, $this->connection);
+ $q = "DELETE FROM ".TB_PREFIX."bdata WHERE `wid` = $wref";
+ mysql_query($q, $this->connection);
+ $q = "DELETE FROM ".TB_PREFIX."abdata WHERE `wid` = $wref";
+ mysql_query($q, $this->connection);
+ $q = "DELETE FROM ".TB_PREFIX."fdata WHERE `vref` = $wref";
+ mysql_query($q, $this->connection);
+ $q = "DELETE FROM ".TB_PREFIX."training WHERE `vref` = $wref";
+ mysql_query($q, $this->connection);
+ $q = "DELETE FROM ".TB_PREFIX."movement WHERE `from` = $wref";
+ mysql_query($q, $this->connection);
+ $q = "UPDATE ".TB_PREFIX."wdata SET `occupied` = '0' WHERE `id` = $wref";
+ mysql_query($q, $this->connection);
+ }
+ }
+
+ function DelBan($uid,$id){
+ global $database;
+ $name = addslashes($database->getUserField($uid,"username",0));
+ mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Unbanned user
$name',".time().")");
+ $q = "UPDATE ".TB_PREFIX."users SET `access` = '".USER."' WHERE `id` = $uid;";
+ mysql_query($q, $this->connection);
+ $q = "UPDATE ".TB_PREFIX."banlist SET `active` = '0' WHERE `id` = $id;";
+ mysql_query($q, $this->connection);
+ }
+
+ function AddBan($uid,$end,$reason){
+ global $database;
+ $name = addslashes($database->getUserField($uid,"username",0));
+ mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Banned user
$name',".time().")");
+ $q = "UPDATE ".TB_PREFIX."users SET `access` = '0' WHERE `id` = $uid;";
+ mysql_query($q, $this->connection);
+ $time = time();
+ $admin = $_SESSION['id']; //$database->getUserField($_SESSION['username'],'id',1);
+ $name = addslashes($database->getUserField($uid,'username',0));
+ $q = "INSERT INTO ".TB_PREFIX."banlist (`uid`, `name`, `reason`, `time`, `end`, `admin`, `active`) VALUES ($uid, '$name' , '$reason', '$time', '$end', '$admin', '1');";
+ mysql_query($q, $this->connection);
+ }
+
+ function search_player($player){
+ $q = "SELECT id,username FROM ".TB_PREFIX."users WHERE `username` LIKE '%$player%' and username != 'support'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function search_email($email){
+ $q = "SELECT id,email FROM ".TB_PREFIX."users WHERE `email` LIKE '%$email%' and username != 'support'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function search_village($village){
+ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `name` LIKE '%$village%' or `wref` LIKE '%$village%'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function search_alliance($alliance){
+ $q = "SELECT * FROM ".TB_PREFIX."alidata WHERE `name` LIKE '%$alliance%' or `tag` LIKE '%$alliance%' or `id` LIKE '%$alliance%'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function search_ip($ip){
+ $q = "SELECT * FROM ".TB_PREFIX."login_log WHERE `ip` LIKE '%$ip%'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function search_banned(){
+ $q = "SELECT * FROM ".TB_PREFIX."banlist where active = '1'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function Del_banned(){
+ //$q = "SELECT * FROM ".TB_PREFIX."banlist";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ /***************************
+ Function to process MYSQLi->fetch_all (Only exist in MYSQL)
+ References: Result
+ ***************************/
+ function mysql_fetch_all($result) {
+ $all = array();
+ if($result) {
+ while ($row = mysql_fetch_assoc($result)){ $all[] = $row; }
+ return $all;
+ }
+ }
+
+ function query_return($q) {
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ /***************************
+ Function to do free query
+ References: Query
+ ***************************/
+ function query($query) {
+ return mysql_query($query, $this->connection);
+ }
+
+
+};
+
+$admin = new adm_DB;
+include("function.php");
+?>
\ No newline at end of file
diff --git a/GameEngine/Admin/function.php b/GameEngine/Admin/function.php
new file mode 100644
index 00000000..9c4523ef
--- /dev/null
+++ b/GameEngine/Admin/function.php
@@ -0,0 +1,168 @@
+= MULTIHUNTER and $_SESSION['id']){
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+ function Act($get){
+ global $admin,$database;
+
+ switch($get['action']){
+ case recountPop:
+ $admin->recountPop($get['did']);
+ $admin->recountCP($get['did']);
+ break;
+ case recountPopUsr:
+ $admin->recountPopUser($get['uid']);
+ break;
+ case StopDel:
+ //stop deleting
+ break;
+ case delVil:
+ $admin->DelVillage($get['did']);
+ break;
+ case delBan:
+ $admin->DelBan($get['uid'],$get['id']);
+ //remove ban
+ break;
+ case addBan:
+ if($get['time']){$end = time()+$get['time']; }else{$end = '';}
+
+ if(is_numeric($get['uid'])){
+ $get['uid'] = $get['uid'];
+ }else{
+ $get['uid'] = $database->getUserField(addslashes($get['uid']),'id',1);
+ }
+
+ $admin->AddBan($get['uid'],$end,$get['reason']);
+ //add ban
+ break;
+ case delOas:
+ //oaza
+ break;
+ case logout:
+ $this->LogOut();
+ break;
+ }
+ if($get['action'] == 'logout'){
+ header("Location: admin.php");
+ }else{
+ header("Location: ".$_SERVER['HTTP_REFERER']);
+ }
+ }
+
+ function Act2($post){
+ global $admin,$database;
+ switch($post['action']){
+ case DelPlayer:
+ $admin->DelPlayer($post['uid'],$post['pass']);
+ header("Location: ?p=search&msg=ursdel");
+ break;
+ case punish:
+ $admin->Punish($post);
+ header("Location: ".$_SERVER['HTTP_REFERER']);
+ break;
+ case addVillage:
+ $admin->AddVillage($post);
+ header("Location: ".$_SERVER['HTTP_REFERER']);
+ break;
+ }
+ }
+
+ function LogIN($username,$password){
+ global $admin,$database;
+ if($admin->Login($username,$password)){
+ //$_SESSION['username'] = $username;
+ $_SESSION['access'] = $database->getUserField($username,'access',1);
+ $_SESSION['id'] = $database->getUserField($username,'id',1);
+ header("Location: ".$_SERVER['HTTP_REFERER']);
+ //header("Location: admin.php");
+ }else{
+ echo "Error";
+ }
+ }
+
+ function LogOut(){
+ $_SESSION['access'] = '';
+ $_SESSION['id'] = '';
+ }
+
+ public function procResType($ref) {
+ global $session;
+ switch($ref) {
+ case 1: $build = "Woodcutter"; break;
+ case 2: $build = "Clay Pit"; break;
+ case 3: $build = "Iron Mine"; break;
+ case 4: $build = "Cropland"; break;
+ case 5: $build = "Sawmill"; break;
+ case 6: $build = "Brickyard"; break;
+ case 7: $build = "Iron Foundry"; break;
+ case 8: $build = "Grain Mill"; break;
+ case 9: $build = "Bakery"; break;
+ case 10: $build = "Warehouse"; break;
+ case 11: $build = "Granary"; break;
+ case 12: $build = "Blacksmith"; break;
+ case 13: $build = "Armoury"; break;
+ case 14: $build = "Tournament Square"; break;
+ case 15: $build = "Main Building"; break;
+ case 16: $build = "Rally Point"; break;
+ case 17: $build = "Marketplace"; break;
+ case 18: $build = "Embassy"; break;
+ case 19: $build = "Barracks"; break;
+ case 20: $build = "Stable"; break;
+ case 21: $build = "Workshop"; break;
+ case 22: $build = "Academy"; break;
+ case 23: $build = "Cranny"; break;
+ case 24: $build = "Town Hall"; break;
+ case 25: $build = "Residence"; break;
+ case 26: $build = "Palace"; break;
+ case 27: $build = "Treasury"; break;
+ case 28: $build = "Trade Office"; break;
+ case 29: $build = "Great Barracks"; break;
+ case 30: $build = "Great Stable"; break;
+ case 31: $build = "City Wall"; break;
+ case 32: $build = "Earth Wall"; break;
+ case 33: $build = "Palisade"; break;
+ case 34: $build = "Stonemason's Lodge"; break;
+ case 35: $build = "Brewery"; break;
+ case 36: $build = "Trapper"; break;
+ case 37: $build = "Hero's Mansion"; break;
+ case 38: $build = "Great Warehouse"; break;
+ case 39: $build = "Great Granary"; break;
+ case 40: $build = "Wonder of the World"; break;
+ case 41: $build = "Horse Drinking Trough"; break;
+ default: $build = "Error"; break;
+ }
+ return $build;
+ }
+
+};
+
+$funct = new funct;
+if($funct->CheckLogin()){
+ if($_GET['action']){
+ $funct->Act($_GET);
+ }
+ if($_POST['action']){
+ $funct->Act2($_POST);
+ }
+}
+if($_POST['action']=='login'){
+ $funct->LogIN($_POST['name'],$_POST['pw']);
+}
+?>
\ No newline at end of file
diff --git a/GameEngine/Admin/welcome.tpl b/GameEngine/Admin/welcome.tpl
new file mode 100644
index 00000000..d0ed6e71
--- /dev/null
+++ b/GameEngine/Admin/welcome.tpl
@@ -0,0 +1,6 @@
+Hello %USER%,
+
+Thank you for registering on our server.
+Since the %START% at %TIME% Romans, Gauls and Teutons attack each other on this game world. Right now, %PLAYERS% players in %ALLI% Alliances are fighting for supremacy.
+
+Regards, %SERVER_NAME%
\ No newline at end of file
diff --git a/GameEngine/Alliance.php b/GameEngine/Alliance.php
new file mode 100644
index 00000000..64597bbf
--- /dev/null
+++ b/GameEngine/Alliance.php
@@ -0,0 +1,464 @@
+
+|
+| This script is property of TravianX Project. You are allowed to change
+| its source and release it under own name, not under name `TravianX`.
+| You have no rights to remove copyright notices.
+|
+| TravianX All rights reserved
+|
+*/
+
+ class Alliance {
+
+ public $gotInvite = false;
+ public $inviteArray = array();
+ public $allianceArray = array();
+ public $userPermArray = array();
+
+ public function procAlliance($get) {
+ global $session, $database;
+
+ if($session->alliance != 0) {
+ $this->allianceArray = $database->getAlliance($session->alliance);
+ // Permissions Array
+ // [id] => id [uid] => uid [alliance] => alliance [opt1] => X [opt2] => X [opt3] => X [opt4] => X [opt5] => X [opt6] => X [opt7] => X [opt8] => X
+ $this->userPermArray = $database->getAlliPermissions($session->uid, $session->alliance);
+ } else {
+ $this->inviteArray = $database->getInvitation($session->uid);
+ $this->gotInvite = count($this->inviteArray) == 0 ? false : true;
+ }
+ if(isset($get['a'])) {
+ switch($get['a']) {
+ case 2:
+ $this->rejectInvite($get);
+ break;
+ case 3:
+ $this->acceptInvite($get);
+ break;
+ default:
+ break;
+ }
+ }
+ if(isset($get['o'])) {
+ switch($get['o']) {
+ case 4:
+ $this->delInvite($get);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ public function procAlliForm($post) {
+ if(isset($post['ft'])) {
+ switch($post['ft']) {
+ case "ali1":
+ $this->createAlliance($post);
+ break;
+ }
+
+ }
+ if(isset($_POST['dipl']) and isset($_POST['a_name'])) {
+ $this->changediplomacy($post);
+ }
+
+ if(isset($post['s'])) {
+ if(isset($post['o'])) {
+ switch($post['o']) {
+ case 1:
+ if(isset($_POST['a'])) {
+ $this->changeUserPermissions($post);
+ }
+ break;
+ case 2:
+ if(isset($_POST['a_user'])) {
+ $this->kickAlliUser($post);
+ }
+ break;
+ case 4:
+ if(isset($_POST['a']) && $_POST['a'] == 4) {
+ $this->sendInvite($post);
+ }
+ break;
+ case 3:
+ $this->updateAlliProfile($post);
+ break;
+ case 11:
+ $this->quitally($post);
+ break;
+ case 100:
+ $this->changeAliName($post);
+ break;
+ }
+ }
+ }
+ }
+
+ /*****************************************
+ Function to process of sending invitations
+ *****************************************/
+ public function sendInvite($post) {
+ global $form, $database, $session;
+ if($session->access != BANNED){
+ $UserData = $database->getUserArray(stripslashes($post['a_name']), 0);
+ if($this->userPermArray['opt4'] == 0) {
+ $form->addError("perm", NO_PERMISSION);
+ }elseif(!isset($post['a_name']) || $post['a_name'] == "") {
+ $form->addError("name1", NAME_EMPTY);
+ }elseif(!$database->checkExist(stripslashes($post['a_name']), 0)) {
+ $form->addError("name2", NAME_NO_EXIST."".stripslashes(stripslashes($post['a_name'])));
+ }elseif($UserData['id'] == $session->uid) {
+ $form->addError("name3", SAME_NAME);
+ }elseif($database->getInvitation2($UserData['id'],$session->alliance)) {
+ $form->addError("name4", $post['a_name'].ALREADY_INVITED);
+ }elseif($UserData['alliance'] == $session->alliance) {
+ $form->addError("name5", $post['a_name'].ALREADY_IN_ALLY);
+ }else{
+ // Obtenemos la informacion necesaria
+ $aid = $session->alliance;
+ // Insertamos invitacion
+ $database->sendInvitation($UserData['id'], $aid, $session->uid);
+ // Log the notice
+ $database->insertAlliNotice($session->alliance, '
' . addslashes($session->username) . ' has invited
' . addslashes($UserData['username']) . ' into the alliance.');
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ /*****************************************
+ Function to reject an invitation
+ *****************************************/
+ private function rejectInvite($get) {
+ global $database, $session;
+ if($session->access != BANNED){
+ foreach($this->inviteArray as $invite) {
+ if($invite['id'] == $get['d']) {
+ $database->removeInvitation($get['d']);
+ $database->insertAlliNotice($invite['alliance'], '
' . addslashes($session->username) . ' has rejected the invitation.');
+ }
+ }
+ header("Location: build.php?id=".$get['id']);
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ /*****************************************
+ Function to del an invitation
+ *****************************************/
+ private function delInvite($get) {
+ global $database, $session;
+ if($session->access != BANNED){
+ $inviteArray = $database->getAliInvitations($session->alliance);
+ foreach($inviteArray as $invite) {
+ if($invite['id'] == $get['d']) {
+ $invitename = $database->getUserArray($invite['uid'], 1);
+ $database->removeInvitation($get['d']);
+ $database->insertAlliNotice($session->alliance, '
' . addslashes($session->username) . ' has deleted the invitation for
' . addslashes($invitename['username']) . '.');
+ }
+ }
+ header("Location: allianz.php?delinvite");
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ /*****************************************
+ Function to accept an invitation
+ *****************************************/
+ private function acceptInvite($get) {
+ global $form, $database, $session;
+ if($session->access != BANNED){
+ foreach($this->inviteArray as $invite) {
+ if($session->alliance == 0){
+ if($invite['id'] == $get['d'] && $invite['uid'] == $session->uid) {
+ $memberlist = $database->getAllMember($invite['alliance']);
+ $alliance_info = $database->getAlliance($invite['alliance']);
+ if(count($memberlist) < $alliance_info['max']){
+ $database->removeInvitation($database->RemoveXSS($get['d']));
+ $database->updateUserField($database->RemoveXSS($invite['uid']), "alliance", $database->RemoveXSS($invite['alliance']), 1);
+ $database->createAlliPermissions($database->RemoveXSS($invite['uid']), $database->RemoveXSS($invite['alliance']), '', '0', '0', '0', '0', '0', '0', '0', '0');
+ // Log the notice
+ $database->insertAlliNotice($invite['alliance'], '
' . addslashes($session->username) . ' has joined the alliance.');
+ }else{
+ $accept_error = 1;
+ $max = $alliance_info['max'];
+ }
+ }
+ }
+ }
+ if($accept_error == 1){
+ $form->addError("ally_accept", "The alliance can contain only ".$max." peoples right now.");
+ }else{
+ header("Location: build.php?id=" . $get['id']);
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ /*****************************************
+ Function to create an alliance
+ *****************************************/
+ private function createAlliance($post) {
+ global $form, $database, $session, $bid18, $village;
+ if($session->access != BANNED){
+ if(!isset($post['ally1']) || $post['ally1'] == "") {
+ $form->addError("ally1", ATAG_EMPTY);
+ }
+ if(!isset($post['ally2']) || $post['ally2'] == "") {
+ $form->addError("ally2", ANAME_EMPTY);
+ }
+ if($database->aExist($post['ally1'], "tag")) {
+ $form->addError("ally1", ATAG_EXIST);
+ }
+ if($database->aExist($post['ally2'], "name")) {
+ $form->addError("ally2", ANAME_EXIST);
+ }
+ if($form->returnErrors() != 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $post;
+
+ header("Location: build.php?id=" . $post['id']);
+ } else {
+ $max = $bid18[$village->resarray['f' . $post['id']]]['attri'];
+ $aid = $database->createAlliance($database->RemoveXSS($post['ally1']), $database->RemoveXSS($post['ally2']), $session->uid, $max);
+ $database->updateUserField($database->RemoveXSS($session->uid), "alliance", $database->RemoveXSS($aid), 1);
+ $database->procAllyPop($aid);
+ // Asign Permissions
+ $database->createAlliPermissions($database->RemoveXSS($session->uid), $database->RemoveXSS($aid), 'Alliance founder', '1', '1', '1', '1', '1', '1', '1', '1');
+ // log the notice
+ $database->insertAlliNotice($aid, 'The alliance has been founded by
' . addslashes($session->username) . '.');
+ header("Location: build.php?id=" . $post['id']);
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ /*****************************************
+ Function to change the alliance name
+ *****************************************/
+ private function changeAliName($get) {
+ global $form, $database, $session;
+ if($session->access != BANNED){
+ if(!isset($get['ally1']) || $get['ally1'] == "") {
+ $form->addError("ally1", ATAG_EMPTY);
+ }
+ if(!isset($get['ally2']) || $get['ally2'] == "") {
+ $form->addError("ally2", ANAME_EMPTY);
+ }
+ if($database->aExist($get['ally1'], "tag")) {
+ $form->addError("tag", ATAG_EXIST);
+ }
+ if($database->aExist($get['ally2'], "name")) {
+ $form->addError("name", ANAME_EXIST);
+ }
+ if($this->userPermArray['opt3'] == 0) {
+ $form->addError("perm", NO_PERMISSION);
+ }
+ if($form->returnErrors() != 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $post;
+ //header("Location: build.php?id=".$post['id']);
+ } else {
+ $database->setAlliName($database->RemoveXSS($session->alliance), $database->RemoveXSS($get['ally2']), $database->RemoveXSS($get['ally1']));
+ // log the notice
+ $database->insertAlliNotice($session->alliance, '
' . addslashes($session->username) . ' has changed the alliance name.');
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ /*****************************************
+ Function to create/change the alliance description
+ *****************************************/
+ private function updateAlliProfile($post) {
+ global $database, $session, $form;
+ if($session->access != BANNED){
+ if($this->userPermArray['opt3'] == 0) {
+ $form->addError("perm", NO_PERMISSION);
+ }
+ if($form->returnErrors() != 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $post;
+ //header("Location: build.php?id=".$post['id']);
+ } else {
+ $database->submitAlliProfile($database->RemoveXSS($session->alliance), $post['be2'], $post['be1']);
+ // log the notice
+ $database->insertAlliNotice($session->alliance, '
' . addslashes($session->username) . ' has changed the alliance description.');
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ /*****************************************
+ Function to change the user permissions
+ *****************************************/
+ private function changeUserPermissions($post) {
+ global $database, $session, $form;
+ if($session->access != BANNED){
+ if($this->userPermArray['opt1'] == 0) {
+ $form->addError("perm", NO_PERMISSION);
+ }
+ if($form->returnErrors() != 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $post;
+ //header("Location: build.php?id=".$post['id']);
+ } else {
+ $database->updateAlliPermissions($post['a_user'], $session->alliance, $post['a_titel'], $post['e1'], $post['e2'], $post['e3'], $post['e4'], $post['e5'], $post['e6'], $post['e7']);
+ // log the notice
+ $database->insertAlliNotice($session->alliance, '
' . addslashes($session->username) . ' has changed permissions.');
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+ /*****************************************
+ Function to kick a user from alliance
+ *****************************************/
+ private function kickAlliUser($post) {
+ global $database, $session, $form;
+ if($session->access != BANNED){
+ $UserData = $database->getUserArray($post['a_user'], 0);
+ if($this->userPermArray['opt2'] == 0) {
+ $form->addError("perm", NO_PERMISSION);
+ } else if($UserData['id'] != $session->uid){
+ $database->updateUserField($post['a_user'], 'alliance', 0, 1);
+ $database->deleteAlliPermissions($post['a_user']);
+ $database->deleteAlliance($session->alliance);
+ // log the notice
+ $database->insertAlliNotice($session->alliance, '
' . addslashes($post['a_user']) . ' has quit the alliance.');
+ if($database->isAllianceOwner($UserData['id'])){
+ $newowner = $database->getAllMember2($session->alliance);
+ $newleader = $newowner['id'];
+ $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$session->alliance."";
+ $database->query($q);
+ $database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1);
+ $this->updateMax($newleader);
+ }
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+ /*****************************************
+ Function to set forum link
+ *****************************************/
+ public function setForumLink($post) {
+ global $database, $session;
+ if($session->access != BANNED){
+ if(isset($post['f_link'])){
+ $database->setAlliForumLink($session->alliance, $post['f_link']);
+ header("Location: allianz.php?s=5");
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+ /*****************************************
+ Function to quit from alliance
+ *****************************************/
+ private function quitally($post) {
+ global $database, $session, $form;
+ if($session->access != BANNED){
+ if(!isset($post['pw']) || $post['pw'] == "") {
+ $form->addError("pw1", PW_EMPTY);
+ } elseif(md5($post['pw']) !== $session->userinfo['password']) {
+ $form->addError("pw2", PW_ERR);
+ } else {
+ $database->updateUserField($session->uid, 'alliance', 0, 1);
+ if($database->isAllianceOwner($session->uid)){
+ $newowner = $database->getAllMember2($session->alliance);
+ $newleader = $newowner['id'];
+ $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$session->alliance."";
+ $database->query($q);
+ $database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1);
+ $this->updateMax($newleader);
+ }
+ $database->deleteAlliPermissions($session->uid);
+ // log the notice
+ $database->deleteAlliance($session->alliance);
+ $database->insertAlliNotice($session->alliance, '
' . addslashes($session->username) . ' has quit the alliance.');
+ header("Location: spieler.php?uid=".$session->uid);
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ private function changediplomacy($post) {
+ global $database, $session, $form;
+ if($session->access != BANNED){
+ $aName = $database->RemoveXSS($_POST['a_name']);
+ $aType = (int)intval($_POST['dipl']);
+ if($database->aExist($aName, "tag")) {
+ if($database->getAllianceID($aName) != $session->alliance) {
+ if($aType >= 1 and $aType <= 3) {
+ if(!$database->diplomacyInviteCheck2($session->alliance, $database->getAllianceID($aName))) {
+ $database->diplomacyInviteAdd($session->alliance, $database->getAllianceID($aName), $aType);
+ if($aType == 1){
+ $notice = "offer a confederation to";
+ }else if($aType == 2){
+ $notice = "offer non-aggression pact to";
+ }else if($aType == 3){
+ $notice = "declare war on";
+ }
+ $database->insertAlliNotice($session->alliance, '
' . $database->getAllianceName($session->alliance) . ' '. $notice .'
' . $aName . '.');
+ $form->addError("name", "Invite sended");
+ } else {
+ $form->addError("name", "You have already sended them a invite");
+ }
+
+ } else {
+ $form->addError("name", "wrong choice made");
+ }
+ } else {
+ $form->addError("name", "You can not invite your own alliance");
+ }
+ } else {
+ $form->addError("name", "Alliance does not exist");
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ private function updateMax($leader) {
+ global $bid18, $database;
+ $q = mysql_query("SELECT * FROM " . TB_PREFIX . "alidata where leader = $leader");
+ if(mysql_num_rows($q) > 0){
+ $villages = $database->getVillagesID2($leader);
+ $max = 0;
+ foreach($villages as $village){
+ $field = $database->getResourceLevel($village['wref']);
+ for($i=19;$i<=40;$i++){
+ if($field['f'.$i.'t'] == 18){
+ $level = $field['f'.$i];
+ $attri = $bid18[$level]['attri'];
+ }
+ }
+ if($attri > $max){
+ $max = $attri;
+ }
+ }
+ $q = "UPDATE ".TB_PREFIX."alidata set max = $max where leader = $leader";
+ $database->query($q);
+ }
+ }
+ }
+
+ $alliance = new Alliance;
+
+?>
diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php
new file mode 100644
index 00000000..65e3db3b
--- /dev/null
+++ b/GameEngine/Automation.php
@@ -0,0 +1,4415 @@
+ 0)
+ {
+ header('Location: /winner.php');
+ }else{
+ ## there is no winner
+ }
+ }
+
+ public function procResType($ref) {
+ global $session;
+ switch($ref) {
+ case 1: $build = "Woodcutter"; break;
+ case 2: $build = "Clay Pit"; break;
+ case 3: $build = "Iron Mine"; break;
+ case 4: $build = "Cropland"; break;
+ case 5: $build = "Sawmill"; break;
+ case 6: $build = "Brickyard"; break;
+ case 7: $build = "Iron Foundry"; break;
+ case 8: $build = "Grain Mill"; break;
+ case 9: $build = "Bakery"; break;
+ case 10: $build = "Warehouse"; break;
+ case 11: $build = "Granary"; break;
+ case 12: $build = "Blacksmith"; break;
+ case 13: $build = "Armoury"; break;
+ case 14: $build = "Tournament Square"; break;
+ case 15: $build = "Main Building"; break;
+ case 16: $build = "Rally Point"; break;
+ case 17: $build = "Marketplace"; break;
+ case 18: $build = "Embassy"; break;
+ case 19: $build = "Barracks"; break;
+ case 20: $build = "Stable"; break;
+ case 21: $build = "Workshop"; break;
+ case 22: $build = "Academy"; break;
+ case 23: $build = "Cranny"; break;
+ case 24: $build = "Town Hall"; break;
+ case 25: $build = "Residence"; break;
+ case 26: $build = "Palace"; break;
+ case 27: $build = "Treasury"; break;
+ case 28: $build = "Trade Office"; break;
+ case 29: $build = "Great Barracks"; break;
+ case 30: $build = "Great Stable"; break;
+ case 31: $build = "City Wall"; break;
+ case 32: $build = "Earth Wall"; break;
+ case 33: $build = "Palisade"; break;
+ case 34: $build = "Stonemason's Lodge"; break;
+ case 35: $build = "Brewery"; break;
+ case 36: $build = "Trapper"; break;
+ case 37: $build = "Hero's Mansion"; break;
+ case 38: $build = "Great Warehouse"; break;
+ case 39: $build = "Great Granary"; break;
+ case 40: $build = "Wonder of the World"; break;
+ case 41: $build = "Horse Drinking Trough"; break;
+ case 42: $build = "Great Workshop"; break;
+ default: $build = "Nothing had"; break;
+ }
+ return addslashes($build);
+ }
+
+ function recountPop($vid){
+ global $database;
+ $fdata = $database->getResourceLevel($vid);
+ $popTot = 0;
+
+ for ($i = 1; $i <= 40; $i++) {
+ $lvl = $fdata["f".$i];
+ $building = $fdata["f".$i."t"];
+ if($building){
+ $popTot += $this->buildingPOP($building,$lvl);
+ }
+ }
+ $this->recountCP($vid);
+ $q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
+ mysql_query($q);
+ $owner = $database->getVillageField($vid,"owner");
+ $this->procClimbers($owner);
+
+ return $popTot;
+
+ }
+
+ function recountCP($vid){
+ global $database;
+ $fdata = $database->getResourceLevel($vid);
+ $popTot = 0;
+
+ for ($i = 1; $i <= 40; $i++) {
+ $lvl = $fdata["f".$i];
+ $building = $fdata["f".$i."t"];
+ if($building){
+ $popTot += $this->buildingCP($building,$lvl);
+ }
+ }
+
+ $q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid";
+ mysql_query($q);
+
+ return $popTot;
+
+ }
+
+ function buildingPOP($f,$lvl){
+ $name = "bid".$f;
+ global $$name;
+ $popT = 0;
+ $dataarray = $$name;
+
+ for ($i = 0; $i <= $lvl; $i++) {
+ $popT += $dataarray[$i]['pop'];
+ }
+ return $popT;
+ }
+
+ function buildingCP($f,$lvl){
+ $name = "bid".$f;
+ global $$name;
+ $popT = 0;
+ $dataarray = $$name;
+
+ for ($i = 0; $i <= $lvl; $i++) {
+ $popT += $dataarray[$i]['cp'];
+ }
+ return $popT;
+ }
+
+ public function Automation() {
+
+ $this->procNewClimbers();
+ $this->ClearUser();
+ $this->ClearInactive();
+ $this->oasisResourcesProduce();
+ $this->pruneResource();
+ $this->pruneOResource();
+ $this->checkWWAttacks();
+ if(!file_exists("GameEngine/Prevention/culturepoints.txt") or time()-filemtime("GameEngine/Prevention/culturepoints.txt")>50) {
+ $this->culturePoints();
+ }
+ if(!file_exists("GameEngine/Prevention/updatehero.txt") or time()-filemtime("GameEngine/Prevention/updatehero.txt")>50) {
+ $this->updateHero();
+ }
+ if(!file_exists("GameEngine/Prevention/cleardeleting.txt") or time()-filemtime("GameEngine/Prevention/cleardeleting.txt")>50) {
+ $this->clearDeleting();
+ }
+ if (! file_exists("GameEngine/Prevention/build.txt") or time() - filemtime("GameEngine/Prevention/build.txt")>50)
+ {
+ $this->buildComplete();
+ }
+ $this->MasterBuilder();
+ if (! file_exists("GameEngine/Prevention/demolition.txt") or time() - filemtime("GameEngine/Prevention/demolition.txt")>50)
+ {
+ $this->demolitionComplete();
+ }
+ $this->updateStore();
+ $this->delTradeRoute();
+ $this->TradeRoute();
+ if(!file_exists("GameEngine/Prevention/market.txt") or time()-filemtime("GameEngine/Prevention/market.txt")>50) {
+ $this->marketComplete();
+ }
+ if(!file_exists("GameEngine/Prevention/research.txt") or time()-filemtime("GameEngine/Prevention/research.txt")>50) {
+ $this->researchComplete();
+ }
+ if(!file_exists("GameEngine/Prevention/training.txt") or time()-filemtime("GameEngine/Prevention/training.txt")>50) {
+ $this->trainingComplete();
+ }
+ if(!file_exists("GameEngine/Prevention/starvation.txt") or time()-filemtime("GameEngine/Prevention/starvation.txt")>50) {
+ $this->starvation();
+ }
+ if(!file_exists("GameEngine/Prevention/celebration.txt") or time()-filemtime("GameEngine/Prevention/celebration.txt")>50) {
+ $this->celebrationComplete();
+ }
+ if(!file_exists("GameEngine/Prevention/sendunits.txt") or time()-filemtime("GameEngine/Prevention/sendunits.txt")>50) {
+ $this->sendunitsComplete();
+ }
+ if(!file_exists("GameEngine/Prevention/loyalty.txt") or time()-filemtime("GameEngine/Prevention/loyalty.txt")>50) {
+ $this->loyaltyRegeneration();
+ }
+ if(!file_exists("GameEngine/Prevention/sendreinfunits.txt") or time()-filemtime("GameEngine/Prevention/sendreinfunits.txt")>50) {
+ $this->sendreinfunitsComplete();
+ }
+ if(!file_exists("GameEngine/Prevention/returnunits.txt") or time()-filemtime("GameEngine/Prevention/returnunits.txt")>50) {
+ $this->returnunitsComplete();
+ }
+ if(!file_exists("GameEngine/Prevention/settlers.txt") or time()-filemtime("GameEngine/Prevention/settlers.txt")>50) {
+ $this->sendSettlersComplete();
+ }
+ $this->updateGeneralAttack();
+ $this->checkInvitedPlayes();
+ $this->updateStore();
+ $this->CheckBan();
+ $this->regenerateOasisTroops();
+
+ $this->artefactOfTheFool();
+ }
+
+ private function loyaltyRegeneration() {
+ if(file_exists("GameEngine/Prevention/loyalty.txt")) {
+ unlink("GameEngine/Prevention/loyalty.txt");
+ }
+ global $database;
+ $array = array();
+ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE loyalty<>100";
+ $array = $database->query_return($q);
+ if(!empty($array)) {
+ foreach($array as $loyalty) {
+ if($this->getTypeLevel(25,$loyalty['wref']) >= 1){
+ $value = $this->getTypeLevel(25,$loyalty['wref']);
+ }elseif($this->getTypeLevel(26,$loyalty['wref']) >= 1){
+ $value = $this->getTypeLevel(26,$loyalty['wref']);
+ } else {
+ $value = 0;
+ }
+ $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdate'])/(60*60));
+ $q = "UPDATE ".TB_PREFIX."vdata SET loyalty = $newloyalty WHERE wref = '".$loyalty['wref']."'";
+ $database->query($q);
+ }
+ }
+ $array = array();
+ $q = "SELECT * FROM ".TB_PREFIX."odata WHERE loyalty<>100";
+ $array = $database->query_return($q);
+ if(!empty($array)) {
+ foreach($array as $loyalty) {
+ if($this->getTypeLevel(25,$loyalty['conqured']) >= 1){
+ $value = $this->getTypeLevel(25,$loyalty['conqured']);
+ }elseif($this->getTypeLevel(26,$loyalty['conqured']) >= 1){
+ $value = $this->getTypeLevel(26,$loyalty['conqured']);
+ } else {
+ $value = 0;
+ }
+ $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdate'])/(60*60));
+ $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty WHERE wref = '".$loyalty['wref']."'";
+ $database->query($q);
+ }
+ }
+ if(file_exists("GameEngine/Prevention/loyalty.txt")) {
+ unlink("GameEngine/Prevention/loyalty.txt");
+ }
+ }
+
+ private function getfieldDistance($coorx1, $coory1, $coorx2, $coory2) {
+ $max = 2 * WORLD_MAX + 1;
+ $x1 = intval($coorx1);
+ $y1 = intval($coory1);
+ $x2 = intval($coorx2);
+ $y2 = intval($coory2);
+ $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1)));
+ $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1)));
+ $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2));
+ return round($dist, 1);
+ }
+
+ public function getTypeLevel($tid,$vid) {
+ global $village,$database;
+ $keyholder = array();
+
+ $resourcearray = $database->getResourceLevel($vid);
+
+ foreach(array_keys($resourcearray,$tid) as $key) {
+ if(strpos($key,'t')) {
+ $key = preg_replace("/[^0-9]/", '', $key);
+ array_push($keyholder, $key);
+ }
+ }
+ $element = count($keyholder);
+ if($element >= 2) {
+ if($tid <= 4) {
+ $temparray = array();
+ for($i=0;$i<=$element-1;$i++) {
+ array_push($temparray,$resourcearray['f'.$keyholder[$i]]);
+ }
+ foreach ($temparray as $key => $val) {
+ if ($val == max($temparray))
+ $target = $key;
+ }
+ }
+ else {
+ $target = 0;
+ for($i=1;$i<=$element-1;$i++) {
+ if($resourcearray['f'.$keyholder[$i]] > $resourcearray['f'.$keyholder[$target]]) {
+ $target = $i;
+ }
+ }
+ }
+ }
+ else if($element == 1) {
+ $target = 0;
+ }
+ else {
+ return 0;
+ }
+ if($keyholder[$target] != "") {
+ return $resourcearray['f'.$keyholder[$target]];
+ }
+ else {
+ return 0;
+ }
+ }
+
+ private function clearDeleting() {
+ if(file_exists("GameEngine/Prevention/cleardeleting.txt")) {
+ unlink("GameEngine/Prevention/cleardeleting.txt");
+ }
+ global $database;
+ $ourFileHandle = fopen("GameEngine/Prevention/cleardeleting.txt", 'w');
+ fclose($ourFileHandle);
+ $needDelete = $database->getNeedDelete();
+ if(count($needDelete) > 0) {
+ foreach($needDelete as $need) {
+ $needVillage = $database->getVillagesID($need['uid']);
+ foreach($needVillage as $village) {
+ $q = "DELETE FROM ".TB_PREFIX."abdata where wref = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."bdata where wid = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."enforcement where from = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."fdata where vref = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."market where vref = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."odata where wref = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."research where vref = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."tdata where vref = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."training where vref =".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."units where vref =".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."farmlist where wref =".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."raidlist where towref = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."vdata where wref = ".$village;
+ $database->query($q);
+ $q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = ".$village;
+ $database->query($q);
+ $getmovement = $database->getMovement(3,$village,1);
+ foreach($getmovement as $movedata) {
+ $time = microtime(true);
+ $time2 = $time - $movedata['starttime'];
+ $database->addMovement(4,$movedata['to'],$movedata['from'],$movedata['ref'],$time,$time+$time2);
+ $database->setMovementProc($movedata['moveid']);
+ }
+ $q = "DELETE FROM ".TB_PREFIX."movement where from = ".$village;
+ $database->query($q);
+ $getprisoners = $database->getPrisoners($village);
+ foreach($getprisoners as $pris) {
+ $troops = 0;
+ for($i=1;$i<12;$i++){
+ $troops += $pris['t'.$i];
+ }
+ $database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
+ $database->deletePrisoners($pris['id']);
+ }
+ $getprisoners = $database->getPrisoners3($village);
+ foreach($getprisoners as $pris) {
+ $troops = 0;
+ for($i=1;$i<12;$i++){
+ $troops += $pris['t'.$i];
+ }
+ $database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
+ $database->deletePrisoners($pris['id']);
+ }
+ $enforcement = $database->getEnforceVillage($village,0);
+ foreach($enforcement as $enforce) {
+ $time = microtime(true);
+ $fromcoor = $database->getCoor($enforce['vref']);
+ $tocoor = $database->getCoor($enforce['from']);
+ $targettribe = $database->getUserField($database->getVillageField($enforce['from'],"owner"),"tribe",0);
+ $time2 = $this->procDistanceTime($tocoor,$fromcoor,$targettribe,0);
+ $start = 10*($targettribe-1);
+ for($i=1;$i<11;$i++){
+ $unit = $start + $i;
+ $post['t'.$i] = $enforce['u'.$unit];
+ }
+ $post['t11'] = $enforce['hero'];
+ $reference = $database->addAttack($enforce['from'],$post['t1'],$post['t2'],$post['t3'],$post['t4'],$post['t5'],$post['t6'],$post['t7'],$post['t8'],$post['t9'],$post['t10'],$post['t11'],2,0,0,0,0);
+ $database->addMovement(4,$enforce['vref'],$enforce['from'],$reference,$time,$time+$time2);
+ $q = "DELETE FROM ".TB_PREFIX."enforcement where id = ".$enforce['id'];
+ $database->query($q);
+ }
+ }
+ for($i=0;$i<20;$i++){
+ $q = "SELECT * 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);
+ $database->deleteFriend($friend['id'],"friend".$i."wait");
+ }
+ }
+ $database->updateUserField($need['uid'], 'alliance', 0, 1);
+ if($database->isAllianceOwner($need['uid'])){
+ $alliance = $database->getUserAllianceID($need['uid']);
+ $newowner = $database->getAllMember2($alliance);
+ $newleader = $newowner['id'];
+ $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$alliance."";
+ $database->query($q);
+ $database->updateAlliPermissions($newleader, $alliance, "Leader", 1, 1, 1, 1, 1, 1, 1);
+ $this->updateMax($newleader);
+ }
+ $database->deleteAlliance($alliance);
+ $q = "DELETE FROM ".TB_PREFIX."hero where uid = ".$need['uid'];
+ $database->query($q);
+ $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 = ".$need['uid'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."users where id = ".$need['uid'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."deleting where uid = ".$need['uid'];
+ $database->query($q);
+ }
+ }
+ if(file_exists("GameEngine/Prevention/cleardeleting.txt")) {
+ unlink("GameEngine/Prevention/cleardeleting.txt");
+ }
+ }
+
+ private function ClearUser() {
+ global $database;
+ if(AUTO_DEL_INACTIVE) {
+ $time = time()+UN_ACT_TIME;
+ $q = "DELETE from ".TB_PREFIX."users where timestamp >= $time and act != ''";
+ $database->query($q);
+ }
+ }
+
+ private function ClearInactive() {
+ global $database;
+ if(TRACK_USR) {
+ $timeout = time()-USER_TIMEOUT*60;
+ $q = "DELETE FROM ".TB_PREFIX."active WHERE timestamp < $timeout";
+ $database->query($q);
+ }
+ }
+ private function pruneOResource() {
+ global $database;
+ if(!ALLOW_BURST) {
+ $q = "SELECT * FROM ".TB_PREFIX."odata WHERE maxstore < 800 OR maxcrop < 800";
+ $array = $database->query_return($q);
+ foreach($array as $getoasis) {
+ if($getoasis['maxstore'] < 800){
+ $maxstore = 800;
+ }else{
+ $maxstore = $getoasis['maxstore'];
+ }
+ if($getoasis['maxcrop'] < 800){
+ $maxcrop = 800;
+ }else{
+ $maxcrop = $getoasis['maxcrop'];
+ }
+ $q = "UPDATE " . TB_PREFIX . "odata set maxstore = $maxstore, maxcrop = $maxcrop where wref = ".$getoasis['wref']."";
+ $database->query($q);
+ }
+ $q = "SELECT * FROM ".TB_PREFIX."odata WHERE wood < 0 OR clay < 0 OR iron < 0 OR crop < 0";
+ $array = $database->query_return($q);
+ foreach($array as $getoasis) {
+ if($getoasis['wood'] < 0){
+ $wood = 0;
+ }else{
+ $wood = $getoasis['wood'];
+ }
+ if($getoasis['clay'] < 0){
+ $clay = 0;
+ }else{
+ $clay = $getoasis['clay'];
+ }
+ if($getoasis['iron'] < 0){
+ $iron = 0;
+ }else{
+ $iron = $getoasis['iron'];
+ }
+ if($getoasis['crop'] < 0){
+ $crop = 0;
+ }else{
+ $crop = $getoasis['crop'];
+ }
+ $q = "UPDATE " . TB_PREFIX . "odata set wood = $wood, clay = $clay, iron = $iron, crop = $crop where wref = ".$getoasis['wref']."";
+ $database->query($q);
+ }
+ }
+ }
+ private function pruneResource() {
+ global $database;
+ if(!ALLOW_BURST) {
+ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE maxstore < 800 OR maxcrop < 800";
+ $array = $database->query_return($q);
+ foreach($array as $getvillage) {
+ if($getvillage['maxstore'] < 800){
+ $maxstore = 800;
+ }else{
+ $maxstore = $getvillage['maxstore'];
+ }
+ if($getvillage['maxcrop'] < 800){
+ $maxcrop = 800;
+ }else{
+ $maxcrop = $getvillage['maxcrop'];
+ }
+ $q = "UPDATE " . TB_PREFIX . "vdata set maxstore = $maxstore, maxcrop = $maxcrop where wref = ".$getvillage['wref']."";
+ $database->query($q);
+ }
+ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE wood > maxstore OR clay > maxstore OR iron > maxstore OR crop > maxcrop";
+ $array = $database->query_return($q);
+ foreach($array as $getvillage) {
+ if($getvillage['wood'] > $getvillage['maxstore']){
+ $wood = $getvillage['maxstore'];
+ }else{
+ $wood = $getvillage['wood'];
+ }
+ if($getvillage['clay'] > $getvillage['maxstore']){
+ $clay = $getvillage['maxstore'];
+ }else{
+ $clay = $getvillage['clay'];
+ }
+ if($getvillage['iron'] > $getvillage['maxstore']){
+ $iron = $getvillage['maxstore'];
+ }else{
+ $iron = $getvillage['iron'];
+ }
+ if($getvillage['crop'] > $getvillage['maxstore']){
+ $crop = $getvillage['maxstore'];
+ }else{
+ $crop = $getvillage['crop'];
+ }
+ $q = "UPDATE " . TB_PREFIX . "vdata set wood = $wood, clay = $clay, iron = $iron, crop = $crop where wref = ".$getvillage['wref']."";
+ $database->query($q);
+ }
+ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE wood < 0 OR clay < 0 OR iron < 0 OR crop < 0";
+ $array = $database->query_return($q);
+ foreach($array as $getvillage) {
+ if($getvillage['wood'] < 0){
+ $wood = 0;
+ }else{
+ $wood = $getvillage['wood'];
+ }
+ if($getvillage['clay'] < 0){
+ $clay = 0;
+ }else{
+ $clay = $getvillage['clay'];
+ }
+ if($getvillage['iron'] < 0){
+ $iron = 0;
+ }else{
+ $iron = $getvillage['iron'];
+ }
+ if($getvillage['crop'] < 0){
+ $crop = 0;
+ }else{
+ $crop = $getvillage['crop'];
+ }
+ $q = "UPDATE " . TB_PREFIX . "vdata set wood = $wood, clay = $clay, iron = $iron, crop = $crop where wref = ".$getvillage['wref']."";
+ $database->query($q);
+ }
+ }
+ }
+
+ private function culturePoints() {
+ if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
+ unlink("GameEngine/Prevention/culturepoints.txt");
+ }
+ global $database,$session;
+ $time = time()-600; // 10minutes
+ $array = array();
+ $q = "SELECT id, lastupdate FROM ".TB_PREFIX."users WHERE lastupdate < $time";
+ $array = $database->query_return($q);
+
+ foreach($array as $indi) {
+ if($indi['lastupdate'] <= $time && $indi['lastupdate'] > 0){
+ $cp = $database->getVSumField($indi['id'], 'cp') * (time()-$indi['lastupdate'])/86400; // 24 hours
+
+ $newupdate = time();
+ $q = "UPDATE ".TB_PREFIX."users set cp = cp + $cp, lastupdate = $newupdate where id = '".$indi['id']."'";
+ $database->query($q);
+ }
+ }
+ if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
+ unlink("GameEngine/Prevention/culturepoints.txt");
+ }
+}
+
+ private function buildComplete() {
+ if(file_exists("GameEngine/Prevention/build.txt")) {
+ unlink("GameEngine/Prevention/build.txt");
+ }
+ global $database,$bid18,$bid10,$bid11,$bid38,$bid39;
+ $time = time();
+ $array = array();
+ $q = "SELECT * FROM ".TB_PREFIX."bdata where timestamp < $time and master = 0";
+ $array = $database->query_return($q);
+ foreach($array as $indi) {
+ $q = "UPDATE ".TB_PREFIX."fdata set f".$indi['field']." = ".$indi['level'].", f".$indi['field']."t = ".$indi['type']." where vref = ".$indi['wid'];
+ if($database->query($q)) {
+ $level = $database->getFieldLevel($indi['wid'],$indi['field']);
+ $pop = $this->getPop($indi['type'],($level-1));
+ $database->modifyPop($indi['wid'],$pop[0],0);
+ $this->procClimbers($database->getVillageField($indi['wid'],'owner'));
+ $database->addCP($indi['wid'],$pop[1]);
+
+ if($indi['type'] == 10) {
+ $max=$database->getVillageField($indi['wid'],"maxstore");
+ if($level=='1' && $max==STORAGE_BASE){ $max=STORAGE_BASE; }
+ if($level!=1){
+ $max-=$bid10[$level-1]['attri']*STORAGE_MULTIPLIER;
+ $max+=$bid10[$level]['attri']*STORAGE_MULTIPLIER;
+ }else{
+ $max=$bid10[$level]['attri']*STORAGE_MULTIPLIER;
+ }
+ $database->setVillageField($indi['wid'],"maxstore",$max);
+ }
+
+ if($indi['type'] == 11) {
+ $max=$database->getVillageField($indi['wid'],"maxcrop");
+ if($level=='1' && $max==STORAGE_BASE){ $max=STORAGE_BASE; }
+ if($level!=1){
+ $max-=$bid11[$level-1]['attri']*STORAGE_MULTIPLIER;
+ $max+=$bid11[$level]['attri']*STORAGE_MULTIPLIER;
+ }else{
+ $max=$bid11[$level]['attri']*STORAGE_MULTIPLIER;
+ }
+ $database->setVillageField($indi['wid'],"maxcrop",$max);
+ }
+
+ if($indi['type'] == 18){
+ $this->updateMax($database->getVillageField($indi['wid'],"owner"));
+ }
+
+ if($indi['type'] == 38) {
+ $max=$database->getVillageField($indi['wid'],"maxstore");
+ if($level=='1' && $max==STORAGE_BASE){ $max=STORAGE_BASE; }
+ if($level!=1){
+ $max-=$bid38[$level-1]['attri']*STORAGE_MULTIPLIER;
+ $max+=$bid38[$level]['attri']*STORAGE_MULTIPLIER;
+ }else{
+ $max=$bid38[$level]['attri']*STORAGE_MULTIPLIER;
+ }
+ $database->setVillageField($indi['wid'],"maxstore",$max);
+ }
+
+ if($indi['type'] == 39) {
+ $max=$database->getVillageField($indi['wid'],"maxcrop");
+ if($level=='1' && $max==STORAGE_BASE){ $max=STORAGE_BASE; }
+ if($level!=1){
+ $max-=$bid39[$level-1]['attri']*STORAGE_MULTIPLIER;
+ $max+=$bid39[$level]['attri']*STORAGE_MULTIPLIER;
+ }else{
+ $max=$bid39[$level]['attri']*STORAGE_MULTIPLIER;
+ }
+ $database->setVillageField($indi['wid'],"maxcrop",$max);
+ }
+
+ // by SlimShady95 aka Manuel Mannhardt < manuel_mannhardt@web.de >
+ if($indi['type'] == 40 and ($indi['level'] % 5 == 0 or $indi['level'] > 95) and $indi['level'] != 100){
+ $this->startNatarAttack($indi['level'], $indi['wid'], $indi['timestamp']);
+ }
+ if($indi['type'] == 40 && $indi['level'] == 100){ //now can't be more than one winners if ww to level 100 is build by 2 users or more on same time
+ mysql_query("TRUNCATE ".TB_PREFIX."bdata");
+ }
+ if($database->getUserField($database->getVillageField($indi['wid'],"owner"),"tribe",0) != 1){
+ $q4 = "UPDATE ".TB_PREFIX."bdata set loopcon = 0 where loopcon = 1 and master = 0 and wid = ".$indi['wid'];
+ $database->query($q4);
+ }else{
+ if($indi['field'] > 18){
+ $q4 = "UPDATE ".TB_PREFIX."bdata set loopcon = 0 where loopcon = 1 and master = 0 and wid = ".$indi['wid']." and field > 18";
+ $database->query($q4);
+ }else{
+ $q4 = "UPDATE ".TB_PREFIX."bdata set loopcon = 0 where loopcon = 1 and master = 0 and wid = ".$indi['wid']." and field < 19";
+ $database->query($q4);
+ }
+ }
+ $q = "DELETE FROM ".TB_PREFIX."bdata where id = ".$indi['id'];
+ $database->query($q);
+ }
+ $crop = $database->getCropProdstarv($indi['wid']);
+ $unitarrays = $this->getAllUnits($indi['wid']);
+ $village = $database->getVillage($indi['wid']);
+ $upkeep = $village['pop'] + $this->getUpkeep($unitarrays, 0);
+ if ($crop < $upkeep){
+ // add starv data
+ $database->setVillageField($indi['wid'], 'starv', $upkeep);
+ $database->setVillageField($indi['wid'], 'starvupdate', $time);
+ }
+ }
+ if(file_exists("GameEngine/Prevention/build.txt")) {
+ unlink("GameEngine/Prevention/build.txt");
+ }
+ }
+
+ // by SlimShady95 aka Manuel Mannhardt < manuel_mannhardt@web.de >
+ private function startNatarAttack($level, $vid, $time) {
+ global $database;
+
+ // bad, but should work :D
+ // I took the data from my first ww (first .org world)
+ // todo: get the algo from the real travian with the 100 biggest
+ // offs and so on
+ $troops = array(
+ 5 => array(
+ array(3412, 2814, 4156, 3553, 9, 0),
+ array(35, 0, 77, 33, 17, 10)
+ ),
+
+ 10 => array(
+ array(4314, 3688, 5265, 4621, 13, 0),
+ array(65, 0, 175, 77, 28, 17)
+ ),
+
+ 15 => array(
+ array(4645, 4267, 5659, 5272, 15, 0),
+ array(99, 0, 305, 134, 40, 25)
+ ),
+
+ 20 => array(
+ array(6207, 5881, 7625, 7225, 22, 0),
+ array(144, 0, 456, 201, 56, 36)
+ ),
+
+ 25 => array(
+ array(6004, 5977, 7400, 7277, 23, 0),
+ array(152, 0, 499, 220, 58, 37)
+ ),
+
+ 30 => array(
+ array(7073, 7181, 8730, 8713, 27, 0),
+ array(183, 0, 607, 268, 69, 45)
+ ),
+
+ 35 => array(
+ array(7090, 7320, 8762, 8856, 28, 0),
+ array(186, 0, 620, 278, 70, 45)
+ ),
+
+ 40 => array(
+ array(7852, 6967, 9606, 8667, 25, 0),
+ array(146, 0, 431, 190, 60, 37)
+ ),
+
+ 45 => array(
+ array(8480, 8883, 10490, 10719, 35, 0),
+ array(223, 0, 750, 331, 83, 54)
+ ),
+
+ 50 => array(
+ array(8522, 9038, 10551, 10883, 35, 0),
+ array(224, 0, 757, 335, 83, 54)
+ ),
+
+ 55 => array(
+ array(8931, 8690, 10992, 10624, 32, 0),
+ array(219, 0, 707, 312, 84, 54)
+ ),
+
+ 60 => array(
+ array(12138, 13013, 15040, 15642, 51, 0),
+ array(318, 0, 1079, 477, 118, 76)
+ ),
+
+ 65 => array(
+ array(13397, 14619, 16622, 17521, 58, 0),
+ array(345, 0, 1182, 522, 127, 83)
+ ),
+
+ 70 => array(
+ array(16323, 17665, 20240, 21201, 70, 0),
+ array(424, 0, 1447, 640, 157, 102)
+ ),
+
+ 75 => array(
+ array(20739, 22796, 25746, 27288, 91, 0),
+ array(529, 0, 1816, 803, 194, 127)
+ ),
+
+ 80 => array(
+ array(21857, 24180, 27147, 28914, 97, 0),
+ array(551, 0, 1898, 839, 202, 132)
+ ),
+
+ 85 => array(
+ array(22476, 25007, 27928, 29876, 100, 0),
+ array(560, 0, 1933, 855, 205, 134)
+ ),
+
+ 90 => array(
+ array(31345, 35053, 38963, 41843, 141, 0),
+ array(771, 0, 2668, 1180, 281, 184)
+ ),
+
+ 95 => array(
+ array(31720, 35635, 39443, 42506, 144, 0),
+ array(771, 0, 2671, 1181, 281, 184)
+ ),
+
+ 96 => array(
+ array(32885, 37007, 40897, 44130, 150, 0),
+ array(795, 0, 2757, 1219, 289, 190)
+ ),
+
+ 97 => array(
+ array(32940, 37099, 40968, 44235, 150, 0),
+ array(794, 0, 2755, 1219, 289, 190)
+ ),
+
+ 98 => array(
+ array(33521, 37691, 41686, 44953, 152, 0),
+ array(812, 0, 2816, 1246, 296, 194)
+ ),
+
+ 99 => array(
+ array(36251, 40861, 45089, 48714, 165, 0),
+ array(872, 0, 3025, 1338, 317, 208)
+ )
+ );
+
+ // select the troops^^
+ if (isset($troops[$level]))
+ {
+ $units = $troops[$level];
+ }
+ else
+ {
+ return false;
+ }
+
+ // get the capital village from the natars
+ $query = mysql_query('SELECT `wref` FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = 3 and `capital` = 1 LIMIT 1') or die(mysql_error());
+ $row = mysql_fetch_assoc($query);
+
+ // start the attacks
+ $endtime = $time + round((60 * 60 * 24) / INCREASE_SPEED);
+
+ // -.-
+ mysql_query('INSERT INTO `' . TB_PREFIX . 'ww_attacks` (`vid`, `attack_time`) VALUES (' . $vid . ', ' . $endtime . ')');
+ mysql_query('INSERT INTO `' . TB_PREFIX . 'ww_attacks` (`vid`, `attack_time`) VALUES (' . $vid . ', ' . ($endtime + 1) . ')');
+
+ // wave 1
+ $ref = $database->addAttack($row['wref'], 0, $units[0][0], $units[0][1], 0, $units[0][2], $units[0][3], $units[0][4], $units[0][5], 0, 0, 0, 3, 0, 0, 0, 0, 20, 20, 0, 20, 20, 20, 20);
+ $database->addMovement(3, $row['wref'], $vid, $ref, $time, $endtime);
+
+ // wave 2
+ $ref2 = $database->addAttack($row['wref'], 0, $units[1][0], $units[1][1], 0, $units[1][2], $units[1][3], $units[1][4], $units[1][5], 0, 0, 0, 3, 40, 0, 0, 0, 20, 20, 0, 20, 20, 20, 20, array('vid' => $vid, 'endtime' => ($endtime + 1)));
+ $database->addMovement(3, $row['wref'], $vid, $ref2, $time, $endtime + 1);
+ }
+
+ private function checkWWAttacks() {
+ $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'ww_attacks` WHERE `attack_time` <= ' . time());
+ while ($row = mysql_fetch_assoc($query))
+ {
+ // delete the attack
+ $query3 = mysql_query('DELETE FROM `' . TB_PREFIX . 'ww_attacks` WHERE `vid` = ' . $row['vid'] . ' AND `attack_time` = ' . $row['attack_time']);
+ }
+ }
+
+ private function getPop($tid,$level) {
+ $name = "bid".$tid;
+ global $$name,$village;
+ $dataarray = $$name;
+ $pop = $dataarray[($level+1)]['pop'];
+ $cp = $dataarray[($level+1)]['cp'];
+ return array($pop,$cp);
+ }
+
+ private function delTradeRoute() {
+ global $database;
+ $time = time();
+ $q = "DELETE from ".TB_PREFIX."route where timeleft < $time";
+ $database->query($q);
+ }
+
+ private function TradeRoute() {
+ global $database;
+ $time = time();
+ $q = "SELECT * FROM ".TB_PREFIX."route where timestamp < $time";
+ $dataarray = $database->query_return($q);
+ foreach($dataarray as $data) {
+ $database->modifyResource($data['from'],$data['wood'],$data['clay'],$data['iron'],$data['crop'],0);
+ $targettribe = $database->getUserField($database->getVillageField($data['from'],"owner"),"tribe",0);
+ $this->sendResource2($data['wood'],$data['clay'],$data['iron'],$data['crop'],$data['from'],$data['wid'],$targettribe,$data['deliveries']);
+ $database->editTradeRoute($data['id'],"timestamp",86400,1);
+ }
+ }
+
+ private function marketComplete() {
+ if(file_exists("GameEngine/Prevention/market.txt")) {
+ unlink("GameEngine/Prevention/market.txt");
+ }
+ global $database;
+ $ourFileHandle = fopen("GameEngine/Prevention/market.txt", 'w');
+ fclose($ourFileHandle);
+ $time = microtime(true);
+ $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."send where ".TB_PREFIX."movement.ref = ".TB_PREFIX."send.id and ".TB_PREFIX."movement.proc = 0 and sort_type = 0 and endtime < $time";
+ $dataarray = $database->query_return($q);
+ foreach($dataarray as $data) {
+
+ if($data['wood'] >= $data['clay'] && $data['wood'] >= $data['iron'] && $data['wood'] >= $data['crop']){ $sort_type = "10"; }
+ elseif($data['clay'] >= $data['wood'] && $data['clay'] >= $data['iron'] && $data['clay'] >= $data['crop']){ $sort_type = "11"; }
+ elseif($data['iron'] >= $data['wood'] && $data['iron'] >= $data['clay'] && $data['iron'] >= $data['crop']){ $sort_type = "12"; }
+ elseif($data['crop'] >= $data['wood'] && $data['crop'] >= $data['clay'] && $data['crop'] >= $data['iron']){ $sort_type = "13"; }
+
+ $to = $database->getMInfo($data['to']);
+ $from = $database->getMInfo($data['from']);
+ $database->addNotice($to['owner'],$to['wref'],$targetally,$sort_type,''.addslashes($from['name']).' send resources to '.addslashes($to['name']).'',''.$from['owner'].','.$from['wref'].','.$data['wood'].','.$data['clay'].','.$data['iron'].','.$data['crop'].'',$data['endtime']);
+ if($from['owner'] != $to['owner']) {
+ $database->addNotice($from['owner'],$to['wref'],$ownally,$sort_type,''.addslashes($from['name']).' send resources to '.addslashes($to['name']).'',''.$from['owner'].','.$from['wref'].','.$data['wood'].','.$data['clay'].','.$data['iron'].','.$data['crop'].'',$data['endtime']);
+ }
+ $database->modifyResource($data['to'],$data['wood'],$data['clay'],$data['iron'],$data['crop'],1);
+ $tocoor = $database->getCoor($data['from']);
+ $fromcoor = $database->getCoor($data['to']);
+ $targettribe = $database->getUserField($database->getVillageField($data['from'],"owner"),"tribe",0);
+ $endtime = $this->procDistanceTime($tocoor,$fromcoor,$targettribe,0) + $data['endtime'];
+ $database->addMovement(2,$data['to'],$data['from'],$data['merchant'],time(),$endtime,$data['send'],$data['wood'],$data['clay'],$data['iron'],$data['crop']);
+ $database->setMovementProc($data['moveid']);
+ }
+ $q1 = "SELECT * FROM ".TB_PREFIX."movement where proc = 0 and sort_type = 2 and endtime < $time";
+ $dataarray1 = $database->query_return($q1);
+ foreach($dataarray1 as $data1) {
+ $database->setMovementProc($data1['moveid']);
+ if($data1['send'] > 1){
+ $targettribe1 = $database->getUserField($database->getVillageField($data1['to'],"owner"),"tribe",0);
+ $send = $data1['send']-1;
+ $this->sendResource2($data1['wood'],$data1['clay'],$data1['iron'],$data1['crop'],$data1['to'],$data1['from'],$targettribe1,$send);
+ }
+ }
+ if(file_exists("GameEngine/Prevention/market.txt")) {
+ unlink("GameEngine/Prevention/market.txt");
+ }
+ }
+
+ private function sendResource2($wtrans,$ctrans,$itrans,$crtrans,$from,$to,$tribe,$send) {
+ global $bid17,$bid28,$database,$generator,$logging;
+ $availableWood = $database->getWoodAvailable($from);
+ $availableClay = $database->getClayAvailable($from);
+ $availableIron = $database->getIronAvailable($from);
+ $availableCrop = $database->getCropAvailable($from);
+ if($availableWood >= $wtrans AND $availableClay >= $ctrans AND $availableIron >= $itrans AND $availableCrop >= $crtrans){
+ $merchant2 = ($this->getTypeLevel(17,$from) > 0)? $this->getTypeLevel(17,$from) : 0;
+ $used2 = $database->totalMerchantUsed($from);
+ $merchantAvail2 = $merchant2 - $used2;
+ $maxcarry2 = ($tribe == 1)? 500 : (($tribe == 2)? 1000 : 750);
+ $maxcarry2 *= TRADER_CAPACITY;
+ if($this->getTypeLevel(28,$from) != 0) {
+ $maxcarry2 *= $bid28[$this->getTypeLevel(28,$from)]['attri'] / 100;
+ }
+ $resource = array($wtrans,$ctrans,$itrans,$crtrans);
+ $reqMerc = ceil((array_sum($resource)-0.1)/$maxcarry2);
+ if($merchantAvail2 != 0 && $reqMerc <= $merchantAvail2) {
+ $coor = $database->getCoor($to);
+ $coor2 = $database->getCoor($from);
+ if($database->getVillageState($to)) {
+ $timetaken = $generator->procDistanceTime($coor,$coor2,$tribe,0);
+ $res = $resource[0]+$resource[1]+$resource[2]+$resource[3];
+ if($res!=0){
+ $reference = $database->sendResource($resource[0],$resource[1],$resource[2],$resource[3],$reqMerc,0);
+ $database->modifyResource($from,$resource[0],$resource[1],$resource[2],$resource[3],0);
+ $database->addMovement(0,$from,$to,$reference,microtime(true),microtime(true)+$timetaken,$send);
+ }
+ }
+ }
+ }
+ }
+
+ private function sendunitsComplete() {
+ if(file_exists("GameEngine/Prevention/sendunits.txt")) {
+ unlink("GameEngine/Prevention/sendunits.txt");
+ }
+ global $bid23,$bid34,$database,$battle,$village,$technology,$logging,$generator;
+ $ourFileHandle = fopen("GameEngine/Prevention/sendunits.txt", 'w');
+ fclose($ourFileHandle);
+ $time = time();
+ $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."attacks where ".TB_PREFIX."movement.ref = ".TB_PREFIX."attacks.id and ".TB_PREFIX."movement.proc = '0' and ".TB_PREFIX."movement.sort_type = '3' and ".TB_PREFIX."attacks.attack_type != '2' and endtime < $time ORDER BY endtime ASC";
+ $dataarray = $database->query_return($q);
+ $totalattackdead = 0;
+ $data_num = 0;
+ foreach($dataarray as $data) {
+ //set base things
+ //$battle->resolveConflict($data);
+ $tocoor = $database->getCoor($data['from']);
+ $fromcoor = $database->getCoor($data['to']);
+ $isoasis = $database->isVillageOases($data['to']);
+ $AttackArrivalTime = $data['endtime'];
+ $AttackerWref = $data['from'];
+ $DefenderWref = $data['to'];
+ if ($isoasis == 0){
+ $Attacker['id'] = $database->getUserField($database->getVillageField($data['from'],"owner"),"id",0);
+ $Defender['id'] = $database->getUserField($database->getVillageField($data['to'],"owner"),"id",0);
+ $AttackerID = $database->getUserField($database->getVillageField($data['from'],"owner"),"id",0);
+ $DefenderID = $database->getUserField($database->getVillageField($data['to'],"owner"),"id",0);
+ $owntribe = $database->getUserField($database->getVillageField($data['from'],"owner"),"tribe",0);
+ $targettribe = $database->getUserField($database->getVillageField($data['to'],"owner"),"tribe",0);
+ $ownally = $database->getUserField($database->getVillageField($data['from'],"owner"),"alliance",0);
+ $targetally = $database->getUserField($database->getVillageField($data['to'],"owner"),"alliance",0);
+ $to = $database->getMInfo($data['to']);
+ $from = $database->getMInfo($data['from']);
+ $toF = $database->getVillage($data['to']);
+ $fromF = $database->getVillage($data['from']);
+
+ $DefenderUnit = array();
+ $DefenderUnit = $database->getUnit($data['to']);
+ $evasion = $database->getVillageField($data['to'],"evasion");
+ $maxevasion = $database->getUserField($DefenderID,"maxevasion",0);
+ $gold = $database->getUserField($DefenderID,"gold",0);
+ $playerunit = ($targettribe-1)*10;
+ $cannotsend = 0;
+ $movements = $database->getMovement("34",$data['to'],1);
+ for($y=0;$y < count($movements);$y++){
+ $returntime = $units[$y]['endtime']-time();
+ if($units[$y]['sort_type'] == 4 && $units[$y]['from'] != 0 && $returntime <= 10){
+ $cannotsend = 1;
+ }
+ }
+ if($evasion == 1 && $maxevasion > 0 && $gold > 1 && $cannotsend == 0 && $dataarray[$data_num]['attack_type'] > 2){
+ $totaltroops = 0;
+ for($i=1;$i<=10;$i++){
+ $playerunit += $i;
+ $data['u'.$i] = $DefenderUnit['u'.$playerunit];
+ $database->modifyUnit($data['to'],array($playerunit),array($DefenderUnit['u'.$playerunit]),array(0));
+ $playerunit -= $i;
+ $totaltroops += $data['u'.$i];
+ }
+ $data['u11'] = $DefenderUnit['hero'];
+ $totaltroops += $data['u11'];
+ if($totaltroops > 0){
+ $database->modifyUnit($data['to'],array("hero"),array($DefenderUnit['hero']),array(0));
+ $attackid = $database->addAttack($data['to'],$data['u1'],$data['u2'],$data['u3'],$data['u4'],$data['u5'],$data['u6'],$data['u7'],$data['u8'],$data['u9'],$data['u10'],$data['u11'],4,0,0,0,0,0,0,0,0,0,0,0);
+ $database->addMovement(4,0,$data['to'],$attackid,microtime(true),microtime(true)+(180/EVASION_SPEED));
+ $newgold = $gold-2;
+ $newmaxevasion = $maxevasion-1;
+ $database->updateUserField($DefenderID, "gold", $newgold, 1);
+ $database->updateUserField($DefenderID, "maxevasion", $newmaxevasion, 1);
+ }
+ }
+ //get defence units
+ $Defender = array(); $rom = $ger = $gal = $nat = $natar = 0;
+ $Defender = $database->getUnit($data['to']);
+ $enforcementarray = $database->getEnforceVillage($data['to'],0);
+ if(count($enforcementarray) > 0) {
+ foreach($enforcementarray as $enforce) {
+ for($i=1;$i<=50;$i++) {
+ $Defender['u'.$i] += $enforce['u'.$i];
+ }
+ }
+ }
+ for($i=1;$i<=50;$i++){
+ if(!isset($Defender['u'.$i])){
+ $Defender['u'.$i] = '0';
+ } else {
+ if($Defender['u'.$i]=='' or $Defender['u'.$i]<='0'){
+ $Defender['u'.$i] = '0';
+ } else {
+ if($i<=10){ $rom='1'; }
+ else if($i<=20){ $ger='1'; }
+ else if($i<=30){ $gal='1'; }
+ else if($i<=40){ $nat='1'; }
+ else if($i<=50){ $natar='1'; }
+ }
+ }
+ }
+ if(!isset($Defender['hero'])){
+ $Defender['hero'] = '0';
+ } else {
+ if($Defender['hero']=='' or $Defender['hero']<='0'){
+ $Defender['hero'] = '0';
+ }
+ }
+ //get attack units
+ $Attacker = array();
+ $start = ($owntribe-1)*10+1;
+ $end = ($owntribe*10);
+ $u = (($owntribe-1)*10);
+ $catp = 0;
+ $catapult = array(8,18,28,48);
+ $ram = array(7,17,27,47);
+ $chief = array(9,19,29,49);
+ $spys = array(4,14,23,44);
+ for($i=$start;$i<=$end;$i++) {
+ $y = $i-$u;
+ $Attacker['u'.$i] = $dataarray[$data_num]['t'.$y];
+ //there are catas
+ if(in_array($i,$catapult)) {
+ $catp += $Attacker['u'.$i];
+ $catp_pic = $i;
+ }
+ if(in_array($i,$ram)) {
+ $rams += $Attacker['u'.$i];
+ $ram_pic = $i;
+ }
+ if(in_array($i,$chief)) {
+ $chiefs += $Attacker['u'.$i];
+ $chief_pic = $i;
+ }
+ if(in_array($i,$spys)) {
+ $chiefs += $Attacker['u'.$i];
+ $spy_pic = $i;
+ }
+ }
+ $Attacker['uhero'] = $dataarray[$data_num]['t11'];
+ $hero_pic = "hero";
+ //need to set these variables.
+ $def_wall = $database->getFieldLevel($data['to'],40);
+ $att_tribe = $owntribe;
+ $def_tribe = $targettribe;
+ $residence = "0";
+ $attpop = $fromF['pop'];
+ $defpop = $toF['pop'];
+ for ($i=19; $i<40; $i++){
+ if ($database->getFieldLevel($data['to'],"".$i."t")=='25' OR $database->getFieldLevel($data['to'],"".$i."t")=='26'){
+ $residence = $database->getFieldLevel($data['to'],$i);
+ $i=40;
+ }
+ }
+
+ //type of attack
+ if($dataarray[$data_num]['attack_type'] == 1){
+ $type = 1;
+ $scout = 1;
+ }
+ if($dataarray[$data_num]['attack_type'] == 2){
+ $type = 2;
+ }
+ if($dataarray[$data_num]['attack_type'] == 3){
+ $type = 3;
+ }
+ if($dataarray[$data_num]['attack_type'] == 4){
+ $type = 4;
+ }
+
+ $att_ab = $database->getABTech($data['from']); // Blacksmith level
+ $att_ab1 = $att_ab['b1'];
+ $att_ab2 = $att_ab['b2'];
+ $att_ab3 = $att_ab['b3'];
+ $att_ab4 = $att_ab['b4'];
+ $att_ab5 = $att_ab['b5'];
+ $att_ab6 = $att_ab['b6'];
+ $att_ab7 = $att_ab['b7'];
+ $att_ab8 = $att_ab['b8'];
+ $def_ab = $database->getABTech($data['to']); // Armory level
+ $att_ab1 = $att_ab['a1'];
+ $att_ab2 = $att_ab['a2'];
+ $att_ab3 = $att_ab['a3'];
+ $att_ab4 = $att_ab['a4'];
+ $att_ab5 = $att_ab['a5'];
+ $att_ab6 = $att_ab['a6'];
+ $att_ab7 = $att_ab['a7'];
+ $att_ab8 = $att_ab['a8'];
+
+ //rams attack
+ if($rams > 0 and $type=='3'){
+ $basearraywall = $database->getMInfo($data['to']);
+ if($database->getFieldLevel($basearraywall['wref'],40)>'0'){
+ for ($w=1; $w<2; $w++){
+ if ($database->getFieldLevel($basearraywall['wref'],40)!='0'){
+
+ $walllevel = $database->getFieldLevel($basearraywall['wref'],40);
+ $wallgid = $database->getFieldLevel($basearraywall['wref'],"40t");
+ $wallid = 40;
+ $w='4';
+ } else {$w = $w--; }
+ }
+ }else{
+ $empty = 1;
+ }
+ }
+
+ $tblevel = '1';
+ $stonemason = "1";
+
+
+ /*--------------------------------
+ // End Battle part
+ --------------------------------*/
+ }else{
+ $Attacker['id'] = $database->getUserField($database->getVillageField($data['from'],"owner"),"id",0);
+ $Defender['id'] = $database->getUserField($database->getOasisField($data['to'],"owner"),"id",0);
+ $AttackerID = $database->getUserField($database->getVillageField($data['from'],"owner"),"id",0);
+ $DefenderID = $database->getUserField($database->getOasisField($data['to'],"owner"),"id",0);
+ $owntribe = $database->getUserField($database->getVillageField($data['from'],"owner"),"tribe",0);
+ $targettribe = $database->getUserField($database->getOasisField($data['to'],"owner"),"tribe",0);;
+ $ownally = $database->getUserField($database->getVillageField($data['from'],"owner"),"alliance",0);
+ $targetally = $database->getUserField($database->getOasisField($data['to'],"owner"),"alliance",0);
+ $to = $database->getOMInfo($data['to']);
+ $from = $database->getMInfo($data['from']);
+ $toF = $database->getOasisV($data['to']);
+ $fromF = $database->getVillage($data['from']);
+
+
+ //get defence units
+ $Defender = array(); $rom = $ger = $gal = $nat = $natar = 0;
+ $Defender = $database->getUnit($data['to']);
+ $enforcementarray = $database->getEnforceVillage($data['to'],0);
+
+ if(count($enforcementarray) > 0) {
+ foreach($enforcementarray as $enforce) {
+ for($i=1;$i<=50;$i++) {
+ $Defender['u'.$i] += $enforce['u'.$i];
+ }
+ $Defender['hero'] += $enforce['hero'];
+ }
+ }
+ for($i=1;$i<=50;$i++){
+ if(!isset($Defender['u'.$i])){
+ $Defender['u'.$i] = '0';
+ } else {
+ if($Defender['u'.$i]=='' or $Defender['u'.$i]<='0'){
+ $Defender['u'.$i] = '0';
+ } else {
+ if($i<=10){ $rom='1'; }
+ else if($i<=20){ $ger='1'; }
+ else if($i<=30){ $gal='1'; }
+ else if($i<=40){ $nat='1'; }
+ else if($i<=50){ $natar='1'; }
+ }
+ }
+ }
+ if(!isset($Defender['hero'])){
+ $Defender['hero'] = '0';
+ } else {
+ if($Defender['hero']=='' or $Defender['hero']<'0'){
+ $Defender['hero'] = '0';
+ }
+ }
+ //get attack units
+ $Attacker = array();
+ $start = ($owntribe-1)*10+1;
+ $end = ($owntribe*10);
+ $u = (($owntribe-1)*10);
+ $catp = 0;
+ $catapult = array(8,18,28,38,48);
+ $ram = array(7,17,27,37,47);
+ $chief = array(9,19,29,39,49);
+ $spys = array(4,14,23,44);
+ for($i=$start;$i<=$end;$i++) {
+ $y = $i-$u;
+ $Attacker['u'.$i] = $dataarray[$data_num]['t'.$y];
+ //there are catas
+ if(in_array($i,$catapult)) {
+ $catp += $Attacker['u'.$i];
+ $catp_pic = $i;
+ }
+ if(in_array($i,$ram)) {
+ $rams += $Attacker['u'.$i];
+ $ram_pic = $i;
+ }
+ if(in_array($i,$chief)) {
+ $chiefs += $Attacker['u'.$i];
+ $chief_pic = $i;
+ }
+ if(in_array($i,$spys)) {
+ $chiefs += $Attacker['u'.$i];
+ $spy_pic = $i;
+ }
+ }
+ $Attacker['uhero'] = $dataarray[$data_num]['t11'];
+ $hero_pic = "hero";
+ //need to set these variables.
+ $def_wall = 1;
+ $att_tribe = $owntribe;
+ $def_tribe = $targettribe;
+ $residence = "0";
+ $attpop = $fromF['pop'];
+ $defpop = 100;
+
+
+ //type of attack
+ if($dataarray[$data_num]['attack_type'] == 1){
+ $type = 1;
+ $scout = 1;
+ }
+ if($dataarray[$data_num]['attack_type'] == 2){
+ $type = 2;
+ }
+ if($dataarray[$data_num]['attack_type'] == 3){
+ $type = 3;
+ }
+ if($dataarray[$data_num]['attack_type'] == 4){
+ $type = 4;
+ }
+
+ $def_ab = Array (
+ "b1" => 0, // Blacksmith level
+ "b2" => 0, // Blacksmith level
+ "b3" => 0, // Blacksmith level
+ "b4" => 0, // Blacksmith level
+ "b5" => 0, // Blacksmith level
+ "b6" => 0, // Blacksmith level
+ "b7" => 0, // Blacksmith level
+ "b8" => 0); // Blacksmith level
+
+ $att_ab = Array (
+ "a1" => 0, // armoury level
+ "a2" => 0, // armoury level
+ "a3" => 0, // armoury level
+ "a4" => 0, // armoury level
+ "a5" => 0, // armoury level
+ "a6" => 0, // armoury level
+ "a7" => 0, // armoury level
+ "a8" => 0); // armoury level
+
+ $empty='1';
+ $tblevel = '0';
+ $stonemason = "1";
+
+ }
+
+ if(PEACE == 0 || $targettribe == 4 || $targettribe == 5){
+ if($targettribe == 1){
+ $def_spy = $Defender['u4'];
+ }elseif($targettribe == 2){
+ $def_spy = $Defender['u14'];
+ }elseif($targettribe == 3){
+ $def_spy = $Defender['u23'];
+ }elseif($targettribe == 5){
+ $def_spy = $Defender['u54'];
+ }
+ if(!$scout or $def_spy > 0){
+ $traps = $Defender['u99']-$Defender['u99o'];
+ for($i=1;$i<=11;$i++){
+ $traps1 = $traps;
+ if($data['t'.$i] < $traps1){
+ $traps1 = $data['t'.$i];
+ }
+ ${traped.$i}=$traps1;
+ $traps -= $traps1;
+ $database->modifyUnit($data['to'],array("99o"),array($traps1),array(1));
+ }
+ for($i=$start;$i<=$end;$i++) {
+ $j = $i-$start+1;
+ $Attacker['u'.$i] -= ${traped.$j};
+ }
+ $Attacker['uhero'] -= $traped11;
+ $totaltraped_att = $traped1+$traped2+$traped3+$traped4+$traped5+$traped6+$traped7+$traped8+$traped9+$traped10+$traped11;
+ if($totaltraped_att > 0){
+ $prisoners2 = $database->getPrisoners2($data['to'],$data['from']);
+ if(empty($prisoners2)){
+ $database->addPrisoners($data['to'],$data['from'],$traped1,$traped2,$traped3,$traped4,$traped5,$traped6,$traped7,$traped8,$traped9,$traped10,$traped11);
+ }else{
+ $database->updatePrisoners($data['to'],$data['from'],$traped1,$traped2,$traped3,$traped4,$traped5,$traped6,$traped7,$traped8,$traped9,$traped10,$traped11);
+ }
+ }
+ }
+ $battlepart = $battle->calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab1,$def_ab2,$def_ab3,$def_ab4,$def_ab5,$def_ab6,$def_ab7,$def_ab8,$att_ab1,$att_ab2,$att_ab3,$att_ab4,$att_ab5,$att_ab6,$att_ab7,$att_ab8,$tblevel,$stonemason,$walllevel,$AttackerID,$DefenderID,$AttackerWref,$DefenderWref);
+
+ //units attack string for battleraport
+ $unitssend_att = ''.$data['t1'].','.$data['t2'].','.$data['t3'].','.$data['t4'].','.$data['t5'].','.$data['t6'].','.$data['t7'].','.$data['t8'].','.$data['t9'].','.$data['t10'].'';
+ $herosend_att = $data['t11'];
+ if ($herosend_att>0){
+ $unitssend_att_check=$unitssend_att.','.$data['t11'];
+ }else{
+ $unitssend_att_check=$unitssend_att;
+ }
+ //units defence string for battleraport
+ $enforcementarray2 = $database->getEnforceVillage($data['to'],0);
+ if(count($enforcementarray2) > 0) {
+ foreach($enforcementarray2 as $enforce2) {
+ $Defender['hero'] += $enforce2['hero'];
+ }
+ }
+ $unitssend_def[1] = ''.$Defender['u1'].','.$Defender['u2'].','.$Defender['u3'].','.$Defender['u4'].','.$Defender['u5'].','.$Defender['u6'].','.$Defender['u7'].','.$Defender['u8'].','.$Defender['u9'].','.$Defender['u10'].'';
+ $unitssend_def[2] = ''.$Defender['u11'].','.$Defender['u12'].','.$Defender['u13'].','.$Defender['u14'].','.$Defender['u15'].','.$Defender['u16'].','.$Defender['u17'].','.$Defender['u18'].','.$Defender['u19'].','.$Defender['u20'].'';
+ $unitssend_def[3] = ''.$Defender['u21'].','.$Defender['u22'].','.$Defender['u23'].','.$Defender['u24'].','.$Defender['u25'].','.$Defender['u26'].','.$Defender['u27'].','.$Defender['u28'].','.$Defender['u29'].','.$Defender['u30'].'';
+ $unitssend_def[4] = ''.$Defender['u31'].','.$Defender['u32'].','.$Defender['u33'].','.$Defender['u34'].','.$Defender['u35'].','.$Defender['u36'].','.$Defender['u37'].','.$Defender['u38'].','.$Defender['u39'].','.$Defender['u40'].'';
+ $unitssend_def[5] = ''.$Defender['u41'].','.$Defender['u42'].','.$Defender['u43'].','.$Defender['u44'].','.$Defender['u45'].','.$Defender['u46'].','.$Defender['u47'].','.$Defender['u48'].','.$Defender['u49'].','.$Defender['u50'].'';
+ $herosend_def = $Defender['hero'];
+ $totalsend_alldef[1] = $Defender['u1']+$Defender['u2']+$Defender['u3']+$Defender['u4']+$Defender['u5']+$Defender['u6']+$Defender['u7']+$Defender['u8']+$Defender['u9']+$Defender['u10'];
+ $totalsend_alldef[2] = $Defender['u11']+$Defender['u12']+$Defender['u13']+$Defender['u14']+$Defender['u15']+$Defender['u16']+$Defender['u17']+$Defender['u18']+$Defender['u19']+$Defender['u20'];
+ $totalsend_alldef[3] = $Defender['u21']+$Defender['u22']+$Defender['u23']+$Defender['u24']+$Defender['u25']+$Defender['u26']+$Defender['u27']+$Defender['u28']+$Defender['u29']+$Defender['u30'];
+ $totalsend_alldef[4] = $Defender['u31']+$Defender['u32']+$Defender['u33']+$Defender['u34']+$Defender['u35']+$Defender['u36']+$Defender['u37']+$Defender['u38']+$Defender['u39']+$Defender['u40'];
+ $totalsend_alldef[5] = $Defender['u41']+$Defender['u42']+$Defender['u43']+$Defender['u44']+$Defender['u45']+$Defender['u46']+$Defender['u47']+$Defender['u48']+$Defender['u49']+$Defender['u50'];
+
+ $totalsend_alldef = $totalsend_alldef[1]+$totalsend_alldef[2]+$totalsend_alldef[3]+$totalsend_alldef[4]+$totalsend_alldef[5]+$herosend_def;
+
+ $unitssend_deff[1] = '?,?,?,?,?,?,?,?,?,?,';
+ $unitssend_deff[2] = '?,?,?,?,?,?,?,?,?,?,';
+ $unitssend_deff[3] = '?,?,?,?,?,?,?,?,?,?,';
+ $unitssend_deff[4] = '?,?,?,?,?,?,?,?,?,?,';
+ $unitssend_deff[5] = '?,?,?,?,?,?,?,?,?,?,';
+ //how many troops died? for battleraport
+
+ #################################################
+ ################FIXED BY SONGER################
+ #################################################
+
+ for($i=1;$i<=11;$i++){
+ if($battlepart['casualties_attacker'][$i] <= 0) { ${dead.$i} = 0; }elseif($battlepart['casualties_attacker'][$i] > $data['t'.$i]){
+ ${dead.$i}=$data['t'.$i];
+ }else { ${dead.$i} = $battlepart['casualties_attacker'][$i]; }
+ }
+
+ #################################################
+
+ $heroAttackDead=$dead11;
+ //kill own defence
+ $q = "SELECT * FROM ".TB_PREFIX."units WHERE vref='".$data['to']."'";
+ $unitlist = $database->query_return($q);
+ $start = ($targettribe-1)*10+1;
+ $end = ($targettribe*10);
+
+ if($targettribe == 1){ $u = ""; $rom='1'; } else if($targettribe == 2){ $u = "1"; $ger='1'; } else if($targettribe == 3){$u = "2"; $gal='1'; }else if($targettribe == 4){ $u = "3"; $nat='1'; } else { $u = "4"; $natar='1'; } //FIX
+ for($i=$start;$i<=$end;$i++) { if($i==$end){ $u=$targettribe; }
+ if($unitlist){
+ $dead[$i]+=round($battlepart[2]*$unitlist[0]['u'.$i]);
+ $database->modifyUnit($data['to'],array($i),array(round($battlepart[2]*$unitlist[0]['u'.$i])),array(0));
+ }
+ }
+ $dead['hero']='0';
+ if($unitlist){
+ $dead['hero']+=$battlepart['deadherodef'];
+ $database->modifyUnit($data['to'],array("hero"),array($battlepart['deadherodef']),array(0));
+ }
+ //kill other defence in village
+ if(count($database->getEnforceVillage($data['to'],0)) > 0) {
+ foreach($database->getEnforceVillage($data['to'],0) as $enforce) {
+ $life=''; $notlife=''; $wrong='0';
+ if($enforce['from'] != 0){
+ $tribe = $database->getUserField($database->getVillageField($enforce['from'],"owner"),"tribe",0);
+ }else{
+ $tribe = 4;
+ }
+ $start = ($tribe-1)*10+1;
+ $totalreinfunits = 0;
+ for($i=1;$i<=50;$i++) {
+ $totalreinfunits += $enforce['u'.$i];
+ }
+ if($totalreinfunits > 0){
+ if($tribe == 1){ $rom='1'; } else if($tribe == 2){ $ger='1'; }else if($tribe == 3){ $gal='1'; }else if($tribe == 4){ $nat='1'; } else { $natar='1'; }
+ for($i=$start;$i<=($start+9);$i++) {
+ if($enforce['u'.$i]>'0'){
+ $database->modifyEnforce($enforce['id'],$i,round($battlepart[2]*$enforce['u'.$i]),0);
+ $dead[$i]+=round($battlepart[2]*$enforce['u'.$i]);
+ $checkpoint=round($battlepart[2]*$enforce['u'.$i]);
+ if($checkpoint!=$enforce['u'.$i]){
+ $wrong='1';
+ }
+ } else {
+ $dead[$i]='0';
+ }
+ }
+ }
+ if($enforce['hero']>'0'){
+ $database->modifyEnforce($enforce['id'],"hero",$battlepart['deadheroref'][$enforce['id']],0);
+ $dead['hero']+=$battlepart['deadheroref'][$enforce['id']];
+ if($dead['hero']!=$enforce['hero']){
+ $wrong='1';
+ }
+ }
+ $notlife= ''.$dead[$start].','.$dead[$start+1].','.$dead[$start+2].','.$dead[$start+3].','.$dead[$start+4].','.$dead[$start+5].','.$dead[$start+6].','.$dead[$start+7].','.$dead[$start+8].','.$dead[$start+9].'';
+ $notlife1 = $dead[$start]+$dead[$start+1]+$dead[$start+2]+$dead[$start+3]+$dead[$start+4]+$dead[$start+5]+$dead[$start+6]+$dead[$start+7]+$dead[$start+8]+$dead[$start+9];
+ $life= ''.$enforce['u'.$start.''].','.$enforce['u'.($start+1).''].','.$enforce['u'.($start+2).''].','.$enforce['u'.($start+3).''].','.$enforce['u'.($start+4).''].','.$enforce['u'.($start+5).''].','.$enforce['u'.($start+6).''].','.$enforce['u'.($start+7).''].','.$enforce['u'.($start+8).''].','.$enforce['u'.($start+9).''].'';
+ $life1 = $enforce['u'.$start.'']+$enforce['u'.($start+1).'']+$enforce['u'.($start+2).'']+$enforce['u'.($start+3).'']+$enforce['u'.($start+4).'']+$enforce['u'.($start+5).'']+$enforce['u'.($start+6).'']+$enforce['u'.($start+7).'']+$enforce['u'.($start+8).'']+$enforce['u'.($start+9).''];
+ $lifehero = $enforce['hero'];
+ $notlifehero = $dead['hero'];
+ $totallife = $enforce['hero']+$life1;
+ $totalnotlife = $dead['hero']+$notlife1;
+ $totalsend_att = $data['t1']+$data['t2']+$data['t3']+$data['t4']+$data['t5']+$data['t6']+$data['t7']+$data['t8']+$data['t9']+$data['t10']+$data['t11'];
+ $totaldead_att = $dead1+$dead2+$dead3+$dead4+$dead5+$dead6+$dead7+$dead8+$dead9+$dead10+$dead11;
+ //NEED TO SEND A RAPPORTAGE!!!
+ $data2 = ''.$database->getVillageField($enforce['from'],"owner").','.$to['wref'].','.addslashes($to['name']).','.$tribe.','.$life.','.$notlife.','.$lifehero.','.$notlifehero.'';
+ if($scout){
+ if($totaldead_att > 0){
+ if($totaldead_att == $totalsend_att){
+ $database->addNotice($database->getVillageField($enforce['from'],"owner"),$from['wref'],$ownally,15,'Reinforcement in '.addslashes($to['name']).' was attacked',$data2,$AttackArrivalTime);
+ }else{
+ $database->addNotice($database->getVillageField($enforce['from'],"owner"),$from['wref'],$ownally,16,'Reinforcement in '.addslashes($to['name']).' was attacked',$data2,$AttackArrivalTime);
+ }
+ }
+ }else{
+ if($totalnotlife == 0){
+ $database->addNotice($database->getVillageField($enforce['from'],"owner"),$from['wref'],$ownally,15,'Reinforcement in '.addslashes($to['name']).' was attacked',$data2,$AttackArrivalTime);
+ }else if($totallife > $totalnotlife){
+ $database->addNotice($database->getVillageField($enforce['from'],"owner"),$from['wref'],$ownally,16,'Reinforcement in '.addslashes($to['name']).' was attacked',$data2,$AttackArrivalTime);
+ }else{
+ $database->addNotice($database->getVillageField($enforce['from'],"owner"),$from['wref'],$ownally,17,'Reinforcement in '.addslashes($to['name']).' was attacked',$data2,$AttackArrivalTime);
+ }
+ //delete reinf sting when its killed all.
+ if($wrong=='0'){ $database->deleteReinf($enforce['id']); }
+ }
+ }
+ }
+ $totalsend_att = $data['t1']+$data['t2']+$data['t3']+$data['t4']+$data['t5']+$data['t6']+$data['t7']+$data['t8']+$data['t9']+$data['t10']+$data['t11'];
+
+ $unitsdead_def[1] = ''.$dead['1'].','.$dead['2'].','.$dead['3'].','.$dead['4'].','.$dead['5'].','.$dead['6'].','.$dead['7'].','.$dead['8'].','.$dead['9'].','.$dead['10'].'';
+ $unitsdead_def[2] = ''.$dead['11'].','.$dead['12'].','.$dead['13'].','.$dead['14'].','.$dead['15'].','.$dead['16'].','.$dead['17'].','.$dead['18'].','.$dead['19'].','.$dead['20'].'';
+ $unitsdead_def[3] = ''.$dead['21'].','.$dead['22'].','.$dead['23'].','.$dead['24'].','.$dead['25'].','.$dead['26'].','.$dead['27'].','.$dead['28'].','.$dead['29'].','.$dead['30'].'';
+ $unitsdead_def[4] = ''.$dead['31'].','.$dead['32'].','.$dead['33'].','.$dead['34'].','.$dead['35'].','.$dead['36'].','.$dead['37'].','.$dead['38'].','.$dead['39'].','.$dead['40'].'';
+ $unitsdead_def[5] = ''.$dead['41'].','.$dead['42'].','.$dead['43'].','.$dead['44'].','.$dead['45'].','.$dead['46'].','.$dead['47'].','.$dead['48'].','.$dead['49'].','.$dead['50'].'';
+ $unitsdead_deff[1] = '?,?,?,?,?,?,?,?,?,?,';
+ $unitsdead_deff[2] = '?,?,?,?,?,?,?,?,?,?,';
+ $unitsdead_deff[3] = '?,?,?,?,?,?,?,?,?,?,';
+ $unitsdead_deff[4] = '?,?,?,?,?,?,?,?,?,?,';
+ $unitsdead_deff[5] = '?,?,?,?,?,?,?,?,?,?,';
+ $deadhero = $dead['hero'];
+
+ $totaldead_alldef[1] = $dead['1']+$dead['2']+$dead['3']+$dead['4']+$dead['5']+$dead['6']+$dead['7']+$dead['8']+$dead['9']+$dead['10'];
+ $totaldead_alldef[2] = $dead['11']+$dead['12']+$dead['13']+$dead['14']+$dead['15']+$dead['16']+$dead['17']+$dead['18']+$dead['19']+$dead['20'];
+ $totaldead_alldef[3] = $dead['21']+$dead['22']+$dead['23']+$dead['24']+$dead['25']+$dead['26']+$dead['27']+$dead['28']+$dead['29']+$dead['30'];
+ $totaldead_alldef[4] = $dead['31']+$dead['32']+$dead['33']+$dead['34']+$dead['35']+$dead['36']+$dead['37']+$dead['38']+$dead['39']+$dead['40'];
+ $totaldead_alldef[5] = $dead['41']+$dead['42']+$dead['43']+$dead['44']+$dead['45']+$dead['46']+$dead['47']+$dead['48']+$dead['49']+$dead['50'];
+
+ $totaldead_alldef = $totaldead_alldef[1]+$totaldead_alldef[2]+$totaldead_alldef[3]+$totaldead_alldef[4]+$totaldead_alldef[5]+$deadhero;
+ $totalattackdead += $totaldead_alldef;
+
+
+ // Set units returning from attack
+ $database->modifyAttack($data['ref'],1,$dead1);
+ $database->modifyAttack($data['ref'],2,$dead2);
+ $database->modifyAttack($data['ref'],3,$dead3);
+ $database->modifyAttack($data['ref'],4,$dead4);
+ $database->modifyAttack($data['ref'],5,$dead5);
+ $database->modifyAttack($data['ref'],6,$dead6);
+ $database->modifyAttack($data['ref'],7,$dead7);
+ $database->modifyAttack($data['ref'],8,$dead8);
+ $database->modifyAttack($data['ref'],9,$dead9);
+ $database->modifyAttack($data['ref'],10,$dead10);
+ $database->modifyAttack($data['ref'],11,$dead11);
+ $unitsdead_att = ''.$dead1.','.$dead2.','.$dead3.','.$dead4.','.$dead5.','.$dead6.','.$dead7.','.$dead8.','.$dead9.','.$dead10.'';
+
+ $database->modifyAttack($data['ref'],1,$traped1);
+ $database->modifyAttack($data['ref'],2,$traped2);
+ $database->modifyAttack($data['ref'],3,$traped3);
+ $database->modifyAttack($data['ref'],4,$traped4);
+ $database->modifyAttack($data['ref'],5,$traped5);
+ $database->modifyAttack($data['ref'],6,$traped6);
+ $database->modifyAttack($data['ref'],7,$traped7);
+ $database->modifyAttack($data['ref'],8,$traped8);
+ $database->modifyAttack($data['ref'],9,$traped9);
+ $database->modifyAttack($data['ref'],10,$traped10);
+ $database->modifyAttack($data['ref'],11,$traped11);
+ $unitstraped_att = ''.$traped1.','.$traped2.','.$traped3.','.$traped4.','.$traped5.','.$traped6.','.$traped7.','.$traped8.','.$traped9.','.$traped10.','.$traped11.'';
+ if ($herosend_att>0){
+ $unitsdead_att_check = $unitsdead_att.','.$dead11;
+ }else{
+ $unitsdead_att_check = $unitsdead_att;
+ }
+ //$unitsdead_def = ''.$dead11.','.$dead12.','.$dead13.','.$dead14.','.$dead15.','.$dead16.','.$dead17.','.$dead18.','.$dead19.','.$dead20.'';
+
+
+ //top 10 attack and defence update
+ $totaldead_att = $dead1+$dead2+$dead3+$dead4+$dead5+$dead6+$dead7+$dead8+$dead9+$dead10+$dead11;
+ $totalattackdead += $totaldead_att;
+ $troopsdead1 = $dead1;
+ $troopsdead2 = $dead2;
+ $troopsdead3 = $dead3;
+ $troopsdead4 = $dead4;
+ $troopsdead5 = $dead5;
+ $troopsdead6 = $dead6;
+ $troopsdead7 = $dead7;
+ $troopsdead8 = $dead8;
+ $troopsdead9 = $dead9+1;
+ $troopsdead10 = $dead10;
+ $troopsdead11 = $dead11;
+ for($i=1;$i<=50;$i++) {
+ $totaldead_def += $dead[''.$i.''];
+ }
+ $totaldead_def += $dead['hero'];
+ if ($Attacker['uhero'] != 0){
+ $heroxp = $totaldead_def;
+ $database->modifyHeroXp("experience",$heroxp,$from['owner']);
+ }
+ if($Defender['hero'] > 0){
+ $defheroxp = $totaldead_att;
+ $database->modifyHeroXp("experience",$defheroxp,$toF['owner']);
+ }
+ $enforcementarray1 = $database->getEnforceVillage($to['wref'],0);
+ if(count($enforcementarray1) > 0) {
+ foreach($enforcementarray1 as $enforce1) {
+ if($enforce1['hero'] > 0){
+ $enforceowner = $database->getVillageField($enforce1['from'],"owner");
+ $reinfheroxp = $totaldead_att;
+ $database->modifyHeroXp("experience",$reinfheroxp,$enforceowner);
+ }
+ }
+ }
+ $database->modifyPoints($toF['owner'],'dpall',$totaldead_att );
+ $database->modifyPoints($from['owner'],'apall',$totaldead_def);
+ $database->modifyPoints($toF['owner'],'dp',$totaldead_att );
+ $database->modifyPoints($from['owner'],'ap',$totaldead_def);
+ $database->modifyPointsAlly($targetally,'Adp',$totaldead_att );
+ $database->modifyPointsAlly($ownally,'Aap',$totaldead_def);
+ $database->modifyPointsAlly($targetally,'dp',$totaldead_att );
+ $database->modifyPointsAlly($ownally,'ap',$totaldead_def);
+
+
+
+ if ($isoasis == 0){
+ // get toatal cranny value:
+ $buildarray = $database->getResourceLevel($data['to']);
+ $cranny = 0;
+ for($i=19;$i<39;$i++){
+ if($buildarray['f'.$i.'t']==23){
+ $cranny += $bid23[$buildarray['f'.$i.'']]['attri']*CRANNY_CAPACITY;
+ }
+ }
+
+ //cranny efficiency
+ $atk_bonus = ($owntribe == 2)? (4/5) : 1;
+ $def_bonus = ($targettribe == 3)? 2 : 1;
+ $to_owner = $database->getVillageField($data['to'],"owner");
+ $artefact_2 = count($database->getOwnUniqueArtefactInfo2($to_owner,7,3,0));
+ $artefact1_2 = count($database->getOwnUniqueArtefactInfo2($data['to'],7,1,1));
+ $artefact2_2 = count($database->getOwnUniqueArtefactInfo2($to_owner,7,2,0));
+ if($artefact_2 > 0){
+ $artefact_bouns = 6;
+ }else if($artefact1_2 > 0){
+ $artefact_bouns = 3;
+ }else if($artefact2_2 > 0){
+ $artefact_bouns = 2;
+ }else{
+ $artefact_bouns = 1;
+ }
+ $foolartefact = $database->getFoolArtefactInfo(7,$vid,$session->uid);
+ if(count($foolartefact) > 0){
+ foreach($foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $cranny_eff *= $arte['effect2'];
+ }else{
+ $cranny_eff /= $arte['effect2'];
+ $cranny_eff = round($cranny_eff);
+ }
+ }
+ }
+ $cranny_eff = ($cranny * $atk_bonus)*$def_bonus*$artefact_bouns;
+
+ // work out available resources.
+ $this->updateRes($data['to'],$to['owner']);
+ $this->pruneResource();
+
+ $totclay = $database->getVillageField($data['to'],'clay');
+ $totiron = $database->getVillageField($data['to'],'iron');
+ $totwood = $database->getVillageField($data['to'],'wood');
+ $totcrop = $database->getVillageField($data['to'],'crop');
+ }else{
+ $cranny_eff = 0;
+
+ // work out available resources.
+ $this->updateORes($data['to']);
+ $this->pruneOResource();
+
+ $totclay = $database->getOasisField($data['to'],'clay');
+ $totiron = $database->getOasisField($data['to'],'iron');
+ $totwood = $database->getOasisField($data['to'],'wood');
+ $totcrop = $database->getOasisField($data['to'],'crop');
+ }
+ $avclay = floor($totclay - $cranny_eff);
+ $aviron = floor($totiron - $cranny_eff);
+ $avwood = floor($totwood - $cranny_eff);
+ $avcrop = floor($totcrop - $cranny_eff);
+
+ $avclay = ($avclay < 0)? 0 : $avclay;
+ $aviron = ($aviron < 0)? 0 : $aviron;
+ $avwood = ($avwood < 0)? 0 : $avwood;
+ $avcrop = ($avcrop < 0)? 0 : $avcrop;
+
+
+ $avtotal = array($avwood, $avclay, $aviron, $avcrop);
+
+ $av = $avtotal;
+
+ // resources (wood,clay,iron,crop)
+ $steal = array(0,0,0,0);
+
+ //bounty variables
+ $btotal = $battlepart['bounty'];
+ $bmod = 0;
+
+
+ for($i = 0; $i<5; $i++)
+ {
+ for($j=0;$j<4;$j++)
+ {
+ if(isset($avtotal[$j]))
+ {
+ if($avtotal[$j]<1)
+ unset($avtotal[$j]);
+ }
+ }
+ if(!$avtotal)
+ {
+ // echo 'array empty'; *no resources left to take.
+ break;
+ }
+ if($btotal <1 && $bmod <1)
+ break;
+ if($btotal<1)
+ {
+ while($bmod)
+ {
+ //random select
+ $rs = array_rand($avtotal);
+ if(isset($avtotal[$rs]))
+ {
+ $avtotal[$rs] -= 1;
+ $steal[$rs] += 1;
+ $bmod -= 1;
+ }
+ }
+ }
+
+ // handle unballanced amounts.
+ $btotal +=$bmod;
+ $bmod = $btotal%count($avtotal);
+ $btotal -=$bmod;
+ $bsplit = $btotal/count($avtotal);
+
+ $max_steal = (min($avtotal) < $bsplit)? min($avtotal): $bsplit;
+
+ for($j=0;$j<4;$j++)
+ {
+ if(isset($avtotal[$j]))
+ {
+ $avtotal[$j] -= $max_steal;
+ $steal[$j] += $max_steal;
+ $btotal -= $max_steal;
+ }
+ }
+ }
+
+ if ($isoasis == 0) {
+ $database->modifyResource($data["to"], $steal[0], $steal[1], $steal[2], $steal[3], false);
+ $this->pruneResource();
+ } else {
+ $database->modifyOasisResource($data["to"], $steal[0], $steal[1], $steal[2], $steal[3], false);
+ $this->pruneOResource();
+ }
+
+ //work out time of return
+ $start = ($owntribe-1)*10+1;
+ $end = ($owntribe*10);
+
+ $unitspeeds = array(6,5,7,16,14,10,4,3,4,5,
+ 7,7,6,9,10,9,4,3,4,5,
+ 7,6,17,19,16,13,4,3,4,5,
+ 7,7,6,9,10,9,4,3,4,5,
+ 7,7,6,9,10,9,4,3,4,5);
+
+ $speeds = array();
+
+ //find slowest unit.
+ for($i=1;$i<=10;$i++)
+ {
+ if ($data['t'.$i] > $battlepart['casualties_attacker'][$i]) {
+ if($unitarray) { reset($unitarray); }
+ $unitarray = $GLOBALS["u".(($owntribe-1)*10+$i)];
+ $speeds[] = $unitarray['speed'];
+ }
+ }
+ if ($herosend_att>0){
+ $qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner']."";
+ $resulth = mysql_query($qh);
+ $hero_f=mysql_fetch_array($resulth);
+ $hero_unit=$hero_f['unit'];
+ $speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
+ }
+
+// Data for when troops return.
+
+ //catapulten kijken :D
+ $info_cat = $info_chief = $info_ram = ",";
+
+ if ($type=='3'){
+ if ($rams!='0'){
+ if (isset($empty)){
+ $info_ram = "".$ram_pic.",There is no wall to destroy.";
+ } else
+
+ if ($battlepart[8]>$battlepart[7]){
+ $info_ram = "".$ram_pic.",Wall destroyed.";
+ $database->setVillageLevel($data['to'],"f".$wallid."",'0');
+ $database->setVillageLevel($data['to'],"f".$wallid."t",'0');
+ $pop=$this->recountPop($data['to']);
+
+ }elseif ($battlepart[8]==0){
+
+ $info_ram = "".$ram_pic.",Wall was not damaged.";
+ }else{
+
+ $demolish=$battlepart[8]/$battlepart[7];
+ $totallvl = round(sqrt(pow(($walllevel+0.5),2)-($battlepart[8]*8)));
+ if($walllevel == $totallvl){
+ $info_ram = "".$ram_pic.",Wall was not damaged.";
+ }else{
+ $info_ram = "".$ram_pic.",Wall damaged from level
".$walllevel." to level
".$totallvl.".";
+ $database->setVillageLevel($data['to'],"f".$wallid."",$totallvl);
+ }
+
+ }
+ }
+ }
+ if ($type=='3')
+{
+ if ($catp!='0')
+ {
+ $pop=$this->recountPop($data['to']);
+ if($pop<=0)
+ {
+ $info_cat = ",".$catp_pic.", Village already destroyed.";
+ }
+ else
+ {
+ $basearray = $data['to'];
+
+ if ($data['ctar2']==0)
+ {
+ $bdo2=mysql_query("select * from " . TB_PREFIX . "fdata where vref = $basearray");
+ $bdo=mysql_fetch_array($bdo2);
+
+ $rand=$data['ctar1'];
+
+ if ($rand != 0)
+ {
+ $_rand=array();
+ $__rand=array();
+ $j=0;
+ for ($i=1;$i<=41;$i++)
+ {
+ if ($i==41) $i=99;
+ if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0 && $rand != 31 && $rand != 32 && $rand != 33)
+ {
+ $j++;
+ $_rand[$j]=$bdo['f'.$i];
+ $__rand[$j]=$i;
+ }
+ }
+ if (count($_rand)>0)
+ {
+ if (max($_rand)<=0) $rand=0;
+ else
+ {
+ $rand=rand(1, $j);
+ $rand=$__rand[$rand];
+ }
+ }
+ else
+ {
+ $rand=0;
+ }
+ }
+
+ if ($rand == 0)
+ {
+ $list=array();
+ $j=1;
+ for ($i=1;$i<=41;$i++)
+ {
+ if ($i==41) $i=99;
+ if ($bdo['f'.$i] > 0 && $rand != 31 && $rand != 32 && $rand != 33)
+ {
+ $list[$j]=$i;
+ $j++;
+ }
+ }
+ $rand=rand(1, $j);
+ $rand=$list[$rand];
+ }
+
+ $tblevel = $bdo['f'.$rand];
+ $tbgid = $bdo['f'.$rand.'t'];
+ $tbid = $rand;
+ if ($battlepart[4]>$battlepart[3])
+ {
+ $info_cat = "".$catp_pic.", ".$this->procResType($tbgid)." destroyed.";
+ $database->setVillageLevel($data['to'],"f".$tbid."",'0');
+ if($tbid>=19 && $tbid!=99) { $database->setVillageLevel($data['to'],"f".$tbid."t",'0'); }
+ $buildarray = $GLOBALS["bid".$tbgid];
+ if ($tbgid==10 || $tbgid==38) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxstore=$t_sql['maxstore']-$buildarray[$tblevel]['attri'];
+ if ($tmaxstore<800) $tmaxstore=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."'*32 WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==11 || $tbgid==39) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxcrop=$t_sql['maxcrop']-$buildarray[$tblevel]['attri'];
+ if ($tmaxcrop<800) $tmaxcrop=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."'*32 WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==18){
+ $this->updateMax($database->getVillageField($data['to'],'owner'));
+ }
+ $pop=$this->recountPop($data['to']);
+ $capital = $database->getVillage($data['to']);
+ if($pop=='0' && $capital['capital']=='0')
+ {
+ $village_destroyed = 1;
+ }
+ }
+ elseif ($battlepart[4]==0)
+ {
+ $info_cat = "".$catp_pic.",".$this->procResType($tbgid)." was not damaged.";
+ }
+ else
+ {
+ $demolish=$battlepart[4]/$battlepart[3];
+ $totallvl = round(sqrt(pow(($tblevel+0.5),2)-($battlepart[4]*8)));
+ if ($tblevel==$totallvl)
+ $info_cata=" was not damaged.";
+ else
+ {
+ $info_cata=" damaged from level
".$tblevel." to level
".$totallvl.".";
+ $buildarray = $GLOBALS["bid".$tbgid];
+ if ($tbgid==10 || $tbgid==38) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxstore=$t_sql['maxstore']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri'];
+ if ($tmaxstore<800) $tmaxstore=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==11 || $tbgid==39) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxcrop=$t_sql['maxcrop']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri'];
+ if ($tmaxcrop<800) $tmaxcrop=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==18){
+ $this->updateMax($database->getVillageField($data['to'],'owner'));
+ }
+ $pop=$this->recountPop($data['to']);
+ }
+ $info_cat = "".$catp_pic.",".$this->procResType($tbgid).$info_cata;
+ $database->setVillageLevel($data['to'],"f".$tbid."",$totallvl);
+ }
+ }
+ else
+ {
+ $bdo2=mysql_query("select * from " . TB_PREFIX . "fdata where vref = $basearray");
+ $bdo=mysql_fetch_array($bdo2);
+ $rand=$data['ctar1'];
+ if ($rand != 0)
+ {
+ $_rand=array();
+ $__rand=array();
+ $j=0;
+ for ($i=1;$i<=41;$i++)
+ {
+ if ($i==41) $i=99;
+ if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0 && $rand != 31 && $rand != 32 && $rand != 33)
+ {
+ $j++;
+ $_rand[$j]=$bdo['f'.$i];
+ $__rand[$j]=$i;
+ }
+ }
+ if (count($_rand)>0)
+ {
+ if (max($_rand)<=0) $rand=0;
+ else
+ {
+ $rand=rand(1, $j);
+ $rand=$__rand[$rand];
+ }
+ }
+ else
+ {
+ $rand=0;
+ }
+ }
+
+ if ($rand == 0)
+ {
+ $list=array();
+ $j=0;
+ for ($i=1;$i<=41;$i++)
+ {
+ if ($i==41) $i=99;
+ if ($bdo['f'.$i] > 0 && $rand != 31 && $rand != 32 && $rand != 33)
+ {
+ $j++;
+ $list[$j]=$i;
+ }
+ }
+ $rand=rand(1, $j);
+ $rand=$list[$rand];
+ }
+
+ $tblevel = $bdo['f'.$rand];
+ $tbgid = $bdo['f'.$rand.'t'];
+ $tbid = $rand;
+ if ($battlepart[4]>$battlepart[3])
+ {
+ $info_cat = "".$catp_pic.", ".$this->procResType($tbgid)." destroyed.";
+ $database->setVillageLevel($data['to'],"f".$tbid."",'0');
+ if($tbid>=19 && $tbid!=99) { $database->setVillageLevel($data['to'],"f".$tbid."t",'0'); }
+ $buildarray = $GLOBALS["bid".$tbgid];
+ if ($tbgid==10 || $tbgid==38) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxstore=$t_sql['maxstore']-$buildarray[$tblevel]['attri'];
+ if ($tmaxstore<800) $tmaxstore=800*32;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==11 || $tbgid==39) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxcrop=$t_sql['maxcrop']-$buildarray[$tblevel]['attri'];
+ if ($tmaxcrop<800) $tmaxcrop=800*32;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==18){
+ $this->updateMax($database->getVillageField($data['to'],'owner'));
+ }
+ $pop=$this->recountPop($data['to']);
+ if($pop=='0')
+ {
+ $varray = $database->getProfileVillages($to['owner']);
+ if(count($varray)!='1' AND $to['capital']!='1'){
+ $village_destroyed = 1;
+ }
+ }
+ }
+ elseif ($battlepart[4]==0)
+ {
+ $info_cat = "".$catp_pic.",".$this->procResType($tbgid)." was not damaged.";
+ }
+ else
+ {
+ $demolish=$battlepart[4]/$battlepart[3];
+ $totallvl = round(sqrt(pow(($tblevel+0.5),2)-(($battlepart[4]/2)*8)));
+ if ($tblevel==$totallvl)
+ $info_cata=" was not damaged.";
+ else
+ {
+ $info_cata=" damaged from level
".$tblevel." to level
".$totallvl.".";
+ $buildarray = $GLOBALS["bid".$tbgid];
+ if ($tbgid==10 || $tbgid==38) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxstore=$t_sql['maxstore']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri'];
+ if ($tmaxstore<800) $tmaxstore=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==11 || $tbgid==39) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxcrop=$t_sql['maxcrop']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri'];
+ if ($tmaxcrop<800) $tmaxcrop=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==18){
+ $this->updateMax($database->getVillageField($data['to'],'owner'));
+ }
+ $pop=$this->recountPop($data['to']);
+ }
+ $info_cat = "".$catp_pic.",".$this->procResType($tbgid).$info_cata;
+ $database->setVillageLevel($data['to'],"f".$tbid."",$totallvl);
+ }
+ $bdo2=mysql_query("select * from " . TB_PREFIX . "fdata where vref = $basearray");
+ $bdo=mysql_fetch_array($bdo2);
+ $rand=$data['ctar2'];
+ if ($rand != 99)
+ {
+ $_rand=array();
+ $__rand=array();
+ $j=0;
+ for ($i=1;$i<=41;$i++)
+ {
+ if ($i==41) $i=99;
+ if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0 && $rand != 31 && $rand != 32 && $rand != 33)
+ {
+ $j++;
+ $_rand[$j]=$bdo['f'.$i];
+ $__rand[$j]=$i;
+ }
+ }
+ if (count($_rand)>0)
+ {
+ if (max($_rand)<=0) $rand=99;
+ else
+ {
+ $rand=rand(1, $j);
+ $rand=$__rand[$rand];
+ }
+ }
+ else
+ {
+ $rand=99;
+ }
+ }
+
+ if ($rand == 99)
+ {
+ $list=array();
+ $j=0;
+ for ($i=1;$i<=41;$i++)
+ {
+ if ($i==41) $i=99;
+ if ($bdo['f'.$i] > 0)
+ {
+ $j++;
+ $list[$j]=$i;
+ }
+ }
+ $rand=rand(1, $j);
+ $rand=$list[$rand];
+ }
+
+ $tblevel = $bdo['f'.$rand];
+ $tbgid = $bdo['f'.$rand.'t'];
+ $tbid = $rand;
+ if ($battlepart[4]>$battlepart[3])
+ {
+ $info_cat .= "
Information |
+ ".$this->procResType($tbgid)." destroyed. |
---|
";
+ $database->setVillageLevel($data['to'],"f".$tbid."",'0');
+ if($tbid>=19 && $tbid!=99) { $database->setVillageLevel($data['to'],"f".$tbid."t",'0'); }
+ $buildarray = $GLOBALS["bid".$tbgid];
+ if ($tbgid==10 || $tbgid==38) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxstore=$t_sql['maxstore']-$buildarray[$tblevel]['attri'];
+ if ($tmaxstore<800) $tmaxstore=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==11 || $tbgid==39) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxcrop=$t_sql['maxcrop']-$buildarray[$tblevel]['attri'];
+ if ($tmaxcrop<800) $tmaxcrop=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==18){
+ $this->updateMax($database->getVillageField($data['to'],'owner'));
+ }
+ $pop=$this->recountPop($data['to']);
+ if($pop=='0')
+ {
+ $varray = $database->getProfileVillages($to['owner']);
+ if(count($varray)!='1' AND $to['capital']!='1'){
+ $village_destroyed = 1;
+ }
+ }
+ }
+ elseif ($battlepart[4]==0)
+ {
+ $info_cat .= "
Information |
+ ".$this->procResType($tbgid)." was not damaged. |
---|
";
+ }
+ else
+ {
+ $demolish=$battlepart[4]/$battlepart[3];
+ $totallvl = round(sqrt(pow(($tblevel+0.5),2)-(($battlepart[4]/2)*8)));
+ if ($tblevel==$totallvl)
+ $info_cata=" was not damaged.";
+ else
+ {
+ $info_cata=" damaged from level
".$tblevel." to level
".$totallvl.".";
+ $buildarray = $GLOBALS["bid".$tbgid];
+ if ($tbgid==10 || $tbgid==38) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxstore=$t_sql['maxstore']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri'];
+ if ($tmaxstore<800) $tmaxstore=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`='".$tmaxstore."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==11 || $tbgid==39) {
+ $tsql=mysql_query("select `maxstore`,`maxcrop` from ".TB_PREFIX."vdata where wref=".$data['to']."");
+ $t_sql=mysql_fetch_array($tsql);
+ $tmaxcrop=$t_sql['maxcrop']+$buildarray[$totallvl]['attri']-$buildarray[$tblevel]['attri'];
+ if ($tmaxcrop<800) $tmaxcrop=800;
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to'];
+ $database->query($q);
+ }
+ if ($tbgid==18){
+ $this->updateMax($database->getVillageField($data['to'],'owner'));
+ }
+ $pop=$this->recountPop($data['to']);
+ }
+
+ $info_cat .= "
Information |
+ ".$this->procResType($tbgid).$info_cata." |
---|
";
+ $database->setVillageLevel($data['to'],"f".$tbid."",$totallvl);
+
+ }
+ }
+ }
+ }
+}
+
+ //chiefing village
+ //there are senators
+ if(($data['t9']-$dead9)>0){
+
+ $palacelevel = $database->getResourceLevel($from['wref']);
+ for($i=1;$i<=40;$i++) {
+ if($palacelevel['f'.$i.'t'] == 26){
+ $plevel = $i;
+ }else if($palacelevel['f'.$i.'t'] == 25){
+ $plevel = $i;
+ }
+ }
+ if($palacelevel['f'.$plevel.'t'] == 26){
+ if($palacelevel['f'.$plevel] < 10){
+ $canconquer = 0;
+ }
+ elseif($palacelevel['f'.$plevel] < 15){
+ $canconquer = 1;
+ }
+ elseif($palacelevel['f'.$plevel] < 20){
+ $canconquer = 2;
+ }
+ else{
+ $canconquer = 3;
+ }
+ }else if($palacelevel['f'.$plevel.'t'] == 25){
+ if($palacelevel['f'.$plevel] < 10){
+ $canconquer = 0;
+ }
+ elseif($palacelevel['f'.$plevel] < 20){
+ $canconquer = 1;
+ }
+ else{
+ $canconquer = 2;
+ }
+ }
+
+ $exp1 = $database->getVillageField($from['wref'],'exp1');
+ $exp2 = $database->getVillageField($from['wref'],'exp2');
+ $exp3 = $database->getVillageField($from['wref'],'exp3');
+ if($exp1 == 0){
+ $villexp = 0;
+ }
+ elseif($exp2 == 0){
+ $villexp = 1;
+ }
+ elseif($exp3 == 0){
+ $villexp = 2;
+ }
+ else{
+ $villexp = 3;
+ }
+ $varray = $database->getProfileVillages($to['owner']);
+ $varray1 = count($database->getProfileVillages($from['owner']));
+ $mode = CP;
+ $cp_mode = $GLOBALS['cp'.$mode];
+ $need_cps = $cp_mode[$varray1+1];
+ $user_cps = $database->getUserField($from['owner'],"cp",0);
+ //kijken of laatste dorp is, of hoofddorp
+ if($user_cps >= $need_cps){
+ if(count($varray)!='1' AND $to['capital']!='1' AND $villexp < $canconquer){
+ if($to['owner']!=3 OR $to['name']!='WW Buildingplan'){
+ //if there is no Palace/Residence
+ for ($i=18; $i<39; $i++){
+ if ($database->getFieldLevel($data['to'],"".$i."t")==25 or $database->getFieldLevel($data['to'],"".$i."t")==26){
+ $nochiefing='1';
+ $info_chief = "".$chief_pic.",The Palace/Residence isn\'t destroyed!";
+ }
+ }
+ if(!isset($nochiefing)){
+ //$info_chief = "".$chief_pic.",You don't have enought CP to chief a village.";
+ if($this->getTypeLevel(35,$data['from']) == 0){
+ for ($i=0; $i<($data['t9']-$dead9); $i++){
+ if($owntribe == 1){
+ $rand+=rand(20,30);
+ }else{
+ $rand+=rand(20,25);
+ }
+ }
+ }else{
+ for ($i=0; $i<($data['t9']-$dead9); $i++){
+ $rand+=rand(5,15);
+ }
+ }
+ //loyalty is more than 0
+ if(($toF['loyalty']-$rand)>0){
+ $info_chief = "".$chief_pic.",The loyalty was lowered from
".floor($toF['loyalty'])." to
".floor($toF['loyalty']-$rand).".";
+ $database->setVillageField($data['to'],loyalty,($toF['loyalty']-$rand));
+ } else {
+ //you took over the village
+ $villname = addslashes($database->getVillageField($data['to'],"name"));
+ $artifact = $database->getOwnArtefactInfo($data['to']);
+ $info_chief = "".$chief_pic.",Inhabitants of ".$villname." village decided to join your empire.";
+ if ($artifact['vref'] == $data['to']){
+ $database->claimArtefact($data['to'],$data['to'],$database->getVillageField($data['from'],"owner"));
+ }
+ $database->setVillageField($data['to'],loyalty,0);
+ $database->setVillageField($data['to'],owner,$database->getVillageField($data['from'],"owner"));
+ //delete upgrades in armory and blacksmith
+ $q = "DELETE FROM ".TB_PREFIX."abdata WHERE vref = ".$data['to']."";
+ $database->query($q);
+ $database->addABTech($data['to']);
+ //delete researches in academy
+ $q = "DELETE FROM ".TB_PREFIX."tdata WHERE vref = ".$data['to']."";
+ $database->query($q);
+ $database->addTech($data['to']);
+ //delete reinforcement
+ $q = "DELETE FROM ".TB_PREFIX."enforcement WHERE from = ".$data['to']."";
+ $database->query($q);
+ // check buildings
+ $pop1 = $database->getVillageField($data['from'],"pop");
+ $pop2 = $database->getVillageField($data['to'],"pop");
+ if($pop1 > $pop2){
+ $buildlevel = $database->getResourceLevel($data['to']);
+ for ($i=1; $i<=39; $i++){
+ if($buildlevel['f'.$i]!=0){
+ if($buildlevel['f'.$i."t"]!=35 && $buildlevel['f'.$i."t"]!=36 && $buildlevel['f'.$i."t"]!=41){
+ $leveldown = $buildlevel['f'.$i]-1;
+ $database->setVillageLevel($data['to'],"f".$i,$leveldown);
+ }else{
+ $database->setVillageLevel($data['to'],"f".$i,0);
+ $database->setVillageLevel($data['to'],"f".$i."t",0);
+ }
+ }
+ }
+ if($buildlevel['f99']!=0){
+ $leveldown = $buildlevel['f99']-1;
+ $database->setVillageLevel($data['to'],"f99",$leveldown);
+ }
+ }
+ //destroy wall
+ $database->setVillageLevel($data['to'],"f40",0);
+ $database->setVillageLevel($data['to'],"f40t",0);
+ $database->clearExpansionSlot($data['to']);
+
+
+ $exp1 = $database->getVillageField($data['from'],'exp1');
+ $exp2 = $database->getVillageField($data['from'],'exp2');
+ $exp3 = $database->getVillageField($data['from'],'exp3');
+
+ if($exp1 == 0){
+ $exp = 'exp1';
+ $value = $data['to'];
+ }
+ elseif($exp2 == 0){
+ $exp = 'exp2';
+ $value = $data['to'];
+ }
+ else{
+ $exp = 'exp3';
+ $value = $data['to'];
+ }
+ $database->setVillageField($data['from'],$exp,$value);
+ $chiefing_village = 1;
+
+ }
+ }
+ } else {
+ $info_chief = "".$chief_pic.",You cant take over this village.";
+ }
+ } else {
+ $info_chief = "".$chief_pic.",You cant take over this village.";
+ }
+ } else {
+ $info_chief = "".$chief_pic.",Not enough culture points.";
+ }
+ unset($plevel);
+ }
+
+if($data['t11'] > 0){
+ if ($isoasis != 0) {
+ if ($database->canConquerOasis($data['from'],$data['to'])) {
+ if($unitssend_def[1] == '0,0,0,0,0,0,0,0,0,0' and $unitssend_def[2] == '0,0,0,0,0,0,0,0,0,0' and $unitssend_def[3] == '0,0,0,0,0,0,0,0,0,0' and $unitssend_def[4] == '0,0,0,0,0,0,0,0,0,0' and $unitssend_def[5] == '0,0,0,0,0,0,0,0,0,0'){
+ $database->conquerOasis($data['from'],$data['to']);
+ $info_chief = $hero_pic.",Your hero has conquered this oasis";
+ }
+ } else {
+ $OasisInfo = $database->getOasisInfo($data['to']);
+ if ($OasisInfo['conqured'] != 0) {
+ $Oloyaltybefore = $OasisInfo['loyalty'];
+ $database->modifyOasisLoyalty($data['to']);
+ $OasisInfo = $database->getOasisInfo($data['to']);
+ $Oloyaltynow = $OasisInfo['loyalty'];
+ $info_chief = $hero_pic.",Your hero has reduced oasis loyalty to ".$Oloyaltynow." from ".$Oloyaltybefore." and gained ".$heroxp." XP";
+ } else {
+ if ($heroxp == 0) {
+ $info_chief = $hero_pic.",Your hero had nothing to kill therfore gains no XP at all";
+ } else {
+ $info_chief = $hero_pic.",Your hero gained ".$heroxp." XP";
+ }
+ }
+ }
+ } else {
+ $artifact = $database->getOwnArtefactInfo($data['to']);
+ if ($artifact['vref'] == $data['to']) {
+ if ($database->canClaimArtifact($data['from'],$artifact['vref'],$artifact['size'],$artifact['type'])) {
+ $database->claimArtefact($data['from'],$data['to'],$database->getVillageField($data['from'],"owner"));
+ $info_chief = $hero_pic.",Your hero is carrying home a artefact and gained ".$heroxp." XP from the battle";
+ } else {
+ $info_chief = $hero_pic.",Your hero could not claim the artefact and gained ".$heroxp." XP from the battle";
+
+ }
+ }
+ }
+ }
+
+ if($scout){
+ if ($data['spy'] == 1){
+ $info_spy = "".$spy_pic.",
![\"Lumber\" \"Lumber\"](\"img/x.gif\")
".round($totwood)." |
+
![\"Clay\" \"Clay\"](\"img/x.gif\")
".round($totclay)." |
+
![\"Iron\" \"Iron\"](\"img/x.gif\")
".round($totiron)." |
+
![\"Crop\" \"Crop\"](\"img/x.gif\")
".round($totcrop)."
+
![\"carry\" \"carry\"](\"img/x.gif\")
Total Resources : ".round($totwood+$totclay+$totiron+$totcrop)."
+ ";
+ }else if($data['spy'] == 2){
+ if ($isoasis == 0){
+ $resarray = $database->getResourceLevel($data['to']);
+
+
+ $crannylevel =0;
+ $rplevel = 0;
+ $walllevel = 0;
+ for($j=19;$j<=40;$j++) {
+ if($resarray['f'.$j.'t'] == 25 || $resarray['f'.$j.'t'] == 26 ) {
+
+ $rplevel = $database->getFieldLevel($data['to'],$j);
+
+ }
+ }
+ for($j=19;$j<=40;$j++) {
+ if($resarray['f'.$j.'t'] == 31 || $resarray['f'.$j.'t'] == 32 || $resarray['f'.$j.'t'] == 33) {
+
+ $walllevel = $database->getFieldLevel($data['to'],$j);
+
+ }
+ }
+ for($j=19;$j<=40;$j++) {
+ if($resarray['f'.$j.'t'] == 23) {
+
+ $crannylevel = $database->getFieldLevel($data['to'],$j);
+
+ }
+ }
+ }else {
+ $crannylevel =0;
+ $walllevel =0;
+ $rplevel =0;
+ }
+$palaceimg = "
![\"Palace\" \"Palace\"](\"".GP_LOCATE."img/g/g26.gif\")
";
+$crannyimg = "
![\"Cranny\" \"Cranny\"](\"".GP_LOCATE."img/g/g23.gif\")
";
+ $info_spy = "".$spy_pic.",".$palaceimg." Residance/Palace Level : ".$rplevel."
+
".$crannyimg." Cranny level: ".$crannylevel."
Wall Level : ".$walllevel."";
+
+ }
+
+ $data2 = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.',0,0,0,0,0,'.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$rom.','.$unitssend_def[1].','.$unitsdead_def[1].','.$ger.','.$unitssend_def[2].','.$unitsdead_def[2].','.$gal.','.$unitssend_def[3].','.$unitsdead_def[3].','.$nat.','.$unitssend_def[4].','.$unitsdead_def[4].','.$natar.','.$unitssend_def[5].','.$unitsdead_def[5].','.$info_ram.','.$info_cat.','.$info_chief.','.$info_spy.',,'.$data['t11'].','.$dead11.','.$herosend_def.','.$deadhero.','.$unitstraped_att;
+ }
+ else{
+ $data2 = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.','.$steal[0].','.$steal[1].','.$steal[2].','.$steal[3].','.$battlepart['bounty'].','.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$rom.','.$unitssend_def[1].','.$unitsdead_def[1].','.$ger.','.$unitssend_def[2].','.$unitsdead_def[2].','.$gal.','.$unitssend_def[3].','.$unitsdead_def[3].','.$nat.','.$unitssend_def[4].','.$unitsdead_def[4].','.$natar.','.$unitssend_def[5].','.$unitsdead_def[5].','.$info_ram.','.$info_cat.','.$info_chief.','.$info_spy.',,'.$data['t11'].','.$dead11.','.$herosend_def.','.$deadhero.','.$unitstraped_att;
+ }
+
+
+
+
+
+ // When all troops die, sends no info.
+ $data_fail = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.','.$steal[0].','.$steal[1].','.$steal[2].','.$steal[3].','.$battlepart['bounty'].','.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$rom.','.$unitssend_deff[1].','.$unitsdead_deff[1].','.$ger.','.$unitssend_deff[2].','.$unitsdead_deff[2].','.$gal.','.$unitssend_deff[3].','.$unitsdead_deff[3].','.$nat.','.$unitssend_deff[4].','.$unitsdead_deff[4].','.$natar.','.$unitssend_deff[5].','.$unitsdead_deff[5].',,,'.$data['t11'].','.$dead11.','.$unitstraped_att.',,';
+
+ //Undetected and detected in here.
+ if($scout){
+ for($i=1;$i<=10;$i++)
+ {
+ if($battlepart['casualties_attacker'][$i]){
+ if($from['owner'] == 3){
+ $database->addNotice($to['owner'],$to['wref'],$targetally,0,''.addslashes($from['name']).' scouts '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ break;
+ }else if($unitsdead_att == $unitssend_att){
+ $database->addNotice($to['owner'],$to['wref'],$targetally,20,''.addslashes($from['name']).' scouts '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ break;
+ }else{
+ $database->addNotice($to['owner'],$to['wref'],$targetally,21,''.addslashes($from['name']).' scouts '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ break;
+ }
+ }
+ }
+ }
+ else {
+ if($type == 3 && $totalsend_att - ($totaldead_att+$totaltraped_att) > 0){
+ $prisoners = $database->getPrisoners($to['wref']);
+ if(count($prisoners) > 0){
+ $anothertroops = 0;
+ foreach($prisoners as $prisoner){
+ $p_owner = $database->getVillageField($prisoner['from'],"owner");
+ if($p_owner == $from['owner']){
+ $database->modifyAttack2($data['ref'],1,$prisoner['t1']);
+ $database->modifyAttack2($data['ref'],2,$prisoner['t2']);
+ $database->modifyAttack2($data['ref'],3,$prisoner['t3']);
+ $database->modifyAttack2($data['ref'],4,$prisoner['t4']);
+ $database->modifyAttack2($data['ref'],5,$prisoner['t5']);
+ $database->modifyAttack2($data['ref'],6,$prisoner['t6']);
+ $database->modifyAttack2($data['ref'],7,$prisoner['t7']);
+ $database->modifyAttack2($data['ref'],8,$prisoner['t8']);
+ $database->modifyAttack2($data['ref'],9,$prisoner['t9']);
+ $database->modifyAttack2($data['ref'],10,$prisoner['t10']);
+ $database->modifyAttack2($data['ref'],11,$prisoner['t11']);
+ $mytroops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11'];
+ $newtraps = round($mytroops/3);
+ $database->modifyUnit($data['to'],array("99"),array($newtraps),array(0));
+ $database->modifyUnit($data['to'],array("99o"),array($mytroops),array(0));
+ }else{
+ $p_alliance = $database->getUserField($p_owner,"alliance",0);
+ $friendarray = $database->getAllianceAlly($p_alliance,1);
+ $neutralarray = $database->getAllianceAlly($p_alliance,2);
+ $friend = (($friendarray[0]['alli1']>0 and $friendarray[0]['alli2']>0 and $p_alliance>0) and ($friendarray[0]['alli1']==$ownally or $friendarray[0]['alli2']==$ownally) and ($ownally != $p_alliance and $ownally and $p_alliance)) ? '1':'0';
+ $neutral = (($neutralarray[0]['alli1']>0 and $neutralarray[0]['alli2']>0 and $p_alliance>0) and ($neutralarray[0]['alli1']==$ownally or $neutralarray[0]['alli2']==$ownally) and ($ownally != $p_alliance and $ownally and $p_alliance)) ? '1':'0';
+ if($p_alliance == $ownally or $friend == 1 or $neutral == 1){
+ $p_tribe = $database->getUserField($p_owner,"tribe",0);
+
+ $p_eigen = $database->getCoor($prisoner['wref']);
+ $p_from = array('x'=>$p_eigen['x'], 'y'=>$p_eigen['y']);
+ $p_ander = $database->getCoor($prisoner['from']);
+ $p_to = array('x'=>$p_ander['x'], 'y'=>$p_ander['y']);
+ $p_tribe = $database->getUserField($p_owner,"tribe",0);
+
+ $p_speeds = array();
+
+ //find slowest unit.
+ for($i=1;$i<=10;$i++){
+ if ($prisoner['t'.$i]){
+ if($prisoner['t'.$i] != '' && $prisoner['t'.$i] > 0){
+ if($p_unitarray) { reset($p_unitarray); }
+ $p_unitarray = $GLOBALS["u".(($p_tribe-1)*10+$i)];
+ $p_speeds[] = $p_unitarray['speed'];
+ }
+ }
+ }
+
+ if ($prisoner['t11']>0){
+ $p_qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$p_owner."";
+ $p_resulth = mysql_query($p_qh);
+ $p_hero_f=mysql_fetch_array($p_resulth);
+ $p_hero_unit=$p_hero_f['unit'];
+ $p_speeds[] = $GLOBALS['u'.$p_hero_unit]['speed'];
+ }
+
+ $p_artefact = count($database->getOwnUniqueArtefactInfo2($p_owner,2,3,0));
+ $p_artefact1 = count($database->getOwnUniqueArtefactInfo2($prisoner['from'],2,1,1));
+ $p_artefact2 = count($database->getOwnUniqueArtefactInfo2($p_owner,2,2,0));
+ if($p_artefact > 0){
+ $p_fastertroops = 3;
+ }else if($p_artefact1 > 0){
+ $p_fastertroops = 2;
+ }else if($p_artefact2 > 0){
+ $p_fastertroops = 1.5;
+ }else{
+ $p_fastertroops = 1;
+ }
+ $p_time = round($this->procDistanceTime($p_to,$p_from,min($p_speeds),1)/$p_fastertroops);
+ $foolartefact1 = $database->getFoolArtefactInfo(2,$prisoner['from'],$p_owner);
+ if(count($foolartefact1) > 0){
+ foreach($foolartefact1 as $arte){
+ if($arte['bad_effect'] == 1){
+ $p_time *= $arte['effect2'];
+ }else{
+ $p_time /= $arte['effect2'];
+ $p_time = round($p_time);
+ }
+ }
+ }
+ $p_reference = $database->addAttack($prisoner['from'],$prisoner['t1'],$prisoner['t2'],$prisoner['t3'],$prisoner['t4'],$prisoner['t5'],$prisoner['t6'],$prisoner['t7'],$prisoner['t8'],$prisoner['t9'],$prisoner['t10'],$prisoner['t11'],3,0,0,0,0,0,0,0,0,0,0,0);
+ $database->addMovement(4,$prisoner['wref'],$prisoner['from'],$p_reference,microtime(true),($p_time+microtime(true)));
+ $anothertroops += $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11'];
+ $newtraps = (round($anothertroops/3))*2;
+ $database->modifyUnit($data['to'],array("99"),array($newtraps),array(0));
+ $database->modifyUnit($data['to'],array("99o"),array($anothertroops),array(0));
+ }
+ }
+ $database->deletePrisoners($prisoner['id']);
+ }
+ $trapper_pic = "
![\"Trap\" \"Trap\"](\"".GP_LOCATE."img/u/98.gif\")
";
+ $p_username = $database->getUserField($from['owner'],"username",0);
+ if($mytroops > 0 && $anothertroops > 0){
+ $info_trap = "".$trapper_pic." ".$p_username." released
".$mytroops." from his troops and
".$anothertroops." friendly troops.";
+ }elseif($mytroops > 0){
+ $info_trap = "".$trapper_pic." ".$p_username." released
".$mytroops." from his troops.";
+ }elseif($anothertroops > 0){
+ $info_trap = "".$trapper_pic." ".$p_username." released
".$anothertroops." friendly troops.";
+ }
+ }
+ }
+ $data2 = $data2.','.addslashes($info_trap).',,';
+ if($totalsend_alldef == 0){
+ $database->addNotice($to['owner'],$to['wref'],$targetally,7,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ }else if($totaldead_alldef == 0){
+ $database->addNotice($to['owner'],$to['wref'],$targetally,4,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ }else if($totalsend_alldef > $totaldead_alldef){
+ $database->addNotice($to['owner'],$to['wref'],$targetally,5,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ }else if($totalsend_alldef == $totaldead_alldef){
+ $database->addNotice($to['owner'],$to['wref'],$targetally,6,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ }
+ }
+ //to here
+ // If the dead units not equal the ammount sent they will return and report
+ if($totalsend_att - ($totaldead_att+$totaltraped_att) > 0)
+ {
+ $artefact = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,3,0));
+ $artefact1 = count($database->getOwnUniqueArtefactInfo2($from['wref'],2,1,1));
+ $artefact2 = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,2,0));
+ if($artefact > 0){
+ $fastertroops = 3;
+ }else if($artefact1 > 0){
+ $fastertroops = 2;
+ }else if($artefact2 > 0){
+ $fastertroops = 1.5;
+ }else{
+ $fastertroops = 1;
+ }
+ $endtime = round($this->procDistanceTime($from,$to,min($speeds),1)/$fastertroops);
+ $foolartefact2 = $database->getFoolArtefactInfo(2,$from['wref'],$from['owner']);
+ if(count($foolartefact2) > 0){
+ foreach($foolartefact2 as $arte){
+ if($arte['bad_effect'] == 1){
+ $endtime *= $arte['effect2'];
+ }else{
+ $endtime /= $arte['effect2'];
+ $endtime = round($endtime);
+ }
+ }
+ }
+ $endtime += $AttackArrivalTime;
+ if($type == 1) {
+ $database->addNotice($from['owner'],$to['wref'],$ownally,18,''.addslashes($from['name']).' scouts '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ }else {
+ if ($totaldead_att == 0 && $totaltraped_att == 0){
+ $database->addNotice($from['owner'],$to['wref'],$ownally,1,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ }else{
+ $database->addNotice($from['owner'],$to['wref'],$ownally,2,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
+ }
+ }
+
+ $database->setMovementProc($data['moveid']);
+ if($chiefing_village != 1 && $village_destroyed != 1){
+ $database->addMovement(4,$to['wref'],$from['wref'],$data['ref'],$AttackArrivalTime,$endtime);
+ // send the bounty on type 6.
+ if($type !== 1)
+ {
+ $reference = $database->sendResource($steal[0],$steal[1],$steal[2],$steal[3],0,0);
+ $database->addMovement(6,$to['wref'],$from['wref'],$reference,$AttackArrivalTime,$endtime,1,0,0,0,0,$data['ref']);
+ $totalstolengain=$steal[0]+$steal[1]+$steal[2]+$steal[3];
+ $totalstolentaken=($totalstolentaken-($steal[0]+$steal[1]+$steal[2]+$steal[3]));
+ $database->modifyPoints($from['owner'],'RR',$totalstolengain);
+ $database->modifyPoints($to['owner'],'RR',$totalstolentaken);
+ $database->modifyPointsAlly($targetally,'RR',$totalstolentaken );
+ $database->modifyPointsAlly($ownally,'RR',$totalstolengain);
+ }
+ }else if($chiefing_village == 1){
+ $database->addEnforce2($data,$owntribe,$troopsdead1,$troopsdead2,$troopsdead3,$troopsdead4,$troopsdead5,$troopsdead6,$troopsdead7,$troopsdead8,$troopsdead9,$troopsdead10,$troopsdead11);
+ }
+ }
+ else //else they die and don't return or report.
+ {
+ $database->setMovementProc($data['moveid']);
+ if($type == 1){
+ $database->addNotice($from['owner'],$to['wref'],$ownally,19,addslashes($from['name']).' scouts '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime);
+ }else{
+ $database->addNotice($from['owner'],$to['wref'],$ownally,3,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime);
+ }
+ }
+ if($type == 3 or $type == 4){
+ $database->addGeneralAttack($totalattackdead);
+ }
+ if($village_destroyed == 1){
+ $varray = $database->getProfileVillages($to['owner']);
+ if(count($varray)!='1' AND $to['capital']!='1'){
+ $database->clearExpansionSlot($data['to']);
+ $q = "DELETE FROM ".TB_PREFIX."abdata where wref = ".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."bdata where wid = ".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."enforcement where from = ".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."fdata where vref = ".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."market where vref = ".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."odata where wref = ".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."research where vref = ".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."tdata where vref = ".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."training where vref =".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."units where vref =".$data['to'];
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."farmlist where wref =".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."raidlist where towref = ".$village;
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."vdata where wref = ".$data['to'];
+ $database->query($q);
+ $q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = ".$data['to'];
+ $database->query($q);
+ $getmovement = $database->getMovement(3,$data['to'],1);
+ foreach($getmovement as $movedata) {
+ $time = microtime(true);
+ $time2 = $time - $movedata['starttime'];
+ $database->setMovementProc($data['moveid']);
+ $database->addMovement(4,$movedata['to'],$movedata['from'],$movedata['ref'],$time,$time+$time2);
+ $database->setMovementProc($movedata['moveid']);
+ }
+ $q = "DELETE FROM ".TB_PREFIX."movement where from = ".$data['to'];
+ $database->query($q);
+ $getprisoners = $database->getPrisoners($data['to']);
+ foreach($getprisoners as $pris) {
+ $troops = 0;
+ for($i=1;$i<12;$i++){
+ $troops += $pris['t'.$i];
+ }
+ $database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
+ $database->deletePrisoners($pris['id']);
+ }
+ $getprisoners = $database->getPrisoners3($data['to']);
+ foreach($getprisoners as $pris) {
+ $troops = 0;
+ for($i=1;$i<12;$i++){
+ $troops += $pris['t'.$i];
+ }
+ $database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
+ $database->deletePrisoners($pris['id']);
+ }
+ }
+ }
+ }else{
+ //units attack string for battleraport
+ $unitssend_att1 = ''.$data['t1'].','.$data['t2'].','.$data['t3'].','.$data['t4'].','.$data['t5'].','.$data['t6'].','.$data['t7'].','.$data['t8'].','.$data['t9'].','.$data['t10'].'';
+ $herosend_att = $data['t11'];
+ $unitssend_att= $unitssend_att1.','.$herosend_att;
+
+ $speeds = array();
+
+ //find slowest unit.
+ for($i=1;$i<=10;$i++)
+ {
+ if ($data['t'.$i] > 0) {
+ if($unitarray) { reset($unitarray); }
+ $unitarray = $GLOBALS["u".(($owntribe-1)*10+$i)];
+ $speeds[] = $unitarray['speed'];
+ }
+ }
+ if ($herosend_att>0){
+ $qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner']."";
+ $resulth = mysql_query($qh);
+ $hero_f=mysql_fetch_array($resulth);
+ $hero_unit=$hero_f['unit'];
+ $speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
+ }
+ $artefact = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,3,0));
+ $artefact1 = count($database->getOwnUniqueArtefactInfo2($from['vref'],2,1,1));
+ $artefact2 = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,2,0));
+ if($artefact > 0){
+ $fastertroops = 3;
+ }else if($artefact1 > 0){
+ $fastertroops = 2;
+ }else if($artefact2 > 0){
+ $fastertroops = 1.5;
+ }else{
+ $fastertroops = 1;
+ }
+ $endtime = round($this->procDistanceTime($from,$to,min($speeds),1)/$fastertroops);
+ $foolartefact3 = $database->getFoolArtefactInfo(2,$from['wref'],$from['owner']);
+ if(count($foolartefact3) > 0){
+ foreach($foolartefact3 as $arte){
+ if($arte['bad_effect'] == 1){
+ $endtime *= $arte['effect2'];
+ }else{
+ $endtime /= $arte['effect2'];
+ $endtime = round($endtime);
+ }
+ }
+ }
+ $endtime += $AttackArrivalTime;
+ $endtime += microtime(true);
+ $database->setMovementProc($data['moveid']);
+ $database->addMovement(4,$to['wref'],$from['wref'],$data['ref'],$AttackArrivalTime,$endtime);
+ $peace = PEACE;
+ $data2 = ''.$from['owner'].','.$from['wref'].','.$to['owner'].','.$owntribe.','.$unitssend_att.','.$peace.'';
+ $database->addNotice($from['owner'],$to['wref'],$ownally,22,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,time());
+ $database->addNotice($to['owner'],$to['wref'],$targetally,22,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,time());
+ }
+ $crop = $database->getCropProdstarv($to['wref']);
+ $unitarrays = $this->getAllUnits($to['wref']);
+ $getvillage = $database->getVillage($to['wref']);
+ $village_upkeep = $getvillage['pop'] + $this->getUpkeep($unitarrays, 0);
+ if ($crop < $village_upkeep){
+ // add starv data
+ $database->setVillageField($to['wref'], 'starv', $village_upkeep);
+ $database->setVillageField($to['wref'], 'starvupdate', time());
+ }
+ unset($crop,$unitarrays,$getvillage,$village_upkeep);
+
+ #################################################
+ ################FIXED BY SONGER################
+ #################################################
+
+ ################################################################################
+ ##############ISUE: Lag, fixed3####################################################
+ #### PHP.NET manual: unset() destroy more than one variable unset($foo1, $foo2, $foo3);######
+ ################################################################################
+ $data_num++;
+ unset(
+ $Attacker
+ ,$Defender
+ ,$enforce
+ ,$unitssend_att
+ ,$unitssend_def
+ ,$battlepart
+ ,$unitlist
+ ,$unitsdead_def
+ ,$dead
+ ,$steal
+ ,$from
+ ,$data
+ ,$data2
+ ,$to
+ ,$artifact
+ ,$artifactBig
+ ,$canclaim
+ ,$data_fail
+ ,$owntribe
+ ,$unitsdead_att
+ ,$herosend_def
+ ,$deadhero
+ ,$heroxp
+ ,$AttackerID
+ ,$DefenderID
+ ,$totalsend_att
+ ,$totalsend_alldef
+ ,$totaldead_att
+ ,$totaltraped_att
+ ,$totaldead_def
+ ,$unitsdead_att_check
+ ,$totalattackdead
+ ,$enforce1
+ ,$defheroowner
+ ,$enforceowner
+ ,$defheroxp
+ ,$reinfheroxp
+ ,$AttackerWref
+ ,$DefenderWref
+ ,$troopsdead1
+ ,$troopsdead2
+ ,$troopsdead3
+ ,$troopsdead4
+ ,$troopsdead5
+ ,$troopsdead6
+ ,$troopsdead7
+ ,$troopsdead8
+ ,$troopsdead9
+ ,$troopsdead10
+ ,$troopsdead11
+ ,$DefenderUnit);
+
+ #################################################
+
+ }
+ if(file_exists("GameEngine/Prevention/sendunits.txt")) {
+ unlink("GameEngine/Prevention/sendunits.txt");
+ }
+ }
+
+ private function sendTroopsBack($post) {
+ global $form, $database, $village, $generator, $session, $technology;
+
+ $enforce=$database->getEnforceArray($post['ckey'],0);
+ $to = $database->getVillage($enforce['from']);
+ $Gtribe = "";
+ if ($database->getUserField($to['owner'],'tribe',0) == '2'){ $Gtribe = "1"; } else if ($database->getUserField($to['owner'],'tribe',0) == '3'){ $Gtribe = "2"; } else if ($database->getUserField($to['owner'],'tribe',0) == '4'){ $Gtribe = "3"; }else if ($database->getUserField($to['owner'],'tribe',0) == '5'){ $Gtribe = "4"; }
+
+ for($i=1; $i<10; $i++){
+ if(isset($post['t'.$i])){
+ if($i!=10){
+ if ($post['t'.$i] > $enforce['u'.$Gtribe.$i])
+ {
+ $form->addError("error","You can't send more units than you have");
+ break;
+ }
+
+ if($post['t'.$i]<0)
+ {
+ $form->addError("error","You can't send negative units.");
+ break;
+ }
+ }
+ } else {
+ $post['t'.$i.'']='0';
+ }
+ }
+ if(isset($post['t11'])){
+ if ($post['t11'] > $enforce['hero'])
+ {
+ $form->addError("error","You can't send more units than you have");
+ break;
+ }
+
+ if($post['t11']<0)
+ {
+ $form->addError("error","You can't send negative units.");
+ break;
+ }
+ } else {
+ $post['t11']='0';
+ }
+
+ if($form->returnErrors() > 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $_POST;
+ header("Location: a2b.php");
+ } else {
+
+ //change units
+ $start = ($database->getUserField($to['owner'],'tribe',0)-1)*10+1;
+ $end = ($database->getUserField($to['owner'],'tribe',0)*10);
+
+ $j='1';
+ for($i=$start;$i<=$end;$i++){
+ $database->modifyEnforce($post['ckey'],$i,$post['t'.$j.''],0); $j++;
+ }
+
+ //get cord
+ $from = $database->getVillage($enforce['from']);
+ $fromcoor = $database->getCoor($enforce['from']);
+ $tocoor = $database->getCoor($enforce['vref']);
+ $fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']);
+ $toCor = array('x'=>$fromcoor['x'], 'y'=>$fromcoor['y']);
+
+ $speeds = array();
+
+ //find slowest unit.
+ for($i=1;$i<=10;$i++){
+ if (isset($post['t'.$i])){
+ if( $post['t'.$i] != '' && $post['t'.$i] > 0){
+ if($unitarray) { reset($unitarray); }
+ $unitarray = $GLOBALS["u".(($session->tribe-1)*10+$i)];
+ $speeds[] = $unitarray['speed'];
+ } else {
+ $post['t'.$i.'']='0';
+ }
+ } else {
+ $post['t'.$i.'']='0';
+ }
+ }
+ if (isset($post['t11'])){
+ if( $post['t11'] != '' && $post['t11'] > 0){
+ $qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner']."";
+ $resulth = mysql_query($qh);
+ $hero_f=mysql_fetch_array($resulth);
+ $hero_unit=$hero_f['unit'];
+ $speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
+ } else {
+ $post['t11']='0';
+ }
+ } else {
+ $post['t11']='0';
+ }
+ $artefact = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,3,0));
+ $artefact1 = count($database->getOwnUniqueArtefactInfo2($from['vref'],2,1,1));
+ $artefact2 = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,2,0));
+ if($artefact > 0){
+ $fastertroops = 3;
+ }else if($artefact1 > 0){
+ $fastertroops = 2;
+ }else if($artefact2 > 0){
+ $fastertroops = 1.5;
+ }else{
+ $fastertroops = 1;
+ }
+ $time = round($generator->procDistanceTime($fromCor,$toCor,min($speeds),1)/$fastertroops);
+ $foolartefact4 = $database->getFoolArtefactInfo(2,$from['wref'],$from['owner']);
+ if(count($foolartefact4) > 0){
+ foreach($foolartefact4 as $arte){
+ if($arte['bad_effect'] == 1){
+ $time *= $arte['effect2'];
+ }else{
+ $time /= $arte['effect2'];
+ $time = round($endtime);
+ }
+ }
+ }
+ $reference = $database->addAttack($enforce['from'],$post['t1'],$post['t2'],$post['t3'],$post['t4'],$post['t5'],$post['t6'],$post['t7'],$post['t8'],$post['t9'],$post['t10'],$post['t11'],2,0,0,0,0);
+ $database->addMovement(4,$village->wid,$enforce['from'],$reference,$AttackArrivalTime,($time+$AttackArrivalTime));
+ $technology->checkReinf($post['ckey']);
+
+ header("Location: build.php?id=39");
+
+ }
+ }
+
+ private function sendreinfunitsComplete() {
+ if(file_exists("GameEngine/Prevention/sendreinfunits.txt")) {
+ unlink("GameEngine/Prevention/sendreinfunits.txt");
+ }
+ global $bid23,$database,$battle;
+ $time = time();
+ $ourFileHandle = fopen("GameEngine/Prevention/sendreinfunits.txt", 'w');
+ fclose($ourFileHandle);
+ $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."attacks where ".TB_PREFIX."movement.ref = ".TB_PREFIX."attacks.id and ".TB_PREFIX."movement.proc = '0' and ".TB_PREFIX."movement.sort_type = '3' and ".TB_PREFIX."attacks.attack_type = '2' and endtime < $time";
+ $dataarray = $database->query_return($q);
+ foreach($dataarray as $data) {
+ if($data['from']==0){
+ $to = $database->getMInfo($data['to']);
+ $database->addEnforce($data);
+ $reinf = $database->getEnforce($data['to'],$data['from']);
+ $database->modifyEnforce($reinf['id'],31,1,1);
+ $data_fail = '0,0,4,1,0,0,0,0,0,0,0,0,0,0';
+ $database->addNotice($to['owner'],$to['wref'],$targetally,8,'village of the elders reinforcement '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime);
+ $database->setMovementProc($data['moveid']);
+ }else{
+ //set base things
+ $owntribe = $database->getUserField($database->getVillageField($data['from'],"owner"),"tribe",0);
+ $targettribe = $database->getUserField($database->getVillageField($data['to'],"owner"),"tribe",0);
+ $to = $database->getMInfo($data['to']);
+ $from = $database->getMInfo($data['from']);
+ $toF = $database->getVillage($data['to']);
+ $fromF = $database->getVillage($data['from']);
+
+ //check to see if we're only sending a hero between own villages and there's a Mansion at target village
+ if($data['t11'] != 0) {
+ if($database->getVillageField($data['from'],"owner") == $database->getVillageField($data['to'],"owner")) {
+ for($i=1;$i<=10;$i++) { if($data['t'.$i]>0) { $NonHeroPresent = 1; break; } }
+ if($NonHeroPresent == 0 && $this->getTypeLevel(37,$data['to']) > 0) {
+ //don't reinforce, addunit instead
+ $database->modifyUnit($data['to'],array("hero"),array(1),array(1));
+ $heroid = $database->getHero($database->getVillageField($data['from'],"owner"),1);
+ $database->modifyHero("wref",$data['to'],$heroid,0);
+ $HeroTransfer = 1;
+ }
+ }
+ } if(!$HeroTransfer)
+ {
+ //check if there is defence from town in to town
+ $check=$database->getEnforce($data['to'],$data['from']);
+ if (!isset($check['id'])){
+ //no:
+ $database->addEnforce($data);
+ } else{
+ //yes
+ $start = ($owntribe-1)*10+1;
+ $end = ($owntribe*10);
+ //add unit.
+ $j='1';
+ for($i=$start;$i<=$end;$i++){
+ $database->modifyEnforce($check['id'],$i,$data['t'.$j.''],1); $j++;
+ }
+ }
+ }
+ //send rapport
+ $unitssend_att = ''.$data['t1'].','.$data['t2'].','.$data['t3'].','.$data['t4'].','.$data['t5'].','.$data['t6'].','.$data['t7'].','.$data['t8'].','.$data['t9'].','.$data['t10'].','.$data['t11'].'';
+ $data_fail = ''.$from['wref'].','.$from['owner'].','.$owntribe.','.$unitssend_att.'';
+ $database->addNotice($from['owner'],$from['wref'],$ownally,8,''.addslashes($from['name']).' reinforcement '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime);
+ if($from['owner'] != $to['owner']) {
+ $database->addNotice($to['owner'],$to['wref'],$targetally,8,''.addslashes($from['name']).' reinforcement '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime);
+ }
+ //update status
+ $database->setMovementProc($data['moveid']);
+ }
+ }
+ if(file_exists("GameEngine/Prevention/sendreinfunits.txt")) {
+ unlink("GameEngine/Prevention/sendreinfunits.txt");
+ }
+ }
+
+ private function returnunitsComplete() {
+ if(file_exists("GameEngine/Prevention/returnunits.txt")) {
+ unlink("GameEngine/Prevention/returnunits.txt");
+ }
+ global $database;
+ $ourFileHandle = fopen("GameEngine/Prevention/returnunits.txt", 'w');
+ fclose($ourFileHandle);
+ $time = time();
+ $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."attacks where ".TB_PREFIX."movement.ref = ".TB_PREFIX."attacks.id and ".TB_PREFIX."movement.proc = '0' and ".TB_PREFIX."movement.sort_type = '4' and endtime < $time";
+ $dataarray = $database->query_return($q);
+
+ foreach($dataarray as $data) {
+
+ $tribe = $database->getUserField($database->getVillageField($data['to'],"owner"),"tribe",0);
+
+ if($tribe == 1){ $u = ""; } elseif($tribe == 2){ $u = "1"; } elseif($tribe == 3){ $u = "2"; } elseif($tribe == 4){ $u = "3"; } else{ $u = "4"; }
+ $database->modifyUnit(
+ $data['to'],
+ array($u."1",$u."2",$u."3",$u."4",$u."5",$u."6",$u."7",$u."8",$u."9",$tribe."0","hero"),
+ array($data['t1'],$data['t2'],$data['t3'],$data['t4'],$data['t5'],$data['t6'],$data['t7'],$data['t8'],$data['t9'],$data['t10'],$data['t11']),
+ array(1,1,1,1,1,1,1,1,1,1,1)
+ );
+ $database->setMovementProc($data['moveid']);
+ }
+
+ // Recieve the bounty on type 6.
+
+ $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."send where ".TB_PREFIX."movement.ref = ".TB_PREFIX."send.id and ".TB_PREFIX."movement.proc = 0 and sort_type = 6 and endtime < $time";
+ $dataarray = $database->query_return($q);
+ foreach($dataarray as $data) {
+
+ if($data['wood'] >= $data['clay'] && $data['wood'] >= $data['iron'] && $data['wood'] >= $data['crop']){ $sort_type = "10"; }
+ elseif($data['clay'] >= $data['wood'] && $data['clay'] >= $data['iron'] && $data['clay'] >= $data['crop']){ $sort_type = "11"; }
+ elseif($data['iron'] >= $data['wood'] && $data['iron'] >= $data['clay'] && $data['iron'] >= $data['crop']){ $sort_type = "12"; }
+ elseif($data['crop'] >= $data['wood'] && $data['crop'] >= $data['clay'] && $data['crop'] >= $data['iron']){ $sort_type = "13"; }
+
+ $to = $database->getMInfo($data['to']);
+ $from = $database->getMInfo($data['from']);
+ $database->modifyResource($data['to'],$data['wood'],$data['clay'],$data['iron'],$data['crop'],1);
+ //$database->updateVillage($data['to']);
+ $database->setMovementProc($data['moveid']);
+ }
+ $this->pruneResource();
+
+ // Settlers
+
+ $q = "SELECT * FROM ".TB_PREFIX."movement where ref = 0 and proc = '0' and sort_type = '4' and endtime < $time";
+ $dataarray = $database->query_return($q);
+ foreach($dataarray as $data) {
+
+ $tribe = $database->getUserField($database->getVillageField($data['to'],"owner"),"tribe",0);
+
+ $database->modifyUnit($data['to'],array($tribe."0"),array(3),array(1));
+ $database->setMovementProc($data['moveid']);
+ }
+
+ if(file_exists("GameEngine/Prevention/returnunits.txt")) {
+ unlink("GameEngine/Prevention/returnunits.txt");
+ }
+ }
+
+ private function sendSettlersComplete() {
+ if(file_exists("GameEngine/Prevention/settlers.txt")) {
+ unlink("GameEngine/Prevention/settlers.txt");
+ }
+ global $database, $building;
+ $ourFileHandle = fopen("GameEngine/Prevention/settlers.txt", 'w');
+ fclose($ourFileHandle);
+ $time = microtime(true);
+ $q = "SELECT * FROM ".TB_PREFIX."movement where proc = 0 and sort_type = 5 and endtime < $time";
+ $dataarray = $database->query_return($q);
+ foreach($dataarray as $data) {
+ $to = $database->getMInfo($data['from']);
+ $user = addslashes($database->getUserField($to['owner'],'username',0));
+ $taken = $database->getVillageState($data['to']);
+ if($taken != 1){
+ $database->setFieldTaken($data['to']);
+ $database->addVillage($data['to'],$to['owner'],$user,'0');
+ $database->addResourceFields($data['to'],$database->getVillageType($data['to']));
+ $database->addUnits($data['to']);
+ $database->addTech($data['to']);
+ $database->addABTech($data['to']);
+ $database->setMovementProc($data['moveid']);
+
+ $exp1 = $database->getVillageField($data['from'],'exp1');
+ $exp2 = $database->getVillageField($data['from'],'exp2');
+ $exp3 = $database->getVillageField($data['from'],'exp3');
+
+ if($exp1 == 0){
+ $exp = 'exp1';
+ $value = $data['to'];
+ }
+ elseif($exp2 == 0){
+ $exp = 'exp2';
+ $value = $data['to'];
+ }
+ else{
+ $exp = 'exp3';
+ $value = $data['to'];
+ }
+ $database->setVillageField($data['from'],$exp,$value);
+ }
+ else{
+ // here must come movement from returning settlers
+ $database->addMovement(4,$data['to'],$data['from'],$data['ref'],$time,$time+($time-$data['starttime']));
+ $database->setMovementProc($data['moveid']);
+ }
+ }
+ if(file_exists("GameEngine/Prevention/settlers.txt")) {
+ unlink("GameEngine/Prevention/settlers.txt");
+ }
+ }
+
+ private function researchComplete() {
+ if(file_exists("GameEngine/Prevention/research.txt")) {
+ unlink("GameEngine/Prevention/research.txt");
+ }
+ global $database;
+ $ourFileHandle = fopen("GameEngine/Prevention/research.txt", 'w');
+ fclose($ourFileHandle);
+ $time = time();
+ $q = "SELECT * FROM ".TB_PREFIX."research where timestamp < $time";
+ $dataarray = $database->query_return($q);
+ foreach($dataarray as $data) {
+ $sort_type = substr($data['tech'],0,1);
+ switch($sort_type) {
+ case "t":
+ $q = "UPDATE ".TB_PREFIX."tdata set ".$data['tech']." = 1 where vref = ".$data['vref'];
+ break;
+ case "a":
+ case "b":
+ $q = "UPDATE ".TB_PREFIX."abdata set ".$data['tech']." = ".$data['tech']." + 1 where vref = ".$data['vref'];
+ break;
+ }
+ $database->query($q);
+ $q = "DELETE FROM ".TB_PREFIX."research where id = ".$data['id'];
+ $database->query($q);
+ }
+ if(file_exists("GameEngine/Prevention/research.txt")) {
+ unlink("GameEngine/Prevention/research.txt");
+ }
+ }
+
+ private function updateRes($bountywid,$uid) {
+ global $session;
+
+
+ $this->bountyLoadTown($bountywid);
+ $this->bountycalculateProduction($bountywid,$uid);
+ $this->bountyprocessProduction($bountywid);
+ }
+
+ private function updateORes($bountywid) {
+ global $session;
+ $this->bountyLoadOTown($bountywid);
+ $this->bountycalculateOProduction($bountywid);
+ $this->bountyprocessOProduction($bountywid);
+ }
+ private function bountyLoadOTown($bountywid) {
+ global $database,$session,$logging,$technology;
+ $this->bountyinfoarray = $database->getOasisV($bountywid);
+ $this->bountyresarray = $database->getResourceLevel($bountywid);
+ $this->bountypop = 2;
+
+ }
+ private function bountyLoadTown($bountywid) {
+ global $database,$session,$logging,$technology;
+ $this->bountyinfoarray = $database->getVillage($bountywid);
+ $this->bountyresarray = $database->getResourceLevel($bountywid);
+ $this->bountyoasisowned = $database->getOasis($bountywid);
+ $this->bountyocounter = $this->bountysortOasis();
+ $this->bountypop = $this->bountyinfoarray['pop'];
+
+ }
+
+ private function bountysortOasis() {
+ $crop = $clay = $wood = $iron = 0;
+ foreach ($this->bountyoasisowned as $oasis) {
+ switch($oasis['type']) {
+ case 1:
+ case 2:
+ $wood += 1;
+ break;
+ case 3:
+ $wood += 1;
+ $crop += 1;
+ break;
+ case 4:
+ case 5:
+ $clay += 1;
+ break;
+ case 6:
+ $clay += 1;
+ $crop += 1;
+ break;
+ case 7:
+ case 8:
+ $iron += 1;
+ break;
+ case 9:
+ $iron += 1;
+ $crop += 1;
+ break;
+ case 10:
+ case 11:
+ $crop += 1;
+ break;
+ case 12:
+ $crop += 2;
+ break;
+ }
+ }
+ return array($wood,$clay,$iron,$crop);
+ }
+
+ function getAllUnits($base) {
+ global $database;
+ $ownunit = $database->getUnit($base);
+ $enforcementarray = $database->getEnforceVillage($base,0);
+ if(count($enforcementarray) > 0) {
+ foreach($enforcementarray as $enforce) {
+ for($i=1;$i<=50;$i++) {
+ $ownunit['u'.$i] += $enforce['u'.$i];
+ }
+ }
+ }
+ $movement = $database->getVillageMovement($base);
+ if(!empty($movement)) {
+ for($i=1;$i<=50;$i++) {
+ $ownunit['u'.$i] += $movement['u'.$i];
+ }
+ }
+ $prisoners = $database->getPrisoners($base);
+ if(!empty($prisoners)) {
+ foreach($prisoners as $prisoner){
+ $owner = $database->getVillageField($base,"owner");
+ $ownertribe = $database->getUserField($owner,"tribe",0);
+ $start = ($ownertribe-1)*10+1;
+ $end = ($ownertribe*10);
+ for($i=$start;$i<=$end;$i++) {
+ $j = $i-$start+1;
+ $ownunit['u'.$i] += $prisoner['t'.$j];
+ }
+ $ownunit['hero'] += $prisoner['t11'];
+ }
+ }
+ return $ownunit;
+ }
+
+ public function getUpkeep($array,$type,$vid=0,$prisoners=0) {
+ global $database,$session,$village;
+ if($vid==0) { $vid=$village->wid; }
+ $buildarray = array();
+ if($vid!=0){ $buildarray = $database->getResourceLevel($vid); }
+ $upkeep = 0;
+ switch($type) {
+ case 0:
+ $start = 1;
+ $end = 50;
+ break;
+ case 1:
+ $start = 1;
+ $end = 10;
+ break;
+ case 2:
+ $start = 11;
+ $end = 20;
+ break;
+ case 3:
+ $start = 21;
+ $end = 30;
+ break;
+ case 4:
+ $start = 31;
+ $end = 40;
+ break;
+ case 5:
+ $start = 41;
+ $end = 50;
+ break;
+ }
+ for($i=$start;$i<=$end;$i++) {
+ $k = $i-$start+1;
+ $unit = "u".$i;
+ $unit2 = "t".$k;
+ global $$unit;
+ $dataarray = $$unit;
+ for($j=19;$j<=38;$j++) {
+ if($buildarray['f'.$j.'t'] == 41) {
+ $horsedrinking = $j;
+ }
+ }
+ if($prisoners == 0){
+ if(isset($horsedrinking)){
+ if(($i==4 && $buildarray['f'.$horsedrinking] >= 10)
+ || ($i==5 && $buildarray['f'.$horsedrinking] >= 15)
+ || ($i==6 && $buildarray['f'.$horsedrinking] == 20)) {
+ $upkeep += ($dataarray['pop']-1) * $array[$unit];
+ } else {
+ $upkeep += $dataarray['pop'] * $array[$unit];
+ }}else{
+ $upkeep += $dataarray['pop'] * $array[$unit];
+ }
+ }else{
+ if(isset($horsedrinking)){
+ if(($i==4 && $buildarray['f'.$horsedrinking] >= 10)
+ || ($i==5 && $buildarray['f'.$horsedrinking] >= 15)
+ || ($i==6 && $buildarray['f'.$horsedrinking] == 20)) {
+ $upkeep += ($dataarray['pop']-1) * $array[$unit2];
+ } else {
+ $upkeep += $dataarray['pop'] * $array[$unit2];
+ }}else{
+ $upkeep += $dataarray['pop'] * $array[$unit2];
+ }
+ }
+ }
+ // $unit = "hero";
+ // global $$unit;
+ // $dataarray = $$unit;
+ if($prisoners == 0){
+ $upkeep += $array['hero'] * 6;
+ }else{
+ $upkeep += $array['t11'] * 6;
+ }
+ $artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,4,3,0));
+ $artefact1 = count($database->getOwnUniqueArtefactInfo2($vid,4,1,1));
+ $artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,4,2,0));
+ if($artefact > 0){
+ $upkeep /= 2;
+ $upkeep = round($upkeep);
+ }else if($artefact1 > 0){
+ $upkeep /= 2;
+ $upkeep = round($upkeep);
+ }else if($artefact2 > 0){
+ $upkeep /= 4;
+ $upkeep = round($upkeep);
+ $upkeep *= 3;
+ }
+ $foolartefact = $database->getFoolArtefactInfo(4,$vid,$session->uid);
+ if(count($foolartefact) > 0){
+ foreach($foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $upkeep *= $arte['effect2'];
+ }else{
+ $upkeep /= $arte['effect2'];
+ $upkeep = round($upkeep);
+ }
+ }
+ }
+ return $upkeep;
+ }
+
+ private function bountycalculateOProduction($bountywid) {
+ global $technology,$database;
+ $this->bountyOproduction['wood'] = $this->bountyGetOWoodProd();
+ $this->bountyOproduction['clay'] = $this->bountyGetOClayProd();
+ $this->bountyOproduction['iron'] = $this->bountyGetOIronProd();
+ $this->bountyOproduction['crop'] = $this->bountyGetOCropProd();
+ }
+ private function bountycalculateProduction($bountywid,$uid) {
+ global $technology,$database;
+ $normalA = $database->getOwnArtefactInfoByType($bountywid,4);
+ $largeA = $database->getOwnUniqueArtefactInfo($uid,4,2);
+ $uniqueA = $database->getOwnUniqueArtefactInfo($uid,4,3);
+ $upkeep = $this->getUpkeep($this->getAllUnits($bountywid),0);
+ $this->bountyproduction['wood'] = $this->bountyGetWoodProd();
+ $this->bountyproduction['clay'] = $this->bountyGetClayProd();
+ $this->bountyproduction['iron'] = $this->bountyGetIronProd();
+ if ($uniqueA['size']==3 && $uniqueA['owner']==$uid){
+ $this->bountyproduction['crop'] = $this->bountyGetCropProd()-$this->bountypop-(($upkeep)-round($upkeep*0.50));
+
+ }else if ($normalA['type']==4 && $normalA['size']==1 && $normalA['owner']==$uid){
+ $this->bountyproduction['crop'] = $this->bountyGetCropProd()-$this->bountypop-(($upkeep)-round($upkeep*0.25));
+
+ }else if ($largeA['size']==2 && $largeA['owner']==$uid){
+ $this->bountyproduction['crop'] = $this->bountyGetCropProd()-$this->bountypop-(($upkeep)-round($upkeep*0.25));
+
+ }else{
+ $this->bountyproduction['crop'] = $this->bountyGetCropProd()-$this->bountypop-$upkeep;
+ }
+ }
+
+ private function bountyprocessProduction($bountywid) {
+ global $database;
+ $timepast = time() - $this->bountyinfoarray['lastupdate'];
+ $nwood = ($this->bountyproduction['wood'] / 3600) * $timepast;
+ $nclay = ($this->bountyproduction['clay'] / 3600) * $timepast;
+ $niron = ($this->bountyproduction['iron'] / 3600) * $timepast;
+ $ncrop = ($this->bountyproduction['crop'] / 3600) * $timepast;
+ $database->modifyResource($bountywid,$nwood,$nclay,$niron,$ncrop,1);
+ $database->updateVillage($bountywid);
+ }
+ private function bountyprocessOProduction($bountywid) {
+ global $database;
+ $timepast = time() - $this->bountyinfoarray['lastupdated'];
+ $nwood = ($this->bountyproduction['wood'] / 3600) * $timepast;
+ $nclay = ($this->bountyproduction['clay'] / 3600) * $timepast;
+ $niron = ($this->bountyproduction['iron'] / 3600) * $timepast;
+ $ncrop = ($this->bountyproduction['crop'] / 3600) * $timepast;
+ $database->modifyOasisResource($bountywid,$nwood,$nclay,$niron,$ncrop,1);
+ $database->updateOasis($bountywid);
+ }
+
+ private function bountyGetWoodProd() {
+ global $bid1,$bid5,$session;
+ $wood = $sawmill = 0;
+ $woodholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($this->bountyresarray['f'.$i.'t'] == 1) {
+ array_push($woodholder,'f'.$i);
+ }
+ if($this->bountyresarray['f'.$i.'t'] == 5) {
+ $sawmill = $this->bountyresarray['f'.$i];
+ }
+ }
+ for($i=0;$i<=count($woodholder)-1;$i++) { $wood+= $bid1[$this->bountyresarray[$woodholder[$i]]]['prod']; }
+ if($sawmill >= 1) {
+ $wood += $wood /100 * $bid5[$sawmill]['attri'];
+ }
+ if($this->bountyocounter[0] != 0) {
+ $wood += $wood*0.25*$this->bountyocounter[0];
+ }
+ $wood *= SPEED;
+ return round($wood);
+ }
+ private function bountyGetOWoodProd() {
+ global $session;
+ $wood = 0;
+ $wood += 40;
+ $wood *= SPEED;
+ return round($wood);
+ }
+ private function bountyGetOClayProd() {
+ global $session;
+ $clay = 0;
+ $clay += 40;
+ $clay *= SPEED;
+ return round($clay);
+ }private function bountyGetOIronProd() {
+ global $session;
+ $iron = 0;
+ $iron += 40;
+ $iron *= SPEED;
+ return round($iron);
+ }
+
+ private function bountyGetOCropProd() {
+ global $session;
+ $crop = 0;
+ $clay += 40;
+ $crop *= SPEED;
+ return round($crop);
+ }
+ private function bountyGetClayProd() {
+ global $bid2,$bid6,$session;
+ $clay = $brick = 0;
+ $clayholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($this->bountyresarray['f'.$i.'t'] == 2) {
+ array_push($clayholder,'f'.$i);
+ }
+ if($this->bountyresarray['f'.$i.'t'] == 6) {
+ $brick = $this->bountyresarray['f'.$i];
+ }
+ }
+ for($i=0;$i<=count($clayholder)-1;$i++) { $clay+= $bid2[$this->bountyresarray[$clayholder[$i]]]['prod']; }
+ if($brick >= 1) {
+ $clay += $clay /100 * $bid6[$brick]['attri'];
+ }
+ if($this->bountyocounter[1] != 0) {
+ $clay += $clay*0.25*$this->bountyocounter[1];
+ }
+ $clay *= SPEED;
+ return round($clay);
+ }
+
+ private function bountyGetIronProd() {
+ global $bid3,$bid7,$session;
+ $iron = $foundry = 0;
+ $ironholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($this->bountyresarray['f'.$i.'t'] == 3) {
+ array_push($ironholder,'f'.$i);
+ }
+ if($this->bountyresarray['f'.$i.'t'] == 7) {
+ $foundry = $this->bountyresarray['f'.$i];
+ }
+ }
+ for($i=0;$i<=count($ironholder)-1;$i++) { $iron+= $bid3[$this->bountyresarray[$ironholder[$i]]]['prod']; }
+ if($foundry >= 1) {
+ $iron += $iron /100 * $bid7[$foundry]['attri'];
+ }
+ if($this->bountyocounter[2] != 0) {
+ $iron += $iron*0.25*$this->bountyocounter[2];
+ }
+ $iron *= SPEED;
+ return round($iron);
+ }
+
+ private function bountyGetCropProd() {
+ global $bid4,$bid8,$bid9,$session;
+ $crop = $grainmill = $bakery = 0;
+ $cropholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($this->bountyresarray['f'.$i.'t'] == 4) {
+ array_push($cropholder,'f'.$i);
+ }
+ if($this->bountyresarray['f'.$i.'t'] == 8) {
+ $grainmill = $this->bountyresarray['f'.$i];
+ }
+ if($this->bountyresarray['f'.$i.'t'] == 9) {
+ $bakery = $this->bountyresarray['f'.$i];
+ }
+ }
+ for($i=0;$i<=count($cropholder)-1;$i++) { $crop+= $bid4[$this->bountyresarray[$cropholder[$i]]]['prod']; }
+ if($grainmill >= 1) {
+ $crop += $crop /100 * $bid8[$grainmill]['attri'];
+ }
+ if($bakery >= 1) {
+ $crop += $crop /100 * $bid9[$bakery]['attri'];
+ }
+ if($this->bountyocounter[3] != 0) {
+ $crop += $crop*0.25*$this->bountyocounter[3];
+ }
+ $crop *= SPEED;
+ return round($crop);
+ }
+
+ private function trainingComplete() {
+ if(file_exists("GameEngine/Prevention/training.txt")) {
+ unlink("GameEngine/Prevention/training.txt");
+ }
+ global $database;
+ $time = time();
+ $ourFileHandle = fopen("GameEngine/Prevention/training.txt", 'w');
+ fclose($ourFileHandle);
+ $trainlist = $database->getTrainingList();
+ if(count($trainlist) > 0){
+ foreach($trainlist as $train){
+ $timepast = $train['timestamp2'] - $time;
+ $pop = $train['pop'];
+ if($timepast <= 0 && $train['amt'] > 0) {
+ $timepast2 = $time - $train['timestamp2'];
+ $trained = 1;
+ while($timepast2 >= $train['eachtime']){
+ $timepast2 -= $train['eachtime'];
+ $trained += 1;
+ }
+ if($trained > $train['amt']){
+ $trained = $train['amt'];
+ }
+ if($train['unit']>60 && $train['unit']!=99){
+ $database->modifyUnit($train['vref'],array($train['unit']-60),array($trained),array(1));
+ }else{
+ $database->modifyUnit($train['vref'],array($train['unit']),array($trained),array(1));
+ }
+ $database->updateTraining($train['id'],$trained,$trained*$train['eachtime']);
+ }
+ if($train['amt'] == 0){
+ $database->trainUnit($train['id'],0,0,0,0,1,1);
+ }
+ $crop = $database->getCropProdstarv($train['vref']);
+ $unitarrays = $this->getAllUnits($train['vref']);
+ $village = $database->getVillage($train['vref']);
+ $upkeep = $village['pop'] + $this->getUpkeep($unitarrays, 0);
+ if ($crop < $upkeep){
+ // add starv data
+ $database->setVillageField($train['vref'], 'starv', $upkeep);
+ $database->setVillageField($train['vref'], 'starvupdate', $time);
+ }
+ }
+ }
+ if(file_exists("GameEngine/Prevention/training.txt")) {
+ unlink("GameEngine/Prevention/training.txt");
+ }
+ }
+
+ public function procDistanceTime($coor,$thiscoor,$ref,$mode) {
+ global $bid14,$database,$generator;
+ $resarray = $database->getResourceLevel($generator->getBaseID($coor['x'],$coor['y']));
+ $xdistance = ABS($thiscoor['x'] - $coor['x']);
+ if($xdistance > WORLD_MAX) {
+ $xdistance = (2*WORLD_MAX+1) - $xdistance;
+ }
+ $ydistance = ABS($thiscoor['y'] - $coor['y']);
+ if($ydistance > WORLD_MAX) {
+ $ydistance = (2*WORLD_MAX+1) - $ydistance;
+ }
+ $distance = SQRT(POW($xdistance,2)+POW($ydistance,2));
+ if(!$mode) {
+ if($ref == 1) {
+ $speed = 16;
+ }
+ else if($ref == 2) {
+ $speed = 12;
+ }
+ else if($ref == 3) {
+ $speed = 24;
+ }
+ else if($ref == 300) {
+ $speed = 5;
+ }
+ else {
+ $speed = 1;
+ }
+ }
+ else {
+ $speed = $ref;
+ if($this->getsort_typeLevel(14,$resarray) != 0 && $distance >= TS_THRESHOLD) {
+ $speed = $speed * ($bid14[$this->getsort_typeLevel(14,$resarray)]['attri']/100) ;
+ }
+ }
+
+
+ if($speed!=0){
+ return round(($distance/$speed) * 3600 / INCREASE_SPEED);
+ }else{
+ return round($distance * 3600 / INCREASE_SPEED);
+ }
+
+ }
+
+ private function getsort_typeLevel($tid,$resarray) {
+
+
+ global $village;
+ $keyholder = array();
+ foreach(array_keys($resarray,$tid) as $key) {
+ if(strpos($key,'t')) {
+ $key = preg_replace("/[^0-9]/", '', $key);
+ array_push($keyholder, $key);
+ }
+ }
+ $element = count($keyholder);
+ if($element >= 2) {
+ if($tid <= 4) {
+ $temparray = array();
+ for($i=0;$i<=$element-1;$i++) {
+ array_push($temparray,$resarray['f'.$keyholder[$i]]);
+ }
+ foreach ($temparray as $key => $val) {
+ if ($val == max($temparray))
+ $target = $key;
+ }
+ }
+ else {
+ /*for($i=0;$i<=$element-1;$i++) {
+ //if($resarray['f'.$keyholder[$i]] != $this->getsort_typeMaxLevel($tid)) {
+ // $target = $i;
+ //}
+ }
+ */
+ }
+ }
+ else if($element == 1) {
+ $target = 0;
+ }
+ else {
+ return 0;
+ }
+ if($keyholder[$target] != "") {
+ return $resarray['f'.$keyholder[$target]];
+ }
+ else {
+ return 0;
+ }
+ }
+
+ private function celebrationComplete() {
+ if(file_exists("GameEngine/Prevention/celebration.txt")) {
+ unlink("GameEngine/Prevention/celebration.txt");
+ }
+ global $database;
+ $ourFileHandle = fopen("GameEngine/Prevention/celebration.txt", 'w');
+ fclose($ourFileHandle);
+
+ $varray = $database->getCel();
+ foreach($varray as $vil){
+ $id = $vil['wref'];
+ $type = $vil['type'];
+ $user = $vil['owner'];
+ if($type == 1){$cp = 500;}else if($type == 2){$cp = 2000;}
+ $database->clearCel($id);
+ $database->setCelCp($user,$cp);
+ }
+ if(file_exists("GameEngine/Prevention/celebration.txt")) {
+ unlink("GameEngine/Prevention/celebration.txt");
+ }
+ }
+
+ private function demolitionComplete() {
+ if(file_exists("GameEngine/Prevention/demolition.txt")) {
+ unlink("GameEngine/Prevention/demolition.txt");
+ }
+ global $building,$database;
+ $ourFileHandle = fopen("GameEngine/Prevention/demolition.txt", 'w');
+ fclose($ourFileHandle);
+
+ $varray = $database->getDemolition();
+ foreach($varray as $vil) {
+ if ($vil['timetofinish'] <= time()) {
+ $type = $database->getFieldType($vil['vref'],$vil['buildnumber']);
+ $level = $database->getFieldLevel($vil['vref'],$vil['buildnumber']);
+ $buildarray = $GLOBALS["bid".$type];
+ if ($type==10 || $type==38) {
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`=`maxstore`-".$buildarray[$level]['attri']." WHERE wref=".$vil['vref'];
+ $database->query($q);
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxstore`=800 WHERE `maxstore`<= 800 AND wref=".$vil['vref'];
+ $database->query($q);
+ }
+ if ($type==11 || $type==39) {
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`=`maxcrop`-".$buildarray[$level]['attri']." WHERE wref=".$vil['vref'];
+ $database->query($q);
+ $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`=800 WHERE `maxcrop`<=800 AND wref=".$vil['vref'];
+ $database->query($q);
+ }
+ if ($type==18){
+ $this->updateMax($database->getVillageField($vil['vref'],'owner'));
+ }
+ if ($level==1) { $clear=",f".$vil['buildnumber']."t=0"; } else { $clear=""; }
+ $q = "UPDATE ".TB_PREFIX."fdata SET f".$vil['buildnumber']."=".($level-1).$clear." WHERE vref=".$vil['vref'];
+ $database->query($q);
+ $pop=$this->getPop($type,$level-1);
+ $database->modifyPop($vil['vref'],$pop[0],1);
+ $this->procClimbers($database->getVillageField($vil['vref'],'owner'));
+ $database->delDemolition($vil['vref']);
+ }
+ }
+ if(file_exists("GameEngine/Prevention/demolition.txt")) {
+ unlink("GameEngine/Prevention/demolition.txt");
+ }
+ }
+
+ private function updateHero() {
+ if(file_exists("GameEngine/Prevention/updatehero.txt")) {
+ unlink("GameEngine/Prevention/updatehero.txt");
+ }
+ global $database,$hero_levels;
+ $harray = $database->getHero();
+ if(!empty($harray)){
+ foreach($harray as $hdata){
+ if((time()-$hdata['lastupdate'])>=1){
+ if($hdata['health']<100 and $hdata['health']>0){
+ $reg = $hdata['health']+$hdata['regeneration']*5*SPEED/86400*(time()-$hdata['lastupdate']);
+ if($reg <= 100){
+ $database->modifyHero("health",$reg,$hdata['heroid']);
+ }else{
+ $database->modifyHero("health",100,$hdata['heroid']);
+ }
+ $database->modifyHero("lastupdate",time(),$hdata['heroid']);
+ }
+ }
+ $herolevel = $hdata['level'];
+ for($i = $herolevel+1; $i < 100; $i++){
+ if($hdata['experience'] > $hero_levels[$i]){
+ mysql_query("UPDATE " . TB_PREFIX ."hero SET level = $i WHERE heroid = '".$hdata['heroid']."'");
+ if($i < 99){
+ mysql_query("UPDATE " . TB_PREFIX ."hero SET points = points + 5 WHERE heroid = '".$hdata['heroid']."'");
+ }
+ }
+ }
+ $villunits = $database->getUnit($hdata['wref']);
+ if($villunits['hero'] == 0 && $hdata['trainingtime'] < time() && $hdata['inrevive'] == 1){
+ mysql_query("UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".$hdata['wref']."");
+ mysql_query("UPDATE ".TB_PREFIX."hero SET `dead` = '0', `inrevive` = '0', `health` = '100', `lastupdate` = ".$hdata['trainingtime']." WHERE `uid` = '".$hdata['uid']."'");
+ }
+ if($villunits['hero'] == 0 && $hdata['trainingtime'] < time() && $hdata['intraining'] == 1){
+ mysql_query("UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".$hdata['wref']."");
+ mysql_query("UPDATE ".TB_PREFIX."hero SET `intraining` = '0', `lastupdate` = ".$hdata['trainingtime']." WHERE `uid` = '".$hdata['uid']."'");
+ }
+ }
+ }
+ if(file_exists("GameEngine/Prevention/updatehero.txt")) {
+ unlink("GameEngine/Prevention/updatehero.txt");
+ }
+
+
+}
+
+ // by SlimShady95, aka Manuel Mannhardt < manuel_mannhardt@web.de > UPDATED FROM songeriux < haroldas.snei@gmail.com >
+ private function updateStore() {
+ global $bid10, $bid38, $bid11, $bid39;
+
+ $result = mysql_query('SELECT * FROM `' . TB_PREFIX . 'fdata`');
+ while ($row = mysql_fetch_assoc($result))
+ {
+ $ress = $crop = 0;
+ for ($i = 19; $i < 40; ++$i)
+ {
+ if ($row['f' . $i . 't'] == 10)
+ {
+ $ress += $bid10[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
+ }
+
+ if ($row['f' . $i . 't'] == 38)
+ {
+ $ress += $bid38[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
+ }
+
+
+
+ if ($row['f' . $i . 't'] == 11)
+ {
+ $crop += $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
+ }
+
+ if ($row['f' . $i . 't'] == 39)
+ {
+ $crop += $bid39[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
+ }
+ }
+
+ if ($ress == 0)
+ {
+ $ress = 800 * STORAGE_MULTIPLIER;
+ }
+
+ if ($crop == 0)
+ {
+ $crop = 800 * STORAGE_MULTIPLIER;
+ }
+
+ mysql_query('UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . $ress . ', `maxcrop` = ' . $crop . ' WHERE `wref` = ' . $row['vref']) or die(mysql_error());
+ }
+ }
+
+ private function oasisResourcesProduce() {
+ global $database;
+ $time = time();
+ $q = "SELECT * FROM ".TB_PREFIX."odata WHERE wood < 800 OR clay < 800 OR iron < 800 OR crop < 800";
+ $array = $database->query_return($q);
+ foreach($array as $getoasis) {
+ $oasiswood = $getoasis['wood'] + (8*SPEED/3600)*(time()-$getoasis['lastupdated']);
+ $oasisclay = $getoasis['clay'] + (8*SPEED/3600)*(time()-$getoasis['lastupdated']);
+ $oasisiron = $getoasis['iron'] + (8*SPEED/3600)*(time()-$getoasis['lastupdated']);
+ $oasiscrop = $getoasis['crop'] + (8*SPEED/3600)*(time()-$getoasis['lastupdated']);
+ if($oasiswood > $getoasis['maxstore']){
+ $oasiswood = $getoasis['maxstore'];
+ }
+ if($oasisclay > $getoasis['maxstore']){
+ $oasisclay = $getoasis['maxstore'];
+ }
+ if($oasisiron > $getoasis['maxstore']){
+ $oasisiron = $getoasis['maxstore'];
+ }
+ if($oasiscrop > $getoasis['maxcrop']){
+ $oasiscrop = $getoasis['maxcrop'];
+ }
+ $q = "UPDATE " . TB_PREFIX . "odata set wood = $oasiswood, clay = $oasisclay, iron = $oasisiron, crop = $oasiscrop where wref = ".$getoasis['wref']."";
+ $database->query($q);
+ $database->updateOasis($getoasis['wref']);
+ }
+ }
+
+ private function checkInvitedPlayes() {
+ global $database;
+ $q = "SELECT * FROM ".TB_PREFIX."users WHERE invited != 0";
+ $array = $database->query_return($q);
+ foreach($array as $user) {
+ $numusers = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$user['invited']);
+ if(mysql_num_rows($numusers) > 0){
+ $varray = count($database->getProfileVillages($user['id']));
+ if($varray > 1){
+ $usergold = $database->getUserField($user['invited'],"gold",0);
+ $gold = $usergold+50;
+ $database->updateUserField($user['invited'],"gold",$gold,1);
+ $database->updateUserField($user['id'],"invited",0,1);
+ }
+ }
+ }
+ }
+
+ private function updateGeneralAttack() {
+ global $database;
+ $time = time();
+ $q = "SELECT * FROM ".TB_PREFIX."general WHERE shown = 1";
+ $array = $database->query_return($q);
+ foreach($array as $general) {
+ if(time() - (86400*8) > $general['time']){
+ mysql_query("UPDATE ".TB_PREFIX."general SET shown = 0 WHERE id = ".$general['id']."");
+ }
+ }
+ }
+
+ private function MasterBuilder() {
+ global $database;
+ $q = "SELECT * FROM ".TB_PREFIX."bdata WHERE master = 1";
+ $array = $database->query_return($q);
+ foreach($array as $master) {
+ $owner = $database->getVillageField($master['wid'],'owner');
+ $tribe = $database->getUserField($owner,'tribe',0);
+ $villwood = $database->getVillageField($master['wid'],'wood');
+ $villclay = $database->getVillageField($master['wid'],'clay');
+ $villiron = $database->getVillageField($master['wid'],'iron');
+ $villcrop = $database->getVillageField($master['wid'],'crop');
+ $type = $master['type'];
+ $level = $master['level'];
+ $buildarray = $GLOBALS["bid".$type];
+ $buildwood = $buildarray[$level]['wood'];
+ $buildclay = $buildarray[$level]['clay'];
+ $buildiron = $buildarray[$level]['iron'];
+ $buildcrop = $buildarray[$level]['crop'];
+ $ww = count($database->getBuildingByType($master['wid'],40));
+ if($tribe == 1){
+ if($master['field'] < 19){
+ $bdata = count($database->getDorf1Building($master['wid']));
+ $bbdata = count($database->getDorf2Building($master['wid']));
+ $bdata1 = $database->getDorf1Building($master['wid']);
+ }else{
+ $bdata = count($database->getDorf2Building($master['wid']));
+ $bbdata = count($database->getDorf1Building($master['wid']));
+ $bdata1 = $database->getDorf2Building($master['wid']);
+ }
+ }else{
+ $bdata = $bbdata = $bdata1 = count($database->getDorf1Building($master['wid'])) + count($database->getDorf2Building($master['wid']));
+ }
+ if($database->getUserField($owner,'plus',0) > time() or $ww > 0){
+ if($bbdata < 2){
+ $inbuild = 2;
+ }else{
+ $inbuild = 1;
+ }
+ }else{
+ $inbuild = 1;
+ }
+ $usergold = $database->getUserField($owner,'gold',0);
+ if($bdata < $inbuild && $buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop && $usergold > 0){
+ $time = $master['timestamp']+time();
+ if(!empty($bdata1)){
+ foreach($bdata1 as $master1) {
+ $time += ($master1['timestamp']-time());
+ }
+ }
+ if($bdata == 0){
+ $database->updateBuildingWithMaster($master['id'],$time,0);
+ }else{
+ $database->updateBuildingWithMaster($master['id'],$time,1);
+ }
+ $gold = $usergold-1;
+ $database->updateUserField($owner,'gold',$gold,1);
+ $database->modifyResource($master['wid'],$buildwood,$buildclay,$buildiron,$buildcrop,0);
+ }
+ }
+ }
+
+ private function starvation() {
+ if(file_exists("GameEngine/Prevention/starvation.txt")) {
+ unlink("GameEngine/Prevention/starvation.txt");
+ }
+ global $database;
+ $ourFileHandle = fopen("GameEngine/Prevention/starvation.txt", 'w');
+ fclose($ourFileHandle);
+ $starvupkeep = array(
+
+ '1'=>1,
+ '2'=>1,
+ '3'=>1,
+ '4'=>2,
+ '5'=>3,
+ '6'=>4,
+ '7'=>3,
+ '8'=>6,
+ '9'=>5,
+ '10'=>1,
+ '11'=>1,
+ '12'=>1,
+ '13'=>1,
+ '14'=>1,
+ '15'=>2,
+ '16'=>3,
+ '17'=>6,
+ '18'=>4,
+ '19'=>1,
+ '20'=>1,
+ '21'=>1,
+ '22'=>1,
+ '23'=>2,
+ '24'=>2,
+ '25'=>2,
+ '26'=>3,
+ '27'=>3,
+ '28'=>6,
+ '29'=>4,
+ '30'=>1,
+ '31'=>1,
+ '32'=>1,
+ '33'=>1,
+ '34'=>2,
+ '35'=>2,
+ '36'=>3,
+ '37'=>3,
+ '38'=>3,
+ '39'=>3,
+ '40'=>5,
+ '41'=>1,
+ '42'=>1,
+ '43'=>1,
+ '44'=>1,
+ '45'=>2,
+ '46'=>3,
+ '47'=>6,
+ '48'=>5,
+ '49'=>1,
+ '50'=>1,
+ 'hero'=>6
+ );
+
+ $time = time();
+
+ // load villages with minus prod
+ $starvarray = array();
+ $starvarray = $database->getStarvation();
+ foreach ($starvarray as $starv){
+ $unitarrays = $this->getAllUnits($starv['wref']);
+ $upkeep = $starv['pop'] + $this->getUpkeep($unitarrays, 0);
+ if (($starv['starvupdate']+600) < $time){
+ // get enforce
+ $enforcearray = $database->getEnforceVillage($starv['wref'],0);
+ $maxcount = 0;
+ if(count($enforcearray)==0){
+ // get units
+ $unitarray = $database->getUnit($starv['wref']);
+ for($i = 0 ; $i <= 50 ; $i++){
+ $units = $unitarray['u'.$i];
+ if($unitarray['u'.$i] > $maxcount){
+ $maxcount = $unitarray['u'.$i];
+ $maxtype = $i;
+ }
+ $totalunits += $unitarray['u'.$i];
+ }
+ if($totalunits == 0){
+ $maxcount = $unitarray['hero'];
+ $maxtype = "hero";
+ }
+ }else{
+ foreach ($enforcearray as $enforce){
+ for($i = 0 ; $i <= 50 ; $i++){
+ $units = $enforce['u'.$i];
+ if($enforce['u'.$i] > $maxcount){
+ $maxcount = $enforce['u'.$i];
+ $maxtype = $i;
+ $enf = $enforce['id'];
+ }
+ $totalunits += $enforce['u'.$i];
+ }
+ if($totalunits == 0){
+ $maxcount = $enforce['hero'];
+ $maxtype = "hero";
+ }
+ }
+ }
+
+ // counting
+
+ $timedif = $time-$starv['starvupdate'];
+
+ $starvsec = ($starv['starv']/3600);
+
+ $difcrop = ($timedif*$starvsec);
+ $newcrop = 0;
+ $oldcrop = $database->getVillageField($starv['wref'], 'crop');
+ if ($oldcrop > 100){
+ $difcrop = $difcrop-$oldcrop;
+ if($difcrop < 0){
+ $difcrop = 0;
+ $newcrop = $oldcrop-$difcrop;
+ $database->setVillageField($starv['wref'], 'crop', $newcrop);
+ }
+ }
+ if($difcrop > 0){
+ $killunits = floor($difcrop/18000);
+ if($killunits > 0){
+ if (isset($enf)){
+ if($killunits < $maxcount){
+ $database->modifyEnforce($enf, $maxtype, $killunits, 0);
+ $database->setVillageField($starv['wref'], 'starv', $upkeep);
+ $database->setVillageField($starv['wref'], 'starvupdate', $time);
+ }else{
+ $database->deleteReinf($enf);
+ $database->setVillageField($starv['wref'], 'starv', $upkeep);
+ $database->setVillageField($starv['wref'], 'starvupdate', $time);
+ }
+ }else{
+ if($killunits < $maxcount){
+ $database->modifyUnit($starv['wref'], array($maxtype), array($killunits), array(0));
+ $database->setVillageField($starv['wref'], 'starv', $upkeep);
+ $database->setVillageField($starv['wref'], 'starvupdate', $time);
+ }elseif($killunits > $maxcount){
+ $killunits = $maxcount;
+ $database->modifyUnit($starv['wref'], array($maxtype), array($killunits), array(0));
+ $database->setVillageField($starv['wref'], 'starv', $upkeep);
+ $database->setVillageField($starv['wref'], 'starvupdate', $time);
+ }
+ }
+ }
+ }
+ }
+ $crop = $database->getCropProdstarv($starv['wref']);
+ if ($crop > $upkeep){
+ $database->setVillageField($starv['wref'], 'starv', 0);
+ $database->setVillageField($starv['wref'], 'starvupdate', 0);
+ }
+
+ unset ($starv,$unitarrays,$enforcearray,$enforce,$starvarray);
+ }
+
+ if(file_exists("GameEngine/Prevention/starvation.txt")) {
+ unlink("GameEngine/Prevention/starvation.txt");
+ }
+ }
+
+ private function procNewClimbers() {
+ if(file_exists("GameEngine/Prevention/climbers.txt")) {
+ unlink("GameEngine/Prevention/climbers.txt");
+ }
+ global $database, $ranking;
+ $ranking->procRankArray();
+ $climbers = $ranking->getRank();
+ if(count($ranking->getRank()) > 0){
+ $q = "SELECT * FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1";
+ $result = mysql_query($q);
+ if(mysql_num_rows($result)) {
+ $row=mysql_fetch_assoc($result);
+ $week=($row['week']+1);
+ } else {
+ $week='1';
+ }
+ $q = "SELECT * FROM ".TB_PREFIX."users where oldrank = 0 and id > 5";
+ $array = $database->query_return($q);
+ foreach($array as $user){
+ $newrank = $ranking->getUserRank($user['id']);
+ if($week > 1){
+ for($i=$newrank+1;$i
getRank());$i++) {
+ $oldrank = $ranking->getUserRank($climbers[$i]['userid']);
+ $totalpoints = $oldrank - $climbers[$i]['oldrank'];
+ $database->removeclimberrankpop($climbers[$i]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$i]['userid'], $oldrank);
+ }
+ $database->updateoldrank($user['id'], $newrank);
+ }else{
+ $totalpoints = count($ranking->getRank()) - $newrank;
+ $database->setclimberrankpop($user['id'], $totalpoints);
+ $database->updateoldrank($user['id'], $newrank);
+ for($i=1;$i<$newrank;$i++){
+ $oldrank = $ranking->getUserRank($climbers[$i]['userid']);
+ $totalpoints = count($ranking->getRank()) - $oldrank;
+ $database->setclimberrankpop($climbers[$i]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$i]['userid'], $oldrank);
+ }
+ for($i=$newrank+1;$igetRank());$i++){
+ $oldrank = $ranking->getUserRank($climbers[$i]['userid']);
+ $totalpoints = count($ranking->getRank()) - $oldrank;
+ $database->setclimberrankpop($climbers[$i]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$i]['userid'], $oldrank);
+ }
+ }
+ }
+ }
+ if(file_exists("GameEngine/Prevention/climbers.txt")) {
+ unlink("GameEngine/Prevention/climbers.txt");
+ }
+ }
+
+ private function procClimbers($uid) {
+ global $database, $ranking;
+ $ranking->procRankArray();
+ $climbers = $ranking->getRank();
+ if(count($ranking->getRank()) > 0){
+ $q = "SELECT * FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1";
+ $result = mysql_query($q);
+ if(mysql_num_rows($result)) {
+ $row=mysql_fetch_assoc($result);
+ $week=($row['week']+1);
+ } else {
+ $week='1';
+ }
+ $myrank = $ranking->getUserRank($uid);
+ if($climbers[$myrank]['oldrank'] > $myrank){
+ for($i=$myrank+1;$i<=$climbers[$myrank]['oldrank'];$i++) {
+ $oldrank = $ranking->getUserRank($climbers[$i]['userid']);
+ if($week > 1){
+ $totalpoints = $oldrank - $climbers[$i]['oldrank'];
+ $database->removeclimberrankpop($climbers[$i]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$i]['userid'], $oldrank);
+ }else{
+ $totalpoints = count($ranking->getRank()) - $oldrank;
+ $database->setclimberrankpop($climbers[$i]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$i]['userid'], $oldrank);
+ }
+ }
+ if($week > 1){
+ $totalpoints = $climbers[$myrank]['oldrank'] - $myrank;
+ $database->addclimberrankpop($climbers[$myrank]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$myrank]['userid'], $myrank);
+ }else{
+ $totalpoints = count($ranking->getRank()) - $myrank;
+ $database->setclimberrankpop($climbers[$myrank]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$myrank]['userid'], $myrank);
+ }
+ }else if($climbers[$myrank]['oldrank'] < $myrank){
+ for($i=$climbers[$myrank]['oldrank'];$i<$myrank;$i++) {
+ $oldrank = $ranking->getUserRank($climbers[$i]['userid']);
+ if($week > 1){
+ $totalpoints = $climbers[$i]['oldrank'] - $oldrank;
+ $database->addclimberrankpop($climbers[$i]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$i]['userid'], $oldrank);
+ }else{
+ $totalpoints = count($ranking->getRank()) - $oldrank;
+ $database->setclimberrankpop($climbers[$i]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$i]['userid'], $oldrank);
+ }
+ }
+ if($week > 1){
+ $totalpoints = $myrank - $climbers[$myrank-1]['oldrank'];
+ $database->removeclimberrankpop($climbers[$myrank-1]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$myrank-1]['userid'], $myrank);
+ }else{
+ $totalpoints = count($ranking->getRank()) - $myrank;
+ $database->setclimberrankpop($climbers[$myrank-1]['userid'], $totalpoints);
+ $database->updateoldrank($climbers[$myrank-1]['userid'], $myrank);
+ }
+ }
+ }
+ $ranking->procARankArray();
+ $aid = $database->getUserField($uid,"alliance",0);
+ if(count($ranking->getRank()) > 0 && $aid != 0){
+ $ally = $database->getAlliance($aid);
+ $memberlist = $database->getAllMember($ally['id']);
+ $oldrank = 0;
+ foreach($memberlist as $member) {
+ $oldrank += $database->getVSumField($member['id'],"pop");
+ }
+ if($ally['oldrank'] != $oldrank){
+ if($ally['oldrank'] < $oldrank) {
+ $totalpoints = $oldrank - $ally['oldrank'];
+ $database->addclimberrankpopAlly($ally['id'], $totalpoints);
+ $database->updateoldrankAlly($ally['id'], $oldrank);
+ } else
+ if($ally['oldrank'] > $oldrank) {
+ $totalpoints = $ally['oldrank'] - $oldrank;
+ $database->removeclimberrankpopAlly($ally['id'], $totalpoints);
+ $database->updateoldrankAlly($ally['id'], $oldrank);
+ }
+ }
+ }
+ }
+
+ private function checkBan() {
+ global $database;
+ $time = time();
+ $q = "SELECT * FROM ".TB_PREFIX."banlist WHERE active = 1 and end < $time";
+ $array = $database->query_return($q);
+ foreach($array as $banlist) {
+ mysql_query("UPDATE ".TB_PREFIX."banlist SET active = 0 WHERE id = ".$banlist['id']."");
+ mysql_query("UPDATE ".TB_PREFIX."users SET access = 2 WHERE id = ".$banlist['uid']."");
+ }
+ }
+
+ private function regenerateOasisTroops() {
+ global $database;
+ $time = time();
+ $q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = 0 and $time - lastupdated > 3600";
+ $array = $database->query_return($q);
+ foreach($array as $oasis) {
+ $database->populateOasisUnits($oasis['wref'],$oasis['high']);
+ $database->updateOasis($oasis['wref']);
+ }
+ }
+
+ private function updateMax($leader) {
+ global $bid18, $database;
+ $q = mysql_query("SELECT * FROM " . TB_PREFIX . "alidata where leader = $leader");
+ if(mysql_num_rows($q) > 0){
+ $villages = $database->getVillagesID2($leader);
+ $max = 0;
+ foreach($villages as $village){
+ $field = $database->getResourceLevel($village['wref']);
+ for($i=19;$i<=40;$i++){
+ if($field['f'.$i.'t'] == 18){
+ $level = $field['f'.$i];
+ $attri = $bid18[$level]['attri'];
+ }
+ }
+ if($attri > $max){
+ $max = $attri;
+ }
+ }
+ $q = "UPDATE ".TB_PREFIX."alidata set max = $max where leader = $leader";
+ $database->query($q);
+ }
+ }
+
+ private function artefactOfTheFool() {
+ global $database;
+ $time = time();
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts where type = 8 and active = 1 and $time - lastupdate >= 86400";
+ $array = $database->query_return($q);
+ foreach($array as $artefact) {
+ $kind = rand(1,7);
+ while($kind == 6){
+ $kind = rand(1,7);
+ }
+ if($artefact['size'] != 3){
+ $bad_effect = rand(0,1);
+ }else{
+ $bad_effect = 0;
+ }
+ switch($kind) {
+ case 1:
+ $effect = rand(1,5);
+ break;
+ case 2:
+ $effect = rand(1,3);
+ break;
+ case 3:
+ $effect = rand(3,10);
+ break;
+ case 4:
+ $effect = rand(2,4);
+ break;
+ case 5:
+ $effect = rand(2,4);
+ break;
+ case 7:
+ $effect = rand(1,6);
+ break;
+ }
+ mysql_query("UPDATE ".TB_PREFIX."artefacts SET kind = $kind, bad_effect = $bad_effect, effect2 = $effect, lastupdate = $time WHERE id = ".$artefact['id']."");
+ }
+ }
+}
+$automation = new Automation;
+?>
diff --git a/GameEngine/BBCode.php b/GameEngine/BBCode.php
new file mode 100644
index 00000000..7aefab45
--- /dev/null
+++ b/GameEngine/BBCode.php
@@ -0,0 +1 @@
+$1";
$replace[1] = "$1";
$replace[2] = "$1";
$replace[3] = "
";
$replace[4] = "
";
$replace[5] = "
";
$replace[6] = "
";
$replace[7] = "
";
$replace[8] = "
";
$replace[9] = "
";
$replace[10] = "
";
$replace[11] = "
";
$replace[12] = "
";
$replace[13] = "
";
$replace[14] = "
";
$replace[15] = "
";
$replace[16] = "
";
$replace[17] = "
";
$replace[18] = "
";
$replace[19] = "
";
$replace[20] = "
";
$replace[21] = "
";
$replace[22] = "
";
$replace[23] = "
";
$replace[24] = "
";
$replace[25] = "
";
$replace[26] = "
";
$replace[27] = "
";
$replace[28] = "
";
$replace[29] = "
";
$replace[30] = "
";
$replace[31] = "
";
$replace[32] = "
";
$replace[33] = "
";
$replace[34] = "
";
$replace[35] = "
";
$replace[36] = "
";
$replace[37] = "
";
$replace[38] = "
";
$replace[39] = "
";
$replace[40] = "
";
$replace[41] = "
";
$replace[42] = "
";
$replace[43] = "
";
$replace[44] = "
";
$replace[45] = "
";
$replace[46] = "
";
$replace[47] = "
";
$replace[48] = "
";
$replace[49] = "
";
$replace[50] = "
";
$replace[51] = "
";
$replace[52] = "
";
$replace[53] = "
";
$replace[54] = "
";
$replace[55] = "
";
$replace[56] = "
";
$replace[57] = "
";
$replace[54] = "
";
$replace[55] = "
";
$replace[56] = "
";
$replace[57] = "
";
$replace[58] = "
";
$replace[59] = "
";
$replace[60] = "
";
$replace[61] = "
";
$replace[62] = "
";
$replace[63] = "
";
$replace[64] = "
";
$replace[65] = "
";
$replace[66] = "
";
$replace[67] = "
";
$replace[68] = "
";
$replace[69] = "
";
$replace[70] = "
";
$replace[71] = "
";
$replace[72] = "
";
$replace[73] = "
";
$replace[74] = "
";
$replace[75] = "
";
$replace[76] = "";
$replace[77] = "
";
$replace[78] = "
";
$replace[79] = "
";
$replace[80] = "
";
$replace[81] = "
";
$replace[82] = "
";
$replace[83] = "
";
$replace[84] = "
";
$replace[85] = "
";
$replace[86] = "
";
$replace[87] = "
";
$replace[88] = "
";
for($i=0;$i<=$alliance;$i++){
$pattern[89+$i] = "/\[alliance".$i."\](.*?)\[\/alliance".$i."\]/is";
${'bbcoded1_'.$i} = preg_replace($pattern[89+$i], "$1", $input);
${'bbcoded1_'.$i} = preg_replace('/\[\/alliance'.$i.'\](.*?)\[\/message\]/is', '', $input);
${'bbcoded1_'.$i} = preg_replace('/\[message\](.*?)\[alliance'.$i.'\]/is', '', ${'bbcoded1_'.$i});
$aname = $database->getAllianceID(${'bbcoded1_'.$i});
if($aname != ""){
$replace[89+$i] = "$1";
}else{
$replace[89+$i] = "alliance not exist";
}
$rep1 = 90+$i;
}
for($i=0;$i<=$player;$i++){
$pattern[$rep1+$i] = "/\[player".$i."\](.*?)\[\/player".$i."\]/is";
${'bbcoded2_'.$i} = preg_replace($pattern[$rep1+$i], "$1", $input);
${'bbcoded2_'.$i} = preg_replace('/\[\/player'.$i.'\](.*?)\[\/message\]/is', '', $input);
${'bbcoded2_'.$i} = preg_replace('/\[message\](.*?)\[player'.$i.'\]/is', '', ${'bbcoded2_'.$i});
$uname = $database->getUserField(${'bbcoded2_'.$i}, "id", 1);
if($uname != ""){
$replace[$rep1+$i] = "$1";
}else{
$replace[$rep1+$i] = "player not exist";
}
$rep2 = $rep1+$i+1;
}
for($i=0;$i<=$report;$i++){
$pattern[$rep2+$i] = "/\[report".$i."\](.*?)\[\/report".$i."\]/is";
${'bbcoded3_'.$i} = preg_replace($pattern[$rep2+$i], "$1", $input);
${'bbcoded3_'.$i} = preg_replace('/\[\/report'.$i.'\](.*?)\[\/message\]/is', '', $input);
${'bbcoded3_'.$i} = preg_replace('/\[message\](.*?)\[report'.$i.'\]/is', '', ${'bbcoded3_'.$i});
$report = count($database->getNotice4(${'bbcoded3_'.$i}));
if($report > 0){
$topic = $database->getNotice2(${'bbcoded3_'.$i},"topic");
$ally = $database->getNotice2(${'bbcoded3_'.$i},"ally");
$replace[$rep2+$i] = "$topic";
}else{
$replace[$rep2+$i] = "report not exist";
}
$rep3 = $rep2+$i+1;
}
for($i=0;$i<=$coor;$i++){
$pattern[$rep3+$i] = "/\[coor".$i."\](.*?)\[\/coor".$i."\]/is";
${'bbcoded4_'.$i} = preg_replace($pattern[$rep3+$i], "$1", $input);
${'bbcoded4_'.$i} = preg_replace('/\[\/coor'.$i.'\](.*?)\[\/message\]/is', '', $input);
${'bbcoded4_'.$i} = preg_replace('/\[message\](.*?)\[coor'.$i.'\]/is', '', ${'bbcoded4_'.$i});
for($x = 0; $x < 401; $x++) {
if(preg_match('/^'.$x.'/', ${'bbcoded4_'.$i})){
$xx = 1;
$cx = $x;
}
}
for($x = 0; $x > -401; $x--) {
if(preg_match('/^'.$x.'/', ${'bbcoded4_'.$i})){
$xx = 1;
$cx = $x;
}
}
for($y = 0; $y < 401; $y++) {
if(preg_match('/-'.$y.'$/', ${'bbcoded4_'.$i})){
$yy = 1;
$cy = $y*(-1);
}else if(preg_match('/'.$y.'$/', ${'bbcoded4_'.$i})){
$yy = 1;
$cy = $y;
}
}
if(preg_match('/|/', ${'bbcoded4_'.$i}) && $xx == 1 && $yy == 1){
$wref = $database->getVilWref($cx,$cy);
$cwref = $generator->getMapCheck($wref);
if($wref != ""){
$wref1 = $database->getVillageType3($wref);
if($wref1['oasistype'] == 0 && $wref1['occupied'] == 1){
$vname = $database->getVillageField($wref,"name");
}else if($wref1['oasistype'] == 0 && $wref1['occupied'] == 0){
$vname = "Abandoned valley";
}else if($wref1['oasistype'] != 0 && $wref1['occupied'] == 1){
$vname = "Occupied Oasis";
}else if($wref1['oasistype'] != 0 && $wref1['occupied'] == 0){
$vname = "Unoccupied Oasis";
}
$replace[$rep3+$i] = "$vname($cx|$cy)";
}
}
}
$input = preg_replace('/\[message\]/', '', $input);
$input = preg_replace('/\[\/message\]/', '', $input);
$bbcoded = preg_replace($pattern, $replace, $input);
?>
\ No newline at end of file
diff --git a/GameEngine/Battle.php b/GameEngine/Battle.php
new file mode 100644
index 00000000..1c94af01
--- /dev/null
+++ b/GameEngine/Battle.php
@@ -0,0 +1,1082 @@
+ 0) {
+ if($post['palast'] == "") {
+ $post['palast'] = 0;
+ }
+ if(isset($post['wall1']) && $post['wall1'] == "") {
+ $post['wall1'] = 0;
+ }
+ if(isset($post['wall2']) && $post['wall2'] == "") {
+ $post['wall2'] = 0;
+ }
+ if(isset($post['wall3']) && $post['wall3'] == "") {
+ $post['wall3'] = 0;
+ }if(isset($post['wall4']) && $post['wall4'] == "") {
+ $post['wall4'] = 0;
+ }if(isset($post['wall5']) && $post['wall5'] == "") {
+ $post['wall5'] = 0;
+ }
+ $post['tribe'] = $target[0];
+ $_POST['result'] = $this->simulate($post);
+ $form->valuearray = $post;
+ }
+ }
+ }
+ }
+ private function getBattleHero($uid) {
+ global $database;
+ $heroarray = $database->getHero($uid);
+ $herodata = $GLOBALS["h".$heroarray[0]['unit']];
+
+ $h_atk = $herodata['atk'] + 5 * floor($heroarray[0]['attack'] * $herodata['atkp'] / 5);
+ $h_di = $herodata['di'] + 5 * floor($heroarray[0]['defence'] * $herodata['dip'] / 5);
+ $h_dc = $herodata['dc'] + 5 * floor($heroarray[0]['defence'] * $herodata['dcp'] / 5);
+ $h_ob = 1 + 0.002 * $heroarray[0]['attackbonus'];
+ $h_db = 1 + 0.002 * $heroarray[0]['defencebonus'];
+
+ return array('heroid'=>$heroarray[0]['heroid'],'unit'=>$heroarray[0]['unit'],'atk'=>$h_atk,'di'=>$h_di,'dc'=>$h_dc,'ob'=>$h_ob,'db'=>$h_db,'health'=>$heroarray['health']);
+ }
+
+ private function simulate($post) {
+ // Establecemos los arrays con las unidades del atacante y defensor
+ $attacker = array('u1'=>0,'u2'=>0,'u3'=>0,'u4'=>0,'u5'=>0,'u6'=>0,'u7'=>0,'u8'=>0,'u9'=>0,'u10'=>0,'u11'=>0,'u12'=>0,'u13'=>0,'u14'=>0,'u15'=>0,'u16'=>0,'u17'=>0,'u18'=>0,'u19'=>0,'u20'=>0,'u21'=>0,'u22'=>0,'u23'=>0,'u24'=>0,'u25'=>0,'u26'=>0,'u27'=>0,'u28'=>0,'u29'=>0,'u30'=>0,'u31'=>0,'u32'=>0,'u33'=>0,'u34'=>0,'u35'=>0,'u36'=>0,'u37'=>0,'u38'=>0,'u39'=>0,'u40'=>0,'u41'=>0,'u42'=>0,'u43'=>0,'u44'=>0,'u45'=>0,'u46'=>0,'u47'=>0,'u48'=>0,'u49'=>0,'u50'=>0);
+ $start = ($post['a1_v']-1)*10+1;
+ $index = 1;
+ for($i=$start;$i<=($start+9);$i++) {
+ $attacker['u'.$i] = $post['a1_'.$index];
+ if($index <=8) {
+ ${att_ab.$index} = $post['f1_'.$index];
+ }
+ $index += 1;
+ }
+ $defender = array();
+ for($i=1;$i<=50;$i++) {
+ if(isset($post['a2_'.$i]) && $post['a2_'.$i] != "") {
+ $defender['u'.$i] = $post['a2_'.$i];
+ }
+ else {
+ $defender['u'.$i] = 0;
+ }
+ }
+ $deftribe = $post['tribe'];
+ $wall = 0;
+ switch($deftribe) {
+ case 1:
+ for($i=1;$i<=8;$i++) {
+ ${def_ab.$i} = $post['f2_'.$i];
+ }
+ break;
+ case 2:
+ for($i=11;$i<=18;$i++) {
+ ${def_ab.$i-10} = $post['f2_'.$i];
+ }
+ break;
+ case 3:
+ for($i=21;$i<=28;$i++) {
+ ${def_ab.$i-20} = $post['f2_'.$i];
+ }
+ break;
+ case 4:
+ for($i=31;$i<=38;$i++) {
+ ${def_ab.$i-30} = $post['f2_'.$i];
+ }
+ break;
+ case 5:
+ for($i=41;$i<=48;$i++) {
+ ${def_ab.$i-40} = $post['f2_'.$i];
+ }
+ break;
+ }
+ if($post['kata'] == "") {
+ $post['kata'] = 0;
+ }
+
+ // check scout
+
+ $scout = 1;
+ for($i=$start;$i<=($start+9);$i++) {
+ if($i == 4 || $i == 14 || $i == 23 || $i == 44)
+ {}
+ else{
+ if($attacker['u'.$i]>0) {
+ $scout = 0;
+ break;
+ }
+ }
+ }
+ if($post['wall1'] != 0){
+ $walllevel = $post['wall1'];
+ }elseif($post['wall2'] != 0){
+ $walllevel = $post['wall2'];
+ }elseif($post['wall3'] != 0){
+ $walllevel = $post['wall3'];
+ }elseif($post['wall4'] != 0){
+ $walllevel = $post['wall4'];
+ }elseif($post['wall5'] != 0){
+ $walllevel = $post['wall5'];
+ }else{
+ $walllevel = 0;
+ }
+ if($walllevel > 20){
+ $walllevel = 0;
+ }
+ $wall = $walllevel;
+ if(!$scout)
+ return $this->calculateBattle($attacker,$defender,$wall,$post['a1_v'],$deftribe,$post['palast'],$post['ew1'],$post['ew2'],$post['ktyp']+3,$def_ab1,$def_ab2,$def_ab3,$def_ab4,$def_ab5,$def_ab6,$def_ab7,$def_ab8,$att_ab1,$att_ab2,$att_ab3,$att_ab4,$att_ab5,$att_ab6,$att_ab7,$att_ab8,$post['kata'],$post['stonemason'],$walllevel,0,0,0,0);
+ else
+ return $this->calculateBattle($attacker,$defender,$wall,$post['a1_v'],$deftribe,$post['palast'],$post['ew1'],$post['ew2'],1,$def_ab1,$def_ab2,$def_ab3,$def_ab4,$def_ab5,$def_ab6,$def_ab7,$def_ab8,$att_ab1,$att_ab2,$att_ab3,$att_ab4,$att_ab5,$att_ab6,$att_ab7,$att_ab8,$post['kata'],$post['stonemason'],$walllevel,0,0,0,0);
+ }
+
+ public function getTypeLevel($tid,$vid) {
+ global $village,$database;
+ $keyholder = array();
+
+ $resourcearray = $database->getResourceLevel($vid);
+
+ foreach(array_keys($resourcearray,$tid) as $key) {
+ if(strpos($key,'t')) {
+ $key = preg_replace("/[^0-9]/", '', $key);
+ array_push($keyholder, $key);
+ }
+ }
+ $element = count($keyholder);
+ if($element >= 2) {
+ if($tid <= 4) {
+ $temparray = array();
+ for($i=0;$i<=$element-1;$i++) {
+ array_push($temparray,$resourcearray['f'.$keyholder[$i]]);
+ }
+ foreach ($temparray as $key => $val) {
+ if ($val == max($temparray))
+ $target = $key;
+ }
+ }
+ else {
+ $target = 0;
+ for($i=1;$i<=$element-1;$i++) {
+ if($resourcearray['f'.$keyholder[$i]] > $resourcearray['f'.$keyholder[$target]]) {
+ $target = $i;
+ }
+ }
+ }
+ }
+ else if($element == 1) {
+ $target = 0;
+ }
+ else {
+ return 0;
+ }
+ if($keyholder[$target] != "") {
+ return $resourcearray['f'.$keyholder[$target]];
+ }
+ else {
+ return 0;
+ }
+ }
+
+ //1 raid 0 normal
+ function calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab1,$def_ab2,$def_ab3,$def_ab4,$def_ab5,$def_ab6,$def_ab7,$def_ab8,$att_ab1,$att_ab2,$att_ab3,$att_ab4,$att_ab5,$att_ab6,$att_ab7,$att_ab8,$tblevel,$stonemason,$walllevel,$AttackerID,$DefenderID,$AttackerWref,$DefenderWref) {
+ global $bid34,$bid35,$database;
+ // Definieer de array met de eenheden
+ $calvary = array(4,5,6,15,16,23,24,25,26,45,46);
+ $catapult = array(8,18,28,48);
+ $rams = array(7,17,27,47);
+ $catp = $ram = 0;
+ // Array om terug te keren met het resultaat van de berekening
+ $result = array();
+ $involve = 0;
+ $winner = false;
+ // bij 0 alle deelresultaten
+ $cap = $ap = $dp = $cdp = $rap = $rdp = 0;
+
+ //exit($type);
+ $att_artefact = count($database->getOwnUniqueArtefactInfo2($AttackerID,3,3,0));
+ $att_artefact1 = count($database->getOwnUniqueArtefactInfo2($AttackerWref,3,1,1));
+ $att_artefact2 = count($database->getOwnUniqueArtefactInfo2($AttackerID,3,2,0));
+ if($att_artefact > 0){
+ $attacker_artefact = 10;
+ }else if($att_artefact1 > 0){
+ $attacker_artefact = 5;
+ }else if($att_artefact2 > 0){
+ $attacker_artefact = 3;
+ }else{
+ $attacker_artefact = 1;
+ }
+ $def_artefact = count($database->getOwnUniqueArtefactInfo2($DefenderID,3,3,0));
+ $def_artefact1 = count($database->getOwnUniqueArtefactInfo2($DefenderWref,3,1,1));
+ $def_artefact2 = count($database->getOwnUniqueArtefactInfo2($DefenderID,3,2,0));
+ if($def_artefact > 0){
+ $defender_artefact = 10;
+ }else if($att_artefact1 > 0){
+ $defender_artefact = 5;
+ }else if($def_artefact2 > 0){
+ $defender_artefact = 3;
+ }else{
+ $defender_artefact = 1;
+ }
+ if($Attacker['uhero'] != 0)
+ {
+ //exit($AttackerID);
+ $atkhero = $this->getBattleHero($AttackerID);
+ }
+
+ if($Defender['hero'] != 0)
+ {
+ //exit($DefenderID);
+ $defenderhero = $this->getBattleHero($DefenderID);
+ }
+
+ $DefendersAll = $database->getEnforceVillage($DefenderWref,0);
+ if(!empty($DefendersAll)){
+ foreach($DefendersAll as $defenders) {
+ $fromvillage = $defenders['from'];
+ $reinfowner = $database->getVillageField($fromvillage,"owner");
+ $defhero[$fromvillage] = $this->getBattleHero($reinfowner);
+ }
+ }
+ // Berekenen het totaal aantal punten van Aanvaller
+ $start = ($att_tribe-1)*10+1;
+ $end = ($att_tribe*10);
+ if($att_tribe == 3){
+ $abcount = 3;
+ }else{
+ $abcount = 4;
+ }
+
+ if($type == 1)
+ {
+ for($i=$start;$i<=$end;$i++) {
+ global ${'u'.$i};
+ $j = $i-$start+1;
+ if($abcount <= 8 && ${att_ab.$abcount} > 0) {
+
+ $ap += (35 + ( 35 + 300 * ${'u'.$i}['pop'] / 7) * (pow(1.007, ${att_ab.$abcount}) - 1)) * $Attacker['u'.$i] * $attacker_artefact;
+ $att_foolartefact = $database->getFoolArtefactInfo(3,$AttackerWref,$AttackerID);
+ if(count($att_foolartefact) > 0){
+ foreach($att_foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $ap *= $arte['effect2'];
+ }else{
+ $ap /= $arte['effect2'];
+ $ap = round($ap);
+ }
+ }
+ }
+ }
+ else {
+ $ap += ($Attacker['u'.$i] * $Attacker['u'.$i] * $Attacker['u'.$i])/3;
+ }
+
+
+ $units['Att_unit'][$i] = $Attacker['u'.$i];
+ }
+ if ($Attacker['uhero'] != 0){
+ $ap += $atkhero['atk'] * 35;
+ $ap = $ap * $atkhero['ob'];
+ }
+ }
+ else
+ {
+ $abcount = 1;
+ for($i=$start;$i<=$end;$i++) {
+ global ${'u'.$i};
+ $j = $i-$start+1;
+ if($abcount <= 8 && ${att_ab.$abcount} > 0) {
+ if(in_array($i,$calvary)) {
+ $cap += (${'u'.$i}['atk'] + (${'u'.$i}['atk'] + 300 * ${'u'.$i}['pop'] / 7) * (pow(1.007, ${att_ab.$abcount}) - 1)) * $Attacker['u'.$i];
+ }
+ else {
+ $ap += (${'u'.$i}['atk'] + (${'u'.$i}['atk'] + 300 * ${'u'.$i}['pop'] / 7) * (pow(1.007, ${att_ab.$abcount}) - 1)) * $Attacker['u'.$i];
+ }
+ }
+ else {
+ if(in_array($i,$calvary)) {
+ $cap += $Attacker['u'.$i]*${'u'.$i}['atk'];
+ }
+ else {
+ $ap += $Attacker['u'.$i]*${'u'.$i}['atk'];
+ }
+ }
+
+
+ $abcount +=1;
+ // Punten van de catavult van de aanvaller
+ if(in_array($i,$catapult)) {
+ $catp += $Attacker['u'.$i];
+ }
+ // Punten van de Rammen van de aanvaller
+ if(in_array($i,$rams))
+ {
+ $ram += $Attacker['u'.$i];
+ }
+ $involve += $Attacker['u'.$i];
+ $units['Att_unit'][$i] = $Attacker['u'.$i];
+ }
+
+ if ($Attacker['uhero'] != 0)
+ {
+ $units['Att_unit']['hero'] = $Attacker['uhero'];
+ $cap += $Attacker['uhero']*$atkhero['atk'];
+ $ap += $Attacker['uhero']*$atkhero['atk'];
+ $ap = $ap * $atkhero['ob'];
+ $cap = $cap * $atkhero['ob'];
+ }
+
+ }
+
+ //
+ // Berekent het totaal aantal punten van de Defender
+ //
+ $start = ($def_tribe-1)*10+1;
+ $end = ($def_tribe*10);
+
+ $abcount = 1;
+
+ if($type == 1)
+ {
+ for($y=4;$y<=44;$y++) {
+ if($y == 4 || $y == 14 || $y == 23 || $y == 44)
+ {
+ global ${'u'.$y};
+ if($y >= $start && $y <= ($end-2) && ${def_ab.$abcount} > 0) {
+ $dp += (20 + (20 + 300 * ${'u'.$y}['pop'] / 7) * (pow(1.007, ${def_ab.$abcount}) - 1)) * (($Defender['u'.$y]*$Defender['u'.$y]*$Defender['u'.$y])/4) * $defender_artefact;
+ $abcount +=1;
+ $def_foolartefact = $database->getFoolArtefactInfo(3,$AttackerWref,$AttackerID);
+ if(count($def_foolartefact) > 0){
+ foreach($def_foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $dp *= $arte['effect2'];
+ }else{
+ $dp /= $arte['effect2'];
+ $dp = round($dp);
+ }
+ }
+ }
+ }
+ else {
+ $dp += ($Defender['u'.$y]*$Defender['u'.$y]*$Defender['u'.$y])/4;
+ }
+ $units['Def_unit'][$y] = $Defender['u'.$y];
+ if($units['Def_unit'][$y] > 0){
+ $detected = 1;
+ }
+ }
+ }
+ if($detected == 1){
+ if ($Defender['hero'] != 0){
+ $dp += $defenderhero['di'] * 35;
+ $dp = $dp * $defenderhero['db'];
+ }
+ $DefendersAll = $database->getEnforceVillage($DefenderWref,0);
+ if(!empty($DefendersAll)){
+ foreach($DefendersAll as $defenders) {
+ $fromvillage = $defenders['from'];
+ $dp += $defhero[$fromvillage]['di'] * 35;
+ $dp = $dp * $defhero[$fromvillage]['db'];
+ }
+ }
+ }
+ }
+
+ else
+ {
+ for($y=1;$y<=50;$y++) {
+ global ${'u'.$y};
+ if($y >= $start && $y <= ($end-2) && ${def_ab.$abcount} > 0) {
+ $dp += (${'u'.$y}['di'] + (${'u'.$y}['di'] + 300 * ${'u'.$y}['pop'] / 7) * (pow(1.007, ${def_ab.$abcount}) - 1)) * $Defender['u'.$y];
+ $cdp += (${'u'.$y}['dc'] + (${'u'.$y}['dc'] + 300 * ${'u'.$y}['pop'] / 7) * (pow(1.007, ${def_ab.$abcount}) - 1)) * $Defender['u'.$y];
+ }
+ else {
+ $dp += $Defender['u'.$y]*${'u'.$y}['di'];
+ $cdp += $Defender['u'.$y]*${'u'.$y}['dc'];
+ }
+ $involve += $Defender['u'.$y];
+ $units['Def_unit'][$y] = $Defender['u'.$y];
+ $abcount +=1;
+ }
+ if($Defender['hero'] != 0)
+ {
+ $units['Def_unit']['hero'] = $Defender['hero'];
+ $cdp += $defenderhero['dc'];
+ $dp += $defenderhero['di'];
+ $dp = $dp * $defenderhero['db'];
+ $cdp = $cdp * $defenderhero['db'];
+ }
+ $DefendersAll = $database->getEnforceVillage($DefenderWref,0);
+ if(!empty($DefendersAll)){
+ foreach($DefendersAll as $defenders) {
+ $fromvillage = $defenders['from'];
+ $cdp += $defhero[$fromvillage]['dc'];
+ $dp += $defhero[$fromvillage]['di'];
+ $dp = $dp * $defhero[$fromvillage]['db'];
+ $cdp = $cdp * $defhero[$fromvillage]['db'];
+ }
+ }
+ }
+
+ //
+ // Formule voor de berekening van de bonus verdedigingsmuur "en" Residence ";
+ //
+ if($def_wall > 0) {
+ // Stel de factor berekening voor de "Muur" als het type van de beschaving
+ // Factor = 1030 Romeinse muur
+ // Factor = 1020 Wall Germanen
+ // Factor = 1025 Wall Galliers
+ $factor = ($def_tribe == 1)? 1.030 : (($def_tribe == 2)? 1.020 : 1.025);
+ // Verdediging infantery = Infantery * Muur (%)
+ $dp *= pow($factor,$def_wall);
+ // Verdediging Cavelerie = Cavelerie * Muur (%)
+ $cdp *= pow($factor,$def_wall);
+
+ // Berekening van de Basic defence bonus "Residence"
+ $dp += ((2*(pow($residence,2)))*(pow($factor,$def_wall)));
+ $cdp += ((2*(pow($residence,2)))*(pow($factor,$def_wall)));
+ }
+ else
+ {
+ // Berekening van de Basic defence bonus "Residence"
+ $dp += (2*(pow($residence,2)));
+ $cdp += (2*(pow($residence,2)));
+ }
+
+ //
+ // Formule voor het berekenen van punten aanvallers (Infanterie & Cavalry)
+ //
+ if($AttackerWref != 0){
+ $rap = ($ap+$cap)+(($ap+$cap)/100*$bid35[$this->getTypeLevel(35,$AttackerWref)]['attri']);
+ }else{
+ $rap = $ap+$cap;
+ }
+ //
+ // Formule voor de berekening van Defensive Punten
+ //
+ if ($rap==0)
+ $rdp = ($dp) + ($cdp) + 10;
+ else
+ $rdp = ($dp * ($ap/$rap)) + ($cdp * ($cap/$rap)) + 10;
+ //
+ // En de Winnaar is....:
+ //
+ $result['Attack_points'] = $rap;
+ $result['Defend_points'] = $rdp;
+
+ $winner = ($rap > $rdp);
+
+ $result['Winner'] = ($winner)? "attacker" : "defender";
+
+ // Formule voor de berekening van de Moraal
+ if($attpop > $defpop) {
+ if ($rap < $rdp) {
+ $moralbonus = min(1.5, pow($attpop / $defpop, (0.2*($rap/$rdp))));
+ }
+ else {
+ if($defpop==0){
+ $moralbonus = min(1.5, pow($attpop, 0.2));
+ }else{
+ $moralbonus = min(1.5, pow($attpop / $defpop, 0.2));
+ }
+ }
+ }
+ else {
+ $moralbonus = 1.0;
+ }
+
+ if($involve >= 1000) {
+ $Mfactor = round(2*(1.8592-pow($involve,0.015)),4);
+ }
+ else {
+ $Mfactor = 1.5;
+ }
+ if ($Mfactor < 1.25778){$Mfactor=1.25778;}elseif ($Mfactor > 1.5){$Mfactor=1.5;}
+ // Formule voor het berekenen verloren drives
+ // $type = 1 Raid, 0 Normal
+ if($type == 1)
+ {
+ $holder = pow((($rdp*$moralbonus)/$rap),$Mfactor);
+ $holder = $holder / (1 + $holder);
+ // Attacker
+ $result[1] = $holder;
+
+ // Defender
+ $result[2] = 0;
+ }
+ else if($type == 2)
+ {
+
+ }
+ else if($type == 4) {
+ $holder = ($winner) ? pow((($rdp*$moralbonus)/$rap),$Mfactor) : pow(($rap/($rdp*$moralbonus)),$Mfactor);
+ $holder = $holder / (1 + $holder);
+ // Attacker
+ $result[1] = $winner ? $holder : 1 - $holder;
+ // Defender
+ $result[2] = $winner ? 1 - $holder : $holder;
+ $ram -= round($ram*$result[1]/100);
+ $catp -= round($catp*$result[1]/100);
+ }
+ else if($type == 3)
+ {
+ // Attacker
+ $result[1] = ($winner)? pow((($rdp*$moralbonus)/$rap),$Mfactor) : 1;
+ $result[1] = round($result[1],8);
+
+ // Defender
+ $result[2] = (!$winner)? pow(($rap/($rdp*$moralbonus)),$Mfactor) : 1;
+ $result[2] = round($result[2],8);
+ // Als aangevallen met "Hero"
+ $ku = ($att_tribe-1)*10+9;
+ $kings = $Attacker['u'.$ku];
+
+ $aviables= $kings-round($kings*$result[1]);
+ if ($aviables>0){
+ switch($aviables){
+ case 1:
+ $fealthy = rand(20,30);
+ break;
+ case 2:
+ $fealthy = rand(40,60);
+ break;
+ case 3:
+ $fealthy = rand(60,80);
+ break;
+ case 4:
+ $fealthy = rand(80,100);
+ break;
+ default:
+ $fealthy = 100;
+ break;
+ }
+ $result['hero_fealthy'] = $fealthy;
+ }
+ $ram -= ($winner)? round($ram*$result[1]/100) : round($ram*$result[2]/100);
+ $catp -= ($winner)? round($catp*$result[1]/100) : round($catp*$result[2]/100);
+
+ }
+ // Formule voor de berekening van katapulten nodig
+ if($catp > 0 && $tblevel != 0) {
+ $wctp = pow(($rap/$rdp),1.5);
+ $wctp = ($wctp >= 1)? 1-0.5/$wctp : 0.5*$wctp;
+ $wctp *= $catp;
+ $artowner = $database->getVillageField($DefenderWref,"owner");
+ $bartefact = count($database->getOwnUniqueArtefactInfo2($artowner,1,3,0));
+ $bartefact1 = count($database->getOwnUniqueArtefactInfo2($DefenderWref,1,1,1));
+ $bartefact2 = count($database->getOwnUniqueArtefactInfo2($artowner,1,2,0));
+ if($bartefact > 0){
+ $strongerbuildings = 5;
+ }else if($bartefact1 > 0){
+ $strongerbuildings = 4;
+ }else if($bartefact2 > 0){
+ $strongerbuildings = 3;
+ }else{
+ $strongerbuildings = 1;
+ }
+ $good_effect = $bad_effect = 1;
+ $foolartefact = $database->getFoolArtefactInfo(3,$DefenderWref,$artowner);
+ if(count($foolartefact) > 0){
+ foreach($foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $bad_effect = $arte['effect2'];
+ }else{
+ $good_effect = $arte['effect2'];
+ }
+ }
+ }
+ if($stonemason==0){
+ $need = round((($moralbonus * (pow($tblevel,2) + $tblevel + 1)) / (8 * (round(200 * pow(1.0205,$att_ab['a8']))/200) / $strongerbuildings / $good_effect * $bad_effect)) + 0.5);
+ }else{
+ $need = round((($moralbonus * (pow($tblevel,2) + $tblevel + 1)) / (8 * (round(200 * pow(1.0205,$att_ab['a8']))/200) / ($bid34[$stonemason]['attri']/100) / $strongerbuildings / $good_effect * $bad_effect)) + 0.5);
+ }
+ // Aantal katapulten om het gebouw neer te halen
+ $result[3] = $need;
+ // Aantal Katapulten die handeling
+ $result[4] = $wctp;
+ $result[5] = $moralbonus;
+ $result[6] = $att_ab['a8'];
+ }
+ if($ram > 0 && $walllevel != 0) {
+ $wctp = pow(($rap/$rdp),1.5);
+ $wctp = ($wctp >= 1)? 1-0.5/$wctp : 0.5*$wctp;
+ $wctp *= $ram/2;
+ $artowner = $database->getVillageField($DefenderWref,"owner");
+ $bartefact = count($database->getOwnUniqueArtefactInfo2($artowner,1,3,0));
+ $bartefact1 = count($database->getOwnUniqueArtefactInfo2($DefenderWref,1,1,1));
+ $bartefact2 = count($database->getOwnUniqueArtefactInfo2($artowner,1,2,0));
+ if($bartefact > 0){
+ $strongerbuildings = 5;
+ }else if($bartefact1 > 0){
+ $strongerbuildings = 4;
+ }else if($bartefact2 > 0){
+ $strongerbuildings = 3;
+ }else{
+ $strongerbuildings = 1;
+ }
+ $good_effect = $bad_effect = 1;
+ $foolartefact = $database->getFoolArtefactInfo(3,$DefenderWref,$artowner);
+ if(count($foolartefact) > 0){
+ foreach($foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $bad_effect = $arte['effect2'];
+ }else{
+ $good_effect = $arte['effect2'];
+ }
+ }
+ }
+ if($stonemason==0){
+ $need = round((($moralbonus * (pow($walllevel,2) + $walllevel + 1)) / (8 * (round(200 * pow(1.0205,$att_ab['a7']))/200) / $strongerbuildings / $good_effect * $bad_effect)) + 0.5);
+ }else{
+ $need = round((($moralbonus * (pow($walllevel,2) + $walllevel + 1)) / (8 * (round(200 * pow(1.0205,$att_ab['a7']))/200) / ($bid34[$stonemason]['attri']/100) / $strongerbuildings / $good_effect * $bad_effect)) + 0.5);
+ }
+ // Aantal katapulten om het gebouw neer te halen
+ $result[7] = $need;
+
+ // Aantal Katapulten die handeling
+ $result[8] = $wctp;
+ }
+
+ $result[6] = pow($rap/$rdp*$moralbonus,$Mfactor);
+
+ $total_att_units = count($units['Att_unit']);
+ $start = intval(($att_tribe-1)*10+1);
+ $end = intval(($att_tribe*10));
+
+ for($i=$start;$i <= $end;$i++)
+ {
+ $y = $i-(($att_tribe-1)*10);
+ $result['casualties_attacker'][$y] = round($result[1]*$units['Att_unit'][$i]);
+
+ }
+
+ if ($units['Att_unit']['hero']>0)
+ {
+
+ $_result=mysql_query("select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$atkhero['heroid']."'");
+ $fdb = mysql_fetch_array($_result);
+ $hero_id=$fdb['heroid'];
+ $hero_health=$fdb['health'];
+ $damage_health=round(100*$result[1]);
+ //exit($damage_health."|".$hero_health."|".$atkhero['heroid']);
+ if ($hero_health<=$damage_health or $damage_health>90)
+ {
+ //hero die
+ $result['casualties_attacker']['11'] = 1;
+ mysql_query("update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'");
+ mysql_query("update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'");
+ }
+ else
+ {
+ mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'");
+ }
+ }
+ unset($_result,$fdb,$hero_id,$hero_health,$damage_health);
+
+
+ if ($units['Def_unit']['hero']>0)
+ {
+
+ $_result=mysql_query("select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$defenderhero['heroid']."'");
+ $fdb = mysql_fetch_array($_result);
+ $hero_id=$fdb['heroid'];
+ $hero_health=$fdb['health'];
+ $damage_health=round(100*$result[2]);
+ if ($hero_health<=$damage_health or $damage_health>90)
+ {
+ //hero die
+ $result['deadherodef'] = 1;
+ mysql_query("update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'");
+ mysql_query("update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'");
+ }
+ else
+ {
+ $result['deadherodef'] = 0;
+ mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'");
+ }
+ }
+ unset($_result,$fdb,$hero_id,$hero_health,$damage_health);
+
+ $DefendersAll = $database->getEnforceVillage($DefenderWref,0);
+ if(!empty($DefendersAll)){
+ foreach($DefendersAll as $defenders) {
+ if($defenders['hero']>0) {
+ if(!empty($heroarray)) { reset($heroarray); }
+ $Reinforcer = $database->getVillageField($defenders['from'],"owner");
+ $heroarraydefender = $this->getBattleHero($Reinforcer);
+ $_result=mysql_query("select * from " . TB_PREFIX . "hero where `dead`='0' and `heroid`='".$heroarraydefender['heroid']."'");
+ $fdb = mysql_fetch_array($_result);
+ $hero_id=$fdb['heroid'];
+ $hero_health=$fdb['health'];
+ $damage_health=round(100*$result[2]);
+ if ($hero_health<=$damage_health or $damage_health>90)
+ {
+ //hero die
+ $result['deadheroref'][$defenders['id']] = 1;
+ mysql_query("update " . TB_PREFIX . "hero set `dead`='1' where `heroid`='".$hero_id."'");
+ mysql_query("update " . TB_PREFIX . "hero set `health`='0' where `heroid`='".$hero_id."'");
+ }
+ else
+ {
+ $result['deadheroref'][$defenders['id']] = 0;
+ mysql_query("update " . TB_PREFIX . "hero set `health`=`health`-".$damage_health." where `heroid`='".$hero_id."'");
+ }
+ }
+ }
+ }
+ unset($_result,$fdb,$hero_id,$hero_health,$damage_health);
+
+
+ // Work out bounty
+ $start = ($att_tribe-1)*10+1;
+ $end = ($att_tribe*10);
+
+ $max_bounty = 0;
+
+ for($i=$start;$i<=$end;$i++) {
+ $j = $i-$start+1;
+ $y = $i-(($att_tribe-1)*10);
+
+ $max_bounty += ($Attacker['u'.$i]-$result['casualties_attacker'][$y])*${'u'.$i}['cap'];
+
+ }
+
+ $result['bounty'] = $max_bounty;
+
+
+ return $result;
+ }
+
+ public function resolveConflict($data) {
+ global $database,$units,$unitsbytype;
+ $UnitChief = $UnitRam = $UnitCatapult = 0;
+ $attacker_count = $attack_infantry = $attack_cavalry = $attack_scout = $rams = $catapults = 0;
+ $defender_count = $defense_infantry = $defense_cavalry = $defense_scout = $defense_heros = 0;
+ $DefenderFieldsArray = $ResourceImprovementArray = $TrapperArray = array();
+ $FieldPalRes = $BonusPalRes = $BonusStoneMason = $BonusArtefactDurability = 0;
+ $ExperienceAttacker = $ExperienceDefender = 0;
+ $RecountReqd = $AllDefendersDead = False;
+
+ $AttackArrivalTime = $data['endtime'];
+ $AttackerData = $database->getVillageBattleData($data['from']);
+ $AttackerData['pop'] = $database->getPopulation($AttackerData['id']);
+ $Blacksmith = $database->getABTech($data['from']);
+
+ for($i=1;$i<=11;$i++) { $attacker_count += $data['t'.$i]; }
+ if($data['type'] != 1) {
+ // Trap attacking troops if this is not a scouting mission
+ }
+
+ for($i=1;$i<=10;$i++) {
+ if($data['t'.$i] > 0) {
+ $unit = ($AttackerData['tribe']-1)*10+$i;
+ $unitdata = $GLOBALS['u'.$unit];
+ if(in_array($unit,$unitsbytype['cavalry'])) {
+ $attack_cavalry += $data['t'.$i] * ($unitdata['atk'] + ($unitdata['atk'] + 300 * $unitdata['pop'] / 7) * (pow(1.007,$Blacksmith['b'.$i]) - 1));
+ } else {
+ $attack_infantry += $data['t'.$i] * ($unitdata['atk'] + ($unitdata['atk'] + 300 * $unitdata['pop'] / 7) * (pow(1.007,$Blacksmith['b'.$i]) - 1));
+ }
+ if(in_array($unit,$unitsbytype['scout'])) {
+ $attack_scout = $data['t'.$i] * 35 * pow(1.021,$Blacksmith['b'.$i]);
+ }
+ if(in_array($unit,$unitsbytype['chief'])) { $UnitChief = $i; }
+ if(in_array($unit,$unitsbytype['ram'])) { $UnitRam = $i; }
+ if(in_array($unit,$unitsbytype['catapult'])) { $UnitCatapult = $i; }
+ }
+ }
+ if($data['t11'] == 1 && $data['type'] != 1) {
+ $heroarrayAttacker = $this->getBattleHero($AttackerData['id']);
+ if(in_array($heroarrayAttacker['unit'],$unitsbytype['cavalry'])) {
+ $attack_cavalry += $heroarrayAttacker['atk'];
+ } else {
+ $attack_infantry += $heroarrayAttacker['atk'];
+ }
+ $attack_infantry *= $heroarrayAttacker['ob'];
+ $attack_cavalry *= $heroarrayAttacker['ob'];
+ }
+ $attack_total = $attack_infantry + $attack_cavalry;
+ if($attacker_count == 1 && $attack_total < 83 && $data['type'] != 1) {
+ // kill the single non-scout low level attacker due to basic village defense
+ }
+
+ if ($database->isVillageOases($id) == 0) {
+ $DefenderData = $database->getVillageBattleData($data['to']);
+ $DefenderData['pop'] = $database->getPopulation($DefenderData['id']);
+ $IsOasis = False;
+ } else {
+ $OasisData = $database->getOMInfo($data['to']);
+ $IsOasis = True;
+ if($OasisData['conqured'] == 0) {
+ $DefenderData['pop'] = 500;
+ } else {
+ $DefenderData['pop'] = $database->getPopulation($OasisData['conqured']);
+ }
+ $DefenderData['tribe'] = 4;
+ $DefenderData['wall'] = 0;
+ }
+ $DefenderUnits = $database->getUnit($data['to']);
+ $DefendersAll = $database->getEnforceVillage($data['to'],0);
+ array_unshift($DefendersAll,$DefenderUnits);
+ foreach($DefendersAll as $defenders) {
+ $definf = $defcav = 0;
+ if(!empty($Armoury)) { reset($Armoury); }
+ $Armoury = $defenders['from'] != $defenders['vref'] ? $database->getABTech($defenders['from']) : $database->getABTech($defenders['vref']);
+ for($i=1;$i<=50;$i++) {
+ if($defenders['u'.$i] > 0) {
+ if(!empty($unitdata)) { reset($unitdata); }
+ $unitdata = $GLOBALS['u'.$i];
+ $definf += $defenders['u'.$i] * ($unitdata['di'] + ($unitdata['di'] + 300 * $unitdata['pop'] / 7) * (pow(1.007,$Armoury['a'.($i%10)]) - 1));
+ $defcav += $defenders['u'.$i] * ($unitdata['dc'] + ($unitdata['dc'] + 300 * $unitdata['pop'] / 7) * (pow(1.007,$Armoury['a'.($i%10)]) - 1));
+ if(in_array($i,$unitsbytype['scout'])) {
+ $defense_scout += $defenders['u'.$i] * 20 * pow(1.03,$Armoury['a'.($i%10)]);
+ }
+ $defender_count += $defenders['u'.$i];
+ }
+ }
+ if($defenders['hero'] == 1 && $data['type'] != 1) {
+ if(!empty($heroarray)) { reset($heroarray); }
+ if($defenders['vref'] == $data['to']) {
+ $heroarraydefender = $this->getBattleHero($DefenderData['id']);
+ } else {
+ $ReinforcerData = $database->getVillageBattleData($defenders['from']);
+ $heroarraydefender = $this->getBattleHero($ReinforcerData['id']);
+ }
+ $definf = ($definf + $heroarraydefender['di']) * $heroarraydefender['db'];
+ $defcav = ($defcav + $heroarraydefender['dc']) * $heroarraydefender['db'];
+ $defense_heros++;
+ }
+ $defense_infantry += $definf;
+ $defense_cavalry += $defcav;
+ }
+
+ if($data['type'] == 1) {
+ if($attack_scout > $defense_scout) {
+ $attack_scout_casualties = pow(($defense_scout / $attack_scout),1.5);
+ // generate scout report and process casualties
+ } else {
+ $attack_scout_casualties = 1;
+ // kill all scouts
+ }
+ } else {
+ $defense_total = $attack_infantry * $defense_infantry / $attack_total + $attack_cavalry * $defense_cavalry / $attack_total;
+
+ if($DefenderData['pop'] < $AttackerData['pop']) {
+ $defense_total *= min(1.5,pow($AttackerData['pop']/$DefenderData['pop'],0.2));
+ }
+
+ $DefenderFields = $database->getResourceLevel($data['to']);
+ for($i=1;$i<=38;$i++) {
+ if($DefenderFields['f'.$i] > 0) { $DefenderFieldsArray[] = $i; }
+ if($DefenderFields['f'.$i.'t'] == 25 || $DefenderFields['f'.$i.'t'] == 26) {
+ $BonusPalRes = 2 * pow($DefenderFields['f'.$i],2);
+ $FieldPalRes = $i;
+ }
+ if($DefenderFields['f'.$i.'t'] == 34) {
+ $BonusStoneMason = $DefenderFields['f'.$i] / 10 + 1;
+ }
+ if($DefenderFields['f'.$i.'t'] >= 5 && $DefenderFields['f'.$i.'t'] <= 9) {
+ $ResourceImprovementArray[] = $i;
+ }
+ if($DefenderFields['f'.$i.'t'] == 36) {
+ $TrapperArray[] = $i;
+ }
+ if($DefenderFields['f'.$i.'t'] == $data['ctar1'] && $data['ctar1'] != 0) {
+ $ctarf[1] = $i;
+ }
+ if($DefenderFields['f'.$i.'t'] == $data['ctar2'] && $data['ctar2'] != 0 && ($data['ctar1'] != $data['ctar2'] || $data['ctar2'] <= 18)) {
+ $ctarf[2]= $i;
+ }
+ }
+ $defense_total += $BonusPalRes;
+
+ $BonusWall = $DefenderData['tribe'] == 1 ? 1.03 : ($DefenderData['tribe'] == 2 ? 1.02 : 1.025);
+ $defense_total *= pow($BonusWall,$DefenderData['wall']);
+
+ if($attacker_count + $defender_count + $defense_heros > 1000) {
+ $DiffModifier = 2 * (1.8592 - pow(($attacker_count + $defender_count + $defense_heros),0.015));
+ } else {
+ $DiffModifier = 1.5;
+ }
+ $attack_casualties = $defense_casualties = 1;
+ if($attack_total > $defense_total) {
+ $attack_casualties = pow(($defense_total / $attack_total),$DiffModifier);
+ if($data['type'] == 4) {
+ $attack_casualties = $attack_casualties / (1 + $attack_casualties);
+ $defense_casualties = 1 - $attack_casualties;
+ }
+ } else {
+ $defense_casualties = pow(($attack_total / $defense_total),$DiffModifier);
+ if($data['type'] == 4) {
+ $defense_casualties = $defense_casualties / (1 + $defense_casualties);
+ $attack_casualties = 1 - $defense_casualties;
+ }
+ }
+
+ if($rams > 0 && $DefenderData['wall'] > 0) {
+ if($attack_casualties < 1) {
+ $database->setVillageLevel($data['to'],'f40t',0);
+ $database->setVillageLevel($data['to'],'f40',0);
+ } else {
+ $RequiredRams=array(1=>array(1,2,2,3,4,6,7,10,12,14,17,20,23,27,31,35,39,43,48,53),array(1,4,8,13,19,27,36,46,57,69,83,98,114,132,151,171,192,214,238,263),array(1,2,4,6,8,11,15,19,23,28,34,40,46,53,61,69,77,86,96,106));
+ $DC = max(1,$BonusStoneMason) * max(1,$BonusPalRes) / (pow(1.015,$Blacksmith['b'.$UnitRam])) ;
+ $L = $DefenderData['wall'];
+ $L2 = round(($DefenderData['wall'] - 1) /2);
+ $DDR = $DC / ( $L*($L+1)/8 + 5 + (24.875 + 0.625*$L2)*$L2/2 );
+ //calculate damage to wall based on surviving rams
+ }
+ $RecountReqd = True;
+ }
+ if($catapults > 0 && !$IsOasis) {
+ $BuildLevelStrength=array(1=>1,2,2,3,4,6,8,10,12,14,17,20,23,27,31,35,39,43,48,53);
+ $RequiredCatapults = $RequiredCatapultsMax = $BuildingLevelMax = array();
+ if(!empty($RequiredCatapults)) { reset($RequiredCatapults); }
+ for($i=1;$i<=2;$i++) {
+ if($data['ctar'.$i] == 0 || $ctarf[$i] == 0) {
+ $data['ctar'.$i] = $DefenderFieldsArray[rand(0,count($DefenderFieldsArray)-1)];
+ if($data['ctar2'] == 0 && $i == 1) { $data['ctar2'] = $data['ctar1']; }
+ }
+ $RequiredCatapults[$i] = round((($DefenderData['pop'] < $AttackerData['pop'] ? min(3,pow($AttackerData['pop'] / $DefenderData['pop'],0.3)) : 1) * (pow($DefenderField['f'.$ctarf[$i]],2) + $DefenderField['f'.$ctarf[$i]] + 1) / (8 * (round(200 * pow(1.0205,$Blacksmith['b'.$UnitCatapult])) / 200) / max(1,($data['ctar'.$i]>=18?max(1,$BonusStoneMason + $BonusArtefactDurability):1)))) + 0.5);
+ $BuildingLevelMax[$i] = 20;
+ if($DefenderData['capital'] != 1 && $data['ctar'.$i] <= 18 || in_array($data['ctar'.$i],$TrapperArray)) { $BuildingLevelMax[$i] = 10; }
+ if(in_array($data['ctar'.$i],$ResourceImprovementArray)) { $BuildingLevelMax[$i] = 5; }
+ $RequiredCatapultsMax[$i] = round((($DefenderData['pop'] < $AttackerData['pop'] ? min(3,pow($AttackerData['pop'] / $DefenderData['pop'],0.3)) : 1) * (pow($BuildingLevelMax[$i],2) + $BuildingLevelMax[$i] + 1) / (8 * (round(200 * pow(1.0205,$Blacksmith['b'.$UnitCatapult])) / 200) / max(1,($data['ctar'.$i]>=18?max(1,$BonusStoneMason + $BonusArtefactDurability):1)))) + 0.5);
+ }
+ $CatapultsFiring = pow($attack_total / $defense_total,1.5);
+ if($CatapultsFiring > 1) {
+ $CatapultsFiring = 1 - 0.5 / $CatapultsFiring;
+ } else {
+ $CatapultsFiring = 0.5 * $CatapultsFiring;
+ }
+ $CatapultsFiring *= $data['t'.$UnitCatapult];
+ for($i=1;$i=($data['ctar1']==$data['ctar2']?1:2);$i++) {
+ $BuildingLevelOld[$i] = $DefenderField['f'.$data['ctar'.$i]];
+ if($data['ctar1']!=$data['ctar2'] && $i==1) { $CatapultsFiring /= 2; }
+ if($CatapultsFiring >= $RequiredCatapults[$i]) {
+ if($DefenderField['f'.$data['ctar'.$i]] == $FieldPalRes) { $DestroyedPalRes = True; }
+ if($data['ctar'.$i] >= 19) { $database->setVillageLevel($data['to'],'f'.$data['ctar'.$i].'t',0); }
+ $database->setVillageLevel($data['to'],'f'.$data['ctar'.$i],0);
+ $BuildingLevelNow[$i] = 0;
+ $RecountReqd = True;
+ } else {
+ $BuildLevelCount = 0;
+ for($j=$DefenderField['f'.$data['ctar'.$i]];$j=1;$j--) {
+ $BuildLevelCount += ($BuildLevelStrength[$j] - $BuildLevelStrength[$j-1]) * $RequiredCatapultsMax[$i] / $BuildLevelStrength[$BuildingLevelMax[$i]];
+ if($CatapultsFiring < $BuildLevelCount) {
+ $BuildingLevelNow[$i] = $j;
+ break;
+ }
+ $database->setVillageLevel($data['to'],'f'.$data['ctar'.$i],$BuildingLevelNow[$i]);
+ $RecountReqd = True;
+ }
+ }
+ }
+ }
+
+ for($i=1;$i<=10;$i++) {
+ $attack_casualties_array[$i] = round($data['t'.$i] * $attack_casualties);
+ if(!empty($unitdata)) { reset($unitdata); }
+ $unitdata = $GLOBALS['u'.(($AttackerData['tribe']-1)*10+$i)];
+ $ExperienceDefender += $attack_casualties_array[$i] * $unitdata['pop'];
+ }
+ if($data['t11'] == 1) {
+ if($attack_casualties < 0.9) {
+ if($heroarrayAttacker['health']-100*$attack_casualties > 0) {
+ $database->modifyHero('health',(100*$attack_casualties),$heroarrayAttacker['heroid'],2);
+ $database->modifyHero('lastupdate',time(),$heroarrayAttacker['heroid'],0);
+ } else {
+ $database->modifyHero('health',0,$heroarrayAttacker['heroid'],0);
+ $database->modifyHero('dead',1,$heroarrayAttacker['heroid'],0);
+ $database->modifyHero('lastupdate',time(),$heroarrayAttacker['heroid'],0);
+ }
+ } else {
+ $database->modifyHero('health',0,$heroarrayAttacker['heroid'],0);
+ $database->modifyHero('dead',1,$heroarrayAttacker['heroid'],0);
+ $database->modifyHero('lastupdate',time(),$heroarrayAttacker['heroid'],0);
+ }
+ }
+ $DefenderUnits = $database->getUnit($data['to']);
+ $DefendersAll = $database->getEnforceVillage($data['to'],0);
+ array_unshift($DefendersAll,$DefenderUnits);
+ foreach($DefendersAll as $defenders) {
+ if($defenders['hero'] == 1 && $data['type'] != 1) {
+ if(!empty($heroarray)) { reset($heroarray); }
+ if($defenders['vref'] == $data['to']) {
+ $heroarraydefender = $this->getBattleHero($DefenderData['id']);
+ } else {
+ $ReinforcerData = $database->getVillageBattleData($defenders['from']);
+ $heroarraydefender = $this->getBattleHero($ReinforcerData['id']);
+ }
+ if($defense_casualties < 0.9) {
+ if($heroarrayDefender['health']-100*$defense_casualties > 0) {
+ $database->modifyHero('health',(100*$defense_casualties),$heroarrayDefender['heroid'],2);
+ $database->modifyHero('lastupdate',time(),$heroarrayDefender['heroid'],0);
+ } else {
+ $database->modifyHero('health',0,$heroarrayDefender['heroid'],0);
+ $database->modifyHero('dead',1,$heroarrayDefender['heroid'],0);
+ $database->modifyHero('lastupdate',time(),$heroarrayDefender['heroid'],0);
+ }
+ } else {
+ $database->modifyHero('health',0,$heroarrayDefender['heroid'],0);
+ $database->modifyHero('dead',1,$heroarrayDefender['heroid'],0);
+ $database->modifyHero('lastupdate',time(),$heroarrayDefender['heroid'],0);
+ }
+ }
+ }
+ // send surviving attackers and hero home, report.
+ // calculate defensive casualties, hero damage and experience (all heroes), modify units and reinforcements, report.
+ // damage buildings report
+
+ // Chiefing logic including wall and tribal specific building removal
+
+ if($IsOasis && $data['t11'] == 1 && $AllDefendersDead) {
+ $database->modifyOasisLoyalty($data['to']);
+ if($database->canConquerOasis($data['from'],$data['to'])) {
+ $database->conquerOasis($data['to'],$data['from'],$AttackerData['id']);
+ }
+ }
+
+ if($RecountReqd) { $automation->recountPop($data['to']); }
+ }
+ }
+
+};
+
+$battle = new Battle;
+?>
\ No newline at end of file
diff --git a/GameEngine/Building.php b/GameEngine/Building.php
new file mode 100644
index 00000000..a4f2bb2b
--- /dev/null
+++ b/GameEngine/Building.php
@@ -0,0 +1,799 @@
+maxConcurrent = BASIC_MAX;
+ if(ALLOW_ALL_TRIBE || $session->tribe == 1) {
+ $this->maxConcurrent += INNER_MAX;
+ }
+ if($session->plus) {
+ $this->maxConcurrent += PLUS_MAX;
+ }
+ $this->LoadBuilding();
+ foreach($this->buildArray as $build) {
+ if($build['master']==1){
+ $this->maxConcurrent += 1;
+ }
+ }
+ }
+
+ public function procBuild($get) {
+ global $session;
+ if(isset($get['a']) && $get['c'] == $session->checker && !isset($get['id'])) {
+ if($get['a'] == 0) {
+ $this->removeBuilding($get['d']);
+ }
+ else {
+ $session->changeChecker();
+ $this->upgradeBuilding($get['a']);
+ }
+ }
+ if(isset($get['a']) && $get['c'] == $session->checker && isset($get['id'])) {
+ $session->changeChecker();
+ $this->constructBuilding($get['id'],$get['a']);
+ }
+ if(isset($get['buildingFinish'])) {
+ if($session->gold >= 2 && $session->sit == 0) {
+ $this->finishAll();
+ }
+ }
+ }
+
+ public function canBuild($id,$tid) {
+ global $village,$session,$database;
+ $demolition = $database->getDemolition($village->wid);
+ if($demolition[0]['buildnumber']==$id) { return 11; }
+ if($this->isMax($tid,$id)) {
+ return 1;
+ } else if($this->isMax($tid,$id,1) && ($this->isLoop($id) || $this->isCurrent($id))) {
+ return 10;
+ } else if($this->isMax($tid,$id,2) && $this->isLoop($id) && $this->isCurrent($id)) {
+ return 10;
+ } else if($this->isMax($tid,$id,3) && $this->isLoop($id) && $this->isCurrent($id) && count($database->getMasterJobs($village->wid)) > 0) {
+ return 10;
+ }
+ else {
+ if($this->allocated <= $this->maxConcurrent) {
+ $resRequired = $this->resourceRequired($id,$village->resarray['f'.$id.'t']);
+ $resRequiredPop = $resRequired['pop'];
+ if ($resRequiredPop == "") {
+ $buildarray = $GLOBALS["bid".$tid];
+ $resRequiredPop = $buildarray[1]['pop'];
+ }
+ $jobs = $database->getJobs($village->wid);
+ if ($jobs > 0) {
+ $soonPop = 0;
+ foreach ($jobs as $j) {
+ $buildarray = $GLOBALS["bid".$j['type']];
+ $soonPop += $buildarray[$database->getFieldLevel($village->wid,$j['field'])+1]['pop'];
+ }
+ }
+ if(($village->allcrop - $village->pop - $soonPop - $resRequiredPop) <= 1 && $village->resarray['f'.$id.'t'] <> 4) {
+ return 4;
+ }
+ else {
+ switch($this->checkResource($tid,$id)) {
+ case 1:
+ return 5;
+ break;
+ case 2:
+ return 6;
+ break;
+ case 3:
+ return 7;
+ break;
+ case 4:
+ if($id >= 19) {
+ if($session->tribe == 1 || ALLOW_ALL_TRIBE) {
+ if($this->inner == 0) {
+ return 8;
+ }
+ else {
+ if($session->plus or $tid==40) {
+ if($this->plus == 0) {
+ return 9;
+ }
+ else {
+ return 3;
+ }
+ }
+ else {
+ return 2;
+ }
+ }
+ }
+ else {
+ if($this->basic == 0) {
+ return 8;
+ }
+ else {
+ if($session->plus or $tid==40) {
+ if($this->plus == 0) {
+ return 9;
+ }
+ else {
+ return 3;
+ }
+ }
+ else {
+ return 2;
+ }
+ }
+ }
+ }
+ else {
+ if($this->basic == 1) {
+ if(($session->plus or $tid==40) && $this->plus == 0) {
+ return 9;
+ }
+ else {
+ return 3;
+ }
+ }
+ else {
+ return 8;
+ }
+ }
+ break;
+ }
+ }
+ }
+ else {
+ return 2;
+ }
+ }
+ }
+
+ public function walling() {
+ global $session;
+ $wall = array(31,32,33);
+ foreach($this->buildArray as $job) {
+ if(in_array($job['type'],$wall)) {
+ return "3".$session->tribe;
+ }
+ }
+ return false;
+ }
+
+ public function rallying() {
+ foreach($this->buildArray as $job) {
+ if($job['type'] == 16) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public function procResType($ref) {
+ global $session;
+ switch($ref) {
+ case 1: $build = "Woodcutter"; break;
+ case 2: $build = "Clay Pit"; break;
+ case 3: $build = "Iron Mine"; break;
+ case 4: $build = "Cropland"; break;
+ case 5: $build = "Sawmill"; break;
+ case 6: $build = "Brickyard"; break;
+ case 7: $build = "Iron Foundry"; break;
+ case 8: $build = "Grain Mill"; break;
+ case 9: $build = "Bakery"; break;
+ case 10: $build = "Warehouse"; break;
+ case 11: $build = "Granary"; break;
+ case 12: $build = "Blacksmith"; break;
+ case 13: $build = "Armoury"; break;
+ case 14: $build = "Tournament Square"; break;
+ case 15: $build = "Main Building"; break;
+ case 16: $build = "Rally Point"; break;
+ case 17: $build = "Marketplace"; break;
+ case 18: $build = "Embassy"; break;
+ case 19: $build = "Barracks"; break;
+ case 20: $build = "Stable"; break;
+ case 21: $build = "Workshop"; break;
+ case 22: $build = "Academy"; break;
+ case 23: $build = "Cranny"; break;
+ case 24: $build = "Town Hall"; break;
+ case 25: $build = "Residence"; break;
+ case 26: $build = "Palace"; break;
+ case 27: $build = "Treasury"; break;
+ case 28: $build = "Trade Office"; break;
+ case 29: $build = "Great Barracks"; break;
+ case 30: $build = "Great Stable"; break;
+ case 31: $build = "City Wall"; break;
+ case 32: $build = "Earth Wall"; break;
+ case 33: $build = "Palisade"; break;
+ case 34: $build = "Stonemason's Lodge"; break;
+ case 35: $build = "Brewery"; break;
+ case 36: $build = "Trapper"; break;
+ case 37: $build = "Hero's Mansion"; break;
+ case 38: $build = "Great Warehouse"; break;
+ case 39: $build = "Great Granary"; break;
+ case 40: $build = "Wonder of the World"; break;
+ case 41: $build = "Horse Drinking Trough"; break;
+ case 42: $build = "Great Workshop"; break;
+ default: $build = "Error"; break;
+ }
+ return $build;
+ }
+
+ private function loadBuilding() {
+ global $database,$village,$session;
+ $this->buildArray = $database->getJobs($village->wid);
+ $this->allocated = count($this->buildArray);
+ if($this->allocated > 0) {
+ foreach($this->buildArray as $build) {
+ if($build['loopcon'] == 1) {
+ $this->plus = 1;
+ }
+ else {
+ if($build['field'] <= 18) {
+ $this->basic += 1;
+ }
+ else {
+ if($session->tribe == 1 || ALLOW_ALL_TRIBE) {
+ $this->inner += 1;
+ }
+ else {
+ $this->basic += 1;
+ }
+ }
+ }
+ }
+ $this->NewBuilding = true;
+ }
+ }
+
+ private function removeBuilding($d) {
+ global $database,$village;
+ foreach($this->buildArray as $jobs) {
+ if($jobs['id'] == $d) {
+ $uprequire = $this->resourceRequired($jobs['field'],$jobs['type']);
+ if($database->removeBuilding($d)) {
+ if($jobs['master'] == 0){
+ $database->modifyResource($village->wid,$uprequire['wood'],$uprequire['clay'],$uprequire['iron'],$uprequire['crop'],1);
+ }
+ if($jobs['field'] >= 19) {
+ header("Location: dorf2.php");
+ }
+ else {
+ header("Location: dorf1.php");
+ }
+ }
+ }
+ }
+ }
+
+ private function upgradeBuilding($id) {
+ global $database,$village,$session,$logging;
+ if($this->allocated < $this->maxConcurrent) {
+ $uprequire = $this->resourceRequired($id,$village->resarray['f'.$id.'t']);
+ $time = time() + $uprequire['time'];
+ $bindicate = $this->canBuild($id,$village->resarray['f'.$id.'t']);
+ $loop = ($bindicate == 9 ? 1 : 0);
+ $loopsame = 0;
+ if($loop == 1) {
+ foreach($this->buildArray as $build) {
+ if($build['field']==$id) {
+ $loopsame += 1;
+ $uprequire = $this->resourceRequired($id,$village->resarray['f'.$id.'t'],($loopsame>0?2:1));
+ }
+ }
+ if($session->tribe == 1 || ALLOW_ALL_TRIBE) {
+ if($id >= 19) {
+ foreach($this->buildArray as $build) {
+ if($build['field'] >= 19) {
+ $time = $build['timestamp'] + $uprequire['time'];
+ }
+ }
+ }
+ else {
+ foreach($this->buildArray as $build) {
+ if($build['field'] <= 18) {
+ $time = $build['timestamp'] + $uprequire['time'];
+ }
+ }
+ }
+ }
+ else {
+ $time = $this->buildArray[0]['timestamp'] + $uprequire['time'];
+ }
+ }
+ $level = $database->getResourceLevel($village->wid);
+ if($session->access!=BANNED){
+ if($database->addBuilding($village->wid,$id,$village->resarray['f'.$id.'t'],$loop,$time+($loop==1?ceil(60/SPEED):0),0,$level['f'.$id] + 1 + count($database->getBuildingByField($village->wid,$id)))) {
+ $database->modifyResource($village->wid,$uprequire['wood'],$uprequire['clay'],$uprequire['iron'],$uprequire['crop'],0);
+ $logging->addBuildLog($village->wid,$this->procResType($village->resarray['f'.$id.'t']),($village->resarray['f'.$id]+($loopsame>0?2:1)),0);
+ if($id >= 19) {
+ header("Location: dorf2.php");
+ }
+ else {
+ header("Location: dorf1.php");
+ }
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+ }
+
+ private function downgradeBuilding($id) {
+ global $database,$village,$session,$logging;
+ if($this->allocated < $this->maxConcurrent) {
+ $name = "bid".$village->resarray['f'.$id.'t'];
+ global $$name;
+ $dataarray = $$name;
+ $time = time() + round($dataarray[$village->resarray['f'.$id]-1]['time'] / 4);
+ $loop = 0;
+ if($this->inner == 1 || $this->basic == 1) {
+ if(($session->plus or $village->resarray['f'.$id.'t']==40)&& $this->plus == 0) {
+ $loop = 1;
+ }
+ }
+ if($loop == 1) {
+ if($session->tribe == 1 || ALLOW_ALL_TRIBE) {
+ if($id >= 19) {
+ foreach($this->buildArray as $build) {
+ if($build['field'] >= 19) {
+ $time = $build['timestamp'] + round($dataarray[$village->resarray['f'.$id]-1]['time'] / 4);
+ }
+ }
+ }
+ }
+ else {
+ $time = $this->buildArray[0]['timestamp'] + round($dataarray[$village->resarray['f'.$id]-1]['time'] / 4);
+ }
+ }
+ if($session->access!=BANNED){
+ $level = $database->getResourceLevel($village->wid);
+ if($database->addBuilding($village->wid,$id,$village->resarray['f'.$id.'t'],$loop,$time,0,0,$level['f'.$id] + 1 + count($database->getBuildingByField($village->wid,$id)))) {
+ $logging->addBuildLog($village->wid,$this->procResType($village->resarray['f'.$id.'t']),($village->resarray['f'.$id]-1),2);
+ header("Location: dorf2.php");
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+ }
+
+
+
+ private function constructBuilding($id,$tid) {
+ global $database,$village,$session,$logging;
+ if($this->allocated < $this->maxConcurrent) {
+ if($tid == 16) {
+ $id = 39;
+ }
+ else if($tid == 31 || $tid == 32 || $tid == 33) {
+ $id = 40;
+ }
+ $uprequire = $this->resourceRequired($id,$tid);
+ $time = time() + $uprequire['time'];
+ $bindicate = $this->canBuild($id,$village->resarray['f'.$id.'t']);
+ $loop = ($bindicate == 9 ? 1 : 0);
+ if($loop == 1) {
+ foreach($this->buildArray as $build) {
+ if($build['field'] >= 19 || ($session->tribe <> 1 && !ALLOW_ALL_TRIBE)) {
+ $time = $build['timestamp'] + ceil(60/SPEED) + $uprequire['time'];
+ }
+ }
+ }
+ if($this->meetRequirement($tid)) {
+ if($session->access!=BANNED){
+ $level = $database->getResourceLevel($village->wid);
+ if($database->addBuilding($village->wid,$id,$tid,$loop,$time,0,$level['f'.$id] + 1 + count($database->getBuildingByField($village->wid,$id)))) {
+ $logging->addBuildLog($village->wid,$this->procResType($tid),($village->resarray['f'.$id]+1),1);
+ $database->modifyResource($village->wid,$uprequire['wood'],$uprequire['clay'],$uprequire['iron'],$uprequire['crop'],0);
+ header("Location: dorf2.php");
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+ }
+ }
+
+ private function meetRequirement($id) {
+ global $village,$session,$database;
+ switch($id) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 11:
+ case 15:
+ case 16:
+ case 18:
+ case 23:
+ case 31:
+ case 32:
+ case 33:
+ return true;
+ break;
+ case 10:
+ case 20:
+ return ($this->getTypeLevel(15) >= 1)? true : false;
+ break;
+ case 5:
+ if($this->getTypeLevel(1) >= 10 && $this->getTypeLevel(15) >= 5) { return true; } else { return false; }
+ break;
+ case 6:
+ if($this->getTypeLevel(2) >= 10 && $this->getTypeLevel(15) >= 5) { return true; } else { return false; }
+ break;
+ case 7:
+ if($this->getTypeLevel(3) >= 10 && $this->getTypeLevel(15) >= 5) { return true; } else { return false; }
+ break;
+ case 8:
+ if($this->getTypeLevel(4) >= 5) { return true; } else { return false; }
+ break;
+ case 9:
+ if($this->getTypeLevel(15) >= 5 && $this->getTypeLevel(4) >= 10 && $this->getTypeLevel(8) >= 5) { return true; } else { return false; }
+ break;
+ case 12:
+ if($this->getTypeLevel(22) >= 3 && $this->getTypeLevel(15) >= 3) { return true; } else { return false; }
+ break;
+ case 13:
+ if($this->getTypeLevel(15) >= 3 && $this->getTypeLevel(22) >= 1) { return true; } else { return false; }
+ break;
+ case 14:
+ if($this->getTypeLevel(16) >= 15) { return true; } else { return false; }
+ break;
+ case 17:
+ if($this->getTypeLevel(15) >= 3 && $this->getTypeLevel(10) >= 1 && $this->getTypeLevel(11) >= 1) { return true; } else { return false; }
+ break;
+ case 19:
+ if($this->getTypeLevel(15) >= 3 && $this->getTypeLevel(16) >= 1) { return true; } else { return false; }
+ break;
+ case 20:
+ if($this->getTypeLevel(12) >= 3 && $this->getTypeLevel(22) >= 5) { return true; } else { return false; }
+ break;
+ case 21:
+ if($this->getTypeLevel(22) >= 10 && $this->getTypeLevel(15) >= 5) { return true; } else { return false; }
+ break;
+ case 22:
+ if($this->getTypeLevel(15) >= 3 && $this->getTypeLevel(16) >= 1) { return true; } else { return false; }
+ break;
+ case 24:
+ if($this->getTypeLevel(22) >= 10 && $this->getTypeLevel(15) >= 10) { return true; } else { return false; }
+ break;
+ case 25:
+ if($this->getTypeLevel(15) >= 5) { return true; } else { return false; }
+ break;
+ case 26:
+ if($this->getTypeLevel(18) >= 1 && $this->getTypeLevel(15) >= 5 && $this->getTypeLevel(25) == 0) { return true; } else { return false; }
+ break;
+ case 27:
+ if($this->getTypeLevel(15) >= 10) { return true; } else { return false; }
+ break;
+ case 28:
+ if($this->getTypeLevel(17) == 20 && $this->getTypeLevel(20) >= 10) { return true; } else { return false; }
+ break;
+ case 29:
+ if($this->getTypeLevel(19) == 20 && $village->capital == 0) { return true; } else { return false; }
+ break;
+ case 30:
+ if($this->getTypeLevel(20) == 20 && $village->capital == 0) { return true; } else { return false; }
+ break;
+ case 34:
+ if($this->getTypeLevel(26) >= 3 && $this->getTypeLevel(15) >= 5 && $this->getTypeLevel(25) == 0) { return true; } else { return false; }
+ break;
+ case 35:
+ if($this->getTypeLevel(16) >= 10 && $this->getTypeLevel(11) == 20) { return true; } else { return false; }
+ break;
+ case 36:
+ if($this->getTypeLevel(16) >= 1) { return true; } else { return false; }
+ break;
+ case 37:
+ if($this->getTypeLevel(15) >= 3 && $this->getTypeLevel(16) >= 1) { return true; } else { return false; }
+ break;
+ case 38:
+ if($this->getTypeLevel(15) >= 10 && $village->capital == 0) { return true; } else { return false; }
+ break;
+ case 39:
+ if($this->getTypeLevel(15) >= 10 && $village->capital == 0) { return true; } else { return false; }
+ break;
+ case 40:
+ $wwlevel = $village->resarray['f99'];
+ if($wwlevel > 50){
+ $needed_plan = 1;
+ }else{
+ $needed_plan = 0;
+ }
+ $wwbuildingplan = 0;
+ $villages = $database->getVillagesID($session->uid);
+ foreach($villages as $village1){
+ $plan = count($database->getOwnArtefactInfoByType2($village1,11));
+ if($plan > 0){
+ $wwbuildingplan = 1;
+ }
+ }
+ if($session->alliance != 0){
+ $alli_users = $database->getUserByAlliance($session->alliance);
+ foreach($alli_users as $users){
+ $villages = $database->getVillagesID($users['id']);
+ if($users['id'] != $session->uid){
+ foreach($villages as $village1){
+ $plan = count($database->getOwnArtefactInfoByType2($village1,11));
+ if($plan > 0){
+ $wwbuildingplan += 1;
+ }
+ }
+ }
+ }
+ }
+ if($village->natar == 1 && $wwbuildingplan > $needed_plan) { return true; } else { return false; }
+ break;
+ case 41:
+ if($this->getTypeLevel(16) >= 10 && $this->getTypeLevel(20) == 20) { return true; } else { return false; }
+ break;
+ case 42:
+ if($this->getTypeLevel(21) == 20 && $village->capital == 0) { return true; } else { return false; }
+ break;
+ }
+ }
+
+ private function checkResource($tid,$id) {
+ $name = "bid".$tid;
+ global $village,$$name,$database;
+ $plus = 1;
+ foreach($this->buildArray as $job) {
+ if($job['type'] == $tid && $job['field'] == $id) {
+ $plus = 2;
+ }
+ }
+ $dataarray = $$name;
+ $wood = $dataarray[$village->resarray['f'.$id]+$plus]['wood'];
+ $clay = $dataarray[$village->resarray['f'.$id]+$plus]['clay'];
+ $iron = $dataarray[$village->resarray['f'.$id]+$plus]['iron'];
+ $crop = $dataarray[$village->resarray['f'.$id]+$plus]['crop'];
+ if($wood > $village->maxstore || $clay > $village->maxstore || $iron > $village->maxstore) {
+ return 1;
+ }
+ else {
+ if($crop > $village->maxcrop) {
+ return 2;
+ }
+ else {
+ if($wood > $village->awood || $clay > $village->aclay || $iron > $village->airon || $crop > $village->acrop) {
+ return 3;
+ }
+ else {
+ if($village->awood-$wood > 0 && $village->aclay-$clay > 0 && $village->airon-$iron > 0 && $village->acrop-$crop >0){
+ return 4;
+ }
+ else {
+ return 3;
+ }
+ }
+ }
+ }
+ }
+
+ public function isMax($id,$field,$loop=0) {
+ $name = "bid".$id;
+ global $$name,$village;
+ $dataarray = $$name;
+ if($id <= 4) {
+ if($village->capital == 1) {
+ return ($village->resarray['f'.$field] == (count($dataarray) - 1 - $loop));
+ }
+ else {
+ return ($village->resarray['f'.$field] == (count($dataarray) - 11 - $loop));
+ }
+ }
+ else {
+ return ($village->resarray['f'.$field] == count($dataarray) - $loop);
+ }
+ }
+
+ public function getTypeLevel($tid,$vid=0) {
+ global $village,$database;
+ $keyholder = array();
+ if($vid == 0) {
+ $resourcearray = $village->resarray;
+ } else {
+ $resourcearray = $database->getResourceLevel($vid);
+ }
+ foreach(array_keys($resourcearray,$tid) as $key) {
+ if(strpos($key,'t')) {
+ $key = preg_replace("/[^0-9]/", '', $key);
+ array_push($keyholder, $key);
+ }
+ }
+ $element = count($keyholder);
+ if($element >= 2) {
+ if($tid <= 4) {
+ $temparray = array();
+ for($i=0;$i<=$element-1;$i++) {
+ array_push($temparray,$resourcearray['f'.$keyholder[$i]]);
+ }
+ foreach ($temparray as $key => $val) {
+ if ($val == max($temparray))
+ $target = $key;
+ }
+ }
+ else {
+ $target = 0;
+ for($i=1;$i<=$element-1;$i++) {
+ if($resourcearray['f'.$keyholder[$i]] > $resourcearray['f'.$keyholder[$target]]) {
+ $target = $i;
+ }
+ }
+ }
+ }
+ else if($element == 1) {
+ $target = 0;
+ }
+ else {
+ return 0;
+ }
+ if($keyholder[$target] != "") {
+ return $resourcearray['f'.$keyholder[$target]];
+ }
+ else {
+ return 0;
+ }
+ }
+
+
+ public function isCurrent($id) {
+ foreach($this->buildArray as $build) {
+ if($build['field'] == $id && $build['loopcon'] <> 1) {
+ return true;
+ }
+ }
+ }
+
+ public function isLoop($id=0) {
+ foreach($this->buildArray as $build) {
+ if(($build['field'] == $id && $build['loopcon']) || ($build['loopcon'] == 1 && $id == 0)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public function finishAll() {
+ global $database,$session,$logging,$village,$bid18,$bid10,$bid11,$technology,$_SESSION;
+ if($session->access!=BANNED){
+ $ww = 1;
+ foreach($this->buildArray as $jobs) {
+ if($jobs['wid']==$village->wid){
+ $wwvillage = $database->getResourceLevel($jobs['wid']);
+ if($wwvillage['f99t']!=40){
+ $level = $jobs['level'];
+ if($jobs['type'] != 25 AND $jobs['type'] != 26 AND $jobs['type'] != 40) {
+ $finish = 1;
+ $resource = $this->resourceRequired($jobs['field'],$jobs['type']);
+ if($jobs['master'] == 0){
+ $q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
+ }else{
+ $villwood = $database->getVillageField($jobs['wid'],'wood');
+ $villclay = $database->getVillageField($jobs['wid'],'clay');
+ $villiron = $database->getVillageField($jobs['wid'],'iron');
+ $villcrop = $database->getVillageField($jobs['wid'],'crop');
+ $type = $jobs['type'];
+ $buildarray = $GLOBALS["bid".$type];
+ $buildwood = $buildarray[$level]['wood'];
+ $buildclay = $buildarray[$level]['clay'];
+ $buildiron = $buildarray[$level]['iron'];
+ $buildcrop = $buildarray[$level]['crop'];
+ if($buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop){
+ $newgold = $session->gold-1;
+ $database->updateUserField($session->uid, "gold", $newgold, 1);
+ $enought_res = 1;
+ $q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
+ }
+ }
+ if($database->query($q) && ($enought_res == 1 or $jobs['master'] == 0)) {
+ $database->modifyPop($jobs['wid'],$resource['pop'],0);
+ $database->addCP($jobs['wid'],$resource['cp']);
+ $q = "DELETE FROM ".TB_PREFIX."bdata where id = ".$jobs['id'];
+ $database->query($q);
+ if($jobs['type'] == 18) {
+ $owner = $database->getVillageField($jobs['wid'],"owner");
+ $max = $bid18[$level]['attri'];
+ $q = "UPDATE ".TB_PREFIX."alidata set max = $max where leader = $owner";
+ $database->query($q);
+ }
+ }
+ if(($jobs['field'] >= 19 && ($session->tribe == 1 || ALLOW_ALL_TRIBE)) || (!ALLOW_ALL_TRIBE && $session->tribe != 1)) { $innertimestamp = $jobs['timestamp']; }
+ }
+ }
+ }
+ }
+ $wwvillage1 = $database->getResourceLevel($village->wid);
+ if($wwvillage1['f99t']!=40){
+ $ww = 0;
+ }
+ if($ww == 0){
+ $database->finishDemolition($village->wid);
+ $technology->finishTech();
+ $logging->goldFinLog($village->wid);
+ $database->modifyGold($session->uid,2,0);
+ $stillbuildingarray = $database->getJobs($village->wid);
+ if(count($stillbuildingarray) == 1) {
+ if($stillbuildingarray[0]['loopcon'] == 1) {
+ $q = "UPDATE ".TB_PREFIX."bdata SET loopcon=0,timestamp=".(time()+$stillbuildingarray[0]['timestamp']-$innertimestamp)." WHERE id=".$stillbuildingarray[0]['id'];
+ $database->query($q);
+ }
+ }
+ }
+ header("Location: ".$session->referrer);
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ public function resourceRequired($id,$tid,$plus=1) {
+ $name = "bid".$tid;
+ global $$name,$village,$bid15;
+ $dataarray = $$name;
+ $wood = $dataarray[$village->resarray['f'.$id]+$plus]['wood'];
+ $clay = $dataarray[$village->resarray['f'.$id]+$plus]['clay'];
+ $iron = $dataarray[$village->resarray['f'.$id]+$plus]['iron'];
+ $crop = $dataarray[$village->resarray['f'.$id]+$plus]['crop'];
+ $pop = $dataarray[$village->resarray['f'.$id]+$plus]['pop'];
+ if ($tid == 15) {
+ if($this->getTypeLevel(15) == 0) {
+ $time = round($dataarray[$village->resarray['f'.$id]+$plus]['time']/ SPEED *5);
+ }
+ else {
+ $time = round($dataarray[$village->resarray['f'.$id]+$plus]['time'] / SPEED);
+ }
+ }
+ else {
+ if($this->getTypeLevel(15) != 0) {
+ $time = round($dataarray[$village->resarray['f'.$id]+$plus]['time'] * ($bid15[$this->getTypeLevel(15)]['attri']/100) / SPEED);
+ }
+ else {
+ $time = round($dataarray[$village->resarray['f'.$id]+$plus]['time']*5 / SPEED);
+ }
+ }
+ $cp = $dataarray[$village->resarray['f'.$id]+$plus]['cp'];
+ return array("wood"=>$wood,"clay"=>$clay,"iron"=>$iron,"crop"=>$crop,"pop"=>$pop,"time"=>$time,"cp"=>$cp);
+ }
+
+ public function getTypeField($type) {
+ global $village;
+ for($i=19;$i<=40;$i++) {
+ if($village->resarray['f'.$i.'t'] == $type) {
+ return $i;
+ }
+ }
+ }
+
+ public function calculateAvaliable($id,$tid,$plus=1) {
+ global $village,$generator;
+ $uprequire = $this->resourceRequired($id,$tid,$plus);
+ $rwood = $uprequire['wood']-$village->awood;
+ $rclay = $uprequire['clay']-$village->aclay;
+ $rcrop = $uprequire['crop']-$village->acrop;
+ $riron = $uprequire['iron']-$village->airon;
+ $rwtime = $rwood / $village->getProd("wood") * 3600;
+ $rcltime = $rclay / $village->getProd("clay")* 3600;
+ $rctime = $rcrop / $village->getProd("crop")* 3600;
+ $ritime = $riron / $village->getProd("iron")* 3600;
+ $reqtime = max($rwtime,$rctime,$rcltime,$ritime);
+ $reqtime += time();
+ return $generator->procMtime($reqtime);
+ }
+};
+
+?>
\ No newline at end of file
diff --git a/GameEngine/Chat.php b/GameEngine/Chat.php
new file mode 100644
index 00000000..67b0c0ab
--- /dev/null
+++ b/GameEngine/Chat.php
@@ -0,0 +1,384 @@
+$v) {
+ $esc_key = sajax_esc($k);
+ if (is_numeric($k))
+ $s .= "$k: " . sajax_get_js_repr($v) . ", ";
+ else
+ $s .= "\"$esc_key\": " . sajax_get_js_repr($v) . ", ";
+ }
+ if (count($value))
+ $s = substr($s, 0, -2);
+ return $s . " }";
+ }
+ else {
+ $esc_val = sajax_esc($value);
+ $s = "'$esc_val'";
+ return $s;
+ }
+ }
+
+ function sajax_handle_client_request() {
+ global $sajax_export_list;
+
+ $mode = "";
+
+ if (! empty($_GET["rs"]))
+ $mode = "get";
+
+ if (!empty($_POST["rs"]))
+ $mode = "post";
+
+ if (empty($mode))
+ return;
+
+ $target = "";
+
+ if ($mode == "get") {
+
+ header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+ header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+
+ header ("Cache-Control: no-cache, must-revalidate");
+ header ("Pragma: no-cache");
+ $func_name = $_GET["rs"];
+ if (! empty($_GET["rsargs"]))
+ $args = $_GET["rsargs"];
+ else
+ $args = array();
+ }
+ else {
+ $func_name = $_POST["rs"];
+ if (! empty($_POST["rsargs"]))
+ $args = $_POST["rsargs"];
+ else
+ $args = array();
+ }
+
+ if (! in_array($func_name, $sajax_export_list))
+ echo "-:$func_name not callable";
+ else {
+ echo "+:";
+ $result = call_user_func_array($func_name, $args);
+ echo "var res = " . trim(sajax_get_js_repr($result)) . "; res;";
+ }
+ exit;
+ }
+
+ function sajax_get_common_js() {
+ global $sajax_debug_mode;
+ global $sajax_request_type;
+ global $sajax_remote_uri;
+ global $sajax_failure_redirect;
+
+ $t = strtoupper($sajax_request_type);
+ if ($t != "" && $t != "GET" && $t != "POST")
+ return "// Invalid type: $t.. \n\n";
+
+ ob_start();
+ ?>
+
+ // remote scripting library
+ // (c) copyright 2005 modernmethod, inc
+ // edited by ttmtt
+ var sajax_debug_mode = ;
+ var sajax_request_type = "";
+ var sajax_target_id = "";
+ var sajax_failure_redirect = "";
+
+ function sajax_debug(text) {
+ if (sajax_debug_mode)
+ alert(text);
+ }
+
+ function sajax_init_object() {
+ sajax_debug("sajax_init_object() called..")
+
+ var A;
+
+ var msxmlhttp = new Array(
+ 'Msxml2.XMLHTTP.5.0',
+ 'Msxml2.XMLHTTP.4.0',
+ 'Msxml2.XMLHTTP.3.0',
+ 'Msxml2.XMLHTTP',
+ 'Microsoft.XMLHTTP');
+ for (var i = 0; i < msxmlhttp.length; i++) {
+ try {
+ A = new ActiveXObject(msxmlhttp[i]);
+ } catch (e) {
+ A = null;
+ }
+ }
+
+ if(!A && typeof XMLHttpRequest != "undefined")
+ A = new XMLHttpRequest();
+ if (!A)
+ sajax_debug("Could not create connection object.");
+ return A;
+ }
+
+ var sajax_requests = new Array();
+
+ function sajax_cancel() {
+ for (var i = 0; i < sajax_requests.length; i++)
+ sajax_requests[i].abort();
+ }
+
+ function sajax_do_call(func_name, args) {
+ var i, x, n;
+ var uri;
+ var post_data;
+ var target_id;
+
+ sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id);
+ target_id = sajax_target_id;
+ if (typeof(sajax_request_type) == "undefined" || sajax_request_type == "")
+ sajax_request_type = "GET";
+
+ uri = "";
+ if (sajax_request_type == "GET") {
+// alert(args);
+ if (uri.indexOf("?") == -1)
+ uri += "?rs=" + escape(func_name);
+ else
+ uri += "&rs=" + escape(func_name);
+ uri += "&rst=" + escape(sajax_target_id);
+ uri += "&rsrnd=" + new Date().getTime();
+
+ for (i = 0; i < args.length-1; i++) {
+ uri += "&rsargs[]=" + args[i];
+ }
+ post_data = null;
+ }
+ else if (sajax_request_type == "POST") {
+ post_data = "rs=" + escape(func_name);
+ post_data += "&rst=" + escape(sajax_target_id);
+ post_data += "&rsrnd=" + new Date().getTime();
+
+ for (i = 0; i < args.length-1; i++)
+ post_data = post_data + "&rsargs[]=" + escape(args[i]);
+ }
+ else {
+ alert("Illegal request type: " + sajax_request_type);
+ }
+
+ x = sajax_init_object();
+ if (x == null) {
+ if (sajax_failure_redirect != "") {
+ location.href = sajax_failure_redirect;
+ return false;
+ } else {
+ sajax_debug("NULL sajax object for user agent:\n" + navigator.userAgent);
+ return false;
+ }
+ } else {
+ x.open(sajax_request_type, uri, true);
+ // window.open(uri);
+
+ sajax_requests[sajax_requests.length] = x;
+
+ if (sajax_request_type == "POST") {
+ x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
+ x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+
+ x.onreadystatechange = function() {
+ if (x.readyState != 4)
+ return;
+
+ sajax_debug("received " + x.responseText);
+
+ var status;
+ var data;
+ var txt = x.responseText.replace(/^\s*|\s*$/g,"");
+ status = txt.charAt(0);
+ data = txt.substring(2);
+
+ if (status == "") {
+ // let's just assume this is a pre-response bailout and let it slide for now
+ } else if (status == "-")
+ alert("Error: " + data);
+ else {
+ if (target_id != "")
+ document.getElementById(target_id).innerHTML = eval(data);
+ else {
+ try {
+ var callback;
+ var extra_data = false;
+ if (typeof args[args.length-1] == "object") {
+ callback = args[args.length-1].callback;
+ extra_data = args[args.length-1].extra_data;
+ } else {
+ callback = args[args.length-1];
+ }
+ callback(eval(data), extra_data);
+ } catch (e) {
+ sajax_debug("Caught error " + e + ": Could not eval " + data );
+ }
+ }
+ }
+ }
+ }
+
+ sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
+ x.send(post_data);
+ sajax_debug(func_name + " waiting..");
+ delete x;
+ return true;
+ }
+
+
+
+ // wrapper for
+
+ function x_() {
+ sajax_do_call("",
+ x_.arguments);
+ }
+
+ username;
+
+ $id_user = $session->uid;
+ $alliance = $session->alliance;
+ $now = time();
+ echo $q = "INSERT into ".TB_PREFIX."chat (id_user,name,alli,date,msg) values ('$id_user','$name','$alliance','$now','$msg')";
+ mysql_query($q, $database->connection);
+ }
+
+ function get_data() {
+ global $session,$database;
+
+ $alliance = $session->alliance;
+ $query = mysql_query("select * from ".TB_PREFIX."chat where alli='$alliance' order by id desc limit 0,13");
+ while ($r = mysql_fetch_array($query)) {
+ $dates = date("g:i",$r[date]);
+ $data .= "[{$dates}] {$r['name']}: {$r[msg]}
";
+ }
+ return $data;
+ }
+
+ $sajax_request_type = "GET";
+ sajax_init();
+ sajax_export("add_data","get_data");
+ sajax_handle_client_request();
+
+?>
\ No newline at end of file
diff --git a/GameEngine/Data/buidata.php b/GameEngine/Data/buidata.php
new file mode 100644
index 00000000..4d58b766
--- /dev/null
+++ b/GameEngine/Data/buidata.php
@@ -0,0 +1,55 @@
+2),array('wood'=>40,'clay'=>100,'iron'=>50,'crop'=>60,'pop'=>2,'cp'=>1,'prod'=>5,'time'=>260),array('wood'=>65,'clay'=>165,'iron'=>85,'crop'=>100,'pop'=>1,'cp'=>1,'prod'=>9,'time'=>620),array('wood'=>110,'clay'=>280,'iron'=>140,'crop'=>165,'pop'=>1,'cp'=>2,'prod'=>15,'time'=>1190),array('wood'=>185,'clay'=>465,'iron'=>235,'crop'=>280,'pop'=>1,'cp'=>2,'prod'=>22,'time'=>2100),array('wood'=>310,'clay'=>780,'iron'=>390,'crop'=>465,'pop'=>1,'cp'=>2,'prod'=>33,'time'=>3560),array('wood'=>520,'clay'=>1300,'iron'=>650,'crop'=>780,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>5890),array('wood'=>870,'clay'=>2170,'iron'=>1085,'crop'=>1300,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>9620),array('wood'=>1450,'clay'=>3625,'iron'=>1810,'crop'=>2175,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>15590),array('wood'=>2420,'clay'=>6050,'iron'=>3025,'crop'=>3630,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>25150),array('wood'=>4040,'clay'=>10105,'iron'=>5050,'crop'=>6060,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>40440),array('wood'=>6750,'clay'=>16870,'iron'=>8435,'crop'=>10125,'pop'=>2,'cp'=>7,'prod'=>280,'time'=>64900),array('wood'=>11270,'clay'=>28175,'iron'=>14090,'crop'=>16905,'pop'=>2,'cp'=>9,'prod'=>375,'time'=>104050),array('wood'=>18820,'clay'=>47055,'iron'=>23525,'crop'=>28230,'pop'=>2,'cp'=>11,'prod'=>495,'time'=>166680),array('wood'=>31430,'clay'=>78580,'iron'=>39290,'crop'=>47150,'pop'=>2,'cp'=>13,'prod'=>635,'time'=>266880),array('wood'=>52490,'clay'=>131230,'iron'=>65615,'crop'=>78740,'pop'=>2,'cp'=>15,'prod'=>800,'time'=>427210),array('wood'=>87660,'clay'=>219155,'iron'=>109575,'crop'=>131490,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>683730),array('wood'=>146395,'clay'=>365985,'iron'=>182995,'crop'=>219590,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>1094170),array('wood'=>244480,'clay'=>611195,'iron'=>305600,'crop'=>366715,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>1750880),array('wood'=>408280,'clay'=>1020695,'iron'=>510350,'crop'=>612420,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>2801600),array('wood'=>681825,'clay'=>1704565,'iron'=>852280,'crop'=>1022740,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>4482770));
+$bid2=array(array('prod'=>2),array('wood'=>80,'clay'=>40,'iron'=>80,'crop'=>50,'pop'=>2,'cp'=>1,'prod'=>5,'time'=>220),array('wood'=>135,'clay'=>65,'iron'=>135,'crop'=>85,'pop'=>1,'cp'=>1,'prod'=>9,'time'=>550),array('wood'=>225,'clay'=>110,'iron'=>225,'crop'=>140,'pop'=>1,'cp'=>2,'prod'=>15,'time'=>1080),array('wood'=>375,'clay'=>185,'iron'=>375,'crop'=>235,'pop'=>1,'cp'=>2,'prod'=>22,'time'=>1930),array('wood'=>620,'clay'=>310,'iron'=>620,'crop'=>390,'pop'=>1,'cp'=>2,'prod'=>33,'time'=>3290),array('wood'=>1040,'clay'=>520,'iron'=>1040,'crop'=>650,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>5470),array('wood'=>1735,'clay'=>870,'iron'=>1735,'crop'=>1085,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>8950),array('wood'=>2900,'clay'=>1450,'iron'=>2900,'crop'=>1810,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>14520),array('wood'=>4840,'clay'=>2420,'iron'=>4840,'crop'=>3025,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>23430),array('wood'=>8080,'clay'=>4040,'iron'=>8080,'crop'=>5050,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>37690),array('wood'=>13500,'clay'=>6750,'iron'=>13500,'crop'=>8435,'pop'=>2,'cp'=>7,'prod'=>280,'time'=>60510),array('wood'=>22540,'clay'=>11270,'iron'=>22540,'crop'=>14090,'pop'=>2,'cp'=>9,'prod'=>375,'time'=>97010),array('wood'=>37645,'clay'=>18820,'iron'=>37645,'crop'=>23525,'pop'=>2,'cp'=>11,'prod'=>495,'time'=>155420),array('wood'=>62865,'clay'=>31430,'iron'=>62865,'crop'=>39290,'pop'=>2,'cp'=>13,'prod'=>635,'time'=>248870),array('wood'=>104985,'clay'=>52490,'iron'=>104985,'crop'=>65615,'pop'=>2,'cp'=>15,'prod'=>800,'time'=>398390),array('wood'=>175320,'clay'=>87660,'iron'=>175320,'crop'=>109575,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>637620),array('wood'=>292790,'clay'=>146395,'iron'=>292790,'crop'=>182995,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>1020390),array('wood'=>488955,'clay'=>244480,'iron'=>488955,'crop'=>305600,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>1632820),array('wood'=>816555,'clay'=>408280,'iron'=>816555,'crop'=>510350,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>2612710),array('wood'=>1363650,'clay'=>681825,'iron'=>1363650,'crop'=>852280,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>4180540));
+$bid3=array(array('prod'=>2),array('wood'=>100,'clay'=>80,'iron'=>30,'crop'=>60,'pop'=>3,'cp'=>1,'prod'=>5,'time'=>450),array('wood'=>165,'clay'=>135,'iron'=>50,'crop'=>100,'pop'=>2,'cp'=>1,'prod'=>9,'time'=>920),array('wood'=>280,'clay'=>225,'iron'=>85,'crop'=>165,'pop'=>2,'cp'=>2,'prod'=>15,'time'=>1670),array('wood'=>465,'clay'=>375,'iron'=>140,'crop'=>280,'pop'=>2,'cp'=>2,'prod'=>22,'time'=>2880),array('wood'=>780,'clay'=>620,'iron'=>235,'crop'=>465,'pop'=>2,'cp'=>2,'prod'=>33,'time'=>4800),array('wood'=>1300,'clay'=>1040,'iron'=>390,'crop'=>780,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>7880),array('wood'=>2170,'clay'=>1735,'iron'=>650,'crop'=>1300,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>12810),array('wood'=>3625,'clay'=>2900,'iron'=>1085,'crop'=>2175,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>20690),array('wood'=>6050,'clay'=>4840,'iron'=>1815,'crop'=>3630,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>33310),array('wood'=>10105,'clay'=>8080,'iron'=>3030,'crop'=>6060,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>53500),array('wood'=>16870,'clay'=>13500,'iron'=>5060,'crop'=>10125,'pop'=>3,'cp'=>7,'prod'=>280,'time'=>85800),array('wood'=>28175,'clay'=>22540,'iron'=>8455,'crop'=>16905,'pop'=>3,'cp'=>9,'prod'=>375,'time'=>137470),array('wood'=>47055,'clay'=>37645,'iron'=>14115,'crop'=>28230,'pop'=>3,'cp'=>11,'prod'=>495,'time'=>220160),array('wood'=>78580,'clay'=>62865,'iron'=>23575,'crop'=>47150,'pop'=>3,'cp'=>13,'prod'=>635,'time'=>352450),array('wood'=>131230,'clay'=>104985,'iron'=>39370,'crop'=>78740,'pop'=>3,'cp'=>15,'prod'=>800,'time'=>564120),array('wood'=>219155,'clay'=>175320,'iron'=>65745,'crop'=>131490,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>902760),array('wood'=>365985,'clay'=>292790,'iron'=>109795,'crop'=>219590,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>145546),array('wood'=>611195,'clay'=>488955,'iron'=>183360,'crop'=>366715,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>2311660),array('wood'=>1020695,'clay'=>816555,'iron'=>306210,'crop'=>612420,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>3698850),array('wood'=>1704565,'clay'=>1363650,'iron'=>511370,'crop'=>1022740,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>5918370));
+$bid4=array(array('prod'=>2),array('wood'=>70,'clay'=>90,'iron'=>70,'crop'=>20,'pop'=>0,'cp'=>1,'prod'=>5,'time'=>150),array('wood'=>115,'clay'=>150,'iron'=>115,'crop'=>35,'pop'=>0,'cp'=>1,'prod'=>9,'time'=>440),array('wood'=>195,'clay'=>250,'iron'=>195,'crop'=>55,'pop'=>0,'cp'=>2,'prod'=>15,'time'=>900),array('wood'=>325,'clay'=>420,'iron'=>325,'crop'=>95,'pop'=>0,'cp'=>2,'prod'=>22,'time'=>1650),array('wood'=>545,'clay'=>700,'iron'=>545,'crop'=>155,'pop'=>0,'cp'=>2,'prod'=>33,'time'=>2830),array('wood'=>910,'clay'=>1170,'iron'=>910,'crop'=>260,'pop'=>1,'cp'=>3,'prod'=>50,'time'=>4730),array('wood'=>1520,'clay'=>1950,'iron'=>1520,'crop'=>435,'pop'=>1,'cp'=>4,'prod'=>70,'time'=>7780),array('wood'=>2535,'clay'=>3260,'iron'=>2535,'crop'=>725,'pop'=>1,'cp'=>4,'prod'=>100,'time'=>12190),array('wood'=>4235,'clay'=>5445,'iron'=>4235,'crop'=>1210,'pop'=>1,'cp'=>5,'prod'=>145,'time'=>19690),array('wood'=>7070,'clay'=>9095,'iron'=>7070,'crop'=>2020,'pop'=>1,'cp'=>6,'prod'=>200,'time'=>31700),array('wood'=>11810,'clay'=>15185,'iron'=>11810,'crop'=>3375,'pop'=>1,'cp'=>7,'prod'=>280,'time'=>50910),array('wood'=>19725,'clay'=>25360,'iron'=>19725,'crop'=>5635,'pop'=>1,'cp'=>9,'prod'=>375,'time'=>84700),array('wood'=>32940,'clay'=>42350,'iron'=>32940,'crop'=>9410,'pop'=>1,'cp'=>11,'prod'=>495,'time'=>135710),array('wood'=>55005,'clay'=>70720,'iron'=>55005,'crop'=>15715,'pop'=>1,'cp'=>13,'prod'=>635,'time'=>217340),array('wood'=>91860,'clay'=>118105,'iron'=>91860,'crop'=>26245,'pop'=>1,'cp'=>15,'prod'=>800,'time'=>347950),array('wood'=>153405,'clay'=>197240,'iron'=>153405,'crop'=>43830,'pop'=>2,'cp'=>18,'prod'=>1000,'time'=>556910),array('wood'=>256190,'clay'=>329385,'iron'=>256190,'crop'=>73195,'pop'=>2,'cp'=>22,'prod'=>1300,'time'=>891260),array('wood'=>427835,'clay'=>550075,'iron'=>427835,'crop'=>122240,'pop'=>2,'cp'=>27,'prod'=>1600,'time'=>1426210),array('wood'=>714485,'clay'=>918625,'iron'=>714485,'crop'=>204140,'pop'=>2,'cp'=>32,'prod'=>2000,'time'=>2282140),array('wood'=>1193195,'clay'=>1534105,'iron'=>1193195,'crop'=>340915,'pop'=>2,'cp'=>38,'prod'=>2450,'time'=>3651630));
+$bid5=array(1=>array('wood'=>520,'clay'=>380,'iron'=>290,'crop'=>90,'pop'=>4,'cp'=>1,'attri'=>5,'time'=>3000),array('wood'=>935,'clay'=>685,'iron'=>520,'crop'=>160,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>5700),array('wood'=>1685,'clay'=>1230,'iron'=>940,'crop'=>290,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>9750),array('wood'=>3035,'clay'=>2215,'iron'=>1690,'crop'=>525,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>15830),array('wood'=>5460,'clay'=>3990,'iron'=>3045,'crop'=>945,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>24940));
+$bid6=array(1=>array('wood'=>440,'clay'=>480,'iron'=>320,'crop'=>50,'pop'=>3,'cp'=>1,'attri'=>5,'time'=>2240),array('wood'=>790,'clay'=>865,'iron'=>575,'crop'=>90,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>4560),array('wood'=>1425,'clay'=>1555,'iron'=>1035,'crop'=>160,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>8040),array('wood'=>2565,'clay'=>2800,'iron'=>1865,'crop'=>290,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>13260),array('wood'=>4620,'clay'=>5040,'iron'=>3360,'crop'=>525,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>21090));
+$bid7=array(1=>array('wood'=>200,'clay'=>450,'iron'=>510,'crop'=>120,'pop'=>6,'cp'=>1,'attri'=>5,'time'=>4080),array('wood'=>360,'clay'=>810,'iron'=>920,'crop'=>215,'pop'=>3,'cp'=>1,'attri'=>10,'time'=>7320),array('wood'=>650,'clay'=>1460,'iron'=>1650,'crop'=>390,'pop'=>3,'cp'=>2,'attri'=>15,'time'=>12180),array('wood'=>1165,'clay'=>2625,'iron'=>2975,'crop'=>700,'pop'=>3,'cp'=>2,'attri'=>20,'time'=>19470),array('wood'=>2100,'clay'=>4725,'iron'=>5355,'crop'=>1260,'pop'=>3,'cp'=>2,'attri'=>25,'time'=>30410));
+$bid8=array(1=>array('wood'=>500,'clay'=>440,'iron'=>380,'crop'=>1240,'pop'=>3,'cp'=>1,'attri'=>5,'time'=>1840),array('wood'=>900,'clay'=>790,'iron'=>685,'crop'=>2230,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>3960),array('wood'=>1620,'clay'=>1425,'iron'=>1230,'crop'=>4020,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>7140),array('wood'=>2915,'clay'=>2565,'iron'=>2215,'crop'=>7230,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>11910),array('wood'=>5250,'clay'=>4620,'iron'=>3990,'crop'=>13015,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>19070));
+$bid9=array(1=>array('wood'=>1200,'clay'=>1480,'iron'=>870,'crop'=>1600,'pop'=>4,'cp'=>1,'attri'=>5,'time'=>3680),array('wood'=>2160,'clay'=>2665,'iron'=>1565,'crop'=>2880,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>6720),array('wood'=>3890,'clay'=>4795,'iron'=>2820,'crop'=>5185,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>11280),array('wood'=>7000,'clay'=>8630,'iron'=>5075,'crop'=>9330,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>18120),array('wood'=>12595,'clay'=>15535,'iron'=>9135,'crop'=>16795,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>28380));
+$bid10=array(1=>array('wood'=>130,'clay'=>160,'iron'=>90,'crop'=>40,'pop'=>1,'cp'=>1,'attri'=>1200,'time'=>2000),array('wood'=>165,'clay'=>205,'iron'=>115,'crop'=>50,'pop'=>1,'cp'=>1,'attri'=>1700,'time'=>2620),array('wood'=>215,'clay'=>260,'iron'=>145,'crop'=>65,'pop'=>1,'cp'=>2,'attri'=>2300,'time'=>3340),array('wood'=>275,'clay'=>335,'iron'=>190,'crop'=>85,'pop'=>1,'cp'=>2,'attri'=>3100,'time'=>4170),array('wood'=>350,'clay'=>430,'iron'=>240,'crop'=>105,'pop'=>1,'cp'=>2,'attri'=>4000,'time'=>5140),array('wood'=>445,'clay'=>550,'iron'=>310,'crop'=>135,'pop'=>1,'cp'=>3,'attri'=>5000,'time'=>6260),array('wood'=>570,'clay'=>705,'iron'=>395,'crop'=>175,'pop'=>1,'cp'=>4,'attri'=>6300,'time'=>7570),array('wood'=>730,'clay'=>900,'iron'=>505,'crop'=>225,'pop'=>1,'cp'=>4,'attri'=>7800,'time'=>9080),array('wood'=>935,'clay'=>1115,'iron'=>650,'crop'=>290,'pop'=>1,'cp'=>5,'attri'=>9600,'time'=>10830),array('wood'=>1200,'clay'=>1475,'iron'=>830,'crop'=>370,'pop'=>1,'cp'=>6,'attri'=>11800,'time'=>12860),array('wood'=>1535,'clay'=>1890,'iron'=>1065,'crop'=>470,'pop'=>2,'cp'=>7,'attri'=>14400,'time'=>15220),array('wood'=>1965,'clay'=>2420,'iron'=>1360,'crop'=>605,'pop'=>2,'cp'=>9,'attri'=>17600,'time'=>17950),array('wood'=>2515,'clay'=>3095,'iron'=>1740,'crop'=>775,'pop'=>2,'cp'=>11,'attri'=>21400,'time'=>21130),array('wood'=>3220,'clay'=>3960,'iron'=>2230,'crop'=>990,'pop'=>2,'cp'=>13,'attri'=>25900,'time'=>24810),array('wood'=>4120,'clay'=>5070,'iron'=>2850,'crop'=>1270,'pop'=>2,'cp'=>15,'attri'=>31300,'time'=>29080),array('wood'=>5275,'clay'=>6490,'iron'=>3650,'crop'=>1625,'pop'=>2,'cp'=>18,'attri'=>37900,'time'=>34030),array('wood'=>6750,'clay'=>8310,'iron'=>4675,'crop'=>2075,'pop'=>2,'cp'=>22,'attri'=>45700,'time'=>39770),array('wood'=>8640,'clay'=>10635,'iron'=>5980,'crop'=>2660,'pop'=>2,'cp'=>27,'attri'=>55100,'time'=>46440),array('wood'=>11060,'clay'=>13610,'iron'=>7655,'crop'=>3405,'pop'=>2,'cp'=>32,'attri'=>66400,'time'=>54170),array('wood'=>14155,'clay'=>17420,'iron'=>9800,'crop'=>4355,'pop'=>2,'cp'=>38,'attri'=>80000,'time'=>63130));
+$bid11=array(1=>array('wood'=>80,'clay'=>100,'iron'=>70,'crop'=>20,'pop'=>1,'cp'=>1,'attri'=>1200,'time'=>1600),array('wood'=>100,'clay'=>130,'iron'=>90,'crop'=>25,'pop'=>1,'cp'=>1,'attri'=>1700,'time'=>2160),array('wood'=>130,'clay'=>165,'iron'=>115,'crop'=>35,'pop'=>1,'cp'=>2,'attri'=>2300,'time'=>2800),array('wood'=>170,'clay'=>210,'iron'=>145,'crop'=>40,'pop'=>1,'cp'=>2,'attri'=>3100,'time'=>3550),array('wood'=>215,'clay'=>270,'iron'=>190,'crop'=>55,'pop'=>1,'cp'=>2,'attri'=>4000,'time'=>4420),array('wood'=>275,'clay'=>345,'iron'=>240,'crop'=>70,'pop'=>1,'cp'=>3,'attri'=>5000,'time'=>5420),array('wood'=>350,'clay'=>440,'iron'=>310,'crop'=>90,'pop'=>1,'cp'=>4,'attri'=>6300,'time'=>6590),array('wood'=>450,'clay'=>565,'iron'=>395,'crop'=>115,'pop'=>1,'cp'=>4,'attri'=>7800,'time'=>7950),array('wood'=>575,'clay'=>720,'iron'=>505,'crop'=>145,'pop'=>1,'cp'=>5,'attri'=>9600,'time'=>9520),array('wood'=>740,'clay'=>920,'iron'=>645,'crop'=>185,'pop'=>1,'cp'=>6,'attri'=>11800,'time'=>11340),array('wood'=>945,'clay'=>1180,'iron'=>825,'crop'=>235,'pop'=>2,'cp'=>7,'attri'=>14400,'time'=>13450),array('wood'=>1210,'clay'=>1510,'iron'=>1060,'crop'=>300,'pop'=>2,'cp'=>9,'attri'=>17600,'time'=>15910),array('wood'=>1545,'clay'=>1935,'iron'=>1355,'crop'=>385,'pop'=>2,'cp'=>11,'attri'=>21400,'time'=>18750),array('wood'=>1980,'clay'=>2475,'iron'=>1735,'crop'=>495,'pop'=>2,'cp'=>13,'attri'=>25900,'time'=>22050),array('wood'=>2535,'clay'=>3170,'iron'=>2220,'crop'=>635,'pop'=>2,'cp'=>15,'attri'=>31300,'time'=>25880),array('wood'=>3245,'clay'=>4055,'iron'=>2840,'crop'=>810,'pop'=>2,'cp'=>18,'attri'=>37900,'time'=>30320),array('wood'=>4155,'clay'=>5190,'iron'=>3635,'crop'=>1040,'pop'=>2,'cp'=>22,'attri'=>45700,'time'=>35470),array('wood'=>5315,'clay'=>6645,'iron'=>4650,'crop'=>1330,'pop'=>2,'cp'=>27,'attri'=>55100,'time'=>41450),array('wood'=>6805,'clay'=>8505,'iron'=>5955,'crop'=>1700,'pop'=>2,'cp'=>32,'attri'=>66400,'time'=>48380),array('wood'=>8710,'clay'=>10890,'iron'=>7620,'crop'=>2180,'pop'=>2,'cp'=>38,'attri'=>80000,'time'=>56420));
+$bid12=array(1=>array('wood'=>170,'clay'=>200,'iron'=>380,'crop'=>130,'pop'=>4,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>220,'clay'=>255,'iron'=>485,'crop'=>165,'pop'=>2,'cp'=>3,'attri'=>96.4,'time'=>2620),array('wood'=>280,'clay'=>330,'iron'=>625,'crop'=>215,'pop'=>2,'cp'=>3,'attri'=>92.93,'time'=>3340),array('wood'=>355,'clay'=>420,'iron'=>795,'crop'=>275,'pop'=>2,'cp'=>4,'attri'=>89.58,'time'=>4170),array('wood'=>455,'clay'=>535,'iron'=>1020,'crop'=>350,'pop'=>2,'cp'=>5,'attri'=>86.36,'time'=>5140),array('wood'=>585,'clay'=>685,'iron'=>1305,'crop'=>445,'pop'=>3,'cp'=>6,'attri'=>83.25,'time'=>6260),array('wood'=>750,'clay'=>880,'iron'=>1670,'crop'=>570,'pop'=>3,'cp'=>7,'attri'=>80.25,'time'=>7570),array('wood'=>955,'clay'=>1125,'iron'=>2140,'crop'=>730,'pop'=>3,'cp'=>9,'attri'=>77.36,'time'=>9080),array('wood'=>1225,'clay'=>1440,'iron'=>2740,'crop'=>935,'pop'=>3,'cp'=>10,'attri'=>74.58,'time'=>10830),array('wood'=>1570,'clay'=>1845,'iron'=>3505,'crop'=>1200,'pop'=>3,'cp'=>12,'attri'=>71.89,'time'=>12860),array('wood'=>2005,'clay'=>2360,'iron'=>4485,'crop'=>1535,'pop'=>3,'cp'=>15,'attri'=>69.31,'time'=>15220),array('wood'=>2570,'clay'=>3020,'iron'=>5740,'crop'=>1965,'pop'=>3,'cp'=>18,'attri'=>66.81,'time'=>17950),array('wood'=>3290,'clay'=>3870,'iron'=>7350,'crop'=>2515,'pop'=>3,'cp'=>21,'attri'=>64.41,'time'=>21130),array('wood'=>4210,'clay'=>4950,'iron'=>9410,'crop'=>3220,'pop'=>3,'cp'=>26,'attri'=>62.09,'time'=>24810),array('wood'=>5390,'clay'=>6340,'iron'=>12045,'crop'=>4120,'pop'=>3,'cp'=>31,'attri'=>59.85,'time'=>29080),array('wood'=>6895,'clay'=>8115,'iron'=>15415,'crop'=>5275,'pop'=>4,'cp'=>37,'attri'=>57.70,'time'=>34030),array('wood'=>8825,'clay'=>10385,'iron'=>19730,'crop'=>6750,'pop'=>4,'cp'=>44,'attri'=>55.62,'time'=>39770),array('wood'=>11300,'clay'=>13290,'iron'=>25255,'crop'=>8640,'pop'=>4,'cp'=>53,'attri'=>53.62,'time'=>46440),array('wood'=>14460,'clay'=>17015,'iron'=>32325,'crop'=>11060,'pop'=>4,'cp'=>64,'attri'=>51.69,'time'=>54170),array('wood'=>18510,'clay'=>21780,'iron'=>41380,'crop'=>14155,'pop'=>4,'cp'=>77,'attri'=>49.83,'time'=>63130));
+$bid13=array(1=>array('wood'=>130,'clay'=>210,'iron'=>410,'crop'=>130,'pop'=>4,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>165,'clay'=>270,'iron'=>525,'crop'=>165,'pop'=>2,'cp'=>3,'attri'=>96.4,'time'=>2620),array('wood'=>215,'clay'=>345,'iron'=>670,'crop'=>215,'pop'=>2,'cp'=>3,'attri'=>92.93,'time'=>3340),array('wood'=>275,'clay'=>440,'iron'=>860,'crop'=>275,'pop'=>2,'cp'=>4,'attri'=>89.58,'time'=>4170),array('wood'=>350,'clay'=>565,'iron'=>1100,'crop'=>350,'pop'=>2,'cp'=>5,'attri'=>86.36,'time'=>5140),array('wood'=>445,'clay'=>720,'iron'=>1410,'crop'=>445,'pop'=>3,'cp'=>6,'attri'=>83.25,'time'=>6260),array('wood'=>570,'clay'=>925,'iron'=>1805,'crop'=>570,'pop'=>3,'cp'=>7,'attri'=>80.25,'time'=>7570),array('wood'=>730,'clay'=>1180,'iron'=>2310,'crop'=>730,'pop'=>3,'cp'=>9,'attri'=>77.36,'time'=>9080),array('wood'=>935,'clay'=>1515,'iron'=>2955,'crop'=>935,'pop'=>3,'cp'=>10,'attri'=>74.58,'time'=>10830),array('wood'=>1200,'clay'=>1935,'iron'=>3780,'crop'=>1200,'pop'=>3,'cp'=>12,'attri'=>71.89,'time'=>12860),array('wood'=>1535,'clay'=>2480,'iron'=>4840,'crop'=>1535,'pop'=>3,'cp'=>15,'attri'=>69.31,'time'=>15220),array('wood'=>1965,'clay'=>3175,'iron'=>6195,'crop'=>1965,'pop'=>3,'cp'=>18,'attri'=>66.81,'time'=>17950),array('wood'=>2515,'clay'=>4060,'iron'=>7930,'crop'=>2515,'pop'=>3,'cp'=>21,'attri'=>64.41,'time'=>21130),array('wood'=>3220,'clay'=>5200,'iron'=>10150,'crop'=>3220,'pop'=>3,'cp'=>26,'attri'=>62.09,'time'=>24810),array('wood'=>4120,'clay'=>6655,'iron'=>12995,'crop'=>4120,'pop'=>3,'cp'=>31,'attri'=>59.85,'time'=>29080),array('wood'=>5275,'clay'=>8520,'iron'=>16630,'crop'=>5275,'pop'=>4,'cp'=>37,'attri'=>57.70,'time'=>34030),array('wood'=>6750,'clay'=>10905,'iron'=>21290,'crop'=>6750,'pop'=>4,'cp'=>44,'attri'=>55.62,'time'=>39770),array('wood'=>8640,'clay'=>13955,'iron'=>27250,'crop'=>8640,'pop'=>4,'cp'=>53,'attri'=>53.62,'time'=>46440),array('wood'=>11060,'clay'=>17865,'iron'=>34880,'crop'=>11060,'pop'=>4,'cp'=>64,'attri'=>51.69,'time'=>54170),array('wood'=>14155,'clay'=>22865,'iron'=>44645,'crop'=>14155,'pop'=>4,'cp'=>77,'attri'=>49.83,'time'=>63130));
+$bid14=array(1=>array('wood'=>1750,'clay'=>2250,'iron'=>1530,'crop'=>240,'pop'=>1,'cp'=>1,'attri'=>110,'time'=>3500),array('wood'=>2240,'clay'=>2880,'iron'=>1960,'crop'=>305,'pop'=>1,'cp'=>1,'attri'=>120,'time'=>4360),array('wood'=>2865,'clay'=>3685,'iron'=>2505,'crop'=>395,'pop'=>1,'cp'=>2,'attri'=>130,'time'=>5360),array('wood'=>3670,'clay'=>4720,'iron'=>3210,'crop'=>505,'pop'=>1,'cp'=>2,'attri'=>140,'time'=>6510),array('wood'=>4700,'clay'=>6040,'iron'=>4105,'crop'=>645,'pop'=>1,'cp'=>2,'attri'=>150,'time'=>7860),array('wood'=>6015,'clay'=>7730,'iron'=>5255,'crop'=>825,'pop'=>1,'cp'=>3,'attri'=>160,'time'=>9410),array('wood'=>7695,'clay'=>9895,'iron'=>6730,'crop'=>1055,'pop'=>1,'cp'=>4,'attri'=>170,'time'=>11220),array('wood'=>9850,'clay'=>12665,'iron'=>8615,'crop'=>1350,'pop'=>1,'cp'=>4,'attri'=>180,'time'=>13320),array('wood'=>12610,'clay'=>16215,'iron'=>11025,'crop'=>1730,'pop'=>1,'cp'=>5,'attri'=>190,'time'=>15750),array('wood'=>16140,'clay'=>20755,'iron'=>14110,'crop'=>2215,'pop'=>1,'cp'=>6,'attri'=>200,'time'=>18570),array('wood'=>20660,'clay'=>26565,'iron'=>18065,'crop'=>2835,'pop'=>2,'cp'=>7,'attri'=>210,'time'=>21840),array('wood'=>26445,'clay'=>34000,'iron'=>23120,'crop'=>3625,'pop'=>2,'cp'=>9,'attri'=>220,'time'=>25630),array('wood'=>33850,'clay'=>43520,'iron'=>29595,'crop'=>4640,'pop'=>2,'cp'=>11,'attri'=>230,'time'=>30030),array('wood'=>43330,'clay'=>55705,'iron'=>37880,'crop'=>5940,'pop'=>2,'cp'=>13,'attri'=>240,'time'=>35140),array('wood'=>55460,'clay'=>71305,'iron'=>48490,'crop'=>7605,'pop'=>2,'cp'=>15,'attri'=>250,'time'=>41060),array('wood'=>70990,'clay'=>91270,'iron'=>62065,'crop'=>9735,'pop'=>2,'cp'=>18,'attri'=>260,'time'=>47930),array('wood'=>90865,'clay'=>116825,'iron'=>79440,'crop'=>12460,'pop'=>2,'cp'=>22,'attri'=>270,'time'=>55900),array('wood'=>116305,'clay'=>149540,'iron'=>101685,'crop'=>15950,'pop'=>2,'cp'=>27,'attri'=>280,'time'=>65140),array('wood'=>148875,'clay'=>191410,'iron'=>130160,'crop'=>20415,'pop'=>2,'cp'=>32,'attri'=>290,'time'=>75860),array('wood'=>190560,'clay'=>245005,'iron'=>166600,'crop'=>26135,'pop'=>2,'cp'=>38,'attri'=>300,'time'=>88300));
+$bid15=array(1=>array('wood'=>70,'clay'=>40,'iron'=>60,'crop'=>20,'pop'=>2,'cp'=>2,'attri'=>100,'time'=>2620),array('wood'=>90,'clay'=>50,'iron'=>75,'crop'=>25,'pop'=>1,'cp'=>3,'attri'=>96.4,'time'=>3220),array('wood'=>115,'clay'=>65,'iron'=>100,'crop'=>35,'pop'=>1,'cp'=>3,'attri'=>92.93,'time'=>3880),array('wood'=>145,'clay'=>85,'iron'=>125,'crop'=>40,'pop'=>1,'cp'=>4,'attri'=>89.58,'time'=>4610),array('wood'=>190,'clay'=>105,'iron'=>160,'crop'=>55,'pop'=>1,'cp'=>5,'attri'=>86.36,'time'=>5410),array('wood'=>240,'clay'=>135,'iron'=>205,'crop'=>70,'pop'=>2,'cp'=>6,'attri'=>83.25,'time'=>6300),array('wood'=>310,'clay'=>175,'iron'=>265,'crop'=>90,'pop'=>2,'cp'=>7,'attri'=>80.25,'time'=>7280),array('wood'=>395,'clay'=>225,'iron'=>340,'crop'=>115,'pop'=>2,'cp'=>9,'attri'=>77.36,'time'=>8380),array('wood'=>505,'clay'=>290,'iron'=>430,'crop'=>145,'pop'=>2,'cp'=>10,'attri'=>74.58,'time'=>9590),array('wood'=>645,'clay'=>370,'iron'=>555,'crop'=>185,'pop'=>2,'cp'=>12,'attri'=>71.89,'time'=>10940),array('wood'=>825,'clay'=>470,'iron'=>710,'crop'=>235,'pop'=>2,'cp'=>15,'attri'=>69.31,'time'=>12440),array('wood'=>1060,'clay'=>605,'iron'=>905,'crop'=>300,'pop'=>2,'cp'=>18,'attri'=>66.81,'time'=>14120),array('wood'=>1355,'clay'=>775,'iron'=>1160,'crop'=>385,'pop'=>2,'cp'=>21,'attri'=>64.41,'time'=>15980),array('wood'=>1735,'clay'=>990,'iron'=>1485,'crop'=>495,'pop'=>2,'cp'=>26,'attri'=>62.09,'time'=>18050),array('wood'=>2220,'clay'=>1270,'iron'=>1900,'crop'=>635,'pop'=>2,'cp'=>31,'attri'=>59.85,'time'=>20370),array('wood'=>2840,'clay'=>1625,'iron'=>2435,'crop'=>810,'pop'=>3,'cp'=>37,'attri'=>57.70,'time'=>22950),array('wood'=>3635,'clay'=>2075,'iron'=>3115,'crop'=>1040,'pop'=>3,'cp'=>44,'attri'=>55.62,'time'=>25830),array('wood'=>4650,'clay'=>2660,'iron'=>3990,'crop'=>1330,'pop'=>3,'cp'=>53,'attri'=>53.62,'time'=>29040),array('wood'=>5955,'clay'=>3405,'iron'=>5105,'crop'=>1700,'pop'=>3,'cp'=>64,'attri'=>51.69,'time'=>32630),array('wood'=>7620,'clay'=>4355,'iron'=>6535,'crop'=>2180,'pop'=>3,'cp'=>77,'attri'=>49.83,'time'=>32632));
+$bid16=array(1=>array('wood'=>110,'clay'=>160,'iron'=>90,'crop'=>70,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>670),array('wood'=>140,'clay'=>205,'iron'=>115,'crop'=>90,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>870),array('wood'=>180,'clay'=>260,'iron'=>145,'crop'=>115,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1110),array('wood'=>230,'clay'=>335,'iron'=>190,'crop'=>145,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1390),array('wood'=>295,'clay'=>430,'iron'=>240,'crop'=>190,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1710),array('wood'=>380,'clay'=>550,'iron'=>310,'crop'=>240,'pop'=>1,'cp'=>3,'attri'=>0,'time'=>2090),array('wood'=>485,'clay'=>705,'iron'=>395,'crop'=>310,'pop'=>1,'cp'=>4,'attri'=>0,'time'=>2520),array('wood'=>620,'clay'=>900,'iron'=>505,'crop'=>395,'pop'=>1,'cp'=>4,'attri'=>0,'time'=>3030),array('wood'=>795,'clay'=>1155,'iron'=>650,'crop'=>505,'pop'=>1,'cp'=>5,'attri'=>0,'time'=>3610),array('wood'=>1015,'clay'=>1475,'iron'=>830,'crop'=>645,'pop'=>1,'cp'=>6,'attri'=>0,'time'=>4290),array('wood'=>1300,'clay'=>1890,'iron'=>1065,'crop'=>825,'pop'=>2,'cp'=>7,'attri'=>0,'time'=>5070),array('wood'=>1660,'clay'=>2420,'iron'=>1360,'crop'=>1060,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>5980),array('wood'=>2130,'clay'=>3095,'iron'=>1740,'crop'=>1355,'pop'=>2,'cp'=>11,'attri'=>0,'time'=>7040),array('wood'=>2725,'clay'=>3960,'iron'=>2230,'crop'=>1735,'pop'=>2,'cp'=>13,'attri'=>0,'time'=>8270),array('wood'=>3485,'clay'=>5070,'iron'=>2850,'crop'=>2220,'pop'=>2,'cp'=>15,'attri'=>0,'time'=>9690),array('wood'=>4460,'clay'=>6490,'iron'=>3650,'crop'=>2840,'pop'=>2,'cp'=>18,'attri'=>0,'time'=>11340),array('wood'=>5710,'clay'=>8310,'iron'=>4675,'crop'=>3635,'pop'=>2,'cp'=>22,'attri'=>0,'time'=>13260),array('wood'=>7310,'clay'=>10635,'iron'=>5980,'crop'=>4650,'pop'=>2,'cp'=>27,'attri'=>0,'time'=>15480),array('wood'=>9360,'clay'=>13610,'iron'=>7655,'crop'=>5955,'pop'=>2,'cp'=>32,'attri'=>0,'time'=>18060),array('wood'=>11980,'clay'=>17420,'iron'=>9800,'crop'=>7620,'pop'=>2,'cp'=>38,'attri'=>0,'time'=>21040));
+$bid17=array(1=>array('wood'=>80,'clay'=>70,'iron'=>120,'crop'=>70,'pop'=>4,'cp'=>4,'attri'=>1,'time'=>1800),array('wood'=>100,'clay'=>90,'iron'=>155,'crop'=>90,'pop'=>2,'cp'=>4,'attri'=>2,'time'=>2390),array('wood'=>130,'clay'=>115,'iron'=>195,'crop'=>115,'pop'=>2,'cp'=>5,'attri'=>3,'time'=>3070),array('wood'=>170,'clay'=>145,'iron'=>250,'crop'=>145,'pop'=>2,'cp'=>6,'attri'=>4,'time'=>3860),array('wood'=>215,'clay'=>190,'iron'=>320,'crop'=>190,'pop'=>2,'cp'=>7,'attri'=>5,'time'=>4780),array('wood'=>275,'clay'=>240,'iron'=>410,'crop'=>240,'pop'=>3,'cp'=>9,'attri'=>6,'time'=>5840),array('wood'=>350,'clay'=>310,'iron'=>530,'crop'=>310,'pop'=>3,'cp'=>11,'attri'=>7,'time'=>7080),array('wood'=>450,'clay'=>395,'iron'=>675,'crop'=>395,'pop'=>3,'cp'=>13,'attri'=>8,'time'=>8510),array('wood'=>575,'clay'=>505,'iron'=>865,'crop'=>505,'pop'=>3,'cp'=>15,'attri'=>9,'time'=>10170),array('wood'=>740,'clay'=>645,'iron'=>1105,'crop'=>645,'pop'=>3,'cp'=>19,'attri'=>10,'time'=>12100),array('wood'=>945,'clay'=>825,'iron'=>1415,'crop'=>825,'pop'=>3,'cp'=>22,'attri'=>11,'time'=>14340),array('wood'=>1210,'clay'=>1060,'iron'=>1815,'crop'=>1060,'pop'=>3,'cp'=>27,'attri'=>12,'time'=>16930),array('wood'=>1545,'clay'=>1355,'iron'=>2320,'crop'=>1355,'pop'=>3,'cp'=>32,'attri'=>13,'time'=>19940),array('wood'=>1980,'clay'=>1735,'iron'=>2970,'crop'=>1735,'pop'=>3,'cp'=>39,'attri'=>14,'time'=>23430),array('wood'=>2535,'clay'=>2220,'iron'=>3805,'crop'=>2220,'pop'=>3,'cp'=>46,'attri'=>15,'time'=>27480),array('wood'=>3245,'clay'=>2840,'iron'=>4870,'crop'=>2840,'pop'=>4,'cp'=>55,'attri'=>16,'time'=>32180),array('wood'=>4155,'clay'=>3635,'iron'=>6230,'crop'=>3635,'pop'=>4,'cp'=>67,'attri'=>17,'time'=>37620),array('wood'=>5315,'clay'=>4650,'iron'=>7975,'crop'=>4650,'pop'=>4,'cp'=>80,'attri'=>18,'time'=>43940),array('wood'=>6805,'clay'=>5955,'iron'=>10210,'crop'=>5955,'pop'=>4,'cp'=>96,'attri'=>19,'time'=>51270),array('wood'=>8710,'clay'=>7620,'iron'=>13065,'crop'=>7620,'pop'=>4,'cp'=>115,'attri'=>20,'time'=>59780));
+$bid18=array(1=>array('wood'=>180,'clay'=>130,'iron'=>150,'crop'=>80,'pop'=>3,'cp'=>5,'attri'=>0,'time'=>2000),array('wood'=>230,'clay'=>165,'iron'=>190,'crop'=>100,'pop'=>2,'cp'=>6,'attri'=>0,'time'=>2620),array('wood'=>295,'clay'=>215,'iron'=>245,'crop'=>130,'pop'=>2,'cp'=>7,'attri'=>9,'time'=>3340),array('wood'=>375,'clay'=>275,'iron'=>315,'crop'=>170,'pop'=>2,'cp'=>8,'attri'=>12,'time'=>4170),array('wood'=>485,'clay'=>350,'iron'=>405,'crop'=>215,'pop'=>2,'cp'=>10,'attri'=>15,'time'=>5140),array('wood'=>620,'clay'=>445,'iron'=>515,'crop'=>275,'pop'=>2,'cp'=>12,'attri'=>18,'time'=>6260),array('wood'=>790,'clay'=>570,'iron'=>660,'crop'=>350,'pop'=>2,'cp'=>14,'attri'=>21,'time'=>7570),array('wood'=>1015,'clay'=>730,'iron'=>845,'crop'=>450,'pop'=>2,'cp'=>17,'attri'=>24,'time'=>9080),array('wood'=>1295,'clay'=>935,'iron'=>1080,'crop'=>575,'pop'=>2,'cp'=>21,'attri'=>27,'time'=>10830),array('wood'=>1660,'clay'=>1200,'iron'=>1385,'crop'=>740,'pop'=>2,'cp'=>25,'attri'=>30,'time'=>12860),array('wood'=>2125,'clay'=>1535,'iron'=>1770,'crop'=>945,'pop'=>3,'cp'=>30,'attri'=>33,'time'=>15220),array('wood'=>2720,'clay'=>1965,'iron'=>2265,'crop'=>1210,'pop'=>3,'cp'=>36,'attri'=>36,'time'=>17950),array('wood'=>3480,'clay'=>2515,'iron'=>2900,'crop'=>1545,'pop'=>3,'cp'=>43,'attri'=>39,'time'=>21130), array('wood'=>4455,'clay'=>3220,'iron'=>3715,'crop'=>1980,'pop'=>3,'cp'=>51,'attri'=>42,'time'=>24810),array('wood'=>5705,'clay'=>4120,'iron'=>4755,'crop'=>2535,'pop'=>3,'cp'=>62,'attri'=>45,'time'=>29080),array('wood'=>7300,'clay'=>5275,'iron'=>6085,'crop'=>3245,'pop'=>3,'cp'=>74,'attri'=>48,'time'=>34030),array('wood'=>9345,'clay'=>6750,'iron'=>7790,'crop'=>4155,'pop'=>3,'cp'=>89,'attri'=>51,'time'=>39770),array('wood'=>11965,'clay'=>8640,'iron'=>9970,'crop'=>5315,'pop'=>3,'cp'=>106,'attri'=>54,'time'=>46440),array('wood'=>15315,'clay'=>11060,'iron'=>12760,'crop'=>6805,'pop'=>3,'cp'=>128,'attri'=>57,'time'=>54170),array('wood'=>19600,'clay'=>14155,'iron'=>16335,'crop'=>8710,'pop'=>3,'cp'=>153,'attri'=>60,'time'=>63130));
+$bid19=array(1=>array('wood'=>210,'clay'=>140,'iron'=>260,'crop'=>120,'pop'=>4,'cp'=>1,'attri'=>100,'time'=>2000),array('wood'=>270,'clay'=>180,'iron'=>335,'crop'=>155,'pop'=>2,'cp'=>1,'attri'=>90,'time'=>2620),array('wood'=>345,'clay'=>230,'iron'=>425,'crop'=>195,'pop'=>2,'cp'=>2,'attri'=>81,'time'=>3340),array('wood'=>440,'clay'=>295,'iron'=>545,'crop'=>250,'pop'=>2,'cp'=>2,'attri'=>72.9,'time'=>4170),array('wood'=>565,'clay'=>375,'iron'=>700,'crop'=>320,'pop'=>2,'cp'=>2,'attri'=>65.61,'time'=>5140),array('wood'=>720,'clay'=>480,'iron'=>895,'crop'=>410,'pop'=>3,'cp'=>3,'attri'=>59.05,'time'=>6260),array('wood'=>925,'clay'=>615,'iron'=>1145,'crop'=>530,'pop'=>3,'cp'=>4,'attri'=>53.14,'time'=>7570),array('wood'=>1180,'clay'=>790,'iron'=>1465,'crop'=>675,'pop'=>3,'cp'=>4,'attri'=>47.83,'time'=>9080),array('wood'=>1515,'clay'=>1010,'iron'=>1875,'crop'=>865,'pop'=>3,'cp'=>5,'attri'=>43.05,'time'=>10830),array('wood'=>1935,'clay'=>1290,'iron'=>2400,'crop'=>1105,'pop'=>3,'cp'=>6,'attri'=>38.74,'time'=>12860),array('wood'=>2480,'clay'=>1655,'iron'=>3070,'crop'=>1415,'pop'=>3,'cp'=>7,'attri'=>34.87,'time'=>15220),array('wood'=>3175,'clay'=>2115,'iron'=>3930,'crop'=>1815,'pop'=>3,'cp'=>9,'attri'=>31.38,'time'=>17950),array('wood'=>4060,'clay'=>2710,'iron'=>5030,'crop'=>2320,'pop'=>3,'cp'=>11,'attri'=>28.24,'time'=>21130),array('wood'=>5200,'clay'=>3465,'iron'=>6435,'crop'=>2970,'pop'=>3,'cp'=>13,'attri'=>25.42,'time'=>24810),array('wood'=>6655,'clay'=>4435,'iron'=>8240,'crop'=>3805,'pop'=>3,'cp'=>15,'attri'=>22.88,'time'=>29080),array('wood'=>8520,'clay'=>5680,'iron'=>10545,'crop'=>4870,'pop'=>4,'cp'=>18,'attri'=>20.59,'time'=>34030),array('wood'=>10905,'clay'=>7270,'iron'=>13500,'crop'=>6230,'pop'=>4,'cp'=>22,'attri'=>18.53,'time'=>39770),array('wood'=>13955,'clay'=>9305,'iron'=>17280,'crop'=>7975,'pop'=>4,'cp'=>27,'attri'=>16.68,'time'=>46440),array('wood'=>17865,'clay'=>11910,'iron'=>22120,'crop'=>10210,'pop'=>4,'cp'=>32,'attri'=>15.01,'time'=>54170),array('wood'=>22865,'clay'=>15245,'iron'=>28310,'crop'=>13065,'pop'=>4,'cp'=>38,'attri'=>13.51,'time'=>63130));
+$bid20=array(1=>array('wood'=>260,'clay'=>140,'iron'=>220,'crop'=>100,'pop'=>5,'cp'=>2,'attri'=>100,'time'=>2200),array('wood'=>335,'clay'=>180,'iron'=>280,'crop'=>130,'pop'=>3,'cp'=>3,'attri'=>90,'time'=>2850),array('wood'=>425,'clay'=>230,'iron'=>360,'crop'=>165,'pop'=>3,'cp'=>3,'attri'=>81,'time'=>3610),array('wood'=>545,'clay'=>295,'iron'=>460,'crop'=>210,'pop'=>3,'cp'=>4,'attri'=>72.9,'time'=>4490),array('wood'=>700,'clay'=>375,'iron'=>590,'crop'=>270,'pop'=>3,'cp'=>5,'attri'=>65.61,'time'=>5500),array('wood'=>895,'clay'=>480,'iron'=>755,'crop'=>345,'pop'=>3,'cp'=>6,'attri'=>59.05,'time'=>6680),array('wood'=>1145,'clay'=>615,'iron'=>970,'crop'=>440,'pop'=>3,'cp'=>7,'attri'=>53.14,'time'=>8050),array('wood'=>1465,'clay'=>790,'iron'=>1240,'crop'=>565,'pop'=>3,'cp'=>9,'attri'=>47.83,'time'=>9640),array('wood'=>1875,'clay'=>1010,'iron'=>1585,'crop'=>720,'pop'=>3,'cp'=>10,'attri'=>43.05,'time'=>11480),array('wood'=>2400,'clay'=>1290,'iron'=>2030,'crop'=>920,'pop'=>3,'cp'=>12,'attri'=>38.74,'time'=>13620),array('wood'=>3070,'clay'=>1655,'iron'=>2595,'crop'=>1180,'pop'=>4,'cp'=>15,'attri'=>34.87,'time'=>16100),array('wood'=>3930,'clay'=>2115,'iron'=>3325,'crop'=>1510,'pop'=>4,'cp'=>18,'attri'=>31.38,'time'=>18980),array('wood'=>5030,'clay'=>2710,'iron'=>4255,'crop'=>1935,'pop'=>4,'cp'=>21,'attri'=>28.24,'time'=>22310),array('wood'=>6435,'clay'=>3465,'iron'=>5445,'crop'=>2475,'pop'=>4,'cp'=>26,'attri'=>25.42,'time'=>26180),array('wood'=>8240,'clay'=>4435,'iron'=>6970,'crop'=>3170,'pop'=>4,'cp'=>31,'attri'=>22.88,'time'=>30670),array('wood'=>10545,'clay'=>5680,'iron'=>8925,'crop'=>4055,'pop'=>4,'cp'=>37,'attri'=>20.59,'time'=>35880),array('wood'=>13500,'clay'=>7270,'iron'=>11425,'crop'=>5190,'pop'=>4,'cp'=>44,'attri'=>18.53,'time'=>41920),array('wood'=>17280,'clay'=>9305,'iron'=>14620,'crop'=>6645,'pop'=>4,'cp'=>53,'attri'=>16.68,'time'=>48930),array('wood'=>22120,'clay'=>11910,'iron'=>18715,'crop'=>8505,'pop'=>4,'cp'=>64,'attri'=>15.01,'time'=>57060),array('wood'=>28310,'clay'=>15245,'iron'=>23955,'crop'=>10890,'pop'=>4,'cp'=>77,'attri'=>13.51,'time'=>66490));
+$bid21=array(1=>array('wood'=>460,'clay'=>510,'iron'=>600,'crop'=>320,'pop'=>3,'cp'=>4,'attri'=>100,'time'=>3000),array('wood'=>590,'clay'=>655,'iron'=>770,'crop'=>410,'pop'=>2,'cp'=>4,'attri'=>90,'time'=>3780),array('wood'=>755,'clay'=>835,'iron'=>985,'crop'=>525,'pop'=>2,'cp'=>5,'attri'=>81,'time'=>4680),array('wood'=>965,'clay'=>1070,'iron'=>1260,'crop'=>670,'pop'=>2,'cp'=>6,'attri'=>72.9,'time'=>5730),array('wood'=>1235,'clay'=>1370,'iron'=>1610,'crop'=>860,'pop'=>2,'cp'=>7,'attri'=>65.61,'time'=>6950),array('wood'=>1580,'clay'=>1750,'iron'=>2060,'crop'=>1100,'pop'=>2,'cp'=>9,'attri'=>59.05,'time'=>8360),array('wood'=>2025,'clay'=>2245,'iron'=>2640,'crop'=>1405,'pop'=>2,'cp'=>11,'attri'=>53.14,'time'=>10000),array('wood'=>2590,'clay'=>2870,'iron'=>3380,'crop'=>1800,'pop'=>2,'cp'=>13,'attri'=>47.83,'time'=>11900),array('wood'=>3315,'clay'=>3675,'iron'=>4325,'crop'=>2305,'pop'=>2,'cp'=>15,'attri'=>43.05,'time'=>14110),array('wood'=>4245,'clay'=>4705,'iron'=>5535,'crop'=>2950,'pop'=>2,'cp'=>19,'attri'=>38.74,'time'=>16660),array('wood'=>5430,'clay'=>6020,'iron'=>7085,'crop'=>3780,'pop'=>3,'cp'=>22,'attri'=>34.87,'time'=>19630),array('wood'=>6950,'clay'=>7705,'iron'=>9065,'crop'=>4835,'pop'=>3,'cp'=>27,'attri'=>31.38,'time'=>23070),array('wood'=>8900,'clay'=>9865,'iron'=>11605,'crop'=>6190,'pop'=>3,'cp'=>32,'attri'=>28.24,'time'=>27060),array('wood'=>11390,'clay'=>12625,'iron'=>14855,'crop'=>7925,'pop'=>3,'cp'=>39,'attri'=>25.42,'time'=>31690),array('wood'=>14580,'clay'=>16165,'iron'=>19015,'crop'=>10140,'pop'=>3,'cp'=>46,'attri'=>22.88,'time'=>37060),array('wood'=>18660,'clay'=>20690,'iron'=>24340,'crop'=>12980,'pop'=>3,'cp'=>55,'attri'=>20.59,'time'=>43290),array('wood'=>23885,'clay'=>26480,'iron'=>31155,'crop'=>16615,'pop'=>3,'cp'=>67,'attri'=>18.53,'time'=>50520),array('wood'=>30570,'clay'=>33895,'iron'=>39875,'crop'=>21270,'pop'=>3,'cp'=>80,'attri'=>16.68,'time'=>58900),array('wood'=>39130,'clay'=>43385,'iron'=>51040,'crop'=>27225,'pop'=>3,'cp'=>96,'attri'=>15.01,'time'=>68630),array('wood'=>50090,'clay'=>55535,'iron'=>65335,'crop'=>34845,'pop'=>3,'cp'=>115,'attri'=>13.51,'time'=>79910));
+$bid22=array(1=>array('wood'=>220,'clay'=>160,'iron'=>90,'crop'=>40,'pop'=>4,'cp'=>5,'attri'=>100,'time'=>2000),array('wood'=>280,'clay'=>205,'iron'=>115,'crop'=>50,'pop'=>2,'cp'=>6,'attri'=>96.4,'time'=>2620),array('wood'=>360,'clay'=>260,'iron'=>145,'crop'=>65,'pop'=>2,'cp'=>7,'attri'=>92.93,'time'=>3340),array('wood'=>460,'clay'=>335,'iron'=>190,'crop'=>85,'pop'=>2,'cp'=>8,'attri'=>89.58,'time'=>4170),array('wood'=>590,'clay'=>430,'iron'=>240,'crop'=>105,'pop'=>2,'cp'=>10,'attri'=>86.36,'time'=>5140),array('wood'=>755,'clay'=>550,'iron'=>310,'crop'=>135,'pop'=>3,'cp'=>12,'attri'=>83.25,'time'=>6260),array('wood'=>970,'clay'=>705,'iron'=>395,'crop'=>175,'pop'=>3,'cp'=>14,'attri'=>80.25,'time'=>7570),array('wood'=>1240,'clay'=>900,'iron'=>505,'crop'=>225,'pop'=>3,'cp'=>17,'attri'=>77.36,'time'=>9080),array('wood'=>1585,'clay'=>1155,'iron'=>650,'crop'=>290,'pop'=>3,'cp'=>21,'attri'=>74.58,'time'=>10830),array('wood'=>2030,'clay'=>1475,'iron'=>830,'crop'=>370,'pop'=>3,'cp'=>25,'attri'=>71.89,'time'=>12860),array('wood'=>2595,'clay'=>1890,'iron'=>1065,'crop'=>470,'pop'=>3,'cp'=>30,'attri'=>69.31,'time'=>15220),array('wood'=>3325,'clay'=>2420,'iron'=>1360,'crop'=>605,'pop'=>3,'cp'=>36,'attri'=>66.81,'time'=>17950),array('wood'=>4255,'clay'=>3095,'iron'=>1740,'crop'=>775,'pop'=>3,'cp'=>43,'attri'=>64.41,'time'=>21130),array('wood'=>5445,'clay'=>3960,'iron'=>2230,'crop'=>990,'pop'=>3,'cp'=>51,'attri'=>62.09,'time'=>24810),array('wood'=>6970,'clay'=>5070,'iron'=>2850,'crop'=>1270,'pop'=>3,'cp'=>62,'attri'=>59.85,'time'=>29080),array('wood'=>8925,'clay'=>6490,'iron'=>3650,'crop'=>1625,'pop'=>4,'cp'=>74,'attri'=>57.70,'time'=>34030),array('wood'=>11425,'clay'=>8310,'iron'=>4675,'crop'=>2075,'pop'=>4,'cp'=>89,'attri'=>55.62,'time'=>39770),array('wood'=>14620,'clay'=>10635,'iron'=>5980,'crop'=>2660,'pop'=>4,'cp'=>106,'attri'=>53.62,'time'=>46440),array('wood'=>18715,'clay'=>13610,'iron'=>7655,'crop'=>3405,'pop'=>4,'cp'=>128,'attri'=>51.69,'time'=>54170),array('wood'=>23955,'clay'=>17420,'iron'=>9800,'crop'=>4355,'pop'=>4,'cp'=>153,'attri'=>49.83,'time'=>63134));
+$bid23=array(1=>array('wood'=>40,'clay'=>50,'iron'=>30,'crop'=>10,'pop'=>0,'cp'=>1,'attri'=>100,'time'=>750),array('wood'=>50,'clay'=>65,'iron'=>40,'crop'=>15,'pop'=>0,'cp'=>1,'attri'=>130,'time'=>1170),array('wood'=>65,'clay'=>80,'iron'=>50,'crop'=>15,'pop'=>0,'cp'=>2,'attri'=>170,'time'=>1660),array('wood'=>85,'clay'=>105,'iron'=>65,'crop'=>20,'pop'=>0,'cp'=>2,'attri'=>220,'time'=>2220),array('wood'=>105,'clay'=>135,'iron'=>80,'crop'=>25,'pop'=>0,'cp'=>2,'attri'=>280,'time'=>2880),array('wood'=>135,'clay'=>170,'iron'=>105,'crop'=>35,'pop'=>1,'cp'=>3,'attri'=>360,'time'=>3640),array('wood'=>175,'clay'=>220,'iron'=>130,'crop'=>45,'pop'=>1,'cp'=>4,'attri'=>460,'time'=>4520),array('wood'=>225,'clay'=>280,'iron'=>170,'crop'=>55,'pop'=>1,'cp'=>4,'attri'=>600,'time'=>5540),array('wood'=>290,'clay'=>360,'iron'=>215,'crop'=>70,'pop'=>1,'cp'=>5,'attri'=>770,'time'=>6730),array('wood'=>370,'clay'=>460,'iron'=>275,'crop'=>90,'pop'=>1,'cp'=>6,'attri'=>1000,'time'=>8110));
+$bid24=array(1=>array('wood'=>1250,'clay'=>1110,'iron'=>1260,'crop'=>600,'pop'=>4,'cp'=>6,'attri'=>100.00,'time'=>12500),array('wood'=>1600,'clay'=>1420,'iron'=>1615,'crop'=>770,'pop'=>2,'cp'=>7,'attri'=>96.40,'time'=>14800),array('wood'=>2050,'clay'=>1820,'iron'=>2065,'crop'=>985,'pop'=>2,'cp'=>9,'attri'=>92.93,'time'=>17468),array('wood'=>2620,'clay'=>2330,'iron'=>2640,'crop'=>1260,'pop'=>2,'cp'=>10,'attri'=>89.58,'time'=>20563),array('wood'=>3355,'clay'=>2980,'iron'=>3380,'crop'=>1610,'pop'=>2,'cp'=>12,'attri'=>86.36,'time'=>24153),array('wood'=>4295,'clay'=>3815,'iron'=>4330,'crop'=>2060,'pop'=>3,'cp'=>15,'attri'=>83.25,'time'=>28317),array('wood'=>5500,'clay'=>4880,'iron'=>5540,'crop'=>2640,'pop'=>3,'cp'=>18,'attri'=>80.25,'time'=>33148),array('wood'=>7035,'clay'=>6250,'iron'=>7095,'crop'=>3380,'pop'=>3,'cp'=>21,'attri'=>77.36,'time'=>38752),array('wood'=>9005,'clay'=>8000,'iron'=>9080,'crop'=>4325,'pop'=>3,'cp'=>26,'attri'=>74.58,'time'=>45252),array('wood'=>11530,'clay'=>10240,'iron'=>11620,'crop'=>5535,'pop'=>3,'cp'=>31,'attri'=>71.89,'time'=>52793),array('wood'=>14755,'clay'=>13105,'iron'=>14875,'crop'=>7085,'pop'=>3,'cp'=>37,'attri'=>69.31,'time'=>61539),array('wood'=>18890,'clay'=>16775,'iron'=>19040,'crop'=>9065,'pop'=>3,'cp'=>45,'attri'=>66.81,'time'=>71686),array('wood'=>24180,'clay'=>21470,'iron'=>24370,'crop'=>11605,'pop'=>3,'cp'=>53,'attri'=>64.41,'time'=>83455),array('wood'=>30950,'clay'=>27480,'iron'=>31195,'crop'=>14855,'pop'=>3,'cp'=>64,'attri'=>62.09,'time'=>97108),array('wood'=>39615,'clay'=>35175,'iron'=>39930,'crop'=>19015,'pop'=>3,'cp'=>77,'attri'=>59.85,'time'=>112946),array('wood'=>50705,'clay'=>45025,'iron'=>51110,'crop'=>24340,'pop'=>4,'cp'=>92,'attri'=>57.70,'time'=>131317),array('wood'=>64905,'clay'=>57635,'iron'=>65425,'crop'=>31155,'pop'=>4,'cp'=>111,'attri'=>55.62,'time'=>152628),array('wood'=>83075,'clay'=>73770,'iron'=>83740,'crop'=>39875,'pop'=>4,'cp'=>133,'attri'=>53.62,'time'=>177348),array('wood'=>106340,'clay'=>94430,'iron'=>107190,'crop'=>51040,'pop'=>4,'cp'=>160,'attri'=>51.69,'time'=>206024),array('wood'=>136115,'clay'=>120870,'iron'=>137200,'crop'=>65335,'pop'=>4,'cp'=>192,'attri'=>49.83,'time'=>239287));
+$bid25=array(1=>array('wood'=>580,'clay'=>460,'iron'=>350,'crop'=>180,'pop'=>1,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>740,'clay'=>590,'iron'=>450,'crop'=>230,'pop'=>1,'cp'=>3,'attri'=>90,'time'=>2620),array('wood'=>950,'clay'=>755,'iron'=>575,'crop'=>295,'pop'=>1,'cp'=>3,'attri'=>81,'time'=>3340),array('wood'=>1215,'clay'=>965,'iron'=>735,'crop'=>375,'pop'=>1,'cp'=>4,'attri'=>72.9,'time'=>4170),array('wood'=>1555,'clay'=>1235,'iron'=>940,'crop'=>485,'pop'=>1,'cp'=>5,'attri'=>65.61,'time'=>5140),array('wood'=>1995,'clay'=>1580,'iron'=>1205,'crop'=>620,'pop'=>1,'cp'=>6,'attri'=>59.05,'time'=>6260),array('wood'=>2550,'clay'=>2025,'iron'=>1540,'crop'=>790,'pop'=>1,'cp'=>7,'attri'=>53.14,'time'=>7570),array('wood'=>3265,'clay'=>2590,'iron'=>1970,'crop'=>1015,'pop'=>1,'cp'=>9,'attri'=>47.83,'time'=>9080),array('wood'=>4180,'clay'=>3315,'iron'=>2520,'crop'=>1295,'pop'=>1,'cp'=>10,'attri'=>43.05,'time'=>10830),array('wood'=>5350,'clay'=>4245,'iron'=>3230,'crop'=>1660,'pop'=>1,'cp'=>12,'attri'=>38.74,'time'=>12860),array('wood'=>6845,'clay'=>5430,'iron'=>4130,'crop'=>2125,'pop'=>2,'cp'=>15,'attri'=>34.87,'time'=>15220),array('wood'=>8765,'clay'=>6950,'iron'=>5290,'crop'=>2720,'pop'=>2,'cp'=>18,'attri'=>31.38,'time'=>17950),array('wood'=>11220,'clay'=>8900,'iron'=>6770,'crop'=>3480,'pop'=>2,'cp'=>21,'attri'=>28.24,'time'=>21130),array('wood'=>14360,'clay'=>11390,'iron'=>8665,'crop'=>4455,'pop'=>2,'cp'=>26,'attri'=>25.42,'time'=>24810),array('wood'=>18380,'clay'=>14580,'iron'=>11090,'crop'=>5705,'pop'=>2,'cp'=>31,'attri'=>22.88,'time'=>29080),array('wood'=>23530,'clay'=>18660,'iron'=>14200,'crop'=>7300,'pop'=>2,'cp'=>37,'attri'=>20.59,'time'=>34030),array('wood'=>30115,'clay'=>23885,'iron'=>18175,'crop'=>9345,'pop'=>2,'cp'=>44,'attri'=>18.53,'time'=>39770),array('wood'=>38550,'clay'=>30570,'iron'=>23260,'crop'=>11965,'pop'=>2,'cp'=>53,'attri'=>16.68,'time'=>46440),array('wood'=>49340,'clay'=>39130,'iron'=>29775,'crop'=>15315,'pop'=>2,'cp'=>64,'attri'=>15.01,'time'=>54170),array('wood'=>63155,'clay'=>50090,'iron'=>38110,'crop'=>19600,'pop'=>2,'cp'=>77,'attri'=>13.51,'time'=>63130));
+$bid26=array(1=>array('wood'=>550,'clay'=>800,'iron'=>750,'crop'=>250,'pop'=>1,'cp'=>6,'attri'=>100,'time'=>5000),array('wood'=>705,'clay'=>1025,'iron'=>960,'crop'=>320,'pop'=>1,'cp'=>7,'attri'=>90,'time'=>6100),array('wood'=>900,'clay'=>1310,'iron'=>1230,'crop'=>410,'pop'=>1,'cp'=>9,'attri'=>81,'time'=>7380),array('wood'=>1155,'clay'=>1680,'iron'=>1575,'crop'=>525,'pop'=>1,'cp'=>10,'attri'=>72.9,'time'=>8860),array('wood'=>1475,'clay'=>2145,'iron'=>2015,'crop'=>670,'pop'=>1,'cp'=>12,'attri'=>65.61,'time'=>10570),array('wood'=>1890,'clay'=>2750,'iron'=>2575,'crop'=>860,'pop'=>1,'cp'=>15,'attri'=>59.05,'time'=>12560),array('wood'=>2420,'clay'=>3520,'iron'=>3300,'crop'=>1100,'pop'=>1,'cp'=>18,'attri'=>53.14,'time'=>14880),array('wood'=>3095,'clay'=>4505,'iron'=>4220,'crop'=>1405,'pop'=>1,'cp'=>21,'attri'=>47.83,'time'=>17560),array('wood'=>3965,'clay'=>5765,'iron'=>5405,'crop'=>1800,'pop'=>1,'cp'=>26,'attri'=>43.05,'time'=>20660),array('wood'=>5075,'clay'=>7380,'iron'=>6920,'crop'=>2305,'pop'=>1,'cp'=>31,'attri'=>38.74,'time'=>24270),array('wood'=>6495,'clay'=>9445,'iron'=>8855,'crop'=>2950,'pop'=>2,'cp'=>37,'attri'=>34.87,'time'=>28450),array('wood'=>8310,'clay'=>12090,'iron'=>11335,'crop'=>3780,'pop'=>2,'cp'=>45,'attri'=>31.38,'time'=>33306),array('wood'=>10640,'clay'=>15475,'iron'=>14505,'crop'=>4835,'pop'=>2,'cp'=>53,'attri'=>28.24,'time'=>38935),array('wood'=>13615,'clay'=>19805,'iron'=>18570,'crop'=>6190,'pop'=>2,'cp'=>64,'attri'=>25.42,'time'=>45465),array('wood'=>17430,'clay'=>25355,'iron'=>23770,'crop'=>7925,'pop'=>2,'cp'=>77,'attri'=>22.88,'time'=>53039),array('wood'=>22310,'clay'=>32450,'iron'=>30425,'crop'=>10140,'pop'=>2,'cp'=>92,'attri'=>20.59,'time'=>61825),array('wood'=>28560,'clay'=>41540,'iron'=>38940,'crop'=>12980,'pop'=>2,'cp'=>111,'attri'=>18.53,'time'=>72018),array('wood'=>36555,'clay'=>53170,'iron'=>49845,'crop'=>16615,'pop'=>2,'cp'=>133,'attri'=>16.68,'time'=>83840),array('wood'=>46790,'clay'=>68055,'iron'=>63805,'crop'=>21270,'pop'=>2,'cp'=>160,'attri'=>15.01,'time'=>97555),array('wood'=>59890,'clay'=>87110,'iron'=>81675,'crop'=>27225,'pop'=>2,'cp'=>192,'attri'=>13.51,'time'=>113464));
+$bid27=array(1=>array('wood'=>2880,'clay'=>2740,'iron'=>2580,'crop'=>990,'pop'=>4,'cp'=>7,'attri'=>0,'time'=>8000),array('wood'=>3630,'clay'=>3450,'iron'=>3250,'crop'=>1245,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>9580),array('wood'=>4570,'clay'=>4350,'iron'=>4095,'crop'=>1570,'pop'=>2,'cp'=>10,'attri'=>0,'time'=>11410),array('wood'=>5760,'clay'=>5480,'iron'=>5160,'crop'=>1980,'pop'=>2,'cp'=>12,'attri'=>0,'time'=>13540),array('wood'=>7260,'clay'=>6905,'iron'=>6505,'crop'=>2495,'pop'=>2,'cp'=>15,'attri'=>0,'time'=>16010),array('wood'=>9145,'clay'=>8700,'iron'=>8195,'crop'=>3145,'pop'=>3,'cp'=>18,'attri'=>0,'time'=>18870),array('wood'=>11525,'clay'=>10965,'iron'=>10325,'crop'=>3960,'pop'=>3,'cp'=>21,'attri'=>0,'time'=>22180),array('wood'=>14520,'clay'=>13815,'iron'=>13010,'crop'=>4990,'pop'=>3,'cp'=>26,'attri'=>0,'time'=>26030),array('wood'=>18295,'clay'=>17405,'iron'=>16390,'crop'=>6290,'pop'=>3,'cp'=>31,'attri'=>0,'time'=>30500),array('wood'=>23055,'clay'=>21930,'iron'=>20650,'crop'=>7925,'pop'=>3,'cp'=>37,'attri'=>1,'time'=>35680),array('wood'=>9045,'clay'=>27635,'iron'=>26020,'crop'=>9985,'pop'=>3,'cp'=>45,'attri'=>1,'time'=>41690),array('wood'=>6600,'clay'=>34820,'iron'=>32785,'crop'=>12580,'pop'=>3,'cp'=>53,'attri'=>1,'time'=>48660),array('wood'=>46115,'clay'=>43875,'iron'=>41310,'crop'=>15850,'pop'=>3,'cp'=>64,'attri'=>1,'time'=>56740),array('wood'=>58105,'clay'=>55280,'iron'=>52050,'crop'=>19975,'pop'=>3,'cp'=>77,'attri'=>1,'time'=>66120),array('wood'=>73210,'clay'=>69655,'iron'=>65585,'crop'=>25165,'pop'=>3,'cp'=>92,'attri'=>1,'time'=>77000),array('wood'=>92245,'clay'=>87760,'iron'=>82640,'crop'=>31710,'pop'=>4,'cp'=>111,'attri'=>1,'time'=>89620),array('wood'=>116230,'clay'=>110580,'iron'=>104125,'crop'=>39955,'pop'=>4,'cp'=>133,'attri'=>1,'time'=>104260),array('wood'=>146450,'clay'=>139330,'iron'=>131195,'crop'=>50340,'pop'=>4,'cp'=>160,'attri'=>1,'time'=>121240),array('wood'=>184530,'clay'=>175560,'iron'=>165305,'crop'=>63430,'pop'=>4,'cp'=>192,'attri'=>1,'time'=>140940),array('wood'=>232505,'clay'=>221205,'iron'=>208285,'crop'=>79925,'pop'=>4,'cp'=>230,'attri'=>1,'time'=>163790));
+$bid28=array(1=>array('wood'=>1400,'clay'=>1330,'iron'=>1200,'crop'=>400,'pop'=>3,'cp'=>4,'attri'=>110,'time'=>3000),array('wood'=>1790,'clay'=>1700,'iron'=>1535,'crop'=>510,'pop'=>2,'cp'=>4,'attri'=>120,'time'=>3780),array('wood'=>2295,'clay'=>2180,'iron'=>1965,'crop'=>655,'pop'=>2,'cp'=>5,'attri'=>130,'time'=>4680),array('wood'=>2935,'clay'=>2790,'iron'=>2515,'crop'=>840,'pop'=>2,'cp'=>6,'attri'=>140,'time'=>5730),array('wood'=>3760,'clay'=>3570,'iron'=>3220,'crop'=>1075,'pop'=>2,'cp'=>7,'attri'=>150,'time'=>6950),array('wood'=>4810,'clay'=>4570,'iron'=>4125,'crop'=>1375,'pop'=>2,'cp'=>9,'attri'=>160,'time'=>8360),array('wood'=>6155,'clay'=>5850,'iron'=>5280,'crop'=>1760,'pop'=>2,'cp'=>11,'attri'=>170,'time'=>10000),array('wood'=>7880,'clay'=>7485,'iron'=>6755,'crop'=>2250,'pop'=>2,'cp'=>13,'attri'=>180,'time'=>11900),array('wood'=>10090,'clay'=>9585,'iron'=>8645,'crop'=>2880,'pop'=>2,'cp'=>15,'attri'=>190,'time'=>14110),array('wood'=>12915,'clay'=>12265,'iron'=>11070,'crop'=>3690,'pop'=>2,'cp'=>19,'attri'=>200,'time'=>16660),array('wood'=>16530,'clay'=>15700,'iron'=>14165,'crop'=>4720,'pop'=>3,'cp'=>22,'attri'=>210,'time'=>19630),array('wood'=>21155,'clay'=>20100,'iron'=>18135,'crop'=>6045,'pop'=>3,'cp'=>27,'attri'=>220,'time'=>23070),array('wood'=>27080,'clay'=>25725,'iron'=>23210,'crop'=>7735,'pop'=>3,'cp'=>32,'attri'=>230,'time'=>27060),array('wood'=>34660,'clay'=>32930,'iron'=>29710,'crop'=>9905,'pop'=>3,'cp'=>39,'attri'=>240,'time'=>31690),array('wood'=>44370,'clay'=>42150,'iron'=>38030,'crop'=>12675,'pop'=>3,'cp'=>46,'attri'=>250,'time'=>37060),array('wood'=>56790,'clay'=>53950,'iron'=>48680,'crop'=>16225,'pop'=>3,'cp'=>55,'attri'=>260,'time'=>43290),array('wood'=>72690,'clay'=>69060,'iron'=>62310,'crop'=>20770,'pop'=>3,'cp'=>67,'attri'=>270,'time'=>50520),array('wood'=>93045,'clay'=>88395,'iron'=>79755,'crop'=>26585,'pop'=>3,'cp'=>80,'attri'=>280,'time'=>58900),array('wood'=>119100,'clay'=>113145,'iron'=>102085,'crop'=>34030,'pop'=>3,'cp'=>96,'attri'=>290,'time'=>68630),array('wood'=>152445,'clay'=>144825,'iron'=>130670,'crop'=>43555,'pop'=>3,'cp'=>115,'attri'=>300,'time'=>79910));
+$bid29=array(1=>array('wood'=>630,'clay'=>420,'iron'=>780,'crop'=>360,'pop'=>4,'cp'=>1,'attri'=>100,'time'=>2000),array('wood'=>805,'clay'=>540,'iron'=>1000,'crop'=>460,'pop'=>2,'cp'=>1,'attri'=>90,'time'=>2620),array('wood'=>1035,'clay'=>690,'iron'=>1275,'crop'=>585,'pop'=>2,'cp'=>2,'attri'=>81,'time'=>3340),array('wood'=>1320,'clay'=>885,'iron'=>1635,'crop'=>750,'pop'=>2,'cp'=>2,'attri'=>72.9,'time'=>4170),array('wood'=>1695,'clay'=>1125,'iron'=>2100,'crop'=>960,'pop'=>2,'cp'=>2,'attri'=>65.61,'time'=>5140),array('wood'=>2160,'clay'=>1440,'iron'=>2685,'crop'=>1230,'pop'=>3,'cp'=>3,'attri'=>59.05,'time'=>6260),array('wood'=>2775,'clay'=>1845,'iron'=>3435,'crop'=>1590,'pop'=>3,'cp'=>4,'attri'=>53.14,'time'=>7570),array('wood'=>3540,'clay'=>2370,'iron'=>4395,'crop'=>2025,'pop'=>3,'cp'=>4,'attri'=>47.83,'time'=>9080),array('wood'=>4545,'clay'=>3030,'iron'=>5625,'crop'=>2595,'pop'=>3,'cp'=>5,'attri'=>43.05,'time'=>10830),array('wood'=>5805,'clay'=>3870,'iron'=>7200,'crop'=>3315,'pop'=>3,'cp'=>6,'attri'=>38.74,'time'=>12860),array('wood'=>7460,'clay'=>4965,'iron'=>9210,'crop'=>4245,'pop'=>3,'cp'=>7,'attri'=>34.87,'time'=>15220),array('wood'=>9525,'clay'=>6345,'iron'=>11790,'crop'=>5445,'pop'=>3,'cp'=>9,'attri'=>31.38,'time'=>17950),array('wood'=>12180,'clay'=>8130,'iron'=>15090,'crop'=>6960,'pop'=>3,'cp'=>11,'attri'=>28.24,'time'=>21130),array('wood'=>15600,'clay'=>10395,'iron'=>19305,'crop'=>8910,'pop'=>3,'cp'=>13,'attri'=>25.42,'time'=>24810),array('wood'=>19965,'clay'=>13305,'iron'=>24720,'crop'=>11415,'pop'=>3,'cp'=>15,'attri'=>22.88,'time'=>29080),array('wood'=>25560,'clay'=>17040,'iron'=>31635,'crop'=>14610,'pop'=>4,'cp'=>18,'attri'=>20.59,'time'=>34030),array('wood'=>32715,'clay'=>21810,'iron'=>40500,'crop'=>18690,'pop'=>4,'cp'=>22,'attri'=>18.53,'time'=>39770),array('wood'=>41870,'clay'=>27915,'iron'=>51840,'crop'=>23925,'pop'=>4,'cp'=>27,'attri'=>16.68,'time'=>46440),array('wood'=>53595,'clay'=>35730,'iron'=>66360,'crop'=>30630,'pop'=>4,'cp'=>32,'attri'=>15.01,'time'=>54170),array('wood'=>68595,'clay'=>45735,'iron'=>84930,'crop'=>39195,'pop'=>4,'cp'=>38,'attri'=>13.51,'time'=>63130));
+$bid30=array(1=>array('wood'=>780,'clay'=>420,'iron'=>660,'crop'=>300,'pop'=>5,'cp'=>2,'attri'=>100,'time'=>2200),array('wood'=>1000,'clay'=>540,'iron'=>845,'crop'=>385,'pop'=>3,'cp'=>3,'attri'=>90,'time'=>2850),array('wood'=>1280,'clay'=>690,'iron'=>1080,'crop'=>490,'pop'=>3,'cp'=>3,'attri'=>81,'time'=>3610),array('wood'=>1635,'clay'=>880,'iron'=>1385,'crop'=>630,'pop'=>3,'cp'=>4,'attri'=>72.9,'time'=>4490),array('wood'=>2095,'clay'=>1125,'iron'=>1770,'crop'=>805,'pop'=>3,'cp'=>5,'attri'=>65.61,'time'=>5500),array('wood'=>2680,'clay'=>1445,'iron'=>2270,'crop'=>1030,'pop'=>3,'cp'=>6,'attri'=>59.05,'time'=>6680),array('wood'=>3430,'clay'=>1845,'iron'=>2905,'crop'=>1320,'pop'=>3,'cp'=>7,'attri'=>53.14,'time'=>8050),array('wood'=>4390,'clay'=>2365,'iron'=>3715,'crop'=>1690,'pop'=>3,'cp'=>9,'attri'=>47.83,'time'=>9640),array('wood'=>5620,'clay'=>3025,'iron'=>4755,'crop'=>2160,'pop'=>3,'cp'=>10,'attri'=>43.05,'time'=>11480),array('wood'=>7195,'clay'=>3875,'iron'=>6085,'crop'=>2765,'pop'=>3,'cp'=>12,'attri'=>38.74,'time'=>13620),array('wood'=>9210,'clay'=>4960,'iron'=>7790,'crop'=>3540,'pop'=>4,'cp'=>15,'attri'=>34.87,'time'=>16100),array('wood'=>11785,'clay'=>6345,'iron'=>9975,'crop'=>4535,'pop'=>4,'cp'=>18,'attri'=>31.38,'time'=>18980),array('wood'=>15085,'clay'=>8125,'iron'=>12765,'crop'=>5805,'pop'=>4,'cp'=>21,'attri'=>28.24,'time'=>22310),array('wood'=>19310,'clay'=>10400,'iron'=>16340,'crop'=>7430,'pop'=>4,'cp'=>26,'attri'=>25.42,'time'=>26180),array('wood'=>24720,'clay'=>13310,'iron'=>20915,'crop'=>9505,'pop'=>4,'cp'=>31,'attri'=>22.88,'time'=>30670),array('wood'=>31640,'clay'=>17035,'iron'=>26775,'crop'=>12170,'pop'=>4,'cp'=>37,'attri'=>20.59,'time'=>35880),array('wood'=>40500,'clay'=>21810,'iron'=>34270,'crop'=>15575,'pop'=>4,'cp'=>44,'attri'=>18.53,'time'=>41920),array('wood'=>51840,'clay'=>27915,'iron'=>43865,'crop'=>19940,'pop'=>4,'cp'=>53,'attri'=>16.68,'time'=>48930),array('wood'=>66355,'clay'=>35730,'iron'=>56145,'crop'=>25520,'pop'=>4,'cp'=>64,'attri'=>15.01,'time'=>57060),array('wood'=>84935,'clay'=>45735,'iron'=>71870,'crop'=>32665,'pop'=>4,'cp'=>77,'attri'=>13.51,'time'=>66490));
+$bid31=array(1=>array('wood'=>70,'clay'=>90,'iron'=>170,'crop'=>70,'pop'=>0,'cp'=>1,'attri'=>3,'time'=>2000),array('wood'=>90,'clay'=>115,'iron'=>220,'crop'=>90,'pop'=>0,'cp'=>1,'attri'=>6,'time'=>2620),array('wood'=>115,'clay'=>145,'iron'=>280,'crop'=>115,'pop'=>0,'cp'=>2,'attri'=>9,'time'=>3340),array('wood'=>145,'clay'=>190,'iron'=>355,'crop'=>145,'pop'=>0,'cp'=>2,'attri'=>13,'time'=>4170),array('wood'=>190,'clay'=>240,'iron'=>455,'crop'=>190,'pop'=>0,'cp'=>2,'attri'=>16,'time'=>5140),array('wood'=>240,'clay'=>310,'iron'=>585,'crop'=>240,'pop'=>1,'cp'=>3,'attri'=>19,'time'=>6260),array('wood'=>310,'clay'=>395,'iron'=>750,'crop'=>310,'pop'=>1,'cp'=>4,'attri'=>23,'time'=>7570),array('wood'=>395,'clay'=>505,'iron'=>955,'crop'=>395,'pop'=>1,'cp'=>4,'attri'=>27,'time'=>9080),array('wood'=>505,'clay'=>650,'iron'=>1225,'crop'=>505,'pop'=>1,'cp'=>5,'attri'=>30,'time'=>10830),array('wood'=>645,'clay'=>830,'iron'=>1570,'crop'=>645,'pop'=>1,'cp'=>6,'attri'=>34,'time'=>12860),array('wood'=>825,'clay'=>1065,'iron'=>2005,'crop'=>825,'pop'=>1,'cp'=>7,'attri'=>38,'time'=>15220),array('wood'=>1060,'clay'=>1360,'iron'=>2570,'crop'=>1060,'pop'=>1,'cp'=>9,'attri'=>43,'time'=>17950),array('wood'=>1355,'clay'=>1740,'iron'=>3290,'crop'=>1355,'pop'=>1,'cp'=>11,'attri'=>47,'time'=>21130),array('wood'=>1735,'clay'=>2230,'iron'=>4210,'crop'=>1735,'pop'=>1,'cp'=>13,'attri'=>51,'time'=>24810),array('wood'=>2220,'clay'=>2850,'iron'=>5390,'crop'=>2220,'pop'=>1,'cp'=>15,'attri'=>56,'time'=>29080),array('wood'=>2840,'clay'=>3650,'iron'=>6895,'crop'=>2840,'pop'=>2,'cp'=>18,'attri'=>60,'time'=>34030),array('wood'=>3635,'clay'=>4675,'iron'=>8825,'crop'=>3635,'pop'=>2,'cp'=>22,'attri'=>65,'time'=>39770),array('wood'=>4650,'clay'=>5980,'iron'=>11300,'crop'=>4650,'pop'=>2,'cp'=>27,'attri'=>70,'time'=>46440),array('wood'=>5955,'clay'=>7655,'iron'=>14460,'crop'=>5955,'pop'=>2,'cp'=>32,'attri'=>75,'time'=>54170),array('wood'=>7620,'clay'=>9800,'iron'=>18510,'crop'=>7620,'pop'=>2,'cp'=>38,'attri'=>81,'time'=>63130));
+$bid32=array(1=>array('wood'=>120,'clay'=>200,'iron'=>0,'crop'=>80,'pop'=>0,'cp'=>1,'attri'=>2,'time'=>2000),array('wood'=>155,'clay'=>255,'iron'=>0,'crop'=>100,'pop'=>0,'cp'=>1,'attri'=>4,'time'=>2620),array('wood'=>195,'clay'=>330,'iron'=>0,'crop'=>130,'pop'=>0,'cp'=>2,'attri'=>6,'time'=>3340),array('wood'=>250,'clay'=>420,'iron'=>0,'crop'=>170,'pop'=>0,'cp'=>2,'attri'=>8,'time'=>4170),array('wood'=>320,'clay'=>535,'iron'=>0,'crop'=>215,'pop'=>0,'cp'=>2,'attri'=>10,'time'=>5140),array('wood'=>410,'clay'=>685,'iron'=>0,'crop'=>275,'pop'=>1,'cp'=>3,'attri'=>13,'time'=>6260),array('wood'=>530,'clay'=>880,'iron'=>0,'crop'=>350,'pop'=>1,'cp'=>4,'attri'=>15,'time'=>7570),array('wood'=>675,'clay'=>1125,'iron'=>0,'crop'=>450,'pop'=>1,'cp'=>4,'attri'=>17,'time'=>9080),array('wood'=>865,'clay'=>1440,'iron'=>0,'crop'=>575,'pop'=>1,'cp'=>5,'attri'=>20,'time'=>10830),array('wood'=>1105,'clay'=>1845,'iron'=>0,'crop'=>740,'pop'=>1,'cp'=>6,'attri'=>22,'time'=>12860),array('wood'=>1415,'clay'=>2360,'iron'=>0,'crop'=>945,'pop'=>1,'cp'=>7,'attri'=>24,'time'=>15220),array('wood'=>1815,'clay'=>3020,'iron'=>0,'crop'=>1210,'pop'=>1,'cp'=>9,'attri'=>27,'time'=>17950),array('wood'=>2320,'clay'=>3870,'iron'=>0,'crop'=>1545,'pop'=>1,'cp'=>11,'attri'=>29,'time'=>21130),array('wood'=>2970,'clay'=>4950,'iron'=>0,'crop'=>1980,'pop'=>1,'cp'=>13,'attri'=>32,'time'=>24810),array('wood'=>3805,'clay'=>6340,'iron'=>0,'crop'=>2535,'pop'=>1,'cp'=>15,'attri'=>35,'time'=>29080),array('wood'=>4870,'clay'=>8115,'iron'=>0,'crop'=>3245,'pop'=>2,'cp'=>18,'attri'=>37,'time'=>34030),array('wood'=>6230,'clay'=>10385,'iron'=>0,'crop'=>4155,'pop'=>2,'cp'=>22,'attri'=>40,'time'=>39770),array('wood'=>7975,'clay'=>13290,'iron'=>0,'crop'=>5315,'pop'=>2,'cp'=>27,'attri'=>43,'time'=>46440),array('wood'=>10210,'clay'=>17015,'iron'=>0,'crop'=>6805,'pop'=>2,'cp'=>32,'attri'=>46,'time'=>54170),array('wood'=>13065,'clay'=>21780,'iron'=>0,'crop'=>8710,'pop'=>2,'cp'=>38,'attri'=>49,'time'=>63130));
+$bid33=array(1=>array('wood'=>160,'clay'=>100,'iron'=>80,'crop'=>60,'pop'=>0,'cp'=>1,'attri'=>2,'time'=>2000),array('wood'=>205,'clay'=>130,'iron'=>100,'crop'=>75,'pop'=>0,'cp'=>1,'attri'=>5,'time'=>2620),array('wood'=>260,'clay'=>165,'iron'=>130,'crop'=>100,'pop'=>0,'cp'=>2,'attri'=>8,'time'=>3340),array('wood'=>335,'clay'=>210,'iron'=>170,'crop'=>125,'pop'=>0,'cp'=>2,'attri'=>10,'time'=>4170),array('wood'=>430,'clay'=>270,'iron'=>215,'crop'=>160,'pop'=>0,'cp'=>2,'attri'=>13,'time'=>5140),array('wood'=>550,'clay'=>345,'iron'=>275,'crop'=>205,'pop'=>1,'cp'=>3,'attri'=>16,'time'=>6260),array('wood'=>705,'clay'=>440,'iron'=>350,'crop'=>265,'pop'=>1,'cp'=>4,'attri'=>19,'time'=>7570),array('wood'=>900,'clay'=>565,'iron'=>450,'crop'=>340,'pop'=>1,'cp'=>4,'attri'=>22,'time'=>9080),array('wood'=>1155,'clay'=>720,'iron'=>575,'crop'=>430,'pop'=>1,'cp'=>5,'attri'=>25,'time'=>10830),array('wood'=>1475,'clay'=>920,'iron'=>740,'crop'=>555,'pop'=>1,'cp'=>6,'attri'=>28,'time'=>12860),array('wood'=>1890,'clay'=>1180,'iron'=>945,'crop'=>710,'pop'=>1,'cp'=>7,'attri'=>31,'time'=>15220),array('wood'=>2420,'clay'=>1510,'iron'=>1210,'crop'=>905,'pop'=>1,'cp'=>9,'attri'=>34,'time'=>17950),array('wood'=>3095,'clay'=>1935,'iron'=>1545,'crop'=>1160,'pop'=>1,'cp'=>11,'attri'=>38,'time'=>21130),array('wood'=>3960,'clay'=>2475,'iron'=>1980,'crop'=>1485,'pop'=>1,'cp'=>13,'attri'=>41,'time'=>24810),array('wood'=>5070,'clay'=>3170,'iron'=>2535,'crop'=>1900,'pop'=>1,'cp'=>15,'attri'=>45,'time'=>29080),array('wood'=>6490,'clay'=>4055,'iron'=>3245,'crop'=>2435,'pop'=>2,'cp'=>18,'attri'=>48,'time'=>34030),array('wood'=>8310,'clay'=>5190,'iron'=>4155,'crop'=>3115,'pop'=>2,'cp'=>22,'attri'=>52,'time'=>39770),array('wood'=>10635,'clay'=>6645,'iron'=>5315,'crop'=>3990,'pop'=>2,'cp'=>27,'attri'=>56,'time'=>46440),array('wood'=>13610,'clay'=>8505,'iron'=>6805,'crop'=>5105,'pop'=>2,'cp'=>32,'attri'=>60,'time'=>54170),array('wood'=>17420,'clay'=>10890,'iron'=>8710,'crop'=>6535,'pop'=>2,'cp'=>38,'attri'=>64,'time'=>63130));
+$bid34=array(1=>array('wood'=>155,'clay'=>130,'iron'=>125,'crop'=>70,'pop'=>2,'cp'=>1,'attri'=>110,'time'=>2200),array('wood'=>200,'clay'=>165,'iron'=>160,'crop'=>90,'pop'=>1,'cp'=>1,'attri'=>120,'time'=>3150),array('wood'=>255,'clay'=>215,'iron'=>205,'crop'=>115,'pop'=>1,'cp'=>2,'attri'=>130,'time'=>4260),array('wood'=>325,'clay'=>275,'iron'=>260,'crop'=>145,'pop'=>1,'cp'=>2,'attri'=>140,'time'=>5540),array('wood'=>415,'clay'=>350,'iron'=>335,'crop'=>190,'pop'=>1,'cp'=>2,'attri'=>150,'time'=>7020),array('wood'=>535,'clay'=>445,'iron'=>430,'crop'=>240,'pop'=>2,'cp'=>3,'attri'=>160,'time'=>8750),array('wood'=>680,'clay'=>570,'iron'=>550,'crop'=>310,'pop'=>2,'cp'=>4,'attri'=>170,'time'=>10750),array('wood'=>875,'clay'=>730,'iron'=>705,'crop'=>395,'pop'=>2,'cp'=>4,'attri'=>180,'time'=>13070),array('wood'=>1115,'clay'=>935,'iron'=>900,'crop'=>505,'pop'=>2,'cp'=>5,'attri'=>190,'time'=>15760),array('wood'=>1430,'clay'=>1200,'iron'=>1155,'crop'=>645,'pop'=>2,'cp'=>6,'attri'=>200,'time'=>18880),array('wood'=>1830,'clay'=>1535,'iron'=>1475,'crop'=>825,'pop'=>2,'cp'=>7,'attri'=>210,'time'=>22500),array('wood'=>2340,'clay'=>1965,'iron'=>1890,'crop'=>1060,'pop'=>2,'cp'=>9,'attri'=>220,'time'=>26700),array('wood'=>3000,'clay'=>2515,'iron'=>2420,'crop'=>1355,'pop'=>2,'cp'=>11,'attri'=>230,'time'=>31570),array('wood'=>3840,'clay'=>3220,'iron'=>3095,'crop'=>1735,'pop'=>2,'cp'=>13,'attri'=>240,'time'=>37220),array('wood'=>4910,'clay'=>4120,'iron'=>3960,'crop'=>2220,'pop'=>2,'cp'=>15,'attri'=>250,'time'=>43780),array('wood'=>6290,'clay'=>5275,'iron'=>5070,'crop'=>2840,'pop'=>3,'cp'=>18,'attri'=>260,'time'=>51380),array('wood'=>8050,'clay'=>6750,'iron'=>6490,'crop'=>3635,'pop'=>3,'cp'=>22,'attri'=>270,'time'=>60200),array('wood'=>10300,'clay'=>8640,'iron'=>8310,'crop'=>4650,'pop'=>3,'cp'=>27,'attri'=>280,'time'=>70430),array('wood'=>13185,'clay'=>11060,'iron'=>10635,'crop'=>5955,'pop'=>3,'cp'=>32,'attri'=>290,'time'=>82300),array('wood'=>16880,'clay'=>14155,'iron'=>13610,'crop'=>7620,'pop'=>3,'cp'=>38,'attri'=>300,'time'=>96070));
+$bid35=array(1=>array('wood'=>1460,'clay'=>930,'iron'=>1250,'crop'=>1740,'pop'=>6,'cp'=>5,'attri'=>1,'time'=>8000),array('wood'=>2045,'clay'=>1300,'iron'=>1750,'crop'=>2435,'pop'=>3,'cp'=>6,'attri'=>2,'time'=>9880),array('wood'=>2860,'clay'=>1825,'iron'=>2450,'crop'=>3410,'pop'=>3,'cp'=>7,'attri'=>3,'time'=>12060),array('wood'=>4005,'clay'=>2550,'iron'=>3430,'crop'=>4775,'pop'=>3,'cp'=>8,'attri'=>4,'time'=>14590),array('wood'=>5610,'clay'=>3575,'iron'=>4800,'crop'=>6685,'pop'=>3,'cp'=>10,'attri'=>5,'time'=>17530),array('wood'=>7850,'clay'=>5000,'iron'=>6725,'crop'=>9360,'pop'=>4,'cp'=>12,'attri'=>6,'time'=>20930),array('wood'=>10995,'clay'=>7000,'iron'=>9410,'crop'=>13100,'pop'=>4,'cp'=>14,'attri'=>7,'time'=>24880),array('wood'=>15390,'clay'=>9805,'iron'=>13175,'crop'=>18340,'pop'=>4,'cp'=>17,'attri'=>8,'time'=>29460),array('wood'=>21545,'clay'=>13725,'iron'=>18445,'crop'=>25680,'pop'=>4,'cp'=>21,'attri'=>9,'time'=>34770),array('wood'=>30165,'clay'=>19215,'iron'=>25825,'crop'=>35950,'pop'=>4,'cp'=>25,'attri'=>10,'time'=>40930));
+$bid36=array(1=>array('wood'=>100,'clay'=>100,'iron'=>100,'crop'=>100,'pop'=>4,'cp'=>1,'attri'=>10,'time'=>2000),array('wood'=>130,'clay'=>130,'iron'=>130,'crop'=>130,'pop'=>2,'cp'=>1,'attri'=>22,'time'=>2320),array('wood'=>165,'clay'=>165,'iron'=>165,'crop'=>165,'pop'=>2,'cp'=>2,'attri'=>35,'time'=>2690),array('wood'=>210,'clay'=>210,'iron'=>210,'crop'=>210,'pop'=>2,'cp'=>2,'attri'=>49,'time'=>3120),array('wood'=>270,'clay'=>270,'iron'=>270,'crop'=>270,'pop'=>2,'cp'=>2,'attri'=>64,'time'=>3620),array('wood'=>345,'clay'=>345,'iron'=>345,'crop'=>345,'pop'=>3,'cp'=>3,'attri'=>80,'time'=>4200),array('wood'=>440,'clay'=>440,'iron'=>440,'crop'=>440,'pop'=>3,'cp'=>4,'attri'=>97,'time'=>4870),array('wood'=>565,'clay'=>565,'iron'=>565,'crop'=>565,'pop'=>3,'cp'=>4,'attri'=>115,'time'=>5650),array('wood'=>720,'clay'=>720,'iron'=>720,'crop'=>720,'pop'=>3,'cp'=>5,'attri'=>134,'time'=>6560),array('wood'=>920,'clay'=>920,'iron'=>920,'crop'=>920,'pop'=>3,'cp'=>6,'attri'=>154,'time'=>7610),array('wood'=>1180,'clay'=>1180,'iron'=>1180,'crop'=>1180,'pop'=>3,'cp'=>7,'attri'=>175,'time'=>8820),array('wood'=>1510,'clay'=>1510,'iron'=>1510,'crop'=>1510,'pop'=>3,'cp'=>9,'attri'=>196,'time'=>10230),array('wood'=>1935,'clay'=>1935,'iron'=>1935,'crop'=>1935,'pop'=>3,'cp'=>11,'attri'=>218,'time'=>11870),array('wood'=>2475,'clay'=>2475,'iron'=>2475,'crop'=>2475,'pop'=>3,'cp'=>13,'attri'=>241,'time'=>13770),array('wood'=>3170,'clay'=>3170,'iron'=>3170,'crop'=>3170,'pop'=>3,'cp'=>15,'attri'=>265,'time'=>15980),array('wood'=>4055,'clay'=>4055,'iron'=>4055,'crop'=>4055,'pop'=>4,'cp'=>18,'attri'=>290,'time'=>18530),array('wood'=>5190,'clay'=>5190,'iron'=>5190,'crop'=>5190,'pop'=>4,'cp'=>22,'attri'=>316,'time'=>21500),array('wood'=>6645,'clay'=>6645,'iron'=>6645,'crop'=>6645,'pop'=>4,'cp'=>27,'attri'=>343,'time'=>24940),array('wood'=>8505,'clay'=>8505,'iron'=>8505,'crop'=>8505,'pop'=>4,'cp'=>32,'attri'=>371,'time'=>28930),array('wood'=>10890,'clay'=>10890,'iron'=>10890,'crop'=>10890,'pop'=>4,'cp'=>38,'attri'=>400,'time'=>33550));
+$bid37=array(1=>array('wood'=>700,'clay'=>670,'iron'=>700,'crop'=>240,'pop'=>2,'cp'=>1,'attri'=>0,'time'=>2300),array('wood'=>930,'clay'=>890,'iron'=>930,'crop'=>320,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>2670),array('wood'=>1240,'clay'=>1185,'iron'=>1240,'crop'=>425,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>3090),array('wood'=>1645,'clay'=>1575,'iron'=>1645,'crop'=>565,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>3590),array('wood'=>2190,'clay'=>2095,'iron'=>2190,'crop'=>750,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>4160),array('wood'=>2915,'clay'=>2790,'iron'=>2915,'crop'=>1000,'pop'=>2,'cp'=>3,'attri'=>0,'time'=>4830),array('wood'=>3875,'clay'=>3710,'iron'=>3875,'crop'=>1330,'pop'=>2,'cp'=>4,'attri'=>0,'time'=>5600),array('wood'=>5155,'clay'=>4930,'iron'=>5155,'crop'=>1765,'pop'=>2,'cp'=>4,'attri'=>0,'time'=>6500),array('wood'=>6855,'clay'=>6560,'iron'=>6855,'crop'=>2350,'pop'=>2,'cp'=>5,'attri'=>0,'time'=>7540),array('wood'=>9115,'clay'=>8725,'iron'=>9115,'crop'=>3125,'pop'=>2,'cp'=>6,'attri'=>1,'time'=>8750),array('wood'=>12125,'clay'=>11605,'iron'=>12125,'crop'=>4155,'pop'=>2,'cp'=>7,'attri'=>1,'time'=>10150),array('wood'=>16125,'clay'=>15435,'iron'=>16125,'crop'=>5530,'pop'=>2,'cp'=>9,'attri'=>1,'time'=>11770),array('wood'=>21445,'clay'=>20525,'iron'=>21445,'crop'=>7350,'pop'=>2,'cp'=>11,'attri'=>1,'time'=>13650),array('wood'=>28520,'clay'=>27300,'iron'=>28520,'crop'=>9780,'pop'=>2,'cp'=>13,'attri'=>1,'time'=>15840),array('wood'=>37935,'clay'=>36310,'iron'=>37935,'crop'=>13005,'pop'=>2,'cp'=>15,'attri'=>2,'time'=>18370),array('wood'=>50450,'clay'=>48290,'iron'=>50450,'crop'=>17300,'pop'=>3,'cp'=>18,'attri'=>2,'time'=>21310),array('wood'=>67100,'clay'=>64225,'iron'=>67100,'crop'=>23005,'pop'=>3,'cp'=>22,'attri'=>2,'time'=>24720),array('wood'=>89245,'clay'=>85420,'iron'=>89245,'crop'=>30600,'pop'=>3,'cp'=>27,'attri'=>2,'time'=>28680),array('wood'=>118695,'clay'=>113605,'iron'=>118695,'crop'=>40695,'pop'=>3,'cp'=>32,'attri'=>2,'time'=>33260),array('wood'=>157865,'clay'=>151095,'iron'=>157865,'crop'=>54125,'pop'=>3,'cp'=>38,'attri'=>3,'time'=>38590));
+$bid38=array(1=>array('wood'=>650,'clay'=>800,'iron'=>450,'crop'=>200,'pop'=>1,'cp'=>1,'attri'=>3600,'time'=>9000),array('wood'=>830,'clay'=>1025,'iron'=>575,'crop'=>255,'pop'=>1,'cp'=>1,'attri'=>5100,'time'=>10740),array('wood'=>1065,'clay'=>1310,'iron'=>735,'crop'=>330,'pop'=>1,'cp'=>2,'attri'=>6900,'time'=>12760),array('wood'=>1365,'clay'=>1680,'iron'=>945,'crop'=>420,'pop'=>1,'cp'=>2,'attri'=>9300,'time'=>15100),array('wood'=>1745,'clay'=>2145,'iron'=>1210,'crop'=>535,'pop'=>1,'cp'=>2,'attri'=>12000,'time'=>17820),array('wood'=>2235,'clay'=>2750,'iron'=>1545,'crop'=>685,'pop'=>1,'cp'=>3,'attri'=>15000,'time'=>20970),array('wood'=>2860,'clay'=>3520,'iron'=>1980,'crop'=>880,'pop'=>1,'cp'=>4,'attri'=>18900,'time'=>24620),array('wood'=>3660,'clay'=>4505,'iron'=>2535,'crop'=>1125,'pop'=>1,'cp'=>4,'attri'=>23400,'time'=>28860),array('wood'=>4685,'clay'=>5765,'iron'=>3245,'crop'=>1440,'pop'=>1,'cp'=>5,'attri'=>28800,'time'=>33780),array('wood'=>5995,'clay'=>7380,'iron'=>4150,'crop'=>1845,'pop'=>1,'cp'=>6,'attri'=>35400,'time'=>39480),array('wood'=>7675,'clay'=>9445,'iron'=>5315,'crop'=>2360,'pop'=>2,'cp'=>7,'attri'=>43200,'time'=>46100),array('wood'=>9825,'clay'=>12090,'iron'=>6800,'crop'=>3020,'pop'=>2,'cp'=>9,'attri'=>52800,'time'=>53780),array('wood'=>12575,'clay'=>15475,'iron'=>8705,'crop'=>3870,'pop'=>2,'cp'=>11,'attri'=>64200,'time'=>62680),array('wood'=>16095,'clay'=>19805,'iron'=>11140,'crop'=>4950,'pop'=>2,'cp'=>13,'attri'=>77700,'time'=>73010),array('wood'=>20600,'clay'=>25355,'iron'=>14260,'crop'=>6340,'pop'=>2,'cp'=>15,'attri'=>93900,'time'=>84990),array('wood'=>26365,'clay'=>32450,'iron'=>18255,'crop'=>8115,'pop'=>2,'cp'=>18,'attri'=>113700,'time'=>98890),array('wood'=>33750,'clay'=>41540,'iron'=>23365,'crop'=>10385,'pop'=>2,'cp'=>22,'attri'=>137100,'time'=>115010),array('wood'=>43200,'clay'=>53170,'iron'=>29910,'crop'=>13290,'pop'=>2,'cp'=>27,'attri'=>165300,'time'=>133710),array('wood'=>55295,'clay'=>68055,'iron'=>38280,'crop'=>17015,'pop'=>2,'cp'=>32,'attri'=>199200,'time'=>155400),array('wood'=>70780,'clay'=>87110,'iron'=>49000,'crop'=>21780,'pop'=>2,'cp'=>38,'attri'=>240000,'time'=>180570));
+$bid39=array(1=>array('wood'=>400,'clay'=>500,'iron'=>350,'crop'=>100,'pop'=>1,'cp'=>1,'attri'=>3600,'time'=>7000),array('wood'=>510,'clay'=>640,'iron'=>450,'crop'=>130,'pop'=>1,'cp'=>1,'attri'=>5100,'time'=>8420),array('wood'=>655,'clay'=>820,'iron'=>575,'crop'=>165,'pop'=>1,'cp'=>2,'attri'=>6900,'time'=>10070),array('wood'=>840,'clay'=>1050,'iron'=>735,'crop'=>210,'pop'=>1,'cp'=>2,'attri'=>9300,'time'=>11980),array('wood'=>1075,'clay'=>1340,'iron'=>940,'crop'=>270,'pop'=>1,'cp'=>2,'attri'=>12000,'time'=>14190),array('wood'=>1375,'clay'=>1720,'iron'=>1205,'crop'=>345,'pop'=>1,'cp'=>3,'attri'=>15000,'time'=>16770),array('wood'=>1760,'clay'=>2200,'iron'=>1540,'crop'=>440,'pop'=>1,'cp'=>4,'attri'=>18900,'time'=>19750),array('wood'=>2250,'clay'=>2815,'iron'=>1970,'crop'=>565,'pop'=>1,'cp'=>4,'attri'=>23400,'time'=>23210),array('wood'=>2880,'clay'=>3605,'iron'=>2520,'crop'=>720,'pop'=>1,'cp'=>5,'attri'=>28800,'time'=>27220),array('wood'=>3690,'clay'=>4610,'iron'=>3230,'crop'=>920,'pop'=>1,'cp'=>6,'attri'=>35400,'time'=>31880),array('wood'=>4720,'clay'=>5905,'iron'=>4130,'crop'=>1180,'pop'=>2,'cp'=>7,'attri'=>43200,'time'=>37280),array('wood'=>6045,'clay'=>7555,'iron'=>5290,'crop'=>1510,'pop'=>2,'cp'=>9,'attri'=>52800,'time'=>43540),array('wood'=>7735,'clay'=>9670,'iron'=>6770,'crop'=>1935,'pop'=>2,'cp'=>11,'attri'=>64200,'time'=>50810),array('wood'=>9905,'clay'=>12380,'iron'=>8665,'crop'=>2475,'pop'=>2,'cp'=>13,'attri'=>77700,'time'=>59240),array('wood'=>12675,'clay'=>15845,'iron'=>11090,'crop'=>3170,'pop'=>2,'cp'=>15,'attri'=>93900,'time'=>69010),array('wood'=>16225,'clay'=>20280,'iron'=>14200,'crop'=>4055,'pop'=>2,'cp'=>18,'attri'=>113700,'time'=>80360),array('wood'=>20770,'clay'=>25960,'iron'=>18175,'crop'=>5190,'pop'=>2,'cp'=>22,'attri'=>137100,'time'=>93510),array('wood'=>26585,'clay'=>33230,'iron'=>23260,'crop'=>6645,'pop'=>2,'cp'=>27,'attri'=>165300,'time'=>108780),array('wood'=>34030,'clay'=>42535,'iron'=>29775,'crop'=>8505,'pop'=>2,'cp'=>32,'attri'=>199200,'time'=>126480),array('wood'=>43555,'clay'=>54445,'iron'=>38110,'crop'=>10890,'pop'=>2,'cp'=>38,'attri'=>240000,'time'=>147020));
+$bid40=array(1=>array('wood'=>66700,'clay'=>69050,'iron'=>72200,'crop'=>13200,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>18000),array('wood'=>68535,'clay'=>70950,'iron'=>74185,'crop'=>13565,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>18850),array('wood'=>70420,'clay'=>72900,'iron'=>76225,'crop'=>13935,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>19720),array('wood'=>72355,'clay'=>74905,'iron'=>78320,'crop'=>14320,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>20590),array('wood'=>74345,'clay'=>76965,'iron'=>80475,'crop'=>14715,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>21480),array('wood'=>76390,'clay'=>79080,'iron'=>82690,'crop'=>15120,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>22380),array('wood'=>78490,'clay'=>81255,'iron'=>84965,'crop'=>15535,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>23290),array('wood'=>80650,'clay'=>83490,'iron'=>87300,'crop'=>15960,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>24220),array('wood'=>82865,'clay'=>85785,'iron'=>89700,'crop'=>16400,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>25160),array('wood'=>85145,'clay'=>88145,'iron'=>92165,'crop'=>16850,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>26110),array('wood'=>87485,'clay'=>90570,'iron'=>94700,'crop'=>17315,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>27080),array('wood'=>89895,'clay'=>93060,'iron'=>97305,'crop'=>17790,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>28060),array('wood'=>92365,'clay'=>95620,'iron'=>99980,'crop'=>18280,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>29050),array('wood'=>94905,'clay'=>98250,'iron'=>102730,'crop'=>18780,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>30060),array('wood'=>97515,'clay'=>100950,'iron'=>105555,'crop'=>19300,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>31080),array('wood'=>100195,'clay'=>103725,'iron'=>108460,'crop'=>19830,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>32110),array('wood'=>102950,'clay'=>106580,'iron'=>111440,'crop'=>20375,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>33160),array('wood'=>105785,'clay'=>109510,'iron'=>114505,'crop'=>20935,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>34230),array('wood'=>108690,'clay'=>112520,'iron'=>117655,'crop'=>21510,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>35300),array('wood'=>111680,'clay'=>115615,'iron'=>120890,'crop'=>22100,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>36400),array('wood'=>114755,'clay'=>118795,'iron'=>124215,'crop'=>22710,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>37510),array('wood'=>117910,'clay'=>122060,'iron'=>127630,'crop'=>23335,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>38630),array('wood'=>121150,'clay'=>125420,'iron'=>131140,'crop'=>23975,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>39770),array('wood'=>124480,'clay'=>128870,'iron'=>134745,'crop'=>24635,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>40930),array('wood'=>127905,'clay'=>132410,'iron'=>138455,'crop'=>25315,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>42100),array('wood'=>131425,'clay'=>136055,'iron'=>142260,'crop'=>26010,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>43290),array('wood'=>135035,'clay'=>139795,'iron'=>146170,'crop'=>26725,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>44500),array('wood'=>138750,'clay'=>143640,'iron'=>150190,'crop'=>27460,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>45720),array('wood'=>142565,'clay'=>147590,'iron'=>154320,'crop'=>28215,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>46960),array('wood'=>146485,'clay'=>151650,'iron'=>158565,'crop'=>28990,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>48220),array('wood'=>150515,'clay'=>155820,'iron'=>162925,'crop'=>29785,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>49500),array('wood'=>154655,'clay'=>160105,'iron'=>167405,'crop'=>30605,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>50790),array('wood'=>158910,'clay'=>164505,'iron'=>172010,'crop'=>31450,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>52100),array('wood'=>163275,'clay'=>169030,'iron'=>176740,'crop'=>32315,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>53430),array('wood'=>167770,'clay'=>173680,'iron'=>181600,'crop'=>33200,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>54780),array('wood'=>172380,'clay'=>178455,'iron'=>186595,'crop'=>34115,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>56140),array('wood'=>177120,'clay'=>183360,'iron'=>191725,'crop'=>35055,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>57530),array('wood'=>181995,'clay'=>188405,'iron'=>197000,'crop'=>36015,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>58940),array('wood'=>186995,'clay'=>193585,'iron'=>202415,'crop'=>37005,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>60360),array('wood'=>192140,'clay'=>198910,'iron'=>207985,'crop'=>38025,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>61810),array('wood'=>197425,'clay'=>204380,'iron'=>213705,'crop'=>39070,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>63270),array('wood'=>202855,'clay'=>210000,'iron'=>219580,'crop'=>40145,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>64760),array('wood'=>208430,'clay'=>215775,'iron'=>225620,'crop'=>41250,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>66260),array('wood'=>214165,'clay'=>221710,'iron'=>231825,'crop'=>42385,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>67790),array('wood'=>220055,'clay'=>227805,'iron'=>238200,'crop'=>43550,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>69340),array('wood'=>226105,'clay'=>234070,'iron'=>244750,'crop'=>44745,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>70910),array('wood'=>232320,'clay'=>240505,'iron'=>251480,'crop'=>45975,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>72500),array('wood'=>238710,'clay'=>247120,'iron'=>258395,'crop'=>47240,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>74120),array('wood'=>245275,'clay'=>253915,'iron'=>265500,'crop'=>48540,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>75760),array('wood'=>252020,'clay'=>260900,'iron'=>272800,'crop'=>49875,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>77420),array('wood'=>258950,'clay'=>268075,'iron'=>280305,'crop'=>51245,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>79100),array('wood'=>266070,'clay'=>275445,'iron'=>288010,'crop'=>52655,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>80810),array('wood'=>273390,'clay'=>283020,'iron'=>295930,'crop'=>54105,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>82540),array('wood'=>280905,'clay'=>290805,'iron'=>304070,'crop'=>55590,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>84290),array('wood'=>288630,'clay'=>298800,'iron'=>312430,'crop'=>57120,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>86070),array('wood'=>296570,'clay'=>307020,'iron'=>321025,'crop'=>58690,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>87880),array('wood'=>304725,'clay'=>315460,'iron'=>329850,'crop'=>60305,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>89710),array('wood'=>313105,'clay'=>324135,'iron'=>338925,'crop'=>61965,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>91570),array('wood'=>321715,'clay'=>333050,'iron'=>348245,'crop'=>63670,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>93450),array('wood'=>330565,'clay'=>342210,'iron'=>357820,'crop'=>65420,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>95360),array('wood'=>339655,'clay'=>351620,'iron'=>367660,'crop'=>67220,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>97290),array('wood'=>348995,'clay'=>361290,'iron'=>377770,'crop'=>69065,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>99250),array('wood'=>358590,'clay'=>371225,'iron'=>388160,'crop'=>70965,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>101240),array('wood'=>368450,'clay'=>381435,'iron'=>398835,'crop'=>72915,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>103260),array('wood'=>378585,'clay'=>391925,'iron'=>409800,'crop'=>74920,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>105310),array('wood'=>388995,'clay'=>402700,'iron'=>421070,'crop'=>76985,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>107380),array('wood'=>399695,'clay'=>413775,'iron'=>432650,'crop'=>79100,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>109480),array('wood'=>410685,'clay'=>425155,'iron'=>444550,'crop'=>81275,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>111620),array('wood'=>421980,'clay'=>436845,'iron'=>456775,'crop'=>83510,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>113780),array('wood'=>433585,'clay'=>448860,'iron'=>469335,'crop'=>85805,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>115970),array('wood'=>445505,'clay'=>461205,'iron'=>482240,'crop'=>88165,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>118200),array('wood'=>457760,'clay'=>473885,'iron'=>495505,'crop'=>90590,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>120450),array('wood'=>470345,'clay'=>486920,'iron'=>509130,'crop'=>93080,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>122740),array('wood'=>483280,'clay'=>500310,'iron'=>523130,'crop'=>95640,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>125060),array('wood'=>496570,'clay'=>514065,'iron'=>537520,'crop'=>98270,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>127410),array('wood'=>510225,'clay'=>528205,'iron'=>552300,'crop'=>100975,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>129790),array('wood'=>524260,'clay'=>542730,'iron'=>567490,'crop'=>103750,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>132210),array('wood'=>538675,'clay'=>557655,'iron'=>583095,'crop'=>106605,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>134660),array('wood'=>553490,'clay'=>572990,'iron'=>599130,'crop'=>109535,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>137140),array('wood'=>568710,'clay'=>588745,'iron'=>615605,'crop'=>112550,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>139660),array('wood'=>584350,'clay'=>604935,'iron'=>632535,'crop'=>115645,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>142220),array('wood'=>600420,'clay'=>621575,'iron'=>649930,'crop'=>118825,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>144810),array('wood'=>616930,'clay'=>638665,'iron'=>667800,'crop'=>122090,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>147440),array('wood'=>633895,'clay'=>656230,'iron'=>686165,'crop'=>125450,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>150100),array('wood'=>651330,'clay'=>674275,'iron'=>705035,'crop'=>128900,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>152800),array('wood'=>669240,'clay'=>692820,'iron'=>724425,'crop'=>132445,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>155540),array('wood'=>687645,'clay'=>711870,'iron'=>744345,'crop'=>136085,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>158320),array('wood'=>706555,'clay'=>731445,'iron'=>764815,'crop'=>139830,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>161140),array('wood'=>725985,'clay'=>751560,'iron'=>785850,'crop'=>143675,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>163990),array('wood'=>745950,'clay'=>772230,'iron'=>807460,'crop'=>147625,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>166890),array('wood'=>766460,'clay'=>793465,'iron'=>829665,'crop'=>151685,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>169820),array('wood'=>787540,'clay'=>815285,'iron'=>852480,'crop'=>155855,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>172800),array('wood'=>809195,'clay'=>837705,'iron'=>875920,'crop'=>160140,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>175820),array('wood'=>831450,'clay'=>860745,'iron'=>900010,'crop'=>164545,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>178880),array('wood'=>854315,'clay'=>884415,'iron'=>924760,'crop'=>169070,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>181990),array('wood'=>877810,'clay'=>908735,'iron'=>950190,'crop'=>173720,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>185130),array('wood'=>901950,'clay'=>933725,'iron'=>976320,'crop'=>178495,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>188330),array('wood'=>926750,'clay'=>959405,'iron'=>1000000,'crop'=>183405,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>191560),array('wood'=>952235,'clay'=>985785,'iron'=>1000000,'crop'=>188450,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>194840),array('wood'=>1000000,'clay'=>1000000,'iron'=>1000000,'crop'=>193630,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>198170));
+$bid41=array(1=>array('wood'=>780,'clay'=>420,'iron'=>660,'crop'=>540,'pop'=>5,'cp'=>2,'attri'=>1.01,'time'=>2200),array('wood'=>1000,'clay'=>540,'iron'=>845,'crop'=>690,'pop'=>3,'cp'=>3,'attri'=>1.02,'time'=>3152),array('wood'=>1280,'clay'=>690,'iron'=>1080,'crop'=>885,'pop'=>3,'cp'=>3,'attri'=>1.03,'time'=>4256),array('wood'=>1635,'clay'=>880,'iron'=>1385,'crop'=>1130,'pop'=>3,'cp'=>4,'attri'=>1.04,'time'=>5537),array('wood'=>2095,'clay'=>1125,'iron'=>1770,'crop'=>1450,'pop'=>3,'cp'=>5,'attri'=>1.05,'time'=>7023),array('wood'=>2680,'clay'=>1445,'iron'=>2270,'crop'=>1855,'pop'=>3,'cp'=>6,'attri'=>1.06,'time'=>8747),array('wood'=>3430,'clay'=>1845,'iron'=>2905,'crop'=>2375,'pop'=>3,'cp'=>7,'attri'=>1.08,'time'=>10747),array('wood'=>4390,'clay'=>2365,'iron'=>3715,'crop'=>3040,'pop'=>3,'cp'=>9,'attri'=>1.09,'time'=>13066),array('wood'=>5620,'clay'=>3025,'iron'=>4755,'crop'=>3890,'pop'=>3,'cp'=>10,'attri'=>1.10,'time'=>15757),array('wood'=>7195,'clay'=>3875,'iron'=>6085,'crop'=>4980,'pop'=>3,'cp'=>12,'attri'=>1.11,'time'=>18878),array('wood'=>9210,'clay'=>4960,'iron'=>7790,'crop'=>6375,'pop'=>4,'cp'=>15,'attri'=>1.12,'time'=>22498),array('wood'=>11785,'clay'=>6345,'iron'=>9975,'crop'=>8160,'pop'=>4,'cp'=>18,'attri'=>1.14,'time'=>26698),array('wood'=>15085,'clay'=>8125,'iron'=>12765,'crop'=>10445,'pop'=>4,'cp'=>21,'attri'=>1.15,'time'=>31569),array('wood'=>19310,'clay'=>10400,'iron'=>16340,'crop'=>13370,'pop'=>4,'cp'=>26,'attri'=>1.16,'time'=>37220),array('wood'=>24720,'clay'=>13310,'iron'=>20915,'crop'=>17115,'pop'=>4,'cp'=>31,'attri'=>1.18,'time'=>43776),array('wood'=>31640,'clay'=>17035,'iron'=>26775,'crop'=>21905,'pop'=>4,'cp'=>37,'attri'=>1.19,'time'=>51380),array('wood'=>40500,'clay'=>21810,'iron'=>34270,'crop'=>28040,'pop'=>4,'cp'=>44,'attri'=>1.2,'time'=>60201),array('wood'=>51840,'clay'=>27915,'iron'=>43865,'crop'=>35890,'pop'=>4,'cp'=>53,'attri'=>1.22,'time'=>70433),array('wood'=>66355,'clay'=>35730,'iron'=>56145,'crop'=>45940,'pop'=>4,'cp'=>64,'attri'=>1.23,'time'=>82302),array('wood'=>84935,'clay'=>45735,'iron'=>71870,'crop'=>58800,'pop'=>4,'cp'=>77,'attri'=>1.25,'time'=>96070));
+$bid42=array(1=>array('wood'=>1380,'clay'=>1530,'iron'=>1800,'crop'=>960,'pop'=>3,'cp'=>4,'attri'=>100,'time'=>3000),array('wood'=>1770,'clay'=>1915,'iron'=>2310,'crop'=>1230,'pop'=>2,'cp'=>4,'attri'=>90,'time'=>3780),array('wood'=>2215,'clay'=>2505,'iron'=>2955,'crop'=>1575,'pop'=>2,'cp'=>5,'attri'=>81,'time'=>4680),array('wood'=>2895,'clay'=>3210,'iron'=>3780,'crop'=>2010,'pop'=>2,'cp'=>6,'attri'=>72.9,'time'=>5730),array('wood'=>3705,'clay'=>4110,'iron'=>4830,'crop'=>2580,'pop'=>2,'cp'=>7,'attri'=>65.61,'time'=>6950),array('wood'=>4740,'clay'=>5250,'iron'=>6180,'crop'=>3300,'pop'=>2,'cp'=>9,'attri'=>59.05,'time'=>8360),array('wood'=>6075,'clay'=>6735,'iron'=>7920,'crop'=>4215,'pop'=>2,'cp'=>11,'attri'=>53.14,'time'=>10000),array('wood'=>7730,'clay'=>8610,'iron'=>10140,'crop'=>5600,'pop'=>2,'cp'=>13,'attri'=>47.83,'time'=>11900),array('wood'=>9945,'clay'=>11025,'iron'=>12975,'crop'=>4615,'pop'=>2,'cp'=>15,'attri'=>43.05,'time'=>14110),array('wood'=>12735,'clay'=>14115,'iron'=>16605,'crop'=>8850,'pop'=>2,'cp'=>19,'attri'=>38.74,'time'=>16660),array('wood'=>16290,'clay'=>18060,'iron'=>23415,'crop'=>11340,'pop'=>3,'cp'=>22,'attri'=>34.87,'time'=>19630),array('wood'=>20850,'clay'=>23115,'iron'=>27195,'crop'=>14505,'pop'=>3,'cp'=>27,'attri'=>31.38,'time'=>23070),array('wood'=>26700,'clay'=>29595,'iron'=>34815,'crop'=>18570,'pop'=>3,'cp'=>32,'attri'=>28.24,'time'=>27060),array('wood'=>34170,'clay'=>37875,'iron'=>44565,'crop'=>23775,'pop'=>3,'cp'=>39,'attri'=>25.42,'time'=>31690),array('wood'=>43740,'clay'=>48495,'iron'=>57045,'crop'=>30420,'pop'=>3,'cp'=>46,'attri'=>22.88,'time'=>37060),array('wood'=>55980,'clay'=>62070,'iron'=>73020,'crop'=>38940,'pop'=>3,'cp'=>55,'attri'=>20.59,'time'=>43290),array('wood'=>71655,'clay'=>79440,'iron'=>93465,'crop'=>49485,'pop'=>3,'cp'=>67,'attri'=>18.53,'time'=>50520),array('wood'=>91710,'clay'=>101685,'iron'=>119625,'crop'=>63810,'pop'=>3,'cp'=>80,'attri'=>16.68,'time'=>58900),array('wood'=>105650,'clay'=>117140,'iron'=>137810,'crop'=>73510,'pop'=>3,'cp'=>96,'attri'=>15.01,'time'=>68630),array('wood'=>125225,'clay'=>138840,'iron'=>159995,'crop'=>87090,'pop'=>3,'cp'=>115,'attri'=>13.51,'time'=>79910));
+?>
\ No newline at end of file
diff --git a/GameEngine/Data/buidata.php_backup_postpercup b/GameEngine/Data/buidata.php_backup_postpercup
new file mode 100644
index 00000000..06542e05
--- /dev/null
+++ b/GameEngine/Data/buidata.php_backup_postpercup
@@ -0,0 +1,54 @@
+2),array('wood'=>40,'clay'=>100,'iron'=>50,'crop'=>60,'pop'=>2,'cp'=>1,'prod'=>5,'time'=>260),array('wood'=>65,'clay'=>165,'iron'=>85,'crop'=>100,'pop'=>1,'cp'=>1,'prod'=>9,'time'=>620),array('wood'=>110,'clay'=>280,'iron'=>140,'crop'=>165,'pop'=>1,'cp'=>2,'prod'=>15,'time'=>1190),array('wood'=>185,'clay'=>465,'iron'=>235,'crop'=>280,'pop'=>1,'cp'=>2,'prod'=>22,'time'=>2100),array('wood'=>310,'clay'=>780,'iron'=>390,'crop'=>465,'pop'=>1,'cp'=>2,'prod'=>33,'time'=>3560),array('wood'=>520,'clay'=>1300,'iron'=>650,'crop'=>780,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>3638),array('wood'=>870,'clay'=>2170,'iron'=>1085,'crop'=>1300,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>7220),array('wood'=>1450,'clay'=>3625,'iron'=>1810,'crop'=>2175,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>15590),array('wood'=>2420,'clay'=>6050,'iron'=>3025,'crop'=>3630,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>25150),array('wood'=>4040,'clay'=>10105,'iron'=>5050,'crop'=>6060,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>40440),array('wood'=>6750,'clay'=>16870,'iron'=>8435,'crop'=>10125,'pop'=>2,'cp'=>7,'prod'=>280,'time'=>64900),array('wood'=>11270,'clay'=>28175,'iron'=>14090,'crop'=>16905,'pop'=>2,'cp'=>9,'prod'=>375,'time'=>104050),array('wood'=>18820,'clay'=>47055,'iron'=>23525,'crop'=>28230,'pop'=>2,'cp'=>11,'prod'=>495,'time'=>166680),array('wood'=>31430,'clay'=>78580,'iron'=>39290,'crop'=>47150,'pop'=>2,'cp'=>13,'prod'=>635,'time'=>266880),array('wood'=>52490,'clay'=>131230,'iron'=>65615,'crop'=>78740,'pop'=>2,'cp'=>15,'prod'=>800,'time'=>427210),array('wood'=>87660,'clay'=>219155,'iron'=>109575,'crop'=>131490,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>683730),array('wood'=>146395,'clay'=>365985,'iron'=>182995,'crop'=>219590,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>1094170),array('wood'=>244480,'clay'=>611195,'iron'=>305600,'crop'=>366715,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>1750880),array('wood'=>408280,'clay'=>1020695,'iron'=>510350,'crop'=>612420,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>2801600),array('wood'=>681825,'clay'=>1704565,'iron'=>852280,'crop'=>1022740,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>4482770));
+$bid2=array(array('prod'=>2),array('wood'=>80,'clay'=>40,'iron'=>80,'crop'=>50,'pop'=>2,'cp'=>1,'prod'=>5,'time'=>220),array('wood'=>135,'clay'=>65,'iron'=>135,'crop'=>85,'pop'=>1,'cp'=>1,'prod'=>9,'time'=>550),array('wood'=>225,'clay'=>110,'iron'=>225,'crop'=>140,'pop'=>1,'cp'=>2,'prod'=>15,'time'=>1080),array('wood'=>375,'clay'=>185,'iron'=>375,'crop'=>235,'pop'=>1,'cp'=>2,'prod'=>22,'time'=>1930),array('wood'=>620,'clay'=>310,'iron'=>620,'crop'=>390,'pop'=>1,'cp'=>2,'prod'=>33,'time'=>3290),array('wood'=>1040,'clay'=>520,'iron'=>1040,'crop'=>650,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>5470),array('wood'=>1735,'clay'=>870,'iron'=>1735,'crop'=>1085,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>8950),array('wood'=>2900,'clay'=>1450,'iron'=>2900,'crop'=>1810,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>14520),array('wood'=>4840,'clay'=>2420,'iron'=>4840,'crop'=>3025,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>23430),array('wood'=>8080,'clay'=>4040,'iron'=>8080,'crop'=>5050,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>37690),array('wood'=>13500,'clay'=>6750,'iron'=>13500,'crop'=>8435,'pop'=>2,'cp'=>7,'prod'=>280,'time'=>60510),array('wood'=>22540,'clay'=>11270,'iron'=>22540,'crop'=>14090,'pop'=>2,'cp'=>9,'prod'=>375,'time'=>97010),array('wood'=>37645,'clay'=>18820,'iron'=>37645,'crop'=>23525,'pop'=>2,'cp'=>11,'prod'=>495,'time'=>155420),array('wood'=>62865,'clay'=>31430,'iron'=>62865,'crop'=>39290,'pop'=>2,'cp'=>13,'prod'=>635,'time'=>248870),array('wood'=>104985,'clay'=>52490,'iron'=>104985,'crop'=>65615,'pop'=>2,'cp'=>15,'prod'=>800,'time'=>398390),array('wood'=>175320,'clay'=>87660,'iron'=>175320,'crop'=>109575,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>637620),array('wood'=>292790,'clay'=>146395,'iron'=>292790,'crop'=>182995,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>1020390),array('wood'=>488955,'clay'=>244480,'iron'=>488955,'crop'=>305600,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>1632820),array('wood'=>816555,'clay'=>408280,'iron'=>816555,'crop'=>510350,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>2612710),array('wood'=>1363650,'clay'=>681825,'iron'=>1363650,'crop'=>852280,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>4180540));
+$bid3=array(array('prod'=>2),array('wood'=>100,'clay'=>80,'iron'=>30,'crop'=>60,'pop'=>3,'cp'=>1,'prod'=>5,'time'=>450),array('wood'=>165,'clay'=>135,'iron'=>50,'crop'=>100,'pop'=>2,'cp'=>1,'prod'=>9,'time'=>920),array('wood'=>280,'clay'=>225,'iron'=>85,'crop'=>165,'pop'=>2,'cp'=>2,'prod'=>15,'time'=>1670),array('wood'=>465,'clay'=>375,'iron'=>140,'crop'=>280,'pop'=>2,'cp'=>2,'prod'=>22,'time'=>2880),array('wood'=>780,'clay'=>620,'iron'=>235,'crop'=>465,'pop'=>2,'cp'=>2,'prod'=>33,'time'=>4800),array('wood'=>1300,'clay'=>1040,'iron'=>390,'crop'=>780,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>7880),array('wood'=>2170,'clay'=>1735,'iron'=>650,'crop'=>1300,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>12810),array('wood'=>3625,'clay'=>2900,'iron'=>1085,'crop'=>2175,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>20690),array('wood'=>6050,'clay'=>4840,'iron'=>1815,'crop'=>3630,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>33310),array('wood'=>10105,'clay'=>8080,'iron'=>3030,'crop'=>6060,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>53500),array('wood'=>16870,'clay'=>13500,'iron'=>5060,'crop'=>10125,'pop'=>3,'cp'=>7,'prod'=>280,'time'=>85800),array('wood'=>28175,'clay'=>22540,'iron'=>8455,'crop'=>16905,'pop'=>3,'cp'=>9,'prod'=>375,'time'=>137470),array('wood'=>47055,'clay'=>37645,'iron'=>14115,'crop'=>28230,'pop'=>3,'cp'=>11,'prod'=>495,'time'=>220160),array('wood'=>78580,'clay'=>62865,'iron'=>23575,'crop'=>47150,'pop'=>3,'cp'=>13,'prod'=>635,'time'=>352450),array('wood'=>131230,'clay'=>104985,'iron'=>39370,'crop'=>78740,'pop'=>3,'cp'=>15,'prod'=>800,'time'=>564120),array('wood'=>219155,'clay'=>175320,'iron'=>65745,'crop'=>131490,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>902760),array('wood'=>365985,'clay'=>292790,'iron'=>109795,'crop'=>219590,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>145546),array('wood'=>611195,'clay'=>488955,'iron'=>183360,'crop'=>366715,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>2311660),array('wood'=>1020695,'clay'=>816555,'iron'=>306210,'crop'=>612420,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>3698850),array('wood'=>1704565,'clay'=>1363650,'iron'=>511370,'crop'=>1022740,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>5918370));
+$bid4=array(array('prod'=>2),array('wood'=>70,'clay'=>90,'iron'=>70,'crop'=>20,'pop'=>0,'cp'=>1,'prod'=>5,'time'=>150),array('wood'=>115,'clay'=>150,'iron'=>115,'crop'=>35,'pop'=>0,'cp'=>1,'prod'=>9,'time'=>440),array('wood'=>195,'clay'=>250,'iron'=>195,'crop'=>55,'pop'=>0,'cp'=>2,'prod'=>15,'time'=>900),array('wood'=>325,'clay'=>420,'iron'=>325,'crop'=>95,'pop'=>0,'cp'=>2,'prod'=>22,'time'=>1650),array('wood'=>545,'clay'=>700,'iron'=>545,'crop'=>155,'pop'=>0,'cp'=>2,'prod'=>33,'time'=>2830),array('wood'=>910,'clay'=>1170,'iron'=>910,'crop'=>260,'pop'=>1,'cp'=>3,'prod'=>50,'time'=>4730),array('wood'=>1520,'clay'=>1950,'iron'=>1520,'crop'=>435,'pop'=>1,'cp'=>4,'prod'=>70,'time'=>7780),array('wood'=>2535,'clay'=>3260,'iron'=>2535,'crop'=>725,'pop'=>1,'cp'=>4,'prod'=>100,'time'=>12190),array('wood'=>4235,'clay'=>5445,'iron'=>4235,'crop'=>1210,'pop'=>1,'cp'=>5,'prod'=>145,'time'=>19690),array('wood'=>7070,'clay'=>9095,'iron'=>7070,'crop'=>2020,'pop'=>1,'cp'=>6,'prod'=>200,'time'=>31700),array('wood'=>11810,'clay'=>15185,'iron'=>11810,'crop'=>3375,'pop'=>1,'cp'=>7,'prod'=>280,'time'=>50910),array('wood'=>19725,'clay'=>25360,'iron'=>19725,'crop'=>5635,'pop'=>1,'cp'=>9,'prod'=>375,'time'=>84700),array('wood'=>32940,'clay'=>42350,'iron'=>32940,'crop'=>9410,'pop'=>1,'cp'=>11,'prod'=>495,'time'=>135710),array('wood'=>55005,'clay'=>70720,'iron'=>55005,'crop'=>15715,'pop'=>1,'cp'=>13,'prod'=>635,'time'=>217340),array('wood'=>91860,'clay'=>118105,'iron'=>91860,'crop'=>26245,'pop'=>1,'cp'=>15,'prod'=>800,'time'=>347950),array('wood'=>153405,'clay'=>197240,'iron'=>153405,'crop'=>43830,'pop'=>2,'cp'=>18,'prod'=>1000,'time'=>556910),array('wood'=>256190,'clay'=>329385,'iron'=>256190,'crop'=>73195,'pop'=>2,'cp'=>22,'prod'=>1300,'time'=>891260),array('wood'=>427835,'clay'=>550075,'iron'=>427835,'crop'=>122240,'pop'=>2,'cp'=>27,'prod'=>1600,'time'=>1426210),array('wood'=>714485,'clay'=>918625,'iron'=>714485,'crop'=>204140,'pop'=>2,'cp'=>32,'prod'=>2000,'time'=>2282140),array('wood'=>1193195,'clay'=>1534105,'iron'=>1193195,'crop'=>340915,'pop'=>2,'cp'=>38,'prod'=>2450,'time'=>3651630));
+$bid5=array(1=>array('wood'=>520,'clay'=>380,'iron'=>290,'crop'=>90,'pop'=>4,'cp'=>1,'attri'=>5,'time'=>3000),array('wood'=>935,'clay'=>685,'iron'=>520,'crop'=>160,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>5700),array('wood'=>1685,'clay'=>1230,'iron'=>940,'crop'=>290,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>9750),array('wood'=>3035,'clay'=>2215,'iron'=>1690,'crop'=>525,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>15830),array('wood'=>5460,'clay'=>3990,'iron'=>3045,'crop'=>945,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>24940));
+$bid6=array(1=>array('wood'=>440,'clay'=>480,'iron'=>320,'crop'=>50,'pop'=>3,'cp'=>1,'attri'=>5,'time'=>2240),array('wood'=>790,'clay'=>865,'iron'=>575,'crop'=>90,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>4560),array('wood'=>1425,'clay'=>1555,'iron'=>1035,'crop'=>160,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>8040),array('wood'=>2565,'clay'=>2800,'iron'=>1865,'crop'=>290,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>13260),array('wood'=>4620,'clay'=>5040,'iron'=>3360,'crop'=>525,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>21090));
+$bid7=array(1=>array('wood'=>200,'clay'=>450,'iron'=>510,'crop'=>120,'pop'=>6,'cp'=>1,'attri'=>5,'time'=>4080),array('wood'=>360,'clay'=>810,'iron'=>920,'crop'=>215,'pop'=>3,'cp'=>1,'attri'=>10,'time'=>7320),array('wood'=>650,'clay'=>1460,'iron'=>1650,'crop'=>390,'pop'=>3,'cp'=>2,'attri'=>15,'time'=>12180),array('wood'=>1165,'clay'=>2625,'iron'=>2975,'crop'=>700,'pop'=>3,'cp'=>2,'attri'=>20,'time'=>19470),array('wood'=>2100,'clay'=>4725,'iron'=>5355,'crop'=>1260,'pop'=>3,'cp'=>2,'attri'=>25,'time'=>30410));
+$bid8=array(1=>array('wood'=>500,'clay'=>440,'iron'=>380,'crop'=>1240,'pop'=>3,'cp'=>1,'attri'=>5,'time'=>1840),array('wood'=>900,'clay'=>790,'iron'=>685,'crop'=>2230,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>3960),array('wood'=>1620,'clay'=>1425,'iron'=>1230,'crop'=>4020,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>7140),array('wood'=>2915,'clay'=>2565,'iron'=>2215,'crop'=>7230,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>11910),array('wood'=>5250,'clay'=>4620,'iron'=>3990,'crop'=>13015,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>19070));
+$bid9=array(1=>array('wood'=>1200,'clay'=>1480,'iron'=>870,'crop'=>1600,'pop'=>4,'cp'=>1,'attri'=>5,'time'=>3680),array('wood'=>2160,'clay'=>2665,'iron'=>1565,'crop'=>2880,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>6720),array('wood'=>3890,'clay'=>4795,'iron'=>2820,'crop'=>5185,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>11280),array('wood'=>7000,'clay'=>8630,'iron'=>5075,'crop'=>9330,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>18120),array('wood'=>12595,'clay'=>15535,'iron'=>9135,'crop'=>16795,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>28380));
+$bid10=array(1=>array('wood'=>130,'clay'=>160,'iron'=>90,'crop'=>40,'pop'=>1,'cp'=>1,'attri'=>1200,'time'=>2000),array('wood'=>165,'clay'=>205,'iron'=>115,'crop'=>50,'pop'=>1,'cp'=>1,'attri'=>1700,'time'=>2620),array('wood'=>215,'clay'=>260,'iron'=>145,'crop'=>65,'pop'=>1,'cp'=>2,'attri'=>2300,'time'=>3340),array('wood'=>275,'clay'=>335,'iron'=>190,'crop'=>85,'pop'=>1,'cp'=>2,'attri'=>3100,'time'=>4170),array('wood'=>350,'clay'=>430,'iron'=>240,'crop'=>105,'pop'=>1,'cp'=>2,'attri'=>4000,'time'=>5140),array('wood'=>445,'clay'=>550,'iron'=>310,'crop'=>135,'pop'=>1,'cp'=>3,'attri'=>5000,'time'=>6260),array('wood'=>570,'clay'=>705,'iron'=>395,'crop'=>175,'pop'=>1,'cp'=>4,'attri'=>6300,'time'=>7570),array('wood'=>730,'clay'=>900,'iron'=>505,'crop'=>225,'pop'=>1,'cp'=>4,'attri'=>7800,'time'=>9080),array('wood'=>935,'clay'=>1115,'iron'=>650,'crop'=>290,'pop'=>1,'cp'=>5,'attri'=>9600,'time'=>10830),array('wood'=>1200,'clay'=>1475,'iron'=>830,'crop'=>370,'pop'=>1,'cp'=>6,'attri'=>11800,'time'=>12860),array('wood'=>1535,'clay'=>1890,'iron'=>1065,'crop'=>470,'pop'=>2,'cp'=>7,'attri'=>14400,'time'=>15220),array('wood'=>1965,'clay'=>2420,'iron'=>1360,'crop'=>605,'pop'=>2,'cp'=>9,'attri'=>17600,'time'=>17950),array('wood'=>2515,'clay'=>3095,'iron'=>1740,'crop'=>775,'pop'=>2,'cp'=>11,'attri'=>21400,'time'=>21130),array('wood'=>3220,'clay'=>3960,'iron'=>2230,'crop'=>990,'pop'=>2,'cp'=>13,'attri'=>25900,'time'=>24810),array('wood'=>4120,'clay'=>5070,'iron'=>2850,'crop'=>1270,'pop'=>2,'cp'=>15,'attri'=>31300,'time'=>29080),array('wood'=>5275,'clay'=>6490,'iron'=>3650,'crop'=>1625,'pop'=>2,'cp'=>18,'attri'=>37900,'time'=>34030),array('wood'=>6750,'clay'=>8310,'iron'=>4675,'crop'=>2075,'pop'=>2,'cp'=>22,'attri'=>45700,'time'=>39770),array('wood'=>8640,'clay'=>10635,'iron'=>5980,'crop'=>2660,'pop'=>2,'cp'=>27,'attri'=>55100,'time'=>46440),array('wood'=>11060,'clay'=>13610,'iron'=>7655,'crop'=>3405,'pop'=>2,'cp'=>32,'attri'=>66400,'time'=>54170),array('wood'=>14155,'clay'=>17420,'iron'=>9800,'crop'=>4355,'pop'=>2,'cp'=>38,'attri'=>80000,'time'=>63130));
+$bid11=array(1=>array('wood'=>80,'clay'=>100,'iron'=>70,'crop'=>20,'pop'=>1,'cp'=>1,'attri'=>1200,'time'=>1600),array('wood'=>100,'clay'=>130,'iron'=>90,'crop'=>25,'pop'=>1,'cp'=>1,'attri'=>1700,'time'=>2160),array('wood'=>130,'clay'=>165,'iron'=>115,'crop'=>35,'pop'=>1,'cp'=>2,'attri'=>2300,'time'=>2800),array('wood'=>170,'clay'=>210,'iron'=>145,'crop'=>40,'pop'=>1,'cp'=>2,'attri'=>3100,'time'=>3550),array('wood'=>215,'clay'=>270,'iron'=>190,'crop'=>55,'pop'=>1,'cp'=>2,'attri'=>4000,'time'=>4420),array('wood'=>275,'clay'=>345,'iron'=>240,'crop'=>70,'pop'=>1,'cp'=>3,'attri'=>5000,'time'=>5420),array('wood'=>350,'clay'=>440,'iron'=>310,'crop'=>90,'pop'=>1,'cp'=>4,'attri'=>6300,'time'=>6590),array('wood'=>450,'clay'=>565,'iron'=>395,'crop'=>115,'pop'=>1,'cp'=>4,'attri'=>7800,'time'=>7950),array('wood'=>575,'clay'=>720,'iron'=>505,'crop'=>145,'pop'=>1,'cp'=>5,'attri'=>9600,'time'=>9520),array('wood'=>740,'clay'=>920,'iron'=>645,'crop'=>185,'pop'=>1,'cp'=>6,'attri'=>11800,'time'=>11340),array('wood'=>945,'clay'=>1180,'iron'=>825,'crop'=>235,'pop'=>2,'cp'=>7,'attri'=>14400,'time'=>13450),array('wood'=>1210,'clay'=>1510,'iron'=>1060,'crop'=>300,'pop'=>2,'cp'=>9,'attri'=>17600,'time'=>15910),array('wood'=>1545,'clay'=>1935,'iron'=>1355,'crop'=>385,'pop'=>2,'cp'=>11,'attri'=>21400,'time'=>18750),array('wood'=>1980,'clay'=>2475,'iron'=>1735,'crop'=>495,'pop'=>2,'cp'=>13,'attri'=>25900,'time'=>22050),array('wood'=>2535,'clay'=>3170,'iron'=>2220,'crop'=>635,'pop'=>2,'cp'=>15,'attri'=>31300,'time'=>25880),array('wood'=>3245,'clay'=>4055,'iron'=>2840,'crop'=>810,'pop'=>2,'cp'=>18,'attri'=>37900,'time'=>30320),array('wood'=>4155,'clay'=>5190,'iron'=>3635,'crop'=>1040,'pop'=>2,'cp'=>22,'attri'=>45700,'time'=>35470),array('wood'=>5315,'clay'=>6645,'iron'=>4650,'crop'=>1330,'pop'=>2,'cp'=>27,'attri'=>55100,'time'=>41450),array('wood'=>6805,'clay'=>8505,'iron'=>5955,'crop'=>1700,'pop'=>2,'cp'=>32,'attri'=>66400,'time'=>48380),array('wood'=>8710,'clay'=>10890,'iron'=>7620,'crop'=>2180,'pop'=>2,'cp'=>38,'attri'=>80000,'time'=>56420));
+$bid12=array(1=>array('wood'=>170,'clay'=>200,'iron'=>380,'crop'=>130,'pop'=>4,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>220,'clay'=>255,'iron'=>485,'crop'=>165,'pop'=>2,'cp'=>3,'attri'=>96,'time'=>2620),array('wood'=>280,'clay'=>330,'iron'=>625,'crop'=>215,'pop'=>2,'cp'=>3,'attri'=>93,'time'=>3340),array('wood'=>355,'clay'=>420,'iron'=>795,'crop'=>275,'pop'=>2,'cp'=>4,'attri'=>90,'time'=>4170),array('wood'=>455,'clay'=>535,'iron'=>1020,'crop'=>350,'pop'=>2,'cp'=>5,'attri'=>86,'time'=>5140),array('wood'=>585,'clay'=>685,'iron'=>1305,'crop'=>445,'pop'=>3,'cp'=>6,'attri'=>83,'time'=>6260),array('wood'=>750,'clay'=>880,'iron'=>1670,'crop'=>570,'pop'=>3,'cp'=>7,'attri'=>80,'time'=>7570),array('wood'=>955,'clay'=>1125,'iron'=>2140,'crop'=>730,'pop'=>3,'cp'=>9,'attri'=>77,'time'=>9080),array('wood'=>1225,'clay'=>1440,'iron'=>2740,'crop'=>935,'pop'=>3,'cp'=>10,'attri'=>75,'time'=>10830),array('wood'=>1570,'clay'=>1845,'iron'=>3505,'crop'=>1200,'pop'=>3,'cp'=>12,'attri'=>72,'time'=>12860),array('wood'=>2005,'clay'=>2360,'iron'=>4485,'crop'=>1535,'pop'=>3,'cp'=>15,'attri'=>69,'time'=>15220),array('wood'=>2570,'clay'=>3020,'iron'=>5740,'crop'=>1965,'pop'=>3,'cp'=>18,'attri'=>67,'time'=>17950),array('wood'=>3290,'clay'=>3870,'iron'=>7350,'crop'=>2515,'pop'=>3,'cp'=>21,'attri'=>64,'time'=>21130),array('wood'=>4210,'clay'=>4950,'iron'=>9410,'crop'=>3220,'pop'=>3,'cp'=>26,'attri'=>62,'time'=>24810),array('wood'=>5390,'clay'=>6340,'iron'=>12045,'crop'=>4120,'pop'=>3,'cp'=>31,'attri'=>60,'time'=>29080),array('wood'=>6895,'clay'=>8115,'iron'=>15415,'crop'=>5275,'pop'=>4,'cp'=>37,'attri'=>58,'time'=>34030),array('wood'=>8825,'clay'=>10385,'iron'=>19730,'crop'=>6750,'pop'=>4,'cp'=>44,'attri'=>56,'time'=>39770),array('wood'=>11300,'clay'=>13290,'iron'=>25255,'crop'=>8640,'pop'=>4,'cp'=>53,'attri'=>54,'time'=>46440),array('wood'=>14460,'clay'=>17015,'iron'=>32325,'crop'=>11060,'pop'=>4,'cp'=>64,'attri'=>52,'time'=>54170),array('wood'=>18510,'clay'=>21780,'iron'=>41380,'crop'=>14155,'pop'=>4,'cp'=>77,'attri'=>50,'time'=>63130));
+$bid13=array(1=>array('wood'=>130,'clay'=>210,'iron'=>410,'crop'=>130,'pop'=>4,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>165,'clay'=>270,'iron'=>525,'crop'=>165,'pop'=>2,'cp'=>3,'attri'=>96,'time'=>2620),array('wood'=>215,'clay'=>345,'iron'=>670,'crop'=>215,'pop'=>2,'cp'=>3,'attri'=>93,'time'=>3340),array('wood'=>275,'clay'=>440,'iron'=>860,'crop'=>275,'pop'=>2,'cp'=>4,'attri'=>90,'time'=>4170),array('wood'=>350,'clay'=>565,'iron'=>1100,'crop'=>350,'pop'=>2,'cp'=>5,'attri'=>86,'time'=>5140),array('wood'=>445,'clay'=>720,'iron'=>1410,'crop'=>445,'pop'=>3,'cp'=>6,'attri'=>83,'time'=>6260),array('wood'=>570,'clay'=>925,'iron'=>1805,'crop'=>570,'pop'=>3,'cp'=>7,'attri'=>80,'time'=>7570),array('wood'=>730,'clay'=>1180,'iron'=>2310,'crop'=>730,'pop'=>3,'cp'=>9,'attri'=>77,'time'=>9080),array('wood'=>935,'clay'=>1515,'iron'=>2955,'crop'=>935,'pop'=>3,'cp'=>10,'attri'=>75,'time'=>10830),array('wood'=>1200,'clay'=>1935,'iron'=>3780,'crop'=>1200,'pop'=>3,'cp'=>12,'attri'=>72,'time'=>12860),array('wood'=>1535,'clay'=>2480,'iron'=>4840,'crop'=>1535,'pop'=>3,'cp'=>15,'attri'=>69,'time'=>15220),array('wood'=>1965,'clay'=>3175,'iron'=>6195,'crop'=>1965,'pop'=>3,'cp'=>18,'attri'=>67,'time'=>17950),array('wood'=>2515,'clay'=>4060,'iron'=>7930,'crop'=>2515,'pop'=>3,'cp'=>21,'attri'=>64,'time'=>21130),array('wood'=>3220,'clay'=>5200,'iron'=>10150,'crop'=>3220,'pop'=>3,'cp'=>26,'attri'=>62,'time'=>24810),array('wood'=>4120,'clay'=>6655,'iron'=>12995,'crop'=>4120,'pop'=>3,'cp'=>31,'attri'=>60,'time'=>29080),array('wood'=>5275,'clay'=>8520,'iron'=>16630,'crop'=>5275,'pop'=>4,'cp'=>37,'attri'=>58,'time'=>34030),array('wood'=>6750,'clay'=>10905,'iron'=>21290,'crop'=>6750,'pop'=>4,'cp'=>44,'attri'=>56,'time'=>39770),array('wood'=>8640,'clay'=>13955,'iron'=>27250,'crop'=>8640,'pop'=>4,'cp'=>53,'attri'=>54,'time'=>46440),array('wood'=>11060,'clay'=>17865,'iron'=>34880,'crop'=>11060,'pop'=>4,'cp'=>64,'attri'=>52,'time'=>54170),array('wood'=>14155,'clay'=>22865,'iron'=>44645,'crop'=>14155,'pop'=>4,'cp'=>77,'attri'=>50,'time'=>63130));
+$bid14=array(1=>array('wood'=>1750,'clay'=>2250,'iron'=>1530,'crop'=>240,'pop'=>1,'cp'=>1,'attri'=>110,'time'=>3500),array('wood'=>2240,'clay'=>2880,'iron'=>1960,'crop'=>305,'pop'=>1,'cp'=>1,'attri'=>120,'time'=>4360),array('wood'=>2865,'clay'=>3685,'iron'=>2505,'crop'=>395,'pop'=>1,'cp'=>2,'attri'=>130,'time'=>5360),array('wood'=>3670,'clay'=>4720,'iron'=>3210,'crop'=>505,'pop'=>1,'cp'=>2,'attri'=>140,'time'=>6510),array('wood'=>4700,'clay'=>6040,'iron'=>4105,'crop'=>645,'pop'=>1,'cp'=>2,'attri'=>150,'time'=>7860),array('wood'=>6015,'clay'=>7730,'iron'=>5255,'crop'=>825,'pop'=>1,'cp'=>3,'attri'=>160,'time'=>9410),array('wood'=>7695,'clay'=>9895,'iron'=>6730,'crop'=>1055,'pop'=>1,'cp'=>4,'attri'=>170,'time'=>11220),array('wood'=>9850,'clay'=>12665,'iron'=>8615,'crop'=>1350,'pop'=>1,'cp'=>4,'attri'=>180,'time'=>13320),array('wood'=>12610,'clay'=>16215,'iron'=>11025,'crop'=>1730,'pop'=>1,'cp'=>5,'attri'=>190,'time'=>15750),array('wood'=>16140,'clay'=>20755,'iron'=>14110,'crop'=>2215,'pop'=>1,'cp'=>6,'attri'=>200,'time'=>18570),array('wood'=>20660,'clay'=>26565,'iron'=>18065,'crop'=>2835,'pop'=>2,'cp'=>7,'attri'=>210,'time'=>21840),array('wood'=>26445,'clay'=>34000,'iron'=>23120,'crop'=>3625,'pop'=>2,'cp'=>9,'attri'=>220,'time'=>25630),array('wood'=>33850,'clay'=>43520,'iron'=>29595,'crop'=>4640,'pop'=>2,'cp'=>11,'attri'=>230,'time'=>30030),array('wood'=>43330,'clay'=>55705,'iron'=>37880,'crop'=>5940,'pop'=>2,'cp'=>13,'attri'=>240,'time'=>35140),array('wood'=>55460,'clay'=>71305,'iron'=>48490,'crop'=>7605,'pop'=>2,'cp'=>15,'attri'=>250,'time'=>41060),array('wood'=>70990,'clay'=>91270,'iron'=>62065,'crop'=>9735,'pop'=>2,'cp'=>18,'attri'=>260,'time'=>47930),array('wood'=>90865,'clay'=>116825,'iron'=>79440,'crop'=>12460,'pop'=>2,'cp'=>22,'attri'=>270,'time'=>55900),array('wood'=>116305,'clay'=>149540,'iron'=>101685,'crop'=>15950,'pop'=>2,'cp'=>27,'attri'=>280,'time'=>65140),array('wood'=>148875,'clay'=>191410,'iron'=>130160,'crop'=>20415,'pop'=>2,'cp'=>32,'attri'=>290,'time'=>75860),array('wood'=>190560,'clay'=>245005,'iron'=>166600,'crop'=>26135,'pop'=>2,'cp'=>38,'attri'=>300,'time'=>88300));
+$bid15=array(1=>array('wood'=>70,'clay'=>40,'iron'=>60,'crop'=>20,'pop'=>2,'cp'=>2,'attri'=>100,'time'=>2620),array('wood'=>90,'clay'=>50,'iron'=>75,'crop'=>25,'pop'=>1,'cp'=>3,'attri'=>96,'time'=>3220),array('wood'=>115,'clay'=>65,'iron'=>100,'crop'=>35,'pop'=>1,'cp'=>3,'attri'=>93,'time'=>3880),array('wood'=>145,'clay'=>85,'iron'=>125,'crop'=>40,'pop'=>1,'cp'=>4,'attri'=>90,'time'=>4610),array('wood'=>190,'clay'=>105,'iron'=>160,'crop'=>55,'pop'=>1,'cp'=>5,'attri'=>86,'time'=>5410),array('wood'=>240,'clay'=>135,'iron'=>205,'crop'=>70,'pop'=>2,'cp'=>6,'attri'=>83,'time'=>6300),array('wood'=>310,'clay'=>175,'iron'=>265,'crop'=>90,'pop'=>2,'cp'=>7,'attri'=>80,'time'=>7280),array('wood'=>395,'clay'=>225,'iron'=>340,'crop'=>115,'pop'=>2,'cp'=>9,'attri'=>77,'time'=>8380),array('wood'=>505,'clay'=>290,'iron'=>430,'crop'=>145,'pop'=>2,'cp'=>10,'attri'=>75,'time'=>9590),array('wood'=>645,'clay'=>370,'iron'=>555,'crop'=>185,'pop'=>2,'cp'=>12,'attri'=>72,'time'=>10940),array('wood'=>825,'clay'=>470,'iron'=>710,'crop'=>235,'pop'=>2,'cp'=>15,'attri'=>69,'time'=>12440),array('wood'=>1060,'clay'=>605,'iron'=>905,'crop'=>300,'pop'=>2,'cp'=>18,'attri'=>67,'time'=>14120),array('wood'=>1355,'clay'=>775,'iron'=>1160,'crop'=>385,'pop'=>2,'cp'=>21,'attri'=>64,'time'=>15980),array('wood'=>1735,'clay'=>990,'iron'=>1485,'crop'=>495,'pop'=>2,'cp'=>26,'attri'=>62,'time'=>18050),array('wood'=>2220,'clay'=>1270,'iron'=>1900,'crop'=>635,'pop'=>2,'cp'=>31,'attri'=>60,'time'=>20370),array('wood'=>2840,'clay'=>1625,'iron'=>2435,'crop'=>810,'pop'=>3,'cp'=>37,'attri'=>58,'time'=>22950),array('wood'=>3635,'clay'=>2075,'iron'=>3115,'crop'=>1040,'pop'=>3,'cp'=>44,'attri'=>56,'time'=>25830),array('wood'=>4650,'clay'=>2660,'iron'=>3990,'crop'=>1330,'pop'=>3,'cp'=>53,'attri'=>54,'time'=>29040),array('wood'=>5955,'clay'=>3405,'iron'=>5105,'crop'=>1700,'pop'=>3,'cp'=>64,'attri'=>52,'time'=>32630),array('wood'=>7620,'clay'=>4355,'iron'=>6535,'crop'=>2180,'pop'=>3,'cp'=>77,'attri'=>50,'time'=>0));
+$bid16=array(1=>array('wood'=>110,'clay'=>160,'iron'=>90,'crop'=>70,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>670),array('wood'=>140,'clay'=>205,'iron'=>115,'crop'=>90,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>870),array('wood'=>180,'clay'=>260,'iron'=>145,'crop'=>115,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1110),array('wood'=>230,'clay'=>335,'iron'=>190,'crop'=>145,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1390),array('wood'=>295,'clay'=>430,'iron'=>240,'crop'=>190,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1710),array('wood'=>380,'clay'=>550,'iron'=>310,'crop'=>240,'pop'=>1,'cp'=>3,'attri'=>0,'time'=>2090),array('wood'=>485,'clay'=>705,'iron'=>395,'crop'=>310,'pop'=>1,'cp'=>4,'attri'=>0,'time'=>2520),array('wood'=>620,'clay'=>900,'iron'=>505,'crop'=>395,'pop'=>1,'cp'=>4,'attri'=>0,'time'=>3030),array('wood'=>795,'clay'=>1155,'iron'=>650,'crop'=>505,'pop'=>1,'cp'=>5,'attri'=>0,'time'=>3610),array('wood'=>1015,'clay'=>1475,'iron'=>830,'crop'=>645,'pop'=>1,'cp'=>6,'attri'=>0,'time'=>4290),array('wood'=>1300,'clay'=>1890,'iron'=>1065,'crop'=>825,'pop'=>2,'cp'=>7,'attri'=>0,'time'=>5070),array('wood'=>1660,'clay'=>2420,'iron'=>1360,'crop'=>1060,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>5980),array('wood'=>2130,'clay'=>3095,'iron'=>1740,'crop'=>1355,'pop'=>2,'cp'=>11,'attri'=>0,'time'=>7040),array('wood'=>2725,'clay'=>3960,'iron'=>2230,'crop'=>1735,'pop'=>2,'cp'=>13,'attri'=>0,'time'=>8270),array('wood'=>3485,'clay'=>5070,'iron'=>2850,'crop'=>2220,'pop'=>2,'cp'=>15,'attri'=>0,'time'=>9690),array('wood'=>4460,'clay'=>6490,'iron'=>3650,'crop'=>2840,'pop'=>2,'cp'=>18,'attri'=>0,'time'=>11340),array('wood'=>5710,'clay'=>8310,'iron'=>4675,'crop'=>3635,'pop'=>2,'cp'=>22,'attri'=>0,'time'=>13260),array('wood'=>7310,'clay'=>10635,'iron'=>5980,'crop'=>4650,'pop'=>2,'cp'=>27,'attri'=>0,'time'=>15480),array('wood'=>9360,'clay'=>13610,'iron'=>7655,'crop'=>5955,'pop'=>2,'cp'=>32,'attri'=>0,'time'=>18060),array('wood'=>11980,'clay'=>17420,'iron'=>9800,'crop'=>7620,'pop'=>2,'cp'=>38,'attri'=>0,'time'=>21040));
+$bid17=array(1=>array('wood'=>80,'clay'=>70,'iron'=>120,'crop'=>70,'pop'=>4,'cp'=>4,'attri'=>1,'time'=>1800),array('wood'=>100,'clay'=>90,'iron'=>155,'crop'=>90,'pop'=>2,'cp'=>4,'attri'=>2,'time'=>2390),array('wood'=>130,'clay'=>115,'iron'=>195,'crop'=>115,'pop'=>2,'cp'=>5,'attri'=>3,'time'=>3070),array('wood'=>170,'clay'=>145,'iron'=>250,'crop'=>145,'pop'=>2,'cp'=>6,'attri'=>4,'time'=>3860),array('wood'=>215,'clay'=>190,'iron'=>320,'crop'=>190,'pop'=>2,'cp'=>7,'attri'=>5,'time'=>4780),array('wood'=>275,'clay'=>240,'iron'=>410,'crop'=>240,'pop'=>3,'cp'=>9,'attri'=>6,'time'=>5840),array('wood'=>350,'clay'=>310,'iron'=>530,'crop'=>310,'pop'=>3,'cp'=>11,'attri'=>7,'time'=>7080),array('wood'=>450,'clay'=>395,'iron'=>675,'crop'=>395,'pop'=>3,'cp'=>13,'attri'=>8,'time'=>8510),array('wood'=>575,'clay'=>505,'iron'=>865,'crop'=>505,'pop'=>3,'cp'=>15,'attri'=>9,'time'=>10170),array('wood'=>740,'clay'=>645,'iron'=>1105,'crop'=>645,'pop'=>3,'cp'=>19,'attri'=>10,'time'=>12100),array('wood'=>945,'clay'=>825,'iron'=>1415,'crop'=>825,'pop'=>3,'cp'=>22,'attri'=>11,'time'=>14340),array('wood'=>1210,'clay'=>1060,'iron'=>1815,'crop'=>1060,'pop'=>3,'cp'=>27,'attri'=>12,'time'=>16930),array('wood'=>1545,'clay'=>1355,'iron'=>2320,'crop'=>1355,'pop'=>3,'cp'=>32,'attri'=>13,'time'=>19940),array('wood'=>1980,'clay'=>1735,'iron'=>2970,'crop'=>1735,'pop'=>3,'cp'=>39,'attri'=>14,'time'=>23430),array('wood'=>2535,'clay'=>2220,'iron'=>3805,'crop'=>2220,'pop'=>3,'cp'=>46,'attri'=>15,'time'=>27480),array('wood'=>3245,'clay'=>2840,'iron'=>4870,'crop'=>2840,'pop'=>4,'cp'=>55,'attri'=>16,'time'=>32180),array('wood'=>4155,'clay'=>3635,'iron'=>6230,'crop'=>3635,'pop'=>4,'cp'=>67,'attri'=>17,'time'=>37620),array('wood'=>5315,'clay'=>4650,'iron'=>7975,'crop'=>4650,'pop'=>4,'cp'=>80,'attri'=>18,'time'=>43940),array('wood'=>6805,'clay'=>5955,'iron'=>10210,'crop'=>5955,'pop'=>4,'cp'=>96,'attri'=>19,'time'=>51270),array('wood'=>8710,'clay'=>7620,'iron'=>13065,'crop'=>7620,'pop'=>4,'cp'=>115,'attri'=>20,'time'=>59780));
+$bid18=array(1=>array('wood'=>180,'clay'=>130,'iron'=>150,'crop'=>80,'pop'=>3,'cp'=>5,'attri'=>0,'time'=>2000),array('wood'=>230,'clay'=>165,'iron'=>190,'crop'=>100,'pop'=>2,'cp'=>6,'attri'=>0,'time'=>2620),array('wood'=>295,'clay'=>215,'iron'=>245,'crop'=>130,'pop'=>2,'cp'=>7,'attri'=>9,'time'=>3340),array('wood'=>375,'clay'=>275,'iron'=>315,'crop'=>170,'pop'=>2,'cp'=>8,'attri'=>12,'time'=>4170),array('wood'=>485,'clay'=>350,'iron'=>405,'crop'=>215,'pop'=>2,'cp'=>10,'attri'=>15,'time'=>5140),array('wood'=>620,'clay'=>445,'iron'=>515,'crop'=>275,'pop'=>2,'cp'=>12,'attri'=>18,'time'=>6260),array('wood'=>790,'clay'=>570,'iron'=>660,'crop'=>350,'pop'=>2,'cp'=>14,'attri'=>21,'time'=>7570),array('wood'=>1015,'clay'=>730,'iron'=>845,'crop'=>450,'pop'=>2,'cp'=>17,'attri'=>24,'time'=>9080),array('wood'=>1295,'clay'=>935,'iron'=>1080,'crop'=>575,'pop'=>2,'cp'=>21,'attri'=>27,'time'=>10830),array('wood'=>1660,'clay'=>1200,'iron'=>1385,'crop'=>740,'pop'=>2,'cp'=>25,'attri'=>30,'time'=>12860),array('wood'=>2125,'clay'=>1535,'iron'=>1770,'crop'=>945,'pop'=>3,'cp'=>30,'attri'=>33,'time'=>15220),array('wood'=>2720,'clay'=>1965,'iron'=>2265,'crop'=>1210,'pop'=>3,'cp'=>36,'attri'=>36,'time'=>17950),array('wood'=>3480,'clay'=>2515,'iron'=>2900,'crop'=>1545,'pop'=>3,'cp'=>43,'attri'=>39,'time'=>21130), array('wood'=>4455,'clay'=>3220,'iron'=>3715,'crop'=>1980,'pop'=>3,'cp'=>51,'attri'=>42,'time'=>24810),array('wood'=>5705,'clay'=>4120,'iron'=>4755,'crop'=>2535,'pop'=>3,'cp'=>62,'attri'=>45,'time'=>29080),array('wood'=>7300,'clay'=>5275,'iron'=>6085,'crop'=>3245,'pop'=>3,'cp'=>74,'attri'=>48,'time'=>34030),array('wood'=>9345,'clay'=>6750,'iron'=>7790,'crop'=>4155,'pop'=>3,'cp'=>89,'attri'=>51,'time'=>39770),array('wood'=>11965,'clay'=>8640,'iron'=>9970,'crop'=>5315,'pop'=>3,'cp'=>106,'attri'=>54,'time'=>46440),array('wood'=>15315,'clay'=>11060,'iron'=>12760,'crop'=>6805,'pop'=>3,'cp'=>128,'attri'=>57,'time'=>54170),array('wood'=>19600,'clay'=>14155,'iron'=>16335,'crop'=>8710,'pop'=>3,'cp'=>153,'attri'=>60,'time'=>63130));
+$bid19=array(1=>array('wood'=>210,'clay'=>140,'iron'=>260,'crop'=>120,'pop'=>4,'cp'=>1,'attri'=>100,'time'=>2000),array('wood'=>270,'clay'=>180,'iron'=>335,'crop'=>155,'pop'=>2,'cp'=>1,'attri'=>90,'time'=>2620),array('wood'=>345,'clay'=>230,'iron'=>425,'crop'=>195,'pop'=>2,'cp'=>2,'attri'=>81,'time'=>3340),array('wood'=>440,'clay'=>295,'iron'=>545,'crop'=>250,'pop'=>2,'cp'=>2,'attri'=>72.9,'time'=>4170),array('wood'=>565,'clay'=>375,'iron'=>700,'crop'=>320,'pop'=>2,'cp'=>2,'attri'=>65.61,'time'=>5140),array('wood'=>720,'clay'=>480,'iron'=>895,'crop'=>410,'pop'=>3,'cp'=>3,'attri'=>59.05,'time'=>6260),array('wood'=>925,'clay'=>615,'iron'=>1145,'crop'=>530,'pop'=>3,'cp'=>4,'attri'=>53.14,'time'=>7570),array('wood'=>1180,'clay'=>790,'iron'=>1465,'crop'=>675,'pop'=>3,'cp'=>4,'attri'=>47.83,'time'=>9080),array('wood'=>1515,'clay'=>1010,'iron'=>1875,'crop'=>865,'pop'=>3,'cp'=>5,'attri'=>43.05,'time'=>10830),array('wood'=>1935,'clay'=>1290,'iron'=>2400,'crop'=>1105,'pop'=>3,'cp'=>6,'attri'=>38.74,'time'=>12860),array('wood'=>2480,'clay'=>1655,'iron'=>3070,'crop'=>1415,'pop'=>3,'cp'=>7,'attri'=>34.87,'time'=>15220),array('wood'=>3175,'clay'=>2115,'iron'=>3930,'crop'=>1815,'pop'=>3,'cp'=>9,'attri'=>31.38,'time'=>17950),array('wood'=>4060,'clay'=>2710,'iron'=>5030,'crop'=>2320,'pop'=>3,'cp'=>11,'attri'=>28.24,'time'=>21130),array('wood'=>5200,'clay'=>3465,'iron'=>6435,'crop'=>2970,'pop'=>3,'cp'=>13,'attri'=>25.42,'time'=>24810),array('wood'=>6655,'clay'=>4435,'iron'=>8240,'crop'=>3805,'pop'=>3,'cp'=>15,'attri'=>22.88,'time'=>29080),array('wood'=>8520,'clay'=>5680,'iron'=>10545,'crop'=>4870,'pop'=>4,'cp'=>18,'attri'=>20.59,'time'=>34030),array('wood'=>10905,'clay'=>7270,'iron'=>13500,'crop'=>6230,'pop'=>4,'cp'=>22,'attri'=>18.53,'time'=>39770),array('wood'=>13955,'clay'=>9305,'iron'=>17280,'crop'=>7975,'pop'=>4,'cp'=>27,'attri'=>16.68,'time'=>46440),array('wood'=>17865,'clay'=>11910,'iron'=>22120,'crop'=>10210,'pop'=>4,'cp'=>32,'attri'=>15.01,'time'=>54170),array('wood'=>22865,'clay'=>15245,'iron'=>28310,'crop'=>13065,'pop'=>4,'cp'=>38,'attri'=>13.51,'time'=>63130));
+$bid20=array(1=>array('wood'=>260,'clay'=>140,'iron'=>220,'crop'=>100,'pop'=>5,'cp'=>2,'attri'=>100,'time'=>2200),array('wood'=>335,'clay'=>180,'iron'=>280,'crop'=>130,'pop'=>3,'cp'=>3,'attri'=>90,'time'=>2850),array('wood'=>425,'clay'=>230,'iron'=>360,'crop'=>165,'pop'=>3,'cp'=>3,'attri'=>81,'time'=>3610),array('wood'=>545,'clay'=>295,'iron'=>460,'crop'=>210,'pop'=>3,'cp'=>4,'attri'=>72.9,'time'=>4490),array('wood'=>700,'clay'=>375,'iron'=>590,'crop'=>270,'pop'=>3,'cp'=>5,'attri'=>65.61,'time'=>5500),array('wood'=>895,'clay'=>480,'iron'=>755,'crop'=>345,'pop'=>3,'cp'=>6,'attri'=>59.05,'time'=>6680),array('wood'=>1145,'clay'=>615,'iron'=>970,'crop'=>440,'pop'=>3,'cp'=>7,'attri'=>53.14,'time'=>8050),array('wood'=>1465,'clay'=>790,'iron'=>1240,'crop'=>565,'pop'=>3,'cp'=>9,'attri'=>47.83,'time'=>9640),array('wood'=>1875,'clay'=>1010,'iron'=>1585,'crop'=>720,'pop'=>3,'cp'=>10,'attri'=>43.05,'time'=>11480),array('wood'=>2400,'clay'=>1290,'iron'=>2030,'crop'=>920,'pop'=>3,'cp'=>12,'attri'=>38.74,'time'=>13620),array('wood'=>3070,'clay'=>1655,'iron'=>2595,'crop'=>1180,'pop'=>4,'cp'=>15,'attri'=>34.87,'time'=>16100),array('wood'=>3930,'clay'=>2115,'iron'=>3325,'crop'=>1510,'pop'=>4,'cp'=>18,'attri'=>31.38,'time'=>18980),array('wood'=>5030,'clay'=>2710,'iron'=>4255,'crop'=>1935,'pop'=>4,'cp'=>21,'attri'=>28.24,'time'=>22310),array('wood'=>6435,'clay'=>3465,'iron'=>5445,'crop'=>2475,'pop'=>4,'cp'=>26,'attri'=>25.42,'time'=>26180),array('wood'=>8240,'clay'=>4435,'iron'=>6970,'crop'=>3170,'pop'=>4,'cp'=>31,'attri'=>22.88,'time'=>30670),array('wood'=>10545,'clay'=>5680,'iron'=>8925,'crop'=>4055,'pop'=>4,'cp'=>37,'attri'=>20.59,'time'=>35880),array('wood'=>13500,'clay'=>7270,'iron'=>11425,'crop'=>5190,'pop'=>4,'cp'=>44,'attri'=>18.53,'time'=>41920),array('wood'=>17280,'clay'=>9305,'iron'=>14620,'crop'=>6645,'pop'=>4,'cp'=>53,'attri'=>16.68,'time'=>48930),array('wood'=>22120,'clay'=>11910,'iron'=>18715,'crop'=>8505,'pop'=>4,'cp'=>64,'attri'=>15.01,'time'=>57060),array('wood'=>28310,'clay'=>15245,'iron'=>23955,'crop'=>10890,'pop'=>4,'cp'=>77,'attri'=>13.51,'time'=>66490));
+$bid21=array(1=>array('wood'=>460,'clay'=>510,'iron'=>600,'crop'=>320,'pop'=>3,'cp'=>4,'attri'=>100,'time'=>3000),array('wood'=>590,'clay'=>655,'iron'=>770,'crop'=>410,'pop'=>2,'cp'=>4,'attri'=>90,'time'=>3780),array('wood'=>755,'clay'=>835,'iron'=>985,'crop'=>525,'pop'=>2,'cp'=>5,'attri'=>81,'time'=>4680),array('wood'=>965,'clay'=>1070,'iron'=>1260,'crop'=>670,'pop'=>2,'cp'=>6,'attri'=>72.9,'time'=>5730),array('wood'=>1235,'clay'=>1370,'iron'=>1610,'crop'=>860,'pop'=>2,'cp'=>7,'attri'=>65.61,'time'=>6950),array('wood'=>1580,'clay'=>1750,'iron'=>2060,'crop'=>1100,'pop'=>2,'cp'=>9,'attri'=>59.05,'time'=>8360),array('wood'=>2025,'clay'=>2245,'iron'=>2640,'crop'=>1405,'pop'=>2,'cp'=>11,'attri'=>53.14,'time'=>10000),array('wood'=>2590,'clay'=>2870,'iron'=>3380,'crop'=>1800,'pop'=>2,'cp'=>13,'attri'=>47.83,'time'=>11900),array('wood'=>3315,'clay'=>3675,'iron'=>4325,'crop'=>2305,'pop'=>2,'cp'=>15,'attri'=>43.05,'time'=>14110),array('wood'=>4245,'clay'=>4705,'iron'=>5535,'crop'=>2950,'pop'=>2,'cp'=>19,'attri'=>38.74,'time'=>16660),array('wood'=>5430,'clay'=>6020,'iron'=>7085,'crop'=>3780,'pop'=>3,'cp'=>22,'attri'=>34.87,'time'=>19630),array('wood'=>6950,'clay'=>7705,'iron'=>9065,'crop'=>4835,'pop'=>3,'cp'=>27,'attri'=>31.38,'time'=>23070),array('wood'=>8900,'clay'=>9865,'iron'=>11605,'crop'=>6190,'pop'=>3,'cp'=>32,'attri'=>28.24,'time'=>27060),array('wood'=>11390,'clay'=>12625,'iron'=>14855,'crop'=>7925,'pop'=>3,'cp'=>39,'attri'=>25.42,'time'=>31690),array('wood'=>14580,'clay'=>16165,'iron'=>19015,'crop'=>10140,'pop'=>3,'cp'=>46,'attri'=>22.88,'time'=>37060),array('wood'=>18660,'clay'=>20690,'iron'=>24340,'crop'=>12980,'pop'=>3,'cp'=>55,'attri'=>20.59,'time'=>43290),array('wood'=>23885,'clay'=>26480,'iron'=>31155,'crop'=>16615,'pop'=>3,'cp'=>67,'attri'=>18.53,'time'=>50520),array('wood'=>30570,'clay'=>33895,'iron'=>39875,'crop'=>21270,'pop'=>3,'cp'=>80,'attri'=>16.68,'time'=>58900),array('wood'=>39130,'clay'=>43385,'iron'=>51040,'crop'=>27225,'pop'=>3,'cp'=>96,'attri'=>15.01,'time'=>68630),array('wood'=>50090,'clay'=>55535,'iron'=>65335,'crop'=>34845,'pop'=>3,'cp'=>115,'attri'=>13.51,'time'=>79910));
+$bid22=array(1=>array('wood'=>220,'clay'=>160,'iron'=>90,'crop'=>40,'pop'=>4,'cp'=>5,'attri'=>0,'time'=>2000),array('wood'=>280,'clay'=>205,'iron'=>115,'crop'=>50,'pop'=>2,'cp'=>6,'attri'=>0,'time'=>2620),array('wood'=>360,'clay'=>260,'iron'=>145,'crop'=>65,'pop'=>2,'cp'=>7,'attri'=>0,'time'=>3340),array('wood'=>460,'clay'=>335,'iron'=>190,'crop'=>85,'pop'=>2,'cp'=>8,'attri'=>0,'time'=>4170),array('wood'=>590,'clay'=>430,'iron'=>240,'crop'=>105,'pop'=>2,'cp'=>10,'attri'=>0,'time'=>5140),array('wood'=>755,'clay'=>550,'iron'=>310,'crop'=>135,'pop'=>3,'cp'=>12,'attri'=>0,'time'=>6260),array('wood'=>970,'clay'=>705,'iron'=>395,'crop'=>175,'pop'=>3,'cp'=>14,'attri'=>0,'time'=>7570),array('wood'=>1240,'clay'=>900,'iron'=>505,'crop'=>225,'pop'=>3,'cp'=>17,'attri'=>0,'time'=>9080),array('wood'=>1585,'clay'=>1155,'iron'=>650,'crop'=>290,'pop'=>3,'cp'=>21,'attri'=>0,'time'=>10830),array('wood'=>2030,'clay'=>1475,'iron'=>830,'crop'=>370,'pop'=>3,'cp'=>25,'attri'=>0,'time'=>12860),array('wood'=>2595,'clay'=>1890,'iron'=>1065,'crop'=>470,'pop'=>3,'cp'=>30,'attri'=>0,'time'=>15220),array('wood'=>3325,'clay'=>2420,'iron'=>1360,'crop'=>605,'pop'=>3,'cp'=>36,'attri'=>0,'time'=>17950),array('wood'=>4255,'clay'=>3095,'iron'=>1740,'crop'=>775,'pop'=>3,'cp'=>43,'attri'=>0,'time'=>21130),array('wood'=>5445,'clay'=>3960,'iron'=>2230,'crop'=>990,'pop'=>3,'cp'=>51,'attri'=>0,'time'=>24810),array('wood'=>6970,'clay'=>5070,'iron'=>2850,'crop'=>1270,'pop'=>3,'cp'=>62,'attri'=>0,'time'=>29080),array('wood'=>8925,'clay'=>6490,'iron'=>3650,'crop'=>1625,'pop'=>4,'cp'=>74,'attri'=>0,'time'=>34030),array('wood'=>11425,'clay'=>8310,'iron'=>4675,'crop'=>2075,'pop'=>4,'cp'=>89,'attri'=>0,'time'=>39770),array('wood'=>14620,'clay'=>10635,'iron'=>5980,'crop'=>2660,'pop'=>4,'cp'=>106,'attri'=>0,'time'=>46440),array('wood'=>18715,'clay'=>13610,'iron'=>7655,'crop'=>3405,'pop'=>4,'cp'=>128,'attri'=>0,'time'=>54170),array('wood'=>23955,'clay'=>17420,'iron'=>9800,'crop'=>4355,'pop'=>4,'cp'=>153,'attri'=>0,'time'=>63130));
+$bid23=array(1=>array('wood'=>40,'clay'=>50,'iron'=>30,'crop'=>10,'pop'=>0,'cp'=>1,'attri'=>100,'time'=>750),array('wood'=>50,'clay'=>65,'iron'=>40,'crop'=>15,'pop'=>0,'cp'=>1,'attri'=>130,'time'=>1170),array('wood'=>65,'clay'=>80,'iron'=>50,'crop'=>15,'pop'=>0,'cp'=>2,'attri'=>170,'time'=>1660),array('wood'=>85,'clay'=>105,'iron'=>65,'crop'=>20,'pop'=>0,'cp'=>2,'attri'=>220,'time'=>2220),array('wood'=>105,'clay'=>135,'iron'=>80,'crop'=>25,'pop'=>0,'cp'=>2,'attri'=>280,'time'=>2880),array('wood'=>135,'clay'=>170,'iron'=>105,'crop'=>35,'pop'=>1,'cp'=>3,'attri'=>360,'time'=>3640),array('wood'=>175,'clay'=>220,'iron'=>130,'crop'=>45,'pop'=>1,'cp'=>4,'attri'=>460,'time'=>4520),array('wood'=>225,'clay'=>280,'iron'=>170,'crop'=>55,'pop'=>1,'cp'=>4,'attri'=>600,'time'=>5540),array('wood'=>290,'clay'=>360,'iron'=>215,'crop'=>70,'pop'=>1,'cp'=>5,'attri'=>770,'time'=>6730),array('wood'=>370,'clay'=>460,'iron'=>275,'crop'=>90,'pop'=>1,'cp'=>6,'attri'=>1000,'time'=>8110));
+$bid24=array(1=>array('wood'=>1250,'clay'=>1110,'iron'=>1260,'crop'=>600,'pop'=>4,'cp'=>6,'attri'=>0,'time'=>12500),array('wood'=>1600,'clay'=>1420,'iron'=>1615,'crop'=>770,'pop'=>2,'cp'=>7,'attri'=>0,'time'=>14800),array('wood'=>2050,'clay'=>1820,'iron'=>2065,'crop'=>985,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>17470),array('wood'=>2620,'clay'=>2330,'iron'=>2640,'crop'=>1260,'pop'=>2,'cp'=>10,'attri'=>0,'time'=>20560),array('wood'=>3355,'clay'=>2980,'iron'=>3380,'crop'=>1610,'pop'=>2,'cp'=>12,'attri'=>0,'time'=>24150),array('wood'=>4295,'clay'=>3815,'iron'=>4330,'crop'=>2060,'pop'=>3,'cp'=>15,'attri'=>0,'time'=>28320),array('wood'=>5500,'clay'=>4880,'iron'=>5540,'crop'=>2640,'pop'=>3,'cp'=>18,'attri'=>0,'time'=>33150),array('wood'=>7035,'clay'=>6250,'iron'=>7095,'crop'=>3380,'pop'=>3,'cp'=>21,'attri'=>0,'time'=>38750),array('wood'=>9005,'clay'=>8000,'iron'=>9080,'crop'=>4325,'pop'=>3,'cp'=>26,'attri'=>0,'time'=>45250),array('wood'=>11530,'clay'=>10240,'iron'=>11620,'crop'=>5535,'pop'=>3,'cp'=>31,'attri'=>0,'time'=>52790),array('wood'=>14755,'clay'=>13105,'iron'=>14875,'crop'=>7085,'pop'=>3,'cp'=>37,'attri'=>0,'time'=>61540),array('wood'=>18890,'clay'=>16775,'iron'=>19040,'crop'=>9065,'pop'=>3,'cp'=>45,'attri'=>0,'time'=>71690),array('wood'=>24180,'clay'=>21470,'iron'=>24370,'crop'=>11605,'pop'=>3,'cp'=>53,'attri'=>0,'time'=>83460),array('wood'=>30950,'clay'=>27480,'iron'=>31195,'crop'=>14855,'pop'=>3,'cp'=>64,'attri'=>0,'time'=>97110),array('wood'=>39615,'clay'=>35175,'iron'=>39930,'crop'=>19015,'pop'=>3,'cp'=>77,'attri'=>0,'time'=>112950),array('wood'=>50705,'clay'=>45025,'iron'=>51110,'crop'=>24340,'pop'=>4,'cp'=>92,'attri'=>0,'time'=>131320),array('wood'=>64905,'clay'=>57635,'iron'=>65425,'crop'=>31155,'pop'=>4,'cp'=>111,'attri'=>0,'time'=>152630),array('wood'=>83075,'clay'=>73770,'iron'=>83740,'crop'=>39875,'pop'=>4,'cp'=>133,'attri'=>0,'time'=>177350),array('wood'=>106340,'clay'=>94430,'iron'=>107190,'crop'=>51040,'pop'=>4,'cp'=>160,'attri'=>0,'time'=>206020),array('wood'=>136115,'clay'=>120870,'iron'=>137200,'crop'=>65335,'pop'=>4,'cp'=>192,'attri'=>0,'time'=>239290));
+$bid25=array(1=>array('wood'=>580,'clay'=>460,'iron'=>350,'crop'=>180,'pop'=>1,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>740,'clay'=>590,'iron'=>450,'crop'=>230,'pop'=>1,'cp'=>3,'attri'=>90,'time'=>2620),array('wood'=>950,'clay'=>755,'iron'=>575,'crop'=>295,'pop'=>1,'cp'=>3,'attri'=>81,'time'=>3340),array('wood'=>1215,'clay'=>965,'iron'=>735,'crop'=>375,'pop'=>1,'cp'=>4,'attri'=>72.9,'time'=>4170),array('wood'=>1555,'clay'=>1235,'iron'=>940,'crop'=>485,'pop'=>1,'cp'=>5,'attri'=>65.61,'time'=>5140),array('wood'=>1995,'clay'=>1580,'iron'=>1205,'crop'=>620,'pop'=>1,'cp'=>6,'attri'=>59.05,'time'=>6260),array('wood'=>2550,'clay'=>2025,'iron'=>1540,'crop'=>790,'pop'=>1,'cp'=>7,'attri'=>53.14,'time'=>7570),array('wood'=>3265,'clay'=>2590,'iron'=>1970,'crop'=>1015,'pop'=>1,'cp'=>9,'attri'=>47.83,'time'=>9080),array('wood'=>4180,'clay'=>3315,'iron'=>2520,'crop'=>1295,'pop'=>1,'cp'=>10,'attri'=>43.05,'time'=>10830),array('wood'=>5350,'clay'=>4245,'iron'=>3230,'crop'=>1660,'pop'=>1,'cp'=>12,'attri'=>38.74,'time'=>12860),array('wood'=>6845,'clay'=>5430,'iron'=>4130,'crop'=>2125,'pop'=>2,'cp'=>15,'attri'=>34.87,'time'=>15220),array('wood'=>8765,'clay'=>6950,'iron'=>5290,'crop'=>2720,'pop'=>2,'cp'=>18,'attri'=>31.38,'time'=>17950),array('wood'=>11220,'clay'=>8900,'iron'=>6770,'crop'=>3480,'pop'=>2,'cp'=>21,'attri'=>28.24,'time'=>21130),array('wood'=>14360,'clay'=>11390,'iron'=>8665,'crop'=>4455,'pop'=>2,'cp'=>26,'attri'=>25.42,'time'=>24810),array('wood'=>18380,'clay'=>14580,'iron'=>11090,'crop'=>5705,'pop'=>2,'cp'=>31,'attri'=>22.88,'time'=>29080),array('wood'=>23530,'clay'=>18660,'iron'=>14200,'crop'=>7300,'pop'=>2,'cp'=>37,'attri'=>20.59,'time'=>34030),array('wood'=>30115,'clay'=>23885,'iron'=>18175,'crop'=>9345,'pop'=>2,'cp'=>44,'attri'=>18.53,'time'=>39770),array('wood'=>38550,'clay'=>30570,'iron'=>23260,'crop'=>11965,'pop'=>2,'cp'=>53,'attri'=>16.68,'time'=>46440),array('wood'=>49340,'clay'=>39130,'iron'=>29775,'crop'=>15315,'pop'=>2,'cp'=>64,'attri'=>15.01,'time'=>54170),array('wood'=>63155,'clay'=>50090,'iron'=>38110,'crop'=>19600,'pop'=>2,'cp'=>77,'attri'=>13.51,'time'=>63130));
+$bid26=array(1=>array('wood'=>550,'clay'=>800,'iron'=>750,'crop'=>250,'pop'=>1,'cp'=>6,'attri'=>100,'time'=>5000),array('wood'=>705,'clay'=>1025,'iron'=>960,'crop'=>320,'pop'=>1,'cp'=>7,'attri'=>90,'time'=>6100),array('wood'=>900,'clay'=>1310,'iron'=>1230,'crop'=>410,'pop'=>1,'cp'=>9,'attri'=>81,'time'=>7380),array('wood'=>1155,'clay'=>1680,'iron'=>1575,'crop'=>525,'pop'=>1,'cp'=>10,'attri'=>72.9,'time'=>8860),array('wood'=>1475,'clay'=>2145,'iron'=>2015,'crop'=>670,'pop'=>1,'cp'=>12,'attri'=>65.61,'time'=>10570),array('wood'=>1890,'clay'=>2750,'iron'=>2575,'crop'=>860,'pop'=>1,'cp'=>15,'attri'=>59.05,'time'=>12560),array('wood'=>2420,'clay'=>3520,'iron'=>3300,'crop'=>1100,'pop'=>1,'cp'=>18,'attri'=>53.14,'time'=>14880),array('wood'=>3095,'clay'=>4505,'iron'=>4220,'crop'=>1405,'pop'=>1,'cp'=>21,'attri'=>47.83,'time'=>17560),array('wood'=>3965,'clay'=>5765,'iron'=>5405,'crop'=>1800,'pop'=>1,'cp'=>26,'attri'=>43.05,'time'=>20660),array('wood'=>5075,'clay'=>7380,'iron'=>6920,'crop'=>2305,'pop'=>1,'cp'=>31,'attri'=>38.74,'time'=>24270),array('wood'=>6495,'clay'=>9445,'iron'=>8855,'crop'=>2950,'pop'=>2,'cp'=>37,'attri'=>34.87,'time'=>28450),array('wood'=>8310,'clay'=>12090,'iron'=>11335,'crop'=>3780,'pop'=>2,'cp'=>45,'attri'=>31.38,'time'=>33310),array('wood'=>10640,'clay'=>15475,'iron'=>14505,'crop'=>4835,'pop'=>2,'cp'=>53,'attri'=>28.24,'time'=>38940),array('wood'=>13615,'clay'=>19805,'iron'=>18570,'crop'=>6190,'pop'=>2,'cp'=>64,'attri'=>25.42,'time'=>45460),array('wood'=>17430,'clay'=>25355,'iron'=>23770,'crop'=>7925,'pop'=>2,'cp'=>77,'attri'=>22.88,'time'=>53040),array('wood'=>22310,'clay'=>32450,'iron'=>30425,'crop'=>10140,'pop'=>2,'cp'=>92,'attri'=>20.59,'time'=>61830),array('wood'=>28560,'clay'=>41540,'iron'=>38940,'crop'=>12980,'pop'=>2,'cp'=>111,'attri'=>18.53,'time'=>72020),array('wood'=>36555,'clay'=>53170,'iron'=>49845,'crop'=>16615,'pop'=>2,'cp'=>133,'attri'=>16.68,'time'=>83840),array('wood'=>46790,'clay'=>68055,'iron'=>63805,'crop'=>21270,'pop'=>2,'cp'=>160,'attri'=>15.01,'time'=>97550),array('wood'=>59890,'clay'=>87110,'iron'=>81670,'crop'=>27225,'pop'=>2,'cp'=>192,'attri'=>13.51,'time'=>113460));
+$bid27=array(1=>array('wood'=>2880,'clay'=>2740,'iron'=>2580,'crop'=>990,'pop'=>4,'cp'=>7,'attri'=>0,'time'=>8000),array('wood'=>3630,'clay'=>3450,'iron'=>3250,'crop'=>1245,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>9580),array('wood'=>4570,'clay'=>4350,'iron'=>4095,'crop'=>1570,'pop'=>2,'cp'=>10,'attri'=>0,'time'=>11410),array('wood'=>5760,'clay'=>5480,'iron'=>5160,'crop'=>1980,'pop'=>2,'cp'=>12,'attri'=>0,'time'=>13540),array('wood'=>7260,'clay'=>6905,'iron'=>6505,'crop'=>2495,'pop'=>2,'cp'=>15,'attri'=>0,'time'=>16010),array('wood'=>9145,'clay'=>8700,'iron'=>8195,'crop'=>3145,'pop'=>3,'cp'=>18,'attri'=>0,'time'=>18870),array('wood'=>11525,'clay'=>10965,'iron'=>10325,'crop'=>3960,'pop'=>3,'cp'=>21,'attri'=>0,'time'=>22180),array('wood'=>14520,'clay'=>13815,'iron'=>13010,'crop'=>4990,'pop'=>3,'cp'=>26,'attri'=>0,'time'=>26030),array('wood'=>18295,'clay'=>17405,'iron'=>16390,'crop'=>6290,'pop'=>3,'cp'=>31,'attri'=>0,'time'=>30500),array('wood'=>23055,'clay'=>21930,'iron'=>20650,'crop'=>7925,'pop'=>3,'cp'=>37,'attri'=>1,'time'=>35680),array('wood'=>9045,'clay'=>27635,'iron'=>26020,'crop'=>9985,'pop'=>3,'cp'=>45,'attri'=>1,'time'=>41690),array('wood'=>6600,'clay'=>34820,'iron'=>32785,'crop'=>12580,'pop'=>3,'cp'=>53,'attri'=>1,'time'=>48660),array('wood'=>46115,'clay'=>43875,'iron'=>41310,'crop'=>15850,'pop'=>3,'cp'=>64,'attri'=>1,'time'=>56740),array('wood'=>58105,'clay'=>55280,'iron'=>52050,'crop'=>19975,'pop'=>3,'cp'=>77,'attri'=>1,'time'=>66120),array('wood'=>73210,'clay'=>69655,'iron'=>65585,'crop'=>25165,'pop'=>3,'cp'=>92,'attri'=>1,'time'=>77000),array('wood'=>92245,'clay'=>87760,'iron'=>82640,'crop'=>31710,'pop'=>4,'cp'=>111,'attri'=>1,'time'=>89620),array('wood'=>116230,'clay'=>110580,'iron'=>104125,'crop'=>39955,'pop'=>4,'cp'=>133,'attri'=>1,'time'=>104260),array('wood'=>146450,'clay'=>139330,'iron'=>131195,'crop'=>50340,'pop'=>4,'cp'=>160,'attri'=>1,'time'=>121240),array('wood'=>184530,'clay'=>175560,'iron'=>165305,'crop'=>63430,'pop'=>4,'cp'=>192,'attri'=>1,'time'=>140940),array('wood'=>232505,'clay'=>221205,'iron'=>208285,'crop'=>79925,'pop'=>4,'cp'=>230,'attri'=>1,'time'=>163790));
+$bid28=array(1=>array('wood'=>1400,'clay'=>1330,'iron'=>1200,'crop'=>400,'pop'=>3,'cp'=>4,'attri'=>110,'time'=>3000),array('wood'=>1790,'clay'=>1700,'iron'=>1535,'crop'=>510,'pop'=>2,'cp'=>4,'attri'=>120,'time'=>3780),array('wood'=>2295,'clay'=>2180,'iron'=>1965,'crop'=>655,'pop'=>2,'cp'=>5,'attri'=>130,'time'=>4680),array('wood'=>2935,'clay'=>2790,'iron'=>2515,'crop'=>840,'pop'=>2,'cp'=>6,'attri'=>140,'time'=>5730),array('wood'=>3760,'clay'=>3570,'iron'=>3220,'crop'=>1075,'pop'=>2,'cp'=>7,'attri'=>150,'time'=>6950),array('wood'=>4810,'clay'=>4570,'iron'=>4125,'crop'=>1375,'pop'=>2,'cp'=>9,'attri'=>160,'time'=>8360),array('wood'=>6155,'clay'=>5850,'iron'=>5280,'crop'=>1760,'pop'=>2,'cp'=>11,'attri'=>170,'time'=>10000),array('wood'=>7880,'clay'=>7485,'iron'=>6755,'crop'=>2250,'pop'=>2,'cp'=>13,'attri'=>180,'time'=>11900),array('wood'=>10090,'clay'=>9585,'iron'=>8645,'crop'=>2880,'pop'=>2,'cp'=>15,'attri'=>190,'time'=>14110),array('wood'=>12915,'clay'=>12265,'iron'=>11070,'crop'=>3690,'pop'=>2,'cp'=>19,'attri'=>200,'time'=>16660),array('wood'=>16530,'clay'=>15700,'iron'=>14165,'crop'=>4720,'pop'=>3,'cp'=>22,'attri'=>210,'time'=>19630),array('wood'=>21155,'clay'=>20100,'iron'=>18135,'crop'=>6045,'pop'=>3,'cp'=>27,'attri'=>220,'time'=>23070),array('wood'=>27080,'clay'=>25725,'iron'=>23210,'crop'=>7735,'pop'=>3,'cp'=>32,'attri'=>230,'time'=>27060),array('wood'=>4660,'clay'=>32930,'iron'=>29710,'crop'=>9905,'pop'=>3,'cp'=>39,'attri'=>240,'time'=>31690),array('wood'=>44370,'clay'=>42150,'iron'=>38030,'crop'=>12675,'pop'=>3,'cp'=>46,'attri'=>250,'time'=>37060),array('wood'=>56790,'clay'=>53950,'iron'=>48680,'crop'=>16225,'pop'=>3,'cp'=>55,'attri'=>260,'time'=>43290),array('wood'=>72690,'clay'=>69060,'iron'=>62310,'crop'=>20770,'pop'=>3,'cp'=>67,'attri'=>270,'time'=>50520),array('wood'=>93045,'clay'=>88395,'iron'=>79755,'crop'=>26585,'pop'=>3,'cp'=>80,'attri'=>280,'time'=>58900),array('wood'=>119100,'clay'=>113145,'iron'=>102085,'crop'=>34030,'pop'=>3,'cp'=>96,'attri'=>290,'time'=>68630),array('wood'=>152445,'clay'=>144825,'iron'=>130670,'crop'=>43555,'pop'=>3,'cp'=>115,'attri'=>300,'time'=>79910));
+$bid29=array(1=>array('wood'=>630,'clay'=>420,'iron'=>780,'crop'=>360,'pop'=>4,'cp'=>1,'attri'=>100,'time'=>2000),array('wood'=>805,'clay'=>540,'iron'=>1000,'crop'=>460,'pop'=>2,'cp'=>1,'attri'=>90,'time'=>2620),array('wood'=>1030,'clay'=>690,'iron'=>1280,'crop'=>590,'pop'=>2,'cp'=>2,'attri'=>81,'time'=>3340),array('wood'=>1320,'clay'=>880,'iron'=>1635,'crop'=>755,'pop'=>2,'cp'=>2,'attri'=>72.9,'time'=>4170),array('wood'=>1690,'clay'=>1125,'iron'=>2095,'crop'=>965,'pop'=>2,'cp'=>2,'attri'=>65.61,'time'=>5140),array('wood'=>2165,'clay'=>1445,'iron'=>2680,'crop'=>1235,'pop'=>3,'cp'=>3,'attri'=>59.05,'time'=>6260),array('wood'=>2770,'clay'=>1845,'iron'=>3430,'crop'=>1585,'pop'=>3,'cp'=>4,'attri'=>53.14,'time'=>7570),array('wood'=>3545,'clay'=>2365,'iron'=>4390,'crop'=>2025,'pop'=>3,'cp'=>4,'attri'=>47.83,'time'=>9080),array('wood'=>4540,'clay'=>3025,'iron'=>5620,'crop'=>2595,'pop'=>3,'cp'=>5,'attri'=>43.05,'time'=>10830),array('wood'=>5810,'clay'=>3875,'iron'=>7195,'crop'=>3320,'pop'=>3,'cp'=>6,'attri'=>38.74,'time'=>12860),array('wood'=>7440,'clay'=>4960,'iron'=>9210,'crop'=>4250,'pop'=>3,'cp'=>7,'attri'=>34.87,'time'=>15220),array('wood'=>9520,'clay'=>6345,'iron'=>11785,'crop'=>5440,'pop'=>3,'cp'=>9,'attri'=>31.38,'time'=>17950),array('wood'=>12185,'clay'=>8125,'iron'=>15085,'crop'=>6965,'pop'=>3,'cp'=>11,'attri'=>28.24,'time'=>21130),array('wood'=>15600,'clay'=>10400,'iron'=>19310,'crop'=>8915,'pop'=>3,'cp'=>13,'attri'=>25.42,'time'=>24810),array('wood'=>19965,'clay'=>13310,'iron'=>24720,'crop'=>11410,'pop'=>3,'cp'=>15,'attri'=>22.88,'time'=>29080),array('wood'=>25555,'clay'=>17035,'iron'=>31640,'crop'=>14605,'pop'=>4,'cp'=>18,'attri'=>20.59,'time'=>34030),array('wood'=>32710,'clay'=>21810,'iron'=>40500,'crop'=>18690,'pop'=>4,'cp'=>22,'attri'=>18.53,'time'=>39770),array('wood'=>41870,'clay'=>27915,'iron'=>51840,'crop'=>23925,'pop'=>4,'cp'=>27,'attri'=>16.68,'time'=>46440),array('wood'=>53595,'clay'=>35730,'iron'=>66355,'crop'=>30625,'pop'=>4,'cp'=>32,'attri'=>15.01,'time'=>54170),array('wood'=>68600,'clay'=>45735,'iron'=>84935,'crop'=>39200,'pop'=>4,'cp'=>38,'attri'=>13.51,'time'=>63130));
+$bid30=array(1=>array('wood'=>780,'clay'=>420,'iron'=>660,'crop'=>300,'pop'=>5,'cp'=>2,'attri'=>100,'time'=>2200),array('wood'=>1000,'clay'=>540,'iron'=>845,'crop'=>385,'pop'=>3,'cp'=>3,'attri'=>90,'time'=>2850),array('wood'=>1280,'clay'=>690,'iron'=>1080,'crop'=>490,'pop'=>3,'cp'=>3,'attri'=>81,'time'=>3610),array('wood'=>1635,'clay'=>880,'iron'=>1385,'crop'=>630,'pop'=>3,'cp'=>4,'attri'=>72.9,'time'=>4490),array('wood'=>2095,'clay'=>1125,'iron'=>1770,'crop'=>805,'pop'=>3,'cp'=>5,'attri'=>65.61,'time'=>5500),array('wood'=>2680,'clay'=>1445,'iron'=>2270,'crop'=>1030,'pop'=>3,'cp'=>6,'attri'=>59.05,'time'=>6680),array('wood'=>3430,'clay'=>1845,'iron'=>2905,'crop'=>1320,'pop'=>3,'cp'=>7,'attri'=>53.14,'time'=>8050),array('wood'=>4390,'clay'=>2365,'iron'=>3715,'crop'=>1690,'pop'=>3,'cp'=>9,'attri'=>47.83,'time'=>9640),array('wood'=>5620,'clay'=>3025,'iron'=>4755,'crop'=>2160,'pop'=>3,'cp'=>10,'attri'=>43.05,'time'=>11480),array('wood'=>7195,'clay'=>3875,'iron'=>6085,'crop'=>2765,'pop'=>3,'cp'=>12,'attri'=>38.74,'time'=>13620),array('wood'=>9210,'clay'=>4960,'iron'=>7790,'crop'=>3540,'pop'=>4,'cp'=>15,'attri'=>34.87,'time'=>16100),array('wood'=>11785,'clay'=>6345,'iron'=>9975,'crop'=>4535,'pop'=>4,'cp'=>18,'attri'=>31.38,'time'=>18980),array('wood'=>15085,'clay'=>8125,'iron'=>12765,'crop'=>5805,'pop'=>4,'cp'=>21,'attri'=>28.24,'time'=>22310),array('wood'=>19310,'clay'=>10400,'iron'=>16340,'crop'=>7430,'pop'=>4,'cp'=>26,'attri'=>25.42,'time'=>26180),array('wood'=>24720,'clay'=>13310,'iron'=>20915,'crop'=>9505,'pop'=>4,'cp'=>31,'attri'=>22.88,'time'=>30670),array('wood'=>31640,'clay'=>17035,'iron'=>26775,'crop'=>12170,'pop'=>4,'cp'=>37,'attri'=>20.59,'time'=>35880),array('wood'=>40500,'clay'=>21810,'iron'=>34270,'crop'=>15575,'pop'=>4,'cp'=>44,'attri'=>18.53,'time'=>41920),array('wood'=>51840,'clay'=>27915,'iron'=>43865,'crop'=>19940,'pop'=>4,'cp'=>53,'attri'=>16.68,'time'=>48930),array('wood'=>66355,'clay'=>35730,'iron'=>56145,'crop'=>25520,'pop'=>4,'cp'=>64,'attri'=>15.01,'time'=>57060),array('wood'=>84935,'clay'=>45735,'iron'=>71870,'crop'=>32665,'pop'=>4,'cp'=>77,'attri'=>13.51,'time'=>66490));
+$bid31=array(1=>array('wood'=>70,'clay'=>90,'iron'=>170,'crop'=>70,'pop'=>0,'cp'=>1,'attri'=>3,'time'=>2000),array('wood'=>90,'clay'=>115,'iron'=>220,'crop'=>90,'pop'=>0,'cp'=>1,'attri'=>6,'time'=>2620),array('wood'=>115,'clay'=>145,'iron'=>280,'crop'=>115,'pop'=>0,'cp'=>2,'attri'=>9,'time'=>3340),array('wood'=>145,'clay'=>190,'iron'=>355,'crop'=>145,'pop'=>0,'cp'=>2,'attri'=>13,'time'=>4170),array('wood'=>190,'clay'=>240,'iron'=>455,'crop'=>190,'pop'=>0,'cp'=>2,'attri'=>16,'time'=>5140),array('wood'=>240,'clay'=>310,'iron'=>585,'crop'=>240,'pop'=>1,'cp'=>3,'attri'=>19,'time'=>6260),array('wood'=>310,'clay'=>395,'iron'=>750,'crop'=>310,'pop'=>1,'cp'=>4,'attri'=>23,'time'=>7570),array('wood'=>395,'clay'=>505,'iron'=>955,'crop'=>395,'pop'=>1,'cp'=>4,'attri'=>27,'time'=>9080),array('wood'=>505,'clay'=>650,'iron'=>1225,'crop'=>505,'pop'=>1,'cp'=>5,'attri'=>30,'time'=>10830),array('wood'=>645,'clay'=>830,'iron'=>1570,'crop'=>645,'pop'=>1,'cp'=>6,'attri'=>34,'time'=>12860),array('wood'=>825,'clay'=>1065,'iron'=>2005,'crop'=>825,'pop'=>1,'cp'=>7,'attri'=>38,'time'=>15220),array('wood'=>1060,'clay'=>1360,'iron'=>2570,'crop'=>1060,'pop'=>1,'cp'=>9,'attri'=>43,'time'=>17950),array('wood'=>1355,'clay'=>1740,'iron'=>3290,'crop'=>1355,'pop'=>1,'cp'=>11,'attri'=>47,'time'=>21130),array('wood'=>1735,'clay'=>2230,'iron'=>4210,'crop'=>1735,'pop'=>1,'cp'=>13,'attri'=>51,'time'=>24810),array('wood'=>2220,'clay'=>2850,'iron'=>5390,'crop'=>2220,'pop'=>1,'cp'=>15,'attri'=>56,'time'=>29080),array('wood'=>2840,'clay'=>3650,'iron'=>6895,'crop'=>2840,'pop'=>2,'cp'=>18,'attri'=>60,'time'=>34030),array('wood'=>3635,'clay'=>4675,'iron'=>8825,'crop'=>3635,'pop'=>2,'cp'=>22,'attri'=>65,'time'=>39770),array('wood'=>4650,'clay'=>5980,'iron'=>11300,'crop'=>4650,'pop'=>2,'cp'=>27,'attri'=>70,'time'=>46440),array('wood'=>5955,'clay'=>7655,'iron'=>14460,'crop'=>5955,'pop'=>2,'cp'=>32,'attri'=>75,'time'=>54170),array('wood'=>7620,'clay'=>9800,'iron'=>18510,'crop'=>7620,'pop'=>2,'cp'=>38,'attri'=>81,'time'=>63130));
+$bid32=array(1=>array('wood'=>120,'clay'=>200,'iron'=>0,'crop'=>80,'pop'=>0,'cp'=>1,'attri'=>2,'time'=>2000),array('wood'=>155,'clay'=>255,'iron'=>0,'crop'=>100,'pop'=>0,'cp'=>1,'attri'=>4,'time'=>2620),array('wood'=>195,'clay'=>330,'iron'=>0,'crop'=>130,'pop'=>0,'cp'=>2,'attri'=>6,'time'=>3340),array('wood'=>250,'clay'=>420,'iron'=>0,'crop'=>170,'pop'=>0,'cp'=>2,'attri'=>8,'time'=>4170),array('wood'=>320,'clay'=>535,'iron'=>0,'crop'=>215,'pop'=>0,'cp'=>2,'attri'=>10,'time'=>5140),array('wood'=>410,'clay'=>685,'iron'=>0,'crop'=>275,'pop'=>1,'cp'=>3,'attri'=>13,'time'=>6260),array('wood'=>530,'clay'=>880,'iron'=>0,'crop'=>350,'pop'=>1,'cp'=>4,'attri'=>15,'time'=>7570),array('wood'=>675,'clay'=>1125,'iron'=>0,'crop'=>450,'pop'=>1,'cp'=>4,'attri'=>17,'time'=>9080),array('wood'=>865,'clay'=>1440,'iron'=>0,'crop'=>575,'pop'=>1,'cp'=>5,'attri'=>20,'time'=>10830),array('wood'=>1105,'clay'=>1845,'iron'=>0,'crop'=>740,'pop'=>1,'cp'=>6,'attri'=>22,'time'=>12860),array('wood'=>1415,'clay'=>2360,'iron'=>0,'crop'=>945,'pop'=>1,'cp'=>7,'attri'=>24,'time'=>15220),array('wood'=>1815,'clay'=>3020,'iron'=>0,'crop'=>1210,'pop'=>1,'cp'=>9,'attri'=>27,'time'=>17950),array('wood'=>2320,'clay'=>3870,'iron'=>0,'crop'=>1545,'pop'=>1,'cp'=>11,'attri'=>29,'time'=>21130),array('wood'=>2970,'clay'=>4950,'iron'=>0,'crop'=>1980,'pop'=>1,'cp'=>13,'attri'=>32,'time'=>24810),array('wood'=>3805,'clay'=>6340,'iron'=>0,'crop'=>2535,'pop'=>1,'cp'=>15,'attri'=>35,'time'=>29080),array('wood'=>4870,'clay'=>8115,'iron'=>0,'crop'=>3245,'pop'=>2,'cp'=>18,'attri'=>37,'time'=>34030),array('wood'=>6230,'clay'=>10385,'iron'=>0,'crop'=>4155,'pop'=>2,'cp'=>22,'attri'=>40,'time'=>39770),array('wood'=>7975,'clay'=>13290,'iron'=>0,'crop'=>5315,'pop'=>2,'cp'=>27,'attri'=>43,'time'=>46440),array('wood'=>10210,'clay'=>17015,'iron'=>0,'crop'=>6805,'pop'=>2,'cp'=>32,'attri'=>46,'time'=>54170),array('wood'=>13065,'clay'=>21780,'iron'=>0,'crop'=>8710,'pop'=>2,'cp'=>38,'attri'=>49,'time'=>63130));
+$bid33=array(1=>array('wood'=>160,'clay'=>100,'iron'=>80,'crop'=>60,'pop'=>0,'cp'=>1,'attri'=>2,'time'=>2000),array('wood'=>205,'clay'=>130,'iron'=>100,'crop'=>75,'pop'=>0,'cp'=>1,'attri'=>5,'time'=>2620),array('wood'=>260,'clay'=>165,'iron'=>130,'crop'=>100,'pop'=>0,'cp'=>2,'attri'=>8,'time'=>3340),array('wood'=>335,'clay'=>210,'iron'=>170,'crop'=>125,'pop'=>0,'cp'=>2,'attri'=>10,'time'=>4170),array('wood'=>430,'clay'=>270,'iron'=>215,'crop'=>160,'pop'=>0,'cp'=>2,'attri'=>13,'time'=>5140),array('wood'=>550,'clay'=>345,'iron'=>275,'crop'=>205,'pop'=>1,'cp'=>3,'attri'=>16,'time'=>6260),array('wood'=>705,'clay'=>440,'iron'=>350,'crop'=>265,'pop'=>1,'cp'=>4,'attri'=>19,'time'=>7570),array('wood'=>900,'clay'=>565,'iron'=>450,'crop'=>340,'pop'=>1,'cp'=>4,'attri'=>22,'time'=>9080),array('wood'=>1155,'clay'=>720,'iron'=>575,'crop'=>430,'pop'=>1,'cp'=>5,'attri'=>25,'time'=>10830),array('wood'=>1475,'clay'=>920,'iron'=>740,'crop'=>555,'pop'=>1,'cp'=>6,'attri'=>28,'time'=>12860),array('wood'=>1890,'clay'=>1180,'iron'=>945,'crop'=>710,'pop'=>1,'cp'=>7,'attri'=>31,'time'=>15220),array('wood'=>2420,'clay'=>1510,'iron'=>1210,'crop'=>905,'pop'=>1,'cp'=>9,'attri'=>34,'time'=>17950),array('wood'=>3095,'clay'=>1935,'iron'=>1545,'crop'=>1160,'pop'=>1,'cp'=>11,'attri'=>38,'time'=>21130),array('wood'=>3960,'clay'=>2475,'iron'=>1980,'crop'=>1485,'pop'=>1,'cp'=>13,'attri'=>41,'time'=>24810),array('wood'=>5070,'clay'=>3170,'iron'=>2535,'crop'=>1900,'pop'=>1,'cp'=>15,'attri'=>45,'time'=>29080),array('wood'=>6490,'clay'=>4055,'iron'=>3245,'crop'=>2435,'pop'=>2,'cp'=>18,'attri'=>48,'time'=>34030),array('wood'=>8310,'clay'=>5190,'iron'=>4155,'crop'=>3115,'pop'=>2,'cp'=>22,'attri'=>52,'time'=>39770),array('wood'=>10635,'clay'=>6645,'iron'=>5315,'crop'=>3990,'pop'=>2,'cp'=>27,'attri'=>56,'time'=>46440),array('wood'=>13610,'clay'=>8505,'iron'=>6805,'crop'=>5105,'pop'=>2,'cp'=>32,'attri'=>60,'time'=>54170),array('wood'=>17420,'clay'=>10890,'iron'=>8710,'crop'=>6535,'pop'=>2,'cp'=>38,'attri'=>64,'time'=>63130));
+$bid34=array(1=>array('wood'=>155,'clay'=>130,'iron'=>125,'crop'=>70,'pop'=>2,'cp'=>1,'attri'=>110,'time'=>2200),array('wood'=>200,'clay'=>165,'iron'=>160,'crop'=>90,'pop'=>1,'cp'=>1,'attri'=>120,'time'=>3150),array('wood'=>255,'clay'=>215,'iron'=>205,'crop'=>115,'pop'=>1,'cp'=>2,'attri'=>130,'time'=>4260),array('wood'=>325,'clay'=>275,'iron'=>260,'crop'=>145,'pop'=>1,'cp'=>2,'attri'=>140,'time'=>5540),array('wood'=>415,'clay'=>350,'iron'=>335,'crop'=>190,'pop'=>1,'cp'=>2,'attri'=>150,'time'=>7020),array('wood'=>535,'clay'=>445,'iron'=>430,'crop'=>240,'pop'=>2,'cp'=>3,'attri'=>160,'time'=>8750),array('wood'=>680,'clay'=>570,'iron'=>550,'crop'=>310,'pop'=>2,'cp'=>4,'attri'=>170,'time'=>10750),array('wood'=>875,'clay'=>730,'iron'=>705,'crop'=>395,'pop'=>2,'cp'=>4,'attri'=>180,'time'=>13070),array('wood'=>1115,'clay'=>935,'iron'=>900,'crop'=>505,'pop'=>2,'cp'=>5,'attri'=>190,'time'=>15760),array('wood'=>1430,'clay'=>1200,'iron'=>1155,'crop'=>645,'pop'=>2,'cp'=>6,'attri'=>200,'time'=>18880),array('wood'=>1830,'clay'=>1535,'iron'=>1475,'crop'=>825,'pop'=>2,'cp'=>7,'attri'=>210,'time'=>22500),array('wood'=>2340,'clay'=>1965,'iron'=>1890,'crop'=>1060,'pop'=>2,'cp'=>9,'attri'=>220,'time'=>26700),array('wood'=>3000,'clay'=>2515,'iron'=>2420,'crop'=>1355,'pop'=>2,'cp'=>11,'attri'=>230,'time'=>31570),array('wood'=>3840,'clay'=>3220,'iron'=>3095,'crop'=>1735,'pop'=>2,'cp'=>13,'attri'=>240,'time'=>37220),array('wood'=>4910,'clay'=>4120,'iron'=>3960,'crop'=>2220,'pop'=>2,'cp'=>15,'attri'=>250,'time'=>43780),array('wood'=>6290,'clay'=>5275,'iron'=>5070,'crop'=>2840,'pop'=>3,'cp'=>18,'attri'=>260,'time'=>51380),array('wood'=>8050,'clay'=>6750,'iron'=>6490,'crop'=>3635,'pop'=>3,'cp'=>22,'attri'=>270,'time'=>60200),array('wood'=>10300,'clay'=>8640,'iron'=>8310,'crop'=>4650,'pop'=>3,'cp'=>27,'attri'=>280,'time'=>70430),array('wood'=>13185,'clay'=>11060,'iron'=>10635,'crop'=>5955,'pop'=>3,'cp'=>32,'attri'=>290,'time'=>82300),array('wood'=>16880,'clay'=>14155,'iron'=>13610,'crop'=>7620,'pop'=>3,'cp'=>38,'attri'=>300,'time'=>96070));
+$bid35=array(1=>array('wood'=>1460,'clay'=>930,'iron'=>1250,'crop'=>1740,'pop'=>6,'cp'=>5,'attri'=>0,'time'=>8000),array('wood'=>2045,'clay'=>1300,'iron'=>1750,'crop'=>2435,'pop'=>3,'cp'=>6,'attri'=>0,'time'=>9880),array('wood'=>2860,'clay'=>1825,'iron'=>2450,'crop'=>3410,'pop'=>3,'cp'=>7,'attri'=>0,'time'=>12060),array('wood'=>4005,'clay'=>2550,'iron'=>3430,'crop'=>4775,'pop'=>3,'cp'=>8,'attri'=>0,'time'=>14590),array('wood'=>5610,'clay'=>3575,'iron'=>4800,'crop'=>6685,'pop'=>3,'cp'=>10,'attri'=>0,'time'=>17530),array('wood'=>7850,'clay'=>5000,'iron'=>6725,'crop'=>9360,'pop'=>4,'cp'=>12,'attri'=>0,'time'=>20930),array('wood'=>10995,'clay'=>7000,'iron'=>9410,'crop'=>13100,'pop'=>4,'cp'=>14,'attri'=>0,'time'=>24880),array('wood'=>15390,'clay'=>9805,'iron'=>13175,'crop'=>18340,'pop'=>4,'cp'=>17,'attri'=>0,'time'=>29460),array('wood'=>21545,'clay'=>13725,'iron'=>18445,'crop'=>25680,'pop'=>4,'cp'=>21,'attri'=>0,'time'=>34770),array('wood'=>30165,'clay'=>19215,'iron'=>25825,'crop'=>35950,'pop'=>4,'cp'=>25,'attri'=>0,'time'=>40930));
+$bid36=array(1=>array('wood'=>100,'clay'=>100,'iron'=>100,'crop'=>100,'pop'=>4,'cp'=>1,'attri'=>10,'time'=>2000),array('wood'=>130,'clay'=>130,'iron'=>130,'crop'=>130,'pop'=>2,'cp'=>1,'attri'=>22,'time'=>2320),array('wood'=>165,'clay'=>165,'iron'=>165,'crop'=>165,'pop'=>2,'cp'=>2,'attri'=>35,'time'=>2690),array('wood'=>210,'clay'=>210,'iron'=>210,'crop'=>210,'pop'=>2,'cp'=>2,'attri'=>49,'time'=>3120),array('wood'=>270,'clay'=>270,'iron'=>270,'crop'=>270,'pop'=>2,'cp'=>2,'attri'=>64,'time'=>3620),array('wood'=>345,'clay'=>345,'iron'=>345,'crop'=>345,'pop'=>3,'cp'=>3,'attri'=>80,'time'=>4200),array('wood'=>440,'clay'=>440,'iron'=>440,'crop'=>440,'pop'=>3,'cp'=>4,'attri'=>97,'time'=>4870),array('wood'=>565,'clay'=>565,'iron'=>565,'crop'=>565,'pop'=>3,'cp'=>4,'attri'=>115,'time'=>5650),array('wood'=>720,'clay'=>720,'iron'=>720,'crop'=>720,'pop'=>3,'cp'=>5,'attri'=>134,'time'=>6560),array('wood'=>920,'clay'=>920,'iron'=>920,'crop'=>920,'pop'=>3,'cp'=>6,'attri'=>154,'time'=>7610),array('wood'=>1180,'clay'=>1180,'iron'=>1180,'crop'=>1180,'pop'=>3,'cp'=>7,'attri'=>175,'time'=>8820),array('wood'=>1510,'clay'=>1510,'iron'=>1510,'crop'=>1510,'pop'=>3,'cp'=>9,'attri'=>196,'time'=>10230),array('wood'=>1935,'clay'=>1935,'iron'=>1935,'crop'=>1935,'pop'=>3,'cp'=>11,'attri'=>218,'time'=>11870),array('wood'=>2475,'clay'=>2475,'iron'=>2475,'crop'=>2475,'pop'=>3,'cp'=>13,'attri'=>241,'time'=>13770),array('wood'=>3170,'clay'=>3170,'iron'=>3170,'crop'=>3170,'pop'=>3,'cp'=>15,'attri'=>265,'time'=>15980),array('wood'=>4055,'clay'=>4055,'iron'=>4055,'crop'=>4055,'pop'=>4,'cp'=>18,'attri'=>290,'time'=>18530),array('wood'=>5190,'clay'=>5190,'iron'=>5190,'crop'=>5190,'pop'=>4,'cp'=>22,'attri'=>316,'time'=>21500),array('wood'=>6645,'clay'=>6645,'iron'=>6645,'crop'=>6645,'pop'=>4,'cp'=>27,'attri'=>343,'time'=>24940),array('wood'=>8505,'clay'=>8505,'iron'=>8505,'crop'=>8505,'pop'=>4,'cp'=>32,'attri'=>371,'time'=>28930),array('wood'=>10890,'clay'=>10890,'iron'=>10890,'crop'=>10890,'pop'=>4,'cp'=>38,'attri'=>400,'time'=>33550));
+$bid37=array(1=>array('wood'=>700,'clay'=>670,'iron'=>700,'crop'=>240,'pop'=>2,'cp'=>1,'attri'=>0,'time'=>2300),array('wood'=>930,'clay'=>890,'iron'=>930,'crop'=>320,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>2670),array('wood'=>1240,'clay'=>1185,'iron'=>1240,'crop'=>425,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>3090),array('wood'=>1645,'clay'=>1575,'iron'=>1645,'crop'=>565,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>3590),array('wood'=>2190,'clay'=>2095,'iron'=>2190,'crop'=>750,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>4160),array('wood'=>2915,'clay'=>2790,'iron'=>2915,'crop'=>1000,'pop'=>2,'cp'=>3,'attri'=>0,'time'=>4830),array('wood'=>3875,'clay'=>3710,'iron'=>3875,'crop'=>1330,'pop'=>2,'cp'=>4,'attri'=>0,'time'=>5600),array('wood'=>5155,'clay'=>4930,'iron'=>5155,'crop'=>1765,'pop'=>2,'cp'=>4,'attri'=>0,'time'=>6500),array('wood'=>6855,'clay'=>6560,'iron'=>6855,'crop'=>2350,'pop'=>2,'cp'=>5,'attri'=>0,'time'=>7540),array('wood'=>9115,'clay'=>8725,'iron'=>9115,'crop'=>3125,'pop'=>2,'cp'=>6,'attri'=>1,'time'=>8750),array('wood'=>12125,'clay'=>11605,'iron'=>12125,'crop'=>4155,'pop'=>2,'cp'=>7,'attri'=>1,'time'=>10150),array('wood'=>16125,'clay'=>15435,'iron'=>16125,'crop'=>5530,'pop'=>2,'cp'=>9,'attri'=>1,'time'=>11770),array('wood'=>21445,'clay'=>20525,'iron'=>21445,'crop'=>7350,'pop'=>2,'cp'=>11,'attri'=>1,'time'=>13650),array('wood'=>28520,'clay'=>27300,'iron'=>28520,'crop'=>9780,'pop'=>2,'cp'=>13,'attri'=>1,'time'=>15840),array('wood'=>37935,'clay'=>36310,'iron'=>37935,'crop'=>13005,'pop'=>2,'cp'=>15,'attri'=>2,'time'=>18370),array('wood'=>50450,'clay'=>48290,'iron'=>50450,'crop'=>17300,'pop'=>3,'cp'=>18,'attri'=>2,'time'=>21310),array('wood'=>67100,'clay'=>64225,'iron'=>67100,'crop'=>23005,'pop'=>3,'cp'=>22,'attri'=>2,'time'=>24720),array('wood'=>89245,'clay'=>85420,'iron'=>89245,'crop'=>30600,'pop'=>3,'cp'=>27,'attri'=>2,'time'=>28680),array('wood'=>118695,'clay'=>113605,'iron'=>118695,'crop'=>40695,'pop'=>3,'cp'=>32,'attri'=>2,'time'=>33260),array('wood'=>157865,'clay'=>151095,'iron'=>157865,'crop'=>54125,'pop'=>3,'cp'=>38,'attri'=>3,'time'=>38590));
+$bid38=array(1=>array('wood'=>650,'clay'=>800,'iron'=>450,'crop'=>200,'pop'=>1,'cp'=>1,'attri'=>3600,'time'=>9000),array('wood'=>830,'clay'=>1025,'iron'=>575,'crop'=>255,'pop'=>1,'cp'=>1,'attri'=>5100,'time'=>10740),array('wood'=>1065,'clay'=>1310,'iron'=>735,'crop'=>330,'pop'=>1,'cp'=>2,'attri'=>6900,'time'=>12760),array('wood'=>1365,'clay'=>1680,'iron'=>945,'crop'=>420,'pop'=>1,'cp'=>2,'attri'=>9300,'time'=>15100),array('wood'=>1745,'clay'=>2145,'iron'=>1210,'crop'=>535,'pop'=>1,'cp'=>2,'attri'=>12000,'time'=>17820),array('wood'=>2235,'clay'=>2750,'iron'=>1545,'crop'=>685,'pop'=>1,'cp'=>3,'attri'=>15000,'time'=>20970),array('wood'=>2860,'clay'=>3520,'iron'=>1980,'crop'=>880,'pop'=>1,'cp'=>4,'attri'=>18900,'time'=>24620),array('wood'=>3660,'clay'=>4505,'iron'=>2535,'crop'=>1125,'pop'=>1,'cp'=>4,'attri'=>23400,'time'=>28860),array('wood'=>4685,'clay'=>5765,'iron'=>3245,'crop'=>1440,'pop'=>1,'cp'=>5,'attri'=>28800,'time'=>33780),array('wood'=>5995,'clay'=>7380,'iron'=>4150,'crop'=>1845,'pop'=>1,'cp'=>6,'attri'=>35400,'time'=>39480),array('wood'=>7675,'clay'=>9445,'iron'=>5315,'crop'=>2360,'pop'=>2,'cp'=>7,'attri'=>43200,'time'=>46100),array('wood'=>9825,'clay'=>12090,'iron'=>6800,'crop'=>3020,'pop'=>2,'cp'=>9,'attri'=>52800,'time'=>53780),array('wood'=>12575,'clay'=>15475,'iron'=>8705,'crop'=>3870,'pop'=>2,'cp'=>11,'attri'=>64200,'time'=>62680),array('wood'=>16095,'clay'=>19805,'iron'=>11140,'crop'=>4950,'pop'=>2,'cp'=>13,'attri'=>77700,'time'=>73010),array('wood'=>20600,'clay'=>25355,'iron'=>14260,'crop'=>6340,'pop'=>2,'cp'=>15,'attri'=>93900,'time'=>84990),array('wood'=>26365,'clay'=>32450,'iron'=>18255,'crop'=>8115,'pop'=>2,'cp'=>18,'attri'=>113700,'time'=>98890),array('wood'=>33750,'clay'=>41540,'iron'=>23365,'crop'=>10385,'pop'=>2,'cp'=>22,'attri'=>137100,'time'=>115010),array('wood'=>43200,'clay'=>53170,'iron'=>29910,'crop'=>13290,'pop'=>2,'cp'=>27,'attri'=>165300,'time'=>133710),array('wood'=>55295,'clay'=>68055,'iron'=>38280,'crop'=>17015,'pop'=>2,'cp'=>32,'attri'=>199200,'time'=>155400),array('wood'=>70780,'clay'=>87110,'iron'=>49000,'crop'=>21780,'pop'=>2,'cp'=>38,'attri'=>240000,'time'=>180570));
+$bid39=array(1=>array('wood'=>400,'clay'=>500,'iron'=>350,'crop'=>100,'pop'=>1,'cp'=>1,'attri'=>3600,'time'=>7000),array('wood'=>510,'clay'=>640,'iron'=>450,'crop'=>130,'pop'=>1,'cp'=>1,'attri'=>5100,'time'=>8420),array('wood'=>655,'clay'=>820,'iron'=>575,'crop'=>165,'pop'=>1,'cp'=>2,'attri'=>6900,'time'=>10070),array('wood'=>840,'clay'=>1050,'iron'=>735,'crop'=>210,'pop'=>1,'cp'=>2,'attri'=>9300,'time'=>11980),array('wood'=>1075,'clay'=>1340,'iron'=>940,'crop'=>270,'pop'=>1,'cp'=>2,'attri'=>12000,'time'=>14190),array('wood'=>1375,'clay'=>1720,'iron'=>1205,'crop'=>345,'pop'=>1,'cp'=>3,'attri'=>15000,'time'=>16770),array('wood'=>1760,'clay'=>2200,'iron'=>1540,'crop'=>440,'pop'=>1,'cp'=>4,'attri'=>18900,'time'=>19750),array('wood'=>2250,'clay'=>2815,'iron'=>1970,'crop'=>565,'pop'=>1,'cp'=>4,'attri'=>23400,'time'=>23210),array('wood'=>2880,'clay'=>3605,'iron'=>2520,'crop'=>720,'pop'=>1,'cp'=>5,'attri'=>28800,'time'=>27220),array('wood'=>3690,'clay'=>4610,'iron'=>3230,'crop'=>920,'pop'=>1,'cp'=>6,'attri'=>35400,'time'=>31880),array('wood'=>4720,'clay'=>5905,'iron'=>4130,'crop'=>1180,'pop'=>2,'cp'=>7,'attri'=>43200,'time'=>37280),array('wood'=>6045,'clay'=>7555,'iron'=>5290,'crop'=>1510,'pop'=>2,'cp'=>9,'attri'=>52800,'time'=>43540),array('wood'=>7735,'clay'=>9670,'iron'=>6770,'crop'=>1935,'pop'=>2,'cp'=>11,'attri'=>64200,'time'=>50810),array('wood'=>9905,'clay'=>12380,'iron'=>8665,'crop'=>2475,'pop'=>2,'cp'=>13,'attri'=>77700,'time'=>59240),array('wood'=>12675,'clay'=>15845,'iron'=>11090,'crop'=>3170,'pop'=>2,'cp'=>15,'attri'=>93900,'time'=>69010),array('wood'=>16225,'clay'=>20280,'iron'=>14200,'crop'=>4055,'pop'=>2,'cp'=>18,'attri'=>113700,'time'=>80360),array('wood'=>20770,'clay'=>25960,'iron'=>18175,'crop'=>5190,'pop'=>2,'cp'=>22,'attri'=>137100,'time'=>93510),array('wood'=>26585,'clay'=>33230,'iron'=>23260,'crop'=>6645,'pop'=>2,'cp'=>27,'attri'=>165300,'time'=>108780),array('wood'=>34030,'clay'=>42535,'iron'=>29775,'crop'=>8505,'pop'=>2,'cp'=>32,'attri'=>199200,'time'=>126480),array('wood'=>43555,'clay'=>54445,'iron'=>38110,'crop'=>10890,'pop'=>2,'cp'=>38,'attri'=>240000,'time'=>147020));
+$bid40=array(1=>array('wood'=>66700,'clay'=>69050,'iron'=>72200,'crop'=>13200,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>18000),array('wood'=>68535,'clay'=>70950,'iron'=>74185,'crop'=>13565,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>18850),array('wood'=>70420,'clay'=>72900,'iron'=>76225,'crop'=>13935,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>19720),array('wood'=>72355,'clay'=>74905,'iron'=>78320,'crop'=>14320,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>20590),array('wood'=>74345,'clay'=>76965,'iron'=>80475,'crop'=>14715,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>21480),array('wood'=>76390,'clay'=>79080,'iron'=>82690,'crop'=>15120,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>22380),array('wood'=>78490,'clay'=>81255,'iron'=>84965,'crop'=>15535,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>23290),array('wood'=>80650,'clay'=>83490,'iron'=>87300,'crop'=>15960,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>24220),array('wood'=>82865,'clay'=>85785,'iron'=>89700,'crop'=>16400,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>25160),array('wood'=>85145,'clay'=>88145,'iron'=>92165,'crop'=>16850,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>26110),array('wood'=>87485,'clay'=>90570,'iron'=>94700,'crop'=>17315,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>27080),array('wood'=>89895,'clay'=>93060,'iron'=>97305,'crop'=>17790,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>28060),array('wood'=>92365,'clay'=>95620,'iron'=>99980,'crop'=>18280,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>29050),array('wood'=>94905,'clay'=>98250,'iron'=>102730,'crop'=>18780,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>30060),array('wood'=>97515,'clay'=>100950,'iron'=>105555,'crop'=>19300,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>31080),array('wood'=>100195,'clay'=>103725,'iron'=>108460,'crop'=>19830,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>32110),array('wood'=>102950,'clay'=>106580,'iron'=>111440,'crop'=>20375,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>33160),array('wood'=>105785,'clay'=>109510,'iron'=>114505,'crop'=>20935,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>34230),array('wood'=>108690,'clay'=>112520,'iron'=>117655,'crop'=>21510,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>35300),array('wood'=>111680,'clay'=>115615,'iron'=>120890,'crop'=>22100,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>36400),array('wood'=>114755,'clay'=>118795,'iron'=>124215,'crop'=>22710,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>37510),array('wood'=>117910,'clay'=>122060,'iron'=>127630,'crop'=>23335,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>38630),array('wood'=>121150,'clay'=>125420,'iron'=>131140,'crop'=>23975,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>39770),array('wood'=>124480,'clay'=>128870,'iron'=>134745,'crop'=>24635,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>40930),array('wood'=>127905,'clay'=>132410,'iron'=>138455,'crop'=>25315,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>42100),array('wood'=>131425,'clay'=>136055,'iron'=>142260,'crop'=>26010,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>43290),array('wood'=>135035,'clay'=>139795,'iron'=>146170,'crop'=>26725,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>44500),array('wood'=>138750,'clay'=>143640,'iron'=>150190,'crop'=>27460,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>45720),array('wood'=>142565,'clay'=>147590,'iron'=>154320,'crop'=>28215,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>46960),array('wood'=>146485,'clay'=>151650,'iron'=>158565,'crop'=>28990,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>48220),array('wood'=>150515,'clay'=>155820,'iron'=>162925,'crop'=>29785,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>49500),array('wood'=>154655,'clay'=>160105,'iron'=>167405,'crop'=>30605,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>50790),array('wood'=>158910,'clay'=>164505,'iron'=>172010,'crop'=>31450,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>52100),array('wood'=>163275,'clay'=>169030,'iron'=>176740,'crop'=>32315,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>53430),array('wood'=>167770,'clay'=>173680,'iron'=>181600,'crop'=>33200,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>54780),array('wood'=>172380,'clay'=>178455,'iron'=>186595,'crop'=>34115,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>56140),array('wood'=>177120,'clay'=>183360,'iron'=>191725,'crop'=>35055,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>57530),array('wood'=>181995,'clay'=>188405,'iron'=>197000,'crop'=>36015,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>58940),array('wood'=>186995,'clay'=>193585,'iron'=>202415,'crop'=>37005,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>60360),array('wood'=>192140,'clay'=>198910,'iron'=>207985,'crop'=>38025,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>61810),array('wood'=>197425,'clay'=>204380,'iron'=>213705,'crop'=>39070,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>63270),array('wood'=>202855,'clay'=>210000,'iron'=>219580,'crop'=>40145,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>64760),array('wood'=>208430,'clay'=>215775,'iron'=>225620,'crop'=>41250,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>66260),array('wood'=>214165,'clay'=>221710,'iron'=>231825,'crop'=>42385,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>67790),array('wood'=>220055,'clay'=>227805,'iron'=>238200,'crop'=>43550,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>69340),array('wood'=>226105,'clay'=>234070,'iron'=>244750,'crop'=>44745,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>70910),array('wood'=>232320,'clay'=>240505,'iron'=>251480,'crop'=>45975,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>72500),array('wood'=>238710,'clay'=>247120,'iron'=>258395,'crop'=>47240,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>74120),array('wood'=>245275,'clay'=>253915,'iron'=>265500,'crop'=>48540,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>75760),array('wood'=>252020,'clay'=>260900,'iron'=>272800,'crop'=>49875,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>77420),array('wood'=>258950,'clay'=>268075,'iron'=>280305,'crop'=>51245,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>79100),array('wood'=>266070,'clay'=>275445,'iron'=>288010,'crop'=>52655,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>80810),array('wood'=>273390,'clay'=>283020,'iron'=>295930,'crop'=>54105,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>82540),array('wood'=>280905,'clay'=>290805,'iron'=>304070,'crop'=>55590,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>84290),array('wood'=>288630,'clay'=>298800,'iron'=>312430,'crop'=>57120,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>86070),array('wood'=>296570,'clay'=>307020,'iron'=>321025,'crop'=>58690,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>87880),array('wood'=>304725,'clay'=>315460,'iron'=>329850,'crop'=>60305,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>89710),array('wood'=>313105,'clay'=>324135,'iron'=>338925,'crop'=>61965,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>91570),array('wood'=>321715,'clay'=>333050,'iron'=>348245,'crop'=>63670,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>93450),array('wood'=>330565,'clay'=>342210,'iron'=>357820,'crop'=>65420,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>95360),array('wood'=>339655,'clay'=>351620,'iron'=>367660,'crop'=>67220,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>97290),array('wood'=>348995,'clay'=>361290,'iron'=>377770,'crop'=>69065,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>99250),array('wood'=>358590,'clay'=>371225,'iron'=>388160,'crop'=>70965,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>101240),array('wood'=>368450,'clay'=>381435,'iron'=>398835,'crop'=>72915,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>103260),array('wood'=>378585,'clay'=>391925,'iron'=>409800,'crop'=>74920,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>105310),array('wood'=>388995,'clay'=>402700,'iron'=>421070,'crop'=>76985,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>107380),array('wood'=>399695,'clay'=>413775,'iron'=>432650,'crop'=>79100,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>109480),array('wood'=>410685,'clay'=>425155,'iron'=>444550,'crop'=>81275,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>111620),array('wood'=>421980,'clay'=>436845,'iron'=>456775,'crop'=>83510,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>113780),array('wood'=>433585,'clay'=>448860,'iron'=>469335,'crop'=>85805,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>115970),array('wood'=>445505,'clay'=>461205,'iron'=>482240,'crop'=>88165,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>118200),array('wood'=>457760,'clay'=>473885,'iron'=>495505,'crop'=>90590,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>120450),array('wood'=>470345,'clay'=>486920,'iron'=>509130,'crop'=>93080,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>122740),array('wood'=>483280,'clay'=>500310,'iron'=>523130,'crop'=>95640,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>125060),array('wood'=>496570,'clay'=>514065,'iron'=>537520,'crop'=>98270,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>127410),array('wood'=>510225,'clay'=>528205,'iron'=>552300,'crop'=>100975,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>129790),array('wood'=>524260,'clay'=>542730,'iron'=>567490,'crop'=>103750,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>132210),array('wood'=>538675,'clay'=>557655,'iron'=>583095,'crop'=>106605,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>134660),array('wood'=>553490,'clay'=>572990,'iron'=>599130,'crop'=>109535,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>137140),array('wood'=>568710,'clay'=>588745,'iron'=>615605,'crop'=>112550,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>139660),array('wood'=>584350,'clay'=>604935,'iron'=>632535,'crop'=>115645,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>142220),array('wood'=>600420,'clay'=>621575,'iron'=>649930,'crop'=>118825,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>144810),array('wood'=>616930,'clay'=>638665,'iron'=>667800,'crop'=>122090,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>147440),array('wood'=>633895,'clay'=>656230,'iron'=>686165,'crop'=>125450,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>150100),array('wood'=>651330,'clay'=>674275,'iron'=>705035,'crop'=>128900,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>152800),array('wood'=>669240,'clay'=>692820,'iron'=>724425,'crop'=>132445,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>155540),array('wood'=>687645,'clay'=>711870,'iron'=>744345,'crop'=>136085,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>158320),array('wood'=>706555,'clay'=>731445,'iron'=>764815,'crop'=>139830,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>161140),array('wood'=>725985,'clay'=>751560,'iron'=>785850,'crop'=>143675,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>163990),array('wood'=>745950,'clay'=>772230,'iron'=>807460,'crop'=>147625,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>166890),array('wood'=>766460,'clay'=>793465,'iron'=>829665,'crop'=>151685,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>169820),array('wood'=>787540,'clay'=>815285,'iron'=>852480,'crop'=>155855,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>172800),array('wood'=>809195,'clay'=>837705,'iron'=>875920,'crop'=>160140,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>175820),array('wood'=>831450,'clay'=>860745,'iron'=>900010,'crop'=>164545,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>178880),array('wood'=>854315,'clay'=>884415,'iron'=>924760,'crop'=>169070,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>181990),array('wood'=>877810,'clay'=>908735,'iron'=>950190,'crop'=>173720,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>185130),array('wood'=>901950,'clay'=>933725,'iron'=>976320,'crop'=>178495,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>188330),array('wood'=>926750,'clay'=>959405,'iron'=>1000000,'crop'=>183405,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>191560),array('wood'=>952235,'clay'=>985785,'iron'=>1000000,'crop'=>188450,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>194840),array('wood'=>1000000,'clay'=>1000000,'iron'=>1000000,'crop'=>193630,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>198170));
+$bid41=array(1=>array('wood'=>780,'clay'=>420,'iron'=>660,'crop'=>540,'pop'=>5,'cp'=>4,'attri'=>0,'time'=>2200),array('wood'=>1000,'clay'=>540,'iron'=>845,'crop'=>690,'pop'=>3,'cp'=>4,'attri'=>0,'time'=>3150),array('wood'=>1280,'clay'=>690,'iron'=>1080,'crop'=>885,'pop'=>3,'cp'=>5,'attri'=>0,'time'=>4260),array('wood'=>1635,'clay'=>880,'iron'=>1385,'crop'=>1130,'pop'=>3,'cp'=>6,'attri'=>0,'time'=>5540),array('wood'=>2095,'clay'=>1125,'iron'=>1770,'crop'=>1450,'pop'=>3,'cp'=>7,'attri'=>0,'time'=>7020),array('wood'=>2680,'clay'=>1445,'iron'=>2270,'crop'=>1855,'pop'=>3,'cp'=>9,'attri'=>0,'time'=>8750),array('wood'=>3430,'clay'=>1845,'iron'=>2905,'crop'=>2375,'pop'=>3,'cp'=>11,'attri'=>0,'time'=>10750),array('wood'=>4390,'clay'=>2365,'iron'=>3715,'crop'=>3040,'pop'=>3,'cp'=>13,'attri'=>0,'time'=>13070),array('wood'=>5620,'clay'=>3025,'iron'=>4755,'crop'=>3890,'pop'=>3,'cp'=>15,'attri'=>0,'time'=>15760),array('wood'=>7195,'clay'=>3875,'iron'=>6085,'crop'=>4980,'pop'=>3,'cp'=>19,'attri'=>0,'time'=>18880),array('wood'=>9210,'clay'=>4960,'iron'=>7790,'crop'=>6375,'pop'=>4,'cp'=>22,'attri'=>0,'time'=>22500),array('wood'=>11785,'clay'=>6345,'iron'=>9975,'crop'=>8160,'pop'=>4,'cp'=>27,'attri'=>0,'time'=>26700),array('wood'=>15085,'clay'=>8125,'iron'=>12765,'crop'=>10445,'pop'=>4,'cp'=>32,'attri'=>0,'time'=>31570),array('wood'=>19310,'clay'=>10400,'iron'=>16340,'crop'=>13370,'pop'=>4,'cp'=>39,'attri'=>0,'time'=>37220),array('wood'=>24720,'clay'=>13310,'iron'=>20915,'crop'=>17115,'pop'=>4,'cp'=>46,'attri'=>0,'time'=>43780),array('wood'=>31640,'clay'=>17035,'iron'=>26775,'crop'=>21905,'pop'=>4,'cp'=>55,'attri'=>0,'time'=>51380),array('wood'=>40500,'clay'=>21810,'iron'=>34270,'crop'=>28040,'pop'=>4,'cp'=>67,'attri'=>0,'time'=>60200),array('wood'=>51840,'clay'=>27915,'iron'=>43865,'crop'=>35890,'pop'=>4,'cp'=>80,'attri'=>0,'time'=>70430),array('wood'=>66355,'clay'=>35730,'iron'=>56145,'crop'=>45940,'pop'=>4,'cp'=>96,'attri'=>0,'time'=>82300),array('wood'=>84935,'clay'=>45735,'iron'=>71870,'crop'=>58800,'pop'=>4,'cp'=>115,'attri'=>0,'time'=>96070));
+?>
diff --git a/GameEngine/Data/buidata.php_backup_postrespalfix b/GameEngine/Data/buidata.php_backup_postrespalfix
new file mode 100644
index 00000000..e681a1a7
--- /dev/null
+++ b/GameEngine/Data/buidata.php_backup_postrespalfix
@@ -0,0 +1,54 @@
+2),array('wood'=>40,'clay'=>100,'iron'=>50,'crop'=>60,'pop'=>2,'cp'=>1,'prod'=>5,'time'=>260),array('wood'=>65,'clay'=>165,'iron'=>85,'crop'=>100,'pop'=>1,'cp'=>1,'prod'=>9,'time'=>620),array('wood'=>110,'clay'=>280,'iron'=>140,'crop'=>165,'pop'=>1,'cp'=>2,'prod'=>15,'time'=>1190),array('wood'=>185,'clay'=>465,'iron'=>235,'crop'=>280,'pop'=>1,'cp'=>2,'prod'=>22,'time'=>2100),array('wood'=>310,'clay'=>780,'iron'=>390,'crop'=>465,'pop'=>1,'cp'=>2,'prod'=>33,'time'=>3560),array('wood'=>520,'clay'=>1300,'iron'=>650,'crop'=>780,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>3638),array('wood'=>870,'clay'=>2170,'iron'=>1085,'crop'=>1300,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>7220),array('wood'=>1450,'clay'=>3625,'iron'=>1810,'crop'=>2175,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>15590),array('wood'=>2420,'clay'=>6050,'iron'=>3025,'crop'=>3630,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>25150),array('wood'=>4040,'clay'=>10105,'iron'=>5050,'crop'=>6060,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>40440),array('wood'=>6750,'clay'=>16870,'iron'=>8435,'crop'=>10125,'pop'=>2,'cp'=>7,'prod'=>280,'time'=>64900),array('wood'=>11270,'clay'=>28175,'iron'=>14090,'crop'=>16905,'pop'=>2,'cp'=>9,'prod'=>375,'time'=>104050),array('wood'=>18820,'clay'=>47055,'iron'=>23525,'crop'=>28230,'pop'=>2,'cp'=>11,'prod'=>495,'time'=>166680),array('wood'=>31430,'clay'=>78580,'iron'=>39290,'crop'=>47150,'pop'=>2,'cp'=>13,'prod'=>635,'time'=>266880),array('wood'=>52490,'clay'=>131230,'iron'=>65615,'crop'=>78740,'pop'=>2,'cp'=>15,'prod'=>800,'time'=>427210),array('wood'=>87660,'clay'=>219155,'iron'=>109575,'crop'=>131490,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>683730),array('wood'=>146395,'clay'=>365985,'iron'=>182995,'crop'=>219590,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>1094170),array('wood'=>244480,'clay'=>611195,'iron'=>305600,'crop'=>366715,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>1750880),array('wood'=>408280,'clay'=>1020695,'iron'=>510350,'crop'=>612420,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>2801600),array('wood'=>681825,'clay'=>1704565,'iron'=>852280,'crop'=>1022740,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>4482770));
+$bid2=array(array('prod'=>2),array('wood'=>80,'clay'=>40,'iron'=>80,'crop'=>50,'pop'=>2,'cp'=>1,'prod'=>5,'time'=>220),array('wood'=>135,'clay'=>65,'iron'=>135,'crop'=>85,'pop'=>1,'cp'=>1,'prod'=>9,'time'=>550),array('wood'=>225,'clay'=>110,'iron'=>225,'crop'=>140,'pop'=>1,'cp'=>2,'prod'=>15,'time'=>1080),array('wood'=>375,'clay'=>185,'iron'=>375,'crop'=>235,'pop'=>1,'cp'=>2,'prod'=>22,'time'=>1930),array('wood'=>620,'clay'=>310,'iron'=>620,'crop'=>390,'pop'=>1,'cp'=>2,'prod'=>33,'time'=>3290),array('wood'=>1040,'clay'=>520,'iron'=>1040,'crop'=>650,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>5470),array('wood'=>1735,'clay'=>870,'iron'=>1735,'crop'=>1085,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>8950),array('wood'=>2900,'clay'=>1450,'iron'=>2900,'crop'=>1810,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>14520),array('wood'=>4840,'clay'=>2420,'iron'=>4840,'crop'=>3025,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>23430),array('wood'=>8080,'clay'=>4040,'iron'=>8080,'crop'=>5050,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>37690),array('wood'=>13500,'clay'=>6750,'iron'=>13500,'crop'=>8435,'pop'=>2,'cp'=>7,'prod'=>280,'time'=>60510),array('wood'=>22540,'clay'=>11270,'iron'=>22540,'crop'=>14090,'pop'=>2,'cp'=>9,'prod'=>375,'time'=>97010),array('wood'=>37645,'clay'=>18820,'iron'=>37645,'crop'=>23525,'pop'=>2,'cp'=>11,'prod'=>495,'time'=>155420),array('wood'=>62865,'clay'=>31430,'iron'=>62865,'crop'=>39290,'pop'=>2,'cp'=>13,'prod'=>635,'time'=>248870),array('wood'=>104985,'clay'=>52490,'iron'=>104985,'crop'=>65615,'pop'=>2,'cp'=>15,'prod'=>800,'time'=>398390),array('wood'=>175320,'clay'=>87660,'iron'=>175320,'crop'=>109575,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>637620),array('wood'=>292790,'clay'=>146395,'iron'=>292790,'crop'=>182995,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>1020390),array('wood'=>488955,'clay'=>244480,'iron'=>488955,'crop'=>305600,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>1632820),array('wood'=>816555,'clay'=>408280,'iron'=>816555,'crop'=>510350,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>2612710),array('wood'=>1363650,'clay'=>681825,'iron'=>1363650,'crop'=>852280,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>4180540));
+$bid3=array(array('prod'=>2),array('wood'=>100,'clay'=>80,'iron'=>30,'crop'=>60,'pop'=>3,'cp'=>1,'prod'=>5,'time'=>450),array('wood'=>165,'clay'=>135,'iron'=>50,'crop'=>100,'pop'=>2,'cp'=>1,'prod'=>9,'time'=>920),array('wood'=>280,'clay'=>225,'iron'=>85,'crop'=>165,'pop'=>2,'cp'=>2,'prod'=>15,'time'=>1670),array('wood'=>465,'clay'=>375,'iron'=>140,'crop'=>280,'pop'=>2,'cp'=>2,'prod'=>22,'time'=>2880),array('wood'=>780,'clay'=>620,'iron'=>235,'crop'=>465,'pop'=>2,'cp'=>2,'prod'=>33,'time'=>4800),array('wood'=>1300,'clay'=>1040,'iron'=>390,'crop'=>780,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>7880),array('wood'=>2170,'clay'=>1735,'iron'=>650,'crop'=>1300,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>12810),array('wood'=>3625,'clay'=>2900,'iron'=>1085,'crop'=>2175,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>20690),array('wood'=>6050,'clay'=>4840,'iron'=>1815,'crop'=>3630,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>33310),array('wood'=>10105,'clay'=>8080,'iron'=>3030,'crop'=>6060,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>53500),array('wood'=>16870,'clay'=>13500,'iron'=>5060,'crop'=>10125,'pop'=>3,'cp'=>7,'prod'=>280,'time'=>85800),array('wood'=>28175,'clay'=>22540,'iron'=>8455,'crop'=>16905,'pop'=>3,'cp'=>9,'prod'=>375,'time'=>137470),array('wood'=>47055,'clay'=>37645,'iron'=>14115,'crop'=>28230,'pop'=>3,'cp'=>11,'prod'=>495,'time'=>220160),array('wood'=>78580,'clay'=>62865,'iron'=>23575,'crop'=>47150,'pop'=>3,'cp'=>13,'prod'=>635,'time'=>352450),array('wood'=>131230,'clay'=>104985,'iron'=>39370,'crop'=>78740,'pop'=>3,'cp'=>15,'prod'=>800,'time'=>564120),array('wood'=>219155,'clay'=>175320,'iron'=>65745,'crop'=>131490,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>902760),array('wood'=>365985,'clay'=>292790,'iron'=>109795,'crop'=>219590,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>145546),array('wood'=>611195,'clay'=>488955,'iron'=>183360,'crop'=>366715,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>2311660),array('wood'=>1020695,'clay'=>816555,'iron'=>306210,'crop'=>612420,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>3698850),array('wood'=>1704565,'clay'=>1363650,'iron'=>511370,'crop'=>1022740,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>5918370));
+$bid4=array(array('prod'=>2),array('wood'=>70,'clay'=>90,'iron'=>70,'crop'=>20,'pop'=>0,'cp'=>1,'prod'=>5,'time'=>150),array('wood'=>115,'clay'=>150,'iron'=>115,'crop'=>35,'pop'=>0,'cp'=>1,'prod'=>9,'time'=>440),array('wood'=>195,'clay'=>250,'iron'=>195,'crop'=>55,'pop'=>0,'cp'=>2,'prod'=>15,'time'=>900),array('wood'=>325,'clay'=>420,'iron'=>325,'crop'=>95,'pop'=>0,'cp'=>2,'prod'=>22,'time'=>1650),array('wood'=>545,'clay'=>700,'iron'=>545,'crop'=>155,'pop'=>0,'cp'=>2,'prod'=>33,'time'=>2830),array('wood'=>910,'clay'=>1170,'iron'=>910,'crop'=>260,'pop'=>1,'cp'=>3,'prod'=>50,'time'=>4730),array('wood'=>1520,'clay'=>1950,'iron'=>1520,'crop'=>435,'pop'=>1,'cp'=>4,'prod'=>70,'time'=>7780),array('wood'=>2535,'clay'=>3260,'iron'=>2535,'crop'=>725,'pop'=>1,'cp'=>4,'prod'=>100,'time'=>12190),array('wood'=>4235,'clay'=>5445,'iron'=>4235,'crop'=>1210,'pop'=>1,'cp'=>5,'prod'=>145,'time'=>19690),array('wood'=>7070,'clay'=>9095,'iron'=>7070,'crop'=>2020,'pop'=>1,'cp'=>6,'prod'=>200,'time'=>31700),array('wood'=>11810,'clay'=>15185,'iron'=>11810,'crop'=>3375,'pop'=>1,'cp'=>7,'prod'=>280,'time'=>50910),array('wood'=>19725,'clay'=>25360,'iron'=>19725,'crop'=>5635,'pop'=>1,'cp'=>9,'prod'=>375,'time'=>84700),array('wood'=>32940,'clay'=>42350,'iron'=>32940,'crop'=>9410,'pop'=>1,'cp'=>11,'prod'=>495,'time'=>135710),array('wood'=>55005,'clay'=>70720,'iron'=>55005,'crop'=>15715,'pop'=>1,'cp'=>13,'prod'=>635,'time'=>217340),array('wood'=>91860,'clay'=>118105,'iron'=>91860,'crop'=>26245,'pop'=>1,'cp'=>15,'prod'=>800,'time'=>347950),array('wood'=>153405,'clay'=>197240,'iron'=>153405,'crop'=>43830,'pop'=>2,'cp'=>18,'prod'=>1000,'time'=>556910),array('wood'=>256190,'clay'=>329385,'iron'=>256190,'crop'=>73195,'pop'=>2,'cp'=>22,'prod'=>1300,'time'=>891260),array('wood'=>427835,'clay'=>550075,'iron'=>427835,'crop'=>122240,'pop'=>2,'cp'=>27,'prod'=>1600,'time'=>1426210),array('wood'=>714485,'clay'=>918625,'iron'=>714485,'crop'=>204140,'pop'=>2,'cp'=>32,'prod'=>2000,'time'=>2282140),array('wood'=>1193195,'clay'=>1534105,'iron'=>1193195,'crop'=>340915,'pop'=>2,'cp'=>38,'prod'=>2450,'time'=>3651630));
+$bid5=array(1=>array('wood'=>520,'clay'=>380,'iron'=>290,'crop'=>90,'pop'=>4,'cp'=>1,'attri'=>5,'time'=>3000),array('wood'=>935,'clay'=>685,'iron'=>520,'crop'=>160,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>5700),array('wood'=>1685,'clay'=>1230,'iron'=>940,'crop'=>290,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>9750),array('wood'=>3035,'clay'=>2215,'iron'=>1690,'crop'=>525,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>15830),array('wood'=>5460,'clay'=>3990,'iron'=>3045,'crop'=>945,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>24940));
+$bid6=array(1=>array('wood'=>440,'clay'=>480,'iron'=>320,'crop'=>50,'pop'=>3,'cp'=>1,'attri'=>5,'time'=>2240),array('wood'=>790,'clay'=>865,'iron'=>575,'crop'=>90,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>4560),array('wood'=>1425,'clay'=>1555,'iron'=>1035,'crop'=>160,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>8040),array('wood'=>2565,'clay'=>2800,'iron'=>1865,'crop'=>290,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>13260),array('wood'=>4620,'clay'=>5040,'iron'=>3360,'crop'=>525,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>21090));
+$bid7=array(1=>array('wood'=>200,'clay'=>450,'iron'=>510,'crop'=>120,'pop'=>6,'cp'=>1,'attri'=>5,'time'=>4080),array('wood'=>360,'clay'=>810,'iron'=>920,'crop'=>215,'pop'=>3,'cp'=>1,'attri'=>10,'time'=>7320),array('wood'=>650,'clay'=>1460,'iron'=>1650,'crop'=>390,'pop'=>3,'cp'=>2,'attri'=>15,'time'=>12180),array('wood'=>1165,'clay'=>2625,'iron'=>2975,'crop'=>700,'pop'=>3,'cp'=>2,'attri'=>20,'time'=>19470),array('wood'=>2100,'clay'=>4725,'iron'=>5355,'crop'=>1260,'pop'=>3,'cp'=>2,'attri'=>25,'time'=>30410));
+$bid8=array(1=>array('wood'=>500,'clay'=>440,'iron'=>380,'crop'=>1240,'pop'=>3,'cp'=>1,'attri'=>5,'time'=>1840),array('wood'=>900,'clay'=>790,'iron'=>685,'crop'=>2230,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>3960),array('wood'=>1620,'clay'=>1425,'iron'=>1230,'crop'=>4020,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>7140),array('wood'=>2915,'clay'=>2565,'iron'=>2215,'crop'=>7230,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>11910),array('wood'=>5250,'clay'=>4620,'iron'=>3990,'crop'=>13015,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>19070));
+$bid9=array(1=>array('wood'=>1200,'clay'=>1480,'iron'=>870,'crop'=>1600,'pop'=>4,'cp'=>1,'attri'=>5,'time'=>3680),array('wood'=>2160,'clay'=>2665,'iron'=>1565,'crop'=>2880,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>6720),array('wood'=>3890,'clay'=>4795,'iron'=>2820,'crop'=>5185,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>11280),array('wood'=>7000,'clay'=>8630,'iron'=>5075,'crop'=>9330,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>18120),array('wood'=>12595,'clay'=>15535,'iron'=>9135,'crop'=>16795,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>28380));
+$bid10=array(1=>array('wood'=>130,'clay'=>160,'iron'=>90,'crop'=>40,'pop'=>1,'cp'=>1,'attri'=>1200,'time'=>2000),array('wood'=>165,'clay'=>205,'iron'=>115,'crop'=>50,'pop'=>1,'cp'=>1,'attri'=>1700,'time'=>2620),array('wood'=>215,'clay'=>260,'iron'=>145,'crop'=>65,'pop'=>1,'cp'=>2,'attri'=>2300,'time'=>3340),array('wood'=>275,'clay'=>335,'iron'=>190,'crop'=>85,'pop'=>1,'cp'=>2,'attri'=>3100,'time'=>4170),array('wood'=>350,'clay'=>430,'iron'=>240,'crop'=>105,'pop'=>1,'cp'=>2,'attri'=>4000,'time'=>5140),array('wood'=>445,'clay'=>550,'iron'=>310,'crop'=>135,'pop'=>1,'cp'=>3,'attri'=>5000,'time'=>6260),array('wood'=>570,'clay'=>705,'iron'=>395,'crop'=>175,'pop'=>1,'cp'=>4,'attri'=>6300,'time'=>7570),array('wood'=>730,'clay'=>900,'iron'=>505,'crop'=>225,'pop'=>1,'cp'=>4,'attri'=>7800,'time'=>9080),array('wood'=>935,'clay'=>1115,'iron'=>650,'crop'=>290,'pop'=>1,'cp'=>5,'attri'=>9600,'time'=>10830),array('wood'=>1200,'clay'=>1475,'iron'=>830,'crop'=>370,'pop'=>1,'cp'=>6,'attri'=>11800,'time'=>12860),array('wood'=>1535,'clay'=>1890,'iron'=>1065,'crop'=>470,'pop'=>2,'cp'=>7,'attri'=>14400,'time'=>15220),array('wood'=>1965,'clay'=>2420,'iron'=>1360,'crop'=>605,'pop'=>2,'cp'=>9,'attri'=>17600,'time'=>17950),array('wood'=>2515,'clay'=>3095,'iron'=>1740,'crop'=>775,'pop'=>2,'cp'=>11,'attri'=>21400,'time'=>21130),array('wood'=>3220,'clay'=>3960,'iron'=>2230,'crop'=>990,'pop'=>2,'cp'=>13,'attri'=>25900,'time'=>24810),array('wood'=>4120,'clay'=>5070,'iron'=>2850,'crop'=>1270,'pop'=>2,'cp'=>15,'attri'=>31300,'time'=>29080),array('wood'=>5275,'clay'=>6490,'iron'=>3650,'crop'=>1625,'pop'=>2,'cp'=>18,'attri'=>37900,'time'=>34030),array('wood'=>6750,'clay'=>8310,'iron'=>4675,'crop'=>2075,'pop'=>2,'cp'=>22,'attri'=>45700,'time'=>39770),array('wood'=>8640,'clay'=>10635,'iron'=>5980,'crop'=>2660,'pop'=>2,'cp'=>27,'attri'=>55100,'time'=>46440),array('wood'=>11060,'clay'=>13610,'iron'=>7655,'crop'=>3405,'pop'=>2,'cp'=>32,'attri'=>66400,'time'=>54170),array('wood'=>14155,'clay'=>17420,'iron'=>9800,'crop'=>4355,'pop'=>2,'cp'=>38,'attri'=>80000,'time'=>63130));
+$bid11=array(1=>array('wood'=>80,'clay'=>100,'iron'=>70,'crop'=>20,'pop'=>1,'cp'=>1,'attri'=>1200,'time'=>1600),array('wood'=>100,'clay'=>130,'iron'=>90,'crop'=>25,'pop'=>1,'cp'=>1,'attri'=>1700,'time'=>2160),array('wood'=>130,'clay'=>165,'iron'=>115,'crop'=>35,'pop'=>1,'cp'=>2,'attri'=>2300,'time'=>2800),array('wood'=>170,'clay'=>210,'iron'=>145,'crop'=>40,'pop'=>1,'cp'=>2,'attri'=>3100,'time'=>3550),array('wood'=>215,'clay'=>270,'iron'=>190,'crop'=>55,'pop'=>1,'cp'=>2,'attri'=>4000,'time'=>4420),array('wood'=>275,'clay'=>345,'iron'=>240,'crop'=>70,'pop'=>1,'cp'=>3,'attri'=>5000,'time'=>5420),array('wood'=>350,'clay'=>440,'iron'=>310,'crop'=>90,'pop'=>1,'cp'=>4,'attri'=>6300,'time'=>6590),array('wood'=>450,'clay'=>565,'iron'=>395,'crop'=>115,'pop'=>1,'cp'=>4,'attri'=>7800,'time'=>7950),array('wood'=>575,'clay'=>720,'iron'=>505,'crop'=>145,'pop'=>1,'cp'=>5,'attri'=>9600,'time'=>9520),array('wood'=>740,'clay'=>920,'iron'=>645,'crop'=>185,'pop'=>1,'cp'=>6,'attri'=>11800,'time'=>11340),array('wood'=>945,'clay'=>1180,'iron'=>825,'crop'=>235,'pop'=>2,'cp'=>7,'attri'=>14400,'time'=>13450),array('wood'=>1210,'clay'=>1510,'iron'=>1060,'crop'=>300,'pop'=>2,'cp'=>9,'attri'=>17600,'time'=>15910),array('wood'=>1545,'clay'=>1935,'iron'=>1355,'crop'=>385,'pop'=>2,'cp'=>11,'attri'=>21400,'time'=>18750),array('wood'=>1980,'clay'=>2475,'iron'=>1735,'crop'=>495,'pop'=>2,'cp'=>13,'attri'=>25900,'time'=>22050),array('wood'=>2535,'clay'=>3170,'iron'=>2220,'crop'=>635,'pop'=>2,'cp'=>15,'attri'=>31300,'time'=>25880),array('wood'=>3245,'clay'=>4055,'iron'=>2840,'crop'=>810,'pop'=>2,'cp'=>18,'attri'=>37900,'time'=>30320),array('wood'=>4155,'clay'=>5190,'iron'=>3635,'crop'=>1040,'pop'=>2,'cp'=>22,'attri'=>45700,'time'=>35470),array('wood'=>5315,'clay'=>6645,'iron'=>4650,'crop'=>1330,'pop'=>2,'cp'=>27,'attri'=>55100,'time'=>41450),array('wood'=>6805,'clay'=>8505,'iron'=>5955,'crop'=>1700,'pop'=>2,'cp'=>32,'attri'=>66400,'time'=>48380),array('wood'=>8710,'clay'=>10890,'iron'=>7620,'crop'=>2180,'pop'=>2,'cp'=>38,'attri'=>80000,'time'=>56420));
+$bid12=array(1=>array('wood'=>170,'clay'=>200,'iron'=>380,'crop'=>130,'pop'=>4,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>220,'clay'=>255,'iron'=>485,'crop'=>165,'pop'=>2,'cp'=>3,'attri'=>96,'time'=>2620),array('wood'=>280,'clay'=>330,'iron'=>625,'crop'=>215,'pop'=>2,'cp'=>3,'attri'=>93,'time'=>3340),array('wood'=>355,'clay'=>420,'iron'=>795,'crop'=>275,'pop'=>2,'cp'=>4,'attri'=>90,'time'=>4170),array('wood'=>455,'clay'=>535,'iron'=>1020,'crop'=>350,'pop'=>2,'cp'=>5,'attri'=>86,'time'=>5140),array('wood'=>585,'clay'=>685,'iron'=>1305,'crop'=>445,'pop'=>3,'cp'=>6,'attri'=>83,'time'=>6260),array('wood'=>750,'clay'=>880,'iron'=>1670,'crop'=>570,'pop'=>3,'cp'=>7,'attri'=>80,'time'=>7570),array('wood'=>955,'clay'=>1125,'iron'=>2140,'crop'=>730,'pop'=>3,'cp'=>9,'attri'=>77,'time'=>9080),array('wood'=>1225,'clay'=>1440,'iron'=>2740,'crop'=>935,'pop'=>3,'cp'=>10,'attri'=>75,'time'=>10830),array('wood'=>1570,'clay'=>1845,'iron'=>3505,'crop'=>1200,'pop'=>3,'cp'=>12,'attri'=>72,'time'=>12860),array('wood'=>2005,'clay'=>2360,'iron'=>4485,'crop'=>1535,'pop'=>3,'cp'=>15,'attri'=>69,'time'=>15220),array('wood'=>2570,'clay'=>3020,'iron'=>5740,'crop'=>1965,'pop'=>3,'cp'=>18,'attri'=>67,'time'=>17950),array('wood'=>3290,'clay'=>3870,'iron'=>7350,'crop'=>2515,'pop'=>3,'cp'=>21,'attri'=>64,'time'=>21130),array('wood'=>4210,'clay'=>4950,'iron'=>9410,'crop'=>3220,'pop'=>3,'cp'=>26,'attri'=>62,'time'=>24810),array('wood'=>5390,'clay'=>6340,'iron'=>12045,'crop'=>4120,'pop'=>3,'cp'=>31,'attri'=>60,'time'=>29080),array('wood'=>6895,'clay'=>8115,'iron'=>15415,'crop'=>5275,'pop'=>4,'cp'=>37,'attri'=>58,'time'=>34030),array('wood'=>8825,'clay'=>10385,'iron'=>19730,'crop'=>6750,'pop'=>4,'cp'=>44,'attri'=>56,'time'=>39770),array('wood'=>11300,'clay'=>13290,'iron'=>25255,'crop'=>8640,'pop'=>4,'cp'=>53,'attri'=>54,'time'=>46440),array('wood'=>14460,'clay'=>17015,'iron'=>32325,'crop'=>11060,'pop'=>4,'cp'=>64,'attri'=>52,'time'=>54170),array('wood'=>18510,'clay'=>21780,'iron'=>41380,'crop'=>14155,'pop'=>4,'cp'=>77,'attri'=>50,'time'=>63130));
+$bid13=array(1=>array('wood'=>130,'clay'=>210,'iron'=>410,'crop'=>130,'pop'=>4,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>165,'clay'=>270,'iron'=>525,'crop'=>165,'pop'=>2,'cp'=>3,'attri'=>96,'time'=>2620),array('wood'=>215,'clay'=>345,'iron'=>670,'crop'=>215,'pop'=>2,'cp'=>3,'attri'=>93,'time'=>3340),array('wood'=>275,'clay'=>440,'iron'=>860,'crop'=>275,'pop'=>2,'cp'=>4,'attri'=>90,'time'=>4170),array('wood'=>350,'clay'=>565,'iron'=>1100,'crop'=>350,'pop'=>2,'cp'=>5,'attri'=>86,'time'=>5140),array('wood'=>445,'clay'=>720,'iron'=>1410,'crop'=>445,'pop'=>3,'cp'=>6,'attri'=>83,'time'=>6260),array('wood'=>570,'clay'=>925,'iron'=>1805,'crop'=>570,'pop'=>3,'cp'=>7,'attri'=>80,'time'=>7570),array('wood'=>730,'clay'=>1180,'iron'=>2310,'crop'=>730,'pop'=>3,'cp'=>9,'attri'=>77,'time'=>9080),array('wood'=>935,'clay'=>1515,'iron'=>2955,'crop'=>935,'pop'=>3,'cp'=>10,'attri'=>75,'time'=>10830),array('wood'=>1200,'clay'=>1935,'iron'=>3780,'crop'=>1200,'pop'=>3,'cp'=>12,'attri'=>72,'time'=>12860),array('wood'=>1535,'clay'=>2480,'iron'=>4840,'crop'=>1535,'pop'=>3,'cp'=>15,'attri'=>69,'time'=>15220),array('wood'=>1965,'clay'=>3175,'iron'=>6195,'crop'=>1965,'pop'=>3,'cp'=>18,'attri'=>67,'time'=>17950),array('wood'=>2515,'clay'=>4060,'iron'=>7930,'crop'=>2515,'pop'=>3,'cp'=>21,'attri'=>64,'time'=>21130),array('wood'=>3220,'clay'=>5200,'iron'=>10150,'crop'=>3220,'pop'=>3,'cp'=>26,'attri'=>62,'time'=>24810),array('wood'=>4120,'clay'=>6655,'iron'=>12995,'crop'=>4120,'pop'=>3,'cp'=>31,'attri'=>60,'time'=>29080),array('wood'=>5275,'clay'=>8520,'iron'=>16630,'crop'=>5275,'pop'=>4,'cp'=>37,'attri'=>58,'time'=>34030),array('wood'=>6750,'clay'=>10905,'iron'=>21290,'crop'=>6750,'pop'=>4,'cp'=>44,'attri'=>56,'time'=>39770),array('wood'=>8640,'clay'=>13955,'iron'=>27250,'crop'=>8640,'pop'=>4,'cp'=>53,'attri'=>54,'time'=>46440),array('wood'=>11060,'clay'=>17865,'iron'=>34880,'crop'=>11060,'pop'=>4,'cp'=>64,'attri'=>52,'time'=>54170),array('wood'=>14155,'clay'=>22865,'iron'=>44645,'crop'=>14155,'pop'=>4,'cp'=>77,'attri'=>50,'time'=>63130));
+$bid14=array(1=>array('wood'=>1750,'clay'=>2250,'iron'=>1530,'crop'=>240,'pop'=>1,'cp'=>1,'attri'=>110,'time'=>3500),array('wood'=>2240,'clay'=>2880,'iron'=>1960,'crop'=>305,'pop'=>1,'cp'=>1,'attri'=>120,'time'=>4360),array('wood'=>2865,'clay'=>3685,'iron'=>2505,'crop'=>395,'pop'=>1,'cp'=>2,'attri'=>130,'time'=>5360),array('wood'=>3670,'clay'=>4720,'iron'=>3210,'crop'=>505,'pop'=>1,'cp'=>2,'attri'=>140,'time'=>6510),array('wood'=>4700,'clay'=>6040,'iron'=>4105,'crop'=>645,'pop'=>1,'cp'=>2,'attri'=>150,'time'=>7860),array('wood'=>6015,'clay'=>7730,'iron'=>5255,'crop'=>825,'pop'=>1,'cp'=>3,'attri'=>160,'time'=>9410),array('wood'=>7695,'clay'=>9895,'iron'=>6730,'crop'=>1055,'pop'=>1,'cp'=>4,'attri'=>170,'time'=>11220),array('wood'=>9850,'clay'=>12665,'iron'=>8615,'crop'=>1350,'pop'=>1,'cp'=>4,'attri'=>180,'time'=>13320),array('wood'=>12610,'clay'=>16215,'iron'=>11025,'crop'=>1730,'pop'=>1,'cp'=>5,'attri'=>190,'time'=>15750),array('wood'=>16140,'clay'=>20755,'iron'=>14110,'crop'=>2215,'pop'=>1,'cp'=>6,'attri'=>200,'time'=>18570),array('wood'=>20660,'clay'=>26565,'iron'=>18065,'crop'=>2835,'pop'=>2,'cp'=>7,'attri'=>210,'time'=>21840),array('wood'=>26445,'clay'=>34000,'iron'=>23120,'crop'=>3625,'pop'=>2,'cp'=>9,'attri'=>220,'time'=>25630),array('wood'=>33850,'clay'=>43520,'iron'=>29595,'crop'=>4640,'pop'=>2,'cp'=>11,'attri'=>230,'time'=>30030),array('wood'=>43330,'clay'=>55705,'iron'=>37880,'crop'=>5940,'pop'=>2,'cp'=>13,'attri'=>240,'time'=>35140),array('wood'=>55460,'clay'=>71305,'iron'=>48490,'crop'=>7605,'pop'=>2,'cp'=>15,'attri'=>250,'time'=>41060),array('wood'=>70990,'clay'=>91270,'iron'=>62065,'crop'=>9735,'pop'=>2,'cp'=>18,'attri'=>260,'time'=>47930),array('wood'=>90865,'clay'=>116825,'iron'=>79440,'crop'=>12460,'pop'=>2,'cp'=>22,'attri'=>270,'time'=>55900),array('wood'=>116305,'clay'=>149540,'iron'=>101685,'crop'=>15950,'pop'=>2,'cp'=>27,'attri'=>280,'time'=>65140),array('wood'=>148875,'clay'=>191410,'iron'=>130160,'crop'=>20415,'pop'=>2,'cp'=>32,'attri'=>290,'time'=>75860),array('wood'=>190560,'clay'=>245005,'iron'=>166600,'crop'=>26135,'pop'=>2,'cp'=>38,'attri'=>300,'time'=>88300));
+$bid15=array(1=>array('wood'=>70,'clay'=>40,'iron'=>60,'crop'=>20,'pop'=>2,'cp'=>2,'attri'=>100,'time'=>2620),array('wood'=>90,'clay'=>50,'iron'=>75,'crop'=>25,'pop'=>1,'cp'=>3,'attri'=>96,'time'=>3220),array('wood'=>115,'clay'=>65,'iron'=>100,'crop'=>35,'pop'=>1,'cp'=>3,'attri'=>93,'time'=>3880),array('wood'=>145,'clay'=>85,'iron'=>125,'crop'=>40,'pop'=>1,'cp'=>4,'attri'=>90,'time'=>4610),array('wood'=>190,'clay'=>105,'iron'=>160,'crop'=>55,'pop'=>1,'cp'=>5,'attri'=>86,'time'=>5410),array('wood'=>240,'clay'=>135,'iron'=>205,'crop'=>70,'pop'=>2,'cp'=>6,'attri'=>83,'time'=>6300),array('wood'=>310,'clay'=>175,'iron'=>265,'crop'=>90,'pop'=>2,'cp'=>7,'attri'=>80,'time'=>7280),array('wood'=>395,'clay'=>225,'iron'=>340,'crop'=>115,'pop'=>2,'cp'=>9,'attri'=>77,'time'=>8380),array('wood'=>505,'clay'=>290,'iron'=>430,'crop'=>145,'pop'=>2,'cp'=>10,'attri'=>75,'time'=>9590),array('wood'=>645,'clay'=>370,'iron'=>555,'crop'=>185,'pop'=>2,'cp'=>12,'attri'=>72,'time'=>10940),array('wood'=>825,'clay'=>470,'iron'=>710,'crop'=>235,'pop'=>2,'cp'=>15,'attri'=>69,'time'=>12440),array('wood'=>1060,'clay'=>605,'iron'=>905,'crop'=>300,'pop'=>2,'cp'=>18,'attri'=>67,'time'=>14120),array('wood'=>1355,'clay'=>775,'iron'=>1160,'crop'=>385,'pop'=>2,'cp'=>21,'attri'=>64,'time'=>15980),array('wood'=>1735,'clay'=>990,'iron'=>1485,'crop'=>495,'pop'=>2,'cp'=>26,'attri'=>62,'time'=>18050),array('wood'=>2220,'clay'=>1270,'iron'=>1900,'crop'=>635,'pop'=>2,'cp'=>31,'attri'=>60,'time'=>20370),array('wood'=>2840,'clay'=>1625,'iron'=>2435,'crop'=>810,'pop'=>3,'cp'=>37,'attri'=>58,'time'=>22950),array('wood'=>3635,'clay'=>2075,'iron'=>3115,'crop'=>1040,'pop'=>3,'cp'=>44,'attri'=>56,'time'=>25830),array('wood'=>4650,'clay'=>2660,'iron'=>3990,'crop'=>1330,'pop'=>3,'cp'=>53,'attri'=>54,'time'=>29040),array('wood'=>5955,'clay'=>3405,'iron'=>5105,'crop'=>1700,'pop'=>3,'cp'=>64,'attri'=>52,'time'=>32630),array('wood'=>7620,'clay'=>4355,'iron'=>6535,'crop'=>2180,'pop'=>3,'cp'=>77,'attri'=>50,'time'=>0));
+$bid16=array(1=>array('wood'=>110,'clay'=>160,'iron'=>90,'crop'=>70,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>670),array('wood'=>140,'clay'=>205,'iron'=>115,'crop'=>90,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>870),array('wood'=>180,'clay'=>260,'iron'=>145,'crop'=>115,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1110),array('wood'=>230,'clay'=>335,'iron'=>190,'crop'=>145,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1390),array('wood'=>295,'clay'=>430,'iron'=>240,'crop'=>190,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1710),array('wood'=>380,'clay'=>550,'iron'=>310,'crop'=>240,'pop'=>1,'cp'=>3,'attri'=>0,'time'=>2090),array('wood'=>485,'clay'=>705,'iron'=>395,'crop'=>310,'pop'=>1,'cp'=>4,'attri'=>0,'time'=>2520),array('wood'=>620,'clay'=>900,'iron'=>505,'crop'=>395,'pop'=>1,'cp'=>4,'attri'=>0,'time'=>3030),array('wood'=>795,'clay'=>1155,'iron'=>650,'crop'=>505,'pop'=>1,'cp'=>5,'attri'=>0,'time'=>3610),array('wood'=>1015,'clay'=>1475,'iron'=>830,'crop'=>645,'pop'=>1,'cp'=>6,'attri'=>0,'time'=>4290),array('wood'=>1300,'clay'=>1890,'iron'=>1065,'crop'=>825,'pop'=>2,'cp'=>7,'attri'=>0,'time'=>5070),array('wood'=>1660,'clay'=>2420,'iron'=>1360,'crop'=>1060,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>5980),array('wood'=>2130,'clay'=>3095,'iron'=>1740,'crop'=>1355,'pop'=>2,'cp'=>11,'attri'=>0,'time'=>7040),array('wood'=>2725,'clay'=>3960,'iron'=>2230,'crop'=>1735,'pop'=>2,'cp'=>13,'attri'=>0,'time'=>8270),array('wood'=>3485,'clay'=>5070,'iron'=>2850,'crop'=>2220,'pop'=>2,'cp'=>15,'attri'=>0,'time'=>9690),array('wood'=>4460,'clay'=>6490,'iron'=>3650,'crop'=>2840,'pop'=>2,'cp'=>18,'attri'=>0,'time'=>11340),array('wood'=>5710,'clay'=>8310,'iron'=>4675,'crop'=>3635,'pop'=>2,'cp'=>22,'attri'=>0,'time'=>13260),array('wood'=>7310,'clay'=>10635,'iron'=>5980,'crop'=>4650,'pop'=>2,'cp'=>27,'attri'=>0,'time'=>15480),array('wood'=>9360,'clay'=>13610,'iron'=>7655,'crop'=>5955,'pop'=>2,'cp'=>32,'attri'=>0,'time'=>18060),array('wood'=>11980,'clay'=>17420,'iron'=>9800,'crop'=>7620,'pop'=>2,'cp'=>38,'attri'=>0,'time'=>21040));
+$bid17=array(1=>array('wood'=>80,'clay'=>70,'iron'=>120,'crop'=>70,'pop'=>4,'cp'=>4,'attri'=>1,'time'=>1800),array('wood'=>100,'clay'=>90,'iron'=>155,'crop'=>90,'pop'=>2,'cp'=>4,'attri'=>2,'time'=>2390),array('wood'=>130,'clay'=>115,'iron'=>195,'crop'=>115,'pop'=>2,'cp'=>5,'attri'=>3,'time'=>3070),array('wood'=>170,'clay'=>145,'iron'=>250,'crop'=>145,'pop'=>2,'cp'=>6,'attri'=>4,'time'=>3860),array('wood'=>215,'clay'=>190,'iron'=>320,'crop'=>190,'pop'=>2,'cp'=>7,'attri'=>5,'time'=>4780),array('wood'=>275,'clay'=>240,'iron'=>410,'crop'=>240,'pop'=>3,'cp'=>9,'attri'=>6,'time'=>5840),array('wood'=>350,'clay'=>310,'iron'=>530,'crop'=>310,'pop'=>3,'cp'=>11,'attri'=>7,'time'=>7080),array('wood'=>450,'clay'=>395,'iron'=>675,'crop'=>395,'pop'=>3,'cp'=>13,'attri'=>8,'time'=>8510),array('wood'=>575,'clay'=>505,'iron'=>865,'crop'=>505,'pop'=>3,'cp'=>15,'attri'=>9,'time'=>10170),array('wood'=>740,'clay'=>645,'iron'=>1105,'crop'=>645,'pop'=>3,'cp'=>19,'attri'=>10,'time'=>12100),array('wood'=>945,'clay'=>825,'iron'=>1415,'crop'=>825,'pop'=>3,'cp'=>22,'attri'=>11,'time'=>14340),array('wood'=>1210,'clay'=>1060,'iron'=>1815,'crop'=>1060,'pop'=>3,'cp'=>27,'attri'=>12,'time'=>16930),array('wood'=>1545,'clay'=>1355,'iron'=>2320,'crop'=>1355,'pop'=>3,'cp'=>32,'attri'=>13,'time'=>19940),array('wood'=>1980,'clay'=>1735,'iron'=>2970,'crop'=>1735,'pop'=>3,'cp'=>39,'attri'=>14,'time'=>23430),array('wood'=>2535,'clay'=>2220,'iron'=>3805,'crop'=>2220,'pop'=>3,'cp'=>46,'attri'=>15,'time'=>27480),array('wood'=>3245,'clay'=>2840,'iron'=>4870,'crop'=>2840,'pop'=>4,'cp'=>55,'attri'=>16,'time'=>32180),array('wood'=>4155,'clay'=>3635,'iron'=>6230,'crop'=>3635,'pop'=>4,'cp'=>67,'attri'=>17,'time'=>37620),array('wood'=>5315,'clay'=>4650,'iron'=>7975,'crop'=>4650,'pop'=>4,'cp'=>80,'attri'=>18,'time'=>43940),array('wood'=>6805,'clay'=>5955,'iron'=>10210,'crop'=>5955,'pop'=>4,'cp'=>96,'attri'=>19,'time'=>51270),array('wood'=>8710,'clay'=>7620,'iron'=>13065,'crop'=>7620,'pop'=>4,'cp'=>115,'attri'=>20,'time'=>59780));
+$bid18=array(1=>array('wood'=>180,'clay'=>130,'iron'=>150,'crop'=>80,'pop'=>3,'cp'=>5,'attri'=>0,'time'=>2000),array('wood'=>230,'clay'=>165,'iron'=>190,'crop'=>100,'pop'=>2,'cp'=>6,'attri'=>0,'time'=>2620),array('wood'=>295,'clay'=>215,'iron'=>245,'crop'=>130,'pop'=>2,'cp'=>7,'attri'=>9,'time'=>3340),array('wood'=>375,'clay'=>275,'iron'=>315,'crop'=>170,'pop'=>2,'cp'=>8,'attri'=>12,'time'=>4170),array('wood'=>485,'clay'=>350,'iron'=>405,'crop'=>215,'pop'=>2,'cp'=>10,'attri'=>15,'time'=>5140),array('wood'=>620,'clay'=>445,'iron'=>515,'crop'=>275,'pop'=>2,'cp'=>12,'attri'=>18,'time'=>6260),array('wood'=>790,'clay'=>570,'iron'=>660,'crop'=>350,'pop'=>2,'cp'=>14,'attri'=>21,'time'=>7570),array('wood'=>1015,'clay'=>730,'iron'=>845,'crop'=>450,'pop'=>2,'cp'=>17,'attri'=>24,'time'=>9080),array('wood'=>1295,'clay'=>935,'iron'=>1080,'crop'=>575,'pop'=>2,'cp'=>21,'attri'=>27,'time'=>10830),array('wood'=>1660,'clay'=>1200,'iron'=>1385,'crop'=>740,'pop'=>2,'cp'=>25,'attri'=>30,'time'=>12860),array('wood'=>2125,'clay'=>1535,'iron'=>1770,'crop'=>945,'pop'=>3,'cp'=>30,'attri'=>33,'time'=>15220),array('wood'=>2720,'clay'=>1965,'iron'=>2265,'crop'=>1210,'pop'=>3,'cp'=>36,'attri'=>36,'time'=>17950),array('wood'=>3480,'clay'=>2515,'iron'=>2900,'crop'=>1545,'pop'=>3,'cp'=>43,'attri'=>39,'time'=>21130), array('wood'=>4455,'clay'=>3220,'iron'=>3715,'crop'=>1980,'pop'=>3,'cp'=>51,'attri'=>42,'time'=>24810),array('wood'=>5705,'clay'=>4120,'iron'=>4755,'crop'=>2535,'pop'=>3,'cp'=>62,'attri'=>45,'time'=>29080),array('wood'=>7300,'clay'=>5275,'iron'=>6085,'crop'=>3245,'pop'=>3,'cp'=>74,'attri'=>48,'time'=>34030),array('wood'=>9345,'clay'=>6750,'iron'=>7790,'crop'=>4155,'pop'=>3,'cp'=>89,'attri'=>51,'time'=>39770),array('wood'=>11965,'clay'=>8640,'iron'=>9970,'crop'=>5315,'pop'=>3,'cp'=>106,'attri'=>54,'time'=>46440),array('wood'=>15315,'clay'=>11060,'iron'=>12760,'crop'=>6805,'pop'=>3,'cp'=>128,'attri'=>57,'time'=>54170),array('wood'=>19600,'clay'=>14155,'iron'=>16335,'crop'=>8710,'pop'=>3,'cp'=>153,'attri'=>60,'time'=>63130));
+$bid19=array(1=>array('wood'=>210,'clay'=>140,'iron'=>260,'crop'=>120,'pop'=>4,'cp'=>1,'attri'=>100,'time'=>2000),array('wood'=>270,'clay'=>180,'iron'=>335,'crop'=>155,'pop'=>2,'cp'=>1,'attri'=>90,'time'=>2620),array('wood'=>345,'clay'=>230,'iron'=>425,'crop'=>195,'pop'=>2,'cp'=>2,'attri'=>81,'time'=>3340),array('wood'=>440,'clay'=>295,'iron'=>545,'crop'=>250,'pop'=>2,'cp'=>2,'attri'=>72.9,'time'=>4170),array('wood'=>565,'clay'=>375,'iron'=>700,'crop'=>320,'pop'=>2,'cp'=>2,'attri'=>66,'time'=>5140),array('wood'=>720,'clay'=>480,'iron'=>895,'crop'=>410,'pop'=>3,'cp'=>3,'attri'=>59,'time'=>6260),array('wood'=>925,'clay'=>615,'iron'=>1145,'crop'=>530,'pop'=>3,'cp'=>4,'attri'=>53,'time'=>7570),array('wood'=>1180,'clay'=>790,'iron'=>1465,'crop'=>675,'pop'=>3,'cp'=>4,'attri'=>48,'time'=>9080),array('wood'=>1515,'clay'=>1010,'iron'=>1875,'crop'=>865,'pop'=>3,'cp'=>5,'attri'=>43,'time'=>10830),array('wood'=>1935,'clay'=>1290,'iron'=>2400,'crop'=>1105,'pop'=>3,'cp'=>6,'attri'=>39,'time'=>12860),array('wood'=>2480,'clay'=>1655,'iron'=>3070,'crop'=>1415,'pop'=>3,'cp'=>7,'attri'=>35,'time'=>15220),array('wood'=>3175,'clay'=>2115,'iron'=>3930,'crop'=>1815,'pop'=>3,'cp'=>9,'attri'=>31,'time'=>17950),array('wood'=>4060,'clay'=>2710,'iron'=>5030,'crop'=>2320,'pop'=>3,'cp'=>11,'attri'=>28,'time'=>21130),array('wood'=>5200,'clay'=>3465,'iron'=>6435,'crop'=>2970,'pop'=>3,'cp'=>13,'attri'=>25,'time'=>24810),array('wood'=>6655,'clay'=>4435,'iron'=>8240,'crop'=>3805,'pop'=>3,'cp'=>15,'attri'=>23,'time'=>29080),array('wood'=>8520,'clay'=>5680,'iron'=>10545,'crop'=>4870,'pop'=>4,'cp'=>18,'attri'=>21,'time'=>34030),array('wood'=>10905,'clay'=>7270,'iron'=>13500,'crop'=>6230,'pop'=>4,'cp'=>22,'attri'=>19,'time'=>39770),array('wood'=>13955,'clay'=>9305,'iron'=>17280,'crop'=>7975,'pop'=>4,'cp'=>27,'attri'=>17,'time'=>46440),array('wood'=>17865,'clay'=>11910,'iron'=>22120,'crop'=>10210,'pop'=>4,'cp'=>32,'attri'=>15,'time'=>54170),array('wood'=>22865,'clay'=>15245,'iron'=>28310,'crop'=>13065,'pop'=>4,'cp'=>38,'attri'=>14,'time'=>63130));
+$bid20=array(1=>array('wood'=>260,'clay'=>140,'iron'=>220,'crop'=>100,'pop'=>5,'cp'=>2,'attri'=>100,'time'=>2200),array('wood'=>335,'clay'=>180,'iron'=>280,'crop'=>130,'pop'=>3,'cp'=>3,'attri'=>90,'time'=>2850),array('wood'=>425,'clay'=>230,'iron'=>360,'crop'=>165,'pop'=>3,'cp'=>3,'attri'=>81,'time'=>3610),array('wood'=>545,'clay'=>295,'iron'=>460,'crop'=>210,'pop'=>3,'cp'=>4,'attri'=>73,'time'=>4490),array('wood'=>700,'clay'=>375,'iron'=>590,'crop'=>270,'pop'=>3,'cp'=>5,'attri'=>66,'time'=>5500),array('wood'=>895,'clay'=>480,'iron'=>755,'crop'=>345,'pop'=>3,'cp'=>6,'attri'=>59,'time'=>6680),array('wood'=>1145,'clay'=>615,'iron'=>970,'crop'=>440,'pop'=>3,'cp'=>7,'attri'=>53,'time'=>8050),array('wood'=>1465,'clay'=>790,'iron'=>1240,'crop'=>565,'pop'=>3,'cp'=>9,'attri'=>48,'time'=>9640),array('wood'=>1875,'clay'=>1010,'iron'=>1585,'crop'=>720,'pop'=>3,'cp'=>10,'attri'=>43,'time'=>11480),array('wood'=>2400,'clay'=>1290,'iron'=>2030,'crop'=>920,'pop'=>3,'cp'=>12,'attri'=>39,'time'=>13620),array('wood'=>3070,'clay'=>1655,'iron'=>2595,'crop'=>1180,'pop'=>4,'cp'=>15,'attri'=>35,'time'=>16100),array('wood'=>3930,'clay'=>2115,'iron'=>3325,'crop'=>1510,'pop'=>4,'cp'=>18,'attri'=>31,'time'=>18980),array('wood'=>5030,'clay'=>2710,'iron'=>4255,'crop'=>1935,'pop'=>4,'cp'=>21,'attri'=>28,'time'=>22310),array('wood'=>6435,'clay'=>3465,'iron'=>5445,'crop'=>2475,'pop'=>4,'cp'=>26,'attri'=>25,'time'=>26180),array('wood'=>8240,'clay'=>4435,'iron'=>6970,'crop'=>3170,'pop'=>4,'cp'=>31,'attri'=>23,'time'=>30670),array('wood'=>10545,'clay'=>5680,'iron'=>8925,'crop'=>4055,'pop'=>4,'cp'=>37,'attri'=>21,'time'=>35880),array('wood'=>13500,'clay'=>7270,'iron'=>11425,'crop'=>5190,'pop'=>4,'cp'=>44,'attri'=>19,'time'=>41920),array('wood'=>17280,'clay'=>9305,'iron'=>14620,'crop'=>6645,'pop'=>4,'cp'=>53,'attri'=>17,'time'=>48930),array('wood'=>22120,'clay'=>11910,'iron'=>18715,'crop'=>8505,'pop'=>4,'cp'=>64,'attri'=>15,'time'=>57060),array('wood'=>28310,'clay'=>15245,'iron'=>23955,'crop'=>10890,'pop'=>4,'cp'=>77,'attri'=>14,'time'=>66490));
+$bid21=array(1=>array('wood'=>460,'clay'=>510,'iron'=>600,'crop'=>320,'pop'=>3,'cp'=>4,'attri'=>100,'time'=>3000),array('wood'=>590,'clay'=>655,'iron'=>770,'crop'=>410,'pop'=>2,'cp'=>4,'attri'=>90,'time'=>3780),array('wood'=>755,'clay'=>835,'iron'=>985,'crop'=>525,'pop'=>2,'cp'=>5,'attri'=>81,'time'=>4680),array('wood'=>965,'clay'=>1070,'iron'=>1260,'crop'=>670,'pop'=>2,'cp'=>6,'attri'=>73,'time'=>5730),array('wood'=>1235,'clay'=>1370,'iron'=>1610,'crop'=>860,'pop'=>2,'cp'=>7,'attri'=>66,'time'=>6950),array('wood'=>1580,'clay'=>1750,'iron'=>2060,'crop'=>1100,'pop'=>2,'cp'=>9,'attri'=>59,'time'=>8360),array('wood'=>2025,'clay'=>2245,'iron'=>2640,'crop'=>1405,'pop'=>2,'cp'=>11,'attri'=>53,'time'=>10000),array('wood'=>2590,'clay'=>2870,'iron'=>3380,'crop'=>1800,'pop'=>2,'cp'=>13,'attri'=>48,'time'=>11900),array('wood'=>3315,'clay'=>3675,'iron'=>4325,'crop'=>2305,'pop'=>2,'cp'=>15,'attri'=>43,'time'=>14110),array('wood'=>4245,'clay'=>4705,'iron'=>5535,'crop'=>2950,'pop'=>2,'cp'=>19,'attri'=>39,'time'=>16660),array('wood'=>5430,'clay'=>6020,'iron'=>7085,'crop'=>3780,'pop'=>3,'cp'=>22,'attri'=>35,'time'=>19630),array('wood'=>6950,'clay'=>7705,'iron'=>9065,'crop'=>4835,'pop'=>3,'cp'=>27,'attri'=>31,'time'=>23070),array('wood'=>8900,'clay'=>9865,'iron'=>11605,'crop'=>6190,'pop'=>3,'cp'=>32,'attri'=>28,'time'=>27060),array('wood'=>11390,'clay'=>12625,'iron'=>14855,'crop'=>7925,'pop'=>3,'cp'=>39,'attri'=>25,'time'=>31690),array('wood'=>14580,'clay'=>16165,'iron'=>19015,'crop'=>10140,'pop'=>3,'cp'=>46,'attri'=>23,'time'=>37060),array('wood'=>18660,'clay'=>20690,'iron'=>24340,'crop'=>12980,'pop'=>3,'cp'=>55,'attri'=>21,'time'=>43290),array('wood'=>23885,'clay'=>26480,'iron'=>31155,'crop'=>16615,'pop'=>3,'cp'=>67,'attri'=>19,'time'=>50520),array('wood'=>30570,'clay'=>33895,'iron'=>39875,'crop'=>21270,'pop'=>3,'cp'=>80,'attri'=>17,'time'=>58900),array('wood'=>39130,'clay'=>43385,'iron'=>51040,'crop'=>27225,'pop'=>3,'cp'=>96,'attri'=>15,'time'=>68630),array('wood'=>50090,'clay'=>55535,'iron'=>65335,'crop'=>34845,'pop'=>3,'cp'=>115,'attri'=>14,'time'=>79910));
+$bid22=array(1=>array('wood'=>220,'clay'=>160,'iron'=>90,'crop'=>40,'pop'=>4,'cp'=>5,'attri'=>0,'time'=>2000),array('wood'=>280,'clay'=>205,'iron'=>115,'crop'=>50,'pop'=>2,'cp'=>6,'attri'=>0,'time'=>2620),array('wood'=>360,'clay'=>260,'iron'=>145,'crop'=>65,'pop'=>2,'cp'=>7,'attri'=>0,'time'=>3340),array('wood'=>460,'clay'=>335,'iron'=>190,'crop'=>85,'pop'=>2,'cp'=>8,'attri'=>0,'time'=>4170),array('wood'=>590,'clay'=>430,'iron'=>240,'crop'=>105,'pop'=>2,'cp'=>10,'attri'=>0,'time'=>5140),array('wood'=>755,'clay'=>550,'iron'=>310,'crop'=>135,'pop'=>3,'cp'=>12,'attri'=>0,'time'=>6260),array('wood'=>970,'clay'=>705,'iron'=>395,'crop'=>175,'pop'=>3,'cp'=>14,'attri'=>0,'time'=>7570),array('wood'=>1240,'clay'=>900,'iron'=>505,'crop'=>225,'pop'=>3,'cp'=>17,'attri'=>0,'time'=>9080),array('wood'=>1585,'clay'=>1155,'iron'=>650,'crop'=>290,'pop'=>3,'cp'=>21,'attri'=>0,'time'=>10830),array('wood'=>2030,'clay'=>1475,'iron'=>830,'crop'=>370,'pop'=>3,'cp'=>25,'attri'=>0,'time'=>12860),array('wood'=>2595,'clay'=>1890,'iron'=>1065,'crop'=>470,'pop'=>3,'cp'=>30,'attri'=>0,'time'=>15220),array('wood'=>3325,'clay'=>2420,'iron'=>1360,'crop'=>605,'pop'=>3,'cp'=>36,'attri'=>0,'time'=>17950),array('wood'=>4255,'clay'=>3095,'iron'=>1740,'crop'=>775,'pop'=>3,'cp'=>43,'attri'=>0,'time'=>21130),array('wood'=>5445,'clay'=>3960,'iron'=>2230,'crop'=>990,'pop'=>3,'cp'=>51,'attri'=>0,'time'=>24810),array('wood'=>6970,'clay'=>5070,'iron'=>2850,'crop'=>1270,'pop'=>3,'cp'=>62,'attri'=>0,'time'=>29080),array('wood'=>8925,'clay'=>6490,'iron'=>3650,'crop'=>1625,'pop'=>4,'cp'=>74,'attri'=>0,'time'=>34030),array('wood'=>11425,'clay'=>8310,'iron'=>4675,'crop'=>2075,'pop'=>4,'cp'=>89,'attri'=>0,'time'=>39770),array('wood'=>14620,'clay'=>10635,'iron'=>5980,'crop'=>2660,'pop'=>4,'cp'=>106,'attri'=>0,'time'=>46440),array('wood'=>18715,'clay'=>13610,'iron'=>7655,'crop'=>3405,'pop'=>4,'cp'=>128,'attri'=>0,'time'=>54170),array('wood'=>23955,'clay'=>17420,'iron'=>9800,'crop'=>4355,'pop'=>4,'cp'=>153,'attri'=>0,'time'=>63130));
+$bid23=array(1=>array('wood'=>40,'clay'=>50,'iron'=>30,'crop'=>10,'pop'=>0,'cp'=>1,'attri'=>100,'time'=>750),array('wood'=>50,'clay'=>65,'iron'=>40,'crop'=>15,'pop'=>0,'cp'=>1,'attri'=>130,'time'=>1170),array('wood'=>65,'clay'=>80,'iron'=>50,'crop'=>15,'pop'=>0,'cp'=>2,'attri'=>170,'time'=>1660),array('wood'=>85,'clay'=>105,'iron'=>65,'crop'=>20,'pop'=>0,'cp'=>2,'attri'=>220,'time'=>2220),array('wood'=>105,'clay'=>135,'iron'=>80,'crop'=>25,'pop'=>0,'cp'=>2,'attri'=>280,'time'=>2880),array('wood'=>135,'clay'=>170,'iron'=>105,'crop'=>35,'pop'=>1,'cp'=>3,'attri'=>360,'time'=>3640),array('wood'=>175,'clay'=>220,'iron'=>130,'crop'=>45,'pop'=>1,'cp'=>4,'attri'=>460,'time'=>4520),array('wood'=>225,'clay'=>280,'iron'=>170,'crop'=>55,'pop'=>1,'cp'=>4,'attri'=>600,'time'=>5540),array('wood'=>290,'clay'=>360,'iron'=>215,'crop'=>70,'pop'=>1,'cp'=>5,'attri'=>770,'time'=>6730),array('wood'=>370,'clay'=>460,'iron'=>275,'crop'=>90,'pop'=>1,'cp'=>6,'attri'=>1000,'time'=>8110));
+$bid24=array(1=>array('wood'=>1250,'clay'=>1110,'iron'=>1260,'crop'=>600,'pop'=>4,'cp'=>6,'attri'=>0,'time'=>12500),array('wood'=>1600,'clay'=>1420,'iron'=>1615,'crop'=>770,'pop'=>2,'cp'=>7,'attri'=>0,'time'=>14800),array('wood'=>2050,'clay'=>1820,'iron'=>2065,'crop'=>985,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>17470),array('wood'=>2620,'clay'=>2330,'iron'=>2640,'crop'=>1260,'pop'=>2,'cp'=>10,'attri'=>0,'time'=>20560),array('wood'=>3355,'clay'=>2980,'iron'=>3380,'crop'=>1610,'pop'=>2,'cp'=>12,'attri'=>0,'time'=>24150),array('wood'=>4295,'clay'=>3815,'iron'=>4330,'crop'=>2060,'pop'=>3,'cp'=>15,'attri'=>0,'time'=>28320),array('wood'=>5500,'clay'=>4880,'iron'=>5540,'crop'=>2640,'pop'=>3,'cp'=>18,'attri'=>0,'time'=>33150),array('wood'=>7035,'clay'=>6250,'iron'=>7095,'crop'=>3380,'pop'=>3,'cp'=>21,'attri'=>0,'time'=>38750),array('wood'=>9005,'clay'=>8000,'iron'=>9080,'crop'=>4325,'pop'=>3,'cp'=>26,'attri'=>0,'time'=>45250),array('wood'=>11530,'clay'=>10240,'iron'=>11620,'crop'=>5535,'pop'=>3,'cp'=>31,'attri'=>0,'time'=>52790),array('wood'=>14755,'clay'=>13105,'iron'=>14875,'crop'=>7085,'pop'=>3,'cp'=>37,'attri'=>0,'time'=>61540),array('wood'=>18890,'clay'=>16775,'iron'=>19040,'crop'=>9065,'pop'=>3,'cp'=>45,'attri'=>0,'time'=>71690),array('wood'=>24180,'clay'=>21470,'iron'=>24370,'crop'=>11605,'pop'=>3,'cp'=>53,'attri'=>0,'time'=>83460),array('wood'=>30950,'clay'=>27480,'iron'=>31195,'crop'=>14855,'pop'=>3,'cp'=>64,'attri'=>0,'time'=>97110),array('wood'=>39615,'clay'=>35175,'iron'=>39930,'crop'=>19015,'pop'=>3,'cp'=>77,'attri'=>0,'time'=>112950),array('wood'=>50705,'clay'=>45025,'iron'=>51110,'crop'=>24340,'pop'=>4,'cp'=>92,'attri'=>0,'time'=>131320),array('wood'=>64905,'clay'=>57635,'iron'=>65425,'crop'=>31155,'pop'=>4,'cp'=>111,'attri'=>0,'time'=>152630),array('wood'=>83075,'clay'=>73770,'iron'=>83740,'crop'=>39875,'pop'=>4,'cp'=>133,'attri'=>0,'time'=>177350),array('wood'=>106340,'clay'=>94430,'iron'=>107190,'crop'=>51040,'pop'=>4,'cp'=>160,'attri'=>0,'time'=>206020),array('wood'=>136115,'clay'=>120870,'iron'=>137200,'crop'=>65335,'pop'=>4,'cp'=>192,'attri'=>0,'time'=>239290));
+$bid25=array(1=>array('wood'=>580,'clay'=>460,'iron'=>350,'crop'=>180,'pop'=>1,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>740,'clay'=>590,'iron'=>450,'crop'=>230,'pop'=>1,'cp'=>3,'attri'=>90,'time'=>2620),array('wood'=>950,'clay'=>755,'iron'=>575,'crop'=>295,'pop'=>1,'cp'=>3,'attri'=>81,'time'=>3340),array('wood'=>1215,'clay'=>965,'iron'=>735,'crop'=>375,'pop'=>1,'cp'=>4,'attri'=>73,'time'=>4170),array('wood'=>1555,'clay'=>1235,'iron'=>940,'crop'=>485,'pop'=>1,'cp'=>5,'attri'=>66,'time'=>5140),array('wood'=>1995,'clay'=>1580,'iron'=>1205,'crop'=>620,'pop'=>1,'cp'=>6,'attri'=>59,'time'=>6260),array('wood'=>2550,'clay'=>2025,'iron'=>1540,'crop'=>790,'pop'=>1,'cp'=>7,'attri'=>53,'time'=>7570),array('wood'=>3265,'clay'=>2590,'iron'=>1970,'crop'=>1015,'pop'=>1,'cp'=>9,'attri'=>48,'time'=>9080),array('wood'=>4180,'clay'=>3315,'iron'=>2520,'crop'=>1295,'pop'=>1,'cp'=>10,'attri'=>43,'time'=>10830),array('wood'=>5350,'clay'=>4245,'iron'=>3230,'crop'=>1660,'pop'=>1,'cp'=>12,'attri'=>39,'time'=>12860),array('wood'=>6845,'clay'=>5430,'iron'=>4130,'crop'=>2125,'pop'=>2,'cp'=>15,'attri'=>35,'time'=>15220),array('wood'=>8765,'clay'=>6950,'iron'=>5290,'crop'=>2720,'pop'=>2,'cp'=>18,'attri'=>31,'time'=>17950),array('wood'=>11220,'clay'=>8900,'iron'=>6770,'crop'=>3480,'pop'=>2,'cp'=>21,'attri'=>28,'time'=>21130),array('wood'=>14360,'clay'=>11390,'iron'=>8665,'crop'=>4455,'pop'=>2,'cp'=>26,'attri'=>25,'time'=>24810),array('wood'=>18380,'clay'=>14580,'iron'=>11090,'crop'=>5705,'pop'=>2,'cp'=>31,'attri'=>23,'time'=>29080),array('wood'=>23530,'clay'=>18660,'iron'=>14200,'crop'=>7300,'pop'=>2,'cp'=>37,'attri'=>21,'time'=>34030),array('wood'=>30115,'clay'=>23885,'iron'=>18175,'crop'=>9345,'pop'=>2,'cp'=>44,'attri'=>19,'time'=>39770),array('wood'=>38550,'clay'=>30570,'iron'=>23260,'crop'=>11965,'pop'=>2,'cp'=>53,'attri'=>17,'time'=>46440),array('wood'=>49340,'clay'=>39130,'iron'=>29775,'crop'=>15315,'pop'=>2,'cp'=>64,'attri'=>15,'time'=>54170),array('wood'=>63155,'clay'=>50090,'iron'=>38110,'crop'=>19600,'pop'=>2,'cp'=>77,'attri'=>14,'time'=>63130));
+$bid26=array(1=>array('wood'=>550,'clay'=>800,'iron'=>750,'crop'=>250,'pop'=>1,'cp'=>6,'attri'=>100,'time'=>5000),array('wood'=>705,'clay'=>1025,'iron'=>960,'crop'=>320,'pop'=>1,'cp'=>7,'attri'=>90,'time'=>6100),array('wood'=>900,'clay'=>1310,'iron'=>1230,'crop'=>410,'pop'=>1,'cp'=>9,'attri'=>81,'time'=>7380),array('wood'=>1155,'clay'=>1680,'iron'=>1575,'crop'=>525,'pop'=>1,'cp'=>10,'attri'=>73,'time'=>8860),array('wood'=>1475,'clay'=>2145,'iron'=>2015,'crop'=>670,'pop'=>1,'cp'=>12,'attri'=>66,'time'=>10570),array('wood'=>1890,'clay'=>2750,'iron'=>2575,'crop'=>860,'pop'=>1,'cp'=>15,'attri'=>59,'time'=>12560),array('wood'=>2420,'clay'=>3520,'iron'=>3300,'crop'=>1100,'pop'=>1,'cp'=>18,'attri'=>53,'time'=>14880),array('wood'=>3095,'clay'=>4505,'iron'=>4220,'crop'=>1405,'pop'=>1,'cp'=>21,'attri'=>48,'time'=>17560),array('wood'=>3965,'clay'=>5765,'iron'=>5405,'crop'=>1800,'pop'=>1,'cp'=>26,'attri'=>43,'time'=>20660),array('wood'=>5075,'clay'=>7380,'iron'=>6920,'crop'=>2305,'pop'=>1,'cp'=>31,'attri'=>39,'time'=>24270),array('wood'=>6495,'clay'=>9445,'iron'=>8855,'crop'=>2950,'pop'=>2,'cp'=>37,'attri'=>35,'time'=>28450),array('wood'=>8310,'clay'=>12090,'iron'=>11335,'crop'=>3780,'pop'=>2,'cp'=>45,'attri'=>31,'time'=>33310),array('wood'=>10640,'clay'=>15475,'iron'=>14505,'crop'=>4835,'pop'=>2,'cp'=>53,'attri'=>28,'time'=>38940),array('wood'=>13615,'clay'=>19805,'iron'=>18570,'crop'=>6190,'pop'=>2,'cp'=>64,'attri'=>25,'time'=>45460),array('wood'=>17430,'clay'=>25355,'iron'=>23770,'crop'=>7925,'pop'=>2,'cp'=>77,'attri'=>23,'time'=>53040),array('wood'=>22310,'clay'=>32450,'iron'=>30425,'crop'=>10140,'pop'=>2,'cp'=>92,'attri'=>21,'time'=>61830),array('wood'=>28560,'clay'=>41540,'iron'=>38940,'crop'=>12980,'pop'=>2,'cp'=>111,'attri'=>19,'time'=>72020),array('wood'=>36555,'clay'=>53170,'iron'=>49845,'crop'=>16615,'pop'=>2,'cp'=>133,'attri'=>17,'time'=>83840),array('wood'=>46790,'clay'=>68055,'iron'=>63805,'crop'=>21270,'pop'=>2,'cp'=>160,'attri'=>15,'time'=>97550),array('wood'=>59890,'clay'=>87110,'iron'=>81670,'crop'=>27225,'pop'=>2,'cp'=>192,'attri'=>14,'time'=>113460));
+$bid27=array(1=>array('wood'=>2880,'clay'=>2740,'iron'=>2580,'crop'=>990,'pop'=>4,'cp'=>7,'attri'=>0,'time'=>8000),array('wood'=>3630,'clay'=>3450,'iron'=>3250,'crop'=>1245,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>9580),array('wood'=>4570,'clay'=>4350,'iron'=>4095,'crop'=>1570,'pop'=>2,'cp'=>10,'attri'=>0,'time'=>11410),array('wood'=>5760,'clay'=>5480,'iron'=>5160,'crop'=>1980,'pop'=>2,'cp'=>12,'attri'=>0,'time'=>13540),array('wood'=>7260,'clay'=>6905,'iron'=>6505,'crop'=>2495,'pop'=>2,'cp'=>15,'attri'=>0,'time'=>16010),array('wood'=>9145,'clay'=>8700,'iron'=>8195,'crop'=>3145,'pop'=>3,'cp'=>18,'attri'=>0,'time'=>18870),array('wood'=>11525,'clay'=>10965,'iron'=>10325,'crop'=>3960,'pop'=>3,'cp'=>21,'attri'=>0,'time'=>22180),array('wood'=>14520,'clay'=>13815,'iron'=>13010,'crop'=>4990,'pop'=>3,'cp'=>26,'attri'=>0,'time'=>26030),array('wood'=>18295,'clay'=>17405,'iron'=>16390,'crop'=>6290,'pop'=>3,'cp'=>31,'attri'=>0,'time'=>30500),array('wood'=>23055,'clay'=>21930,'iron'=>20650,'crop'=>7925,'pop'=>3,'cp'=>37,'attri'=>1,'time'=>35680),array('wood'=>9045,'clay'=>27635,'iron'=>26020,'crop'=>9985,'pop'=>3,'cp'=>45,'attri'=>1,'time'=>41690),array('wood'=>6600,'clay'=>34820,'iron'=>32785,'crop'=>12580,'pop'=>3,'cp'=>53,'attri'=>1,'time'=>48660),array('wood'=>46115,'clay'=>43875,'iron'=>41310,'crop'=>15850,'pop'=>3,'cp'=>64,'attri'=>1,'time'=>56740),array('wood'=>58105,'clay'=>55280,'iron'=>52050,'crop'=>19975,'pop'=>3,'cp'=>77,'attri'=>1,'time'=>66120),array('wood'=>73210,'clay'=>69655,'iron'=>65585,'crop'=>25165,'pop'=>3,'cp'=>92,'attri'=>1,'time'=>77000),array('wood'=>92245,'clay'=>87760,'iron'=>82640,'crop'=>31710,'pop'=>4,'cp'=>111,'attri'=>1,'time'=>89620),array('wood'=>116230,'clay'=>110580,'iron'=>104125,'crop'=>39955,'pop'=>4,'cp'=>133,'attri'=>1,'time'=>104260),array('wood'=>146450,'clay'=>139330,'iron'=>131195,'crop'=>50340,'pop'=>4,'cp'=>160,'attri'=>1,'time'=>121240),array('wood'=>184530,'clay'=>175560,'iron'=>165305,'crop'=>63430,'pop'=>4,'cp'=>192,'attri'=>1,'time'=>140940),array('wood'=>232505,'clay'=>221205,'iron'=>208285,'crop'=>79925,'pop'=>4,'cp'=>230,'attri'=>1,'time'=>163790));
+$bid28=array(1=>array('wood'=>1400,'clay'=>1330,'iron'=>1200,'crop'=>400,'pop'=>3,'cp'=>4,'attri'=>110,'time'=>3000),array('wood'=>1790,'clay'=>1700,'iron'=>1535,'crop'=>510,'pop'=>2,'cp'=>4,'attri'=>120,'time'=>3780),array('wood'=>2295,'clay'=>2180,'iron'=>1965,'crop'=>655,'pop'=>2,'cp'=>5,'attri'=>130,'time'=>4680),array('wood'=>2935,'clay'=>2790,'iron'=>2515,'crop'=>840,'pop'=>2,'cp'=>6,'attri'=>140,'time'=>5730),array('wood'=>3760,'clay'=>3570,'iron'=>3220,'crop'=>1075,'pop'=>2,'cp'=>7,'attri'=>150,'time'=>6950),array('wood'=>4810,'clay'=>4570,'iron'=>4125,'crop'=>1375,'pop'=>2,'cp'=>9,'attri'=>160,'time'=>8360),array('wood'=>6155,'clay'=>5850,'iron'=>5280,'crop'=>1760,'pop'=>2,'cp'=>11,'attri'=>170,'time'=>10000),array('wood'=>7880,'clay'=>7485,'iron'=>6755,'crop'=>2250,'pop'=>2,'cp'=>13,'attri'=>180,'time'=>11900),array('wood'=>10090,'clay'=>9585,'iron'=>8645,'crop'=>2880,'pop'=>2,'cp'=>15,'attri'=>190,'time'=>14110),array('wood'=>12915,'clay'=>12265,'iron'=>11070,'crop'=>3690,'pop'=>2,'cp'=>19,'attri'=>200,'time'=>16660),array('wood'=>16530,'clay'=>15700,'iron'=>14165,'crop'=>4720,'pop'=>3,'cp'=>22,'attri'=>210,'time'=>19630),array('wood'=>21155,'clay'=>20100,'iron'=>18135,'crop'=>6045,'pop'=>3,'cp'=>27,'attri'=>220,'time'=>23070),array('wood'=>27080,'clay'=>25725,'iron'=>23210,'crop'=>7735,'pop'=>3,'cp'=>32,'attri'=>230,'time'=>27060),array('wood'=>4660,'clay'=>32930,'iron'=>29710,'crop'=>9905,'pop'=>3,'cp'=>39,'attri'=>240,'time'=>31690),array('wood'=>44370,'clay'=>42150,'iron'=>38030,'crop'=>12675,'pop'=>3,'cp'=>46,'attri'=>250,'time'=>37060),array('wood'=>56790,'clay'=>53950,'iron'=>48680,'crop'=>16225,'pop'=>3,'cp'=>55,'attri'=>260,'time'=>43290),array('wood'=>72690,'clay'=>69060,'iron'=>62310,'crop'=>20770,'pop'=>3,'cp'=>67,'attri'=>270,'time'=>50520),array('wood'=>93045,'clay'=>88395,'iron'=>79755,'crop'=>26585,'pop'=>3,'cp'=>80,'attri'=>280,'time'=>58900),array('wood'=>119100,'clay'=>113145,'iron'=>102085,'crop'=>34030,'pop'=>3,'cp'=>96,'attri'=>290,'time'=>68630),array('wood'=>152445,'clay'=>144825,'iron'=>130670,'crop'=>43555,'pop'=>3,'cp'=>115,'attri'=>300,'time'=>79910));
+$bid29=array(1=>array('wood'=>630,'clay'=>420,'iron'=>780,'crop'=>360,'pop'=>4,'cp'=>1,'attri'=>100,'time'=>2000),array('wood'=>805,'clay'=>540,'iron'=>1000,'crop'=>460,'pop'=>2,'cp'=>1,'attri'=>90,'time'=>2620),array('wood'=>1030,'clay'=>690,'iron'=>1280,'crop'=>590,'pop'=>2,'cp'=>2,'attri'=>81,'time'=>3340),array('wood'=>1320,'clay'=>880,'iron'=>1635,'crop'=>755,'pop'=>2,'cp'=>2,'attri'=>73,'time'=>4170),array('wood'=>1690,'clay'=>1125,'iron'=>2095,'crop'=>965,'pop'=>2,'cp'=>2,'attri'=>66,'time'=>5140),array('wood'=>2165,'clay'=>1445,'iron'=>2680,'crop'=>1235,'pop'=>3,'cp'=>3,'attri'=>59,'time'=>6260),array('wood'=>2770,'clay'=>1845,'iron'=>3430,'crop'=>1585,'pop'=>3,'cp'=>4,'attri'=>53,'time'=>7570),array('wood'=>3545,'clay'=>2365,'iron'=>4390,'crop'=>2025,'pop'=>3,'cp'=>4,'attri'=>48,'time'=>9080),array('wood'=>4540,'clay'=>3025,'iron'=>5620,'crop'=>2595,'pop'=>3,'cp'=>5,'attri'=>43,'time'=>10830),array('wood'=>5810,'clay'=>3875,'iron'=>7195,'crop'=>3320,'pop'=>3,'cp'=>6,'attri'=>39,'time'=>12860),array('wood'=>7440,'clay'=>4960,'iron'=>9210,'crop'=>4250,'pop'=>3,'cp'=>7,'attri'=>35,'time'=>15220),array('wood'=>9520,'clay'=>6345,'iron'=>11785,'crop'=>5440,'pop'=>3,'cp'=>9,'attri'=>31,'time'=>17950),array('wood'=>12185,'clay'=>8125,'iron'=>15085,'crop'=>6965,'pop'=>3,'cp'=>11,'attri'=>28,'time'=>21130),array('wood'=>15600,'clay'=>10400,'iron'=>19310,'crop'=>8915,'pop'=>3,'cp'=>13,'attri'=>25,'time'=>24810),array('wood'=>19965,'clay'=>13310,'iron'=>24720,'crop'=>11410,'pop'=>3,'cp'=>15,'attri'=>23,'time'=>29080),array('wood'=>25555,'clay'=>17035,'iron'=>31640,'crop'=>14605,'pop'=>4,'cp'=>18,'attri'=>21,'time'=>34030),array('wood'=>32710,'clay'=>21810,'iron'=>40500,'crop'=>18690,'pop'=>4,'cp'=>22,'attri'=>19,'time'=>39770),array('wood'=>41870,'clay'=>27915,'iron'=>51840,'crop'=>23925,'pop'=>4,'cp'=>27,'attri'=>17,'time'=>46440),array('wood'=>53595,'clay'=>35730,'iron'=>66355,'crop'=>30625,'pop'=>4,'cp'=>32,'attri'=>15,'time'=>54170),array('wood'=>68600,'clay'=>45735,'iron'=>84935,'crop'=>39200,'pop'=>4,'cp'=>38,'attri'=>14,'time'=>63130));
+$bid30=array(1=>array('wood'=>780,'clay'=>420,'iron'=>660,'crop'=>300,'pop'=>5,'cp'=>2,'attri'=>100,'time'=>2200),array('wood'=>1000,'clay'=>540,'iron'=>845,'crop'=>385,'pop'=>3,'cp'=>3,'attri'=>90,'time'=>2850),array('wood'=>1280,'clay'=>690,'iron'=>1080,'crop'=>490,'pop'=>3,'cp'=>3,'attri'=>81,'time'=>3610),array('wood'=>1635,'clay'=>880,'iron'=>1385,'crop'=>630,'pop'=>3,'cp'=>4,'attri'=>73,'time'=>4490),array('wood'=>2095,'clay'=>1125,'iron'=>1770,'crop'=>805,'pop'=>3,'cp'=>5,'attri'=>66,'time'=>5500),array('wood'=>2680,'clay'=>1445,'iron'=>2270,'crop'=>1030,'pop'=>3,'cp'=>6,'attri'=>59,'time'=>6680),array('wood'=>3430,'clay'=>1845,'iron'=>2905,'crop'=>1320,'pop'=>3,'cp'=>7,'attri'=>53,'time'=>8050),array('wood'=>4390,'clay'=>2365,'iron'=>3715,'crop'=>1690,'pop'=>3,'cp'=>9,'attri'=>48,'time'=>9640),array('wood'=>5620,'clay'=>3025,'iron'=>4755,'crop'=>2160,'pop'=>3,'cp'=>10,'attri'=>43,'time'=>11480),array('wood'=>7195,'clay'=>3875,'iron'=>6085,'crop'=>2765,'pop'=>3,'cp'=>12,'attri'=>39,'time'=>13620),array('wood'=>9210,'clay'=>4960,'iron'=>7790,'crop'=>3540,'pop'=>4,'cp'=>15,'attri'=>35,'time'=>16100),array('wood'=>11785,'clay'=>6345,'iron'=>9975,'crop'=>4535,'pop'=>4,'cp'=>18,'attri'=>31,'time'=>18980),array('wood'=>15085,'clay'=>8125,'iron'=>12765,'crop'=>5805,'pop'=>4,'cp'=>21,'attri'=>28,'time'=>22310),array('wood'=>19310,'clay'=>10400,'iron'=>16340,'crop'=>7430,'pop'=>4,'cp'=>26,'attri'=>25,'time'=>26180),array('wood'=>24720,'clay'=>13310,'iron'=>20915,'crop'=>9505,'pop'=>4,'cp'=>31,'attri'=>23,'time'=>30670),array('wood'=>31640,'clay'=>17035,'iron'=>26775,'crop'=>12170,'pop'=>4,'cp'=>37,'attri'=>21,'time'=>35880),array('wood'=>40500,'clay'=>21810,'iron'=>34270,'crop'=>15575,'pop'=>4,'cp'=>44,'attri'=>19,'time'=>41920),array('wood'=>51840,'clay'=>27915,'iron'=>43865,'crop'=>19940,'pop'=>4,'cp'=>53,'attri'=>17,'time'=>48930),array('wood'=>66355,'clay'=>35730,'iron'=>56145,'crop'=>25520,'pop'=>4,'cp'=>64,'attri'=>15,'time'=>57060),array('wood'=>84935,'clay'=>45735,'iron'=>71870,'crop'=>32665,'pop'=>4,'cp'=>77,'attri'=>14,'time'=>66490));
+$bid31=array(1=>array('wood'=>70,'clay'=>90,'iron'=>170,'crop'=>70,'pop'=>0,'cp'=>1,'attri'=>3,'time'=>2000),array('wood'=>90,'clay'=>115,'iron'=>220,'crop'=>90,'pop'=>0,'cp'=>1,'attri'=>6,'time'=>2620),array('wood'=>115,'clay'=>145,'iron'=>280,'crop'=>115,'pop'=>0,'cp'=>2,'attri'=>9,'time'=>3340),array('wood'=>145,'clay'=>190,'iron'=>355,'crop'=>145,'pop'=>0,'cp'=>2,'attri'=>13,'time'=>4170),array('wood'=>190,'clay'=>240,'iron'=>455,'crop'=>190,'pop'=>0,'cp'=>2,'attri'=>16,'time'=>5140),array('wood'=>240,'clay'=>310,'iron'=>585,'crop'=>240,'pop'=>1,'cp'=>3,'attri'=>19,'time'=>6260),array('wood'=>310,'clay'=>395,'iron'=>750,'crop'=>310,'pop'=>1,'cp'=>4,'attri'=>23,'time'=>7570),array('wood'=>395,'clay'=>505,'iron'=>955,'crop'=>395,'pop'=>1,'cp'=>4,'attri'=>27,'time'=>9080),array('wood'=>505,'clay'=>650,'iron'=>1225,'crop'=>505,'pop'=>1,'cp'=>5,'attri'=>30,'time'=>10830),array('wood'=>645,'clay'=>830,'iron'=>1570,'crop'=>645,'pop'=>1,'cp'=>6,'attri'=>34,'time'=>12860),array('wood'=>825,'clay'=>1065,'iron'=>2005,'crop'=>825,'pop'=>1,'cp'=>7,'attri'=>38,'time'=>15220),array('wood'=>1060,'clay'=>1360,'iron'=>2570,'crop'=>1060,'pop'=>1,'cp'=>9,'attri'=>43,'time'=>17950),array('wood'=>1355,'clay'=>1740,'iron'=>3290,'crop'=>1355,'pop'=>1,'cp'=>11,'attri'=>47,'time'=>21130),array('wood'=>1735,'clay'=>2230,'iron'=>4210,'crop'=>1735,'pop'=>1,'cp'=>13,'attri'=>51,'time'=>24810),array('wood'=>2220,'clay'=>2850,'iron'=>5390,'crop'=>2220,'pop'=>1,'cp'=>15,'attri'=>56,'time'=>29080),array('wood'=>2840,'clay'=>3650,'iron'=>6895,'crop'=>2840,'pop'=>2,'cp'=>18,'attri'=>60,'time'=>34030),array('wood'=>3635,'clay'=>4675,'iron'=>8825,'crop'=>3635,'pop'=>2,'cp'=>22,'attri'=>65,'time'=>39770),array('wood'=>4650,'clay'=>5980,'iron'=>11300,'crop'=>4650,'pop'=>2,'cp'=>27,'attri'=>70,'time'=>46440),array('wood'=>5955,'clay'=>7655,'iron'=>14460,'crop'=>5955,'pop'=>2,'cp'=>32,'attri'=>75,'time'=>54170),array('wood'=>7620,'clay'=>9800,'iron'=>18510,'crop'=>7620,'pop'=>2,'cp'=>38,'attri'=>81,'time'=>63130));
+$bid32=array(1=>array('wood'=>120,'clay'=>200,'iron'=>0,'crop'=>80,'pop'=>0,'cp'=>1,'attri'=>2,'time'=>2000),array('wood'=>155,'clay'=>255,'iron'=>0,'crop'=>100,'pop'=>0,'cp'=>1,'attri'=>4,'time'=>2620),array('wood'=>195,'clay'=>330,'iron'=>0,'crop'=>130,'pop'=>0,'cp'=>2,'attri'=>6,'time'=>3340),array('wood'=>250,'clay'=>420,'iron'=>0,'crop'=>170,'pop'=>0,'cp'=>2,'attri'=>8,'time'=>4170),array('wood'=>320,'clay'=>535,'iron'=>0,'crop'=>215,'pop'=>0,'cp'=>2,'attri'=>10,'time'=>5140),array('wood'=>410,'clay'=>685,'iron'=>0,'crop'=>275,'pop'=>1,'cp'=>3,'attri'=>13,'time'=>6260),array('wood'=>530,'clay'=>880,'iron'=>0,'crop'=>350,'pop'=>1,'cp'=>4,'attri'=>15,'time'=>7570),array('wood'=>675,'clay'=>1125,'iron'=>0,'crop'=>450,'pop'=>1,'cp'=>4,'attri'=>17,'time'=>9080),array('wood'=>865,'clay'=>1440,'iron'=>0,'crop'=>575,'pop'=>1,'cp'=>5,'attri'=>20,'time'=>10830),array('wood'=>1105,'clay'=>1845,'iron'=>0,'crop'=>740,'pop'=>1,'cp'=>6,'attri'=>22,'time'=>12860),array('wood'=>1415,'clay'=>2360,'iron'=>0,'crop'=>945,'pop'=>1,'cp'=>7,'attri'=>24,'time'=>15220),array('wood'=>1815,'clay'=>3020,'iron'=>0,'crop'=>1210,'pop'=>1,'cp'=>9,'attri'=>27,'time'=>17950),array('wood'=>2320,'clay'=>3870,'iron'=>0,'crop'=>1545,'pop'=>1,'cp'=>11,'attri'=>29,'time'=>21130),array('wood'=>2970,'clay'=>4950,'iron'=>0,'crop'=>1980,'pop'=>1,'cp'=>13,'attri'=>32,'time'=>24810),array('wood'=>3805,'clay'=>6340,'iron'=>0,'crop'=>2535,'pop'=>1,'cp'=>15,'attri'=>35,'time'=>29080),array('wood'=>4870,'clay'=>8115,'iron'=>0,'crop'=>3245,'pop'=>2,'cp'=>18,'attri'=>37,'time'=>34030),array('wood'=>6230,'clay'=>10385,'iron'=>0,'crop'=>4155,'pop'=>2,'cp'=>22,'attri'=>40,'time'=>39770),array('wood'=>7975,'clay'=>13290,'iron'=>0,'crop'=>5315,'pop'=>2,'cp'=>27,'attri'=>43,'time'=>46440),array('wood'=>10210,'clay'=>17015,'iron'=>0,'crop'=>6805,'pop'=>2,'cp'=>32,'attri'=>46,'time'=>54170),array('wood'=>13065,'clay'=>21780,'iron'=>0,'crop'=>8710,'pop'=>2,'cp'=>38,'attri'=>49,'time'=>63130));
+$bid33=array(1=>array('wood'=>160,'clay'=>100,'iron'=>80,'crop'=>60,'pop'=>0,'cp'=>1,'attri'=>2,'time'=>2000),array('wood'=>205,'clay'=>130,'iron'=>100,'crop'=>75,'pop'=>0,'cp'=>1,'attri'=>5,'time'=>2620),array('wood'=>260,'clay'=>165,'iron'=>130,'crop'=>100,'pop'=>0,'cp'=>2,'attri'=>8,'time'=>3340),array('wood'=>335,'clay'=>210,'iron'=>170,'crop'=>125,'pop'=>0,'cp'=>2,'attri'=>10,'time'=>4170),array('wood'=>430,'clay'=>270,'iron'=>215,'crop'=>160,'pop'=>0,'cp'=>2,'attri'=>13,'time'=>5140),array('wood'=>550,'clay'=>345,'iron'=>275,'crop'=>205,'pop'=>1,'cp'=>3,'attri'=>16,'time'=>6260),array('wood'=>705,'clay'=>440,'iron'=>350,'crop'=>265,'pop'=>1,'cp'=>4,'attri'=>19,'time'=>7570),array('wood'=>900,'clay'=>565,'iron'=>450,'crop'=>340,'pop'=>1,'cp'=>4,'attri'=>22,'time'=>9080),array('wood'=>1155,'clay'=>720,'iron'=>575,'crop'=>430,'pop'=>1,'cp'=>5,'attri'=>25,'time'=>10830),array('wood'=>1475,'clay'=>920,'iron'=>740,'crop'=>555,'pop'=>1,'cp'=>6,'attri'=>28,'time'=>12860),array('wood'=>1890,'clay'=>1180,'iron'=>945,'crop'=>710,'pop'=>1,'cp'=>7,'attri'=>31,'time'=>15220),array('wood'=>2420,'clay'=>1510,'iron'=>1210,'crop'=>905,'pop'=>1,'cp'=>9,'attri'=>34,'time'=>17950),array('wood'=>3095,'clay'=>1935,'iron'=>1545,'crop'=>1160,'pop'=>1,'cp'=>11,'attri'=>38,'time'=>21130),array('wood'=>3960,'clay'=>2475,'iron'=>1980,'crop'=>1485,'pop'=>1,'cp'=>13,'attri'=>41,'time'=>24810),array('wood'=>5070,'clay'=>3170,'iron'=>2535,'crop'=>1900,'pop'=>1,'cp'=>15,'attri'=>45,'time'=>29080),array('wood'=>6490,'clay'=>4055,'iron'=>3245,'crop'=>2435,'pop'=>2,'cp'=>18,'attri'=>48,'time'=>34030),array('wood'=>8310,'clay'=>5190,'iron'=>4155,'crop'=>3115,'pop'=>2,'cp'=>22,'attri'=>52,'time'=>39770),array('wood'=>10635,'clay'=>6645,'iron'=>5315,'crop'=>3990,'pop'=>2,'cp'=>27,'attri'=>56,'time'=>46440),array('wood'=>13610,'clay'=>8505,'iron'=>6805,'crop'=>5105,'pop'=>2,'cp'=>32,'attri'=>60,'time'=>54170),array('wood'=>17420,'clay'=>10890,'iron'=>8710,'crop'=>6535,'pop'=>2,'cp'=>38,'attri'=>64,'time'=>63130));
+$bid34=array(1=>array('wood'=>155,'clay'=>130,'iron'=>125,'crop'=>70,'pop'=>2,'cp'=>1,'attri'=>110,'time'=>2200),array('wood'=>200,'clay'=>165,'iron'=>160,'crop'=>90,'pop'=>1,'cp'=>1,'attri'=>120,'time'=>3150),array('wood'=>255,'clay'=>215,'iron'=>205,'crop'=>115,'pop'=>1,'cp'=>2,'attri'=>130,'time'=>4260),array('wood'=>325,'clay'=>275,'iron'=>260,'crop'=>145,'pop'=>1,'cp'=>2,'attri'=>140,'time'=>5540),array('wood'=>415,'clay'=>350,'iron'=>335,'crop'=>190,'pop'=>1,'cp'=>2,'attri'=>150,'time'=>7020),array('wood'=>535,'clay'=>445,'iron'=>430,'crop'=>240,'pop'=>2,'cp'=>3,'attri'=>160,'time'=>8750),array('wood'=>680,'clay'=>570,'iron'=>550,'crop'=>310,'pop'=>2,'cp'=>4,'attri'=>170,'time'=>10750),array('wood'=>875,'clay'=>730,'iron'=>705,'crop'=>395,'pop'=>2,'cp'=>4,'attri'=>180,'time'=>13070),array('wood'=>1115,'clay'=>935,'iron'=>900,'crop'=>505,'pop'=>2,'cp'=>5,'attri'=>190,'time'=>15760),array('wood'=>1430,'clay'=>1200,'iron'=>1155,'crop'=>645,'pop'=>2,'cp'=>6,'attri'=>200,'time'=>18880),array('wood'=>1830,'clay'=>1535,'iron'=>1475,'crop'=>825,'pop'=>2,'cp'=>7,'attri'=>210,'time'=>22500),array('wood'=>2340,'clay'=>1965,'iron'=>1890,'crop'=>1060,'pop'=>2,'cp'=>9,'attri'=>220,'time'=>26700),array('wood'=>3000,'clay'=>2515,'iron'=>2420,'crop'=>1355,'pop'=>2,'cp'=>11,'attri'=>230,'time'=>31570),array('wood'=>3840,'clay'=>3220,'iron'=>3095,'crop'=>1735,'pop'=>2,'cp'=>13,'attri'=>240,'time'=>37220),array('wood'=>4910,'clay'=>4120,'iron'=>3960,'crop'=>2220,'pop'=>2,'cp'=>15,'attri'=>250,'time'=>43780),array('wood'=>6290,'clay'=>5275,'iron'=>5070,'crop'=>2840,'pop'=>3,'cp'=>18,'attri'=>260,'time'=>51380),array('wood'=>8050,'clay'=>6750,'iron'=>6490,'crop'=>3635,'pop'=>3,'cp'=>22,'attri'=>270,'time'=>60200),array('wood'=>10300,'clay'=>8640,'iron'=>8310,'crop'=>4650,'pop'=>3,'cp'=>27,'attri'=>280,'time'=>70430),array('wood'=>13185,'clay'=>11060,'iron'=>10635,'crop'=>5955,'pop'=>3,'cp'=>32,'attri'=>290,'time'=>82300),array('wood'=>16880,'clay'=>14155,'iron'=>13610,'crop'=>7620,'pop'=>3,'cp'=>38,'attri'=>300,'time'=>96070));
+$bid35=array(1=>array('wood'=>1460,'clay'=>930,'iron'=>1250,'crop'=>1740,'pop'=>6,'cp'=>5,'attri'=>0,'time'=>8000),array('wood'=>2045,'clay'=>1300,'iron'=>1750,'crop'=>2435,'pop'=>3,'cp'=>6,'attri'=>0,'time'=>9880),array('wood'=>2860,'clay'=>1825,'iron'=>2450,'crop'=>3410,'pop'=>3,'cp'=>7,'attri'=>0,'time'=>12060),array('wood'=>4005,'clay'=>2550,'iron'=>3430,'crop'=>4775,'pop'=>3,'cp'=>8,'attri'=>0,'time'=>14590),array('wood'=>5610,'clay'=>3575,'iron'=>4800,'crop'=>6685,'pop'=>3,'cp'=>10,'attri'=>0,'time'=>17530),array('wood'=>7850,'clay'=>5000,'iron'=>6725,'crop'=>9360,'pop'=>4,'cp'=>12,'attri'=>0,'time'=>20930),array('wood'=>10995,'clay'=>7000,'iron'=>9410,'crop'=>13100,'pop'=>4,'cp'=>14,'attri'=>0,'time'=>24880),array('wood'=>15390,'clay'=>9805,'iron'=>13175,'crop'=>18340,'pop'=>4,'cp'=>17,'attri'=>0,'time'=>29460),array('wood'=>21545,'clay'=>13725,'iron'=>18445,'crop'=>25680,'pop'=>4,'cp'=>21,'attri'=>0,'time'=>34770),array('wood'=>30165,'clay'=>19215,'iron'=>25825,'crop'=>35950,'pop'=>4,'cp'=>25,'attri'=>0,'time'=>40930));
+$bid36=array(1=>array('wood'=>100,'clay'=>100,'iron'=>100,'crop'=>100,'pop'=>4,'cp'=>1,'attri'=>10,'time'=>2000),array('wood'=>130,'clay'=>130,'iron'=>130,'crop'=>130,'pop'=>2,'cp'=>1,'attri'=>22,'time'=>2320),array('wood'=>165,'clay'=>165,'iron'=>165,'crop'=>165,'pop'=>2,'cp'=>2,'attri'=>35,'time'=>2690),array('wood'=>210,'clay'=>210,'iron'=>210,'crop'=>210,'pop'=>2,'cp'=>2,'attri'=>49,'time'=>3120),array('wood'=>270,'clay'=>270,'iron'=>270,'crop'=>270,'pop'=>2,'cp'=>2,'attri'=>64,'time'=>3620),array('wood'=>345,'clay'=>345,'iron'=>345,'crop'=>345,'pop'=>3,'cp'=>3,'attri'=>80,'time'=>4200),array('wood'=>440,'clay'=>440,'iron'=>440,'crop'=>440,'pop'=>3,'cp'=>4,'attri'=>97,'time'=>4870),array('wood'=>565,'clay'=>565,'iron'=>565,'crop'=>565,'pop'=>3,'cp'=>4,'attri'=>115,'time'=>5650),array('wood'=>720,'clay'=>720,'iron'=>720,'crop'=>720,'pop'=>3,'cp'=>5,'attri'=>134,'time'=>6560),array('wood'=>920,'clay'=>920,'iron'=>920,'crop'=>920,'pop'=>3,'cp'=>6,'attri'=>154,'time'=>7610),array('wood'=>1180,'clay'=>1180,'iron'=>1180,'crop'=>1180,'pop'=>3,'cp'=>7,'attri'=>175,'time'=>8820),array('wood'=>1510,'clay'=>1510,'iron'=>1510,'crop'=>1510,'pop'=>3,'cp'=>9,'attri'=>196,'time'=>10230),array('wood'=>1935,'clay'=>1935,'iron'=>1935,'crop'=>1935,'pop'=>3,'cp'=>11,'attri'=>218,'time'=>11870),array('wood'=>2475,'clay'=>2475,'iron'=>2475,'crop'=>2475,'pop'=>3,'cp'=>13,'attri'=>241,'time'=>13770),array('wood'=>3170,'clay'=>3170,'iron'=>3170,'crop'=>3170,'pop'=>3,'cp'=>15,'attri'=>265,'time'=>15980),array('wood'=>4055,'clay'=>4055,'iron'=>4055,'crop'=>4055,'pop'=>4,'cp'=>18,'attri'=>290,'time'=>18530),array('wood'=>5190,'clay'=>5190,'iron'=>5190,'crop'=>5190,'pop'=>4,'cp'=>22,'attri'=>316,'time'=>21500),array('wood'=>6645,'clay'=>6645,'iron'=>6645,'crop'=>6645,'pop'=>4,'cp'=>27,'attri'=>343,'time'=>24940),array('wood'=>8505,'clay'=>8505,'iron'=>8505,'crop'=>8505,'pop'=>4,'cp'=>32,'attri'=>371,'time'=>28930),array('wood'=>10890,'clay'=>10890,'iron'=>10890,'crop'=>10890,'pop'=>4,'cp'=>38,'attri'=>400,'time'=>33550));
+$bid37=array(1=>array('wood'=>700,'clay'=>670,'iron'=>700,'crop'=>240,'pop'=>2,'cp'=>1,'attri'=>0,'time'=>2300),array('wood'=>930,'clay'=>890,'iron'=>930,'crop'=>320,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>2670),array('wood'=>1240,'clay'=>1185,'iron'=>1240,'crop'=>425,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>3090),array('wood'=>1645,'clay'=>1575,'iron'=>1645,'crop'=>565,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>3590),array('wood'=>2190,'clay'=>2095,'iron'=>2190,'crop'=>750,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>4160),array('wood'=>2915,'clay'=>2790,'iron'=>2915,'crop'=>1000,'pop'=>2,'cp'=>3,'attri'=>0,'time'=>4830),array('wood'=>3875,'clay'=>3710,'iron'=>3875,'crop'=>1330,'pop'=>2,'cp'=>4,'attri'=>0,'time'=>5600),array('wood'=>5155,'clay'=>4930,'iron'=>5155,'crop'=>1765,'pop'=>2,'cp'=>4,'attri'=>0,'time'=>6500),array('wood'=>6855,'clay'=>6560,'iron'=>6855,'crop'=>2350,'pop'=>2,'cp'=>5,'attri'=>0,'time'=>7540),array('wood'=>9115,'clay'=>8725,'iron'=>9115,'crop'=>3125,'pop'=>2,'cp'=>6,'attri'=>1,'time'=>8750),array('wood'=>12125,'clay'=>11605,'iron'=>12125,'crop'=>4155,'pop'=>2,'cp'=>7,'attri'=>1,'time'=>10150),array('wood'=>16125,'clay'=>15435,'iron'=>16125,'crop'=>5530,'pop'=>2,'cp'=>9,'attri'=>1,'time'=>11770),array('wood'=>21445,'clay'=>20525,'iron'=>21445,'crop'=>7350,'pop'=>2,'cp'=>11,'attri'=>1,'time'=>13650),array('wood'=>28520,'clay'=>27300,'iron'=>28520,'crop'=>9780,'pop'=>2,'cp'=>13,'attri'=>1,'time'=>15840),array('wood'=>37935,'clay'=>36310,'iron'=>37935,'crop'=>13005,'pop'=>2,'cp'=>15,'attri'=>2,'time'=>18370),array('wood'=>50450,'clay'=>48290,'iron'=>50450,'crop'=>17300,'pop'=>3,'cp'=>18,'attri'=>2,'time'=>21310),array('wood'=>67100,'clay'=>64225,'iron'=>67100,'crop'=>23005,'pop'=>3,'cp'=>22,'attri'=>2,'time'=>24720),array('wood'=>89245,'clay'=>85420,'iron'=>89245,'crop'=>30600,'pop'=>3,'cp'=>27,'attri'=>2,'time'=>28680),array('wood'=>118695,'clay'=>113605,'iron'=>118695,'crop'=>40695,'pop'=>3,'cp'=>32,'attri'=>2,'time'=>33260),array('wood'=>157865,'clay'=>151095,'iron'=>157865,'crop'=>54125,'pop'=>3,'cp'=>38,'attri'=>3,'time'=>38590));
+$bid38=array(1=>array('wood'=>650,'clay'=>800,'iron'=>450,'crop'=>200,'pop'=>1,'cp'=>1,'attri'=>3600,'time'=>9000),array('wood'=>830,'clay'=>1025,'iron'=>575,'crop'=>255,'pop'=>1,'cp'=>1,'attri'=>5100,'time'=>10740),array('wood'=>1065,'clay'=>1310,'iron'=>735,'crop'=>330,'pop'=>1,'cp'=>2,'attri'=>6900,'time'=>12760),array('wood'=>1365,'clay'=>1680,'iron'=>945,'crop'=>420,'pop'=>1,'cp'=>2,'attri'=>9300,'time'=>15100),array('wood'=>1745,'clay'=>2145,'iron'=>1210,'crop'=>535,'pop'=>1,'cp'=>2,'attri'=>12000,'time'=>17820),array('wood'=>2235,'clay'=>2750,'iron'=>1545,'crop'=>685,'pop'=>1,'cp'=>3,'attri'=>15000,'time'=>20970),array('wood'=>2860,'clay'=>3520,'iron'=>1980,'crop'=>880,'pop'=>1,'cp'=>4,'attri'=>18900,'time'=>24620),array('wood'=>3660,'clay'=>4505,'iron'=>2535,'crop'=>1125,'pop'=>1,'cp'=>4,'attri'=>23400,'time'=>28860),array('wood'=>4685,'clay'=>5765,'iron'=>3245,'crop'=>1440,'pop'=>1,'cp'=>5,'attri'=>28800,'time'=>33780),array('wood'=>5995,'clay'=>7380,'iron'=>4150,'crop'=>1845,'pop'=>1,'cp'=>6,'attri'=>35400,'time'=>39480),array('wood'=>7675,'clay'=>9445,'iron'=>5315,'crop'=>2360,'pop'=>2,'cp'=>7,'attri'=>43200,'time'=>46100),array('wood'=>9825,'clay'=>12090,'iron'=>6800,'crop'=>3020,'pop'=>2,'cp'=>9,'attri'=>52800,'time'=>53780),array('wood'=>12575,'clay'=>15475,'iron'=>8705,'crop'=>3870,'pop'=>2,'cp'=>11,'attri'=>64200,'time'=>62680),array('wood'=>16095,'clay'=>19805,'iron'=>11140,'crop'=>4950,'pop'=>2,'cp'=>13,'attri'=>77700,'time'=>73010),array('wood'=>20600,'clay'=>25355,'iron'=>14260,'crop'=>6340,'pop'=>2,'cp'=>15,'attri'=>93900,'time'=>84990),array('wood'=>26365,'clay'=>32450,'iron'=>18255,'crop'=>8115,'pop'=>2,'cp'=>18,'attri'=>113700,'time'=>98890),array('wood'=>33750,'clay'=>41540,'iron'=>23365,'crop'=>10385,'pop'=>2,'cp'=>22,'attri'=>137100,'time'=>115010),array('wood'=>43200,'clay'=>53170,'iron'=>29910,'crop'=>13290,'pop'=>2,'cp'=>27,'attri'=>165300,'time'=>133710),array('wood'=>55295,'clay'=>68055,'iron'=>38280,'crop'=>17015,'pop'=>2,'cp'=>32,'attri'=>199200,'time'=>155400),array('wood'=>70780,'clay'=>87110,'iron'=>49000,'crop'=>21780,'pop'=>2,'cp'=>38,'attri'=>240000,'time'=>180570));
+$bid39=array(1=>array('wood'=>400,'clay'=>500,'iron'=>350,'crop'=>100,'pop'=>1,'cp'=>1,'attri'=>3600,'time'=>7000),array('wood'=>510,'clay'=>640,'iron'=>450,'crop'=>130,'pop'=>1,'cp'=>1,'attri'=>5100,'time'=>8420),array('wood'=>655,'clay'=>820,'iron'=>575,'crop'=>165,'pop'=>1,'cp'=>2,'attri'=>6900,'time'=>10070),array('wood'=>840,'clay'=>1050,'iron'=>735,'crop'=>210,'pop'=>1,'cp'=>2,'attri'=>9300,'time'=>11980),array('wood'=>1075,'clay'=>1340,'iron'=>940,'crop'=>270,'pop'=>1,'cp'=>2,'attri'=>12000,'time'=>14190),array('wood'=>1375,'clay'=>1720,'iron'=>1205,'crop'=>345,'pop'=>1,'cp'=>3,'attri'=>15000,'time'=>16770),array('wood'=>1760,'clay'=>2200,'iron'=>1540,'crop'=>440,'pop'=>1,'cp'=>4,'attri'=>18900,'time'=>19750),array('wood'=>2250,'clay'=>2815,'iron'=>1970,'crop'=>565,'pop'=>1,'cp'=>4,'attri'=>23400,'time'=>23210),array('wood'=>2880,'clay'=>3605,'iron'=>2520,'crop'=>720,'pop'=>1,'cp'=>5,'attri'=>28800,'time'=>27220),array('wood'=>3690,'clay'=>4610,'iron'=>3230,'crop'=>920,'pop'=>1,'cp'=>6,'attri'=>35400,'time'=>31880),array('wood'=>4720,'clay'=>5905,'iron'=>4130,'crop'=>1180,'pop'=>2,'cp'=>7,'attri'=>43200,'time'=>37280),array('wood'=>6045,'clay'=>7555,'iron'=>5290,'crop'=>1510,'pop'=>2,'cp'=>9,'attri'=>52800,'time'=>43540),array('wood'=>7735,'clay'=>9670,'iron'=>6770,'crop'=>1935,'pop'=>2,'cp'=>11,'attri'=>64200,'time'=>50810),array('wood'=>9905,'clay'=>12380,'iron'=>8665,'crop'=>2475,'pop'=>2,'cp'=>13,'attri'=>77700,'time'=>59240),array('wood'=>12675,'clay'=>15845,'iron'=>11090,'crop'=>3170,'pop'=>2,'cp'=>15,'attri'=>93900,'time'=>69010),array('wood'=>16225,'clay'=>20280,'iron'=>14200,'crop'=>4055,'pop'=>2,'cp'=>18,'attri'=>113700,'time'=>80360),array('wood'=>20770,'clay'=>25960,'iron'=>18175,'crop'=>5190,'pop'=>2,'cp'=>22,'attri'=>137100,'time'=>93510),array('wood'=>26585,'clay'=>33230,'iron'=>23260,'crop'=>6645,'pop'=>2,'cp'=>27,'attri'=>165300,'time'=>108780),array('wood'=>34030,'clay'=>42535,'iron'=>29775,'crop'=>8505,'pop'=>2,'cp'=>32,'attri'=>199200,'time'=>126480),array('wood'=>43555,'clay'=>54445,'iron'=>38110,'crop'=>10890,'pop'=>2,'cp'=>38,'attri'=>240000,'time'=>147020));
+$bid40=array(1=>array('wood'=>66700,'clay'=>69050,'iron'=>72200,'crop'=>13200,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>18000),array('wood'=>68535,'clay'=>70950,'iron'=>74185,'crop'=>13565,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>18850),array('wood'=>70420,'clay'=>72900,'iron'=>76225,'crop'=>13935,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>19720),array('wood'=>72355,'clay'=>74905,'iron'=>78320,'crop'=>14320,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>20590),array('wood'=>74345,'clay'=>76965,'iron'=>80475,'crop'=>14715,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>21480),array('wood'=>76390,'clay'=>79080,'iron'=>82690,'crop'=>15120,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>22380),array('wood'=>78490,'clay'=>81255,'iron'=>84965,'crop'=>15535,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>23290),array('wood'=>80650,'clay'=>83490,'iron'=>87300,'crop'=>15960,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>24220),array('wood'=>82865,'clay'=>85785,'iron'=>89700,'crop'=>16400,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>25160),array('wood'=>85145,'clay'=>88145,'iron'=>92165,'crop'=>16850,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>26110),array('wood'=>87485,'clay'=>90570,'iron'=>94700,'crop'=>17315,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>27080),array('wood'=>89895,'clay'=>93060,'iron'=>97305,'crop'=>17790,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>28060),array('wood'=>92365,'clay'=>95620,'iron'=>99980,'crop'=>18280,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>29050),array('wood'=>94905,'clay'=>98250,'iron'=>102730,'crop'=>18780,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>30060),array('wood'=>97515,'clay'=>100950,'iron'=>105555,'crop'=>19300,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>31080),array('wood'=>100195,'clay'=>103725,'iron'=>108460,'crop'=>19830,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>32110),array('wood'=>102950,'clay'=>106580,'iron'=>111440,'crop'=>20375,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>33160),array('wood'=>105785,'clay'=>109510,'iron'=>114505,'crop'=>20935,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>34230),array('wood'=>108690,'clay'=>112520,'iron'=>117655,'crop'=>21510,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>35300),array('wood'=>111680,'clay'=>115615,'iron'=>120890,'crop'=>22100,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>36400),array('wood'=>114755,'clay'=>118795,'iron'=>124215,'crop'=>22710,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>37510),array('wood'=>117910,'clay'=>122060,'iron'=>127630,'crop'=>23335,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>38630),array('wood'=>121150,'clay'=>125420,'iron'=>131140,'crop'=>23975,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>39770),array('wood'=>124480,'clay'=>128870,'iron'=>134745,'crop'=>24635,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>40930),array('wood'=>127905,'clay'=>132410,'iron'=>138455,'crop'=>25315,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>42100),array('wood'=>131425,'clay'=>136055,'iron'=>142260,'crop'=>26010,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>43290),array('wood'=>135035,'clay'=>139795,'iron'=>146170,'crop'=>26725,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>44500),array('wood'=>138750,'clay'=>143640,'iron'=>150190,'crop'=>27460,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>45720),array('wood'=>142565,'clay'=>147590,'iron'=>154320,'crop'=>28215,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>46960),array('wood'=>146485,'clay'=>151650,'iron'=>158565,'crop'=>28990,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>48220),array('wood'=>150515,'clay'=>155820,'iron'=>162925,'crop'=>29785,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>49500),array('wood'=>154655,'clay'=>160105,'iron'=>167405,'crop'=>30605,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>50790),array('wood'=>158910,'clay'=>164505,'iron'=>172010,'crop'=>31450,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>52100),array('wood'=>163275,'clay'=>169030,'iron'=>176740,'crop'=>32315,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>53430),array('wood'=>167770,'clay'=>173680,'iron'=>181600,'crop'=>33200,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>54780),array('wood'=>172380,'clay'=>178455,'iron'=>186595,'crop'=>34115,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>56140),array('wood'=>177120,'clay'=>183360,'iron'=>191725,'crop'=>35055,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>57530),array('wood'=>181995,'clay'=>188405,'iron'=>197000,'crop'=>36015,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>58940),array('wood'=>186995,'clay'=>193585,'iron'=>202415,'crop'=>37005,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>60360),array('wood'=>192140,'clay'=>198910,'iron'=>207985,'crop'=>38025,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>61810),array('wood'=>197425,'clay'=>204380,'iron'=>213705,'crop'=>39070,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>63270),array('wood'=>202855,'clay'=>210000,'iron'=>219580,'crop'=>40145,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>64760),array('wood'=>208430,'clay'=>215775,'iron'=>225620,'crop'=>41250,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>66260),array('wood'=>214165,'clay'=>221710,'iron'=>231825,'crop'=>42385,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>67790),array('wood'=>220055,'clay'=>227805,'iron'=>238200,'crop'=>43550,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>69340),array('wood'=>226105,'clay'=>234070,'iron'=>244750,'crop'=>44745,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>70910),array('wood'=>232320,'clay'=>240505,'iron'=>251480,'crop'=>45975,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>72500),array('wood'=>238710,'clay'=>247120,'iron'=>258395,'crop'=>47240,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>74120),array('wood'=>245275,'clay'=>253915,'iron'=>265500,'crop'=>48540,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>75760),array('wood'=>252020,'clay'=>260900,'iron'=>272800,'crop'=>49875,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>77420),array('wood'=>258950,'clay'=>268075,'iron'=>280305,'crop'=>51245,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>79100),array('wood'=>266070,'clay'=>275445,'iron'=>288010,'crop'=>52655,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>80810),array('wood'=>273390,'clay'=>283020,'iron'=>295930,'crop'=>54105,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>82540),array('wood'=>280905,'clay'=>290805,'iron'=>304070,'crop'=>55590,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>84290),array('wood'=>288630,'clay'=>298800,'iron'=>312430,'crop'=>57120,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>86070),array('wood'=>296570,'clay'=>307020,'iron'=>321025,'crop'=>58690,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>87880),array('wood'=>304725,'clay'=>315460,'iron'=>329850,'crop'=>60305,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>89710),array('wood'=>313105,'clay'=>324135,'iron'=>338925,'crop'=>61965,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>91570),array('wood'=>321715,'clay'=>333050,'iron'=>348245,'crop'=>63670,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>93450),array('wood'=>330565,'clay'=>342210,'iron'=>357820,'crop'=>65420,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>95360),array('wood'=>339655,'clay'=>351620,'iron'=>367660,'crop'=>67220,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>97290),array('wood'=>348995,'clay'=>361290,'iron'=>377770,'crop'=>69065,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>99250),array('wood'=>358590,'clay'=>371225,'iron'=>388160,'crop'=>70965,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>101240),array('wood'=>368450,'clay'=>381435,'iron'=>398835,'crop'=>72915,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>103260),array('wood'=>378585,'clay'=>391925,'iron'=>409800,'crop'=>74920,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>105310),array('wood'=>388995,'clay'=>402700,'iron'=>421070,'crop'=>76985,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>107380),array('wood'=>399695,'clay'=>413775,'iron'=>432650,'crop'=>79100,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>109480),array('wood'=>410685,'clay'=>425155,'iron'=>444550,'crop'=>81275,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>111620),array('wood'=>421980,'clay'=>436845,'iron'=>456775,'crop'=>83510,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>113780),array('wood'=>433585,'clay'=>448860,'iron'=>469335,'crop'=>85805,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>115970),array('wood'=>445505,'clay'=>461205,'iron'=>482240,'crop'=>88165,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>118200),array('wood'=>457760,'clay'=>473885,'iron'=>495505,'crop'=>90590,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>120450),array('wood'=>470345,'clay'=>486920,'iron'=>509130,'crop'=>93080,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>122740),array('wood'=>483280,'clay'=>500310,'iron'=>523130,'crop'=>95640,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>125060),array('wood'=>496570,'clay'=>514065,'iron'=>537520,'crop'=>98270,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>127410),array('wood'=>510225,'clay'=>528205,'iron'=>552300,'crop'=>100975,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>129790),array('wood'=>524260,'clay'=>542730,'iron'=>567490,'crop'=>103750,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>132210),array('wood'=>538675,'clay'=>557655,'iron'=>583095,'crop'=>106605,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>134660),array('wood'=>553490,'clay'=>572990,'iron'=>599130,'crop'=>109535,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>137140),array('wood'=>568710,'clay'=>588745,'iron'=>615605,'crop'=>112550,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>139660),array('wood'=>584350,'clay'=>604935,'iron'=>632535,'crop'=>115645,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>142220),array('wood'=>600420,'clay'=>621575,'iron'=>649930,'crop'=>118825,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>144810),array('wood'=>616930,'clay'=>638665,'iron'=>667800,'crop'=>122090,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>147440),array('wood'=>633895,'clay'=>656230,'iron'=>686165,'crop'=>125450,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>150100),array('wood'=>651330,'clay'=>674275,'iron'=>705035,'crop'=>128900,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>152800),array('wood'=>669240,'clay'=>692820,'iron'=>724425,'crop'=>132445,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>155540),array('wood'=>687645,'clay'=>711870,'iron'=>744345,'crop'=>136085,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>158320),array('wood'=>706555,'clay'=>731445,'iron'=>764815,'crop'=>139830,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>161140),array('wood'=>725985,'clay'=>751560,'iron'=>785850,'crop'=>143675,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>163990),array('wood'=>745950,'clay'=>772230,'iron'=>807460,'crop'=>147625,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>166890),array('wood'=>766460,'clay'=>793465,'iron'=>829665,'crop'=>151685,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>169820),array('wood'=>787540,'clay'=>815285,'iron'=>852480,'crop'=>155855,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>172800),array('wood'=>809195,'clay'=>837705,'iron'=>875920,'crop'=>160140,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>175820),array('wood'=>831450,'clay'=>860745,'iron'=>900010,'crop'=>164545,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>178880),array('wood'=>854315,'clay'=>884415,'iron'=>924760,'crop'=>169070,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>181990),array('wood'=>877810,'clay'=>908735,'iron'=>950190,'crop'=>173720,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>185130),array('wood'=>901950,'clay'=>933725,'iron'=>976320,'crop'=>178495,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>188330),array('wood'=>926750,'clay'=>959405,'iron'=>1000000,'crop'=>183405,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>191560),array('wood'=>952235,'clay'=>985785,'iron'=>1000000,'crop'=>188450,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>194840),array('wood'=>1000000,'clay'=>1000000,'iron'=>1000000,'crop'=>193630,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>198170));
+$bid41=array(1=>array('wood'=>780,'clay'=>420,'iron'=>660,'crop'=>540,'pop'=>5,'cp'=>4,'attri'=>0,'time'=>2200),array('wood'=>1000,'clay'=>540,'iron'=>845,'crop'=>690,'pop'=>3,'cp'=>4,'attri'=>0,'time'=>3150),array('wood'=>1280,'clay'=>690,'iron'=>1080,'crop'=>885,'pop'=>3,'cp'=>5,'attri'=>0,'time'=>4260),array('wood'=>1635,'clay'=>880,'iron'=>1385,'crop'=>1130,'pop'=>3,'cp'=>6,'attri'=>0,'time'=>5540),array('wood'=>2095,'clay'=>1125,'iron'=>1770,'crop'=>1450,'pop'=>3,'cp'=>7,'attri'=>0,'time'=>7020),array('wood'=>2680,'clay'=>1445,'iron'=>2270,'crop'=>1855,'pop'=>3,'cp'=>9,'attri'=>0,'time'=>8750),array('wood'=>3430,'clay'=>1845,'iron'=>2905,'crop'=>2375,'pop'=>3,'cp'=>11,'attri'=>0,'time'=>10750),array('wood'=>4390,'clay'=>2365,'iron'=>3715,'crop'=>3040,'pop'=>3,'cp'=>13,'attri'=>0,'time'=>13070),array('wood'=>5620,'clay'=>3025,'iron'=>4755,'crop'=>3890,'pop'=>3,'cp'=>15,'attri'=>0,'time'=>15760),array('wood'=>7195,'clay'=>3875,'iron'=>6085,'crop'=>4980,'pop'=>3,'cp'=>19,'attri'=>0,'time'=>18880),array('wood'=>9210,'clay'=>4960,'iron'=>7790,'crop'=>6375,'pop'=>4,'cp'=>22,'attri'=>0,'time'=>22500),array('wood'=>11785,'clay'=>6345,'iron'=>9975,'crop'=>8160,'pop'=>4,'cp'=>27,'attri'=>0,'time'=>26700),array('wood'=>15085,'clay'=>8125,'iron'=>12765,'crop'=>10445,'pop'=>4,'cp'=>32,'attri'=>0,'time'=>31570),array('wood'=>19310,'clay'=>10400,'iron'=>16340,'crop'=>13370,'pop'=>4,'cp'=>39,'attri'=>0,'time'=>37220),array('wood'=>24720,'clay'=>13310,'iron'=>20915,'crop'=>17115,'pop'=>4,'cp'=>46,'attri'=>0,'time'=>43780),array('wood'=>31640,'clay'=>17035,'iron'=>26775,'crop'=>21905,'pop'=>4,'cp'=>55,'attri'=>0,'time'=>51380),array('wood'=>40500,'clay'=>21810,'iron'=>34270,'crop'=>28040,'pop'=>4,'cp'=>67,'attri'=>0,'time'=>60200),array('wood'=>51840,'clay'=>27915,'iron'=>43865,'crop'=>35890,'pop'=>4,'cp'=>80,'attri'=>0,'time'=>70430),array('wood'=>66355,'clay'=>35730,'iron'=>56145,'crop'=>45940,'pop'=>4,'cp'=>96,'attri'=>0,'time'=>82300),array('wood'=>84935,'clay'=>45735,'iron'=>71870,'crop'=>58800,'pop'=>4,'cp'=>115,'attri'=>0,'time'=>96070));
+?>
diff --git a/GameEngine/Data/buidata.php_nk b/GameEngine/Data/buidata.php_nk
new file mode 100644
index 00000000..d30f01d5
--- /dev/null
+++ b/GameEngine/Data/buidata.php_nk
@@ -0,0 +1,52 @@
+2),array('wood'=>40,'clay'=>100,'iron'=>50,'crop'=>60,'pop'=>2,'cp'=>1,'prod'=>5,'time'=>260),array('wood'=>65,'clay'=>165,'iron'=>85,'crop'=>100,'pop'=>1,'cp'=>1,'prod'=>9,'time'=>620),array('wood'=>110,'clay'=>280,'iron'=>140,'crop'=>165,'pop'=>1,'cp'=>2,'prod'=>15,'time'=>1190),array('wood'=>185,'clay'=>465,'iron'=>235,'crop'=>280,'pop'=>1,'cp'=>2,'prod'=>22,'time'=>2100),array('wood'=>310,'clay'=>780,'iron'=>390,'crop'=>465,'pop'=>1,'cp'=>2,'prod'=>33,'time'=>3560),array('wood'=>520,'clay'=>1300,'iron'=>650,'crop'=>780,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>3638),array('wood'=>870,'clay'=>2170,'iron'=>1085,'crop'=>1300,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>7220),array('wood'=>1450,'clay'=>3625,'iron'=>1810,'crop'=>2175,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>15590),array('wood'=>2420,'clay'=>6050,'iron'=>3025,'crop'=>3630,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>25150),array('wood'=>4040,'clay'=>10105,'iron'=>5050,'crop'=>6060,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>40440),array('wood'=>6750,'clay'=>16870,'iron'=>8435,'crop'=>10125,'pop'=>2,'cp'=>7,'prod'=>280,'time'=>64900),array('wood'=>11270,'clay'=>28175,'iron'=>14090,'crop'=>16905,'pop'=>2,'cp'=>9,'prod'=>375,'time'=>104050),array('wood'=>18820,'clay'=>47055,'iron'=>23525,'crop'=>28230,'pop'=>2,'cp'=>11,'prod'=>495,'time'=>166680),array('wood'=>31430,'clay'=>78580,'iron'=>39290,'crop'=>47150,'pop'=>2,'cp'=>13,'prod'=>635,'time'=>266880),array('wood'=>52490,'clay'=>131230,'iron'=>65615,'crop'=>78740,'pop'=>2,'cp'=>15,'prod'=>800,'time'=>427210),array('wood'=>87660,'clay'=>219155,'iron'=>109575,'crop'=>131490,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>683730),array('wood'=>146395,'clay'=>365985,'iron'=>182995,'crop'=>219590,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>1094170),array('wood'=>244480,'clay'=>611195,'iron'=>305600,'crop'=>366715,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>1750880),array('wood'=>408280,'clay'=>1020695,'iron'=>510350,'crop'=>612420,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>2801600),array('wood'=>681825,'clay'=>1704565,'iron'=>852280,'crop'=>1022740,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>4482770));
+$bid2=array(array('prod'=>2),array('wood'=>80,'clay'=>40,'iron'=>80,'crop'=>50,'pop'=>2,'cp'=>1,'prod'=>5,'time'=>220),array('wood'=>135,'clay'=>65,'iron'=>135,'crop'=>85,'pop'=>1,'cp'=>1,'prod'=>9,'time'=>550),array('wood'=>225,'clay'=>110,'iron'=>225,'crop'=>140,'pop'=>1,'cp'=>2,'prod'=>15,'time'=>1080),array('wood'=>375,'clay'=>185,'iron'=>375,'crop'=>235,'pop'=>1,'cp'=>2,'prod'=>22,'time'=>1930),array('wood'=>620,'clay'=>310,'iron'=>620,'crop'=>390,'pop'=>1,'cp'=>2,'prod'=>33,'time'=>3290),array('wood'=>1040,'clay'=>520,'iron'=>1040,'crop'=>650,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>5470),array('wood'=>1735,'clay'=>870,'iron'=>1735,'crop'=>1085,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>8950),array('wood'=>2900,'clay'=>1450,'iron'=>2900,'crop'=>1810,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>14520),array('wood'=>4840,'clay'=>2420,'iron'=>4840,'crop'=>3025,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>23430),array('wood'=>8080,'clay'=>4040,'iron'=>8080,'crop'=>5050,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>37690),array('wood'=>13500,'clay'=>6750,'iron'=>13500,'crop'=>8435,'pop'=>2,'cp'=>7,'prod'=>280,'time'=>60510),array('wood'=>22540,'clay'=>11270,'iron'=>22540,'crop'=>14090,'pop'=>2,'cp'=>9,'prod'=>375,'time'=>97010),array('wood'=>37645,'clay'=>18820,'iron'=>37645,'crop'=>23525,'pop'=>2,'cp'=>11,'prod'=>495,'time'=>155420),array('wood'=>62865,'clay'=>31430,'iron'=>62865,'crop'=>39290,'pop'=>2,'cp'=>13,'prod'=>635,'time'=>248870),array('wood'=>104985,'clay'=>52490,'iron'=>104985,'crop'=>65615,'pop'=>2,'cp'=>15,'prod'=>800,'time'=>398390),array('wood'=>175320,'clay'=>87660,'iron'=>175320,'crop'=>109575,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>637620),array('wood'=>292790,'clay'=>146395,'iron'=>292790,'crop'=>182995,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>1020390),array('wood'=>488955,'clay'=>244480,'iron'=>488955,'crop'=>305600,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>1632820),array('wood'=>816555,'clay'=>408280,'iron'=>816555,'crop'=>510350,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>2612710),array('wood'=>1363650,'clay'=>681825,'iron'=>1363650,'crop'=>852280,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>4180540));
+$bid3=array(array('prod'=>2),array('wood'=>100,'clay'=>80,'iron'=>30,'crop'=>60,'pop'=>3,'cp'=>1,'prod'=>5,'time'=>450),array('wood'=>165,'clay'=>135,'iron'=>50,'crop'=>100,'pop'=>2,'cp'=>1,'prod'=>9,'time'=>920),array('wood'=>280,'clay'=>225,'iron'=>85,'crop'=>165,'pop'=>2,'cp'=>2,'prod'=>15,'time'=>1670),array('wood'=>465,'clay'=>375,'iron'=>140,'crop'=>280,'pop'=>2,'cp'=>2,'prod'=>22,'time'=>2880),array('wood'=>780,'clay'=>620,'iron'=>235,'crop'=>465,'pop'=>2,'cp'=>2,'prod'=>33,'time'=>4800),array('wood'=>1300,'clay'=>1040,'iron'=>390,'crop'=>780,'pop'=>2,'cp'=>3,'prod'=>50,'time'=>7880),array('wood'=>2170,'clay'=>1735,'iron'=>650,'crop'=>1300,'pop'=>2,'cp'=>4,'prod'=>70,'time'=>12810),array('wood'=>3625,'clay'=>2900,'iron'=>1085,'crop'=>2175,'pop'=>2,'cp'=>4,'prod'=>100,'time'=>20690),array('wood'=>6050,'clay'=>4840,'iron'=>1815,'crop'=>3630,'pop'=>2,'cp'=>5,'prod'=>145,'time'=>33310),array('wood'=>10105,'clay'=>8080,'iron'=>3030,'crop'=>6060,'pop'=>2,'cp'=>6,'prod'=>200,'time'=>53500),array('wood'=>16870,'clay'=>13500,'iron'=>5060,'crop'=>10125,'pop'=>3,'cp'=>7,'prod'=>280,'time'=>85800),array('wood'=>28175,'clay'=>22540,'iron'=>8455,'crop'=>16905,'pop'=>3,'cp'=>9,'prod'=>375,'time'=>137470),array('wood'=>47055,'clay'=>37645,'iron'=>14115,'crop'=>28230,'pop'=>3,'cp'=>11,'prod'=>495,'time'=>220160),array('wood'=>78580,'clay'=>62865,'iron'=>23575,'crop'=>47150,'pop'=>3,'cp'=>13,'prod'=>635,'time'=>352450),array('wood'=>131230,'clay'=>104985,'iron'=>39370,'crop'=>78740,'pop'=>3,'cp'=>15,'prod'=>800,'time'=>564120),array('wood'=>219155,'clay'=>175320,'iron'=>65745,'crop'=>131490,'pop'=>3,'cp'=>18,'prod'=>1000,'time'=>902760),array('wood'=>365985,'clay'=>292790,'iron'=>109795,'crop'=>219590,'pop'=>3,'cp'=>22,'prod'=>1300,'time'=>145546),array('wood'=>611195,'clay'=>488955,'iron'=>183360,'crop'=>366715,'pop'=>3,'cp'=>27,'prod'=>1600,'time'=>2311660),array('wood'=>1020695,'clay'=>816555,'iron'=>306210,'crop'=>612420,'pop'=>3,'cp'=>32,'prod'=>2000,'time'=>3698850),array('wood'=>1704565,'clay'=>1363650,'iron'=>511370,'crop'=>1022740,'pop'=>3,'cp'=>38,'prod'=>2450,'time'=>5918370));
+$bid4=array(array('prod'=>2),array('wood'=>70,'clay'=>90,'iron'=>70,'crop'=>20,'pop'=>0,'cp'=>1,'prod'=>5,'time'=>150),array('wood'=>115,'clay'=>150,'iron'=>115,'crop'=>35,'pop'=>0,'cp'=>1,'prod'=>9,'time'=>440),array('wood'=>195,'clay'=>250,'iron'=>195,'crop'=>55,'pop'=>0,'cp'=>2,'prod'=>15,'time'=>900),array('wood'=>325,'clay'=>420,'iron'=>325,'crop'=>95,'pop'=>0,'cp'=>2,'prod'=>22,'time'=>1650),array('wood'=>545,'clay'=>700,'iron'=>545,'crop'=>155,'pop'=>0,'cp'=>2,'prod'=>33,'time'=>2830),array('wood'=>910,'clay'=>1170,'iron'=>910,'crop'=>260,'pop'=>1,'cp'=>3,'prod'=>50,'time'=>4730),array('wood'=>1520,'clay'=>1950,'iron'=>1520,'crop'=>435,'pop'=>1,'cp'=>4,'prod'=>70,'time'=>7780),array('wood'=>2535,'clay'=>3260,'iron'=>2535,'crop'=>725,'pop'=>1,'cp'=>4,'prod'=>100,'time'=>12190),array('wood'=>4235,'clay'=>5445,'iron'=>4235,'crop'=>1210,'pop'=>1,'cp'=>5,'prod'=>145,'time'=>19690),array('wood'=>7070,'clay'=>9095,'iron'=>7070,'crop'=>2020,'pop'=>1,'cp'=>6,'prod'=>200,'time'=>31700),array('wood'=>11810,'clay'=>15185,'iron'=>11810,'crop'=>3375,'pop'=>1,'cp'=>7,'prod'=>280,'time'=>50910),array('wood'=>19725,'clay'=>25360,'iron'=>19725,'crop'=>5635,'pop'=>1,'cp'=>9,'prod'=>375,'time'=>84700),array('wood'=>32940,'clay'=>42350,'iron'=>32940,'crop'=>9410,'pop'=>1,'cp'=>11,'prod'=>495,'time'=>135710),array('wood'=>55005,'clay'=>70720,'iron'=>55005,'crop'=>15715,'pop'=>1,'cp'=>13,'prod'=>635,'time'=>217340),array('wood'=>91860,'clay'=>118105,'iron'=>91860,'crop'=>26245,'pop'=>1,'cp'=>15,'prod'=>800,'time'=>347950),array('wood'=>153405,'clay'=>197240,'iron'=>153405,'crop'=>43830,'pop'=>2,'cp'=>18,'prod'=>1000,'time'=>556910),array('wood'=>256190,'clay'=>329385,'iron'=>256190,'crop'=>73195,'pop'=>2,'cp'=>22,'prod'=>1300,'time'=>891260),array('wood'=>427835,'clay'=>550075,'iron'=>427835,'crop'=>122240,'pop'=>2,'cp'=>27,'prod'=>1600,'time'=>1426210),array('wood'=>714485,'clay'=>918625,'iron'=>714485,'crop'=>204140,'pop'=>2,'cp'=>32,'prod'=>2000,'time'=>2282140),array('wood'=>1193195,'clay'=>1534105,'iron'=>1193195,'crop'=>340915,'pop'=>2,'cp'=>38,'prod'=>2450,'time'=>3651630));
+$bid5=array(1=>array('wood'=>520,'clay'=>380,'iron'=>290,'crop'=>90,'pop'=>4,'cp'=>1,'attri'=>5,'time'=>3000),array('wood'=>935,'clay'=>685,'iron'=>520,'crop'=>160,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>5700),array('wood'=>1685,'clay'=>1230,'iron'=>940,'crop'=>290,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>9750),array('wood'=>3035,'clay'=>2215,'iron'=>1690,'crop'=>525,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>15830),array('wood'=>5460,'clay'=>3990,'iron'=>3045,'crop'=>945,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>24940));
+$bid6=array(1=>array('wood'=>440,'clay'=>480,'iron'=>320,'crop'=>50,'pop'=>3,'cp'=>1,'attri'=>5,'time'=>2240),array('wood'=>790,'clay'=>865,'iron'=>575,'crop'=>90,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>4560),array('wood'=>1425,'clay'=>1555,'iron'=>1035,'crop'=>160,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>8040),array('wood'=>2565,'clay'=>2800,'iron'=>1865,'crop'=>290,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>13260),array('wood'=>4620,'clay'=>5040,'iron'=>3360,'crop'=>525,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>21090));
+$bid7=array(1=>array('wood'=>200,'clay'=>450,'iron'=>510,'crop'=>120,'pop'=>6,'cp'=>1,'attri'=>5,'time'=>4080),array('wood'=>360,'clay'=>810,'iron'=>920,'crop'=>215,'pop'=>3,'cp'=>1,'attri'=>10,'time'=>7320),array('wood'=>650,'clay'=>1460,'iron'=>1650,'crop'=>390,'pop'=>3,'cp'=>2,'attri'=>15,'time'=>12180),array('wood'=>1165,'clay'=>2625,'iron'=>2975,'crop'=>700,'pop'=>3,'cp'=>2,'attri'=>20,'time'=>19470),array('wood'=>2100,'clay'=>4725,'iron'=>5355,'crop'=>1260,'pop'=>3,'cp'=>2,'attri'=>25,'time'=>30410));
+$bid8=array(1=>array('wood'=>500,'clay'=>440,'iron'=>380,'crop'=>1240,'pop'=>3,'cp'=>1,'attri'=>5,'time'=>1840),array('wood'=>900,'clay'=>790,'iron'=>685,'crop'=>2230,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>3960),array('wood'=>1620,'clay'=>1425,'iron'=>1230,'crop'=>4020,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>7140),array('wood'=>2915,'clay'=>2565,'iron'=>2215,'crop'=>7230,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>11910),array('wood'=>5250,'clay'=>4620,'iron'=>3990,'crop'=>13015,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>19070));
+$bid9=array(1=>array('wood'=>1200,'clay'=>1480,'iron'=>870,'crop'=>1600,'pop'=>4,'cp'=>1,'attri'=>5,'time'=>3680),array('wood'=>2160,'clay'=>2665,'iron'=>1565,'crop'=>2880,'pop'=>2,'cp'=>1,'attri'=>10,'time'=>6720),array('wood'=>3890,'clay'=>4795,'iron'=>2820,'crop'=>5185,'pop'=>2,'cp'=>2,'attri'=>15,'time'=>11280),array('wood'=>7000,'clay'=>8630,'iron'=>5075,'crop'=>9330,'pop'=>2,'cp'=>2,'attri'=>20,'time'=>18120),array('wood'=>12595,'clay'=>15535,'iron'=>9135,'crop'=>16795,'pop'=>2,'cp'=>2,'attri'=>25,'time'=>28380));
+$bid10=array(1=>array('wood'=>130,'clay'=>160,'iron'=>90,'crop'=>40,'pop'=>1,'cp'=>1,'attri'=>1200,'time'=>2000),array('wood'=>165,'clay'=>205,'iron'=>115,'crop'=>50,'pop'=>1,'cp'=>1,'attri'=>1700,'time'=>2620),array('wood'=>215,'clay'=>260,'iron'=>145,'crop'=>65,'pop'=>1,'cp'=>2,'attri'=>2300,'time'=>3340),array('wood'=>275,'clay'=>335,'iron'=>190,'crop'=>85,'pop'=>1,'cp'=>2,'attri'=>3100,'time'=>4170),array('wood'=>350,'clay'=>430,'iron'=>240,'crop'=>105,'pop'=>1,'cp'=>2,'attri'=>4000,'time'=>5140),array('wood'=>445,'clay'=>550,'iron'=>310,'crop'=>135,'pop'=>1,'cp'=>3,'attri'=>5000,'time'=>6260),array('wood'=>570,'clay'=>705,'iron'=>395,'crop'=>175,'pop'=>1,'cp'=>4,'attri'=>6300,'time'=>7570),array('wood'=>730,'clay'=>900,'iron'=>505,'crop'=>225,'pop'=>1,'cp'=>4,'attri'=>7800,'time'=>9080),array('wood'=>935,'clay'=>1115,'iron'=>650,'crop'=>290,'pop'=>1,'cp'=>5,'attri'=>9600,'time'=>10830),array('wood'=>1200,'clay'=>1475,'iron'=>830,'crop'=>370,'pop'=>1,'cp'=>6,'attri'=>11800,'time'=>12860),array('wood'=>1535,'clay'=>1890,'iron'=>1065,'crop'=>470,'pop'=>2,'cp'=>7,'attri'=>14400,'time'=>15220),array('wood'=>1965,'clay'=>2420,'iron'=>1360,'crop'=>605,'pop'=>2,'cp'=>9,'attri'=>17600,'time'=>17950),array('wood'=>2515,'clay'=>3095,'iron'=>1740,'crop'=>775,'pop'=>2,'cp'=>11,'attri'=>21400,'time'=>21130),array('wood'=>3220,'clay'=>3960,'iron'=>2230,'crop'=>990,'pop'=>2,'cp'=>13,'attri'=>25900,'time'=>24810),array('wood'=>4120,'clay'=>5070,'iron'=>2850,'crop'=>1270,'pop'=>2,'cp'=>15,'attri'=>31300,'time'=>29080),array('wood'=>5275,'clay'=>6490,'iron'=>3650,'crop'=>1625,'pop'=>2,'cp'=>18,'attri'=>37900,'time'=>34030),array('wood'=>6750,'clay'=>8310,'iron'=>4675,'crop'=>2075,'pop'=>2,'cp'=>22,'attri'=>45700,'time'=>39770),array('wood'=>8640,'clay'=>10635,'iron'=>5980,'crop'=>2660,'pop'=>2,'cp'=>27,'attri'=>55100,'time'=>46440),array('wood'=>11060,'clay'=>13610,'iron'=>7655,'crop'=>3405,'pop'=>2,'cp'=>32,'attri'=>66400,'time'=>54170),array('wood'=>14155,'clay'=>17420,'iron'=>9800,'crop'=>4355,'pop'=>2,'cp'=>38,'attri'=>80000,'time'=>63130));
+$bid11=array(1=>array('wood'=>80,'clay'=>100,'iron'=>70,'crop'=>20,'pop'=>1,'cp'=>1,'attri'=>1200,'time'=>1600),array('wood'=>100,'clay'=>130,'iron'=>90,'crop'=>25,'pop'=>1,'cp'=>1,'attri'=>1700,'time'=>2160),array('wood'=>130,'clay'=>165,'iron'=>115,'crop'=>35,'pop'=>1,'cp'=>2,'attri'=>2300,'time'=>2800),array('wood'=>170,'clay'=>210,'iron'=>145,'crop'=>40,'pop'=>1,'cp'=>2,'attri'=>3100,'time'=>3550),array('wood'=>215,'clay'=>270,'iron'=>190,'crop'=>55,'pop'=>1,'cp'=>2,'attri'=>4000,'time'=>4420),array('wood'=>275,'clay'=>345,'iron'=>240,'crop'=>70,'pop'=>1,'cp'=>3,'attri'=>5000,'time'=>5420),array('wood'=>350,'clay'=>440,'iron'=>310,'crop'=>90,'pop'=>1,'cp'=>4,'attri'=>6300,'time'=>6590),array('wood'=>450,'clay'=>565,'iron'=>395,'crop'=>115,'pop'=>1,'cp'=>4,'attri'=>7800,'time'=>7950),array('wood'=>575,'clay'=>720,'iron'=>505,'crop'=>145,'pop'=>1,'cp'=>5,'attri'=>9600,'time'=>9520),array('wood'=>740,'clay'=>920,'iron'=>645,'crop'=>185,'pop'=>1,'cp'=>6,'attri'=>11800,'time'=>11340),array('wood'=>945,'clay'=>1180,'iron'=>825,'crop'=>235,'pop'=>2,'cp'=>7,'attri'=>14400,'time'=>13450),array('wood'=>1210,'clay'=>1510,'iron'=>1060,'crop'=>300,'pop'=>2,'cp'=>9,'attri'=>17600,'time'=>15910),array('wood'=>1545,'clay'=>1935,'iron'=>1355,'crop'=>385,'pop'=>2,'cp'=>11,'attri'=>21400,'time'=>18750),array('wood'=>1980,'clay'=>2475,'iron'=>1735,'crop'=>495,'pop'=>2,'cp'=>13,'attri'=>25900,'time'=>22050),array('wood'=>2535,'clay'=>3170,'iron'=>2220,'crop'=>635,'pop'=>2,'cp'=>15,'attri'=>31300,'time'=>25880),array('wood'=>3245,'clay'=>4055,'iron'=>2840,'crop'=>810,'pop'=>2,'cp'=>18,'attri'=>37900,'time'=>30320),array('wood'=>4155,'clay'=>5190,'iron'=>3635,'crop'=>1040,'pop'=>2,'cp'=>22,'attri'=>45700,'time'=>35470),array('wood'=>5315,'clay'=>6645,'iron'=>4650,'crop'=>1330,'pop'=>2,'cp'=>27,'attri'=>55100,'time'=>41450),array('wood'=>6805,'clay'=>8505,'iron'=>5955,'crop'=>1700,'pop'=>2,'cp'=>32,'attri'=>66400,'time'=>48380),array('wood'=>8710,'clay'=>10890,'iron'=>7620,'crop'=>2180,'pop'=>2,'cp'=>38,'attri'=>80000,'time'=>56420));
+$bid12=array(1=>array('wood'=>170,'clay'=>200,'iron'=>380,'crop'=>130,'pop'=>4,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>220,'clay'=>255,'iron'=>485,'crop'=>165,'pop'=>2,'cp'=>3,'attri'=>96.4,'time'=>2620),array('wood'=>280,'clay'=>330,'iron'=>625,'crop'=>215,'pop'=>2,'cp'=>3,'attri'=>92.93,'time'=>3340),array('wood'=>355,'clay'=>420,'iron'=>795,'crop'=>275,'pop'=>2,'cp'=>4,'attri'=>89.58,'time'=>4170),array('wood'=>455,'clay'=>535,'iron'=>1020,'crop'=>350,'pop'=>2,'cp'=>5,'attri'=>86.36,'time'=>5140),array('wood'=>585,'clay'=>685,'iron'=>1305,'crop'=>445,'pop'=>3,'cp'=>6,'attri'=>83.25,'time'=>6260),array('wood'=>750,'clay'=>880,'iron'=>1670,'crop'=>570,'pop'=>3,'cp'=>7,'attri'=>80.25,'time'=>7570),array('wood'=>955,'clay'=>1125,'iron'=>2140,'crop'=>730,'pop'=>3,'cp'=>9,'attri'=>77.36,'time'=>9080),array('wood'=>1225,'clay'=>1440,'iron'=>2740,'crop'=>935,'pop'=>3,'cp'=>10,'attri'=>74.58,'time'=>10830),array('wood'=>1570,'clay'=>1845,'iron'=>3505,'crop'=>1200,'pop'=>3,'cp'=>12,'attri'=>71.89,'time'=>12860),array('wood'=>2005,'clay'=>2360,'iron'=>4485,'crop'=>1535,'pop'=>3,'cp'=>15,'attri'=>69.31,'time'=>15220),array('wood'=>2570,'clay'=>3020,'iron'=>5740,'crop'=>1965,'pop'=>3,'cp'=>18,'attri'=>66.81,'time'=>17950),array('wood'=>3290,'clay'=>3870,'iron'=>7350,'crop'=>2515,'pop'=>3,'cp'=>21,'attri'=>64.41,'time'=>21130),array('wood'=>4210,'clay'=>4950,'iron'=>9410,'crop'=>3220,'pop'=>3,'cp'=>26,'attri'=>62.09,'time'=>24810),array('wood'=>5390,'clay'=>6340,'iron'=>12045,'crop'=>4120,'pop'=>3,'cp'=>31,'attri'=>59.85,'time'=>29080),array('wood'=>6895,'clay'=>8115,'iron'=>15415,'crop'=>5275,'pop'=>4,'cp'=>37,'attri'=>57.70,'time'=>34030),array('wood'=>8825,'clay'=>10385,'iron'=>19730,'crop'=>6750,'pop'=>4,'cp'=>44,'attri'=>55.62,'time'=>39770),array('wood'=>11300,'clay'=>13290,'iron'=>25255,'crop'=>8640,'pop'=>4,'cp'=>53,'attri'=>53.62,'time'=>46440),array('wood'=>14460,'clay'=>17015,'iron'=>32325,'crop'=>11060,'pop'=>4,'cp'=>64,'attri'=>51.69,'time'=>54170),array('wood'=>18510,'clay'=>21780,'iron'=>41380,'crop'=>14155,'pop'=>4,'cp'=>77,'attri'=>49.83,'time'=>63130));
+$bid13=array(1=>array('wood'=>130,'clay'=>210,'iron'=>410,'crop'=>130,'pop'=>4,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>165,'clay'=>270,'iron'=>525,'crop'=>165,'pop'=>2,'cp'=>3,'attri'=>96.4,'time'=>2620),array('wood'=>215,'clay'=>345,'iron'=>670,'crop'=>215,'pop'=>2,'cp'=>3,'attri'=>92.93,'time'=>3340),array('wood'=>275,'clay'=>440,'iron'=>860,'crop'=>275,'pop'=>2,'cp'=>4,'attri'=>89.58,'time'=>4170),array('wood'=>350,'clay'=>565,'iron'=>1100,'crop'=>350,'pop'=>2,'cp'=>5,'attri'=>86.36,'time'=>5140),array('wood'=>445,'clay'=>720,'iron'=>1410,'crop'=>445,'pop'=>3,'cp'=>6,'attri'=>83.25,'time'=>6260),array('wood'=>570,'clay'=>925,'iron'=>1805,'crop'=>570,'pop'=>3,'cp'=>7,'attri'=>80.25,'time'=>7570),array('wood'=>730,'clay'=>1180,'iron'=>2310,'crop'=>730,'pop'=>3,'cp'=>9,'attri'=>77.36,'time'=>9080),array('wood'=>935,'clay'=>1515,'iron'=>2955,'crop'=>935,'pop'=>3,'cp'=>10,'attri'=>74.58,'time'=>10830),array('wood'=>1200,'clay'=>1935,'iron'=>3780,'crop'=>1200,'pop'=>3,'cp'=>12,'attri'=>71.89,'time'=>12860),array('wood'=>1535,'clay'=>2480,'iron'=>4840,'crop'=>1535,'pop'=>3,'cp'=>15,'attri'=>69.31,'time'=>15220),array('wood'=>1965,'clay'=>3175,'iron'=>6195,'crop'=>1965,'pop'=>3,'cp'=>18,'attri'=>66.81,'time'=>17950),array('wood'=>2515,'clay'=>4060,'iron'=>7930,'crop'=>2515,'pop'=>3,'cp'=>21,'attri'=>64.41,'time'=>21130),array('wood'=>3220,'clay'=>5200,'iron'=>10150,'crop'=>3220,'pop'=>3,'cp'=>26,'attri'=>62.09,'time'=>24810),array('wood'=>4120,'clay'=>6655,'iron'=>12995,'crop'=>4120,'pop'=>3,'cp'=>31,'attri'=>59.85,'time'=>29080),array('wood'=>5275,'clay'=>8520,'iron'=>16630,'crop'=>5275,'pop'=>4,'cp'=>37,'attri'=>57.70,'time'=>34030),array('wood'=>6750,'clay'=>10905,'iron'=>21290,'crop'=>6750,'pop'=>4,'cp'=>44,'attri'=>55.62,'time'=>39770),array('wood'=>8640,'clay'=>13955,'iron'=>27250,'crop'=>8640,'pop'=>4,'cp'=>53,'attri'=>53.62,'time'=>46440),array('wood'=>11060,'clay'=>17865,'iron'=>34880,'crop'=>11060,'pop'=>4,'cp'=>64,'attri'=>51.69,'time'=>54170),array('wood'=>14155,'clay'=>22865,'iron'=>44645,'crop'=>14155,'pop'=>4,'cp'=>77,'attri'=>49.83,'time'=>63130));
+$bid14=array(1=>array('wood'=>1750,'clay'=>2250,'iron'=>1530,'crop'=>240,'pop'=>1,'cp'=>1,'attri'=>110,'time'=>3500),array('wood'=>2240,'clay'=>2880,'iron'=>1960,'crop'=>305,'pop'=>1,'cp'=>1,'attri'=>120,'time'=>4360),array('wood'=>2865,'clay'=>3685,'iron'=>2505,'crop'=>395,'pop'=>1,'cp'=>2,'attri'=>130,'time'=>5360),array('wood'=>3670,'clay'=>4720,'iron'=>3210,'crop'=>505,'pop'=>1,'cp'=>2,'attri'=>140,'time'=>6510),array('wood'=>4700,'clay'=>6040,'iron'=>4105,'crop'=>645,'pop'=>1,'cp'=>2,'attri'=>150,'time'=>7860),array('wood'=>6015,'clay'=>7730,'iron'=>5255,'crop'=>825,'pop'=>1,'cp'=>3,'attri'=>160,'time'=>9410),array('wood'=>7695,'clay'=>9895,'iron'=>6730,'crop'=>1055,'pop'=>1,'cp'=>4,'attri'=>170,'time'=>11220),array('wood'=>9850,'clay'=>12665,'iron'=>8615,'crop'=>1350,'pop'=>1,'cp'=>4,'attri'=>180,'time'=>13320),array('wood'=>12610,'clay'=>16215,'iron'=>11025,'crop'=>1730,'pop'=>1,'cp'=>5,'attri'=>190,'time'=>15750),array('wood'=>16140,'clay'=>20755,'iron'=>14110,'crop'=>2215,'pop'=>1,'cp'=>6,'attri'=>200,'time'=>18570),array('wood'=>20660,'clay'=>26565,'iron'=>18065,'crop'=>2835,'pop'=>2,'cp'=>7,'attri'=>210,'time'=>21840),array('wood'=>26445,'clay'=>34000,'iron'=>23120,'crop'=>3625,'pop'=>2,'cp'=>9,'attri'=>220,'time'=>25630),array('wood'=>33850,'clay'=>43520,'iron'=>29595,'crop'=>4640,'pop'=>2,'cp'=>11,'attri'=>230,'time'=>30030),array('wood'=>43330,'clay'=>55705,'iron'=>37880,'crop'=>5940,'pop'=>2,'cp'=>13,'attri'=>240,'time'=>35140),array('wood'=>55460,'clay'=>71305,'iron'=>48490,'crop'=>7605,'pop'=>2,'cp'=>15,'attri'=>250,'time'=>41060),array('wood'=>70990,'clay'=>91270,'iron'=>62065,'crop'=>9735,'pop'=>2,'cp'=>18,'attri'=>260,'time'=>47930),array('wood'=>90865,'clay'=>116825,'iron'=>79440,'crop'=>12460,'pop'=>2,'cp'=>22,'attri'=>270,'time'=>55900),array('wood'=>116305,'clay'=>149540,'iron'=>101685,'crop'=>15950,'pop'=>2,'cp'=>27,'attri'=>280,'time'=>65140),array('wood'=>148875,'clay'=>191410,'iron'=>130160,'crop'=>20415,'pop'=>2,'cp'=>32,'attri'=>290,'time'=>75860),array('wood'=>190560,'clay'=>245005,'iron'=>166600,'crop'=>26135,'pop'=>2,'cp'=>38,'attri'=>300,'time'=>88300));
+$bid15=array(1=>array('wood'=>70,'clay'=>40,'iron'=>60,'crop'=>20,'pop'=>2,'cp'=>2,'attri'=>100,'time'=>2620),array('wood'=>90,'clay'=>50,'iron'=>75,'crop'=>25,'pop'=>1,'cp'=>3,'attri'=>96.4,'time'=>3220),array('wood'=>115,'clay'=>65,'iron'=>100,'crop'=>35,'pop'=>1,'cp'=>3,'attri'=>92.93,'time'=>3880),array('wood'=>145,'clay'=>85,'iron'=>125,'crop'=>40,'pop'=>1,'cp'=>4,'attri'=>89.58,'time'=>4610),array('wood'=>190,'clay'=>105,'iron'=>160,'crop'=>55,'pop'=>1,'cp'=>5,'attri'=>86.36,'time'=>5410),array('wood'=>240,'clay'=>135,'iron'=>205,'crop'=>70,'pop'=>2,'cp'=>6,'attri'=>83.25,'time'=>6300),array('wood'=>310,'clay'=>175,'iron'=>265,'crop'=>90,'pop'=>2,'cp'=>7,'attri'=>80.25,'time'=>7280),array('wood'=>395,'clay'=>225,'iron'=>340,'crop'=>115,'pop'=>2,'cp'=>9,'attri'=>77.36,'time'=>8380),array('wood'=>505,'clay'=>290,'iron'=>430,'crop'=>145,'pop'=>2,'cp'=>10,'attri'=>74.58,'time'=>9590),array('wood'=>645,'clay'=>370,'iron'=>555,'crop'=>185,'pop'=>2,'cp'=>12,'attri'=>71.89,'time'=>10940),array('wood'=>825,'clay'=>470,'iron'=>710,'crop'=>235,'pop'=>2,'cp'=>15,'attri'=>69.31,'time'=>12440),array('wood'=>1060,'clay'=>605,'iron'=>905,'crop'=>300,'pop'=>2,'cp'=>18,'attri'=>66.81,'time'=>14120),array('wood'=>1355,'clay'=>775,'iron'=>1160,'crop'=>385,'pop'=>2,'cp'=>21,'attri'=>64.41,'time'=>15980),array('wood'=>1735,'clay'=>990,'iron'=>1485,'crop'=>495,'pop'=>2,'cp'=>26,'attri'=>62.09,'time'=>18050),array('wood'=>2220,'clay'=>1270,'iron'=>1900,'crop'=>635,'pop'=>2,'cp'=>31,'attri'=>59.85,'time'=>20370),array('wood'=>2840,'clay'=>1625,'iron'=>2435,'crop'=>810,'pop'=>3,'cp'=>37,'attri'=>57.70,'time'=>22950),array('wood'=>3635,'clay'=>2075,'iron'=>3115,'crop'=>1040,'pop'=>3,'cp'=>44,'attri'=>55.62,'time'=>25830),array('wood'=>4650,'clay'=>2660,'iron'=>3990,'crop'=>1330,'pop'=>3,'cp'=>53,'attri'=>53.62,'time'=>29040),array('wood'=>5955,'clay'=>3405,'iron'=>5105,'crop'=>1700,'pop'=>3,'cp'=>64,'attri'=>51.69,'time'=>32630),array('wood'=>7620,'clay'=>4355,'iron'=>6535,'crop'=>2180,'pop'=>3,'cp'=>77,'attri'=>49.83,'time'=>0));
+$bid16=array(1=>array('wood'=>110,'clay'=>160,'iron'=>90,'crop'=>70,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>670),array('wood'=>140,'clay'=>205,'iron'=>115,'crop'=>90,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>870),array('wood'=>180,'clay'=>260,'iron'=>145,'crop'=>115,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1110),array('wood'=>230,'clay'=>335,'iron'=>190,'crop'=>145,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1390),array('wood'=>295,'clay'=>430,'iron'=>240,'crop'=>190,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>1710),array('wood'=>380,'clay'=>550,'iron'=>310,'crop'=>240,'pop'=>1,'cp'=>3,'attri'=>0,'time'=>2090),array('wood'=>485,'clay'=>705,'iron'=>395,'crop'=>310,'pop'=>1,'cp'=>4,'attri'=>0,'time'=>2520),array('wood'=>620,'clay'=>900,'iron'=>505,'crop'=>395,'pop'=>1,'cp'=>4,'attri'=>0,'time'=>3030),array('wood'=>795,'clay'=>1155,'iron'=>650,'crop'=>505,'pop'=>1,'cp'=>5,'attri'=>0,'time'=>3610),array('wood'=>1015,'clay'=>1475,'iron'=>830,'crop'=>645,'pop'=>1,'cp'=>6,'attri'=>0,'time'=>4290),array('wood'=>1300,'clay'=>1890,'iron'=>1065,'crop'=>825,'pop'=>2,'cp'=>7,'attri'=>0,'time'=>5070),array('wood'=>1660,'clay'=>2420,'iron'=>1360,'crop'=>1060,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>5980),array('wood'=>2130,'clay'=>3095,'iron'=>1740,'crop'=>1355,'pop'=>2,'cp'=>11,'attri'=>0,'time'=>7040),array('wood'=>2725,'clay'=>3960,'iron'=>2230,'crop'=>1735,'pop'=>2,'cp'=>13,'attri'=>0,'time'=>8270),array('wood'=>3485,'clay'=>5070,'iron'=>2850,'crop'=>2220,'pop'=>2,'cp'=>15,'attri'=>0,'time'=>9690),array('wood'=>4460,'clay'=>6490,'iron'=>3650,'crop'=>2840,'pop'=>2,'cp'=>18,'attri'=>0,'time'=>11340),array('wood'=>5710,'clay'=>8310,'iron'=>4675,'crop'=>3635,'pop'=>2,'cp'=>22,'attri'=>0,'time'=>13260),array('wood'=>7310,'clay'=>10635,'iron'=>5980,'crop'=>4650,'pop'=>2,'cp'=>27,'attri'=>0,'time'=>15480),array('wood'=>9360,'clay'=>13610,'iron'=>7655,'crop'=>5955,'pop'=>2,'cp'=>32,'attri'=>0,'time'=>18060),array('wood'=>11980,'clay'=>17420,'iron'=>9800,'crop'=>7620,'pop'=>2,'cp'=>38,'attri'=>0,'time'=>21040));
+$bid17=array(1=>array('wood'=>80,'clay'=>70,'iron'=>120,'crop'=>70,'pop'=>4,'cp'=>4,'attri'=>1,'time'=>1800),array('wood'=>100,'clay'=>90,'iron'=>155,'crop'=>90,'pop'=>2,'cp'=>4,'attri'=>2,'time'=>2390),array('wood'=>130,'clay'=>115,'iron'=>195,'crop'=>115,'pop'=>2,'cp'=>5,'attri'=>3,'time'=>3070),array('wood'=>170,'clay'=>145,'iron'=>250,'crop'=>145,'pop'=>2,'cp'=>6,'attri'=>4,'time'=>3860),array('wood'=>215,'clay'=>190,'iron'=>320,'crop'=>190,'pop'=>2,'cp'=>7,'attri'=>5,'time'=>4780),array('wood'=>275,'clay'=>240,'iron'=>410,'crop'=>240,'pop'=>3,'cp'=>9,'attri'=>6,'time'=>5840),array('wood'=>350,'clay'=>310,'iron'=>530,'crop'=>310,'pop'=>3,'cp'=>11,'attri'=>7,'time'=>7080),array('wood'=>450,'clay'=>395,'iron'=>675,'crop'=>395,'pop'=>3,'cp'=>13,'attri'=>8,'time'=>8510),array('wood'=>575,'clay'=>505,'iron'=>865,'crop'=>505,'pop'=>3,'cp'=>15,'attri'=>9,'time'=>10170),array('wood'=>740,'clay'=>645,'iron'=>1105,'crop'=>645,'pop'=>3,'cp'=>19,'attri'=>10,'time'=>12100),array('wood'=>945,'clay'=>825,'iron'=>1415,'crop'=>825,'pop'=>3,'cp'=>22,'attri'=>11,'time'=>14340),array('wood'=>1210,'clay'=>1060,'iron'=>1815,'crop'=>1060,'pop'=>3,'cp'=>27,'attri'=>12,'time'=>16930),array('wood'=>1545,'clay'=>1355,'iron'=>2320,'crop'=>1355,'pop'=>3,'cp'=>32,'attri'=>13,'time'=>19940),array('wood'=>1980,'clay'=>1735,'iron'=>2970,'crop'=>1735,'pop'=>3,'cp'=>39,'attri'=>14,'time'=>23430),array('wood'=>2535,'clay'=>2220,'iron'=>3805,'crop'=>2220,'pop'=>3,'cp'=>46,'attri'=>15,'time'=>27480),array('wood'=>3245,'clay'=>2840,'iron'=>4870,'crop'=>2840,'pop'=>4,'cp'=>55,'attri'=>16,'time'=>32180),array('wood'=>4155,'clay'=>3635,'iron'=>6230,'crop'=>3635,'pop'=>4,'cp'=>67,'attri'=>17,'time'=>37620),array('wood'=>5315,'clay'=>4650,'iron'=>7975,'crop'=>4650,'pop'=>4,'cp'=>80,'attri'=>18,'time'=>43940),array('wood'=>6805,'clay'=>5955,'iron'=>10210,'crop'=>5955,'pop'=>4,'cp'=>96,'attri'=>19,'time'=>51270),array('wood'=>8710,'clay'=>7620,'iron'=>13065,'crop'=>7620,'pop'=>4,'cp'=>115,'attri'=>20,'time'=>59780));
+$bid18=array(1=>array('wood'=>180,'clay'=>130,'iron'=>150,'crop'=>80,'pop'=>3,'cp'=>5,'attri'=>0,'time'=>2000),array('wood'=>230,'clay'=>165,'iron'=>190,'crop'=>100,'pop'=>2,'cp'=>6,'attri'=>0,'time'=>2620),array('wood'=>295,'clay'=>215,'iron'=>245,'crop'=>130,'pop'=>2,'cp'=>7,'attri'=>9,'time'=>3340),array('wood'=>375,'clay'=>275,'iron'=>315,'crop'=>170,'pop'=>2,'cp'=>8,'attri'=>12,'time'=>4170),array('wood'=>485,'clay'=>350,'iron'=>405,'crop'=>215,'pop'=>2,'cp'=>10,'attri'=>15,'time'=>5140),array('wood'=>620,'clay'=>445,'iron'=>515,'crop'=>275,'pop'=>2,'cp'=>12,'attri'=>18,'time'=>6260),array('wood'=>790,'clay'=>570,'iron'=>660,'crop'=>350,'pop'=>2,'cp'=>14,'attri'=>21,'time'=>7570),array('wood'=>1015,'clay'=>730,'iron'=>845,'crop'=>450,'pop'=>2,'cp'=>17,'attri'=>24,'time'=>9080),array('wood'=>1295,'clay'=>935,'iron'=>1080,'crop'=>575,'pop'=>2,'cp'=>21,'attri'=>27,'time'=>10830),array('wood'=>1660,'clay'=>1200,'iron'=>1385,'crop'=>740,'pop'=>2,'cp'=>25,'attri'=>30,'time'=>12860),array('wood'=>2125,'clay'=>1535,'iron'=>1770,'crop'=>945,'pop'=>3,'cp'=>30,'attri'=>33,'time'=>15220),array('wood'=>2720,'clay'=>1965,'iron'=>2265,'crop'=>1210,'pop'=>3,'cp'=>36,'attri'=>36,'time'=>17950),array('wood'=>3480,'clay'=>2515,'iron'=>2900,'crop'=>1545,'pop'=>3,'cp'=>43,'attri'=>39,'time'=>21130), array('wood'=>4455,'clay'=>3220,'iron'=>3715,'crop'=>1980,'pop'=>3,'cp'=>51,'attri'=>42,'time'=>24810),array('wood'=>5705,'clay'=>4120,'iron'=>4755,'crop'=>2535,'pop'=>3,'cp'=>62,'attri'=>45,'time'=>29080),array('wood'=>7300,'clay'=>5275,'iron'=>6085,'crop'=>3245,'pop'=>3,'cp'=>74,'attri'=>48,'time'=>34030),array('wood'=>9345,'clay'=>6750,'iron'=>7790,'crop'=>4155,'pop'=>3,'cp'=>89,'attri'=>51,'time'=>39770),array('wood'=>11965,'clay'=>8640,'iron'=>9970,'crop'=>5315,'pop'=>3,'cp'=>106,'attri'=>54,'time'=>46440),array('wood'=>15315,'clay'=>11060,'iron'=>12760,'crop'=>6805,'pop'=>3,'cp'=>128,'attri'=>57,'time'=>54170),array('wood'=>19600,'clay'=>14155,'iron'=>16335,'crop'=>8710,'pop'=>3,'cp'=>153,'attri'=>60,'time'=>63130));
+$bid19=array(1=>array('wood'=>210,'clay'=>140,'iron'=>260,'crop'=>120,'pop'=>4,'cp'=>1,'attri'=>100,'time'=>2000),array('wood'=>270,'clay'=>180,'iron'=>335,'crop'=>155,'pop'=>2,'cp'=>1,'attri'=>90,'time'=>2620),array('wood'=>345,'clay'=>230,'iron'=>425,'crop'=>195,'pop'=>2,'cp'=>2,'attri'=>81,'time'=>3340),array('wood'=>440,'clay'=>295,'iron'=>545,'crop'=>250,'pop'=>2,'cp'=>2,'attri'=>72.9,'time'=>4170),array('wood'=>565,'clay'=>375,'iron'=>700,'crop'=>320,'pop'=>2,'cp'=>2,'attri'=>65.61,'time'=>5140),array('wood'=>720,'clay'=>480,'iron'=>895,'crop'=>410,'pop'=>3,'cp'=>3,'attri'=>59.05,'time'=>6260),array('wood'=>925,'clay'=>615,'iron'=>1145,'crop'=>530,'pop'=>3,'cp'=>4,'attri'=>53.14,'time'=>7570),array('wood'=>1180,'clay'=>790,'iron'=>1465,'crop'=>675,'pop'=>3,'cp'=>4,'attri'=>47.83,'time'=>9080),array('wood'=>1515,'clay'=>1010,'iron'=>1875,'crop'=>865,'pop'=>3,'cp'=>5,'attri'=>43.05,'time'=>10830),array('wood'=>1935,'clay'=>1290,'iron'=>2400,'crop'=>1105,'pop'=>3,'cp'=>6,'attri'=>38.74,'time'=>12860),array('wood'=>2480,'clay'=>1655,'iron'=>3070,'crop'=>1415,'pop'=>3,'cp'=>7,'attri'=>34.87,'time'=>15220),array('wood'=>3175,'clay'=>2115,'iron'=>3930,'crop'=>1815,'pop'=>3,'cp'=>9,'attri'=>31.38,'time'=>17950),array('wood'=>4060,'clay'=>2710,'iron'=>5030,'crop'=>2320,'pop'=>3,'cp'=>11,'attri'=>28.24,'time'=>21130),array('wood'=>5200,'clay'=>3465,'iron'=>6435,'crop'=>2970,'pop'=>3,'cp'=>13,'attri'=>25.42,'time'=>24810),array('wood'=>6655,'clay'=>4435,'iron'=>8240,'crop'=>3805,'pop'=>3,'cp'=>15,'attri'=>22.88,'time'=>29080),array('wood'=>8520,'clay'=>5680,'iron'=>10545,'crop'=>4870,'pop'=>4,'cp'=>18,'attri'=>20.59,'time'=>34030),array('wood'=>10905,'clay'=>7270,'iron'=>13500,'crop'=>6230,'pop'=>4,'cp'=>22,'attri'=>18.53,'time'=>39770),array('wood'=>13955,'clay'=>9305,'iron'=>17280,'crop'=>7975,'pop'=>4,'cp'=>27,'attri'=>16.68,'time'=>46440),array('wood'=>17865,'clay'=>11910,'iron'=>22120,'crop'=>10210,'pop'=>4,'cp'=>32,'attri'=>15.01,'time'=>54170),array('wood'=>22865,'clay'=>15245,'iron'=>28310,'crop'=>13065,'pop'=>4,'cp'=>38,'attri'=>13.51,'time'=>63130));
+$bid20=array(1=>array('wood'=>260,'clay'=>140,'iron'=>220,'crop'=>100,'pop'=>5,'cp'=>2,'attri'=>100,'time'=>2200),array('wood'=>335,'clay'=>180,'iron'=>280,'crop'=>130,'pop'=>3,'cp'=>3,'attri'=>90,'time'=>2850),array('wood'=>425,'clay'=>230,'iron'=>360,'crop'=>165,'pop'=>3,'cp'=>3,'attri'=>81,'time'=>3610),array('wood'=>545,'clay'=>295,'iron'=>460,'crop'=>210,'pop'=>3,'cp'=>4,'attri'=>72.9,'time'=>4490),array('wood'=>700,'clay'=>375,'iron'=>590,'crop'=>270,'pop'=>3,'cp'=>5,'attri'=>65.61,'time'=>5500),array('wood'=>895,'clay'=>480,'iron'=>755,'crop'=>345,'pop'=>3,'cp'=>6,'attri'=>59.05,'time'=>6680),array('wood'=>1145,'clay'=>615,'iron'=>970,'crop'=>440,'pop'=>3,'cp'=>7,'attri'=>53.14,'time'=>8050),array('wood'=>1465,'clay'=>790,'iron'=>1240,'crop'=>565,'pop'=>3,'cp'=>9,'attri'=>47.83,'time'=>9640),array('wood'=>1875,'clay'=>1010,'iron'=>1585,'crop'=>720,'pop'=>3,'cp'=>10,'attri'=>43.05,'time'=>11480),array('wood'=>2400,'clay'=>1290,'iron'=>2030,'crop'=>920,'pop'=>3,'cp'=>12,'attri'=>38.74,'time'=>13620),array('wood'=>3070,'clay'=>1655,'iron'=>2595,'crop'=>1180,'pop'=>4,'cp'=>15,'attri'=>34.87,'time'=>16100),array('wood'=>3930,'clay'=>2115,'iron'=>3325,'crop'=>1510,'pop'=>4,'cp'=>18,'attri'=>31.38,'time'=>18980),array('wood'=>5030,'clay'=>2710,'iron'=>4255,'crop'=>1935,'pop'=>4,'cp'=>21,'attri'=>28.24,'time'=>22310),array('wood'=>6435,'clay'=>3465,'iron'=>5445,'crop'=>2475,'pop'=>4,'cp'=>26,'attri'=>25.42,'time'=>26180),array('wood'=>8240,'clay'=>4435,'iron'=>6970,'crop'=>3170,'pop'=>4,'cp'=>31,'attri'=>22.88,'time'=>30670),array('wood'=>10545,'clay'=>5680,'iron'=>8925,'crop'=>4055,'pop'=>4,'cp'=>37,'attri'=>20.59,'time'=>35880),array('wood'=>13500,'clay'=>7270,'iron'=>11425,'crop'=>5190,'pop'=>4,'cp'=>44,'attri'=>18.53,'time'=>41920),array('wood'=>17280,'clay'=>9305,'iron'=>14620,'crop'=>6645,'pop'=>4,'cp'=>53,'attri'=>16.68,'time'=>48930),array('wood'=>22120,'clay'=>11910,'iron'=>18715,'crop'=>8505,'pop'=>4,'cp'=>64,'attri'=>15.01,'time'=>57060),array('wood'=>28310,'clay'=>15245,'iron'=>23955,'crop'=>10890,'pop'=>4,'cp'=>77,'attri'=>13.51,'time'=>66490));
+$bid21=array(1=>array('wood'=>460,'clay'=>510,'iron'=>600,'crop'=>320,'pop'=>3,'cp'=>4,'attri'=>100,'time'=>3000),array('wood'=>590,'clay'=>655,'iron'=>770,'crop'=>410,'pop'=>2,'cp'=>4,'attri'=>90,'time'=>3780),array('wood'=>755,'clay'=>835,'iron'=>985,'crop'=>525,'pop'=>2,'cp'=>5,'attri'=>81,'time'=>4680),array('wood'=>965,'clay'=>1070,'iron'=>1260,'crop'=>670,'pop'=>2,'cp'=>6,'attri'=>72.9,'time'=>5730),array('wood'=>1235,'clay'=>1370,'iron'=>1610,'crop'=>860,'pop'=>2,'cp'=>7,'attri'=>65.61,'time'=>6950),array('wood'=>1580,'clay'=>1750,'iron'=>2060,'crop'=>1100,'pop'=>2,'cp'=>9,'attri'=>59.05,'time'=>8360),array('wood'=>2025,'clay'=>2245,'iron'=>2640,'crop'=>1405,'pop'=>2,'cp'=>11,'attri'=>53.14,'time'=>10000),array('wood'=>2590,'clay'=>2870,'iron'=>3380,'crop'=>1800,'pop'=>2,'cp'=>13,'attri'=>47.83,'time'=>11900),array('wood'=>3315,'clay'=>3675,'iron'=>4325,'crop'=>2305,'pop'=>2,'cp'=>15,'attri'=>43.05,'time'=>14110),array('wood'=>4245,'clay'=>4705,'iron'=>5535,'crop'=>2950,'pop'=>2,'cp'=>19,'attri'=>38.74,'time'=>16660),array('wood'=>5430,'clay'=>6020,'iron'=>7085,'crop'=>3780,'pop'=>3,'cp'=>22,'attri'=>34.87,'time'=>19630),array('wood'=>6950,'clay'=>7705,'iron'=>9065,'crop'=>4835,'pop'=>3,'cp'=>27,'attri'=>31.38,'time'=>23070),array('wood'=>8900,'clay'=>9865,'iron'=>11605,'crop'=>6190,'pop'=>3,'cp'=>32,'attri'=>28.24,'time'=>27060),array('wood'=>11390,'clay'=>12625,'iron'=>14855,'crop'=>7925,'pop'=>3,'cp'=>39,'attri'=>25.42,'time'=>31690),array('wood'=>14580,'clay'=>16165,'iron'=>19015,'crop'=>10140,'pop'=>3,'cp'=>46,'attri'=>22.88,'time'=>37060),array('wood'=>18660,'clay'=>20690,'iron'=>24340,'crop'=>12980,'pop'=>3,'cp'=>55,'attri'=>20.59,'time'=>43290),array('wood'=>23885,'clay'=>26480,'iron'=>31155,'crop'=>16615,'pop'=>3,'cp'=>67,'attri'=>18.53,'time'=>50520),array('wood'=>30570,'clay'=>33895,'iron'=>39875,'crop'=>21270,'pop'=>3,'cp'=>80,'attri'=>16.68,'time'=>58900),array('wood'=>39130,'clay'=>43385,'iron'=>51040,'crop'=>27225,'pop'=>3,'cp'=>96,'attri'=>15.01,'time'=>68630),array('wood'=>50090,'clay'=>55535,'iron'=>65335,'crop'=>34845,'pop'=>3,'cp'=>115,'attri'=>13.51,'time'=>79910));
+$bid22=array(1=>array('wood'=>220,'clay'=>160,'iron'=>90,'crop'=>40,'pop'=>4,'cp'=>5,'attri'=>100,'time'=>2000),array('wood'=>280,'clay'=>205,'iron'=>115,'crop'=>50,'pop'=>2,'cp'=>6,'attri'=>96.4,'time'=>2620),array('wood'=>360,'clay'=>260,'iron'=>145,'crop'=>65,'pop'=>2,'cp'=>7,'attri'=>92.93,'time'=>3340),array('wood'=>460,'clay'=>335,'iron'=>190,'crop'=>85,'pop'=>2,'cp'=>8,'attri'=>89.58,'time'=>4170),array('wood'=>590,'clay'=>430,'iron'=>240,'crop'=>105,'pop'=>2,'cp'=>10,'attri'=>86.36,'time'=>5140),array('wood'=>755,'clay'=>550,'iron'=>310,'crop'=>135,'pop'=>3,'cp'=>12,'attri'=>83.25,'time'=>6260),array('wood'=>970,'clay'=>705,'iron'=>395,'crop'=>175,'pop'=>3,'cp'=>14,'attri'=>80.25,'time'=>7570),array('wood'=>1240,'clay'=>900,'iron'=>505,'crop'=>225,'pop'=>3,'cp'=>17,'attri'=>77.36,'time'=>9080),array('wood'=>1585,'clay'=>1155,'iron'=>650,'crop'=>290,'pop'=>3,'cp'=>21,'attri'=>74.58,'time'=>10830),array('wood'=>2030,'clay'=>1475,'iron'=>830,'crop'=>370,'pop'=>3,'cp'=>25,'attri'=>71.89,'time'=>12860),array('wood'=>2595,'clay'=>1890,'iron'=>1065,'crop'=>470,'pop'=>3,'cp'=>30,'attri'=>69.31,'time'=>15220),array('wood'=>3325,'clay'=>2420,'iron'=>1360,'crop'=>605,'pop'=>3,'cp'=>36,'attri'=>66.81,'time'=>17950),array('wood'=>4255,'clay'=>3095,'iron'=>1740,'crop'=>775,'pop'=>3,'cp'=>43,'attri'=>64.41,'time'=>21130),array('wood'=>5445,'clay'=>3960,'iron'=>2230,'crop'=>990,'pop'=>3,'cp'=>51,'attri'=>62.09,'time'=>24810),array('wood'=>6970,'clay'=>5070,'iron'=>2850,'crop'=>1270,'pop'=>3,'cp'=>62,'attri'=>59.85,'time'=>29080),array('wood'=>8925,'clay'=>6490,'iron'=>3650,'crop'=>1625,'pop'=>4,'cp'=>74,'attri'=>57.70,'time'=>34030),array('wood'=>11425,'clay'=>8310,'iron'=>4675,'crop'=>2075,'pop'=>4,'cp'=>89,'attri'=>55.62,'time'=>39770),array('wood'=>14620,'clay'=>10635,'iron'=>5980,'crop'=>2660,'pop'=>4,'cp'=>106,'attri'=>53.62,'time'=>46440),array('wood'=>18715,'clay'=>13610,'iron'=>7655,'crop'=>3405,'pop'=>4,'cp'=>128,'attri'=>51.69,'time'=>54170),array('wood'=>23955,'clay'=>17420,'iron'=>9800,'crop'=>4355,'pop'=>4,'cp'=>153,'attri'=>49.83,'time'=>0));
+$bid23=array(1=>array('wood'=>40,'clay'=>50,'iron'=>30,'crop'=>10,'pop'=>0,'cp'=>1,'attri'=>100,'time'=>750),array('wood'=>50,'clay'=>65,'iron'=>40,'crop'=>15,'pop'=>0,'cp'=>1,'attri'=>130,'time'=>1170),array('wood'=>65,'clay'=>80,'iron'=>50,'crop'=>15,'pop'=>0,'cp'=>2,'attri'=>170,'time'=>1660),array('wood'=>85,'clay'=>105,'iron'=>65,'crop'=>20,'pop'=>0,'cp'=>2,'attri'=>220,'time'=>2220),array('wood'=>105,'clay'=>135,'iron'=>80,'crop'=>25,'pop'=>0,'cp'=>2,'attri'=>280,'time'=>2880),array('wood'=>135,'clay'=>170,'iron'=>105,'crop'=>35,'pop'=>1,'cp'=>3,'attri'=>360,'time'=>3640),array('wood'=>175,'clay'=>220,'iron'=>130,'crop'=>45,'pop'=>1,'cp'=>4,'attri'=>460,'time'=>4520),array('wood'=>225,'clay'=>280,'iron'=>170,'crop'=>55,'pop'=>1,'cp'=>4,'attri'=>600,'time'=>5540),array('wood'=>290,'clay'=>360,'iron'=>215,'crop'=>70,'pop'=>1,'cp'=>5,'attri'=>770,'time'=>6730),array('wood'=>370,'clay'=>460,'iron'=>275,'crop'=>90,'pop'=>1,'cp'=>6,'attri'=>1000,'time'=>8110));
+$bid24=array(1=>array('wood'=>1250,'clay'=>1110,'iron'=>1260,'crop'=>600,'pop'=>4,'cp'=>6,'attri'=>100,'time'=>12500),array('wood'=>1600,'clay'=>1420,'iron'=>1615,'crop'=>770,'pop'=>2,'cp'=>7,'attri'=>96.4,'time'=>14800),array('wood'=>2050,'clay'=>1820,'iron'=>2065,'crop'=>985,'pop'=>2,'cp'=>9,'attri'=>0,'time'=>17470),array('wood'=>2620,'clay'=>2330,'iron'=>2640,'crop'=>1260,'pop'=>2,'cp'=>10,'attri'=>89.58,'time'=>20560),array('wood'=>3355,'clay'=>2980,'iron'=>3380,'crop'=>1610,'pop'=>2,'cp'=>12,'attri'=>92.93,'time'=>24150),array('wood'=>4295,'clay'=>3815,'iron'=>4330,'crop'=>2060,'pop'=>3,'cp'=>15,'attri'=>83.25,'time'=>28320),array('wood'=>5500,'clay'=>4880,'iron'=>5540,'crop'=>2640,'pop'=>3,'cp'=>18,'attri'=>86.36,'time'=>33150),array('wood'=>7035,'clay'=>6250,'iron'=>7095,'crop'=>3380,'pop'=>3,'cp'=>21,'attri'=>77.36,'time'=>38750),array('wood'=>9005,'clay'=>8000,'iron'=>9080,'crop'=>4325,'pop'=>3,'cp'=>26,'attri'=>80.25,'time'=>45250),array('wood'=>11530,'clay'=>10240,'iron'=>11620,'crop'=>5535,'pop'=>3,'cp'=>31,'attri'=>71.89,'time'=>52790),array('wood'=>14755,'clay'=>13105,'iron'=>14875,'crop'=>7085,'pop'=>3,'cp'=>37,'attri'=>74.58,'time'=>61540),array('wood'=>18890,'clay'=>16775,'iron'=>19040,'crop'=>9065,'pop'=>3,'cp'=>45,'attri'=>66.81,'time'=>71690),array('wood'=>24180,'clay'=>21470,'iron'=>24370,'crop'=>11605,'pop'=>3,'cp'=>53,'attri'=>69.31,'time'=>83460),array('wood'=>30950,'clay'=>27480,'iron'=>31195,'crop'=>14855,'pop'=>3,'cp'=>64,'attri'=>62.09,'time'=>97110),array('wood'=>39615,'clay'=>35175,'iron'=>39930,'crop'=>19015,'pop'=>3,'cp'=>77,'attri'=>64.41,'time'=>112950),array('wood'=>50705,'clay'=>45025,'iron'=>51110,'crop'=>24340,'pop'=>4,'cp'=>92,'attri'=>57.70,'time'=>131320),array('wood'=>64905,'clay'=>57635,'iron'=>65425,'crop'=>31155,'pop'=>4,'cp'=>111,'attri'=>59.85,'time'=>152630),array('wood'=>83075,'clay'=>73770,'iron'=>83740,'crop'=>39875,'pop'=>4,'cp'=>133,'attri'=>53.62,'time'=>177350),array('wood'=>106340,'clay'=>94430,'iron'=>107190,'crop'=>51040,'pop'=>4,'cp'=>160,'attri'=>55.62,'time'=>206020),array('wood'=>136115,'clay'=>120870,'iron'=>137200,'crop'=>65335,'pop'=>4,'cp'=>192,'attri'=>49.83,'time'=>239290));
+$bid25=array(1=>array('wood'=>580,'clay'=>460,'iron'=>350,'crop'=>180,'pop'=>1,'cp'=>2,'attri'=>100,'time'=>2000),array('wood'=>740,'clay'=>590,'iron'=>450,'crop'=>230,'pop'=>1,'cp'=>3,'attri'=>90,'time'=>2620),array('wood'=>950,'clay'=>755,'iron'=>575,'crop'=>295,'pop'=>1,'cp'=>3,'attri'=>81,'time'=>3340),array('wood'=>1215,'clay'=>965,'iron'=>735,'crop'=>375,'pop'=>1,'cp'=>4,'attri'=>72.9,'time'=>4170),array('wood'=>1555,'clay'=>1235,'iron'=>940,'crop'=>485,'pop'=>1,'cp'=>5,'attri'=>65.61,'time'=>5140),array('wood'=>1995,'clay'=>1580,'iron'=>1205,'crop'=>620,'pop'=>1,'cp'=>6,'attri'=>59.05,'time'=>6260),array('wood'=>2550,'clay'=>2025,'iron'=>1540,'crop'=>790,'pop'=>1,'cp'=>7,'attri'=>53.14,'time'=>7570),array('wood'=>3265,'clay'=>2590,'iron'=>1970,'crop'=>1015,'pop'=>1,'cp'=>9,'attri'=>47.83,'time'=>9080),array('wood'=>4180,'clay'=>3315,'iron'=>2520,'crop'=>1295,'pop'=>1,'cp'=>10,'attri'=>43.05,'time'=>10830),array('wood'=>5350,'clay'=>4245,'iron'=>3230,'crop'=>1660,'pop'=>1,'cp'=>12,'attri'=>38.74,'time'=>12860),array('wood'=>6845,'clay'=>5430,'iron'=>4130,'crop'=>2125,'pop'=>2,'cp'=>15,'attri'=>34.87,'time'=>15220),array('wood'=>8765,'clay'=>6950,'iron'=>5290,'crop'=>2720,'pop'=>2,'cp'=>18,'attri'=>31.38,'time'=>17950),array('wood'=>11220,'clay'=>8900,'iron'=>6770,'crop'=>3480,'pop'=>2,'cp'=>21,'attri'=>28.24,'time'=>21130),array('wood'=>14360,'clay'=>11390,'iron'=>8665,'crop'=>4455,'pop'=>2,'cp'=>26,'attri'=>25.42,'time'=>24810),array('wood'=>18380,'clay'=>14580,'iron'=>11090,'crop'=>5705,'pop'=>2,'cp'=>31,'attri'=>22.88,'time'=>29080),array('wood'=>23530,'clay'=>18660,'iron'=>14200,'crop'=>7300,'pop'=>2,'cp'=>37,'attri'=>20.59,'time'=>34030),array('wood'=>30115,'clay'=>23885,'iron'=>18175,'crop'=>9345,'pop'=>2,'cp'=>44,'attri'=>18.53,'time'=>39770),array('wood'=>38550,'clay'=>30570,'iron'=>23260,'crop'=>11965,'pop'=>2,'cp'=>53,'attri'=>16.68,'time'=>46440),array('wood'=>49340,'clay'=>39130,'iron'=>29775,'crop'=>15315,'pop'=>2,'cp'=>64,'attri'=>15.01,'time'=>54170),array('wood'=>63155,'clay'=>50090,'iron'=>38110,'crop'=>19600,'pop'=>2,'cp'=>77,'attri'=>13.51,'time'=>63130));
+$bid26=array(1=>array('wood'=>550,'clay'=>800,'iron'=>750,'crop'=>250,'pop'=>1,'cp'=>6,'attri'=>100,'time'=>5000),array('wood'=>705,'clay'=>1025,'iron'=>960,'crop'=>320,'pop'=>1,'cp'=>7,'attri'=>90,'time'=>6100),array('wood'=>900,'clay'=>1310,'iron'=>1230,'crop'=>410,'pop'=>1,'cp'=>9,'attri'=>81,'time'=>7380),array('wood'=>1155,'clay'=>1680,'iron'=>1575,'crop'=>525,'pop'=>1,'cp'=>10,'attri'=>72.9,'time'=>8860),array('wood'=>1475,'clay'=>2145,'iron'=>2015,'crop'=>670,'pop'=>1,'cp'=>12,'attri'=>65.61,'time'=>10570),array('wood'=>1890,'clay'=>2750,'iron'=>2575,'crop'=>860,'pop'=>1,'cp'=>15,'attri'=>59.05,'time'=>12560),array('wood'=>2420,'clay'=>3520,'iron'=>3300,'crop'=>1100,'pop'=>1,'cp'=>18,'attri'=>53.14,'time'=>14880),array('wood'=>3095,'clay'=>4505,'iron'=>4220,'crop'=>1405,'pop'=>1,'cp'=>21,'attri'=>47.83,'time'=>17560),array('wood'=>3965,'clay'=>5765,'iron'=>5405,'crop'=>1800,'pop'=>1,'cp'=>26,'attri'=>43.05,'time'=>20660),array('wood'=>5075,'clay'=>7380,'iron'=>6920,'crop'=>2305,'pop'=>1,'cp'=>31,'attri'=>38.74,'time'=>24270),array('wood'=>6495,'clay'=>9445,'iron'=>8855,'crop'=>2950,'pop'=>2,'cp'=>37,'attri'=>34.87,'time'=>28450),array('wood'=>8310,'clay'=>12090,'iron'=>11335,'crop'=>3780,'pop'=>2,'cp'=>45,'attri'=>31.38,'time'=>33310),array('wood'=>10640,'clay'=>15475,'iron'=>14505,'crop'=>4835,'pop'=>2,'y'=>6905,'iron'=>6505,'crop'=>2495,'pop'=>2,'cp'=>15,'attri'=>0,'time'=>16010),array('wood'=>9145,'clay'=>8700,'iron'=>8195,'crop'=>3145,'pop'=>3,'cp'=>18,'attri'=>0,'time'=>18870),array('wood'=>11525,'clay'=>10965,'iron'=>10325,'crop'=>3960,'pop'=>3,'cp'=>21,'attri'=>0,'time'=>22180),array('wood'=>14520,'clay'=>13815,'iron'=>13010,'crop'=>4990,'pop'=>3,'cp'=>26,'attri'=>0,'time'=>26030),array('wood'=>18295,'clay'=>17405,'iron'=>16390,'crop'=>6290,'pop'=>3,'cp'=>31,'attri'=>0,'time'=>30500),array('wood'=>23055,'clay'=>21930,'iron'=>20650,'crop'=>7925,'pop'=>3,'cp'=>37,'attri'=>1,'time'=>35680),array('wood'=>9045,'clay'=>27635,'iron'=>26020,'crop'=>9985,'pop'=>3,'cp'=>45,'attri'=>1,'time'=>41690),array('wood'=>6600,'clay'=>34820,'iron'=>32785,'crop'=>12580,'pop'=>3,'cp'=>53,'attri'=>1,'time'=>48660),array('wood'=>46115,'clay'=>43875,'iron'=>41310,'crop'=>15850,'pop'=>3,'cp'=>64,'attri'=>1,'time'=>56740),array('wood'=>58105,'clay'=>55280,'iron'=>52050,'crop'=>19975,'pop'=>3,'cp'=>77,'attri'=>1,'time'=>66120),array('wood'=>73210,'clay'=>69655,'iron'=>65585,'crop'=>25165,'pop'=>3,'cp'=>92,'attri'=>1,'time'=>77000),array('wood'=>92245,'clay'=>87760,'iron'=>82640,'crop'=>31710,'pop'=>4,'cp'=>111,'attri'=>1,'time'=>89620),array('wood'=>116230,'clay'=>110580,'iron'=>104125,'crop'=>39955,'pop'=>4,'cp'=>133,'attri'=>1,'time'=>104260),array('wood'=>146450,'clay'=>139330,'iron'=>131195,'crop'=>50340,'pop'=>4,'cp'=>160,'attri'=>1,'time'=>121240),array('wood'=>184530,'clay'=>175560,'iron'=>165305,'crop'=>63430,'pop'=>4,'cp'=>192,'attri'=>1,'time'=>140940),array('wood'=>232505,'clay'=>221205,'iron'=>208285,'crop'=>79925,'pop'=>4,'cp'=>230,'attri'=>1,'time'=>163790));
+$bid28=array(1=>array('wood'=>1400,'clay'=>1330,'iron'=>1200,'crop'=>400,'pop'=>3,'cp'=>4,'attri'=>110,'time'=>3000),array('wood'=>1790,'clay'=>1700,'iron'=>1535,'crop'=>510,'pop'=>2,'cp'=>4,'attri'=>120,'time'=>3780),array('wood'=>2295,'clay'=>2180,'iron'=>1965,'crop'=>655,'pop'=>2,'cp'=>5,'attri'=>130,'time'=>4680),array('wood'=>2935,'clay'=>2790,'iron'=>2515,'crop'=>840,'pop'=>2,'cp'=>6,'attri'=>140,'time'=>5730),array('wood'=>3760,'clay'=>3570,'iron'=>3220,'crop'=>1075,'pop'=>2,'cp'=>7,'attri'=>150,'time'=>6950),array('wood'=>4810,'clay'=>4570,'iron'=>4125,'crop'=>1375,'pop'=>2,'cp'=>9,'attri'=>160,'time'=>8360),array('wood'=>6155,'clay'=>5850,'iron'=>5280,'crop'=>1760,'pop'=>2,'cp'=>11,'attri'=>170,'time'=>10000),array('wood'=>7880,'clay'=>7485,'iron'=>6755,'crop'=>2250,'pop'=>2,'cp'=>13,'attri'=>180,'time'=>11900),array('wood'=>10090,'clay'=>9585,'iron'=>8645,'crop'=>2880,'pop'=>2,'cp'=>15,'attri'=>190,'time'=>14110),array('wood'=>12915,'clay'=>12265,'iron'=>11070,'crop'=>3690,'pop'=>2,'cp'=>19,'attri'=>200,'time'=>16660),array('wood'=>16530,'clay'=>15700,'iron'=>14165,'crop'=>4720,'pop'=>3,'cp'=>22,'attri'=>210,'time'=>19630),array('wood'=>21155,'clay'=>20100,'iron'=>18135,'crop'=>6045,'pop'=>3,'cp'=>27,'attri'=>220,'time'=>23070),array('wood'=>27080,'clay'=>25725,'iron'=>23210,'crop'=>7735,'pop'=>3,'cp'=>32,'attri'=>230,'time'=>27060),array('wood'=>4660,'clay'=>32930,'iron'=>29710,'crop'=>9905,'pop'=>3,'cp'=>39,'attri'=>240,'time'=>31690),array('wood'=>44370,'clay'=>42150,'iron'=>38030,'crop'=>12675,'pop'=>3,'cp'=>46,'attri'=>250,'time'=>37060),array('wood'=>56790,'clay'=>53950,'iron'=>48680,'crop'=>16225,'pop'=>3,'cp'=>55,'attri'=>260,'time'=>43290),array('wood'=>72690,'clay'=>69060,'iron'=>62310,'crop'=>20770,'pop'=>3,'cp'=>67,'attri'=>270,'time'=>50520),array('wood'=>93045,'clay'=>88395,'iron'=>79755,'crop'=>26585,'pop'=>3,'cp'=>80,'attri'=>280,'time'=>58900),array('wood'=>119100,'clay'=>113145,'iron'=>102085,'crop'=>34030,'pop'=>3,'cp'=>96,'attri'=>290,'time'=>68630),array('wood'=>152445,'clay'=>144825,'iron'=>130670,'crop'=>43555,'pop'=>3,'cp'=>115,'attri'=>300,'time'=>79910));
+$bid29=array(1=>array('wood'=>630,'clay'=>420,'iron'=>780,'crop'=>360,'pop'=>4,'cp'=>1,'attri'=>100,'time'=>2000),array('wood'=>805,'clay'=>540,'iron'=>1000,'crop'=>460,'pop'=>2,'cp'=>1,'attri'=>90,'time'=>2620),array('wood'=>1030,'clay'=>690,'iron'=>1280,'crop'=>590,'pop'=>2,'cp'=>2,'airon'=>11785,'crop'=>5440,'pop'=>3,'cp'=>9,'attri'=>31.38,'time'=>17950),array('wood'=>12185,'clay'=>8125,'iron'=>15085,'crop'=>6965,'pop'=>3,'cp'=>11,'attri'=>28.24,'time'=>21130),array('wood'=>15600,'clay'=>10400,'iron'=>19310,'crop'=>8915,'pop'=>3,'cp'=>13,'attri'=>25.42,'time'=>24810),array('wood'=>19965,'clay'=>13310,'iron'=>24720,'crop'=>11410,'pop'=>3,'cp'=>15,'attri'=>22.88,'time'=>29080),array('wood'=>25555,'clay'=>17035,'iron'=>31640,'crop'=>14605,'pop'=>4,'cp'=>18,'attri'=>20.59,'time'=>34030),array('wood'=>32710,'clay'=>21810,'iron'=>40500,'crop'=>18690,'pop'=>4,'cp'=>22,'attri'=>18.53,'time'=>39770),array('wood'=>41870,'clay'=>27915,'iron'=>51840,'crop'=>23925,'pop'=>4,'cp'=>27,'attri'=>16.68,'time'=>46440),array('wood'=>53595,'clay'=>35730,'iron'=>66355,'crop'=>30625,'pop'=>4,'cp'=>32,'attri'=>15.01,'time'=>54170),array('wood'=>68600,'clay'=>45735,'iron'=>84935,'crop'=>39200,'pop'=>4,'cp'=>38,'attri'=>13.51,'time'=>63130));
+$bid30=array(1=>array('wood'=>780,'clay'=>420,'iron'=>660,'crop'=>300,'pop'=>5,'cp'=>2,'attri'=>100,'time'=>2200),array('wood'=>1000,'clay'=>540,'iron'=>845,'crop'=>385,'pop'=>3,'cp'=>3,'attri'=>90,'time'=>2850),array('wood'=>1280,'clay'=>690,'iron'=>1080,'crop'=>490,'pop'=>3,'cp'=>3,'attri'=>81,'time'=>3610),array('wood'=>1635,'clay'=>880,'iron'=>1385,'crop'=>630,'pop'=>3,'cp'=>4,'attri'=>72.9,'time'=>4490),array('wood'=>2095,'clay'=>1125,'iron'=>1770,'crop'=>805,'pop'=>3,'cp'=>5,'attri'=>65.61,'time'=>5500),array('wood'=>2680,'clay'=>1445,'iron'=>2270,'crop'=>1030,'pop'=>3,'cp'=>6,'attri'=>59.05,'time'=>6680),array('wood'=>3430,'clay'=>1845,'iron'=>2905,'crop'=>1320,'pop'=>3,'cp'=>7,'attri'=>53.14,'time'=>8050),array('wood'=>4390,'clay'=>2365,'iron'=>3715,'crop'=>1690,'pop'=>3,'cp'=>9,'attri'=>47.83,'time'=>9640),array('wood'=>5620,'clay'=>3025,'iron'=>4755,'crop'=>2160,'pop'=>3,'cp'=>10,'attri'=>43.05,'time'=>11480),array('wood'=>7195,'clay'=>3875,'iron'=>6085,'crop'=>2765,'pop'=>3,'cp'=>12,'attri'=>38.74,'time'=>13620),array('wood'=>9210,'clay'=>4960,'iron'=>7790,'crop'=>3540,'pop'=>4,'cp'=>15,'attri'=>34.87,'time'=>16100),array('wood'=>11785,'clay'=>6345,'iron'=>9975,'crop'=>4535,'pop'=>4,'cp'=>18,'attri'=>31.38,'time'=>18980),array('wood'=>15085,'clay'=>8125,'iron'=>12765,'crop'=>5805,'pop'=>4,'cp'=>21,'attri'=>28.24,'time'=>22310),array('wood'=>19310,'clay'=>10400,'iron'=>16340,'crop'=>7430,'pop'=>4,'cp'=>26,'attri'=>25.42,'time'=>26180),array('wood'=>24720,'clay'=>13310,'iron'=>20915,'crop'=>9505,'pop'=>4,'cp'=>31,'attri'=>22.88,'time'=>30670),array('wood'=>31640,'clay'=>17035,'iron'=>26775,'crop'=>12170,'pop'=>4,'cp'=>37,'attri'=>20.59,'time'=>35880),array('wood'=>40500,'clay'=>21810,'iron'=>34270,'crop'=>15575,'pop'=>4,'cp'=>44,'attri'=>18.53,'time'=>41920),array('wood'=>51840,'clay'=>27915,'iron'=>43865,'crop'=>19940,'pop'=>4,'cp'=>53,'attri'=>16.68,'time'=>48930),array('wood'=>66355,'clay'=>35730,'iron'=>56145,'crop'=>25520,'pop'=>4,'cp'=>64,'attri'=>15.01,'time'=>57060),array('wood'=>84935,'clay'=>45735,'iron'=>71870,'crop'=>32665,'pop'=>4,'cp'=>77,'attri'=>13.51,'time'=>66490));
+$bid31=array(1=>array('wood'=>70,'clay'=>90,'iron'=>170,'crop'=>70,'pop'=>0,'cp'=>1,'attri'=>3,'time'=>2000),array('wood'=>90,'clay'=>115,'iron'=>220,'crop'=>90,'pop'=>0,'cp'=>1,'attri'=>6,'time'=>2620),array('wood'=>115,'clay'=>145,'iron'=>280,'crop'=>115,'pop'=>0,'cp'=>2,'attri'=>9,'time'=>3340),array('wood'=>145,'clay'=>190,'iron'=>355,'crop'=>145,'pop'=>0,'cp'=>2,'attri'=>13,'time'=>4170),array('wood'=>190,'clay'=>240,'iron'=>455,'crop'=>190,'pop'=>0,'cp'=>2,'attri'=>16,'time'=>5140),array('wood'=>240,'clay'=>310,'iron'=>585,'crop'=>240,'pop'=>1,'cp'=>3,'attri'=>19,'time'=>6260),array('wood'=>310,'clay'=>395,'iron'=>750,'crop'=>310,'pop'=>1,'cp'=>4,'attri'=>23,'time'=>7570),array('wood'=>395,'clay'=>505,'iron'=>955,'crop'=>395,'pop'=>1,'cp'=>4,'attri'=>27,'time'=>9080),array('wood'=>505,'clay'=>650,'iron'=>1225,'crop'=>505,'pop'=>1,'cp'=>5,'attri'=>30,'time'=>10830),array('wood'=>645,'clay'=>830,'iron'=>1570,'crop'=>645,'pop'=>1,'cp'=>6,'attri'=>34,'time'=>12860),array('wood'=>825,'clay'=>1065,'lay'=>7655,'iron'=>14460,'crop'=>5955,'pop'=>2,'cp'=>32,'attri'=>75,'time'=>54170),array('wood'=>7620,'clay'=>9800,'iron'=>18510,'crop'=>7620,'pop'=>2,'cp'=>38,'attri'=>81,'time'=>63130));
+$bid32=array(1=>array('wood'=>120,'clay'=>200,'iron'=>0,'crop'=>80,'pop'=>0,'cp'=>1,'attri'=>2,'time'=>2000),array('wood'=>155,'clay'=>255,'iron'=>0,'crop'=>100,'pop'=>0,'cp'=>1,'attri'=>4,'time'=>2620),array('wood'=>195,'clay'=>330,'iron'=>0,'crop'=>130,'pop'=>0,'cp'=>2,'attri'=>6,'time'=>3340),array('wood'=>250,'clay'=>420,'iron'=>0,'crop'=>170,'pop'=>0,'cp'=>2,'attri'=>8,'time'=>4170),array('wood'=>320,'clay'=>535,'iron'=>0,'crop'=>215,'pop'=>0,'cp'=>2,'attri'=>10,'time'=>5140),array('wood'=>410,'clay'=>685,'iron'=>0,'crop'=>275,'pop'=>1,'cp'=>3,'attri'=>13,'time'=>6260),array('wood'=>530,'clay'=>880,'iron'=>0,'crop'=>350,'pop'=>1,'cp'=>4,'attri'=>15,'time'=>7570),array('wood'=>675,'clay'=>1125,'iron'=>0,'crop'=>450,'pop'=>1,'cp'=>4,'attri'=>17,'time'=>9080),array('wood'=>865,'clay'=>1440,'iron'=>0,'crop'=>575,'pop'=>1,'cp'=>5,'attri'=>20,'time'=>10830),array('wood'=>1105,'clay'=>1845,'iron'=>0,'crop'=>740,'pop'=>1,'cp'=>6,'attri'=>22,'time'=>12860),array('wood'=>1415,'clay'=>2360,'iron'=>0,'crop'=>945,'pop'=>1,'cp'=>7,'attri'=>24,'time'=>15220),array('wood'=>1815,'clay'=>3020,'iron'=>0,'crop'=>1210,'pop'=>1,'cp'=>9,'attri'=>27,'time'=>17950),array('wood'=>2320,'clay'=>3870,'iron'=>0,'crop'=>1545,'pop'=>1,'cp'=>11,'attri'=>29,'time'=>21130),array('wood'=>2970,'clay'=>4950,'iron'=>0,'crop'=>1980,'pop'=>1,'cp'=>13,'attri'=>32,'time'=>24810),array('wood'=>3805,'clay'=>6340,'iron'=>0,'crop'=>2535,'pop'=>1,'cp'=>15,'attri'=>35,'time'=>29080),array('wood'=>4870,'clay'=>8115,'iron'=>0,'crop'=>3245,'pop'=>2,'cp'=>18,'attri'=>37,'time'=>34030),array('wood'=>6230,'clay'=>10385,'iron'=>0,'crop'=>4155,'pop'=>2,'cp'=>22,'attri'=>40,'time'=>39770),array('wood'=>7975,'clay'=>13290,'iron'=>0,'crop'=>5315,'pop'=>2,'cp'=>27,'attri'=>43,'time'=>46440),array('wood'=>10210,'clay'=>17015,'iron'=>0,'crop'=>6805,'pop'=>2,'cp'=>32,'attri'=>46,'time'=>54170),array('wood'=>13065,'clay'=>21780,'iron'=>0,'crop'=>8710,'pop'=>2,'cp'=>38,'attri'=>49,'time'=>63130));
+$bid33=array(1=>array('wood'=>160,'clay'=>100,'iron'=>80,'crop'=>60,'pop'=>0,'cp'=>1,'attri'=>2,'time'=>2000),array('wood'=>205,'clay'=>130,'iron'=>100,'crop'=>75,'pop'=>0,'cp'=>1,'attri'=>5,'time'=>2620),array('wood'=>260,'clay'=>165,'iron'=>130,'crop'=>100,'pop'=>0,'cp'=>2,'attri'=>8,'time'=>3340),array('wood'=>335,'clay'=>210,'iron'=>170,'crop'=>125,'pop'=>0,'cp'=>2,'attri'=>10,'time'=>4170),array('wood'=>430,'clay'=>270,'iron'=>215,'crop'=>160,'pop'=>0,'cp'=>2,'attri'=>13,'time'=>5140),array('wood'=>550,'clay'=>345,'iron'=>275,'crop'=>205,'pop'=>1,'cp'=>3,'attri'=>16,'time'=>6260),array('wood'=>705,'clay'=>440,'iron'=>350,'crop'=>265,'pop'=>1,'cp'=>4,'attri'=>19,'time'=>7570),array('wood'=>900,'clay'=>565,'iron'=>450,'crop'=>340,'pop'=>1,'cp'=>4,'attri'=>22,'time'=>9080),array('wood'=>1155,'clay'=>720,'iron'=>575,'crop'=>430,'pop'=>1,'cp'=>5,'attri'=>25,'time'=>10830),array('wood'=>1475,'clay'=>920,'iron'=>740,'crop'=>555,'pop'=>1,'cp'=>6,'attri'=>28,'time'=>12860),array('wood'=>1890,'clay'=>1180,'iron'=>945,'crop'=>710,'pop'=>1,'cp'=>7,'attri'=>31,'time'=>15220),array('wood'=>2420,'clay'=>1510,'iron'=>1210,'crop'=>905,'pop'=>1,'cp'=>9,'attri'=>34,'time'=>17950),array('wood'=>3095,'clay'=>1935,'iron'=>1545,'crop'=>1160,'pop'=>1,'cp'=>11,'attri'=>38,'time'=>21130),array('wood'=>3960,'clay'=>2475,'iron'=>1980,'crop'=>1485,'pop'=>1,'cp'=>13,'attri'=>41,'time'=>24810),array('wood'=>5070,'clay'=>3170,'iron'=>2535,'crop'=>1900,'pop'=>1,'cp'=>15,'attri'=>45,'time'=>29080),array('wood'=>6490,'clay'=>4055,'iron'=>3245,'crop'=>2435,'pop'=>2,'cp'=>18,'attri'=>48,'time'=>34030),array('wood'=>8310,'clay'=>5190,'iron'=>4155,'crop'=>3115,'pop'=>2,'cp'=>22,'attri'=>52,'time'=>39770),array('wood'=>10635,'clay'=>6645,'iron'=>5315,'crop'=>3990,'pop'=>2,'cp'=>27,'attri'=>56,'time'=>46440),array('wood'=>13610,'clay'=>8505,'iron'=>6805,'crop'=>5105,'pop'=>2,'cp'=>32,'attri'=>60,'time'=>54170),array('wood'=>17420,'clay'=>10890,'iron'=>8710,'crop'=>6535,'pop'=>2,'cp'=>38,'attri'=>64,'time'=>63130));
+$bid34=array(1=>array('wood'=>155,'clay'=>130,'iron'=>125,'crop'=>70,'pop'=>2,'cp'=>1,'attri'=>110,'time'=>2200),array('wood'=>200,'clay'=>165,'iron'=>160,'crop'=>90,'pop'=>1,'cp'=>1,'attri'=>120,'time'=>3150),array('wood'=>255,'clay'=>215,'iron'=>205,'crop'=>115,'pop'=>1,'cp'=>2,'attri'=>130,'time'=>4260),array('wood'=>325,'clay'=>275,'iron'=>260,'crop'=>145,'pop'=>1,'cp'=>2,'attri'=>140,'time'=>5540),array('wood'=>415,'clay'=>350,'iron'=>335,'crop'=>190,'pop'=>1,'cp'=>2,'attri'=>150,'time'=>7020),array('wood'=>535,'clay'=>445,'iron'=>430,'crop'=>240,'pop'=>2,'cp'=>3,'attri'=>160,'time'=>8750),array('wood'=>680,'clay'=>570,'iron'=>550,'crop'=>310,'pop'=>2,'cp'=>4,'attri'=>170,'time'=>10750),array('wood'=>875,'clay'=>730,'iron'=>705,'crop'=>395,'pop'=>2,'cp'=>4,'attri'=>180,'time'=>13070),array('wood'=>1115,'clay'=>935,'iron'=>900,'crop'=>505,'pop'=>2,'cp'=>5,'attri'=>190,'time'=>15760),array('wood'=>1430,'clay'=>1200,'iron'=>1155,'crop'=>645,'pop'=>2,'cp'=>6,'attri'=>200,'time'=>18880),array('wood'=>1830,'clay'=>1535,'iron'=>1475,'crop'=>825,'pop'=>2,'cp'=>7,'attri'=>210,'time'=>22500),array('wood'=>2340,'clay'=>1965,'iron'=>1890,'crop'=>1060,'pop'=>2,'cp'=>9,'attri'=>220,'time'=>26700),array('wood'=>3000,'clay'=>2515,'iron'=>2420,'crop'=>1355,'pop'=>2,'cp'=>11,'attri'=>230,'time'=>31570),array('wood'=>3840,'clay'=>3220,'iron'=>3095,'crop'=>1735,'pop'=>2,'cp'=>13,'attri'=>240,'time'=>37220),array('wood'=>4910,'clay'=>4120,'iron'=>3960,'crop'=>2220,'pop'=>2,'cp'=>15,'attri'=>250,'time'=>43780),array('wood'=>6290,'clay'=>5275,'iron'=>5070,'crop'=>2840,'pop'=>3,'cp'=>18,'attri'=>260,'time'=>51380),array('wood'=>8050,'clay'=>6750,'iron'=>6490,'crop'=>3635,'pop'=>3,'cp'=>22,'attri'=>270,'time'=>60200),array('wood'=>10300,'clay'=>8640,'iron'=>8310,'crop'=>4650,'pop'=>3,'cp'=>27,'attri'=>280,'time'=>70430),array('wood'=>13185,'clay'=>11060,'iron'=>10635,'crop'=>5955,'pop'=>3,'cp'=>32,'attri'=>290,'time'=>82300),array('wood'=>16880,'clay'=>14155,'iron'=>13610,'crop'=>7620,'pop'=>3,'cp'=>38,'attri'=>300,'time'=>96070));
+$bid35=array(1=>array('wood'=>1460,'clay'=>930,'iron'=>1250,'crop'=>1740,'pop'=>6,'cp'=>5,'attri'=>0,'time'=>8000),array('wood'=>2045,'clay'=>1300,'iron'=>1750,'crop'=>2435,'pop'=>3,'cp'=>6,'attri'=>0,'time'=>9880),array('wood'=>2860,'clay'=>1825,'iron'=>2450,'crop'=>3410,'pop'=>3,'cp'=>7,'attri'=>0,'time'=>12060),array('wood'=>4005,'clay'=>2550,'iron'=>3430,'crop'=>4775,'pop'=>3,'cp'=>8,'attri'=>0,'time'=>14590),array('wood'=>5610,'clay'=>3575,'iron'=>4800,'crop'=>6685,'pop'=>3,'cp'=>10,'attri'=>0,'time'=>17530),array('wood'=>7850,'clay'=>5000,'iron'=>6725,'crop'=>9360,'pop'=>4,'cp'=>12,'attri'=>0,'time'=>20930),array('wood'=>10995,'clay'=>7000,'iron'=>9410,'crop'=>13100,'pop'=>4,'cp'=>14,'attri'=>0,'time'=>24880),array('wood'=>15390,'clay'=>9805,'iron'=>13175,'crop'=>18340,'pop'=>4,'cp'=>17,'attri'=>0,'time'=>29460),array('wood'=>21545,'clay'=>13725,'iron'=>18445,'crop'=>25680,'pop'=>4,'cp'=>21,'attri'=>0,'time'=>34770),array('wood'=>30165,'clay'=>19215,'iron'=>25825,'crop'=>35950,'pop'=>4,'cp'=>25,'attri'=>0,'time'=>40930));
+$bid36=array(1=>array('wood'=>100,'clay'=>100,'iron'=>100,'crop'=>100,'pop'=>4,'cp'=>1,'attri'=>10,'time'=>2000),array('wood'=>130,'clay'=>130,'iron'=>130,'crop'=>130,'pop'=>2,'cp'=>1,'attri'=>22,'time'=>2320),array('wood'=>165,'clay'=>165,'iron'=>165,'crop'=>165,'pop'=>2,'cp'=>2,'attri'=>35,'time'=>2690),array('wood'=>210,'clay'=>210,'iron'=>210,'crop'=>210,'pop'=>2,'cp'=>2,'attri'=>49,'time'=>3120),array('wood'=>270,'clay'=>270,'iron'=>270,'crop'=>270,'pop'=>2,'cp'=>2,'attri'=>64,'time'=>3620),array('wood'=>345,'clay'=>345,'iron'=>345,'crop'=>345,'pop'=>3,'cp'=>3,'attri'=>80,'time'=>4200),array('wood'=>440,'clay'=>440,'iron'=>440,'crop'=>440,'pop'=>3,'cp'=>4,'attri'=>97,'time'=>4870),array('wood'=>565,'clay'=>565,'iron'=>565,'crop'=>565,'pop'=>3,'cp'=>4,'attri'=>115,'time'=>5650),array('wood'=>720,'clay'=>720,'iron'=>720,'crop'=>720,'pop'=>3,'cp'=>5,'attri'=>134,'time'=>6560),array('wood'=>920,'clay'=>920,'iron'=>920,'crop'=>920,'pop'=>3,'cp'=>6,'attri'=>154,'time'=>7610),array('wood'=>1180,'clay'=>1180,'iron'=>1180,'crop'=>1180,'pop'=>3,'cp'=>7,'attri'=>175,'time'=>8820),array('wood'=>1510,'clay'=>1510,'iron'=>1510,'crop'=>1510,'pop'=>3,'cp'=>9,'attri'=>196,'time'=>10230),array('wood'=>1935,'clay'=>1935,'iron'=>1935,'crop'=>1935,'pop'=>3,'cp'=>11,'attri'=>218,'time'=>11870),array('wood'=>2475,'clay'=>2475,'iron'=>2475,'crop'=>2475,'pop'=>3,'cp'=>13,'attri'=>241,'time'=>13770),array('wood'=>3170,'clay'=>3170,'iron'=>3170,'crop'=>3170,'pop'=>3,'cp'=>15,'attri'=>265,'time'=>15980),array('wood'=>4055,'clay'=>4055,'ircrop'=>240,'pop'=>2,'cp'=>1,'attri'=>0,'time'=>2300),array('wood'=>930,'clay'=>890,'iron'=>930,'crop'=>320,'pop'=>1,'cp'=>1,'attri'=>0,'time'=>2670),array('wood'=>1240,'clay'=>1185,'iron'=>1240,'crop'=>425,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>3090),array('wood'=>1645,'clay'=>1575,'iron'=>1645,'crop'=>565,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>3590),array('wood'=>2190,'clay'=>2095,'iron'=>2190,'crop'=>750,'pop'=>1,'cp'=>2,'attri'=>0,'time'=>4160),array('wood'=>2915,'clay'=>2790,'iron'=>2915,'crop'=>1000,'pop'=>2,'cp'=>3,'attri'=>0,'time'=>4830),array('wood'=>3875,'clay'=>3710,'iron'=>3875,'crop'=>1330,'pop'=>2,'cp'=>4,'attri'=>0,'time'=>5600),array('wood'=>5155,'clay'=>4930,'iron'=>5155,'crop'=>1765,'pop'=>2,'cp'=>4,'attri'=>0,'time'=>6500),array('wood'=>6855,'clay'=>6560,'iron'=>6855,'crop'=>2350,'pop'=>2,'cp'=>5,'attri'=>0,'time'=>7540),array('wood'=>9115,'clay'=>8725,'iron'=>9115,'crop'=>3125,'pop'=>2,'cp'=>6,'attri'=>1,'time'=>8750),array('wood'=>12125,'clay'=>11605,'iron'=>12125,'crop'=>4155,'pop'=>2,'cp'=>7,'attri'=>1,'time'=>10150),array('wood'=>16125,'clay'=>15435,'iron'=>16125,'crop'=>5530,'pop'=>2,'cp'=>9,'attri'=>1,'time'=>11770),array('wood'=>21445,'clay'=>20525,'iron'=>21445,'crop'=>7350,'pop'=>2,'cp'=>11,'attri'=>1,'time'=>13650),array('wood'=>28520,'clay'=>27300,'iron'=>28520,'crop'=>9780,'pop'=>2,'cp'=>13,'attri'=>1,'time'=>15840),array('wood'=>37935,'clay'=>36310,'iron'=>37935,'crop'=>13005,'pop'=>2,'cp'=>15,'attri'=>2,'time'=>18370),array('wood'=>50450,'clay'=>48290,'iron'=>50450,'crop'=>17300,'pop'=>3,'cp'=>18,'attri'=>2,'time'=>21310),array('wood'=>67100,'clay'=>64225,'iron'=>67100,'crop'=>23005,'pop'=>3,'cp'=>22,'attri'=>2,'time'=>24720),array('wood'=>89245,'clay'=>85420,'iron'=>89245,'crop'=>30600,'pop'=>3,'cp'=>27,'attri'=>2,'time'=>28680),array('wood'=>118695,'clay'=>113605,'iron'=>118695,'crop'=>40695,'pop'=>3,'cp'=>32,'attri'=>2,'time'=>33260),array('wood'=>157865,'clay'=>151095,'iron'=>157865,'crop'=>54125,'pop'=>3,'cp'=>38,'attri'=>3,'time'=>38590));
+$bid38=array(1=>array('wood'=>650,'clay'=>800,'iron'=>450,'crop'=>200,'pop'=>1,'cp'=>1,'attri'=>3600,'time'=>9000),array('wood'=>830,'clay'=>1025,'iron'=>575,'crop'=>255,'pop'=>1,'cp'=>1,'attri'=>5100,'time'=>10740),array('wood'=>1065,'clay'=>1310,'iron'=>735,'crop'=>330,'pop'=>1,'cp'=>2,'attri'=>6900,'time'=>12760),array('wood'=>1365,'clay'=>1680,'iron'=>945,'crop'=>420,'pop'=>1,'cp'=>2,'attri'=>9300,'time'=>15100),array('wood'=>1745,'clay'=>2145,'iron'=>1210,'crop'=>535,'pop'=>1,'cp'=>2,'attri'=>12000,'time'=>17820),array('wood'=>2235,'clay'=>2750,'iron'=>1545,'crop'=>685,'pop'=>1,'cp'=>3,'attri'=>15000,'time'=>20970),array('wood'=>2860,'clay'=>3520,'iron'=>1980,'crop'=>880,'pop'=>1,'cp'=>4,'attri'=>18900,'time'=>24620),array('wood'=>3660,'clay'=>4505,'iron'=>2535,'crop'=>1125,'pop'=>1,'cp'=>4,'attri'=>23400,'time'=>28860),array('wood'=>4685,'clay'=>5765,'iron'=>3245,'crop'=>1440,'pop'=>1,'cp'=>5,'attri'=>28800,'time'=>33780),array('wood'=>5995,'clay'=>7380,'iron'=>4150,'crop'=>1845,'pop'=>1,'cp'=>6,'attri'=>35400,'time'=>39480),array('wood'=>7675,'clay'=>9445,'iron'=>5315,'crop'=>2360,'pop'=>2,'cp'=>7,'attri'=>43200,'time'=>46100),array('wood'=>9825,'clay'=>12090,'iron'=>6800,'crop'=>3020,'pop'=>2,'cp'=>9,'attri'=>52800,'time'=>53780),array('wood'=>12575,'clay'=>15475,'iron'=>8705,'crop'=>3870,'pop'=>2,'cp'=>11,'attri'=>64200,'time'=>62680),array('wood'=>16095,'clay'=>19805,'iron'=>11140,'crop'=>4950,'pop'=>2,'cp'=>13,'attri'=>77700,'time'=>73010),array('wood'=>20600,'clay'=>25355,'iron'=>14260,'crop'=>6340,'pop'=>2,'cp'=>15,'attri'=>93900,'time'=>84990),array('wood'=>26365,'clay'=>32450,'iron'=>18255,'crop'=>8115,'pop'=>2,'cp'=>18,'attri'=>113700,'time'=>98890),array('wood'=>33750,'clay'=>41540,'iron'=>23365,'crop'=>10385,'pop'=>2,'cp'=>22,'attri'=>137100,'time'=>115010),array('wood'=>43200,'clay'=>53170,'iron'=>29910,'crop'=>13290,'pop'=>2,'cp'=>27,'attri'=>165300,'time'=>133710),array('wood'=>55295,'clay'=>68055,'iron'=>38280,'crop'=>17015,'pop'=>2,'cp'=>32,'attri'=>199200,'time'=>155400),array('wood'=>70780,'clay'=>87110,'iron'=>49000,'crop'=>21780,'pop'=>2,'cp'=>38,'attri'=>240000,'time'=>180570));
+$bid39=array(1=>array('wood'=>400,'clay'=>500,'iron'=>350,'crop'=>100,'pop'=>1,'cp'=>1,'attri'=>3600,'time'=>7000),array('wood'=>510,'clay'=>640,'iron'=>450,'crop'=>130,'pop'=>1,'cp'=>1,'attri'=>5100,'time'=>8420),array('wood'=>655,'clay'=>820,'iron'=>575,'crop'=>165,'pop'=>1,'cp'=>2,'attri'=>6900,'time'=>10070),array('wood'=>840,'clay'=>1050,'iron'=>735,'crop'=>210,'pop'=>1,'cp'=>2,'attri'=>9300,'time'=>11980),array('wood'=>1075,'clay'=>1340,'iron'=>940,'crop'=>270,'pop'=>1,'cp'=>2,'attri'=>12000,'time'=>14190),array('wood'=>1375,'clay'=>1720,'iron'=>1205,'crop'=>345,'pop'=>1,'cp'=>3,'attri'=>15000,'time'=>16770),array('wood'=>1760,'clay'=>2200,'iron'=>1540,'crop'=>440,'pop'=>1,'cp'=>4,'attri'=>18900,'time'=>19750),array('wood'=>2250,'clay'=>2815,'iron'=>1970,'crop'=>565,'pop'=>1,'cp'=>4,'attri'=>23400,'time'=>23210),array('wood'=>2880,'clay'=>3605,'iron'=>2520,'crop'=>720,'pop'=>1,'cp'=>5,'attri'=>28800,'time'=>27220),array('wood'=>3690,'clay'=>4610,'iron'=>3230,'crop'=>920,'pop'=>1,'cp'=>6,'attri'=>35400,'time'=>31880),array('wood'=>4720,'clay'=>5905,'iron'=>4130,'crop'=>1180,'pop'=>2,'cp'=>7,'attri'=>43200,'time'=>37280),array('wood'=>6045,'clay'=>7555,'iron'=>5290,'crop'=>1510,'pop'=>2,'cp'=>9,'attri'=>52800,'time'=>43540),array('wood'=>7735,'clay'=>9670,'iron'=>6770,'crop'=>1935,'pop'=>2,'cp'=>11,'attri'=>64200,'time'=>50810),array('wood'=>9905,'clay'=>12380,'iron'=>8665,'crop'=>2475,'pop'=>2,'cp'=>13,'attri'=>77700,'time'=>59240),array('wood'=>12675,'clay'=>15845,'iron'=>11090,'crop'=>3170,'pop'=>2,'cp'=>15,'attri'=>93900,'time'=>69010),array('wood'=>16225,'clay'=>20280,'iron'=>14200,'crop'=>4055,'pop'=>2,'cp'=>18,'attri'=>113700,'time'=>80360),array('wood'=>20770,'clay'=>25960,'iron'=>18175,'crop'=>5190,'pop'=>2,'cp'=>22,'attri'=>137100,'time'=>93510),array('wood'=>26585,'clay'=>33230,'iron'=>23260,'crop'=>6645,'pop'=>2,'cp'=>27,'attri'=>165300,'time'=>108780),array('wood'=>34030,'clay'=>42535,'iron'=>29775,'crop'=>8505,'pop'=>2,'cp'=>32,'attri'=>199200,'time'=>126480),array('wood'=>43555,'clay'=>54445,'iron'=>38110,'crop'=>10890,'pop'=>2,'cp'=>38,'attri'=>240000,'time'=>147020));
+$bid40=array(1=>array('wood'=>66700,'clay'=>69050,'iron'=>72200,'crop'=>13200,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>18000),array('wood'=>68535,'clay'=>70950,'iron'=>74185,'crop'=>13565,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>18850),array('wood'=>70420,'clay'=>72900,'iron'=>76225,'crop'=>13935,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>19720),array('wood'=>72355,'clay'=>74905,'iron'=>78320,'crop'=>14320,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>20590),array('wood'=>74345,'clay'=>76965,'iron'=>80475,'crop'=>14715,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>21480),array('wood'=>76390,'clay'=>79080,'iron'=>82690,'crop'=>15120,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>22380),array('wood'=>78490,'clay'=>81255,'iron'=>84965,'crop'=>15535,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>23290),array('wood'=>80650,'clay'=>83490,'iron'=>87300,'crop'=>15960,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>24220),array('wood'=>82865,'clay'=>85785,'iron'=>89700,'crop'=>16400,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>25160),array('wood'=>85145,'clay'=>88145,'iron'=>92165,'crop'=>16850,'pop'=>1,'cp'=>0,'attri'=>0,'time'=>26110),array('wood'=>87485,'clay'=>90570,'iron'=>94700,'crop'=>17315,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>27080),array('wood'=>89895,'clay'=>93060,'iron'=>97305,'crop'=>17790,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>28060),array('wood'=>92365,'clay'=>95620,'iron'=>99980,'crop'=>18280,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>29050),array('wood'=>94905,'clay'=>98250,'iron'=>102730,'crop'=>18780,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>30060),array('wood'=>97515,'clay'=>100950,'iron'=>105555,'crop'=>19300,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>31080),array('wood'=>100195,'clay'=>103725,'iron'=>108460,'crop'=>19830,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>32110),array('wood'=>102950,'clay'=>106580,'iron'=>111440,'crop'=>20375,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>33160),array('wood'=>105785,'clay'=>109510,'iron'=>114505,'crop'=>20935,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>34230),array('wood'=>108690,'clay'=>112520,'iron'=>117655,'crop'=>21510,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>35300),array('wood'=>111680,'clay'=>115615,'iron'=>120890,'crop'=>22100,'pop'=>2,'cp'=>0,'attri'=>0,'time'=>36400),array('wood'=>114755,'clay'=>118795,'iron'=>124215,'crop'=>22710,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>37510),array('wood'=>117910,'clay'=>122060,'iron'=>127630,'crop'=>23335,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>38630),array('wood'=>121150,'clay'=>125420,'iron'=>131140,'crop'=>23975,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>39770),array('wood'=>124480,'clay'=>128870,'iron'=>134745,'crop'=>24635,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>40930),array('wood'=>127905,'clay'=>132410,'iron'=>138455,'crop'=>25315,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>42100),array('wood'=>131425,'clay'=>136055,'iron'=>142260,'crop'=>26010,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>43290),array('wood'=>135035,'clay'=>139795,'iron'=>146170,'crop'=>26725,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>44500),array('wood'=>138750,'clay'=>143640,'iron'=>150190,'crop'=>27460,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>45720),array('wood'=>142565,'clay'=>147590,'iron'=>154320,'crop'=>28215,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>46960),array('wood'=>146485,'clay'=>151650,'iron'=>158565,'crop'=>28990,'pop'=>3,'cp'=>0,'attri'=>0,'time'=>48220),array('wood'=>150515,'clay'=>155820,'iron'=>162925,'crop'=>29785,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>49500),array('wood'=>154655,'clay'=>160105,'iron'=>167405,'crop'=>30605,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>50790),array('wood'=>158910,'clay'=>164505,'iron'=>172010,'crop'=>31450,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>52100),array('wood'=>163275,'clay'=>169030,'iron'=>176740,'crop'=>32315,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>53430),array('wood'=>167770,'clay'=>173680,'iron'=>181600,'crop'=>33200,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>54780),array('wood'=>172380,'clay'=>178455,'iron'=>186595,'crop'=>34115,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>56140),array('wood'=>177120,'clay'=>183360,'iron'=>191725,'crop'=>35055,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>57530),array('wood'=>181995,'clay'=>188405,'iron'=>197000,'crop'=>36015,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>58940),array('wood'=>186995,'clay'=>193585,'iron'=>202415,'crop'=>37005,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>60360),array('wood'=>192140,'clay'=>198910,'iron'=>207985,'crop'=>38025,'pop'=>4,'cp'=>0,'attri'=>0,'time'=>61810),array('wood'=>197425,'clay'=>204380,'iron'=>213705,'crop'=>39070,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>63270),array('wood'=>202855,'clay'=>210000,'iron'=>219580,'crop'=>40145,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>64760),array('wood'=>208430,'clay'=>215775,'iron'=>225620,'crop'=>41250,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>66260),array('wood'=>214165,'clay'=>221710,'iron'=>231825,'crop'=>42385,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>67790),array('wood'=>220055,'clay'=>227805,'iron'=>238200,'crop'=>43550,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>69340),array('wood'=>226105,'clay'=>234070,'iron'=>244750,'crop'=>44745,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>70910),array('wood'=>232320,'clay'=>240505,'iron'=>251480,'crop'=>45975,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>72500),array('wood'=>238710,'clay'=>247120,'iron'=>258395,'crop'=>47240,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>74120),array('wood'=>245275,'clay'=>253915,'iron'=>265500,'crop'=>48540,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>75760),array('wood'=>252020,'clay'=>260900,'iron'=>272800,'crop'=>49875,'pop'=>5,'cp'=>0,'attri'=>0,'time'=>77420),array('wood'=>258950,'clay'=>268075,'iron'=>280305,'crop'=>51245,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>79100),array('wood'=>266070,'clay'=>275445,'iron'=>288010,'crop'=>52655,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>80810),array('wood'=>273390,'clay'=>283020,'iron'=>295930,'crop'=>54105,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>82540),array('wood'=>280905,'clay'=>290805,'iron'=>304070,'crop'=>55590,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>84290),array('wood'=>288630,'clay'=>298800,'iron'=>312430,'crop'=>57120,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>86070),array('wood'=>296570,'clay'=>307020,'iron'=>321025,'crop'=>58690,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>87880),array('wood'=>304725,'clay'=>315460,'iron'=>329850,'crop'=>60305,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>89710),array('wood'=>313105,'clay'=>324135,'iron'=>338925,'crop'=>61965,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>91570),array('wood'=>321715,'clay'=>333050,'iron'=>348245,'crop'=>63670,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>93450),array('wood'=>330565,'clay'=>342210,'iron'=>357820,'crop'=>65420,'pop'=>6,'cp'=>0,'attri'=>0,'time'=>95360),array('wood'=>339655,'clay'=>351620,'iron'=>367660,'crop'=>67220,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>97290),array('wood'=>348995,'clay'=>361290,'iron'=>377770,'crop'=>69065,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>99250),array('wood'=>358590,'clay'=>371225,'iron'=>388160,'crop'=>70965,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>101240),array('wood'=>368450,'clay'=>381435,'iron'=>398835,'crop'=>72915,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>103260),array('wood'=>378585,'clay'=>391925,'iron'=>409800,'crop'=>74920,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>105310),array('wood'=>388995,'clay'=>402700,'iron'=>421070,'crop'=>76985,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>107380),array('wood'=>399695,'clay'=>413775,'iron'=>432650,'crop'=>79100,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>109480),array('wood'=>410685,'clay'=>425155,'iron'=>444550,'crop'=>81275,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>111620),array('wood'=>421980,'clay'=>436845,'iron'=>456775,'crop'=>83510,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>113780),array('wood'=>433585,'clay'=>448860,'iron'=>469335,'crop'=>85805,'pop'=>7,'cp'=>0,'attri'=>0,'time'=>115970),array('wood'=>445505,'clay'=>461205,'iron'=>482240,'crop'=>88165,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>118200),array('wood'=>457760,'clay'=>473885,'iron'=>495505,'crop'=>90590,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>120450),array('wood'=>470345,'clay'=>486920,'iron'=>509130,'crop'=>93080,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>122740),array('wood'=>483280,'clay'=>500310,'iron'=>523130,'crop'=>95640,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>125060),array('wood'=>496570,'clay'=>514065,'iron'=>537520,'crop'=>98270,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>127410),array('wood'=>510225,'clay'=>528205,'iron'=>552300,'crop'=>100975,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>129790),array('wood'=>524260,'clay'=>542730,'iron'=>567490,'crop'=>103750,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>132210),array('wood'=>538675,'clay'=>557655,'iron'=>583095,'crop'=>106605,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>134660),array('wood'=>553490,'clay'=>572990,'iron'=>599130,'crop'=>109535,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>137140),array('wood'=>568710,'clay'=>588745,'iron'=>615605,'crop'=>112550,'pop'=>8,'cp'=>0,'attri'=>0,'time'=>139660),array('wood'=>584350,'clay'=>604935,'iron'=>632535,'crop'=>115645,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>142220),array('wood'=>600420,'clay'=>621575,'iron'=>649930,'crop'=>118825,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>144810),array('wood'=>616930,'clay'=>638665,'iron'=>667800,'crop'=>122090,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>147440),array('wood'=>633895,'clay'=>656230,'iron'=>686165,'crop'=>125450,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>150100),array('wood'=>651330,'clay'=>674275,'iron'=>705035,'crop'=>128900,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>152800),array('wood'=>669240,'clay'=>692820,'iron'=>724425,'crop'=>132445,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>155540),array('wood'=>687645,'clay'=>711870,'iron'=>744345,'crop'=>136085,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>158320),array('wood'=>706555,'clay'=>731445,'iron'=>764815,'crop'=>139830,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>161140),array('wood'=>725985,'clay'=>751560,'iron'=>785850,'crop'=>143675,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>163990),array('wood'=>745950,'clay'=>772230,'iron'=>807460,'crop'=>147625,'pop'=>9,'cp'=>0,'attri'=>0,'time'=>166890),array('wood'=>766460,'clay'=>793465,'iron'=>829665,'crop'=>151685,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>169820),array('wood'=>787540,'clay'=>815285,'iron'=>852480,'crop'=>155855,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>172800),array('wood'=>809195,'clay'=>837705,'iron'=>875920,'crop'=>160140,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>175820),array('wood'=>831450,'clay'=>860745,'iron'=>900010,'crop'=>164545,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>178880),array('wood'=>854315,'clay'=>884415,'iron'=>924760,'crop'=>169070,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>181990),array('wood'=>877810,'clay'=>908735,'iron'=>950190,'crop'=>173720,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>185130),array('wood'=>901950,'clay'=>933725,'iron'=>976320,'crop'=>178495,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>188330),array('wood'=>926750,'clay'=>959405,'iron'=>1000000,'crop'=>183405,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>191560),array('wood'=>952235,'clay'=>985785,'iron'=>1000000,'crop'=>188450,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>194840),array('wood'=>1000000,'clay'=>1000000,'iron'=>1000000,'crop'=>193630,'pop'=>10,'cp'=>0,'attri'=>0,'time'=>198170));
+$bid41=array(1=>array('wood'=>780,'clay'=>420,'iron'=>660,'crop'=>540,'pop'=>5,'cp'=>4,'attri'=>0,'time'=>2200),array('wood'=>1000,'clay'=>540,'iron'=>845,'crop'=>690,'pop'=>3,'cp'=>4,'attri'=>0,'time'=>3150),array('wood'=>1280,'clay'=>690,'iron'=>1080,'crop'=>885,'pop'=>3,'cp'=>5,'attri'=>0,'time'=>4260),array('wood'=>1635,'clay'=>880,'iron'=>1385,'crop'=>1130,'pop'=>3,'cp'=>6,'attri'=>0,'time'=>5540),array('wood'=>2095,'clay'=>1125,'iron'=>1770,'crop'=>1450,'pop'=>3,'cp'=>7,'attri'=>0,'time'=>7020),array('wood'=>2680,'clay'=>1445,'iron'=>2270,'crop'=>1855,'pop'=>3,'cp'=>9,'attri'=>0,'time'=>8750),array('wood'=>3430,'clay'=>1845,'iron'=>2905,'crop'=>2375,'pop'=>3,'cp'=>11,'attri'=>0,'time'=>10750),array('wood'=>4390,'clay'=>2365,'iron'=>3715,'crop'=>3040,'pop'=>3,'cp'=>13,'attri'=>0,'time'=>13070),array('wood'=>5620,'clay'=>3025,'iron'=>4755,'crop'=>3890,'pop'=>3,'cp'=>15,'attri'=>0,'time'=>15760),array('wood'=>7195,'clay'=>3875,'iron'=>6085,'crop'=>4980,'pop'=>3,'cp'=>19,'attri'=>0,'time'=>18880),array('wood'=>9210,'clay'=>4960,'iron'=>7790,'crop'=>6375,'pop'=>4,'cp'=>22,'attri'=>0,'time'=>22500),array('wood'=>11785,'clay'=>6345,'iron'=>9975,'crop'=>8160,'pop'=>4,'cp'=>27,'attri'=>0,'time'=>26700),array('wood'=>15085,'clay'=>8125,'iron'=>12765,'crop'=>10445,'pop'=>4,'cp'=>32,'attri'=>0,'time'=>31570),array('wood'=>19310,'clay'=>10400,'iron'=>16340,'crop'=>13370,'pop'=>4,'cp'=>39,'attri'=>0,'time'=>37220),array('wood'=>24720,'clay'=>13310,'iron'=>20915,'crop'=>17115,'pop'=>4,'cp'=>46,'attri'=>0,'time'=>43780),array('wood'=>31640,'clay'=>17035,'iron'=>26775,'crop'=>21905,'pop'=>4,'cp'=>55,'attri'=>0,'time'=>51380),array('wood'=>40500,'clay'=>21810,'iron'=>34270,'crop'=>28040,'pop'=>4,'cp'=>67,'attri'=>0,'time'=>60200),array('wood'=>51840,'clay'=>27915,'iron'=>43865,'crop'=>35890,'pop'=>4,'cp'=>80,'attri'=>0,'time'=>70430),array('wood'=>66355,'clay'=>35730,'iron'=>56145,'crop'=>45940,'pop'=>4,'cp'=>96,'attri'=>0,'time'=>82300),array('wood'=>84935,'clay'=>45735,'iron'=>71870,'crop'=>58800,'pop'=>4,'cp'=>115,'attri'=>0,'time'=>96070));
+?>
diff --git a/GameEngine/Data/cel.php b/GameEngine/Data/cel.php
new file mode 100644
index 00000000..77b8b0fc
--- /dev/null
+++ b/GameEngine/Data/cel.php
@@ -0,0 +1,49 @@
+array('name'=>'Small Celebration','wood'=>6400,'clay'=>6650,'iron'=>5940,'crop'=>1340,'attri'=>500,'time'=>86400),array('name'=>'Great Celebration','wood'=>29700,'clay'=>33250,'iron'=>32000,'crop'=>6700,'attri'=>2000,'time'=>216000));
+
+$sc = array(
+1 => 86400,
+2 => 83290,
+3 => 80291,
+4 => 77401,
+5 => 74614,
+6 => 71928,
+7 => 69338,
+8 => 66843,
+9 => 64436,
+10 => 62117,
+11 => 59880,
+12 => 57725,
+13 => 55647,
+14 => 53643,
+15 => 51712,
+16 => 49850,
+17 => 48056,
+18 => 46326,
+19 => 44658,
+20 => 43050);
+
+$gc= array(
+10 => 155291,
+11 => 149701,
+12 => 144312,
+13 => 139116,
+14 => 134108,
+15 => 129280,
+16 => 124626,
+17 => 120140,
+18 => 115815,
+19 => 111645,
+20 => 107626);
+?>
diff --git a/GameEngine/Data/cp.php b/GameEngine/Data/cp.php
new file mode 100644
index 00000000..a27ebb1e
--- /dev/null
+++ b/GameEngine/Data/cp.php
@@ -0,0 +1,267 @@
+ 0,
+ 2 => 500,
+ 3 => 2600,
+ 4 => 6700,
+ 5 => 12900,
+ 6 => 21600,
+ 7 => 32900,
+ 8 => 46000,
+ 9 => 63000,
+ 10 => 83500,
+ 11 => 106400,
+ 12 => 132500,
+ 13 => 161900,
+ 14 => 194600,
+ 15 => 230700,
+ 16 => 270400,
+ 17 => 313700,
+ 18 => 360600,
+ 19 => 411300,
+ 20 => 465700,
+ 21 => 524000,
+ 22 => 586300,
+ 23 => 652500,
+ 24 => 722700,
+ 25 => 797000,
+ 26 => 875500,
+ 27 => 958200,
+ 28 => 1045000,
+ 29 => 1136200,
+ 30 => 1231700,
+ 31 => 1316000,
+ 32 => 1435900,
+ 33 => 1435900,
+ 34 => 1658000,
+ 35 => 1775800,
+ 36 => 1898300,
+ 37 => 2025300,
+ 38 => 2157100,
+ 39 => 2293500,
+ 40 => 2434700,
+ 41 => 2580700,
+ 42 => 2731500,
+ 43 => 2887200,
+ 44 => 3047700,
+ 45 => 3213200,
+ 46 => 3383700,
+ 47 => 3559100,
+ 48 => 3739600,
+ 49 => 3925100,
+ 50 => 4115800,
+ 51 => 4311500,
+ 52 => 4512400,
+ 53 => 4718500,
+ 54 => 4929800,
+ 55 => 5146400,
+ 56 => 5368300,
+ 57 => 5595400,
+ 58 => 5827900,
+ 59 => 6065700,
+ 60 => 6309000,
+ 61 => 6557600,
+ 62 => 6811700,
+ 63 => 7071300,
+ 64 => 7336400,
+ 65 => 7607000,
+ 66 => 7883100,
+ 67 => 8164900,
+ 68 => 8452200,
+ 69 => 8745200,
+ 70 => 9043800,
+ 71 => 9348100,
+ 72 => 9659100,
+ 73 => 9973900,
+ 74 => 10295400,
+ 75 => 10622600,
+ 76 => 10955700,
+ 77 => 11294600,
+ 78 => 11639300,
+ 79 => 11989900,
+ 80 => 12346400,
+ 81 => 12708800,
+ 82 => 13077200,
+ 83 => 13451500,
+ 84 => 13831800,
+ 85 => 14218100,
+ 86 => 14610400,
+ 87 => 15008800,
+ 88 => 15413200,
+ 89 => 15823700,
+ 90 => 16240400,
+ 91 => 16663100,
+ 92 => 17092000,
+ 93 => 17527100,
+ 94 => 17968400,
+ 95 => 18415900,
+ 96 => 18869600,
+ 97 => 19329600,
+ 98 => 19795800,
+ 99 => 20268400,
+ 100 => 20747200,
+ 101 => 21232400,
+ 102 => 21723900,
+ 103 => 22221800,
+ 104 => 22726100,
+ 105 => 23236800,
+ 106 => 23753900,
+ 107 => 24277400,
+ 108 => 24807400,
+ 109 => 25343900,
+ 110 => 25886900,
+ 111 => 26436400,
+ 112 => 26992400,
+ 113 => 27555000,
+ 114 => 28124100,
+ 115 => 28699900,
+ 116 => 29282200,
+ 117 => 29871200,
+ 118 => 30466800,
+ 119 => 31069000,
+ 120 => 31677900,
+ 121 => 32293500,
+ 122 => 32915900,
+ 123 => 33544900,
+ 124 => 34180700,
+ 125 => 34823200);
+
+$cp1= array(
+ 1 => 0,
+ 2 => 2000,
+ 3 => 8000,
+ 4 => 20000,
+ 5 => 39000,
+ 6 => 65000,
+ 7 => 99000,
+ 8 => 141000,
+ 9 => 191000,
+ 10 => 251000,
+ 11 => 319000,
+ 12 => 397000,
+ 13 => 486000,
+ 14 => 584000,
+ 15 => 692000,
+ 16 => 811000,
+ 17 => 941000,
+ 18 => 1082000,
+ 19 => 1234000,
+ 20 => 1397000,
+ 21 => 1572000,
+ 22 => 1759000,
+ 23 => 1957000,
+ 24 => 2168000,
+ 25 => 2391000,
+ 26 => 2627000,
+ 27 => 2874000,
+ 28 => 3135000,
+ 29 => 3409000,
+ 30 => 3695000,
+ 31 => 3995000,
+ 32 => 4308000,
+ 33 => 4634000,
+ 34 => 4974000,
+ 35 => 5327000,
+ 36 => 5695000,
+ 37 => 6076000,
+ 38 => 6471000,
+ 39 => 6881000,
+ 40 => 7304000,
+ 41 => 7742000,
+ 42 => 8195000,
+ 43 => 8662000,
+ 44 => 9143000,
+ 45 => 9640000,
+ 46 => 10151000,
+ 47 => 10677000,
+ 48 => 11219000,
+ 49 => 11775000,
+ 50 => 12347000,
+ 51 => 12935000,
+ 52 => 13537000,
+ 53 => 14156000,
+ 54 => 14790000,
+ 55 => 15439000,
+ 56 => 16105000,
+ 57 => 16786000,
+ 58 => 17484000,
+ 59 => 18197000,
+ 60 => 18927000,
+ 61 => 19673000,
+ 62 => 20435000,
+ 63 => 21214000,
+ 64 => 22009000,
+ 65 => 22821000,
+ 66 => 23649000,
+ 67 => 24495000,
+ 68 => 25357000,
+ 69 => 26236000,
+ 70 => 27131000,
+ 71 => 28044000,
+ 72 => 28974000,
+ 73 => 29922000,
+ 74 => 30886000,
+ 75 => 31868000,
+ 76 => 32867000,
+ 77 => 33884000,
+ 78 => 34918000,
+ 79 => 35970000,
+ 80 => 37039000,
+ 81 => 38127000,
+ 82 => 39232000,
+ 83 => 40354000,
+ 84 => 41495000,
+ 85 => 42654000,
+ 86 => 43831000,
+ 87 => 45026000,
+ 88 => 46240000,
+ 89 => 47471000,
+ 90 => 48721000,
+ 91 => 49989000,
+ 92 => 51276000,
+ 93 => 52581000,
+ 94 => 53905000,
+ 95 => 55248000,
+ 96 => 56609000,
+ 97 => 57989000,
+ 98 => 59387000,
+ 99 => 60805000,
+ 100 => 62242000,
+ 101 => 63697000,
+ 102 => 65172000,
+ 103 => 66665000,
+ 104 => 68178000,
+ 105 => 69710000,
+ 106 => 71262000,
+ 107 => 72832000,
+ 108 => 74422000,
+ 109 => 76032000,
+ 110 => 77661000,
+ 111 => 79309000,
+ 112 => 80977000,
+ 113 => 82665000,
+ 114 => 84372000,
+ 115 => 86000000,
+ 116 => 87847000,
+ 117 => 89613000,
+ 118 => 91400000,
+ 119 => 93207000,
+ 120 => 95034000,
+ 121 => 96881000,
+ 122 => 98748000,
+ 123 => 100635000,
+ 124 => 102542000,
+ 125 => 104470000);
+?>
\ No newline at end of file
diff --git a/GameEngine/Data/hero_full.php b/GameEngine/Data/hero_full.php
new file mode 100644
index 00000000..febe6c12
--- /dev/null
+++ b/GameEngine/Data/hero_full.php
@@ -0,0 +1,182 @@
+ 0, 100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 6600, 7800, 9100, 10500, 12000, 13600, 15300, 17100, 19000, 21000, 23100, 25300, 27600, 30000, 32500, 35100, 37800, 40600, 43500, 46500, 49600, 52800, 56100, 59500, 63000, 66600, 70300, 74100, 78000, 82000, 86100, 90300, 94600, 99000, 103500, 108100, 112800, 117600, 122500, 127500, 132600, 137800, 143100, 148500, 154000, 159600, 165300, 171100, 177000, 183000, 189100, 195300, 201600, 208000, 214500, 221100, 227800,
+ 234600, 241500, 248500, 255600, 262800, 270100, 277500, 285000, 292600, 300300, 308100, 316000, 324000, 332100, 340300, 348600, 357000, 365500, 374100, 382800, 391600, 400500, 409500, 418600, 427800, 437100, 446500, 456000, 465600, 475300, 485100, 495000);
+
+
+//ROMAN UNITS
+ $h1_full = array(array('wood' => 240, 'clay' => 200, 'iron' => 300, 'crop' => 60, 'time' => 3200), array('wood' => 640, 'clay' => 550, 'iron' => 780, 'crop' => 210, 'time' => 6400), array('wood' => 1100, 'clay' => 910, 'iron' => 1300, 'crop' => 360, 'time' => 9600), array('wood' => 1500, 'clay' => 1300, 'iron' => 1900, 'crop' => 510, 'time' => 12800), array('wood' => 2000, 'clay' => 1700, 'iron' => 2500, 'crop' => 670, 'time' => 16000), array('wood' => 2500, 'clay' => 2200, 'iron' => 3100, 'crop' => 850, 'time' =>
+ 19200), array('wood' => 3100, 'clay' => 2600, 'iron' => 3800, 'crop' => 1000, 'time' => 22400), array('wood' => 3600, 'clay' => 3100, 'iron' => 4400, 'crop' => 1200, 'time' => 25580), array('wood' => 4200, 'clay' => 3600, 'iron' => 5100, 'crop' => 1400, 'time' => 28800), array('wood' => 4800, 'clay' => 4100, 'iron' => 5900, 'crop' => 1600, 'time' => 32000), array('wood' => 5400, 'clay' => 4600, 'iron' => 6600, 'crop' => 1800, 'time' => 35200), array('wood' => 6000, 'clay' => 5100, 'iron' => 7400, 'crop' => 2000,
+ 'time' => 38400), array('wood' => 6700, 'clay' => 5700, 'iron' => 8100, 'crop' => 2200, 'time' => 41600), array('wood' => 7300, 'clay' => 6200, 'iron' => 8900, 'crop' => 2400, 'time' => 44800), array('wood' => 8000, 'clay' => 6800, 'iron' => 9700, 'crop' => 2700, 'time' => 48000), array('wood' => 8600, 'clay' => 7400, 'iron' => 10500, 'crop' => 2900, 'time' => 51200), array('wood' => 9300, 'clay' => 7900, 'iron' => 11500, 'crop' => 3100, 'time' => 54400), array('wood' => 10000, 'clay' => 8500, 'iron' => 12000,
+ 'crop' => 3300, 'time' => 57600), array('wood' => 10500, 'clay' => 9100, 'iron' => 13000, 'crop' => 3600, 'time' => 60800), array('wood' => 11500, 'clay' => 9700, 'iron' => 14000, 'crop' => 3800, 'time' => 64000), array('wood' => 12000, 'clay' => 10500, 'iron' => 15000, 'crop' => 4000, 'time' => 67200), array('wood' => 13000, 'clay' => 11000, 'iron' => 15500, 'crop' => 4300, 'time' => 70400), array('wood' => 13500, 'clay' => 11500, 'iron' => 16500, 'crop' => 4500, 'time' => 73600), array('wood' => 14500, 'clay' =>
+ 12000, 'iron' => 17500, 'crop' => 4800, 'time' => 76800), array('wood' => 15000, 'clay' => 13000, 'iron' => 18500, 'crop' => 5000, 'time' => 80000), array('wood' => 16000, 'clay' => 13500, 'iron' => 19500, 'crop' => 5300, 'time' => 83200), array('wood' => 16500, 'clay' => 14000, 'iron' => 20500, 'crop' => 5500, 'time' => 86400), array('wood' => 17500, 'clay' => 15000, 'iron' => 21500, 'crop' => 5800, 'time' => 89600), array('wood' => 18000, 'clay' => 15500, 'iron' => 22000, 'crop' => 6100, 'time' => 92800),
+ array('wood' => 19000, 'clay' => 16000, 'iron' => 23000, 'crop' => 6300, 'time' => 96000), array('wood' => 19500, 'clay' => 17000, 'iron' => 24000, 'crop' => 6600, 'time' => 99200), array('wood' => 20500, 'clay' => 17500, 'iron' => 25000, 'crop' => 6800, 'time' => 102400), array('wood' => 21500, 'clay' => 18000, 'iron' => 26000, 'crop' => 7100, 'time' => 105600), array('wood' => 22000, 'clay' => 19000, 'iron' => 27000, 'crop' => 7400, 'time' => 108800), array('wood' => 23000, 'clay' => 19500, 'iron' => 28000, 'crop' =>
+ 7700, 'time' => 112000), array('wood' => 24000, 'clay' => 20500, 'iron' => 29000, 'crop' => 7900, 'time' => 115200), array('wood' => 24500, 'clay' => 21000, 'iron' => 30000, 'crop' => 8200, 'time' => 118400), array('wood' => 25500, 'clay' => 21500, 'iron' => 31000, 'crop' => 8500, 'time' => 121600), array('wood' => 26500, 'clay' => 22500, 'iron' => 32000, 'crop' => 8800, 'time' => 124800), array('wood' => 27000, 'clay' => 23000, 'iron' => 33000, 'crop' => 9100, 'time' => 128000), array('wood' => 28000, 'clay' => 24000,
+ 'iron' => 34000, 'crop' => 9300, 'time' => 131200), array('wood' => 29000, 'clay' => 24500, 'iron' => 35500, 'crop' => 9600, 'time' => 134400), array('wood' => 29500, 'clay' => 25500, 'iron' => 36500, 'crop' => 9900, 'time' => 137600), array('wood' => 30500, 'clay' => 26000, 'iron' => 37500, 'crop' => 10000, 'time' => 140800), array('wood' => 31500, 'clay' => 27000, 'iron' => 38500, 'crop' => 10500, 'time' => 144000), array('wood' => 32500, 'clay' => 27500, 'iron' => 39500, 'crop' => 11000, 'time' => 147200),
+ array('wood' => 34000, 'clay' => 28500, 'iron' => 40500, 'crop' => 11000, 'time' => 150400), array('wood' => 34000, 'clay' => 29000, 'iron' => 41500, 'crop' => 11500, 'time' => 153600), array('wood' => 35000, 'clay' => 30000, 'iron' => 43000, 'crop' => 11500, 'time' => 156800), array('wood' => 36000, 'clay' => 30500, 'iron' => 44000, 'crop' => 12000, 'time' => 160000), array('wood' => 37000, 'clay' => 31500, 'iron' => 45000, 'crop' => 12500, 'time' => 163200), array('wood' => 37500, 'clay' => 32000, 'iron' => 46000,
+ 'crop' => 12500, 'time' => 166400), array('wood' => 38500, 'clay' => 33000, 'iron' => 47000, 'crop' => 13000, 'time' => 169600), array('wood' => 39500, 'clay' => 33500, 'iron' => 48500, 'crop' => 13000, 'time' => 172800), array('wood' => 40500, 'clay' => 34500, 'iron' => 49500, 'crop' => 13500, 'time' => 176000), array('wood' => 41500, 'clay' => 35000, 'iron' => 50500, 'crop' => 14000, 'time' => 179200), array('wood' => 42500, 'clay' => 36000, 'iron' => 51500, 'crop' => 14000, 'time' => 182400), array('wood' => 43000,
+ 'clay' => 37000, 'iron' => 53000, 'crop' => 14500, 'time' => 185600), array('wood' => 44000, 'clay' => 37500, 'iron' => 54000, 'crop' => 14500, 'time' => 188800), array('wood' => 45000, 'clay' => 38500, 'iron' => 55000, 'crop' => 15000, 'time' => 192000), array('wood' => 46000, 'clay' => 39000, 'iron' => 56500, 'crop' => 15500, 'time' => 195200));
+ $h2_full = array(array('wood' => 200, 'clay' => 260, 'iron' => 320, 'crop' => 140, 'time' => 3520), array('wood' => 550, 'clay' => 690, 'iron' => 830, 'crop' => 400, 'time' => 7040), array('wood' => 910, 'clay' => 1100, 'iron' => 1400, 'crop' => 670, 'time' => 10560), array('wood' => 1300, 'clay' => 1600, 'iron' => 2000, 'crop' => 960, 'time' => 14080), array('wood' => 1700, 'clay' => 2200, 'iron' => 2600, 'crop' => 1300, 'time' => 17600), array('wood' => 2200, 'clay' => 2700, 'iron' => 3300, 'crop' => 1600, 'time' =>
+ 21120), array('wood' => 2600, 'clay' => 3300, 'iron' => 4000, 'crop' => 1900, 'time' => 24640), array('wood' => 3100, 'clay' => 3900, 'iron' => 4700, 'crop' => 2300, 'time' => 28160), array('wood' => 3600, 'clay' => 4500, 'iron' => 5500, 'crop' => 2700, 'time' => 31680), array('wood' => 4100, 'clay' => 5200, 'iron' => 6200, 'crop' => 3000, 'time' => 35200), array('wood' => 4600, 'clay' => 5800, 'iron' => 7000, 'crop' => 3400, 'time' => 38720), array('wood' => 5100, 'clay' => 6500, 'iron' => 7800, 'crop' => 3800, 'time' =>
+ 42240), array('wood' => 5700, 'clay' => 7200, 'iron' => 8600, 'crop' => 4200, 'time' => 45760), array('wood' => 6200, 'clay' => 7900, 'iron' => 9500, 'crop' => 4600, 'time' => 49280), array('wood' => 6800, 'clay' => 8600, 'iron' => 10500, 'crop' => 5000, 'time' => 52800), array('wood' => 7400, 'clay' => 9300, 'iron' => 11000, 'crop' => 5400, 'time' => 56320), array('wood' => 7900, 'clay' => 10000, 'iron' => 12000, 'crop' => 5900, 'time' => 59840), array('wood' => 8500, 'clay' => 11000, 'iron' => 13000, 'crop' => 6300,
+ 'time' => 63360), array('wood' => 9100, 'clay' => 11500, 'iron' => 14000, 'crop' => 6700, 'time' => 66880), array('wood' => 9700, 'clay' => 12500, 'iron' => 15000, 'crop' => 7200, 'time' => 70400), array('wood' => 10500, 'clay' => 13000, 'iron' => 15500, 'crop' => 7600, 'time' => 73920), array('wood' => 11000, 'clay' => 14000, 'iron' => 16500, 'crop' => 8100, 'time' => 77440), array('wood' => 11500, 'clay' => 14500, 'iron' => 17500, 'crop' => 8600, 'time' => 80960), array('wood' => 12000, 'clay' => 15500, 'iron' => 18500,
+ 'crop' => 9000, 'time' => 84480), array('wood' => 13000, 'clay' => 16000, 'iron' => 19500, 'crop' => 9500, 'time' => 88000), array('wood' => 13500, 'clay' => 17000, 'iron' => 20500, 'crop' => 10000, 'time' => 91520), array('wood' => 14000, 'clay' => 18000, 'iron' => 21500, 'crop' => 10500, 'time' => 95040), array('wood' => 15000, 'clay' => 18500, 'iron' => 22500, 'crop' => 11000, 'time' => 98560), array('wood' => 15500, 'clay' => 19500, 'iron' => 23500, 'crop' => 11500, 'time' => 102080), array('wood' => 16000, 'clay' =>
+ 20500, 'iron' => 24500, 'crop' => 12000, 'time' => 105600), array('wood' => 17000, 'clay' => 21000, 'iron' => 25500, 'crop' => 12500, 'time' => 109120), array('wood' => 17500, 'clay' => 22000, 'iron' => 26500, 'crop' => 13000, 'time' => 112640), array('wood' => 18000, 'clay' => 23000, 'iron' => 27500, 'crop' => 13500, 'time' => 116160), array('wood' => 19000, 'clay' => 24000, 'iron' => 28500, 'crop' => 14000, 'time' => 119680), array('wood' => 19500, 'clay' => 24500, 'iron' => 30000, 'crop' => 14500, 'time' => 123200),
+ array('wood' => 20500, 'clay' => 25500, 'iron' => 31000, 'crop' => 15000, 'time' => 126270), array('wood' => 21000, 'clay' => 26500, 'iron' => 32000, 'crop' => 15500, 'time' => 130240), array('wood' => 21500, 'clay' => 27500, 'iron' => 33000, 'crop' => 16000, 'time' => 133760), array('wood' => 22500, 'clay' => 28500, 'iron' => 34000, 'crop' => 16500, 'time' => 137280), array('wood' => 23000, 'clay' => 29000, 'iron' => 35000, 'crop' => 17000, 'time' => 140800), array('wood' => 24000, 'clay' => 30000, 'iron' => 36500, 'crop' =>
+ 17500, 'time' => 144320), array('wood' => 24500, 'clay' => 31000, 'iron' => 37500, 'crop' => 18000, 'time' => 147840), array('wood' => 25500, 'clay' => 32000, 'iron' => 38500, 'crop' => 18500, 'time' => 151360), array('wood' => 26000, 'clay' => 33000, 'iron' => 39500, 'crop' => 19500, 'time' => 154880), array('wood' => 27000, 'clay' => 34000, 'iron' => 41000, 'crop' => 20000, 'time' => 158400), array('wood' => 27500, 'clay' => 34500, 'iron' => 42000, 'crop' => 20500, 'time' => 161920), array('wood' => 28500, 'clay' => 35500,
+ 'iron' => 43000, 'crop' => 21000, 'time' => 165440), array('wood' => 29000, 'clay' => 36500, 'iron' => 44000, 'crop' => 21500, 'time' => 168960), array('wood' => 30000, 'clay' => 37500, 'iron' => 45500, 'crop' => 22000, 'time' => 172480), array('wood' => 30500, 'clay' => 38500, 'iron' => 46500, 'crop' => 22500, 'time' => 176000), array('wood' => 31500, 'clay' => 39500, 'iron' => 47500, 'crop' => 23000, 'time' => 179520), array('wood' => 32000, 'clay' => 40500, 'iron' => 49000, 'crop' => 23500, 'time' => 183040), array('wood' =>
+ 33000, 'clay' => 41500, 'iron' => 50000, 'crop' => 24500, 'time' => 186560), array('wood' => 33500, 'clay' => 42500, 'iron' => 51000, 'crop' => 25000, 'time' => 190080), array('wood' => 34500, 'clay' => 43500, 'iron' => 52500, 'crop' => 25500, 'time' => 193600), array('wood' => 35000, 'clay' => 44500, 'iron' => 53500, 'crop' => 26000, 'time' => 197120), array('wood' => 36000, 'clay' => 45500, 'iron' => 55000, 'crop' => 26500, 'time' => 200640), array('wood' => 37000, 'clay' => 46500, 'iron' => 56000, 'crop' => 27000, 'time' =>
+ 204160), array('wood' => 37500, 'clay' => 47500, 'iron' => 57000, 'crop' => 28000, 'time' => 207680), array('wood' => 38500, 'clay' => 48500, 'iron' => 58500, 'crop' => 28500, 'time' => 211200), array('wood' => 39000, 'clay' => 49500, 'iron' => 59500, 'crop' => 29000, 'time' => 214720));
+ $h3_full = array(array('wood' => 300, 'clay' => 320, 'iron' => 420, 'crop' => 160, 'time' => 3840), array('wood' => 780, 'clay' => 830, 'iron' => 1100, 'crop' => 450, 'time' => 7680), array('wood' => 1300, 'clay' => 1400, 'iron' => 1800, 'crop' => 750, 'time' => 11520), array('wood' => 1900, 'clay' => 2000, 'iron' => 2500, 'crop' => 1100, 'time' => 15360), array('wood' => 2500, 'clay' => 2600, 'iron' => 3400, 'crop' => 1400, 'time' => 19200), array('wood' => 3100, 'clay' => 3300, 'iron' => 4200, 'crop' => 1800, 'time' => 23040),
+ array('wood' => 3800, 'clay' => 4000, 'iron' => 5100, 'crop' => 2200, 'time' => 26880), array('wood' => 4400, 'clay' => 4700, 'iron' => 6100, 'crop' => 2600, 'time' => 30720), array('wood' => 5100, 'clay' => 5500, 'iron' => 7000, 'crop' => 3000, 'time' => 34560), array('wood' => 5900, 'clay' => 6200, 'iron' => 8000, 'crop' => 3400, 'time' => 38400), array('wood' => 6600, 'clay' => 7000, 'iron' => 9000, 'crop' => 3800, 'time' => 42240), array('wood' => 7400, 'clay' => 7800, 'iron' => 10000, 'crop' => 4200, 'time' => 46080),
+ array('wood' => 8100, 'clay' => 8600, 'iron' => 11000, 'crop' => 4700, 'time' => 49920), array('wood' => 8900, 'clay' => 9500, 'iron' => 12000, 'crop' => 5100, 'time' => 53760), array('wood' => 9700, 'clay' => 10500, 'iron' => 13500, 'crop' => 5600, 'time' => 57600), array('wood' => 10500, 'clay' => 11000, 'iron' => 14500, 'crop' => 6100, 'time' => 61440), array('wood' => 11500, 'clay' => 12000, 'iron' => 15500, 'crop' => 6600, 'time' => 65280), array('wood' => 12000, 'clay' => 13000, 'iron' => 16500, 'crop' => 7000, 'time' =>
+ 69120), array('wood' => 13000, 'clay' => 14000, 'iron' => 18000, 'crop' => 7500, 'time' => 72960), array('wood' => 14000, 'clay' => 15000, 'iron' => 19000, 'crop' => 8000, 'time' => 76800), array('wood' => 15000, 'clay' => 15500, 'iron' => 20000, 'crop' => 8500, 'time' => 80640), array('wood' => 15500, 'clay' => 16500, 'iron' => 21500, 'crop' => 9100, 'time' => 84480), array('wood' => 16500, 'clay' => 17500, 'iron' => 22500, 'crop' => 9600, 'time' => 88320), array('wood' => 17500, 'clay' => 18500, 'iron' => 24000, 'crop' => 10000,
+ 'time' => 92160), array('wood' => 18500, 'clay' => 19500, 'iron' => 25000, 'crop' => 10500, 'time' => 96000), array('wood' => 19500, 'clay' => 20500, 'iron' => 26500, 'crop' => 11000, 'time' => 99840), array('wood' => 20500, 'clay' => 21500, 'iron' => 27500, 'crop' => 11500, 'time' => 103680), array('wood' => 21500, 'clay' => 22500, 'iron' => 29000, 'crop' => 12000, 'time' => 107520), array('wood' => 22000, 'clay' => 23500, 'iron' => 30500, 'crop' => 13000, 'time' => 111360), array('wood' => 23000, 'clay' => 24500, 'iron' => 31500,
+ 'crop' => 13500, 'time' => 115200), array('wood' => 24000, 'clay' => 25500, 'iron' => 33000, 'crop' => 14000, 'time' => 119040), array('wood' => 25000, 'clay' => 26500, 'iron' => 34000, 'crop' => 14500, 'time' => 122880), array('wood' => 26000, 'clay' => 27500, 'iron' => 35500, 'crop' => 15000, 'time' => 126720), array('wood' => 27000, 'clay' => 28500, 'iron' => 37000, 'crop' => 15500, 'time' => 130560), array('wood' => 28000, 'clay' => 30000, 'iron' => 38500, 'crop' => 16000, 'time' => 134400), array('wood' => 29000, 'clay' => 31000,
+ 'iron' => 39500, 'crop' => 17000, 'time' => 138240), array('wood' => 30000, 'clay' => 32000, 'iron' => 41000, 'crop' => 17500, 'time' => 142080), array('wood' => 31000, 'clay' => 33000, 'iron' => 42500, 'crop' => 18000, 'time' => 145920), array('wood' => 32000, 'clay' => 34000, 'iron' => 44000, 'crop' => 18500, 'time' => 149760), array('wood' => 33000, 'clay' => 35000, 'iron' => 45500, 'crop' => 19000, 'time' => 153600), array('wood' => 34000, 'clay' => 36500, 'iron' => 46500, 'crop' => 19500, 'time' => 157440), array('wood' => 35500,
+ 'clay' => 37500, 'iron' => 48000, 'crop' => 20500, 'time' => 161280), array('wood' => 36500, 'clay' => 38500, 'iron' => 49500, 'crop' => 21000, 'time' => 165120), array('wood' => 37500, 'clay' => 39500, 'iron' => 51000, 'crop' => 21500, 'time' => 168960), array('wood' => 38500, 'clay' => 41000, 'iron' => 52500, 'crop' => 22000, 'time' => 172800), array('wood' => 39500, 'clay' => 42000, 'iron' => 54000, 'crop' => 23000, 'time' => 176640), array('wood' => 40500, 'clay' => 43000, 'iron' => 55000, 'crop' => 23500, 'time' => 180480),
+ array('wood' => 41500, 'clay' => 44000, 'iron' => 57000, 'crop' => 24000, 'time' => 184320), array('wood' => 43000, 'clay' => 45500, 'iron' => 58500, 'crop' => 24500, 'time' => 188160), array('wood' => 44000, 'clay' => 46500, 'iron' => 60000, 'crop' => 25500, 'time' => 192000), array('wood' => 45000, 'clay' => 47500, 'iron' => 61500, 'crop' => 26000, 'time' => 195840), array('wood' => 46000, 'clay' => 49000, 'iron' => 63000, 'crop' => 26500, 'time' => 199680), array('wood' => 47000, 'clay' => 50000, 'iron' => 64500, 'crop' => 27000,
+ 'time' => 203520), array('wood' => 48500, 'clay' => 51000, 'iron' => 66000, 'crop' => 28000, 'time' => 207360), array('wood' => 49500, 'clay' => 52500, 'iron' => 67500, 'crop' => 28500, 'time' => 211200), array('wood' => 50500, 'clay' => 53500, 'iron' => 69000, 'crop' => 29000, 'time' => 215040), array('wood' => 51500, 'clay' => 55000, 'iron' => 70500, 'crop' => 30000, 'time' => 218880), array('wood' => 53000, 'clay' => 56000, 'iron' => 72000, 'crop' => 30500, 'time' => 222720), array('wood' => 54000, 'clay' => 57000, 'iron' => 73500,
+ 'crop' => 31000, 'time' => 226560), array('wood' => 55000, 'clay' => 58500, 'iron' => 75000, 'crop' => 31500, 'time' => 230400), array('wood' => 56500, 'clay' => 59500, 'iron' => 76500, 'crop' => 32500, 'time' => 234240));
+ $h5_full = array(array('wood' => 1100, 'clay' => 880, 'iron' => 640, 'crop' => 200, 'time' => 5280), array('wood' => 2700, 'clay' => 2200, 'iron' => 1600, 'crop' => 550, 'time' => 10560), array('wood' => 4500, 'clay' => 3600, 'iron' => 2600, 'crop' => 910, 'time' => 15840), array('wood' => 6400, 'clay' => 5100, 'iron' => 3800, 'crop' => 1300, 'time' => 21120), array('wood' => 8400, 'clay' => 6800, 'iron' => 5000, 'crop' => 1700, 'time' => 26400), array('wood' => 10500, 'clay' => 8500, 'iron' => 6300, 'crop' => 2200, 'time' => 31680),
+ array('wood' => 13000, 'clay' => 10500, 'iron' => 7600, 'crop' => 2600, 'time' => 36960), array('wood' => 15000, 'clay' => 12000, 'iron' => 9000, 'crop' => 3100, 'time' => 42240), array('wood' => 17500, 'clay' => 14000, 'iron' => 10500, 'crop' => 3600, 'time' => 47520), array('wood' => 20000, 'clay' => 16000, 'iron' => 12000, 'crop' => 4100, 'time' => 52800), array('wood' => 22500, 'clay' => 18000, 'iron' => 13500, 'crop' => 4600, 'time' => 58080), array('wood' => 25000, 'clay' => 20500, 'iron' => 15000, 'crop' => 5100, 'time' =>
+ 63360), array('wood' => 28000, 'clay' => 22500, 'iron' => 16500, 'crop' => 5700, 'time' => 68640), array('wood' => 30500, 'clay' => 24500, 'iron' => 18000, 'crop' => 6200, 'time' => 73920), array('wood' => 33500, 'clay' => 27000, 'iron' => 20000, 'crop' => 6800, 'time' => 79200), array('wood' => 36000, 'clay' => 29000, 'iron' => 21500, 'crop' => 7400, 'time' => 84480), array('wood' => 39000, 'clay' => 31500, 'iron' => 23000, 'crop' => 7900, 'time' => 89760), array('wood' => 42000, 'clay' => 33500, 'iron' => 25000, 'crop' => 8500,
+ 'time' => 95040), array('wood' => 45000, 'clay' => 36000, 'iron' => 26500, 'crop' => 9100, 'time' => 100320), array('wood' => 48000, 'clay' => 38500, 'iron' => 28500, 'crop' => 9700, 'time' => 105600), array('wood' => 51000, 'clay' => 41000, 'iron' => 30000, 'crop' => 10500, 'time' => 110880), array('wood' => 54000, 'clay' => 43500, 'iron' => 32000, 'crop' => 11000, 'time' => 116160), array('wood' => 57000, 'clay' => 46000, 'iron' => 33500, 'crop' => 11500, 'time' => 121440), array('wood' => 60000, 'clay' => 48500, 'iron' => 35500,
+ 'crop' => 12000, 'time' => 126720), array('wood' => 63000, 'clay' => 51000, 'iron' => 37500, 'crop' => 13000, 'time' => 132000), array('wood' => 66500, 'clay' => 53500, 'iron' => 39500, 'crop' => 13500, 'time' => 137280), array('wood' => 69500, 'clay' => 56000, 'iron' => 41000, 'crop' => 14000, 'time' => 142560), array('wood' => 73000, 'clay' => 58500, 'iron' => 43000, 'crop' => 15000, 'time' => 147840), array('wood' => 76000, 'clay' => 61000, 'iron' => 45000, 'crop' => 15500, 'time' => 153120), array('wood' => 79500, 'clay' => 64000,
+ 'iron' => 47000, 'crop' => 16000, 'time' => 158400), array('wood' => 82500, 'clay' => 66500, 'iron' => 49000, 'crop' => 17000, 'time' => 163680), array('wood' => 86000, 'clay' => 69500, 'iron' => 51000, 'crop' => 17500, 'time' => 168960), array('wood' => 89500, 'clay' => 72000, 'iron' => 53000, 'crop' => 18000, 'time' => 174240), array('wood' => 93000, 'clay' => 74500, 'iron' => 55000, 'crop' => 19000, 'time' => 179520), array('wood' => 96000, 'clay' => 77500, 'iron' => 57000, 'crop' => 19500, 'time' => 184800), array('wood' => 99500,
+ 'clay' => 80000, 'iron' => 59000, 'crop' => 20500, 'time' => 190080), array('wood' => 103000, 'clay' => 83000, 'iron' => 61000, 'crop' => 21000, 'time' => 195360), array('wood' => 106500, 'clay' => 86000, 'iron' => 63000, 'crop' => 21500, 'time' => 200640), array('wood' => 110000, 'clay' => 88500, 'iron' => 65500, 'crop' => 22500, 'time' => 205920), array('wood' => 113500, 'clay' => 91500, 'iron' => 67500, 'crop' => 23000, 'time' => 211200), array('wood' => 117000, 'clay' => 94500, 'iron' => 69500, 'crop' => 24000, 'time' => 216480),
+ array('wood' => 121000, 'clay' => 97500, 'iron' => 75500, 'crop' => 24500, 'time' => 221760), array('wood' => 124500, 'clay' => 100000, 'iron' => 74000, 'crop' => 25500, 'time' => 227040), array('wood' => 128000, 'clay' => 103000, 'iron' => 76000, 'crop' => 26000, 'time' => 232320), array('wood' => 131500, 'clay' => 106000, 'iron' => 78000, 'crop' => 27000, 'time' => 237600), array('wood' => 135500, 'clay' => 109000, 'iron' => 80500, 'crop' => 27500, 'time' => 242800), array('wood' => 139000, 'clay' => 112000, 'iron' => 82500, 'crop' =>
+ 28500, 'time' => 248160), array('wood' => 143000, 'clay' => 115000, 'iron' => 84500, 'crop' => 29000, 'time' => 253440), array('wood' => 146500, 'clay' => 118000, 'iron' => 87000, 'crop' => 30000, 'time' => 258720), array('wood' => 150000, 'clay' => 121000, 'iron' => 89000, 'crop' => 30500, 'time' => 264000), array('wood' => 154000, 'clay' => 124000, 'iron' => 91500, 'crop' => 31500, 'time' => 269280), array('wood' => 158000, 'clay' => 127000, 'iron' => 93500, 'crop' => 32000, 'time' => 274560), array('wood' => 161500, 'clay' => 130000,
+ 'iron' => 96000, 'crop' => 33000, 'time' => 279840), array('wood' => 165500, 'clay' => 133000, 'iron' => 98000, 'crop' => 33500, 'time' => 285120), array('wood' => 169500, 'clay' => 136500, 'iron' => 100500, 'crop' => 34500, 'time' => 290400), array('wood' => 173000, 'clay' => 139500, 'iron' => 102500, 'crop' => 35000, 'time' => 295680), array('wood' => 177000, 'clay' => 142500, 'iron' => 105000, 'crop' => 36000, 'time' => 300960), array('wood' => 181000, 'clay' => 145500, 'iron' => 107000, 'crop' => 37000, 'time' => 306240), array('wood' =>
+ 185000, 'clay' => 149000, 'iron' => 109500, 'crop' => 37500, 'time' => 311520), array('wood' => 188500, 'clay' => 152000, 'iron' => 112000, 'crop' => 38500, 'time' => 316800), array('wood' => 192500, 'clay' => 155000, 'iron' => 114000, 'crop' => 39000, 'time' => 322080));
+ $h6_full = array(array('wood' => 1100, 'clay' => 1300, 'iron' => 1600, 'crop' => 360, 'time' => 7040), array('wood' => 2700, 'clay' => 3100, 'iron' => 3900, 'crop' => 930, 'time' => 14080), array('wood' => 4500, 'clay' => 5200, 'iron' => 6400, 'crop' => 1500, 'time' => 21120), array('wood' => 6400, 'clay' => 7400, 'iron' => 9200, 'crop' => 2200, 'time' => 28160), array('wood' => 8400, 'clay' => 9800, 'iron' => 12000, 'crop' => 2900, 'time' => 35200), array('wood' => 10500, 'clay' => 12500, 'iron' => 15500, 'crop' => 3700, 'time' => 42240),
+ array('wood' => 13000, 'clay' => 15000, 'iron' => 18500, 'crop' => 4400, 'time' => 49280), array('wood' => 15000, 'clay' => 17500, 'iron' => 22000, 'crop' => 5200, 'time' => 56320), array('wood' => 17500, 'clay' => 20500, 'iron' => 25500, 'crop' => 6100, 'time' => 63360), array('wood' => 20000, 'clay' => 23500, 'iron' => 29000, 'crop' => 6900, 'time' => 70400), array('wood' => 22500, 'clay' => 26000, 'iron' => 32500, 'crop' => 7800, 'time' => 77440), array('wood' => 25000, 'clay' => 29500, 'iron' => 36500, 'crop' => 8700, 'time' => 84480),
+ array('wood' => 28000, 'clay' => 32500, 'iron' => 40000, 'crop' => 9600, 'time' => 91520), array('wood' => 30500, 'clay' => 35500, 'iron' => 44000, 'crop' => 10500, 'time' => 98560), array('wood' => 33500, 'clay' => 38500, 'iron' => 48000, 'crop' => 11500, 'time' => 105600), array('wood' => 36000, 'clay' => 42000, 'iron' => 52000, 'crop' => 12500, 'time' => 112640), array('wood' => 39000, 'clay' => 45000, 'iron' => 56500, 'crop' => 13500, 'time' => 119680), array('wood' => 42000, 'clay' => 48500, 'iron' => 60500, 'crop' => 14500, 'time' =>
+ 126720), array('wood' => 45000, 'clay' => 52000, 'iron' => 64500, 'crop' => 15500, 'time' => 133760), array('wood' => 48000, 'clay' => 55500, 'iron' => 69000, 'crop' => 16500, 'time' => 140800), array('wood' => 51000, 'clay' => 59000, 'iron' => 73500, 'crop' => 17500, 'time' => 147840), array('wood' => 54000, 'clay' => 62500, 'iron' => 77500, 'crop' => 18500, 'time' => 154880), array('wood' => 57000, 'clay' => 66000, 'iron' => 82000, 'crop' => 19500, 'time' => 161920), array('wood' => 60000, 'clay' => 69500, 'iron' => 86500, 'crop' => 20500,
+ 'time' => 168960), array('wood' => 63000, 'clay' => 73000, 'iron' => 91000, 'crop' => 22000, 'time' => 176000), array('wood' => 66500, 'clay' => 77000, 'iron' => 95500, 'crop' => 23000, 'time' => 183040), array('wood' => 69500, 'clay' => 80500, 'iron' => 100500, 'crop' => 24000, 'time' => 190080), array('wood' => 73000, 'clay' => 84500, 'iron' => 105000, 'crop' => 25000, 'time' => 197120), array('wood' => 76000, 'clay' => 88000, 'iron' => 109500, 'crop' => 26000, 'time' => 204160), array('wood' => 79500, 'clay' => 92000, 'iron' => 114500,
+ 'crop' => 27500, 'time' => 211200), array('wood' => 82500, 'clay' => 96000, 'iron' => 119000, 'crop' => 28500, 'time' => 218240), array('wood' => 86000, 'clay' => 99500, 'iron' => 124000, 'crop' => 29500, 'time' => 255280), array('wood' => 89500, 'clay' => 103500, 'iron' => 129000, 'crop' => 31000, 'time' => 232320), array('wood' => 93000, 'clay' => 107500, 'iron' => 134000, 'crop' => 32000, 'time' => 239360), array('wood' => 96000, 'clay' => 111500, 'iron' => 139000, 'crop' => 33000, 'time' => 246400), array('wood' => 99500, 'clay' => 115500,
+ 'iron' => 143500, 'crop' => 34500, 'time' => 253440), array('wood' => 103000, 'clay' => 119500, 'iron' => 148500, 'crop' => 35500, 'time' => 260480), array('wood' => 106500, 'clay' => 123500, 'iron' => 154000, 'crop' => 37000, 'time' => 267520), array('wood' => 110000, 'clay' => 127500, 'iron' => 159000, 'crop' => 38000, 'time' => 274560), array('wood' => 113500, 'clay' => 132000, 'iron' => 164000, 'crop' => 39000, 'time' => 281600), array('wood' => 117000, 'clay' => 136000, 'iron' => 169000, 'crop' => 40500, 'time' => 288640), array('wood' =>
+ 121000, 'clay' => 140000, 'iron' => 174500, 'crop' => 41500, 'time' => 295680), array('wood' => 124500, 'clay' => 144000, 'iron' => 179500, 'crop' => 43000, 'time' => 302720), array('wood' => 128000, 'clay' => 148500, 'iron' => 184500, 'crop' => 44000, 'time' => 309760), array('wood' => 131500, 'clay' => 152500, 'iron' => 190000, 'crop' => 45500, 'time' => 316800), array('wood' => 135500, 'clay' => 157000, 'iron' => 195500, 'crop' => 46500, 'time' => 323840), array('wood' => 139000, 'clay' => 161000, 'iron' => 200500, 'crop' => 48000, 'time' =>
+ 330880), array('wood' => 143000, 'clay' => 165500, 'iron' => 206000, 'crop' => 49500, 'time' => 337920), array('wood' => 146500, 'clay' => 170000, 'iron' => 211500, 'crop' => 50500, 'time' => 344960), array('wood' => 150000, 'clay' => 174000, 'iron' => 216500, 'crop' => 52000, 'time' => 352000), array('wood' => 154000, 'clay' => 178500, 'iron' => 222000, 'crop' => 53000, 'time' => 359040), array('wood' => 46000, 'clay' => 183000, 'iron' => 227500, 'crop' => 54500, 'time' => 366080), array('wood' => 46000, 'clay' => 187500, 'iron' => 233000, 'crop'
+ => 56000, 'time' => 373120), array('wood' => 166500, 'clay' => 192000, 'iron' => 238500, 'crop' => 57000, 'time' => 380160), array('wood' => 169500, 'clay' => 196000, 'iron' => 240000, 'crop' => 58500, 'time' => 387200), array('wood' => 173000, 'clay' => 200500, 'iron' => 240000, 'crop' => 59500, 'time' => 394240), array('wood' => 177000, 'clay' => 205000, 'iron' => 240000, 'crop' => 61000, 'time' => 401280), array('wood' => 181000, 'clay' => 209500, 'iron' => 240000, 'crop' => 62500, 'time' => 406970), array('wood' => 185000, 'clay' => 214000,
+ 'iron' => 240000, 'crop' => 64000, 'time' => 415360), array('wood' => 188500, 'clay' => 219000, 'iron' => 240000, 'crop' => 65000, 'time' => 422400), array('wood' => 192500, 'clay' => 223500, 'iron' => 240000, 'crop' => 66500, 'time' => 429440));
+
+//TEUTON UNITS
+ $h11_full = array(array('wood' => 190, 'clay' => 150, 'iron' => 80, 'crop' => 80, 'time' => 1440), array('wood' => 520, 'clay' => 430, 'iron' => 260, 'crop' => 260, 'time' => 2880), array('wood' => 870, 'clay' => 710, 'iron' => 430, 'crop' => 430, 'time' => 4320), array('wood' => 1200, 'clay' => 1000, 'iron' => 620, 'crop' => 620, 'time' => 5760), array('wood' => 1600, 'clay' => 1300, 'iron' => 820, 'crop' => 820, 'time' => 7200), array('wood' => 2100, 'clay' => 1700, 'iron' => 1000, 'crop' => 1000, 'time' => 8640), array('wood' => 2500, 'clay' =>
+ 2000, 'iron' => 1300, 'crop' => 1300, 'time' => 10080), array('wood' => 3000, 'clay' => 2400, 'iron' => 1500, 'crop' => 1500, 'time' => 11520), array('wood' => 3400, 'clay' => 2800, 'iron' => 1700, 'crop' => 1700, 'time' => 12960), array('wood' => 3900, 'clay' => 3200, 'iron' => 2000, 'crop' => 2000, 'time' => 14400), array('wood' => 4400, 'clay' => 3600, 'iron' => 2200, 'crop' => 2200, 'time' => 15840), array('wood' => 4900, 'clay' => 4000, 'iron' => 2500, 'crop' => 2500, 'time' => 17280), array('wood' => 5400, 'clay' => 4400, 'iron' => 2700,
+ 'crop' => 2700, 'time' => 18720), array('wood' => 6000, 'clay' => 4900, 'iron' => 3000, 'crop' => 3000, 'time' => 20160), array('wood' => 6500, 'clay' => 5300, 'iron' => 3200, 'crop' => 3200, 'time' => 21600), array('wood' => 7000, 'clay' => 5800, 'iron' => 3500, 'crop' => 3500, 'time' => 23040), array('wood' => 7600, 'clay' => 6200, 'iron' => 3800, 'crop' => 3800, 'time' => 24480), array('wood' => 8200, 'clay' => 6700, 'iron' => 4100, 'crop' => 4100, 'time' => 25920), array('wood' => 8700, 'clay' => 7100, 'iron' => 4400, 'crop' => 4400,
+ 'time' => 27360), array('wood' => 9300, 'clay' => 7600, 'iron' => 4700, 'crop' => 4700, 'time' => 28800), array('wood' => 9900, 'clay' => 8100, 'iron' => 4900, 'crop' => 4900, 'time' => 30240), array('wood' => 10500, 'clay' => 8600, 'iron' => 5200, 'crop' => 5200, 'time' => 31680), array('wood' => 11000, 'clay' => 9100, 'iron' => 5500, 'crop' => 5500, 'time' => 33120), array('wood' => 11500, 'clay' => 9600, 'iron' => 5800, 'crop' => 5800, 'time' => 34560), array('wood' => 12500, 'clay' => 10000, 'iron' => 6100, 'crop' => 6100, 'time' => 36000),
+ array('wood' => 13000, 'clay' => 10500, 'iron' => 6500, 'crop' => 6500, 'time' => 37440), array('wood' => 13500, 'clay' => 11000, 'iron' => 6800, 'crop' => 6800, 'time' => 38880), array('wood' => 14000, 'clay' => 11500, 'iron' => 7100, 'crop' => 7100, 'time' => 40320), array('wood' => 15000, 'clay' => 12000, 'iron' => 7400, 'crop' => 7400, 'time' => 41760), array('wood' => 15500, 'clay' => 12500, 'iron' => 7700, 'crop' => 7700, 'time' => 43200), array('wood' => 16000, 'clay' => 13000, 'iron' => 8000, 'crop' => 8000, 'time' => 44640), array('wood'
+ => 16500, 'clay' => 13500, 'iron' => 8400, 'crop' => 8400, 'time' => 46080), array('wood' => 17500, 'clay' => 14000, 'iron' => 8700, 'crop' => 8700, 'time' => 47520), array('wood' => 18000, 'clay' => 15000, 'iron' => 9000, 'crop' => 9000, 'time' => 48960), array('wood' => 18500, 'clay' => 15500, 'iron' => 9400, 'crop' => 9400, 'time' => 50400), array('wood' => 19500, 'clay' => 16000, 'iron' => 9700, 'crop' => 9700, 'time' => 51840), array('wood' => 20000, 'clay' => 16500, 'iron' => 10000, 'crop' => 10000, 'time' => 53280), array('wood' =>
+ 21000, 'clay' => 17000, 'iron' => 10500, 'crop' => 10500, 'time' => 54720), array('wood' => 21500, 'clay' => 17500, 'iron' => 10500, 'crop' => 10500, 'time' => 56160), array('wood' => 22000, 'clay' => 18000, 'iron' => 11000, 'crop' => 11000, 'time' => 57600), array('wood' => 23000, 'clay' => 18500, 'iron' => 11500, 'crop' => 11500, 'time' => 59040), array('wood' => 23500, 'clay' => 19000, 'iron' => 12000, 'crop' => 12000, 'time' => 60480), array('wood' => 24000, 'clay' => 20000, 'iron' => 12000, 'crop' => 12000, 'time' => 61920), array('wood' =>
+ 25000, 'clay' => 20500, 'iron' => 12500, 'crop' => 12500, 'time' => 63360), array('wood' => 25500, 'clay' => 21000, 'iron' => 13000, 'crop' => 13000, 'time' => 64800), array('wood' => 26500, 'clay' => 21500, 'iron' => 13000, 'crop' => 13000, 'time' => 66240), array('wood' => 27000, 'clay' => 22000, 'iron' => 13500, 'crop' => 13500, 'time' => 67680), array('wood' => 28000, 'clay' => 22500, 'iron' => 14000, 'crop' => 14000, 'time' => 69120), array('wood' => 28500, 'clay' => 23500, 'iron' => 14500, 'crop' => 14500, 'time' => 70560), array('wood' =>
+ 29500, 'clay' => 24000, 'iron' => 14500, 'crop' => 14500, 'time' => 72000), array('wood' => 30000, 'clay' => 24500, 'iron' => 15000, 'crop' => 15000, 'time' => 73440), array('wood' => 30500, 'clay' => 25000, 'iron' => 15500, 'crop' => 15500, 'time' => 74880), array('wood' => 31500, 'clay' => 25500, 'iron' => 15500, 'crop' => 15500, 'time' => 76320), array('wood' => 32000, 'clay' => 26500, 'iron' => 16000, 'crop' => 16000, 'time' => 77760), array('wood' => 33000, 'clay' => 27000, 'iron' => 16500, 'crop' => 16500, 'time' => 79200), array('wood' =>
+ 33500, 'clay' => 27500, 'iron' => 17000, 'crop' => 17000, 'time' => 80640), array('wood' => 34500, 'clay' => 28000, 'iron' => 17000, 'crop' => 17000, 'time' => 82080), array('wood' => 35000, 'clay' => 29000, 'iron' => 17500, 'crop' => 17500, 'time' => 83520), array('wood' => 36000, 'clay' => 29500, 'iron' => 18000, 'crop' => 18000, 'time' => 84960), array('wood' => 36500, 'clay' => 30000, 'iron' => 18500, 'crop' => 18500, 'time' => 86400), array('wood' => 37500, 'clay' => 30500, 'iron' => 19000, 'crop' => 19000, 'time' => 87840));
+ $h12_full = array(array('wood' => 290, 'clay' => 140, 'iron' => 170, 'crop' => 80, 'time' => 2240), array('wood' => 760, 'clay' => 400, 'iron' => 480, 'crop' => 260, 'time' => 4480), array('wood' => 1300, 'clay' => 670, 'iron' => 790, 'crop' => 430, 'time' => 6720), array('wood' => 1800, 'clay' => 960, 'iron' => 1100, 'crop' => 620, 'time' => 8960), array('wood' => 2400, 'clay' => 1300, 'iron' => 1500, 'crop' => 820, 'time' => 11200), array('wood' => 3000, 'clay' => 1600, 'iron' => 1900, 'crop' => 1000, 'time' => 13440), array('wood' => 3600,
+ 'clay' => 1900, 'iron' => 2300, 'crop' => 1300, 'time' => 15680), array('wood' => 4300, 'clay' => 2300, 'iron' => 2700, 'crop' => 1500, 'time' => 17920), array('wood' => 5000, 'clay' => 2700, 'iron' => 3100, 'crop' => 1700, 'time' => 20160), array('wood' => 5700, 'clay' => 3000, 'iron' => 3600, 'crop' => 2000, 'time' => 22400), array('wood' => 6400, 'clay' => 3400, 'iron' => 4000, 'crop' => 2200, 'time' => 24640), array('wood' => 7100, 'clay' => 3800, 'iron' => 4500, 'crop' => 2500, 'time' => 26880), array('wood' => 7900, 'clay' => 4200,
+ 'iron' => 4900, 'crop' => 2700, 'time' => 29120), array('wood' => 8700, 'clay' => 4600, 'iron' => 5400, 'crop' => 3000, 'time' => 31360), array('wood' => 9400, 'clay' => 5000, 'iron' => 5900, 'crop' => 3200, 'time' => 33600), array('wood' => 10000, 'clay' => 5400, 'iron' => 6400, 'crop' => 3500, 'time' => 35840), array('wood' => 11000, 'clay' => 5900, 'iron' => 6900, 'crop' => 3800, 'time' => 38080), array('wood' => 12000, 'clay' => 6300, 'iron' => 7400, 'crop' => 4100, 'time' => 40320), array('wood' => 12500, 'clay' => 6700, 'iron' => 7900,
+ 'crop' => 4400, 'time' => 42560), array('wood' => 13500, 'clay' => 7200, 'iron' => 8500, 'crop' => 4700, 'time' => 44800), array('wood' => 14500, 'clay' => 7600, 'iron' => 9000, 'crop' => 4900, 'time' => 47040), array('wood' => 15000, 'clay' => 8100, 'iron' => 9500, 'crop' => 5200, 'time' => 49280), array('wood' => 16000, 'clay' => 8600, 'iron' => 10000, 'crop' => 5500, 'time' => 51520), array('wood' => 17000, 'clay' => 9000, 'iron' => 10500, 'crop' => 5800, 'time' => 53760), array('wood' => 18000, 'clay' => 9500, 'iron' => 11000, 'crop' => 6100,
+ 'time' => 56000), array('wood' => 19000, 'clay' => 10000, 'iron' => 11500, 'crop' => 6500, 'time' => 58240), array('wood' => 19500, 'clay' => 10500, 'iron' => 12500, 'crop' => 6800, 'time' => 60480), array('wood' => 20500, 'clay' => 11000, 'iron' => 13000, 'crop' => 7100, 'time' => 62720), array('wood' => 21500, 'clay' => 11500, 'iron' => 13500, 'crop' => 7400, 'time' => 64960), array('wood' => 22500, 'clay' => 12000, 'iron' => 14000, 'crop' => 7700, 'time' => 67200), array('wood' => 23500, 'clay' => 12500, 'iron' => 14500, 'crop' => 8000,
+ 'time' => 69440), array('wood' => 24500, 'clay' => 13000, 'iron' => 15000, 'crop' => 8400, 'time' => 71680), array('wood' => 25500, 'clay' => 13500, 'iron' => 16000, 'crop' => 8700, 'time' => 73920), array('wood' => 26500, 'clay' => 14000, 'iron' => 16500, 'crop' => 9000, 'time' => 76160), array('wood' => 27000, 'clay' => 14500, 'iron' => 17000, 'crop' => 9400, 'time' => 78400), array('wood' => 28000, 'clay' => 15000, 'iron' => 17500, 'crop' => 9700, 'time' => 80640), array('wood' => 29000, 'clay' => 15500, 'iron' => 18000, 'crop' => 10000,
+ 'time' => 82880), array('wood' => 30000, 'clay' => 16000, 'iron' => 18500, 'crop' => 10500, 'time' => 85120), array('wood' => 31000, 'clay' => 16500, 'iron' => 19500, 'crop' => 10500, 'time' => 87360), array('wood' => 32000, 'clay' => 17000, 'iron' => 20000, 'crop' => 11000, 'time' => 89600), array('wood' => 33000, 'clay' => 17500, 'iron' => 20500, 'crop' => 11500, 'time' => 91840), array('wood' => 34000, 'clay' => 18000, 'iron' => 21500, 'crop' => 12000, 'time' => 94080), array('wood' => 35000, 'clay' => 18500, 'iron' => 22000, 'crop' => 12000,
+ 'time' => 96320), array('wood' => 36500, 'clay' => 19500, 'iron' => 22500, 'crop' => 12500, 'time' => 98560), array('wood' => 37500, 'clay' => 20000, 'iron' => 23500, 'crop' => 13000, 'time' => 100800), array('wood' => 38500, 'clay' => 20500, 'iron' => 24000, 'crop' => 13000, 'time' => 103040), array('wood' => 39500, 'clay' => 21000, 'iron' => 24500, 'crop' => 13500, 'time' => 105280), array('wood' => 40500, 'clay' => 21500, 'iron' => 25500, 'crop' => 14000, 'time' => 107520), array('wood' => 41500, 'clay' => 22000, 'iron' => 26000, 'crop' =>
+ 14500, 'time' => 109760), array('wood' => 42500, 'clay' => 22500, 'iron' => 26500, 'crop' => 14500, 'time' => 112000), array('wood' => 43500, 'clay' => 23000, 'iron' => 27500, 'crop' => 15000, 'time' => 114240), array('wood' => 44500, 'clay' => 23500, 'iron' => 28000, 'crop' => 15500, 'time' => 116480), array('wood' => 46000, 'clay' => 24500, 'iron' => 28500, 'crop' => 15500, 'time' => 118720), array('wood' => 47000, 'clay' => 25000, 'iron' => 29500, 'crop' => 16000, 'time' => 120960), array('wood' => 48000, 'clay' => 25500, 'iron' => 30000,
+ 'crop' => 16500, 'time' => 123200), array('wood' => 49000, 'clay' => 26000, 'iron' => 30500, 'crop' => 17000, 'time' => 125440), array('wood' => 50000, 'clay' => 26500, 'iron' => 31500, 'crop' => 17000, 'time' => 127680), array('wood' => 51000, 'clay' => 27000, 'iron' => 32000, 'crop' => 17500, 'time' => 129920), array('wood' => 52500, 'clay' => 28000, 'iron' => 32500, 'crop' => 18000, 'time' => 132160), array('wood' => 53500, 'clay' => 28500, 'iron' => 33500, 'crop' => 18500, 'time' => 134400), array('wood' => 54500, 'clay' => 29000, 'iron' =>
+ 34000, 'crop' => 19000, 'time' => 136640));
+ $h13_full = array(array('wood' => 260, 'clay' => 240, 'iron' => 340, 'crop' => 140, 'time' => 2400), array('wood' => 690, 'clay' => 640, 'iron' => 880, 'crop' => 400, 'time' => 4800), array('wood' => 1100, 'clay' => 1100, 'iron' => 1500, 'crop' => 670, 'time' => 7200), array('wood' => 1600, 'clay' => 1500, 'iron' => 2100, 'crop' => 960, 'time' => 9600), array('wood' => 2200, 'clay' => 2000, 'iron' => 2800, 'crop' => 1300, 'time' => 12000), array('wood' => 2700, 'clay' => 2500, 'iron' => 3500, 'crop' => 1600, 'time' => 14400), array('wood' => 3300,
+ 'clay' => 3100, 'iron' => 4200, 'crop' => 1900, 'time' => 16800), array('wood' => 3900, 'clay' => 3600, 'iron' => 5000, 'crop' => 2300, 'time' => 19200), array('wood' => 4500, 'clay' => 4200, 'iron' => 5800, 'crop' => 2700, 'time' => 21600), array('wood' => 5200, 'clay' => 4800, 'iron' => 6600, 'crop' => 3000, 'time' => 24000), array('wood' => 5800, 'clay' => 5400, 'iron' => 7400, 'crop' => 3400, 'time' => 26400), array('wood' => 6500, 'clay' => 6000, 'iron' => 8300, 'crop' => 3800, 'time' => 28800), array('wood' => 7200, 'clay' => 6700, 'iron'
+ => 9100, 'crop' => 4200, 'time' => 31200), array('wood' => 7900, 'clay' => 7300, 'iron' => 10000, 'crop' => 4600, 'time' => 33600), array('wood' => 8600, 'clay' => 8000, 'iron' => 11000, 'crop' => 5000, 'time' => 36000), array('wood' => 9300, 'clay' => 8600, 'iron' => 12000, 'crop' => 5400, 'time' => 38400), array('wood' => 10000, 'clay' => 9300, 'iron' => 13000, 'crop' => 5900, 'time' => 40800), array('wood' => 11000, 'clay' => 10000, 'iron' => 13500, 'crop' => 6300, 'time' => 43200), array('wood' => 11500, 'clay' => 10500, 'iron' => 14500,
+ 'crop' => 6700, 'time' => 45600), array('wood' => 12500, 'clay' => 11500, 'iron' => 15500, 'crop' => 7200, 'time' => 48000), array('wood' => 13000, 'clay' => 12000, 'iron' => 16500, 'crop' => 7600, 'time' => 50400), array('wood' => 14000, 'clay' => 13000, 'iron' => 17500, 'crop' => 8100, 'time' => 52800), array('wood' => 14500, 'clay' => 13500, 'iron' => 18500, 'crop' => 8600, 'time' => 55200), array('wood' => 15500, 'clay' => 14500, 'iron' => 19500, 'crop' => 9000, 'time' => 57600), array('wood' => 16000, 'clay' => 15000, 'iron' => 20500,
+ 'crop' => 9500, 'time' => 60000), array('wood' => 17000, 'clay' => 16000, 'iron' => 21500, 'crop' => 10000, 'time' => 62400), array('wood' => 18000, 'clay' => 16500, 'iron' => 23000, 'crop' => 10500, 'time' => 64800), array('wood' => 18500, 'clay' => 17500, 'iron' => 24000, 'crop' => 11000, 'time' => 67200), array('wood' => 19500, 'clay' => 18000, 'iron' => 25000, 'crop' => 11500, 'time' => 69600), array('wood' => 20500, 'clay' => 19000, 'iron' => 26000, 'crop' => 12000, 'time' => 72000), array('wood' => 21000, 'clay' => 19500, 'iron' => 27000,
+ 'crop' => 12500, 'time' => 74400), array('wood' => 22000, 'clay' => 20500, 'iron' => 28000, 'crop' => 13000, 'time' => 76800), array('wood' => 23000, 'clay' => 21500, 'iron' => 29500, 'crop' => 13500, 'time' => 79200), array('wood' => 24000, 'clay' => 22000, 'iron' => 30500, 'crop' => 14000, 'time' => 81600), array('wood' => 24500, 'clay' => 23000, 'iron' => 31500, 'crop' => 14500, 'time' => 84000), array('wood' => 25500, 'clay' => 24000, 'iron' => 32500, 'crop' => 15000, 'time' => 86400), array('wood' => 26500, 'clay' => 24500, 'iron' => 34000,
+ 'crop' => 15500, 'time' => 88800), array('wood' => 27500, 'clay' => 25500, 'iron' => 35000, 'crop' => 16000, 'time' => 91200), array('wood' => 28500, 'clay' => 26500, 'iron' => 36000, 'crop' => 16500, 'time' => 93600), array('wood' => 29000, 'clay' => 27000, 'iron' => 37000, 'crop' => 17000, 'time' => 96000), array('wood' => 30000, 'clay' => 28000, 'iron' => 38500, 'crop' => 17500, 'time' => 98400), array('wood' => 31000, 'clay' => 29000, 'iron' => 39500, 'crop' => 18000, 'time' => 100800), array('wood' => 32000, 'clay' => 29500, 'iron' =>
+ 40500, 'crop' => 18500, 'time' => 103200), array('wood' => 33000, 'clay' => 30500, 'iron' => 42000, 'crop' => 19500, 'time' => 105600), array('wood' => 34000, 'clay' => 31500, 'iron' => 43000, 'crop' => 20000, 'time' => 108000), array('wood' => 34500, 'clay' => 32500, 'iron' => 44500, 'crop' => 20500, 'time' => 110400), array('wood' => 35500, 'clay' => 33000, 'iron' => 45500, 'crop' => 21000, 'time' => 112800), array('wood' => 36500, 'clay' => 34000, 'iron' => 46500, 'crop' => 21500, 'time' => 115200), array('wood' => 37500, 'clay' => 35000,
+ 'iron' => 48000, 'crop' => 22000, 'time' => 117600), array('wood' => 38500, 'clay' => 36000, 'iron' => 49000, 'crop' => 22500, 'time' => 120000), array('wood' => 39500, 'clay' => 37000, 'iron' => 50500, 'crop' => 23000, 'time' => 122400), array('wood' => 40500, 'clay' => 37500, 'iron' => 51500, 'crop' => 23500, 'time' => 124800), array('wood' => 41500, 'clay' => 38500, 'iron' => 53000, 'crop' => 24500, 'time' => 127200), array('wood' => 42500, 'clay' => 39500, 'iron' => 54000, 'crop' => 25000, 'time' => 129600), array('wood' => 43500, 'clay' =>
+ 40500, 'iron' => 55500, 'crop' => 25500, 'time' => 132000), array('wood' => 44500, 'clay' => 41500, 'iron' => 56500, 'crop' => 26000, 'time' => 134400), array('wood' => 45500, 'clay' => 42500, 'iron' => 58000, 'crop' => 26500, 'time' => 136800), array('wood' => 46500, 'clay' => 43000, 'iron' => 59000, 'crop' => 27000, 'time' => 139200), array('wood' => 47500, 'clay' => 44000, 'iron' => 60500, 'crop' => 28000, 'time' => 141600), array('wood' => 48500, 'clay' => 45000, 'iron' => 62000, 'crop' => 28500, 'time' => 144000), array('wood' => 49500,
+ 'clay' => 46000, 'iron' => 63000, 'crop' => 29000, 'time' => 146400));
+ $h15_full = array(array('wood' => 740, 'clay' => 540, 'iron' => 580, 'crop' => 150, 'time' => 4800), array('wood' => 1800, 'clay' => 1400, 'iron' => 1500, 'crop' => 430, 'time' => 9600), array('wood' => 3000, 'clay' => 2300, 'iron' => 2400, 'crop' => 710, 'time' => 14400), array('wood' => 4400, 'clay' => 3200, 'iron' => 3500, 'crop' => 1000, 'time' => 19200), array('wood' => 5800, 'clay' => 4300, 'iron' => 4600, 'crop' => 1300, 'time' => 24000), array('wood' => 7200, 'clay' => 5400, 'iron' => 5700, 'crop' => 1700, 'time' => 28800), array('wood' =>
+ 8800, 'clay' => 6500, 'iron' => 6900, 'crop' => 2000, 'time' => 33600), array('wood' => 10500, 'clay' => 7700, 'iron' => 8200, 'crop' => 2400, 'time' => 38400), array('wood' => 12000, 'clay' => 8900, 'iron' => 9500, 'crop' => 2800, 'time' => 43200), array('wood' => 13500, 'clay' => 10000, 'iron' => 11000, 'crop' => 3200, 'time' => 48000), array('wood' => 15500, 'clay' => 11500, 'iron' => 12000, 'crop' => 3600, 'time' => 52800), array('wood' => 17000, 'clay' => 12500, 'iron' => 13500, 'crop' => 4000, 'time' => 57600), array('wood' => 19000,
+ 'clay' => 14000, 'iron' => 15000, 'crop' => 4400, 'time' => 62400), array('wood' => 21000, 'clay' => 15500, 'iron' => 16500, 'crop' => 4900, 'time' => 67200), array('wood' => 22500, 'clay' => 17000, 'iron' => 18000, 'crop' => 5300, 'time' => 72000), array('wood' => 24500, 'clay' => 18000, 'iron' => 19500, 'crop' => 5800, 'time' => 76800), array('wood' => 26500, 'clay' => 19500, 'iron' => 21000, 'crop' => 6200, 'time' => 81600), array('wood' => 28500, 'clay' => 21000, 'iron' => 22500, 'crop' => 6700, 'time' => 86400), array('wood' => 30500,
+ 'clay' => 22500, 'iron' => 24000, 'crop' => 7100, 'time' => 91200), array('wood' => 32500, 'clay' => 24000, 'iron' => 26000, 'crop' => 7600, 'time' => 96000), array('wood' => 34500, 'clay' => 25500, 'iron' => 27500, 'crop' => 8100, 'time' => 100800), array('wood' => 36500, 'clay' => 27000, 'iron' => 29000, 'crop' => 8600, 'time' => 105600), array('wood' => 39000, 'clay' => 28500, 'iron' => 30500, 'crop' => 9100, 'time' => 110400), array('wood' => 41000, 'clay' => 30500, 'iron' => 32500, 'crop' => 9600, 'time' => 115200), array('wood' => 43000,
+ 'clay' => 32000, 'iron' => 34000, 'crop' => 10000, 'time' => 120000), array('wood' => 45000, 'clay' => 33500, 'iron' => 36000, 'crop' => 10500, 'time' => 124800), array('wood' => 47500, 'clay' => 35000, 'iron' => 37500, 'crop' => 11000, 'time' => 129600), array('wood' => 49500, 'clay' => 36500, 'iron' => 39500, 'crop' => 11500, 'time' => 134400), array('wood' => 52000, 'clay' => 38500, 'iron' => 41000, 'crop' => 12000, 'time' => 139200), array('wood' => 54000, 'clay' => 40000, 'iron' => 43000, 'crop' => 12500, 'time' => 144000), array('wood' =>
+ 56500, 'clay' => 41500, 'iron' => 44500, 'crop' => 13000, 'time' => 148800), array('wood' => 58500, 'clay' => 43500, 'iron' => 46500, 'crop' => 13500, 'time' => 153600), array('wood' => 61000, 'clay' => 45000, 'iron' => 48000, 'crop' => 14000, 'time' => 158400), array('wood' => 63000, 'clay' => 47000, 'iron' => 50000, 'crop' => 15000, 'time' => 163200), array('wood' => 65500, 'clay' => 48500, 'iron' => 52000, 'crop' => 15500, 'time' => 168000), array('wood' => 68000, 'clay' => 50500, 'iron' => 54000, 'crop' => 16000, 'time' => 172800),
+ array('wood' => 70500, 'clay' => 52000, 'iron' => 55500, 'crop' => 16500, 'time' => 177600), array('wood' => 72500, 'clay' => 54000, 'iron' => 57500, 'crop' => 17000, 'time' => 182400), array('wood' => 75000, 'clay' => 55500, 'iron' => 59500, 'crop' => 17500, 'time' => 187200), array('wood' => 77500, 'clay' => 57500, 'iron' => 61500, 'crop' => 18000, 'time' => 192000), array('wood' => 80000, 'clay' => 59000, 'iron' => 63500, 'crop' => 18500, 'time' => 196800), array('wood' => 82500, 'clay' => 61000, 'iron' => 65000, 'crop' => 19000, 'time' =>
+ 201600), array('wood' => 85000, 'clay' => 63000, 'iron' => 67000, 'crop' => 20000, 'time' => 206400), array('wood' => 87500, 'clay' => 64500, 'iron' => 69000, 'crop' => 20500, 'time' => 211200), array('wood' => 89500, 'clay' => 66500, 'iron' => 71000, 'crop' => 21000, 'time' => 216000), array('wood' => 92000, 'clay' => 68500, 'iron' => 73000, 'crop' => 21500, 'time' => 220800), array('wood' => 95000, 'clay' => 70000, 'iron' => 75000, 'crop' => 22000, 'time' => 225600), array('wood' => 97500, 'clay' => 72000, 'iron' => 77000, 'crop' => 22500,
+ 'time' => 230400), array('wood' => 100000, 'clay' => 74000, 'iron' => 79000, 'crop' => 23500, 'time' => 235200), array('wood' => 102500, 'clay' => 76000, 'iron' => 81000, 'crop' => 24000, 'time' => 240000), array('wood' => 105000, 'clay' => 77500, 'iron' => 83000, 'crop' => 24500, 'time' => 244800), array('wood' => 107500, 'clay' => 79500, 'iron' => 85000, 'crop' => 25000, 'time' => 249600), array('wood' => 110000, 'clay' => 81500, 'iron' => 87000, 'crop' => 25500, 'time' => 254400), array('wood' => 112500, 'clay' => 83500, 'iron' => 89500,
+ 'crop' => 26500, 'time' => 259200), array('wood' => 115500, 'clay' => 85500, 'iron' => 91500, 'crop' => 27000, 'time' => 264000), array('wood' => 118000, 'clay' => 87500, 'iron' => 93500, 'crop' => 27500, 'time' => 268800), array('wood' => 120500, 'clay' => 89500, 'iron' => 95500, 'crop' => 28000, 'time' => 273600), array('wood' => 123000, 'clay' => 91000, 'iron' => 97500, 'crop' => 29000, 'time' => 278400), array('wood' => 126000, 'clay' => 93000, 'iron' => 99500, 'crop' => 29500, 'time' => 283200), array('wood' => 128500, 'clay' => 95000,
+ 'iron' => 102000, 'crop' => 30000, 'time' => 288000), array('wood' => 131500, 'clay' => 97000, 'iron' => 104000, 'crop' => 30500, 'time' => 292800));
+ $h16_full = array(array('wood' => 900, 'clay' => 1000, 'iron' => 960, 'crop' => 160, 'time' => 5920), array('wood' => 2200, 'clay' => 2500, 'iron' => 2400, 'crop' => 450, 'time' => 11840), array('wood' => 3700, 'clay' => 4200, 'iron' => 3900, 'crop' => 750, 'time' => 17760), array('wood' => 5300, 'clay' => 6000, 'iron' => 5600, 'crop' => 1100, 'time' => 23680), array('wood' => 7000, 'clay' => 7900, 'iron' => 7400, 'crop' => 1400, 'time' => 29600), array('wood' => 8700, 'clay' => 10000, 'iron' => 9300, 'crop' => 1800, 'time' => 35520), array('wood' =>
+ 10500, 'clay' => 12000, 'iron' => 11500, 'crop' => 2200, 'time' => 41440), array('wood' => 12500, 'clay' => 14500, 'iron' => 13500, 'crop' => 2600, 'time' => 47360), array('wood' => 14500, 'clay' => 16500, 'iron' => 15500, 'crop' => 3000, 'time' => 53280), array('wood' => 16500, 'clay' => 19000, 'iron' => 17500, 'crop' => 3400, 'time' => 59200), array('wood' => 18500, 'clay' => 21000, 'iron' => 20000, 'crop' => 3800, 'time' => 65120), array('wood' => 21000, 'clay' => 23500, 'iron' => 22000, 'crop' => 4200, 'time' => 71040), array('wood' => 23000,
+ 'clay' => 26000, 'iron' => 24500, 'crop' => 4700, 'time' => 76960), array('wood' => 25000, 'clay' => 28500, 'iron' => 27000, 'crop' => 5100, 'time' => 82880), array('wood' => 27500, 'clay' => 31500, 'iron' => 29000, 'crop' => 5600, 'time' => 88800), array('wood' => 30000, 'clay' => 34000, 'iron' => 31500, 'crop' => 6100, 'time' => 94720), array('wood' => 32000, 'clay' => 36500, 'iron' => 34000, 'crop' => 6600, 'time' => 100640), array('wood' => 34500, 'clay' => 39500, 'iron' => 36500, 'crop' => 7000, 'time' => 106560), array('wood' => 37000,
+ 'clay' => 42000, 'iron' => 39500, 'crop' => 7500, 'time' => 112480), array('wood' => 39500, 'clay' => 45000, 'iron' => 42000, 'crop' => 8000, 'time' => 118400), array('wood' => 42000, 'clay' => 47500, 'iron' => 44500, 'crop' => 8500, 'time' => 124320), array('wood' => 44500, 'clay' => 50500, 'iron' => 47000, 'crop' => 9100, 'time' => 130240), array('wood' => 47000, 'clay' => 53500, 'iron' => 50000, 'crop' => 9600, 'time' => 136160), array('wood' => 49500, 'clay' => 56500, 'iron' => 52500, 'crop' => 10000, 'time' => 142080), array('wood' => 52000,
+ 'clay' => 59500, 'iron' => 55500, 'crop' => 10500, 'time' => 148000), array('wood' => 54500, 'clay' => 62000, 'iron' => 58000, 'crop' => 11000, 'time' => 153920), array('wood' => 57000, 'clay' => 65000, 'iron' => 61000, 'crop' => 11500, 'time' => 159840), array('wood' => 60000, 'clay' => 68500, 'iron' => 64000, 'crop' => 12000, 'time' => 165760), array('wood' => 62500, 'clay' => 71500, 'iron' => 66500, 'crop' => 13000, 'time' => 171680), array('wood' => 65500, 'clay' => 74500, 'iron' => 69500, 'crop' => 13500, 'time' => 177600), array('wood' =>
+ 68000, 'clay' => 77500, 'iron' => 72500, 'crop' => 14000, 'time' => 183520), array('wood' => 71000, 'clay' => 80500, 'iron' => 75500, 'crop' => 14500, 'time' => 189440), array('wood' => 73500, 'clay' => 84000, 'iron' => 78500, 'crop' => 15000, 'time' => 195360), array('wood' => 76500, 'clay' => 87000, 'iron' => 81500, 'crop' => 15500, 'time' => 201280), array('wood' => 79000, 'clay' => 90000, 'iron' => 84500, 'crop' => 16000, 'time' => 207200), array('wood' => 82000, 'clay' => 93500, 'iron' => 87500, 'crop' => 17000, 'time' => 213120),
+ array('wood' => 85000, 'clay' => 96500, 'iron' => 90500, 'crop' => 17500, 'time' => 219040), array('wood' => 87500, 'clay' => 100000, 'iron' => 93500, 'crop' => 18000, 'time' => 224960), array('wood' => 90500, 'clay' => 103500, 'iron' => 96500, 'crop' => 18500, 'time' => 230880), array('wood' => 93500, 'clay' => 106500, 'iron' => 99500, 'crop' => 19000, 'time' => 236800), array('wood' => 96500, 'clay' => 110000, 'iron' => 102500, 'crop' => 19500, 'time' => 242720), array('wood' => 99500, 'clay' => 113500, 'iron' => 106000, 'crop' => 20500,
+ 'time' => 248640), array('wood' => 102500, 'clay' => 116500, 'iron' => 109000, 'crop' => 21000, 'time' => 244560), array('wood' => 105500, 'clay' => 120000, 'iron' => 112000, 'crop' => 21500, 'time' => 260480), array('wood' => 108500, 'clay' => 123500, 'iron' => 115500, 'crop' => 22000, 'time' => 266400), array('wood' => 111500, 'clay' => 127000, 'iron' => 118500, 'crop' => 23000, 'time' => 272320), array('wood' => 114500, 'clay' => 130500, 'iron' => 122000, 'crop' => 23500, 'time' => 278240), array('wood' => 117500, 'clay' => 134000, 'iron' =>
+ 125000, 'crop' => 24000, 'time' => 284160), array('wood' => 120500, 'clay' => 137500, 'iron' => 128500, 'crop' => 24500, 'time' => 290080), array('wood' => 123500, 'clay' => 141000, 'iron' => 131500, 'crop' => 25500, 'time' => 296000), array('wood' => 126500, 'clay' => 144500, 'iron' => 135000, 'crop' => 26000, 'time' => 301920), array('wood' => 130000, 'clay' => 148000, 'iron' => 138000, 'crop' => 26500, 'time' => 307840), array('wood' => 133000, 'clay' => 151500, 'iron' => 141500, 'crop' => 27000, 'time' => 313760), array('wood' => 136000,
+ 'clay' => 155000, 'iron' => 145000, 'crop' => 28000, 'time' => 319680), array('wood' => 139500, 'clay' => 159000, 'iron' => 148500, 'crop' => 28500, 'time' => 325600), array('wood' => 142500, 'clay' => 162500, 'iron' => 151500, 'crop' => 29000, 'time' => 331520), array('wood' => 145500, 'clay' => 166000, 'iron' => 155000, 'crop' => 30000, 'time' => 337440), array('wood' => 149000, 'clay' => 169500, 'iron' => 158500, 'crop' => 30500, 'time' => 343360), array('wood' => 152000, 'clay' => 173500, 'iron' => 162000, 'crop' => 31000, 'time' => 349280),
+ array('wood' => 155500, 'clay' => 177000, 'iron' => 165500, 'crop' => 31500, 'time' => 355200), array('wood' => 158500, 'clay' => 180500, 'iron' => 169000, 'crop' => 32500, 'time' => 361120));
+
+//GAUL UNITS
+ $h21_full = array(array('wood' => 200, 'clay' => 260, 'iron' => 110, 'clay' => 60, 'time' => 2080), array('wood' => 550, 'clay' => 690, 'iron' => 330, 'clay' => 210, 'time' => 4160), array('wood' => 910, 'clay' => 1100, 'iron' => 550, 'clay' => 360, 'time' => 6240), array('wood' => 1300, 'clay' => 1600, 'iron' => 790, 'clay' => 510, 'time' => 8320), array('wood' => 1700, 'clay' => 2200, 'iron' => 1000, 'clay' => 670, 'time' => 10400), array('wood' => 2200, 'clay' => 2700, 'iron' => 1300, 'clay' =>
+ 850, 'time' => 12480), array('wood' => 2600, 'clay' => 3300, 'iron' => 1600, 'clay' => 1000, 'time' => 14560), array('wood' => 3100, 'clay' => 3900, 'iron' => 1900, 'clay' => 1200, 'time' => 16640), array('wood' => 3600, 'clay' => 4500, 'iron' => 2200, 'clay' => 1400, 'time' => 18720), array('wood' => 4100, 'clay' => 5200, 'iron' => 2500, 'clay' => 1600, 'time' => 20800), array('wood' => 4600, 'clay' => 5800, 'iron' => 2800, 'clay' => 1800, 'time' => 22880), array('wood' => 5100, 'clay' => 6500,
+ 'iron' => 3100, 'clay' => 2000, 'time' => 24960), array('wood' => 5700, 'clay' => 7200, 'iron' => 3500, 'clay' => 2200, 'time' => 27040), array('wood' => 6200, 'clay' => 7900, 'iron' => 3800, 'clay' => 2400, 'time' => 29120), array('wood' => 6800, 'clay' => 8600, 'iron' => 4100, 'clay' => 2700, 'time' => 31200), array('wood' => 7400, 'clay' => 9300, 'iron' => 4500, 'clay' => 2900, 'time' => 33280), array('wood' => 7900, 'clay' => 10000, 'iron' => 4800, 'clay' => 3100, 'time' => 35360), array('wood' =>
+ 8500, 'clay' => 11000, 'iron' => 5200, 'clay' => 3300, 'time' => 37440), array('wood' => 9100, 'clay' => 11500, 'iron' => 5600, 'clay' => 3600, 'time' => 39520), array('wood' => 9700, 'clay' => 12500, 'iron' => 5900, 'clay' => 3800, 'time' => 41600), array('wood' => 10500, 'clay' => 13000, 'iron' => 6300, 'clay' => 4000, 'time' => 43680), array('wood' => 11000, 'clay' => 14000, 'iron' => 6700, 'clay' => 4300, 'time' => 45760), array('wood' => 11500, 'clay' => 14500, 'iron' => 7100, 'clay' =>
+ 4500, 'time' => 47840), array('wood' => 12000, 'clay' => 15500, 'iron' => 7400, 'clay' => 4800, 'time' => 49920), array('wood' => 13000, 'clay' => 16000, 'iron' => 7800, 'clay' => 5000, 'time' => 52000), array('wood' => 13500, 'clay' => 17000, 'iron' => 8200, 'clay' => 5300, 'time' => 54080), array('wood' => 14000, 'clay' => 18000, 'iron' => 8600, 'clay' => 5500, 'time' => 56160), array('wood' => 15000, 'clay' => 18500, 'iron' => 9000, 'clay' => 5800, 'time' => 58240), array('wood' => 15500,
+ 'clay' => 19500, 'iron' => 9400, 'clay' => 6100, 'time' => 60320), array('wood' => 16000, 'clay' => 20500, 'iron' => 9800, 'clay' => 6300, 'time' => 62400), array('wood' => 17000, 'clay' => 21000, 'iron' => 10000, 'clay' => 6600, 'time' => 64480), array('wood' => 17500, 'clay' => 22000, 'iron' => 10500, 'clay' => 6800, 'time' => 66560), array('wood' => 18000, 'clay' => 23000, 'iron' => 11000, 'clay' => 7100, 'time' => 68640), array('wood' => 19000, 'clay' => 24000, 'iron' => 11500, 'clay' =>
+ 7400, 'time' => 70720), array('wood' => 19500, 'clay' => 24500, 'iron' => 12000, 'clay' => 7700, 'time' => 72800), array('wood' => 20500, 'clay' => 25500, 'iron' => 12500, 'clay' => 7900, 'time' => 74880), array('wood' => 21000, 'clay' => 26500, 'iron' => 13000, 'clay' => 8200, 'time' => 76960), array('wood' => 21500, 'clay' => 27500, 'iron' => 13000, 'clay' => 8500, 'time' => 79040), array('wood' => 22500, 'clay' => 28500, 'iron' => 13500, 'clay' => 8800, 'time' => 81120), array('wood' => 23000,
+ 'clay' => 29000, 'iron' => 14000, 'clay' => 9100, 'time' => 83200), array('wood' => 24000, 'clay' => 30000, 'iron' => 14500, 'clay' => 9300, 'time' => 85280), array('wood' => 24500, 'clay' => 31000, 'iron' => 15000, 'clay' => 9600, 'time' => 87360), array('wood' => 25500, 'clay' => 32000, 'iron' => 15500, 'clay' => 9900, 'time' => 89440), array('wood' => 26000, 'clay' => 33000, 'iron' => 16000, 'clay' => 10000, 'time' => 91520), array('wood' => 27000, 'clay' => 34000, 'iron' => 16500, 'clay' =>
+ 10500, 'time' => 93600), array('wood' => 27500, 'clay' => 34500, 'iron' => 17000, 'clay' => 11000, 'time' => 95680), array('wood' => 28500, 'clay' => 35500, 'iron' => 17000, 'clay' => 11000, 'time' => 97760), array('wood' => 29000, 'clay' => 36500, 'iron' => 17500, 'clay' => 11500, 'time' => 99840), array('wood' => 30000, 'clay' => 37500, 'iron' => 18000, 'clay' => 11500, 'time' => 101920), array('wood' => 30500, 'clay' => 38500, 'iron' => 18500, 'clay' => 12000, 'time' => 104000), array('wood' =>
+ 31500, 'clay' => 39500, 'iron' => 19000, 'clay' => 12500, 'time' => 106080), array('wood' => 32000, 'clay' => 40500, 'iron' => 19500, 'clay' => 12500, 'time' => 108160), array('wood' => 33000, 'clay' => 41500, 'iron' => 20000, 'clay' => 13000, 'time' => 110240), array('wood' => 33500, 'clay' => 42500, 'iron' => 20500, 'clay' => 13000, 'time' => 112320), array('wood' => 34500, 'clay' => 43500, 'iron' => 21000, 'clay' => 13500, 'time' => 114400), array('wood' => 35000, 'clay' => 44500, 'iron' =>
+ 21500, 'clay' => 14000, 'time' => 116480), array('wood' => 36000, 'clay' => 45500, 'iron' => 22000, 'clay' => 14000, 'time' => 118560), array('wood' => 37000, 'clay' => 46500, 'iron' => 22500, 'clay' => 14500, 'time' => 120640), array('wood' => 37500, 'clay' => 47500, 'iron' => 23000, 'clay' => 14500, 'time' => 122720), array('wood' => 38500, 'clay' => 48500, 'iron' => 23500, 'clay' => 15000, 'time' => 124800), array('wood' => 39000, 'clay' => 49500, 'iron' => 24000, 'clay' => 15500, 'time' =>
+ 126880));
+ $h22_full = array(array('wood' => 280, 'clay' => 300, 'iron' => 370, 'crop' => 120, 'time' => 2880), array('wood' => 740, 'clay' => 780, 'iron' => 950, 'crop' => 360, 'time' => 5760), array('wood' => 1200, 'clay' => 1300, 'iron' => 1600, 'crop' => 590, 'time' => 8640), array('wood' => 1800, 'clay' => 1900, 'iron' => 2300, 'crop' => 850, 'time' => 11520), array('wood' => 2300, 'clay' => 2500, 'iron' => 3000, 'crop' => 1100, 'time' => 14400), array('wood' => 2900, 'clay' => 3100, 'iron' => 3800,
+ 'crop' => 1400, 'time' => 17280), array('wood' => 3500, 'clay' => 3800, 'iron' => 4600, 'crop' => 1700, 'time' => 20160), array('wood' => 4200, 'clay' => 4400, 'iron' => 5400, 'crop' => 2000, 'time' => 23040), array('wood' => 4800, 'clay' => 5100, 'iron' => 6200, 'crop' => 2300, 'time' => 25920), array('wood' => 5500, 'clay' => 5900, 'iron' => 7100, 'crop' => 2700, 'time' => 28800), array('wood' => 6200, 'clay' => 6600, 'iron' => 8000, 'crop' => 3000, 'time' => 31680), array('wood' => 6900,
+ 'clay' => 7400, 'iron' => 8900, 'crop' => 3400, 'time' => 34560), array('wood' => 7700, 'clay' => 8100, 'iron' => 9900, 'crop' => 3700, 'time' => 37440), array('wood' => 8400, 'clay' => 8900, 'iron' => 11000, 'crop' => 4100, 'time' => 40320), array('wood' => 9200, 'clay' => 9700, 'iron' => 12000, 'crop' => 4400, 'time' => 43200), array('wood' => 9900, 'clay' => 10500, 'iron' => 13000, 'crop' => 4800, 'time' => 46080), array('wood' => 10500, 'clay' => 11500, 'iron' => 14000, 'crop' => 5200,
+ 'time' => 48960), array('wood' => 11500, 'clay' => 12000, 'iron' => 15000, 'crop' => 5600, 'time' => 51840), array('wood' => 12500, 'clay' => 13000, 'iron' => 16000, 'crop' => 6000, 'time' => 54720), array('wood' => 13000, 'clay' => 14000, 'iron' => 17000, 'crop' => 6300, 'time' => 57600), array('wood' => 14000, 'clay' => 15000, 'iron' => 18000, 'crop' => 6700, 'time' => 60480), array('wood' => 15000, 'clay' => 15500, 'iron' => 19000, 'crop' => 7100, 'time' => 63360), array('wood' => 15500,
+ 'clay' => 16500, 'iron' => 20000, 'crop' => 7600, 'time' => 66240), array('wood' => 16500, 'clay' => 17500, 'iron' => 21000, 'crop' => 8000, 'time' => 69120), array('wood' => 17500, 'clay' => 18500, 'iron' => 22500, 'crop' => 8400, 'time' => 72000), array('wood' => 18000, 'clay' => 19500, 'iron' => 23500, 'crop' => 8800, 'time' => 74880), array('wood' => 19000, 'clay' => 20500, 'iron' => 24500, 'crop' => 9200, 'time' => 77760), array('wood' => 20000, 'clay' => 21500, 'iron' => 26000, 'crop' =>
+ 9700, 'time' => 80640), array('wood' => 21000, 'clay' => 22000, 'iron' => 27000, 'crop' => 10000, 'time' => 83520), array('wood' => 22000, 'clay' => 23000, 'iron' => 28000, 'crop' => 10500, 'time' => 86400), array('wood' => 22500, 'clay' => 24000, 'iron' => 29500, 'crop' => 11000, 'time' => 89280), array('wood' => 23500, 'clay' => 25000, 'iron' => 30500, 'crop' => 11500, 'time' => 92160), array('wood' => 24500, 'clay' => 26000, 'iron' => 31500, 'crop' => 12000, 'time' => 95040), array('wood' =>
+ 25500, 'clay' => 27000, 'iron' => 33000, 'crop' => 12500, 'time' => 97920), array('wood' => 26500, 'clay' => 28000, 'iron' => 34000, 'crop' => 13000, 'time' => 100800), array('wood' => 27500, 'clay' => 29000, 'iron' => 35500, 'crop' => 13000, 'time' => 103680), array('wood' => 28500, 'clay' => 30000, 'iron' => 36500, 'crop' => 13500, 'time' => 106560), array('wood' => 29000, 'clay' => 31000, 'iron' => 37500, 'crop' => 14000, 'time' => 109440), array('wood' => 30000, 'clay' => 32000, 'iron' =>
+ 39000, 'crop' => 14500, 'time' => 112320), array('wood' => 31000, 'clay' => 33000, 'iron' => 40000, 'crop' => 15000, 'time' => 115200), array('wood' => 32000, 'clay' => 34000, 'iron' => 41500, 'crop' => 15500, 'time' => 118080), array('wood' => 33000, 'clay' => 35500, 'iron' => 43000, 'crop' => 16000, 'time' => 120960), array('wood' => 34000, 'clay' => 36500, 'iron' => 44000, 'crop' => 16500, 'time' => 123840), array('wood' => 35000, 'clay' => 37500, 'iron' => 45500, 'crop' => 17000, 'time' =>
+ 126720), array('wood' => 36000, 'clay' => 38500, 'iron' => 46500, 'crop' => 17500, 'time' => 129600), array('wood' => 37000, 'clay' => 39500, 'iron' => 48000, 'crop' => 18000, 'time' => 132480), array('wood' => 38000, 'clay' => 40500, 'iron' => 49000, 'crop' => 18500, 'time' => 135360), array('wood' => 39000, 'clay' => 41500, 'iron' => 50500, 'crop' => 19000, 'time' => 138240), array('wood' => 40000, 'clay' => 43000, 'iron' => 52000, 'crop' => 19500, 'time' => 141120), array('wood' => 41000,
+ 'clay' => 44000, 'iron' => 53000, 'crop' => 20000, 'time' => 144000), array('wood' => 42000, 'clay' => 45000, 'iron' => 54500, 'crop' => 20500, 'time' => 146880), array('wood' => 43500, 'clay' => 46000, 'iron' => 56000, 'crop' => 21000, 'time' => 149760), array('wood' => 44500, 'clay' => 47000, 'iron' => 57000, 'crop' => 21500, 'time' => 152640), array('wood' => 45500, 'clay' => 48500, 'iron' => 58500, 'crop' => 22000, 'time' => 155520), array('wood' => 46500, 'clay' => 49500, 'iron' => 60000,
+ 'crop' => 22500, 'time' => 158400), array('wood' => 47500, 'clay' => 50500, 'iron' => 61500, 'crop' => 23000, 'time' => 161280), array('wood' => 48500, 'clay' => 51500, 'iron' => 62500, 'crop' => 23500, 'time' => 164160), array('wood' => 49500, 'clay' => 53000, 'iron' => 64000, 'crop' => 24000, 'time' => 167040), array('wood' => 50500, 'clay' => 54000, 'iron' => 65500, 'crop' => 24500, 'time' => 169920), array('wood' => 52000, 'clay' => 55000, 'iron' => 67000, 'crop' => 25000, 'time' => 172800),
+ array('wood' => 53000, 'clay' => 56500, 'iron' => 68000, 'crop' => 25500, 'time' => 175680));
+ $h24_full = array(array('wood' => 700, 'clay' => 900, 'iron' => 460, 'crop' => 120, 'time' => 4960), array('wood' => 1700, 'clay' => 2200, 'iron' => 1200, 'crop' => 360, 'time' => 9920), array('wood' => 2900, 'clay' => 3700, 'iron' => 1900, 'crop' => 590, 'time' => 14880), array('wood' => 4100, 'clay' => 5300, 'iron' => 2800, 'crop' => 850, 'time' => 19840), array('wood' => 5500, 'clay' => 7000, 'iron' => 3700, 'crop' => 1100, 'time' => 24800), array('wood' => 6900, 'clay' => 8700, 'iron' =>
+ 4600, 'crop' => 1400, 'time' => 29760), array('wood' => 8300, 'clay' => 10500, 'iron' => 5600, 'crop' => 1700, 'time' => 34720), array('wood' => 9800, 'clay' => 12500, 'iron' => 6600, 'crop' => 2000, 'time' => 39680), array('wood' => 11500, 'clay' => 14500, 'iron' => 7600, 'crop' => 2300, 'time' => 44640), array('wood' => 13000, 'clay' => 16500, 'iron' => 8700, 'crop' => 2700, 'time' => 49600), array('wood' => 14500, 'clay' => 18500, 'iron' => 9800, 'crop' => 3000, 'time' => 54560), array('wood' =>
+ 16500, 'clay' => 21000, 'iron' => 11000, 'crop' => 3400, 'time' => 59520), array('wood' => 18000, 'clay' => 23000, 'iron' => 12000, 'crop' => 3700, 'time' => 64480), array('wood' => 20000, 'clay' => 25000, 'iron' => 13500, 'crop' => 4100, 'time' => 69440), array('wood' => 21500, 'clay' => 27500, 'iron' => 14500, 'crop' => 4400, 'time' => 74400), array('wood' => 23500, 'clay' => 30000, 'iron' => 15500, 'crop' => 4800, 'time' => 79360), array('wood' => 25000, 'clay' => 32000, 'iron' => 17000,
+ 'crop' => 5200, 'time' => 84320), array('wood' => 27000, 'clay' => 34500, 'iron' => 18000, 'crop' => 5600, 'time' => 89280), array('wood' => 29000, 'clay' => 37000, 'iron' => 19500, 'crop' => 6000, 'time' => 94240), array('wood' => 31000, 'clay' => 39500, 'iron' => 20500, 'crop' => 6300, 'time' => 99200), array('wood' => 33000, 'clay' => 42000, 'iron' => 22000, 'crop' => 6700, 'time' => 104160), array('wood' => 35000, 'clay' => 44500, 'iron' => 23500, 'crop' => 7100, 'time' => 109120), array('wood' =>
+ 37000, 'clay' => 47000, 'iron' => 24500, 'crop' => 7600, 'time' => 114080), array('wood' => 39000, 'clay' => 49500, 'iron' => 26000, 'crop' => 8000, 'time' => 119040), array('wood' => 41000, 'clay' => 52000, 'iron' => 27500, 'crop' => 8400, 'time' => 124000), array('wood' => 43000, 'clay' => 54500, 'iron' => 29000, 'crop' => 8800, 'time' => 128960), array('wood' => 45000, 'clay' => 57000, 'iron' => 30000, 'crop' => 9200, 'time' => 133920), array('wood' => 47000, 'clay' => 60000, 'iron' => 31500,
+ 'crop' => 9700, 'time' => 138880), array('wood' => 49000, 'clay' => 62500, 'iron' => 33000, 'crop' => 10000, 'time' => 143840), array('wood' => 51500, 'clay' => 65500, 'iron' => 34500, 'crop' => 10500, 'time' => 148800), array('wood' => 53500, 'clay' => 68000, 'iron' => 36000, 'crop' => 11000, 'time' => 153760), array('wood' => 55500, 'clay' => 71000, 'iron' => 37500, 'crop' => 11500, 'time' => 158720), array('wood' => 57500, 'clay' => 73500, 'iron' => 39000, 'crop' => 12000, 'time' => 163680),
+ array('wood' => 60000, 'clay' => 76500, 'iron' => 40000, 'crop' => 12500, 'time' => 168640), array('wood' => 62000, 'clay' => 79000, 'iron' => 41500, 'crop' => 13000, 'time' => 173600), array('wood' => 64500, 'clay' => 82000, 'iron' => 43000, 'crop' => 13000, 'time' => 178560), array('wood' => 66500, 'clay' => 85000, 'iron' => 44500, 'crop' => 13500, 'time' => 183520), array('wood' => 69000, 'clay' => 87500, 'iron' => 46000, 'crop' => 14000, 'time' => 188480), array('wood' => 71000, 'clay' =>
+ 90500, 'iron' => 48000, 'crop' => 14500, 'time' => 193440), array('wood' => 73500, 'clay' => 93500, 'iron' => 49500, 'crop' => 15000, 'time' => 198400), array('wood' => 75500, 'clay' => 96500, 'iron' => 51000, 'crop' => 15500, 'time' => 203360), array('wood' => 78000, 'clay' => 99500, 'iron' => 52500, 'crop' => 16000, 'time' => 208320), array('wood' => 80500, 'clay' => 102500, 'iron' => 54000, 'crop' => 16500, 'time' => 213280), array('wood' => 82500, 'clay' => 105500, 'iron' => 55500, 'crop' =>
+ 17000, 'time' => 218240), array('wood' => 85000, 'clay' => 108500, 'iron' => 57000, 'crop' => 17500, 'time' => 223200), array('wood' => 87500, 'clay' => 111500, 'iron' => 58500, 'crop' => 18000, 'time' => 228160), array('wood' => 90000, 'clay' => 114500, 'iron' => 60500, 'crop' => 18500, 'time' => 233120), array('wood' => 92000, 'clay' => 117500, 'iron' => 62000, 'crop' => 19000, 'time' => 238080), array('wood' => 94500, 'clay' => 120500, 'iron' => 63500, 'crop' => 19500, 'time' => 243040),
+ array('wood' => 97000, 'clay' => 123500, 'iron' => 65000, 'crop' => 20000, 'time' => 248000), array('wood' => 99500, 'clay' => 126500, 'iron' => 67000, 'crop' => 20500, 'time' => 252960), array('wood' => 102000, 'clay' => 130000, 'iron' => 68500, 'crop' => 21000, 'time' => 257920), array('wood' => 104500, 'clay' => 133000, 'iron' => 70000, 'crop' => 21500, 'time' => 262880), array('wood' => 107000, 'clay' => 136000, 'iron' => 71500, 'crop' => 22000, 'time' => 267840), array('wood' => 109500,
+ 'clay' => 139500, 'iron' => 73500, 'crop' => 22500, 'time' => 272800), array('wood' => 112000, 'clay' => 142500, 'iron' => 75000, 'crop' => 23000, 'time' => 277760), array('wood' => 114500, 'clay' => 145500, 'iron' => 76500, 'crop' => 23500, 'time' => 282720), array('wood' => 117000, 'clay' => 149000, 'iron' => 78500, 'crop' => 24000, 'time' => 287680), array('wood' => 119500, 'clay' => 152000, 'iron' => 80000, 'crop' => 24500, 'time' => 292640), array('wood' => 122000, 'clay' => 155500, 'iron' =>
+ 82000, 'crop' => 25000, 'time' => 297600), array('wood' => 124500, 'clay' => 158500, 'iron' => 83500, 'crop' => 25500, 'time' => 302560));
+ $h25_full = array(array('wood' => 720, 'clay' => 660, 'iron' => 560, 'crop' => 240, 'time' => 5120), array('wood' => 1800, 'clay' => 1600, 'iron' => 1400, 'crop' => 640, 'time' => 10240), array('wood' => 3000, 'clay' => 2700, 'iron' => 2300, 'crop' => 1100, 'time' => 15360), array('wood' => 4200, 'clay' => 3900, 'iron' => 3300, 'crop' => 1500, 'time' => 20480), array('wood' => 5600, 'clay' => 5200, 'iron' => 4400, 'crop' => 2000, 'time' => 25600), array('wood' => 7000, 'clay' => 6500, 'iron' =>
+ 5500, 'crop' => 2500, 'time' => 30720), array('wood' => 8500, 'clay' => 7900, 'iron' => 6700, 'crop' => 3100, 'time' => 35840), array('wood' => 10000, 'clay' => 9300, 'iron' => 7900, 'crop' => 3600, 'time' => 40960), array('wood' => 11500, 'clay' => 11000, 'iron' => 9200, 'crop' => 4200, 'time' => 46080), array('wood' => 13500, 'clay' => 12500, 'iron' => 10500, 'crop' => 4800, 'time' => 51200), array('wood' => 15000, 'clay' => 14000, 'iron' => 12000, 'crop' => 5400, 'time' => 56320), array('wood' =>
+ 17000, 'clay' => 15500, 'iron' => 13000, 'crop' => 6000, 'time' => 61440), array('wood' => 18500, 'clay' => 17000, 'iron' => 14500, 'crop' => 6700, 'time' => 66560), array('wood' => 20500, 'clay' => 18500, 'iron' => 16000, 'crop' => 7300, 'time' => 71680), array('wood' => 22000, 'clay' => 20500, 'iron' => 17500, 'crop' => 8000, 'time' => 76800), array('wood' => 24000, 'clay' => 22000, 'iron' => 19000, 'crop' => 8600, 'time' => 81920), array('wood' => 26000, 'clay' => 24000, 'iron' => 20500,
+ 'crop' => 9300, 'time' => 87040), array('wood' => 28000, 'clay' => 25500, 'iron' => 22000, 'crop' => 10000, 'time' => 92160), array('wood' => 30000, 'clay' => 27500, 'iron' => 23500, 'crop' => 10500, 'time' => 97280), array('wood' => 31500, 'clay' => 29000, 'iron' => 25000, 'crop' => 11500, 'time' => 102400), array('wood' => 33500, 'clay' => 31000, 'iron' => 26500, 'crop' => 12000, 'time' => 107520), array('wood' => 35500, 'clay' => 33000, 'iron' => 28000, 'crop' => 13000, 'time' => 112640),
+ array('wood' => 38000, 'clay' => 35000, 'iron' => 29500, 'crop' => 13500, 'time' => 117760), array('wood' => 40000, 'clay' => 36500, 'iron' => 31500, 'crop' => 14500, 'time' => 122880), array('wood' => 42000, 'clay' => 38500, 'iron' => 33000, 'crop' => 15000, 'time' => 128000), array('wood' => 44000, 'clay' => 40500, 'iron' => 34500, 'crop' => 16000, 'time' => 133120), array('wood' => 46000, 'clay' => 42500, 'iron' => 36500, 'crop' => 16500, 'time' => 138240), array('wood' => 48500, 'clay' =>
+ 44500, 'iron' => 38000, 'crop' => 17500, 'time' => 143360), array('wood' => 50500, 'clay' => 46500, 'iron' => 39500, 'crop' => 18000, 'time' => 148480), array('wood' => 52500, 'clay' => 48500, 'iron' => 41500, 'crop' => 19000, 'time' => 153600), array('wood' => 55000, 'clay' => 50500, 'iron' => 43000, 'crop' => 19500, 'time' => 158720), array('wood' => 57000, 'clay' => 52500, 'iron' => 45000, 'crop' => 20500, 'time' => 163840), array('wood' => 59500, 'clay' => 54500, 'iron' => 46500, 'crop' =>
+ 21500, 'time' => 168960), array('wood' => 61500, 'clay' => 56500, 'iron' => 48500, 'crop' => 22000, 'time' => 174080), array('wood' => 64000, 'clay' => 58500, 'iron' => 50000, 'crop' => 23000, 'time' => 179200), array('wood' => 66000, 'clay' => 61000, 'iron' => 52000, 'crop' => 24000, 'time' => 184320), array('wood' => 68500, 'clay' => 63000, 'iron' => 54000, 'crop' => 24500, 'time' => 189440), array('wood' => 71000, 'clay' => 65000, 'iron' => 55500, 'crop' => 25500, 'time' => 194560), array('wood' =>
+ 73000, 'clay' => 67000, 'iron' => 57500, 'crop' => 26500, 'time' => 199680), array('wood' => 75500, 'clay' => 69500, 'iron' => 59500, 'crop' => 27000, 'time' => 204800), array('wood' => 78000, 'clay' => 71500, 'iron' => 61000, 'crop' => 28000, 'time' => 209920), array('wood' => 80000, 'clay' => 74000, 'iron' => 63000, 'crop' => 29000, 'time' => 215040), array('wood' => 82500, 'clay' => 76000, 'iron' => 65000, 'crop' => 29500, 'time' => 220160), array('wood' => 85000, 'clay' => 78000, 'iron' =>
+ 67000, 'crop' => 30500, 'time' => 225280), array('wood' => 87500, 'clay' => 80500, 'iron' => 69000, 'crop' => 31500, 'time' => 230400), array('wood' => 90000, 'clay' => 82500, 'iron' => 70500, 'crop' => 32500, 'time' => 235520), array('wood' => 92500, 'clay' => 85000, 'iron' => 72500, 'crop' => 33000, 'time' => 240640), array('wood' => 95000, 'clay' => 87000, 'iron' => 74500, 'crop' => 34000, 'time' => 245760), array('wood' => 97000, 'clay' => 89500, 'iron' => 76500, 'crop' => 35000, 'time' =>
+ 250880), array('wood' => 99500, 'clay' => 91500, 'iron' => 78500, 'crop' => 36000, 'time' => 256000), array('wood' => 102000, 'clay' => 94000, 'iron' => 80500, 'crop' => 37000, 'time' => 261120), array('wood' => 104500, 'clay' => 96500, 'iron' => 82500, 'crop' => 37500, 'time' => 266240), array('wood' => 107500, 'clay' => 98500, 'iron' => 84500, 'crop' => 38500, 'time' => 271360), array('wood' => 110000, 'clay' => 101000, 'iron' => 86500, 'crop' => 39500, 'time' => 276480), array('wood' =>
+ 112500, 'clay' => 103500, 'iron' => 88500, 'crop' => 40500, 'time' => 281600), array('wood' => 115000, 'clay' => 105500, 'iron' => 90500, 'crop' => 41500, 'time' => 286720), array('wood' => 117500, 'clay' => 108000, 'iron' => 92500, 'crop' => 42500, 'time' => 291840), array('wood' => 120000, 'clay' => 110500, 'iron' => 94500, 'crop' => 43000, 'time' => 296960), array('wood' => 122500, 'clay' => 113000, 'iron' => 96500, 'crop' => 44000, 'time' => 302080), array('wood' => 125000, 'clay' => 115000,
+ 'iron' => 98500, 'crop' => 45000, 'time' => 307200), array('wood' => 128000, 'clay' => 117500, 'iron' => 100500, 'crop' => 46000, 'time' => 312320));
+ $h26_full = array(array('wood' => 1000, 'clay' => 1200, 'iron' => 1400, 'crop' => 340, 'time' => 6240), array('wood' => 2400, 'clay' => 3000, 'iron' => 3300, 'crop' => 880, 'time' => 12480), array('wood' => 4100, 'clay' => 5000, 'iron' => 5400, 'crop' => 1500, 'time' => 18720), array('wood' => 5800, 'clay' => 7200, 'iron' => 7800, 'crop' => 2100, 'time' => 24960), array('wood' => 7700, 'clay' => 9500, 'iron' => 10500, 'crop' => 2800, 'time' => 31200), array('wood' => 9700, 'clay' => 12000,
+ 'iron' => 13000, 'crop' => 3500, 'time' => 37440), array('wood' => 11500, 'clay' => 14500, 'iron' => 15500, 'crop' => 4200, 'time' => 43680), array('wood' => 14000, 'clay' => 17000, 'iron' => 18500, 'crop' => 5000, 'time' => 49920), array('wood' => 16000, 'clay' => 20000, 'iron' => 21500, 'crop' => 5800, 'time' => 56160), array('wood' => 18500, 'clay' => 22500, 'iron' => 24500, 'crop' => 6600, 'time' => 62400), array('wood' => 20500, 'clay' => 25500, 'iron' => 27500, 'crop' => 7400, 'time' =>
+ 68640), array('wood' => 23000, 'clay' => 28500, 'iron' => 31000, 'crop' => 8300, 'time' => 74880), array('wood' => 25500, 'clay' => 31500, 'iron' => 34000, 'crop' => 9100, 'time' => 81120), array('wood' => 28000, 'clay' => 34500, 'iron' => 37500, 'crop' => 10000, 'time' => 87360), array('wood' => 30500, 'clay' => 37500, 'iron' => 40500, 'crop' => 11000, 'time' => 93600), array('wood' => 33000, 'clay' => 40500, 'iron' => 44000, 'crop' => 12000, 'time' => 99840), array('wood' => 35500, 'clay' =>
+ 44000, 'iron' => 47500, 'crop' => 13000, 'time' => 106080), array('wood' => 38000, 'clay' => 47000, 'iron' => 51000, 'crop' => 13500, 'time' => 112320), array('wood' => 41000, 'clay' => 50500, 'iron' => 54500, 'crop' => 14500, 'time' => 118560), array('wood' => 43500, 'clay' => 53500, 'iron' => 58500, 'crop' => 15500, 'time' => 124800), array('wood' => 46500, 'clay' => 57000, 'iron' => 62000, 'crop' => 16500, 'time' => 131040), array('wood' => 49000, 'clay' => 60500, 'iron' => 66000, 'crop' =>
+ 17500, 'time' => 137280), array('wood' => 52000, 'clay' => 64000, 'iron' => 69500, 'crop' => 18500, 'time' => 143520), array('wood' => 54500, 'clay' => 67500, 'iron' => 73500, 'crop' => 19500, 'time' => 149760), array('wood' => 57500, 'clay' => 71000, 'iron' => 77000, 'crop' => 20500, 'time' => 156000), array('wood' => 60500, 'clay' => 74500, 'iron' => 81000, 'crop' => 21500, 'time' => 162240), array('wood' => 63500, 'clay' => 78000, 'iron' => 85000, 'crop' => 23000, 'time' => 168480), array('wood' =>
+ 66500, 'clay' => 82000, 'iron' => 89000, 'crop' => 24000, 'time' => 174720), array('wood' => 69500, 'clay' => 85500, 'iron' => 93000, 'crop' => 25000, 'time' => 180960), array('wood' => 72500, 'clay' => 89000, 'iron' => 97000, 'crop' => 26000, 'time' => 187200), array('wood' => 75500, 'clay' => 93000, 'iron' => 101000, 'crop' => 27000, 'time' => 193440), array('wood' => 78500, 'clay' => 96500, 'iron' => 105000, 'crop' => 28000, 'time' => 199680), array('wood' => 81500, 'clay' => 100500, 'iron' =>
+ 109000, 'crop' => 29500, 'time' => 205920), array('wood' => 84500, 'clay' => 104500, 'iron' => 113500, 'crop' => 30500, 'time' => 212160), array('wood' => 87500, 'clay' => 108000, 'iron' => 117500, 'crop' => 31500, 'time' => 218400), array('wood' => 91000, 'clay' => 112000, 'iron' => 121500, 'crop' => 32500, 'time' => 224640), array('wood' => 94000, 'clay' => 116000, 'iron' => 126000, 'crop' => 34000, 'time' => 230880), array('wood' => 97000, 'clay' => 120000, 'iron' => 130000, 'crop' => 35000,
+ 'time' => 237120), array('wood' => 100500, 'clay' => 124000, 'iron' => 134500, 'crop' => 36000, 'time' => 243360), array('wood' => 103500, 'clay' => 128000, 'iron' => 139000, 'crop' => 37000, 'time' => 249600), array('wood' => 107000, 'clay' => 132000, 'iron' => 143000, 'crop' => 38500, 'time' => 255840), array('wood' => 110000, 'clay' => 136000, 'iron' => 147500, 'crop' => 39500, 'time' => 262080), array('wood' => 113500, 'clay' => 140000, 'iron' => 152000, 'crop' => 40500, 'time' => 268320),
+ array('wood' => 116500, 'clay' => 144000, 'iron' => 156500, 'crop' => 42000, 'time' => 274560), array('wood' => 120000, 'clay' => 148000, 'iron' => 161000, 'crop' => 43000, 'time' => 280800), array('wood' => 123500, 'clay' => 152000, 'iron' => 165500, 'crop' => 44500, 'time' => 287040), array('wood' => 127000, 'clay' => 156500, 'iron' => 170000, 'crop' => 45500, 'time' => 293280), array('wood' => 130000, 'clay' => 160500, 'iron' => 174500, 'crop' => 46500, 'time' => 299520), array('wood' =>
+ 133500, 'clay' => 164500, 'iron' => 179000, 'crop' => 48000, 'time' => 305760), array('wood' => 137000, 'clay' => 169000, 'iron' => 183500, 'crop' => 49000, 'time' => 312000), array('wood' => 140500, 'clay' => 173000, 'iron' => 188000, 'crop' => 50500, 'time' => 318240), array('wood' => 144000, 'clay' => 177500, 'iron' => 192500, 'crop' => 51500, 'time' => 324480), array('wood' => 147500, 'clay' => 181500, 'iron' => 197500, 'crop' => 53000, 'time' => 330720), array('wood' => 151000, 'clay' =>
+ 186000, 'iron' => 202000, 'crop' => 54000, 'time' => 336960), array('wood' => 154500, 'clay' => 190000, 'iron' => 206500, 'crop' => 55500, 'time' => 343200), array('wood' => 158000, 'clay' => 194500, 'iron' => 211500, 'crop' => 56500, 'time' => 349440), array('wood' => 161500, 'clay' => 199000, 'iron' => 216000, 'crop' => 58000, 'time' => 355680), array('wood' => 165000, 'clay' => 203500, 'iron' => 221000, 'crop' => 59000, 'time' => 361920), array('wood' => 168500, 'clay' => 207500, 'iron' =>
+ 225500, 'crop' => 60500, 'time' => 368160), array('wood' => 172000, 'clay' => 212000, 'iron' => 230500, 'crop' => 62000, 'time' => 374400), array('wood' => 175500, 'clay' => 216500, 'iron' => 235500, 'crop' => 63000, 'time' => 380640));
+
+?>
\ No newline at end of file
diff --git a/GameEngine/Data/hunitdata.php b/GameEngine/Data/hunitdata.php
new file mode 100644
index 00000000..9a81a55f
--- /dev/null
+++ b/GameEngine/Data/hunitdata.php
@@ -0,0 +1,16 @@
+uid."'") or die(mysql_error());
+$heroinfo = mysql_fetch_array($getheroinfo);
+echo $heroinfo['attackpower'];
+$hero=array('atk'=>40*$heroinfo['attackpower'],'di'=>35,'dc'=>50,'wood'=>120,'clay'=>100,'iron'=>150,'crop'=>30,'pop'=>6,'speed'=>6,'time'=>1600,'cap'=>0);
+
+?>
\ No newline at end of file
diff --git a/GameEngine/Data/resdata.php b/GameEngine/Data/resdata.php
new file mode 100644
index 00000000..f5b04711
--- /dev/null
+++ b/GameEngine/Data/resdata.php
@@ -0,0 +1,97 @@
+700,'clay'=>620,'iron'=>1480,'crop'=>580,'time'=>7080);
+$r3=array('wood'=>1000,'clay'=>740,'iron'=>1880,'crop'=>640,'time'=>7560);
+$r4=array('wood'=>940,'clay'=>740,'iron'=>360,'crop'=>400,'time'=>5880);
+$r5=array('wood'=>3400,'clay'=>1860,'iron'=>2760,'crop'=>760,'time'=>9720);
+$r6=array('wood'=>3400,'clay'=>2660,'iron'=>6600,'crop'=>1240,'time'=>12360);
+$r7=array('wood'=>5500,'clay'=>1540,'iron'=>4200,'crop'=>580,'time'=>15600);
+$r8=array('wood'=>5800,'clay'=>5500,'iron'=>5000,'crop'=>700,'time'=>28800);
+$r9=array('wood'=>15880,'clay'=>13800,'iron'=>36400,'crop'=>22660,'time'=>24475);
+$r12=array('wood'=>970,'clay'=>380,'iron'=>880,'crop'=>400,'time'=>5160);
+$r13=array('wood'=>880,'clay'=>580,'iron'=>1560,'crop'=>580,'time'=>5400);
+$r14=array('wood'=>1060,'clay'=>500,'iron'=>600,'crop'=>460,'time'=>5160);
+$r15=array('wood'=>2320,'clay'=>1180,'iron'=>2520,'crop'=>610,'time'=>9000);
+$r16=array('wood'=>2800,'clay'=>2160,'iron'=>4040,'crop'=>640,'time'=>10680);
+$r17=array('wood'=>6100,'clay'=>1300,'iron'=>3000,'crop'=>580,'time'=>14400);
+$r18=array('wood'=>5500,'clay'=>4900,'iron'=>5000,'crop'=>520,'time'=>28800);
+$r19=array('wood'=>18250,'clay'=>13500,'iron'=>20400,'crop'=>16480,'time'=>19425);
+$r22=array('wood'=>940,'clay'=>700,'iron'=>1680,'crop'=>520,'time'=>6120);
+$r23=array('wood'=>1120,'clay'=>700,'iron'=>360,'crop'=>400,'time'=>5880);
+$r24=array('wood'=>2200,'clay'=>1900,'iron'=>2040,'crop'=>520,'time'=>9240);
+$r25=array('wood'=>2260,'clay'=>1420,'iron'=>2440,'crop'=>880,'time'=>9480);
+$r26=array('wood'=>3100,'clay'=>2580,'iron'=>5600,'crop'=>1180,'time'=>11160);
+$r27=array('wood'=>5800,'clay'=>2320,'iron'=>2840,'crop'=>610,'time'=>16800);
+$r28=array('wood'=>5860,'clay'=>5900,'iron'=>5240,'crop'=>700,'time'=>28800);
+$r29=array('wood'=>15880,'clay'=>22900,'iron'=>25200,'crop'=>22660,'time'=>24475);
+$r32=array('wood'=>970,'clay'=>380,'iron'=>880,'crop'=>400,'time'=>5160);
+$r33=array('wood'=>880,'clay'=>580,'iron'=>1560,'crop'=>580,'time'=>5400);
+$r34=array('wood'=>1060,'clay'=>500,'iron'=>600,'crop'=>460,'time'=>5160);
+$r35=array('wood'=>2320,'clay'=>1180,'iron'=>2520,'crop'=>610,'time'=>9000);
+$r36=array('wood'=>2800,'clay'=>2160,'iron'=>4040,'crop'=>640,'time'=>10680);
+$r37=array('wood'=>6100,'clay'=>1300,'iron'=>3000,'crop'=>580,'time'=>14400);
+$r38=array('wood'=>5500,'clay'=>4900,'iron'=>5000,'crop'=>520,'time'=>28800);
+$r39=array('wood'=>18250,'clay'=>13500,'iron'=>20400,'crop'=>16480,'time'=>19425);
+$r42=array('wood'=>970,'clay'=>380,'iron'=>880,'crop'=>400,'time'=>5160);
+$r43=array('wood'=>880,'clay'=>580,'iron'=>1560,'crop'=>580,'time'=>5400);
+$r44=array('wood'=>1060,'clay'=>500,'iron'=>600,'crop'=>460,'time'=>5160);
+$r45=array('wood'=>2320,'clay'=>1180,'iron'=>2520,'crop'=>610,'time'=>9000);
+$r46=array('wood'=>2800,'clay'=>2160,'iron'=>4040,'crop'=>640,'time'=>10680);
+$r47=array('wood'=>6100,'clay'=>1300,'iron'=>3000,'crop'=>580,'time'=>14400);
+$r48=array('wood'=>5500,'clay'=>4900,'iron'=>5000,'crop'=>520,'time'=>28800);
+$r49=array('wood'=>18250,'clay'=>13500,'iron'=>20400,'crop'=>16480,'time'=>19425);
+
+//Armoury
+//Blacksmith
+$ab1=array(1=>array('wood'=>940,'clay'=>800,'iron'=>1250,'crop'=>370,'time'=>6600),array('wood'=>1635,'clay'=>1395,'iron'=>2175,'crop'=>645,'time'=>11491),array('wood'=>2265,'clay'=>1925,'iron'=>3010,'crop'=>890,'time'=>15894),array('wood'=>2850,'clay'=>2425,'iron'=>3790,'crop'=>1120,'time'=>20007),array('wood'=>3405,'clay'=>2900,'iron'=>4530,'crop'=>1340,'time'=>23918),array('wood'=>3940,'clay'=>3355,'iron'=>5240,'crop'=>1550,'time'=>27674),array('wood'=>4460,'clay'=>3795,'iron'=>5930,'crop'=>1755,'time'=>31306),array('wood'=>4960,'clay'=>4220,'iron'=>6600,'crop'=>1955,'time'=>34835),array('wood'=>5450,'clay'=>4640,'iron'=>7250,'crop'=>2145,'time'=>38277),array('wood'=>5930,'clay'=>5050,'iron'=>7885,'crop'=>2335,'time'=>41643),array('wood'=>6400,'clay'=>5450,'iron'=>8510,'crop'=>2520,'time'=>44943),array('wood'=>6860,'clay'=>5840,'iron'=>9125,'crop'=>2700,'time'=>48182),array('wood'=>7315,'clay'=>6225,'iron'=>9730,'crop'=>2880,'time'=>51369),array('wood'=>7765,'clay'=>6605,'iron'=>10325,'crop'=>3055,'time'=>54506),array('wood'=>8205,'clay'=>6980,'iron'=>10910,'crop'=>3230,'time'=>57599),array('wood'=>8640,'clay'=>7350,'iron'=>11485,'crop'=>3400,'time'=>60651),array('wood'=>9065,'clay'=>7715,'iron'=>12060,'crop'=>3570,'time'=>63665),array('wood'=>9490,'clay'=>8080,'iron'=>12620,'crop'=>3735,'time'=>66644),array('wood'=>9910,'clay'=>8435,'iron'=>13180,'crop'=>3900,'time'=>69590),array('wood'=>10325,'clay'=>8790,'iron'=>13730,'crop'=>4065,'time'=>72505));
+$ab2=array(1=>array('wood'=>800,'clay'=>1010,'iron'=>1320,'crop'=>650,'time'=>7080),array('wood'=>1395,'clay'=>1760,'iron'=>2300,'crop'=>1130,'time'=>12327),array('wood'=>1925,'clay'=>2430,'iron'=>3180,'crop'=>1565,'time'=>17050),array('wood'=>2425,'clay'=>3060,'iron'=>4000,'crop'=>1970,'time'=>21463),array('wood'=>2900,'clay'=>3660,'iron'=>4785,'crop'=>2355,'time'=>25657),array('wood'=>3355,'clay'=>4235,'iron'=>5535,'crop'=>2725,'time'=>29686),array('wood'=>3795,'clay'=>4790,'iron'=>6260,'crop'=>3085,'time'=>33582),array('wood'=>4220,'clay'=>5330,'iron'=>6965,'crop'=>3430,'time'=>37368),array('wood'=>4640,'clay'=>5860,'iron'=>7655,'crop'=>3770,'time'=>41061),array('wood'=>5050,'clay'=>6375,'iron'=>8330,'crop'=>4100,'time'=>44672),array('wood'=>5450,'clay'=>6880,'iron'=>8990,'crop'=>4425,'time'=>48211),array('wood'=>5840,'clay'=>7375,'iron'=>9635,'crop'=>4745,'time'=>51687),array('wood'=>6225,'clay'=>7860,'iron'=>10275,'crop'=>5060,'time'=>55105),array('wood'=>6605,'clay'=>8340,'iron'=>10900,'crop'=>5370,'time'=>58470),array('wood'=>6980,'clay'=>8815,'iron'=>11520,'crop'=>5675,'time'=>61788),array('wood'=>7350,'clay'=>9280,'iron'=>12130,'crop'=>5975,'time'=>65062),array('wood'=>7715,'clay'=>9745,'iron'=>12735,'crop'=>6270,'time'=>68296),array('wood'=>8080,'clay'=>10200,'iron'=>13330,'crop'=>6565,'time'=>71491),array('wood'=>8435,'clay'=>10650,'iron'=>13920,'crop'=>6855,'time'=>74651),array('wood'=>8790,'clay'=>11095,'iron'=>14500,'crop'=>7140,'time'=>77778));
+$ab3=array(1=>array('wood'=>1150,'clay'=>1220,'iron'=>1670,'crop'=>720,'time'=>7560),array('wood'=>2000,'clay'=>2125,'iron'=>2910,'crop'=>1255,'time'=>13163),array('wood'=>2770,'clay'=>2940,'iron'=>4020,'crop'=>1735,'time'=>18206),array('wood'=>3485,'clay'=>3700,'iron'=>5060,'crop'=>2185,'time'=>22918),array('wood'=>4165,'clay'=>4420,'iron'=>6050,'crop'=>2610,'time'=>27397),array('wood'=>4820,'clay'=>5115,'iron'=>7000,'crop'=>3020,'time'=>31699),array('wood'=>5455,'clay'=>5785,'iron'=>7920,'crop'=>3415,'time'=>35859),array('wood'=>6070,'clay'=>6440,'iron'=>8815,'crop'=>3800,'time'=>39902),array('wood'=>6670,'clay'=>7075,'iron'=>9685,'crop'=>4175,'time'=>43845),array('wood'=>7255,'clay'=>7700,'iron'=>10535,'crop'=>4545,'time'=>47700),array('wood'=>7830,'clay'=>8310,'iron'=>11370,'crop'=>4905,'time'=>51480),array('wood'=>8395,'clay'=>8905,'iron'=>12190,'crop'=>5255,'time'=>55191),array('wood'=>8950,'clay'=>9495,'iron'=>13000,'crop'=>5605,'time'=>58841),array('wood'=>9495,'clay'=>10075,'iron'=>13790,'crop'=>5945,'time'=>62434),array('wood'=>10035,'clay'=>10645,'iron'=>14575,'crop'=>6285,'time'=>65977),array('wood'=>10570,'clay'=>11210,'iron'=>15345,'crop'=>6615,'time'=>69473),array('wood'=>11095,'clay'=>11770,'iron'=>16110,'crop'=>6945,'time'=>72926),array('wood'=>11610,'clay'=>12320,'iron'=>16865,'crop'=>7270,'time'=>76338),array('wood'=>12125,'clay'=>12865,'iron'=>17610,'crop'=>7590,'time'=>79712),array('wood'=>12635,'clay'=>13400,'iron'=>18345,'crop'=>7910,'time'=>83051));
+$ab4=array(1=>array('wood'=>540,'clay'=>610,'iron'=>170,'crop'=>220,'time'=>5880),array('wood'=>940,'clay'=>1060,'iron'=>295,'crop'=>385,'time'=>10238),array('wood'=>1300,'clay'=>1470,'iron'=>410,'crop'=>530,'time'=>14160),array('wood'=>1635,'clay'=>1850,'iron'=>515,'crop'=>665,'time'=>17825),array('wood'=>1955,'clay'=>2210,'iron'=>615,'crop'=>795,'time'=>21309),array('wood'=>2265,'clay'=>2560,'iron'=>715,'crop'=>920,'time'=>24655),array('wood'=>2560,'clay'=>2895,'iron'=>805,'crop'=>1045,'time'=>27890),array('wood'=>2850,'clay'=>3220,'iron'=>895,'crop'=>1160,'time'=>31035),array('wood'=>3130,'clay'=>3540,'iron'=>985,'crop'=>1275,'time'=>34101),array('wood'=>3405,'clay'=>3850,'iron'=>1075,'crop'=>1390,'time'=>37100),array('wood'=>3675,'clay'=>4155,'iron'=>1160,'crop'=>1500,'time'=>40040),array('wood'=>3940,'clay'=>4455,'iron'=>1240,'crop'=>1605,'time'=>42926),array('wood'=>4205,'clay'=>4750,'iron'=>1325,'crop'=>1710,'time'=>45765),array('wood'=>4460,'clay'=>5040,'iron'=>1405,'crop'=>1815,'time'=>48560),array('wood'=>4715,'clay'=>5325,'iron'=>1485,'crop'=>1920,'time'=>51316),array('wood'=>4960,'clay'=>5605,'iron'=>1560,'crop'=>2020,'time'=>54035),array('wood'=>5210,'clay'=>5885,'iron'=>1640,'crop'=>2120,'time'=>56720),array('wood'=>5455,'clay'=>6160,'iron'=>1715,'crop'=>2220,'time'=>59374),array('wood'=>5695,'clay'=>6430,'iron'=>1790,'crop'=>2320,'time'=>61998),array('wood'=>5930,'clay'=>6700,'iron'=>1870,'crop'=>2415,'time'=>64595));
+$ab5=array(1=>array('wood'=>1315,'clay'=>1060,'iron'=>815,'crop'=>285,'time'=>9720),array('wood'=>2290,'clay'=>1845,'iron'=>1415,'crop'=>500,'time'=>16924),array('wood'=>3170,'clay'=>2555,'iron'=>1960,'crop'=>690,'time'=>23408),array('wood'=>3990,'clay'=>3215,'iron'=>2465,'crop'=>870,'time'=>29466),array('wood'=>4770,'clay'=>3840,'iron'=>2945,'crop'=>1040,'time'=>35224),array('wood'=>5520,'clay'=>4445,'iron'=>3410,'crop'=>1200,'time'=>40756),array('wood'=>6245,'clay'=>5030,'iron'=>3860,'crop'=>1360,'time'=>46105),array('wood'=>6950,'clay'=>5595,'iron'=>4295,'crop'=>1515,'time'=>51302),array('wood'=>7635,'clay'=>6150,'iron'=>4715,'crop'=>1665,'time'=>56372),array('wood'=>8310,'clay'=>6690,'iron'=>5130,'crop'=>1810,'time'=>61329),array('wood'=>8965,'clay'=>7220,'iron'=>5540,'crop'=>1950,'time'=>66188),array('wood'=>9610,'clay'=>7740,'iron'=>5940,'crop'=>2095,'time'=>70960),array('wood'=>10250,'clay'=>8250,'iron'=>6330,'crop'=>2230,'time'=>75652),array('wood'=>10875,'clay'=>8755,'iron'=>6715,'crop'=>2365,'time'=>80273),array('wood'=>11490,'clay'=>9250,'iron'=>7100,'crop'=>2500,'time'=>84828),array('wood'=>12100,'clay'=>9740,'iron'=>7475,'crop'=>2635,'time'=>89323),array('wood'=>12700,'clay'=>10225,'iron'=>7845,'crop'=>2765,'time'=>93762),array('wood'=>13295,'clay'=>10705,'iron'=>8215,'crop'=>2895,'time'=>98149),array('wood'=>13885,'clay'=>11175,'iron'=>8575,'crop'=>3025,'time'=>102487),array('wood'=>14465,'clay'=>11645,'iron'=>8935,'crop'=>3150,'time'=>106780));
+$ab6=array(1=>array('wood'=>990,'clay'=>1145,'iron'=>1450,'crop'=>355,'time'=>12360),array('wood'=>1720,'clay'=>1995,'iron'=>2525,'crop'=>620,'time'=>21520),array('wood'=>2380,'clay'=>2755,'iron'=>3490,'crop'=>855,'time'=>29766),array('wood'=>2995,'clay'=>3470,'iron'=>4395,'crop'=>1075,'time'=>37469),array('wood'=>3580,'clay'=>4150,'iron'=>5255,'crop'=>1285,'time'=>44791),array('wood'=>4140,'clay'=>4800,'iron'=>6080,'crop'=>1490,'time'=>51825),array('wood'=>4685,'clay'=>5430,'iron'=>6880,'crop'=>1685,'time'=>58627),array('wood'=>5210,'clay'=>6045,'iron'=>7655,'crop'=>1875,'time'=>65236),array('wood'=>5725,'clay'=>6640,'iron'=>8410,'crop'=>2060,'time'=>71682),array('wood'=>6230,'clay'=>7225,'iron'=>9150,'crop'=>2240,'time'=>77986),array('wood'=>6725,'clay'=>7795,'iron'=>9875,'crop'=>2415,'time'=>84165),array('wood'=>7210,'clay'=>8360,'iron'=>10585,'crop'=>2590,'time'=>90233),array('wood'=>7685,'clay'=>8910,'iron'=>11285,'crop'=>2765,'time'=>96200),array('wood'=>8155,'clay'=>9455,'iron'=>11975,'crop'=>2930,'time'=>102075),array('wood'=>8620,'clay'=>9995,'iron'=>12655,'crop'=>3100,'time'=>107868),array('wood'=>9075,'clay'=>10520,'iron'=>13325,'crop'=>3260,'time'=>113583),array('wood'=>9525,'clay'=>11045,'iron'=>13985,'crop'=>3425,'time'=>119228),array('wood'=>9970,'clay'=>11560,'iron'=>14640,'crop'=>3585,'time'=>124806),array('wood'=>10410,'clay'=>12075,'iron'=>15290,'crop'=>3745,'time'=>130323),array('wood'=>10850,'clay'=>12580,'iron'=>15930,'crop'=>3900,'time'=>135782));
+$ab7=array(1=>array('wood'=>2135,'clay'=>875,'iron'=>1235,'crop'=>215,'time'=>15600),array('wood'=>3715,'clay'=>1520,'iron'=>2145,'crop'=>375,'time'=>27161),array('wood'=>5140,'clay'=>2105,'iron'=>2970,'crop'=>520,'time'=>37568),array('wood'=>6465,'clay'=>2645,'iron'=>3740,'crop'=>655,'time'=>47290),array('wood'=>7730,'clay'=>3165,'iron'=>4470,'crop'=>785,'time'=>56533),array('wood'=>8945,'clay'=>3660,'iron'=>5170,'crop'=>910,'time'=>65410),array('wood'=>10120,'clay'=>4140,'iron'=>5850,'crop'=>1030,'time'=>73995),array('wood'=>11260,'clay'=>4610,'iron'=>6510,'crop'=>1145,'time'=>82337),array('wood'=>12370,'clay'=>5065,'iron'=>7155,'crop'=>1255,'time'=>90473),array('wood'=>13460,'clay'=>5510,'iron'=>7780,'crop'=>1365,'time'=>98429),array('wood'=>14525,'clay'=>5945,'iron'=>8400,'crop'=>1475,'time'=>106228),array('wood'=>15575,'clay'=>6375,'iron'=>9005,'crop'=>1580,'time'=>113886),array('wood'=>16605,'clay'=>6795,'iron'=>9600,'crop'=>1685,'time'=>121417),array('wood'=>17620,'clay'=>7210,'iron'=>10185,'crop'=>1790,'time'=>128833),array('wood'=>18620,'clay'=>7620,'iron'=>10765,'crop'=>1890,'time'=>136144),array('wood'=>19605,'clay'=>8025,'iron'=>11335,'crop'=>1990,'time'=>143358),array('wood'=>20580,'clay'=>8425,'iron'=>11895,'crop'=>2090,'time'=>150482),array('wood'=>21540,'clay'=>8820,'iron'=>12455,'crop'=>2190,'time'=>157523),array('wood'=>22495,'clay'=>9210,'iron'=>13005,'crop'=>2285,'time'=>164485),array('wood'=>23435,'clay'=>9595,'iron'=>13550,'crop'=>2380,'time'=>171375));
+$ab8=array(1=>array('wood'=>1125,'clay'=>1590,'iron'=>735,'crop'=>130,'time'=>28800),array('wood'=>1960,'clay'=>2770,'iron'=>1275,'crop'=>230,'time'=>50144),array('wood'=>2710,'clay'=>3835,'iron'=>1765,'crop'=>315,'time'=>69357),array('wood'=>3410,'clay'=>4825,'iron'=>2225,'crop'=>400,'time'=>87305),array('wood'=>4075,'clay'=>5770,'iron'=>2660,'crop'=>475,'time'=>104368),array('wood'=>4715,'clay'=>6675,'iron'=>3075,'crop'=>550,'time'=>120757),array('wood'=>5335,'clay'=>7550,'iron'=>3480,'crop'=>625,'time'=>136606),array('wood'=>5940,'clay'=>8400,'iron'=>3870,'crop'=>695,'time'=>152007),array('wood'=>6525,'clay'=>9230,'iron'=>4255,'crop'=>765,'time'=>167027),array('wood'=>7100,'clay'=>10045,'iron'=>4625,'crop'=>830,'time'=>181716),array('wood'=>7660,'clay'=>10840,'iron'=>4995,'crop'=>895,'time'=>196113),array('wood'=>8215,'clay'=>11620,'iron'=>5355,'crop'=>960,'time'=>210251),array('wood'=>8755,'clay'=>12390,'iron'=>5710,'crop'=>1025,'time'=>224154),array('wood'=>9290,'clay'=>13145,'iron'=>6055,'crop'=>1085,'time'=>237845),array('wood'=>9820,'clay'=>13890,'iron'=>6400,'crop'=>1150,'time'=>251342),array('wood'=>10340,'clay'=>14625,'iron'=>6740,'crop'=>1210,'time'=>264660),array('wood'=>10850,'clay'=>15355,'iron'=>7075,'crop'=>1270,'time'=>277812),array('wood'=>11360,'clay'=>16070,'iron'=>7405,'crop'=>1330,'time'=>290811),array('wood'=>11860,'clay'=>16780,'iron'=>7730,'crop'=>1390,'time'=>303665),array('wood'=>12360,'clay'=>17485,'iron'=>8055,'crop'=>1445,'time'=>316385));
+$ab11=array(1=>array('wood'=>765,'clay'=>625,'iron'=>480,'crop'=>440,'time'=>3960),array('wood'=>1330,'clay'=>1090,'iron'=>835,'crop'=>765,'time'=>6895),array('wood'=>1840,'clay'=>1505,'iron'=>1155,'crop'=>1060,'time'=>9537),array('wood'=>2320,'clay'=>1895,'iron'=>1455,'crop'=>1335,'time'=>12004),array('wood'=>2770,'clay'=>2265,'iron'=>1740,'crop'=>1595,'time'=>14351),array('wood'=>3210,'clay'=>2620,'iron'=>2015,'crop'=>1845,'time'=>16604),array('wood'=>3630,'clay'=>2965,'iron'=>2275,'crop'=>2085,'time'=>18783),array('wood'=>4040,'clay'=>3300,'iron'=>2535,'crop'=>2320,'time'=>20901),array('wood'=>4435,'clay'=>3625,'iron'=>2785,'crop'=>2550,'time'=>22966),array('wood'=>4825,'clay'=>3945,'iron'=>3030,'crop'=>2775,'time'=>24986),array('wood'=>5210,'clay'=>4255,'iron'=>3270,'crop'=>2995,'time'=>26966),array('wood'=>5585,'clay'=>4565,'iron'=>3505,'crop'=>3210,'time'=>28909),array('wood'=>5955,'clay'=>4865,'iron'=>3735,'crop'=>3425,'time'=>30821),array('wood'=>6320,'clay'=>5160,'iron'=>3965,'crop'=>3635,'time'=>32704),array('wood'=>6675,'clay'=>5455,'iron'=>4190,'crop'=>3840,'time'=>34560),array('wood'=>7030,'clay'=>5745,'iron'=>4410,'crop'=>4045,'time'=>36391),array('wood'=>7380,'clay'=>6030,'iron'=>4630,'crop'=>4245,'time'=>38199),array('wood'=>7725,'clay'=>6310,'iron'=>4845,'crop'=>4445,'time'=>39986),array('wood'=>8065,'clay'=>6590,'iron'=>5060,'crop'=>4640,'time'=>41754),array('wood'=>8405,'clay'=>6865,'iron'=>5275,'crop'=>4835,'time'=>43503));
+$ab12=array(1=>array('wood'=>1115,'clay'=>590,'iron'=>795,'crop'=>440,'time'=>5160),array('wood'=>1940,'clay'=>1025,'iron'=>1385,'crop'=>765,'time'=>8984),array('wood'=>2685,'clay'=>1420,'iron'=>1915,'crop'=>1060,'time'=>12426),array('wood'=>3380,'clay'=>1790,'iron'=>2410,'crop'=>1335,'time'=>15642),array('wood'=>4040,'clay'=>2140,'iron'=>2880,'crop'=>1595,'time'=>18699),array('wood'=>4675,'clay'=>2475,'iron'=>3335,'crop'=>1845,'time'=>21636),array('wood'=>5290,'clay'=>2800,'iron'=>3770,'crop'=>2085,'time'=>24475),array('wood'=>5885,'clay'=>3115,'iron'=>4195,'crop'=>2320,'time'=>27235),array('wood'=>6465,'clay'=>3420,'iron'=>4610,'crop'=>2550,'time'=>29926),array('wood'=>7035,'clay'=>3725,'iron'=>5015,'crop'=>2775,'time'=>32557),array('wood'=>7595,'clay'=>4020,'iron'=>5415,'crop'=>2995,'time'=>35137),array('wood'=>8140,'clay'=>4305,'iron'=>5805,'crop'=>3210,'time'=>37670),array('wood'=>8680,'clay'=>4590,'iron'=>6190,'crop'=>3425,'time'=>40161),array('wood'=>9210,'clay'=>4875,'iron'=>6565,'crop'=>3635,'time'=>42614),array('wood'=>9730,'clay'=>5150,'iron'=>6940,'crop'=>3840,'time'=>45032),array('wood'=>10245,'clay'=>5420,'iron'=>7305,'crop'=>4045,'time'=>47418),array('wood'=>10755,'clay'=>5690,'iron'=>7670,'crop'=>4245,'time'=>49775),array('wood'=>11260,'clay'=>5960,'iron'=>8030,'crop'=>4445,'time'=>52104),array('wood'=>11755,'clay'=>6220,'iron'=>8380,'crop'=>4640,'time'=>54407),array('wood'=>12250,'clay'=>6480,'iron'=>8735,'crop'=>4835,'time'=>56686));
+$ab13=array(1=>array('wood'=>1010,'clay'=>940,'iron'=>1390,'crop'=>650,'time'=>5400),array('wood'=>1760,'clay'=>1635,'iron'=>2420,'crop'=>1130,'time'=>9402),array('wood'=>2430,'clay'=>2265,'iron'=>3345,'crop'=>1565,'time'=>13004),array('wood'=>3060,'clay'=>2850,'iron'=>4215,'crop'=>1970,'time'=>16370),array('wood'=>3660,'clay'=>3405,'iron'=>5035,'crop'=>2355,'time'=>19569),array('wood'=>4235,'clay'=>3940,'iron'=>5830,'crop'=>2725,'time'=>22642),array('wood'=>4790,'clay'=>4460,'iron'=>6595,'crop'=>3085,'time'=>25614),array('wood'=>5330,'clay'=>4960,'iron'=>7335,'crop'=>3430,'time'=>28501),array('wood'=>5860,'clay'=>5450,'iron'=>8060,'crop'=>3770,'time'=>31318),array('wood'=>6375,'clay'=>5930,'iron'=>8770,'crop'=>4100,'time'=>34072),array('wood'=>6880,'clay'=>6400,'iron'=>9465,'crop'=>4425,'time'=>36771),array('wood'=>7375,'clay'=>6860,'iron'=>10150,'crop'=>4745,'time'=>39422),array('wood'=>7860,'clay'=>7315,'iron'=>10820,'crop'=>5060,'time'=>42029),array('wood'=>8340,'clay'=>7765,'iron'=>11480,'crop'=>5370,'time'=>44596),array('wood'=>8815,'clay'=>8205,'iron'=>12130,'crop'=>5675,'time'=>47127),array('wood'=>9280,'clay'=>8640,'iron'=>12775,'crop'=>5975,'time'=>49624),array('wood'=>9745,'clay'=>9065,'iron'=>13410,'crop'=>6270,'time'=>52090),array('wood'=>10200,'clay'=>9490,'iron'=>14035,'crop'=>6565,'time'=>54527),array('wood'=>10650,'clay'=>9910,'iron'=>14655,'crop'=>6855,'time'=>56937),array('wood'=>11095,'clay'=>10325,'iron'=>15270,'crop'=>7140,'time'=>59322));
+$ab14=array(1=>array('wood'=>1220,'clay'=>800,'iron'=>550,'crop'=>510,'time'=>5160),array('wood'=>2125,'clay'=>1395,'iron'=>960,'crop'=>890,'time'=>8984),array('wood'=>2940,'clay'=>1925,'iron'=>1325,'crop'=>1230,'time'=>12426),array('wood'=>3700,'clay'=>2425,'iron'=>1665,'crop'=>1545,'time'=>15642),array('wood'=>4420,'clay'=>2900,'iron'=>1995,'crop'=>1850,'time'=>18699),array('wood'=>5115,'clay'=>3355,'iron'=>2305,'crop'=>2140,'time'=>21636),array('wood'=>5785,'clay'=>3795,'iron'=>2610,'crop'=>2420,'time'=>24475),array('wood'=>6440,'clay'=>4220,'iron'=>2905,'crop'=>2690,'time'=>27235),array('wood'=>7075,'clay'=>4640,'iron'=>3190,'crop'=>2960,'time'=>29926),array('wood'=>7700,'clay'=>5050,'iron'=>3470,'crop'=>3220,'time'=>32557),array('wood'=>8310,'clay'=>5450,'iron'=>3745,'crop'=>3475,'time'=>35137),array('wood'=>8905,'clay'=>5840,'iron'=>4015,'crop'=>3725,'time'=>37670),array('wood'=>9495,'clay'=>6225,'iron'=>4280,'crop'=>3970,'time'=>40161),array('wood'=>10075,'clay'=>6605,'iron'=>4540,'crop'=>4210,'time'=>42614),array('wood'=>10645,'clay'=>6980,'iron'=>4800,'crop'=>4450,'time'=>45032),array('wood'=>11210,'clay'=>7350,'iron'=>5055,'crop'=>4685,'time'=>47418),array('wood'=>11770,'clay'=>7715,'iron'=>5305,'crop'=>4920,'time'=>49775),array('wood'=>12320,'clay'=>8080,'iron'=>5555,'crop'=>5150,'time'=>52104),array('wood'=>12865,'clay'=>8435,'iron'=>5800,'crop'=>5375,'time'=>54407),array('wood'=>13400,'clay'=>8790,'iron'=>6040,'crop'=>5605,'time'=>56686));
+$ab15=array(1=>array('wood'=>1345,'clay'=>995,'iron'=>1115,'crop'=>345,'time'=>9000),array('wood'=>2340,'clay'=>1730,'iron'=>1940,'crop'=>595,'time'=>15670),array('wood'=>3240,'clay'=>2395,'iron'=>2685,'crop'=>825,'time'=>21674),array('wood'=>4075,'clay'=>3015,'iron'=>3380,'crop'=>1040,'time'=>27283),array('wood'=>4875,'clay'=>3605,'iron'=>4040,'crop'=>1240,'time'=>32615),array('wood'=>5640,'clay'=>4170,'iron'=>4675,'crop'=>1435,'time'=>37737),array('wood'=>6380,'clay'=>4720,'iron'=>5290,'crop'=>1625,'time'=>42689),array('wood'=>7100,'clay'=>5250,'iron'=>5885,'crop'=>1810,'time'=>47502),array('wood'=>7800,'clay'=>5770,'iron'=>6465,'crop'=>1985,'time'=>52196),array('wood'=>8485,'clay'=>6280,'iron'=>7035,'crop'=>2160,'time'=>56786),array('wood'=>9160,'clay'=>6775,'iron'=>7595,'crop'=>2330,'time'=>61285),array('wood'=>9820,'clay'=>7265,'iron'=>8140,'crop'=>2500,'time'=>65703),array('wood'=>10470,'clay'=>7745,'iron'=>8680,'crop'=>2665,'time'=>70048),array('wood'=>11110,'clay'=>8215,'iron'=>9210,'crop'=>2830,'time'=>74327),array('wood'=>11740,'clay'=>8685,'iron'=>9730,'crop'=>2990,'time'=>78544),array('wood'=>12360,'clay'=>9145,'iron'=>10245,'crop'=>3145,'time'=>82706),array('wood'=>12975,'clay'=>9600,'iron'=>10755,'crop'=>3305,'time'=>86816),array('wood'=>13580,'clay'=>10045,'iron'=>11260,'crop'=>3460,'time'=>90878),array('wood'=>14180,'clay'=>10490,'iron'=>11755,'crop'=>3610,'time'=>94895),array('wood'=>14775,'clay'=>10930,'iron'=>12250,'crop'=>3765,'time'=>98870));
+$ab16=array(1=>array('wood'=>1085,'clay'=>1235,'iron'=>1185,'crop'=>240,'time'=>10680),array('wood'=>1885,'clay'=>2150,'iron'=>2065,'crop'=>420,'time'=>18595),array('wood'=>2610,'clay'=>2975,'iron'=>2860,'crop'=>580,'time'=>25720),array('wood'=>3285,'clay'=>3745,'iron'=>3595,'crop'=>730,'time'=>32376),array('wood'=>3925,'clay'=>4475,'iron'=>4300,'crop'=>870,'time'=>38703),array('wood'=>4540,'clay'=>5180,'iron'=>4975,'crop'=>1005,'time'=>44781),array('wood'=>5140,'clay'=>5860,'iron'=>5630,'crop'=>1140,'time'=>50658),array('wood'=>5720,'clay'=>6520,'iron'=>6265,'crop'=>1265,'time'=>56369),array('wood'=>6285,'clay'=>7160,'iron'=>6880,'crop'=>1390,'time'=>61939),array('wood'=>6835,'clay'=>7790,'iron'=>7485,'crop'=>1515,'time'=>67386),array('wood'=>7375,'clay'=>8410,'iron'=>8080,'crop'=>1635,'time'=>72725),array('wood'=>7910,'clay'=>9015,'iron'=>8665,'crop'=>1750,'time'=>77968),array('wood'=>8430,'clay'=>9610,'iron'=>9235,'crop'=>1870,'time'=>83124),array('wood'=>8945,'clay'=>10200,'iron'=>9800,'crop'=>1980,'time'=>88201),array('wood'=>9455,'clay'=>10780,'iron'=>10355,'crop'=>2095,'time'=>93206),array('wood'=>9955,'clay'=>11350,'iron'=>10905,'crop'=>2205,'time'=>98145),array('wood'=>10450,'clay'=>11915,'iron'=>11445,'crop'=>2315,'time'=>103022),array('wood'=>10940,'clay'=>12470,'iron'=>11980,'crop'=>2425,'time'=>107842),array('wood'=>11425,'clay'=>13020,'iron'=>12510,'crop'=>2530,'time'=>112609),array('wood'=>11900,'clay'=>13565,'iron'=>13035,'crop'=>2635,'time'=>117326));
+$ab17=array(1=>array('wood'=>2365,'clay'=>735,'iron'=>885,'crop'=>215,'time'=>14400),array('wood'=>4120,'clay'=>1275,'iron'=>1540,'crop'=>375,'time'=>25072),array('wood'=>5700,'clay'=>1765,'iron'=>2125,'crop'=>520,'time'=>34678),array('wood'=>7175,'clay'=>2225,'iron'=>2680,'crop'=>655,'time'=>43653),array('wood'=>8575,'clay'=>2660,'iron'=>3200,'crop'=>785,'time'=>52184),array('wood'=>9925,'clay'=>3075,'iron'=>3705,'crop'=>910,'time'=>60379),array('wood'=>11225,'clay'=>3480,'iron'=>4190,'crop'=>1030,'time'=>68303),array('wood'=>12490,'clay'=>3870,'iron'=>4660,'crop'=>1145,'time'=>76004),array('wood'=>13725,'clay'=>4255,'iron'=>5125,'crop'=>1255,'time'=>83513),array('wood'=>14935,'clay'=>4625,'iron'=>5575,'crop'=>1365,'time'=>90858),array('wood'=>16115,'clay'=>4995,'iron'=>6015,'crop'=>1475,'time'=>98057),array('wood'=>17280,'clay'=>5355,'iron'=>6450,'crop'=>1580,'time'=>105125),array('wood'=>18420,'clay'=>5710,'iron'=>6875,'crop'=>1685,'time'=>112077),array('wood'=>19545,'clay'=>6055,'iron'=>7295,'crop'=>1790,'time'=>118923),array('wood'=>20655,'clay'=>6400,'iron'=>7710,'crop'=>1890,'time'=>125671),array('wood'=>21750,'clay'=>6740,'iron'=>8115,'crop'=>1990,'time'=>132330),array('wood'=>22830,'clay'=>7075,'iron'=>8520,'crop'=>2090,'time'=>138906),array('wood'=>23900,'clay'=>7405,'iron'=>8920,'crop'=>2190,'time'=>145405),array('wood'=>24955,'clay'=>7730,'iron'=>9315,'crop'=>2285,'time'=>151833),array('wood'=>26000,'clay'=>8055,'iron'=>9705,'crop'=>2380,'time'=>158193));
+$ab18=array(1=>array('wood'=>1065,'clay'=>1415,'iron'=>735,'crop'=>95,'time'=>28800),array('wood'=>1855,'clay'=>2465,'iron'=>1275,'crop'=>170,'time'=>50144),array('wood'=>2570,'clay'=>3410,'iron'=>1765,'crop'=>235,'time'=>69357),array('wood'=>3235,'clay'=>4295,'iron'=>2225,'crop'=>295,'time'=>87305),array('wood'=>3865,'clay'=>5135,'iron'=>2660,'crop'=>350,'time'=>104368),array('wood'=>4470,'clay'=>5940,'iron'=>3075,'crop'=>405,'time'=>120757),array('wood'=>5060,'clay'=>6720,'iron'=>3480,'crop'=>460,'time'=>136606),array('wood'=>5630,'clay'=>7475,'iron'=>3870,'crop'=>510,'time'=>152007),array('wood'=>6185,'clay'=>8215,'iron'=>4255,'crop'=>560,'time'=>167027),array('wood'=>6730,'clay'=>8940,'iron'=>4625,'crop'=>610,'time'=>181716),array('wood'=>7265,'clay'=>9645,'iron'=>4995,'crop'=>660,'time'=>196113),array('wood'=>7785,'clay'=>10340,'iron'=>5355,'crop'=>705,'time'=>210251),array('wood'=>8300,'clay'=>11025,'iron'=>5710,'crop'=>750,'time'=>224154),array('wood'=>8810,'clay'=>11700,'iron'=>6055,'crop'=>800,'time'=>237845),array('wood'=>9310,'clay'=>12365,'iron'=>6400,'crop'=>845,'time'=>251342),array('wood'=>9800,'clay'=>13020,'iron'=>6740,'crop'=>890,'time'=>264660),array('wood'=>10290,'clay'=>13665,'iron'=>7075,'crop'=>930,'time'=>277812),array('wood'=>10770,'clay'=>14305,'iron'=>7405,'crop'=>975,'time'=>290811),array('wood'=>11245,'clay'=>14935,'iron'=>7730,'crop'=>1020,'time'=>303665),array('wood'=>11720,'clay'=>15565,'iron'=>8055,'crop'=>1060,'time'=>316385));
+$ab21=array(1=>array('wood'=>800,'clay'=>1010,'iron'=>585,'crop'=>370,'time'=>4920),array('wood'=>1395,'clay'=>1760,'iron'=>1020,'crop'=>645,'time'=>8566),array('wood'=>1925,'clay'=>2430,'iron'=>1410,'crop'=>890,'time'=>11848),array('wood'=>2425,'clay'=>3060,'iron'=>1775,'crop'=>1120,'time'=>14915),array('wood'=>2900,'clay'=>3660,'iron'=>2120,'crop'=>1340,'time'=>17830),array('wood'=>3355,'clay'=>4235,'iron'=>2455,'crop'=>1550,'time'=>20629),array('wood'=>3795,'clay'=>4790,'iron'=>2775,'crop'=>1755,'time'=>23337),array('wood'=>4220,'clay'=>5330,'iron'=>3090,'crop'=>1955,'time'=>25968),array('wood'=>4640,'clay'=>5860,'iron'=>3395,'crop'=>2145,'time'=>28534),array('wood'=>5050,'clay'=>6375,'iron'=>3690,'crop'=>2335,'time'=>31043),array('wood'=>5450,'clay'=>6880,'iron'=>3985,'crop'=>2520,'time'=>33503),array('wood'=>5840,'clay'=>7375,'iron'=>4270,'crop'=>2700,'time'=>35918),array('wood'=>6225,'clay'=>7860,'iron'=>4555,'crop'=>2880,'time'=>38293),array('wood'=>6605,'clay'=>8340,'iron'=>4830,'crop'=>3055,'time'=>40632),array('wood'=>6980,'clay'=>8815,'iron'=>5105,'crop'=>3230,'time'=>42938),array('wood'=>7350,'clay'=>9280,'iron'=>5375,'crop'=>3400,'time'=>45213),array('wood'=>7715,'clay'=>9745,'iron'=>5645,'crop'=>3570,'time'=>47460),array('wood'=>8080,'clay'=>10200,'iron'=>5905,'crop'=>3735,'time'=>49680),array('wood'=>8435,'clay'=>10650,'iron'=>6170,'crop'=>3900,'time'=>51876),array('wood'=>8790,'clay'=>11095,'iron'=>6425,'crop'=>4065,'time'=>54049));
+$ab22=array(1=>array('wood'=>1080,'clay'=>1150,'iron'=>1495,'crop'=>580,'time'=>6120),array('wood'=>1880,'clay'=>2000,'iron'=>2605,'crop'=>1010,'time'=>10656),array('wood'=>2600,'clay'=>2770,'iron'=>3600,'crop'=>1395,'time'=>14738),array('wood'=>3275,'clay'=>3485,'iron'=>4530,'crop'=>1760,'time'=>18552),array('wood'=>3915,'clay'=>4165,'iron'=>5420,'crop'=>2100,'time'=>22178),array('wood'=>4530,'clay'=>4820,'iron'=>6270,'crop'=>2430,'time'=>25661),array('wood'=>5125,'clay'=>5455,'iron'=>7090,'crop'=>2750,'time'=>29029),array('wood'=>5700,'clay'=>6070,'iron'=>7890,'crop'=>3060,'time'=>32302),array('wood'=>6265,'clay'=>6670,'iron'=>8670,'crop'=>3365,'time'=>35493),array('wood'=>6815,'clay'=>7255,'iron'=>9435,'crop'=>3660,'time'=>38615),array('wood'=>7355,'clay'=>7830,'iron'=>10180,'crop'=>3950,'time'=>41674),array('wood'=>7885,'clay'=>8395,'iron'=>10915,'crop'=>4235,'time'=>44678),array('wood'=>8405,'clay'=>8950,'iron'=>11635,'crop'=>4515,'time'=>47633),array('wood'=>8920,'clay'=>9495,'iron'=>12345,'crop'=>4790,'time'=>50542),array('wood'=>9425,'clay'=>10035,'iron'=>13045,'crop'=>5060,'time'=>53410),array('wood'=>9925,'clay'=>10570,'iron'=>13740,'crop'=>5330,'time'=>56240),array('wood'=>10420,'clay'=>11095,'iron'=>14420,'crop'=>5595,'time'=>59035),array('wood'=>10905,'clay'=>11610,'iron'=>15095,'crop'=>5855,'time'=>61797),array('wood'=>11385,'clay'=>12125,'iron'=>15765,'crop'=>6115,'time'=>64529),array('wood'=>11865,'clay'=>12635,'iron'=>16425,'crop'=>6370,'time'=>67232));
+$ab23=array(1=>array('wood'=>645,'clay'=>575,'iron'=>170,'crop'=>220,'time'=>5880),array('wood'=>1125,'clay'=>1000,'iron'=>295,'crop'=>385,'time'=>10238),array('wood'=>1555,'clay'=>1385,'iron'=>410,'crop'=>530,'time'=>14160),array('wood'=>1955,'clay'=>1745,'iron'=>515,'crop'=>665,'time'=>17825),array('wood'=>2335,'clay'=>2085,'iron'=>615,'crop'=>795,'time'=>21309),array('wood'=>2705,'clay'=>2410,'iron'=>715,'crop'=>920,'time'=>24655),array('wood'=>3060,'clay'=>2725,'iron'=>805,'crop'=>1045,'time'=>27890),array('wood'=>3405,'clay'=>3035,'iron'=>895,'crop'=>1160,'time'=>31035),array('wood'=>3740,'clay'=>3335,'iron'=>985,'crop'=>1275,'time'=>34101),array('wood'=>4070,'clay'=>3630,'iron'=>1075,'crop'=>1390,'time'=>37100),array('wood'=>4390,'clay'=>3915,'iron'=>1160,'crop'=>1500,'time'=>40040),array('wood'=>4710,'clay'=>4200,'iron'=>1240,'crop'=>1605,'time'=>42926),array('wood'=>5020,'clay'=>4475,'iron'=>1325,'crop'=>1710,'time'=>45765),array('wood'=>5325,'clay'=>4750,'iron'=>1405,'crop'=>1815,'time'=>48560),array('wood'=>5630,'clay'=>5020,'iron'=>1485,'crop'=>1920,'time'=>51316),array('wood'=>5925,'clay'=>5285,'iron'=>1560,'crop'=>2020,'time'=>54035),array('wood'=>6220,'clay'=>5545,'iron'=>1640,'crop'=>2120,'time'=>56720),array('wood'=>6515,'clay'=>5805,'iron'=>1715,'crop'=>2220,'time'=>59374),array('wood'=>6800,'clay'=>6065,'iron'=>1790,'crop'=>2320,'time'=>61998),array('wood'=>7085,'clay'=>6315,'iron'=>1870,'crop'=>2415,'time'=>64595));
+$ab24=array(1=>array('wood'=>1275,'clay'=>1625,'iron'=>905,'crop'=>290,'time'=>9240),array('wood'=>2220,'clay'=>2830,'iron'=>1575,'crop'=>505,'time'=>16088),array('wood'=>3070,'clay'=>3915,'iron'=>2180,'crop'=>700,'time'=>22252),array('wood'=>3865,'clay'=>4925,'iron'=>2745,'crop'=>880,'time'=>28010),array('wood'=>4620,'clay'=>5890,'iron'=>3280,'crop'=>1050,'time'=>33485),array('wood'=>5345,'clay'=>6815,'iron'=>3795,'crop'=>1215,'time'=>38743),array('wood'=>6050,'clay'=>7710,'iron'=>4295,'crop'=>1375,'time'=>43828),array('wood'=>6730,'clay'=>8575,'iron'=>4775,'crop'=>1530,'time'=>48769),array('wood'=>7395,'clay'=>9425,'iron'=>5250,'crop'=>1680,'time'=>53588),array('wood'=>8045,'clay'=>10255,'iron'=>5710,'crop'=>1830,'time'=>58300),array('wood'=>8680,'clay'=>11065,'iron'=>6165,'crop'=>1975,'time'=>62920),array('wood'=>9310,'clay'=>11865,'iron'=>6605,'crop'=>2115,'time'=>67455),array('wood'=>9925,'clay'=>12650,'iron'=>7045,'crop'=>2255,'time'=>71916),array('wood'=>10530,'clay'=>13420,'iron'=>7475,'crop'=>2395,'time'=>76309),array('wood'=>11125,'clay'=>14180,'iron'=>7900,'crop'=>2530,'time'=>80639),array('wood'=>11715,'clay'=>14935,'iron'=>8315,'crop'=>2665,'time'=>84912),array('wood'=>12300,'clay'=>15675,'iron'=>8730,'crop'=>2795,'time'=>89131),array('wood'=>12875,'clay'=>16410,'iron'=>9140,'crop'=>2930,'time'=>93302),array('wood'=>13445,'clay'=>17135,'iron'=>9540,'crop'=>3060,'time'=>97426),array('wood'=>14005,'clay'=>17850,'iron'=>9940,'crop'=>3185,'time'=>101507));
+$ab25=array(1=>array('wood'=>1310,'clay'=>1205,'iron'=>1080,'crop'=>500,'time'=>9480),array('wood'=>2280,'clay'=>2100,'iron'=>1880,'crop'=>870,'time'=>16506),array('wood'=>3155,'clay'=>2900,'iron'=>2600,'crop'=>1205,'time'=>22830),array('wood'=>3970,'clay'=>3655,'iron'=>3275,'crop'=>1515,'time'=>28738),array('wood'=>4745,'clay'=>4365,'iron'=>3915,'crop'=>1810,'time'=>34355),array('wood'=>5495,'clay'=>5055,'iron'=>4530,'crop'=>2095,'time'=>39749),array('wood'=>6215,'clay'=>5715,'iron'=>5125,'crop'=>2370,'time'=>44966),array('wood'=>6915,'clay'=>6360,'iron'=>5700,'crop'=>2640,'time'=>50036),array('wood'=>7595,'clay'=>6990,'iron'=>6265,'crop'=>2900,'time'=>54980),array('wood'=>8265,'clay'=>7605,'iron'=>6815,'crop'=>3155,'time'=>59815),array('wood'=>8920,'clay'=>8205,'iron'=>7355,'crop'=>3405,'time'=>64554),array('wood'=>9565,'clay'=>8795,'iron'=>7885,'crop'=>3650,'time'=>69208),array('wood'=>10195,'clay'=>9380,'iron'=>8405,'crop'=>3890,'time'=>73784),array('wood'=>10820,'clay'=>9950,'iron'=>8920,'crop'=>4130,'time'=>78291),array('wood'=>11435,'clay'=>10515,'iron'=>9425,'crop'=>4365,'time'=>82733),array('wood'=>12040,'clay'=>11075,'iron'=>9925,'crop'=>4595,'time'=>87117),array('wood'=>12635,'clay'=>11625,'iron'=>10420,'crop'=>4825,'time'=>91447),array('wood'=>13230,'clay'=>12170,'iron'=>10905,'crop'=>5050,'time'=>95725),array('wood'=>13815,'clay'=>12705,'iron'=>11385,'crop'=>5270,'time'=>99957),array('wood'=>14390,'clay'=>13240,'iron'=>11865,'crop'=>5495,'time'=>104144));
+$ab26=array(1=>array('wood'=>1200,'clay'=>1480,'iron'=>1640,'crop'=>450,'time'=>11160),array('wood'=>2090,'clay'=>2575,'iron'=>2860,'crop'=>785,'time'=>19431),array('wood'=>2890,'clay'=>3565,'iron'=>3955,'crop'=>1085,'time'=>26876),array('wood'=>3640,'clay'=>4485,'iron'=>4975,'crop'=>1365,'time'=>33831),array('wood'=>4350,'clay'=>5365,'iron'=>5950,'crop'=>1630,'time'=>40443),array('wood'=>5030,'clay'=>6205,'iron'=>6885,'crop'=>1885,'time'=>46793),array('wood'=>5690,'clay'=>7020,'iron'=>7785,'crop'=>2135,'time'=>52935),array('wood'=>6335,'clay'=>7810,'iron'=>8665,'crop'=>2375,'time'=>58903),array('wood'=>6960,'clay'=>8585,'iron'=>9520,'crop'=>2610,'time'=>64723),array('wood'=>7570,'clay'=>9340,'iron'=>10360,'crop'=>2840,'time'=>70415),array('wood'=>8170,'clay'=>10080,'iron'=>11180,'crop'=>3065,'time'=>75994),array('wood'=>8760,'clay'=>10805,'iron'=>11985,'crop'=>3285,'time'=>81472),array('wood'=>9340,'clay'=>11520,'iron'=>12775,'crop'=>3500,'time'=>86860),array('wood'=>9910,'clay'=>12225,'iron'=>13560,'crop'=>3715,'time'=>92165),array('wood'=>10475,'clay'=>12915,'iron'=>14325,'crop'=>3925,'time'=>97395),array('wood'=>11030,'clay'=>13600,'iron'=>15085,'crop'=>4135,'time'=>102556),array('wood'=>11575,'clay'=>14275,'iron'=>15835,'crop'=>4340,'time'=>107652),array('wood'=>12115,'clay'=>14945,'iron'=>16575,'crop'=>4545,'time'=>112689),array('wood'=>12655,'clay'=>15605,'iron'=>17310,'crop'=>4745,'time'=>117670),array('wood'=>13185,'clay'=>16260,'iron'=>18035,'crop'=>4945,'time'=>122599));
+$ab27=array(1=>array('wood'=>2250,'clay'=>1330,'iron'=>835,'crop'=>230,'time'=>16800),array('wood'=>3915,'clay'=>2315,'iron'=>1455,'crop'=>400,'time'=>29250),array('wood'=>5420,'clay'=>3200,'iron'=>2015,'crop'=>550,'time'=>40458),array('wood'=>6820,'clay'=>4025,'iron'=>2535,'crop'=>690,'time'=>50928),array('wood'=>8155,'clay'=>4815,'iron'=>3030,'crop'=>825,'time'=>60881),array('wood'=>9435,'clay'=>5570,'iron'=>3510,'crop'=>955,'time'=>70442),array('wood'=>10670,'clay'=>6300,'iron'=>3970,'crop'=>1085,'time'=>79687),array('wood'=>11875,'clay'=>7010,'iron'=>4415,'crop'=>1205,'time'=>88671),array('wood'=>13050,'clay'=>7705,'iron'=>4850,'crop'=>1325,'time'=>97432),array('wood'=>14195,'clay'=>8380,'iron'=>5280,'crop'=>1440,'time'=>106001),array('wood'=>15320,'clay'=>9045,'iron'=>5695,'crop'=>1555,'time'=>114399),array('wood'=>16425,'clay'=>9695,'iron'=>6110,'crop'=>1665,'time'=>122646),array('wood'=>17510,'clay'=>10340,'iron'=>6510,'crop'=>1775,'time'=>130757),array('wood'=>18580,'clay'=>10970,'iron'=>6910,'crop'=>1885,'time'=>138743),array('wood'=>19635,'clay'=>11595,'iron'=>7300,'crop'=>1995,'time'=>146616),array('wood'=>20675,'clay'=>12205,'iron'=>7690,'crop'=>2100,'time'=>154385),array('wood'=>21705,'clay'=>12815,'iron'=>8070,'crop'=>2205,'time'=>162057),array('wood'=>22720,'clay'=>13415,'iron'=>8450,'crop'=>2305,'time'=>169640),array('wood'=>23725,'clay'=>14005,'iron'=>8820,'crop'=>2410,'time'=>177138),array('wood'=>24720,'clay'=>14595,'iron'=>9190,'crop'=>2510,'time'=>184558));
+$ab28=array(1=>array('wood'=>1135,'clay'=>1710,'iron'=>770,'crop'=>130,'time'=>28800),array('wood'=>1980,'clay'=>2975,'iron'=>1340,'crop'=>230,'time'=>50144),array('wood'=>2735,'clay'=>4115,'iron'=>1850,'crop'=>315,'time'=>69357),array('wood'=>3445,'clay'=>5180,'iron'=>2330,'crop'=>400,'time'=>87305),array('wood'=>4120,'clay'=>6190,'iron'=>2785,'crop'=>475,'time'=>104368),array('wood'=>4765,'clay'=>7165,'iron'=>3220,'crop'=>550,'time'=>120757),array('wood'=>5390,'clay'=>8105,'iron'=>3645,'crop'=>625,'time'=>136606),array('wood'=>6000,'clay'=>9015,'iron'=>4055,'crop'=>695,'time'=>152007),array('wood'=>6590,'clay'=>9910,'iron'=>4455,'crop'=>765,'time'=>167027),array('wood'=>7170,'clay'=>10780,'iron'=>4850,'crop'=>830,'time'=>181716),array('wood'=>7740,'clay'=>11635,'iron'=>5230,'crop'=>895,'time'=>196113),array('wood'=>8300,'clay'=>12470,'iron'=>5610,'crop'=>960,'time'=>210251),array('wood'=>8845,'clay'=>13295,'iron'=>5980,'crop'=>1025,'time'=>224154),array('wood'=>9385,'clay'=>14110,'iron'=>6345,'crop'=>1085,'time'=>237845),array('wood'=>9920,'clay'=>14910,'iron'=>6705,'crop'=>1150,'time'=>251342),array('wood'=>10445,'clay'=>15700,'iron'=>7060,'crop'=>1210,'time'=>264660),array('wood'=>10965,'clay'=>16480,'iron'=>7410,'crop'=>1270,'time'=>277812),array('wood'=>11480,'clay'=>17250,'iron'=>7760,'crop'=>1330,'time'=>290811),array('wood'=>11985,'clay'=>18015,'iron'=>8100,'crop'=>1390,'time'=>303665),array('wood'=>12485,'clay'=>18765,'iron'=>8440,'crop'=>1445,'time'=>316385));
+$ab31=array(1=>array('wood'=>765,'clay'=>625,'iron'=>480,'crop'=>440,'time'=>3960),array('wood'=>1330,'clay'=>1090,'iron'=>835,'crop'=>765,'time'=>6895),array('wood'=>1840,'clay'=>1505,'iron'=>1155,'crop'=>1060,'time'=>9537),array('wood'=>2320,'clay'=>1895,'iron'=>1455,'crop'=>1335,'time'=>12004),array('wood'=>2770,'clay'=>2265,'iron'=>1740,'crop'=>1595,'time'=>14351),array('wood'=>3210,'clay'=>2620,'iron'=>2015,'crop'=>1845,'time'=>16604),array('wood'=>3630,'clay'=>2965,'iron'=>2275,'crop'=>2085,'time'=>18783),array('wood'=>4040,'clay'=>3300,'iron'=>2535,'crop'=>2320,'time'=>20901),array('wood'=>4435,'clay'=>3625,'iron'=>2785,'crop'=>2550,'time'=>22966),array('wood'=>4825,'clay'=>3945,'iron'=>3030,'crop'=>2775,'time'=>24986),array('wood'=>5210,'clay'=>4255,'iron'=>3270,'crop'=>2995,'time'=>26966),array('wood'=>5585,'clay'=>4565,'iron'=>3505,'crop'=>3210,'time'=>28909),array('wood'=>5955,'clay'=>4865,'iron'=>3735,'crop'=>3425,'time'=>30821),array('wood'=>6320,'clay'=>5160,'iron'=>3965,'crop'=>3635,'time'=>32704),array('wood'=>6675,'clay'=>5455,'iron'=>4190,'crop'=>3840,'time'=>34560),array('wood'=>7030,'clay'=>5745,'iron'=>4410,'crop'=>4045,'time'=>36391),array('wood'=>7380,'clay'=>6030,'iron'=>4630,'crop'=>4245,'time'=>38199),array('wood'=>7725,'clay'=>6310,'iron'=>4845,'crop'=>4445,'time'=>39986),array('wood'=>8065,'clay'=>6590,'iron'=>5060,'crop'=>4640,'time'=>41754),array('wood'=>8405,'clay'=>6865,'iron'=>5275,'crop'=>4835,'time'=>43503));
+$ab32=array(1=>array('wood'=>1115,'clay'=>590,'iron'=>795,'crop'=>440,'time'=>5160),array('wood'=>1940,'clay'=>1025,'iron'=>1385,'crop'=>765,'time'=>8984),array('wood'=>2685,'clay'=>1420,'iron'=>1915,'crop'=>1060,'time'=>12426),array('wood'=>3380,'clay'=>1790,'iron'=>2410,'crop'=>1335,'time'=>15642),array('wood'=>4040,'clay'=>2140,'iron'=>2880,'crop'=>1595,'time'=>18699),array('wood'=>4675,'clay'=>2475,'iron'=>3335,'crop'=>1845,'time'=>21636),array('wood'=>5290,'clay'=>2800,'iron'=>3770,'crop'=>2085,'time'=>24475),array('wood'=>5885,'clay'=>3115,'iron'=>4195,'crop'=>2320,'time'=>27235),array('wood'=>6465,'clay'=>3420,'iron'=>4610,'crop'=>2550,'time'=>29926),array('wood'=>7035,'clay'=>3725,'iron'=>5015,'crop'=>2775,'time'=>32557),array('wood'=>7595,'clay'=>4020,'iron'=>5415,'crop'=>2995,'time'=>35137),array('wood'=>8140,'clay'=>4305,'iron'=>5805,'crop'=>3210,'time'=>37670),array('wood'=>8680,'clay'=>4590,'iron'=>6190,'crop'=>3425,'time'=>40161),array('wood'=>9210,'clay'=>4875,'iron'=>6565,'crop'=>3635,'time'=>42614),array('wood'=>9730,'clay'=>5150,'iron'=>6940,'crop'=>3840,'time'=>45032),array('wood'=>10245,'clay'=>5420,'iron'=>7305,'crop'=>4045,'time'=>47418),array('wood'=>10755,'clay'=>5690,'iron'=>7670,'crop'=>4245,'time'=>49775),array('wood'=>11260,'clay'=>5960,'iron'=>8030,'crop'=>4445,'time'=>52104),array('wood'=>11755,'clay'=>6220,'iron'=>8380,'crop'=>4640,'time'=>54407),array('wood'=>12250,'clay'=>6480,'iron'=>8735,'crop'=>4835,'time'=>56686));
+$ab33=array(1=>array('wood'=>1010,'clay'=>940,'iron'=>1390,'crop'=>650,'time'=>5400),array('wood'=>1760,'clay'=>1635,'iron'=>2420,'crop'=>1130,'time'=>9402),array('wood'=>2430,'clay'=>2265,'iron'=>3345,'crop'=>1565,'time'=>13004),array('wood'=>3060,'clay'=>2850,'iron'=>4215,'crop'=>1970,'time'=>16370),array('wood'=>3660,'clay'=>3405,'iron'=>5035,'crop'=>2355,'time'=>19569),array('wood'=>4235,'clay'=>3940,'iron'=>5830,'crop'=>2725,'time'=>22642),array('wood'=>4790,'clay'=>4460,'iron'=>6595,'crop'=>3085,'time'=>25614),array('wood'=>5330,'clay'=>4960,'iron'=>7335,'crop'=>3430,'time'=>28501),array('wood'=>5860,'clay'=>5450,'iron'=>8060,'crop'=>3770,'time'=>31318),array('wood'=>6375,'clay'=>5930,'iron'=>8770,'crop'=>4100,'time'=>34072),array('wood'=>6880,'clay'=>6400,'iron'=>9465,'crop'=>4425,'time'=>36771),array('wood'=>7375,'clay'=>6860,'iron'=>10150,'crop'=>4745,'time'=>39422),array('wood'=>7860,'clay'=>7315,'iron'=>10820,'crop'=>5060,'time'=>42029),array('wood'=>8340,'clay'=>7765,'iron'=>11480,'crop'=>5370,'time'=>44596),array('wood'=>8815,'clay'=>8205,'iron'=>12130,'crop'=>5675,'time'=>47127),array('wood'=>9280,'clay'=>8640,'iron'=>12775,'crop'=>5975,'time'=>49624),array('wood'=>9745,'clay'=>9065,'iron'=>13410,'crop'=>6270,'time'=>52090),array('wood'=>10200,'clay'=>9490,'iron'=>14035,'crop'=>6565,'time'=>54527),array('wood'=>10650,'clay'=>9910,'iron'=>14655,'crop'=>6855,'time'=>56937),array('wood'=>11095,'clay'=>10325,'iron'=>15270,'crop'=>7140,'time'=>59322));
+$ab34=array(1=>array('wood'=>1220,'clay'=>800,'iron'=>550,'crop'=>510,'time'=>5160),array('wood'=>2125,'clay'=>1395,'iron'=>960,'crop'=>890,'time'=>8984),array('wood'=>2940,'clay'=>1925,'iron'=>1325,'crop'=>1230,'time'=>12426),array('wood'=>3700,'clay'=>2425,'iron'=>1665,'crop'=>1545,'time'=>15642),array('wood'=>4420,'clay'=>2900,'iron'=>1995,'crop'=>1850,'time'=>18699),array('wood'=>5115,'clay'=>3355,'iron'=>2305,'crop'=>2140,'time'=>21636),array('wood'=>5785,'clay'=>3795,'iron'=>2610,'crop'=>2420,'time'=>24475),array('wood'=>6440,'clay'=>4220,'iron'=>2905,'crop'=>2690,'time'=>27235),array('wood'=>7075,'clay'=>4640,'iron'=>3190,'crop'=>2960,'time'=>29926),array('wood'=>7700,'clay'=>5050,'iron'=>3470,'crop'=>3220,'time'=>32557),array('wood'=>8310,'clay'=>5450,'iron'=>3745,'crop'=>3475,'time'=>35137),array('wood'=>8905,'clay'=>5840,'iron'=>4015,'crop'=>3725,'time'=>37670),array('wood'=>9495,'clay'=>6225,'iron'=>4280,'crop'=>3970,'time'=>40161),array('wood'=>10075,'clay'=>6605,'iron'=>4540,'crop'=>4210,'time'=>42614),array('wood'=>10645,'clay'=>6980,'iron'=>4800,'crop'=>4450,'time'=>45032),array('wood'=>11210,'clay'=>7350,'iron'=>5055,'crop'=>4685,'time'=>47418),array('wood'=>11770,'clay'=>7715,'iron'=>5305,'crop'=>4920,'time'=>49775),array('wood'=>12320,'clay'=>8080,'iron'=>5555,'crop'=>5150,'time'=>52104),array('wood'=>12865,'clay'=>8435,'iron'=>5800,'crop'=>5375,'time'=>54407),array('wood'=>13400,'clay'=>8790,'iron'=>6040,'crop'=>5605,'time'=>56686));
+$ab35=array(1=>array('wood'=>1345,'clay'=>995,'iron'=>1115,'crop'=>345,'time'=>9000),array('wood'=>2340,'clay'=>1730,'iron'=>1940,'crop'=>595,'time'=>15670),array('wood'=>3240,'clay'=>2395,'iron'=>2685,'crop'=>825,'time'=>21674),array('wood'=>4075,'clay'=>3015,'iron'=>3380,'crop'=>1040,'time'=>27283),array('wood'=>4875,'clay'=>3605,'iron'=>4040,'crop'=>1240,'time'=>32615),array('wood'=>5640,'clay'=>4170,'iron'=>4675,'crop'=>1435,'time'=>37737),array('wood'=>6380,'clay'=>4720,'iron'=>5290,'crop'=>1625,'time'=>42689),array('wood'=>7100,'clay'=>5250,'iron'=>5885,'crop'=>1810,'time'=>47502),array('wood'=>7800,'clay'=>5770,'iron'=>6465,'crop'=>1985,'time'=>52196),array('wood'=>8485,'clay'=>6280,'iron'=>7035,'crop'=>2160,'time'=>56786),array('wood'=>9160,'clay'=>6775,'iron'=>7595,'crop'=>2330,'time'=>61285),array('wood'=>9820,'clay'=>7265,'iron'=>8140,'crop'=>2500,'time'=>65703),array('wood'=>10470,'clay'=>7745,'iron'=>8680,'crop'=>2665,'time'=>70048),array('wood'=>11110,'clay'=>8215,'iron'=>9210,'crop'=>2830,'time'=>74327),array('wood'=>11740,'clay'=>8685,'iron'=>9730,'crop'=>2990,'time'=>78544),array('wood'=>12360,'clay'=>9145,'iron'=>10245,'crop'=>3145,'time'=>82706),array('wood'=>12975,'clay'=>9600,'iron'=>10755,'crop'=>3305,'time'=>86816),array('wood'=>13580,'clay'=>10045,'iron'=>11260,'crop'=>3460,'time'=>90878),array('wood'=>14180,'clay'=>10490,'iron'=>11755,'crop'=>3610,'time'=>94895),array('wood'=>14775,'clay'=>10930,'iron'=>12250,'crop'=>3765,'time'=>98870));
+$ab36=array(1=>array('wood'=>1085,'clay'=>1235,'iron'=>1185,'crop'=>240,'time'=>10680),array('wood'=>1885,'clay'=>2150,'iron'=>2065,'crop'=>420,'time'=>18595),array('wood'=>2610,'clay'=>2975,'iron'=>2860,'crop'=>580,'time'=>25720),array('wood'=>3285,'clay'=>3745,'iron'=>3595,'crop'=>730,'time'=>32376),array('wood'=>3925,'clay'=>4475,'iron'=>4300,'crop'=>870,'time'=>38703),array('wood'=>4540,'clay'=>5180,'iron'=>4975,'crop'=>1005,'time'=>44781),array('wood'=>5140,'clay'=>5860,'iron'=>5630,'crop'=>1140,'time'=>50658),array('wood'=>5720,'clay'=>6520,'iron'=>6265,'crop'=>1265,'time'=>56369),array('wood'=>6285,'clay'=>7160,'iron'=>6880,'crop'=>1390,'time'=>61939),array('wood'=>6835,'clay'=>7790,'iron'=>7485,'crop'=>1515,'time'=>67386),array('wood'=>7375,'clay'=>8410,'iron'=>8080,'crop'=>1635,'time'=>72725),array('wood'=>7910,'clay'=>9015,'iron'=>8665,'crop'=>1750,'time'=>77968),array('wood'=>8430,'clay'=>9610,'iron'=>9235,'crop'=>1870,'time'=>83124),array('wood'=>8945,'clay'=>10200,'iron'=>9800,'crop'=>1980,'time'=>88201),array('wood'=>9455,'clay'=>10780,'iron'=>10355,'crop'=>2095,'time'=>93206),array('wood'=>9955,'clay'=>11350,'iron'=>10905,'crop'=>2205,'time'=>98145),array('wood'=>10450,'clay'=>11915,'iron'=>11445,'crop'=>2315,'time'=>103022),array('wood'=>10940,'clay'=>12470,'iron'=>11980,'crop'=>2425,'time'=>107842),array('wood'=>11425,'clay'=>13020,'iron'=>12510,'crop'=>2530,'time'=>112609),array('wood'=>11900,'clay'=>13565,'iron'=>13035,'crop'=>2635,'time'=>117326));
+$ab37=array(1=>array('wood'=>2365,'clay'=>735,'iron'=>885,'crop'=>215,'time'=>14400),array('wood'=>4120,'clay'=>1275,'iron'=>1540,'crop'=>375,'time'=>25072),array('wood'=>5700,'clay'=>1765,'iron'=>2125,'crop'=>520,'time'=>34678),array('wood'=>7175,'clay'=>2225,'iron'=>2680,'crop'=>655,'time'=>43653),array('wood'=>8575,'clay'=>2660,'iron'=>3200,'crop'=>785,'time'=>52184),array('wood'=>9925,'clay'=>3075,'iron'=>3705,'crop'=>910,'time'=>60379),array('wood'=>11225,'clay'=>3480,'iron'=>4190,'crop'=>1030,'time'=>68303),array('wood'=>12490,'clay'=>3870,'iron'=>4660,'crop'=>1145,'time'=>76004),array('wood'=>13725,'clay'=>4255,'iron'=>5125,'crop'=>1255,'time'=>83513),array('wood'=>14935,'clay'=>4625,'iron'=>5575,'crop'=>1365,'time'=>90858),array('wood'=>16115,'clay'=>4995,'iron'=>6015,'crop'=>1475,'time'=>98057),array('wood'=>17280,'clay'=>5355,'iron'=>6450,'crop'=>1580,'time'=>105125),array('wood'=>18420,'clay'=>5710,'iron'=>6875,'crop'=>1685,'time'=>112077),array('wood'=>19545,'clay'=>6055,'iron'=>7295,'crop'=>1790,'time'=>118923),array('wood'=>20655,'clay'=>6400,'iron'=>7710,'crop'=>1890,'time'=>125671),array('wood'=>21750,'clay'=>6740,'iron'=>8115,'crop'=>1990,'time'=>132330),array('wood'=>22830,'clay'=>7075,'iron'=>8520,'crop'=>2090,'time'=>138906),array('wood'=>23900,'clay'=>7405,'iron'=>8920,'crop'=>2190,'time'=>145405),array('wood'=>24955,'clay'=>7730,'iron'=>9315,'crop'=>2285,'time'=>151833),array('wood'=>26000,'clay'=>8055,'iron'=>9705,'crop'=>2380,'time'=>158193));
+$ab38=array(1=>array('wood'=>1065,'clay'=>1415,'iron'=>735,'crop'=>95,'time'=>28800),array('wood'=>1855,'clay'=>2465,'iron'=>1275,'crop'=>170,'time'=>50144),array('wood'=>2570,'clay'=>3410,'iron'=>1765,'crop'=>235,'time'=>69357),array('wood'=>3235,'clay'=>4295,'iron'=>2225,'crop'=>295,'time'=>87305),array('wood'=>3865,'clay'=>5135,'iron'=>2660,'crop'=>350,'time'=>104368),array('wood'=>4470,'clay'=>5940,'iron'=>3075,'crop'=>405,'time'=>120757),array('wood'=>5060,'clay'=>6720,'iron'=>3480,'crop'=>460,'time'=>136606),array('wood'=>5630,'clay'=>7475,'iron'=>3870,'crop'=>510,'time'=>152007),array('wood'=>6185,'clay'=>8215,'iron'=>4255,'crop'=>560,'time'=>167027),array('wood'=>6730,'clay'=>8940,'iron'=>4625,'crop'=>610,'time'=>181716),array('wood'=>7265,'clay'=>9645,'iron'=>4995,'crop'=>660,'time'=>196113),array('wood'=>7785,'clay'=>10340,'iron'=>5355,'crop'=>705,'time'=>210251),array('wood'=>8300,'clay'=>11025,'iron'=>5710,'crop'=>750,'time'=>224154),array('wood'=>8810,'clay'=>11700,'iron'=>6055,'crop'=>800,'time'=>237845),array('wood'=>9310,'clay'=>12365,'iron'=>6400,'crop'=>845,'time'=>251342),array('wood'=>9800,'clay'=>13020,'iron'=>6740,'crop'=>890,'time'=>264660),array('wood'=>10290,'clay'=>13665,'iron'=>7075,'crop'=>930,'time'=>277812),array('wood'=>10770,'clay'=>14305,'iron'=>7405,'crop'=>975,'time'=>290811),array('wood'=>11245,'clay'=>14935,'iron'=>7730,'crop'=>1020,'time'=>303665),array('wood'=>11720,'clay'=>15565,'iron'=>8055,'crop'=>1060,'time'=>316385));
+$ab41=array(1=>array('wood'=>765,'clay'=>625,'iron'=>480,'crop'=>440,'time'=>3960),array('wood'=>1330,'clay'=>1090,'iron'=>835,'crop'=>765,'time'=>6895),array('wood'=>1840,'clay'=>1505,'iron'=>1155,'crop'=>1060,'time'=>9537),array('wood'=>2320,'clay'=>1895,'iron'=>1455,'crop'=>1335,'time'=>12004),array('wood'=>2770,'clay'=>2265,'iron'=>1740,'crop'=>1595,'time'=>14351),array('wood'=>3210,'clay'=>2620,'iron'=>2015,'crop'=>1845,'time'=>16604),array('wood'=>3630,'clay'=>2965,'iron'=>2275,'crop'=>2085,'time'=>18783),array('wood'=>4040,'clay'=>3300,'iron'=>2535,'crop'=>2320,'time'=>20901),array('wood'=>4435,'clay'=>3625,'iron'=>2785,'crop'=>2550,'time'=>22966),array('wood'=>4825,'clay'=>3945,'iron'=>3030,'crop'=>2775,'time'=>24986),array('wood'=>5210,'clay'=>4255,'iron'=>3270,'crop'=>2995,'time'=>26966),array('wood'=>5585,'clay'=>4565,'iron'=>3505,'crop'=>3210,'time'=>28909),array('wood'=>5955,'clay'=>4865,'iron'=>3735,'crop'=>3425,'time'=>30821),array('wood'=>6320,'clay'=>5160,'iron'=>3965,'crop'=>3635,'time'=>32704),array('wood'=>6675,'clay'=>5455,'iron'=>4190,'crop'=>3840,'time'=>34560),array('wood'=>7030,'clay'=>5745,'iron'=>4410,'crop'=>4045,'time'=>36391),array('wood'=>7380,'clay'=>6030,'iron'=>4630,'crop'=>4245,'time'=>38199),array('wood'=>7725,'clay'=>6310,'iron'=>4845,'crop'=>4445,'time'=>39986),array('wood'=>8065,'clay'=>6590,'iron'=>5060,'crop'=>4640,'time'=>41754),array('wood'=>8405,'clay'=>6865,'iron'=>5275,'crop'=>4835,'time'=>43503));
+$ab42=array(1=>array('wood'=>1115,'clay'=>590,'iron'=>795,'crop'=>440,'time'=>5160),array('wood'=>1940,'clay'=>1025,'iron'=>1385,'crop'=>765,'time'=>8984),array('wood'=>2685,'clay'=>1420,'iron'=>1915,'crop'=>1060,'time'=>12426),array('wood'=>3380,'clay'=>1790,'iron'=>2410,'crop'=>1335,'time'=>15642),array('wood'=>4040,'clay'=>2140,'iron'=>2880,'crop'=>1595,'time'=>18699),array('wood'=>4675,'clay'=>2475,'iron'=>3335,'crop'=>1845,'time'=>21636),array('wood'=>5290,'clay'=>2800,'iron'=>3770,'crop'=>2085,'time'=>24475),array('wood'=>5885,'clay'=>3115,'iron'=>4195,'crop'=>2320,'time'=>27235),array('wood'=>6465,'clay'=>3420,'iron'=>4610,'crop'=>2550,'time'=>29926),array('wood'=>7035,'clay'=>3725,'iron'=>5015,'crop'=>2775,'time'=>32557),array('wood'=>7595,'clay'=>4020,'iron'=>5415,'crop'=>2995,'time'=>35137),array('wood'=>8140,'clay'=>4305,'iron'=>5805,'crop'=>3210,'time'=>37670),array('wood'=>8680,'clay'=>4590,'iron'=>6190,'crop'=>3425,'time'=>40161),array('wood'=>9210,'clay'=>4875,'iron'=>6565,'crop'=>3635,'time'=>42614),array('wood'=>9730,'clay'=>5150,'iron'=>6940,'crop'=>3840,'time'=>45032),array('wood'=>10245,'clay'=>5420,'iron'=>7305,'crop'=>4045,'time'=>47418),array('wood'=>10755,'clay'=>5690,'iron'=>7670,'crop'=>4245,'time'=>49775),array('wood'=>11260,'clay'=>5960,'iron'=>8030,'crop'=>4445,'time'=>52104),array('wood'=>11755,'clay'=>6220,'iron'=>8380,'crop'=>4640,'time'=>54407),array('wood'=>12250,'clay'=>6480,'iron'=>8735,'crop'=>4835,'time'=>56686));
+$ab43=array(1=>array('wood'=>1010,'clay'=>940,'iron'=>1390,'crop'=>650,'time'=>5400),array('wood'=>1760,'clay'=>1635,'iron'=>2420,'crop'=>1130,'time'=>9402),array('wood'=>2430,'clay'=>2265,'iron'=>3345,'crop'=>1565,'time'=>13004),array('wood'=>3060,'clay'=>2850,'iron'=>4215,'crop'=>1970,'time'=>16370),array('wood'=>3660,'clay'=>3405,'iron'=>5035,'crop'=>2355,'time'=>19569),array('wood'=>4235,'clay'=>3940,'iron'=>5830,'crop'=>2725,'time'=>22642),array('wood'=>4790,'clay'=>4460,'iron'=>6595,'crop'=>3085,'time'=>25614),array('wood'=>5330,'clay'=>4960,'iron'=>7335,'crop'=>3430,'time'=>28501),array('wood'=>5860,'clay'=>5450,'iron'=>8060,'crop'=>3770,'time'=>31318),array('wood'=>6375,'clay'=>5930,'iron'=>8770,'crop'=>4100,'time'=>34072),array('wood'=>6880,'clay'=>6400,'iron'=>9465,'crop'=>4425,'time'=>36771),array('wood'=>7375,'clay'=>6860,'iron'=>10150,'crop'=>4745,'time'=>39422),array('wood'=>7860,'clay'=>7315,'iron'=>10820,'crop'=>5060,'time'=>42029),array('wood'=>8340,'clay'=>7765,'iron'=>11480,'crop'=>5370,'time'=>44596),array('wood'=>8815,'clay'=>8205,'iron'=>12130,'crop'=>5675,'time'=>47127),array('wood'=>9280,'clay'=>8640,'iron'=>12775,'crop'=>5975,'time'=>49624),array('wood'=>9745,'clay'=>9065,'iron'=>13410,'crop'=>6270,'time'=>52090),array('wood'=>10200,'clay'=>9490,'iron'=>14035,'crop'=>6565,'time'=>54527),array('wood'=>10650,'clay'=>9910,'iron'=>14655,'crop'=>6855,'time'=>56937),array('wood'=>11095,'clay'=>10325,'iron'=>15270,'crop'=>7140,'time'=>59322));
+$ab44=array(1=>array('wood'=>1220,'clay'=>800,'iron'=>550,'crop'=>510,'time'=>5160),array('wood'=>2125,'clay'=>1395,'iron'=>960,'crop'=>890,'time'=>8984),array('wood'=>2940,'clay'=>1925,'iron'=>1325,'crop'=>1230,'time'=>12426),array('wood'=>3700,'clay'=>2425,'iron'=>1665,'crop'=>1545,'time'=>15642),array('wood'=>4420,'clay'=>2900,'iron'=>1995,'crop'=>1850,'time'=>18699),array('wood'=>5115,'clay'=>3355,'iron'=>2305,'crop'=>2140,'time'=>21636),array('wood'=>5785,'clay'=>3795,'iron'=>2610,'crop'=>2420,'time'=>24475),array('wood'=>6440,'clay'=>4220,'iron'=>2905,'crop'=>2690,'time'=>27235),array('wood'=>7075,'clay'=>4640,'iron'=>3190,'crop'=>2960,'time'=>29926),array('wood'=>7700,'clay'=>5050,'iron'=>3470,'crop'=>3220,'time'=>32557),array('wood'=>8310,'clay'=>5450,'iron'=>3745,'crop'=>3475,'time'=>35137),array('wood'=>8905,'clay'=>5840,'iron'=>4015,'crop'=>3725,'time'=>37670),array('wood'=>9495,'clay'=>6225,'iron'=>4280,'crop'=>3970,'time'=>40161),array('wood'=>10075,'clay'=>6605,'iron'=>4540,'crop'=>4210,'time'=>42614),array('wood'=>10645,'clay'=>6980,'iron'=>4800,'crop'=>4450,'time'=>45032),array('wood'=>11210,'clay'=>7350,'iron'=>5055,'crop'=>4685,'time'=>47418),array('wood'=>11770,'clay'=>7715,'iron'=>5305,'crop'=>4920,'time'=>49775),array('wood'=>12320,'clay'=>8080,'iron'=>5555,'crop'=>5150,'time'=>52104),array('wood'=>12865,'clay'=>8435,'iron'=>5800,'crop'=>5375,'time'=>54407),array('wood'=>13400,'clay'=>8790,'iron'=>6040,'crop'=>5605,'time'=>56686));
+$ab45=array(1=>array('wood'=>1345,'clay'=>995,'iron'=>1115,'crop'=>345,'time'=>9000),array('wood'=>2340,'clay'=>1730,'iron'=>1940,'crop'=>595,'time'=>15670),array('wood'=>3240,'clay'=>2395,'iron'=>2685,'crop'=>825,'time'=>21674),array('wood'=>4075,'clay'=>3015,'iron'=>3380,'crop'=>1040,'time'=>27283),array('wood'=>4875,'clay'=>3605,'iron'=>4040,'crop'=>1240,'time'=>32615),array('wood'=>5640,'clay'=>4170,'iron'=>4675,'crop'=>1435,'time'=>37737),array('wood'=>6380,'clay'=>4720,'iron'=>5290,'crop'=>1625,'time'=>42689),array('wood'=>7100,'clay'=>5250,'iron'=>5885,'crop'=>1810,'time'=>47502),array('wood'=>7800,'clay'=>5770,'iron'=>6465,'crop'=>1985,'time'=>52196),array('wood'=>8485,'clay'=>6280,'iron'=>7035,'crop'=>2160,'time'=>56786),array('wood'=>9160,'clay'=>6775,'iron'=>7595,'crop'=>2330,'time'=>61285),array('wood'=>9820,'clay'=>7265,'iron'=>8140,'crop'=>2500,'time'=>65703),array('wood'=>10470,'clay'=>7745,'iron'=>8680,'crop'=>2665,'time'=>70048),array('wood'=>11110,'clay'=>8215,'iron'=>9210,'crop'=>2830,'time'=>74327),array('wood'=>11740,'clay'=>8685,'iron'=>9730,'crop'=>2990,'time'=>78544),array('wood'=>12360,'clay'=>9145,'iron'=>10245,'crop'=>3145,'time'=>82706),array('wood'=>12975,'clay'=>9600,'iron'=>10755,'crop'=>3305,'time'=>86816),array('wood'=>13580,'clay'=>10045,'iron'=>11260,'crop'=>3460,'time'=>90878),array('wood'=>14180,'clay'=>10490,'iron'=>11755,'crop'=>3610,'time'=>94895),array('wood'=>14775,'clay'=>10930,'iron'=>12250,'crop'=>3765,'time'=>98870));
+$ab46=array(1=>array('wood'=>1085,'clay'=>1235,'iron'=>1185,'crop'=>240,'time'=>10680),array('wood'=>1885,'clay'=>2150,'iron'=>2065,'crop'=>420,'time'=>18595),array('wood'=>2610,'clay'=>2975,'iron'=>2860,'crop'=>580,'time'=>25720),array('wood'=>3285,'clay'=>3745,'iron'=>3595,'crop'=>730,'time'=>32376),array('wood'=>3925,'clay'=>4475,'iron'=>4300,'crop'=>870,'time'=>38703),array('wood'=>4540,'clay'=>5180,'iron'=>4975,'crop'=>1005,'time'=>44781),array('wood'=>5140,'clay'=>5860,'iron'=>5630,'crop'=>1140,'time'=>50658),array('wood'=>5720,'clay'=>6520,'iron'=>6265,'crop'=>1265,'time'=>56369),array('wood'=>6285,'clay'=>7160,'iron'=>6880,'crop'=>1390,'time'=>61939),array('wood'=>6835,'clay'=>7790,'iron'=>7485,'crop'=>1515,'time'=>67386),array('wood'=>7375,'clay'=>8410,'iron'=>8080,'crop'=>1635,'time'=>72725),array('wood'=>7910,'clay'=>9015,'iron'=>8665,'crop'=>1750,'time'=>77968),array('wood'=>8430,'clay'=>9610,'iron'=>9235,'crop'=>1870,'time'=>83124),array('wood'=>8945,'clay'=>10200,'iron'=>9800,'crop'=>1980,'time'=>88201),array('wood'=>9455,'clay'=>10780,'iron'=>10355,'crop'=>2095,'time'=>93206),array('wood'=>9955,'clay'=>11350,'iron'=>10905,'crop'=>2205,'time'=>98145),array('wood'=>10450,'clay'=>11915,'iron'=>11445,'crop'=>2315,'time'=>103022),array('wood'=>10940,'clay'=>12470,'iron'=>11980,'crop'=>2425,'time'=>107842),array('wood'=>11425,'clay'=>13020,'iron'=>12510,'crop'=>2530,'time'=>112609),array('wood'=>11900,'clay'=>13565,'iron'=>13035,'crop'=>2635,'time'=>117326));
+$ab47=array(1=>array('wood'=>2365,'clay'=>735,'iron'=>885,'crop'=>215,'time'=>14400),array('wood'=>4120,'clay'=>1275,'iron'=>1540,'crop'=>375,'time'=>25072),array('wood'=>5700,'clay'=>1765,'iron'=>2125,'crop'=>520,'time'=>34678),array('wood'=>7175,'clay'=>2225,'iron'=>2680,'crop'=>655,'time'=>43653),array('wood'=>8575,'clay'=>2660,'iron'=>3200,'crop'=>785,'time'=>52184),array('wood'=>9925,'clay'=>3075,'iron'=>3705,'crop'=>910,'time'=>60379),array('wood'=>11225,'clay'=>3480,'iron'=>4190,'crop'=>1030,'time'=>68303),array('wood'=>12490,'clay'=>3870,'iron'=>4660,'crop'=>1145,'time'=>76004),array('wood'=>13725,'clay'=>4255,'iron'=>5125,'crop'=>1255,'time'=>83513),array('wood'=>14935,'clay'=>4625,'iron'=>5575,'crop'=>1365,'time'=>90858),array('wood'=>16115,'clay'=>4995,'iron'=>6015,'crop'=>1475,'time'=>98057),array('wood'=>17280,'clay'=>5355,'iron'=>6450,'crop'=>1580,'time'=>105125),array('wood'=>18420,'clay'=>5710,'iron'=>6875,'crop'=>1685,'time'=>112077),array('wood'=>19545,'clay'=>6055,'iron'=>7295,'crop'=>1790,'time'=>118923),array('wood'=>20655,'clay'=>6400,'iron'=>7710,'crop'=>1890,'time'=>125671),array('wood'=>21750,'clay'=>6740,'iron'=>8115,'crop'=>1990,'time'=>132330),array('wood'=>22830,'clay'=>7075,'iron'=>8520,'crop'=>2090,'time'=>138906),array('wood'=>23900,'clay'=>7405,'iron'=>8920,'crop'=>2190,'time'=>145405),array('wood'=>24955,'clay'=>7730,'iron'=>9315,'crop'=>2285,'time'=>151833),array('wood'=>26000,'clay'=>8055,'iron'=>9705,'crop'=>2380,'time'=>158193));
+$ab48=array(1=>array('wood'=>1065,'clay'=>1415,'iron'=>735,'crop'=>95,'time'=>28800),array('wood'=>1855,'clay'=>2465,'iron'=>1275,'crop'=>170,'time'=>50144),array('wood'=>2570,'clay'=>3410,'iron'=>1765,'crop'=>235,'time'=>69357),array('wood'=>3235,'clay'=>4295,'iron'=>2225,'crop'=>295,'time'=>87305),array('wood'=>3865,'clay'=>5135,'iron'=>2660,'crop'=>350,'time'=>104368),array('wood'=>4470,'clay'=>5940,'iron'=>3075,'crop'=>405,'time'=>120757),array('wood'=>5060,'clay'=>6720,'iron'=>3480,'crop'=>460,'time'=>136606),array('wood'=>5630,'clay'=>7475,'iron'=>3870,'crop'=>510,'time'=>152007),array('wood'=>6185,'clay'=>8215,'iron'=>4255,'crop'=>560,'time'=>167027),array('wood'=>6730,'clay'=>8940,'iron'=>4625,'crop'=>610,'time'=>181716),array('wood'=>7265,'clay'=>9645,'iron'=>4995,'crop'=>660,'time'=>196113),array('wood'=>7785,'clay'=>10340,'iron'=>5355,'crop'=>705,'time'=>210251),array('wood'=>8300,'clay'=>11025,'iron'=>5710,'crop'=>750,'time'=>224154),array('wood'=>8810,'clay'=>11700,'iron'=>6055,'crop'=>800,'time'=>237845),array('wood'=>9310,'clay'=>12365,'iron'=>6400,'crop'=>845,'time'=>251342),array('wood'=>9800,'clay'=>13020,'iron'=>6740,'crop'=>890,'time'=>264660),array('wood'=>10290,'clay'=>13665,'iron'=>7075,'crop'=>930,'time'=>277812),array('wood'=>10770,'clay'=>14305,'iron'=>7405,'crop'=>975,'time'=>290811),array('wood'=>11245,'clay'=>14935,'iron'=>7730,'crop'=>1020,'time'=>303665),array('wood'=>11720,'clay'=>15565,'iron'=>8055,'crop'=>1060,'time'=>316385));
+
+?>
\ No newline at end of file
diff --git a/GameEngine/Data/unitdata.php b/GameEngine/Data/unitdata.php
new file mode 100644
index 00000000..f7dc4901
--- /dev/null
+++ b/GameEngine/Data/unitdata.php
@@ -0,0 +1,91 @@
+array(1,2,3,11,12,13,14,21,22,31,32,33,34,41,42,43,44),'cavalry'=>array(4,5,6,15,16,23,24,25,26,35,36,45,46),'siege'=>array(7,8,17,18,27,28,37,38,47,48),'ram'=>array(7,17,27,47),'catapult'=>array(8,18,28,48),'expansion'=>array(9,10,19,20,29,30,39,40,49,50),'scout'=>array(4,14,23,44),'chief'=>array(9,19,29,49));
+
+$u1=array('atk'=>40,'di'=>35,'dc'=>50,'wood'=>120,'clay'=>100,'iron'=>150,'crop'=>30,'pop'=>1,'speed'=>6,'time'=>1600,'cap'=>50);
+$u2=array('atk'=>30,'di'=>65,'dc'=>35,'wood'=>100,'clay'=>130,'iron'=>160,'crop'=>70,'pop'=>1,'speed'=>5,'time'=>1760,'cap'=>20);
+$u3=array('atk'=>70,'di'=>40,'dc'=>25,'wood'=>150,'clay'=>160,'iron'=>210,'crop'=>80,'pop'=>1,'speed'=>7,'time'=>1920,'cap'=>50);
+$u4=array('atk'=>0,'di'=>20,'dc'=>10,'wood'=>140,'clay'=>160,'iron'=>20,'crop'=>40,'pop'=>2,'speed'=>16,'time'=>1360,'cap'=>0);
+$u5=array('atk'=>120,'di'=>65,'dc'=>50,'wood'=>550,'clay'=>440,'iron'=>320,'crop'=>100,'pop'=>3,'speed'=>14,'time'=>2640,'cap'=>100);
+$u6=array('atk'=>180,'di'=>80,'dc'=>105,'wood'=>550,'clay'=>640,'iron'=>800,'crop'=>180,'pop'=>4,'speed'=>10,'time'=>3520,'cap'=>70);
+$u7=array('atk'=>60,'di'=>30,'dc'=>75,'wood'=>900,'clay'=>360,'iron'=>500,'crop'=>70,'pop'=>3,'speed'=>4,'time'=>4600,'cap'=>0);
+$u8=array('atk'=>75,'di'=>60,'dc'=>10,'wood'=>950,'clay'=>1350,'iron'=>600,'crop'=>90,'pop'=>6,'speed'=>3,'time'=>9000,'cap'=>0);
+$u9=array('atk'=>50,'di'=>40,'dc'=>30,'wood'=>30750,'clay'=>27200,'iron'=>45000,'crop'=>37500,'pop'=>5,'speed'=>5,'time'=>90700,'cap'=>0);
+$u10=array('atk'=>0,'di'=>80,'dc'=>80,'wood'=>5800,'clay'=>5300,'iron'=>7200,'crop'=>5500,'pop'=>1,'speed'=>5,'time'=>26900,'cap'=>3000);
+$u11=array('atk'=>40,'di'=>20,'dc'=>5,'wood'=>95,'clay'=>75,'iron'=>40,'crop'=>40,'pop'=>1,'speed'=>7,'time'=>720,'cap'=>60);
+$u12=array('atk'=>10,'di'=>35,'dc'=>60,'wood'=>145,'clay'=>70,'iron'=>85,'crop'=>40,'pop'=>1,'speed'=>7,'time'=>1120,'cap'=>40);
+$u13=array('atk'=>60,'di'=>30,'dc'=>30,'wood'=>130,'clay'=>120,'iron'=>170,'crop'=>70,'pop'=>1,'speed'=>6,'time'=>1200,'cap'=>50);
+$u14=array('atk'=>0,'di'=>10,'dc'=>5,'wood'=>160,'clay'=>100,'iron'=>50,'crop'=>50,'pop'=>1,'speed'=>9,'time'=>1120,'cap'=>0);
+$u15=array('atk'=>55,'di'=>100,'dc'=>40,'wood'=>370,'clay'=>270,'iron'=>290,'crop'=>75,'pop'=>2,'speed'=>10,'time'=>2400,'cap'=>110);
+$u16=array('atk'=>150,'di'=>50,'dc'=>75,'wood'=>450,'clay'=>515,'iron'=>480,'crop'=>80,'pop'=>3,'speed'=>9,'time'=>2960,'cap'=>80);
+$u17=array('atk'=>65,'di'=>30,'dc'=>80,'wood'=>1000,'clay'=>300,'iron'=>350,'crop'=>70,'pop'=>3,'speed'=>4,'time'=>4200,'cap'=>0);
+$u18=array('atk'=>50,'di'=>60,'dc'=>10,'wood'=>900,'clay'=>1200,'iron'=>600,'crop'=>60,'pop'=>6,'speed'=>3,'time'=>9000,'cap'=>0);
+$u19=array('atk'=>40,'di'=>60,'dc'=>40,'wood'=>35500,'clay'=>26600,'iron'=>25000,'crop'=>27200,'pop'=>4,'speed'=>5,'time'=>70500,'cap'=>0);
+$u20=array('atk'=>10,'di'=>80,'dc'=>80,'wood'=>7200,'clay'=>5500,'iron'=>5800,'crop'=>6500,'pop'=>1,'speed'=>5,'time'=>31000,'cap'=>3000);
+$u21=array('atk'=>15,'di'=>40,'dc'=>50,'wood'=>100,'clay'=>130,'iron'=>55,'crop'=>30,'pop'=>1,'speed'=>7,'time'=>1040,'cap'=>35);
+$u22=array('atk'=>65,'di'=>35,'dc'=>20,'wood'=>140,'clay'=>150,'iron'=>185,'crop'=>60,'pop'=>1,'speed'=>6,'time'=>1440,'cap'=>45);
+$u23=array('atk'=>0,'di'=>20,'dc'=>10,'wood'=>170,'clay'=>150,'iron'=>20,'crop'=>40,'pop'=>2,'speed'=>17,'time'=>1360,'cap'=>0);
+$u24=array('atk'=>90,'di'=>25,'dc'=>40,'wood'=>350,'clay'=>450,'iron'=>230,'crop'=>60,'pop'=>2,'speed'=>19,'time'=>2480,'cap'=>75);
+$u25=array('atk'=>45,'di'=>115,'dc'=>55,'wood'=>360,'clay'=>330,'iron'=>280,'crop'=>120,'pop'=>2,'speed'=>16,'time'=>2560,'cap'=>35);
+$u26=array('atk'=>140,'di'=>50,'dc'=>165,'wood'=>500,'clay'=>620,'iron'=>675,'crop'=>170,'pop'=>3,'speed'=>13,'time'=>3120,'cap'=>65);
+$u27=array('atk'=>50,'di'=>30,'dc'=>105,'wood'=>950,'clay'=>555,'iron'=>330,'crop'=>75,'pop'=>3,'speed'=>4,'time'=>5000,'cap'=>0);
+$u28=array('atk'=>70,'di'=>45,'dc'=>10,'wood'=>960,'clay'=>1450,'iron'=>630,'crop'=>90,'pop'=>6,'speed'=>3,'time'=>9000,'cap'=>0);
+$u29=array('atk'=>40,'di'=>50,'dc'=>50,'wood'=>30750,'clay'=>45400,'iron'=>31000,'crop'=>37500,'pop'=>4,'speed'=>4,'time'=>90700,'cap'=>0);
+$u30=array('atk'=>0,'di'=>80,'dc'=>80,'wood'=>5500,'clay'=>7000,'iron'=>5300,'crop'=>4900,'pop'=>1,'speed'=>5,'time'=>22700,'cap'=>3000);
+$u31=array('atk'=>10,'di'=>25,'dc'=>20,'wood'=>85,'clay'=>75,'iron'=>120,'crop'=>25,'speed'=>7,'pop'=>1,'time'=>1600,'cap'=>45);
+$u32=array('atk'=>20,'di'=>35,'dc'=>40,'wood'=>125,'clay'=>130,'iron'=>60,'crop'=>40,'speed'=>7,'pop'=>1,'time'=>1800,'cap'=>65);
+$u33=array('atk'=>60,'di'=>40,'dc'=>60,'wood'=>140,'clay'=>150,'iron'=>40,'crop'=>60,'speed'=>6,'pop'=>1,'time'=>1900,'cap'=>80);
+$u34=array('atk'=>10,'di'=>66,'dc'=>50,'wood'=>95,'clay'=>120,'iron'=>65,'crop'=>25,'speed'=>9,'pop'=>1,'time'=>2000,'cap'=>0);
+$u35=array('atk'=>50,'di'=>70,'dc'=>33,'wood'=>250,'clay'=>200,'iron'=>125,'crop'=>45,'speed'=>10,'pop'=>2,'time'=>2000,'cap'=>120);
+$u36=array('atk'=>100,'di'=>80,'dc'=>70,'wood'=>250,'clay'=>125,'iron'=>250,'crop'=>150,'speed'=>9,'pop'=>2,'time'=>2000,'cap'=>150);
+$u37=array('atk'=>250,'di'=>140,'dc'=>200,'wood'=>250,'clay'=>220,'iron'=>135,'crop'=>50,'speed'=>4,'pop'=>3,'time'=>2000,'cap'=>125);
+$u38=array('atk'=>450,'di'=>380,'dc'=>240,'wood'=>125,'clay'=>250,'iron'=>300,'crop'=>65,'speed'=>3,'pop'=>3,'time'=>2000,'cap'=>0);
+$u39=array('atk'=>200,'di'=>170,'dc'=>250,'wood'=>350,'clay'=>350,'iron'=>125,'crop'=>80,'speed'=>5,'pop'=>3,'time'=>70500,'cap'=>0);
+$u40=array('atk'=>600,'di'=>440,'dc'=>520,'wood'=>350,'clay'=>250,'iron'=>135,'crop'=>100,'speed'=>5,'pop'=>5,'time'=>31000,'cap'=>3000);
+$u41=array('atk'=>20,'di'=>35,'dc'=>50,'wood'=>105,'clay'=>110,'iron'=>85,'crop'=>50,'pop'=>1,'speed'=>10,'time'=>1100,'cap'=>25);
+$u42=array('atk'=>65,'di'=>30,'dc'=>10,'wood'=>95,'clay'=>145,'iron'=>100,'crop'=>55,'pop'=>1,'speed'=>9,'time'=>1300,'cap'=>55);
+$u43=array('atk'=>100,'di'=>90,'dc'=>75,'wood'=>125,'clay'=>165,'iron'=>130,'crop'=>75,'pop'=>1,'speed'=>15,'time'=>1500,'cap'=>60);
+$u44=array('atk'=>0,'di'=>10,'dc'=>0,'wood'=>50,'clay'=>25,'iron'=>20,'crop'=>5,'pop'=>2,'speed'=>20,'time'=>2200,'cap'=>0);
+$u45=array('atk'=>155,'di'=>80,'dc'=>50,'wood'=>150,'clay'=>205,'iron'=>135,'crop'=>85,'pop'=>2,'speed'=>22,'time'=>3000,'cap'=>80);
+$u46=array('atk'=>170,'di'=>140,'dc'=>80,'wood'=>175,'clay'=>230,'iron'=>200,'crop'=>100,'pop'=>2,'speed'=>20,'time'=>3450,'cap'=>45);
+$u47=array('atk'=>250,'di'=>120,'dc'=>150,'wood'=>225,'clay'=>255,'iron'=>230,'crop'=>125,'pop'=>3,'speed'=>17,'time'=>4000,'cap'=>55);
+$u48=array('atk'=>60,'di'=>45,'dc'=>10,'wood'=>1500,'clay'=>760,'iron'=>890,'crop'=>390,'pop'=>0,'speed'=>0,'time'=>0,'cap'=>0);
+$u49=array('atk'=>80,'di'=>50,'dc'=>50,'wood'=>37000,'clay'=>30000,'iron'=>32000,'crop'=>33500,'pop'=>0,'speed'=>0,'time'=>0,'cap'=>0);
+$u50=array('atk'=>30,'di'=>40,'dc'=>40,'wood'=>8000,'clay'=>8250,'iron'=>8500,'crop'=>5505,'pop'=>0,'speed'=>0,'time'=>0,'cap'=>0);
+$u51=array('atk'=>10,'di'=>25,'dc'=>20,'wood'=>85,'clay'=>75,'iron'=>120,'crop'=>25,'speed'=>7,'pop'=>1,'time'=>1600,'cap'=>45);
+$u52=array('atk'=>20,'di'=>35,'dc'=>40,'wood'=>125,'clay'=>130,'iron'=>60,'crop'=>40,'speed'=>7,'pop'=>1,'time'=>1800,'cap'=>65);
+$u53=array('atk'=>60,'di'=>40,'dc'=>60,'wood'=>140,'clay'=>150,'iron'=>40,'crop'=>60,'speed'=>6,'pop'=>1,'time'=>1900,'cap'=>80);
+$u54=array('atk'=>10,'di'=>66,'dc'=>50,'wood'=>95,'clay'=>120,'iron'=>65,'crop'=>25,'speed'=>9,'pop'=>1,'time'=>2000,'cap'=>0);
+$u55=array('atk'=>50,'di'=>70,'dc'=>33,'wood'=>250,'clay'=>200,'iron'=>125,'crop'=>45,'speed'=>10,'pop'=>2,'time'=>2000,'cap'=>120);
+$u56=array('atk'=>100,'di'=>80,'dc'=>70,'wood'=>250,'clay'=>125,'iron'=>250,'crop'=>150,'speed'=>9,'pop'=>2,'time'=>2000,'cap'=>150);
+$u57=array('atk'=>250,'di'=>140,'dc'=>200,'wood'=>250,'clay'=>220,'iron'=>135,'crop'=>50,'speed'=>4,'pop'=>3,'time'=>2000,'cap'=>125);
+$u58=array('atk'=>450,'di'=>380,'dc'=>240,'wood'=>125,'clay'=>250,'iron'=>300,'crop'=>65,'speed'=>3,'pop'=>3,'time'=>2000,'cap'=>0);
+$u59=array('atk'=>200,'di'=>170,'dc'=>250,'wood'=>350,'clay'=>350,'iron'=>125,'crop'=>80,'speed'=>5,'pop'=>3,'time'=>70500,'cap'=>0);
+$u60=array('atk'=>600,'di'=>440,'dc'=>520,'wood'=>350,'clay'=>250,'iron'=>135,'crop'=>100,'speed'=>5,'pop'=>5,'time'=>31000,'cap'=>3000);
+$u99=array('atk'=>0,'di'=>0,'dc'=>0,'wood'=>20,'clay'=>30,'iron'=>10,'crop'=>20,'speed'=>0,'pop'=>0,'time'=>600,'cap'=>0);
+// Hero data base values and increase per point
+$h1=array('atk'=>50,'atkp'=>54,'di'=>60,'dip'=>49,'dc'=>85,'dcp'=>62.5);
+$h2=array('atk'=>40,'atkp'=>46.5,'di'=>100,'dip'=>75.5,'dc'=>60,'dcp'=>47.5);
+$h3=array('atk'=>90,'atkp'=>74,'di'=>65,'dip'=>57,'dc'=>40,'dcp'=>42);
+$h5=array('atk'=>150,'atkp'=>107.5,'di'=>100,'dip'=>73,'dc'=>85,'dcp'=>59);
+$h6=array('atk'=>225,'atkp'=>147.5,'di'=>135,'dip'=>79,'dc'=>175,'dcp'=>99);
+$h11=array('atk'=>50,'atkp'=>54,'di'=>35,'dip'=>49.5,'dc'=>10,'dcp'=>24);
+$h12=array('atk'=>15,'atkp'=>34,'di'=>60,'dip'=>48,'dc'=>100,'dcp'=>70.5);
+$h13=array('atk'=>75,'atkp'=>67.5,'di'=>50,'dip'=>47.5,'dc'=>50,'dcp'=>47.5);
+$h15=array('atk'=>70,'atkp'=>64,'di'=>165,'dip'=>100,'dc'=>65,'dcp'=>39.5);
+$h16=array('atk'=>190,'atkp'=>127.5,'di'=>85,'dip'=>58.5,'dc'=>125,'dcp'=>80);
+$h21=array('atk'=>20,'atkp'=>37.5,'di'=>65,'dip'=>53,'dc'=>85,'dcp'=>62);
+$h22=array('atk'=>80,'atkp'=>71,'di'=>60,'dip'=>54,'dc'=>35,'dcp'=>38);
+$h24=array('atk'=>115,'atkp'=>87.5,'di'=>40,'dip'=>42,'dc'=>65,'dcp'=>57);
+$h25=array('atk'=>55,'atkp'=>57.5,'di'=>190,'dip'=>108.5,'dc'=>90,'dcp'=>60.5);
+$h26=array('atk'=>175,'atkp'=>121,'di'=>85,'dip'=>55,'dc'=>275,'dcp'=>145);
+?>
\ No newline at end of file
diff --git a/GameEngine/Database.php b/GameEngine/Database.php
new file mode 100644
index 00000000..edf037ea
--- /dev/null
+++ b/GameEngine/Database.php
@@ -0,0 +1,27 @@
+
\ No newline at end of file
diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php
new file mode 100644
index 00000000..f21c5309
--- /dev/null
+++ b/GameEngine/Database/db_MYSQL.php
@@ -0,0 +1,3328 @@
+connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error());
+ mysql_select_db(SQL_DB, $this->connection) or die(mysql_error());
+ }
+
+ function register($username, $password, $email, $tribe, $act) {
+ $time = time();
+ $timep = time() + PROTECTION;
+ if(strtotime(START_TIME) > time()){
+ $timep = (strtotime(START_TIME) + PROTECTION);
+ }
+ $q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)";
+ if(mysql_query($q, $this->connection)) {
+ return mysql_insert_id($this->connection);
+ } else {
+ return false;
+ }
+ }
+
+ function activate($username, $password, $email, $tribe, $locate, $act, $act2) {
+ $time = time();
+ $q = "INSERT INTO " . TB_PREFIX . "activate (username,password,access,email,tribe,timestamp,location,act,act2) VALUES ('$username', '$password', " . USER . ", '$email', $tribe, $time, $locate, '$act', '$act2')";
+ if(mysql_query($q, $this->connection)) {
+ return mysql_insert_id($this->connection);
+ } else {
+ return false;
+ }
+ }
+
+ function unreg($username) {
+ $q = "DELETE from " . TB_PREFIX . "activate where username = '$username'";
+ return mysql_query($q, $this->connection);
+ }
+ function deleteReinf($id) {
+ $q = "DELETE from " . TB_PREFIX . "enforcement where id = '$id'";
+ mysql_query($q, $this->connection);
+ }
+ function updateResource($vid, $what, $number) {
+
+ $q = "UPDATE " . TB_PREFIX . "vdata set " . $what . "=" . $number . " where wref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_query($q, $this->connection);
+ }
+
+ function checkExist($ref, $mode) {
+
+ if(!$mode) {
+ $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$ref' LIMIT 1";
+ } else {
+ $q = "SELECT email FROM " . TB_PREFIX . "users where email = '$ref' LIMIT 1";
+ }
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function checkExist_activate($ref, $mode) {
+
+ if(!$mode) {
+ $q = "SELECT username FROM " . TB_PREFIX . "activate where username = '$ref' LIMIT 1";
+ } else {
+ $q = "SELECT email FROM " . TB_PREFIX . "activate where email = '$ref' LIMIT 1";
+ }
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public function hasBeginnerProtection($vid) {
+ $q = "SELECT u.protect FROM ".TB_PREFIX."users u,".TB_PREFIX."vdata v WHERE u.id=v.owner AND v.wref=".$vid;
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ if(!empty($dbarray)) {
+ if(time()<$dbarray[0]) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ function updateUserField($ref, $field, $value, $switch) {
+ if(!$switch) {
+ $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where username = '$ref'";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where id = '$ref'";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function getSitee($uid) {
+ $q = "SELECT id from " . TB_PREFIX . "users where sit1 = $uid or sit2 = $uid";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getVilWref($x, $y) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata where x = $x AND y = $y";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['id'];
+ }
+
+ function caststruc($user) {
+ //loop search village user
+ $query = mysql_query("SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user."");
+ while($villaggi_array = mysql_fetch_array($query))
+
+ //loop structure village
+ $query1 = mysql_query("SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref']."");
+ $strutture= mysql_fetch_array($query1);
+ return $strutture;
+ }
+
+ function removeMeSit($uid, $uid2) {
+ $q = "UPDATE " . TB_PREFIX . "users set sit1 = 0 where id = $uid and sit1 = $uid2";
+ mysql_query($q, $this->connection);
+ $q2 = "UPDATE " . TB_PREFIX . "users set sit2 = 0 where id = $uid and sit2 = $uid2";
+ mysql_query($q2, $this->connection);
+ }
+
+ function getUserField($ref, $field, $mode) {
+ if(!$mode) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "users where id = '$ref'";
+ } else {
+ $q = "SELECT $field FROM " . TB_PREFIX . "users where username = '$ref'";
+ }
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray[$field];
+ }
+
+ function getInvitedUser($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where invited = $uid order by regtime desc";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getVrefField($ref, $field){
+ $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = '$ref'";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray[$field];
+ }
+
+ function getVrefCapital($ref){
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner = '$ref' and capital = 1";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray;
+ }
+
+ function getStarvation(){
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where starv != 0 and owner != 3";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getActivateField($ref, $field, $mode) {
+ if(!$mode) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "activate where id = '$ref'";
+ } else {
+ $q = "SELECT $field FROM " . TB_PREFIX . "activate where username = '$ref'";
+ }
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray[$field];
+ }
+
+ function login($username, $password) {
+ $q = "SELECT password,sessid FROM " . TB_PREFIX . "users where username = '$username'";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ if($dbarray['password'] == md5($password)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function checkActivate($act) {
+ $q = "SELECT * FROM " . TB_PREFIX . "activate where act = '$act'";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+
+ return $dbarray;
+ }
+
+ function sitterLogin($username, $password) {
+ $q = "SELECT sit1,sit2 FROM " . TB_PREFIX . "users where username = '$username' and access != " . BANNED;
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ if($dbarray['sit1'] != 0) {
+ $q2 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit1'] . " and access != " . BANNED;
+ $result2 = mysql_query($q2, $this->connection);
+ $dbarray2 = mysql_fetch_array($result2);
+ }
+ if($dbarray['sit2'] != 0) {
+ $q3 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit2'] . " and access != " . BANNED;
+ $result3 = mysql_query($q3, $this->connection);
+ $dbarray3 = mysql_fetch_array($result3);
+ }
+ if($dbarray['sit1'] != 0 || $dbarray['sit2'] != 0) {
+ if($dbarray2['password'] == md5($password) || $dbarray3['password'] == md5($password)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ function setDeleting($uid, $mode) {
+ $time = time() + 72 * 3600;
+ if(!$mode) {
+ $q = "INSERT into " . TB_PREFIX . "deleting values ($uid,$time)";
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "deleting where uid = $uid";
+ }
+ mysql_query($q, $this->connection);
+ }
+
+ function isDeleting($uid) {
+ $q = "SELECT timestamp from " . TB_PREFIX . "deleting where uid = $uid";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['timestamp'];
+ }
+
+ function modifyGold($userid, $amt, $mode) {
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "users set gold = gold - $amt where id = $userid";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "users set gold = gold + $amt where id = $userid";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ /*****************************************
+ Function to retrieve user array via Username or ID
+ Mode 0: Search by Username
+ Mode 1: Search by ID
+ References: Alliance ID
+ *****************************************/
+
+ function getUserArray($ref, $mode) {
+ if(!$mode) {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where username = '$ref'";
+ } else {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where id = $ref";
+ }
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function activeModify($username, $mode) {
+ $time = time();
+ if(!$mode) {
+ $q = "INSERT into " . TB_PREFIX . "active VALUES ('$username',$time)";
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "active where username = '$username'";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function addActiveUser($username, $time) {
+ $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)";
+ if(mysql_query($q, $this->connection)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function updateActiveUser($username, $time) {
+ $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)";
+ $q2 = "UPDATE " . TB_PREFIX . "users set timestamp = $time where username = '$username'";
+ $exec1 = mysql_query($q, $this->connection);
+ $exec2 = mysql_query($q2, $this->connection);
+ if($exec1 && $exec2) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function checkactiveSession($username, $sessid) {
+ $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$username' and sessid = '$sessid' LIMIT 1";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result) != 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function submitProfile($uid, $gender, $location, $birthday, $des1, $des2) {
+ $q = "UPDATE " . TB_PREFIX . "users set gender = $gender, location = '$location', birthday = '$birthday', desc1 = '$des1', desc2 = '$des2' where id = $uid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function gpack($uid, $gpack) {
+ $q = "UPDATE " . TB_PREFIX . "users set gpack = '$gpack' where id = $uid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function GetOnline($uid) {
+ $q = "SELECT sit FROM " . TB_PREFIX . "online where uid = $uid";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['sit'];
+ }
+
+ function UpdateOnline($mode, $name = "", $time = "", $uid = 0) {
+ global $session;
+ if($mode == "login") {
+ $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 0)";
+ return mysql_query($q, $this->connection);
+ } else if($mode == "sitter") {
+ $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 1)";
+ return mysql_query($q, $this->connection);
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "online WHERE name ='" . addslashes($session->username) . "'";
+ return mysql_query($q, $this->connection);
+ }
+ }
+
+ function generateBase($sector) {
+ switch($sector) {
+ case 1:
+ $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x < 0 and y > 0 and occupied = 0";
+ break;
+ case 2:
+ $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x > 0 and y > 0 and occupied = 0";
+ break;
+ case 3:
+ $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x < 0 and y < 0 and occupied = 0";
+ break;
+ case 4:
+ $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x > 0 and y < 0 and occupied = 0";
+ break;
+ }
+ $result = mysql_query($q, $this->connection);
+ $num_rows = mysql_num_rows($result);
+ $result = $this->mysql_fetch_all($result);
+ $base = rand(0, ($num_rows-1));
+ return $result[$base]['id'];
+ }
+
+ function setFieldTaken($id) {
+ $q = "UPDATE " . TB_PREFIX . "wdata set occupied = 1 where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function addVillage($wid, $uid, $username, $capital) {
+ $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 mysql_query($q, $this->connection) or die(mysql_error());
+ }
+
+ function addResourceFields($vid, $type) {
+ switch($type) {
+ case 1:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,4,4,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 2:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 3:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 4:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 5:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 6:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,3,4,4,4,4,4,4,4,4,4,4,4,2,4,4,1,15)";
+ break;
+ case 7:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 8:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 9:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 10:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 11:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,1,1,3,1,4,4,3,3,2,2,3,1,4,4,2,4,4,1,15)";
+ break;
+ case 12:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ }
+ return mysql_query($q, $this->connection);
+ }
+ function isVillageOases($wref) {
+ $q = "SELECT id, oasistype FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['oasistype'];
+ }
+
+ public function VillageOasisCount($vref) {
+ $q = "SELECT count(*) FROM `".TB_PREFIX."odata` WHERE conqured=$vref";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ return $row[0];
+ }
+
+ public function countOasisTroops($vref){
+ //count oasis troops: $troops_o
+ $troops_o=0;
+ $o_unit2=mysql_query("select * from ".TB_PREFIX."units where `vref`='".$vref."'");
+ $o_unit=mysql_fetch_array($o_unit2);
+
+ for ($i=1;$i<51;$i++)
+ {
+ $troops_o+=$o_unit[$i];
+ }
+ $troops_o+=$o_unit['hero'];
+
+ $o_unit2=mysql_query("select * from ".TB_PREFIX."enforcement where `vref`='".$vref."'");
+ while ($o_unit=@mysql_fetch_array($o_unit2))
+ {
+ for ($i=1;$i<51;$i++)
+ {
+ $troops_o+=$o_unit[$i];
+ }
+ $troops_o+=$o_unit['hero'];
+ }
+ return $troops_o;
+ }
+
+ public function canConquerOasis($vref,$wref) {
+ $AttackerFields = $this->getResourceLevel($vref);
+ for($i=19;$i<=38;$i++) {
+ if($AttackerFields['f'.$i.'t'] == 37) { $HeroMansionLevel = $AttackerFields['f'.$i]; }
+ }
+ if($this->VillageOasisCount($vref) < floor(($HeroMansionLevel-5)/5)) {
+ $OasisInfo = $this->getOasisInfo($wref);
+ $troopcount = $this->countOasisTroops($wref);
+ if($OasisInfo['conqured'] == 0 || $OasisInfo['conqured'] != 0 && $OasisInfo['loyalty'] < 99 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured']))) && $troopcount == 0) {
+ $CoordsVillage = $this->getCoor($vref);
+ $CoordsOasis = $this->getCoor($wref);
+ if(abs($CoordsOasis['x']-$CoordsVillage['x'])<=3 && abs($CoordsOasis['y']-$CoordsVillage['y'])<=3) {
+ return True;
+ } else {
+ return False;
+ }
+ } else {
+ return False;
+ }
+ } else {
+ return False;
+ }
+ }
+
+
+
+ public function conquerOasis($vref,$wref) {
+ $vinfo = $this->getVillage($vref);
+ $uid = $vinfo['owner'];
+ $q = "UPDATE `".TB_PREFIX."odata` SET conqured=$vref,loyalty=100,lastupdated=".time().",owner=$uid,name='Occupied Oasis' WHERE wref=$wref";
+ return mysql_query($q, $this->connection);
+ }
+
+ public function modifyOasisLoyalty($wref) {
+ if($this->isVillageOases($wref) != 0) {
+ $OasisInfo = $this->getOasisInfo($wref);
+ if($OasisInfo['conqured'] != 0) {
+ $LoyaltyAmendment = floor(100 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured']))));
+ $q = "UPDATE `".TB_PREFIX."odata` SET loyalty=loyalty-$LoyaltyAmendment WHERE wref=$wref";
+ return mysql_query($q, $this->connection);
+ }
+ }
+ }
+
+ function populateOasis() {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0";
+ $result = mysql_query($q, $this->connection);
+ while($row = mysql_fetch_array($result)) {
+ $wid = $row['id'];
+
+ $this->addUnits($wid);
+
+ }
+ }
+
+ function populateOasisUnits($wid, $high) {
+ $basearray = $this->getMInfo($wid);
+ $basearray = $this->getOasisInfo($wid);
+ if($basearray2['high'] == 0){
+ $max = rand(15,30);
+ }elseif($basearray2['high'] == 1){
+ $max = rand(70,90);
+ }elseif($basearray2['high'] == 2){
+ $max = rand(100,140);
+ }
+ //each Troop is a Set for oasis type like mountains have rats spiders and snakes fields tigers elphants clay wolves so on stonger one more not so less
+ switch($basearray['oasistype']) {
+ case 1:
+ case 2:
+ //+25% lumber per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max.")";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 3:
+ //+25% lumber and +25% crop per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 4:
+ case 5:
+ //+25% clay per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max.")";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 6:
+ //+25% clay and +25% crop per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 7:
+ case 8:
+ //+25% iron per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max.")";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 9:
+ //+25% iron and +25% crop
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 10:
+ case 11:
+ //+25% crop per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 12:
+ //+50% crop per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
+ $result = mysql_query($q, $this->connection);
+ break;
+ }
+ }
+
+ function populateOasisUnits2() {
+ $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0";
+ $result2 = mysql_query($q2, $this->connection);
+ while($row = mysql_fetch_array($result2)) {
+ $wid = $row['id'];
+ switch($row['oasistype']) {
+ case 1:
+ case 2:
+ //+25% lumber oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,10)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <= '10'";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 3:
+ //+25% lumber and +25% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,15)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <='10'";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 4:
+ case 5:
+ //+25% clay oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <= '10'";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 6:
+ //+25% clay and +25% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <='10'";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 7:
+ case 8:
+ //+25% iron oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <= '10'";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 9:
+ //+25% iron and +25% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <='10'";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 10:
+ case 11:
+ //+25% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(5,15)."', u33 = u33 + '".rand(5,10)."', u37 = u37 + '".rand(0,10)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u37 <='10' AND u39 <='10'";
+ $result = mysql_query($q, $this->connection);
+ break;
+ case 12:
+ //+50% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u33 = u33 + '".rand(5,10)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u38 <='10'AND u39 <='10'";
+ $result = mysql_query($q, $this->connection);
+ break;
+ }
+ }
+ }
+
+ function removeOases($wref) {
+ $q = "UPDATE ".TB_PREFIX."odata SET conqured = 0, owner = 2, name = 'Unoccupied Oasis' WHERE wref = $wref";
+ return mysql_query($q, $this->connection);
+ }
+
+
+ /***************************
+ Function to retrieve type of village via ID
+ References: Village ID
+ ***************************/
+ function getVillageType($wref) {
+ $q = "SELECT id, fieldtype FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['fieldtype'];
+ }
+
+
+
+ /*****************************************
+ Function to retrieve if is ocuped via ID
+ References: Village ID
+ *****************************************/
+ function getVillageState($wref) {
+ $q = "SELECT oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ if($dbarray['occupied'] != 0 || $dbarray['oasistype'] != 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function getProfileVillages($uid) {
+ $q = "SELECT capital,wref,name,pop,created from " . TB_PREFIX . "vdata where owner = $uid order by pop desc";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getProfileMedal($uid) {
+ $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "medal where userid = $uid and del = 0 order by id desc";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+
+ }
+
+ function getProfileMedalAlly($uid) {
+ $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "allimedal where allyid = $uid and del = 0 order by id desc";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+
+ }
+
+ function getVillageID($uid) {
+ $q = "SELECT wref FROM " . TB_PREFIX . "vdata WHERE owner = $uid";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['wref'];
+ }
+
+
+ function getVillagesID($uid) {
+ $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC";
+ $result = mysql_query($q, $this->connection);
+ $array = $this->mysql_fetch_all($result);
+ $newarray = array();
+ for($i = 0; $i < count($array); $i++) {
+ array_push($newarray, $array[$i]['wref']);
+ }
+ return $newarray;
+ }
+
+ function getVillagesID2($uid) {
+ $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC";
+ $result = mysql_query($q, $this->connection);
+ $array = $this->mysql_fetch_all($result);
+ return $array;
+ }
+
+ function getVillage($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ public function getVillageBattleData($vid) {
+ $q = "SELECT u.id,u.tribe,v.capital,f.f40 AS wall FROM ".TB_PREFIX."users u,".TB_PREFIX."fdata f,".TB_PREFIX."vdata v WHERE u.id=v.owner AND f.vref=v.wref AND v.wref=".$vid;
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ public function getPopulation($uid) {
+ $q = "SELECT sum(pop) AS pop FROM ".TB_PREFIX."vdata WHERE owner=".$uid;
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['pop'];
+ }
+
+ function getOasisV($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function getMInfo($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "vdata ON " . TB_PREFIX . "vdata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function getOMInfo($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "odata ON " . TB_PREFIX . "odata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function getOasis($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = $vid";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getOasisInfo($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $wid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ function getVillageField($ref, $field) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray[$field];
+
+ }
+
+ function getOasisField($ref, $field) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "odata where wref = $ref";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray[$field];
+ }
+
+ function setVillageField($ref, $field, $value) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set $field = '$value' where wref = $ref";
+ return mysql_query($q, $this->connection);
+ }
+
+ function setVillageLevel($ref, $field, $value) {
+ $q = "UPDATE " . TB_PREFIX . "fdata set " . $field . " = '" . $value . "' where vref = " . $ref . "";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getResourceLevel($vid) {
+ $q = "SELECT * from " . TB_PREFIX . "fdata where vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ function getAdminLog() {
+ $q = "SELECT id,user,log,time from " . TB_PREFIX . "admin_log where id != 0 ORDER BY id ASC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getCoor($wref) {
+ if ($wref !=""){
+ $q = "SELECT x,y FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+ }
+
+ function CheckForum($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id'";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function CountCat($id) {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where cat = '$id'";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ return $row[0];
+ }
+
+ function LastTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' order by post_date";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function CheckLastTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function CheckLastPost($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function LastPost($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function CountTopic($id) {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where owner = '$id'";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+
+ $qs = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where owner = '$id'";
+ $results = mysql_query($qs, $this->connection);
+ $rows = mysql_fetch_row($results);
+ return $row[0] + $rows[0];
+ }
+
+ function CountPost($id) {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where topic = '$id'";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ return $row[0];
+ }
+
+ function ForumCat($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id' ORDER BY id";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function ForumCatEdit($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_cat where id = '$id'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function ForumCatAlliance($id) {
+ $q = "SELECT alliance from " . TB_PREFIX . "forum_cat where id = $id";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['alliance'];
+ }
+
+ function ForumCatName($id) {
+ $q = "SELECT forum_name from " . TB_PREFIX . "forum_cat where id = $id";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['forum_name'];
+ }
+
+ function CheckCatTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function CheckResultEdit($alli) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_edit where alliance = '$alli'";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function CheckCloseTopic($id) {
+ $q = "SELECT close from " . TB_PREFIX . "forum_topic where id = '$id'";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['close'];
+ }
+
+ function CheckEditRes($alli) {
+ $q = "SELECT result from " . TB_PREFIX . "forum_edit where alliance = '$alli'";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['result'];
+ }
+
+ function CreatResultEdit($alli, $result) {
+ $q = "INSERT into " . TB_PREFIX . "forum_edit values (0,'$alli','$result')";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ function UpdateResultEdit($alli, $result) {
+ $date = time();
+ $q = "UPDATE " . TB_PREFIX . "forum_edit set result = '$result' where alliance = '$alli'";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getVillageType2($wref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['oasistype'];
+ }
+
+ function getVillageType3($wref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray;
+ }
+
+ function getFLData($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "farmlist where id = $id";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function checkVilExist($wref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = '$wref'";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function checkOasisExist($wref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = '$wref'";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function UpdateEditTopic($id, $title, $cat) {
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set title = '$title', cat = '$cat' where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function UpdateEditForum($id, $name, $des) {
+ $q = "UPDATE " . TB_PREFIX . "forum_cat set forum_name = '$name', forum_des = '$des' where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function StickTopic($id, $mode) {
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set stick = '$mode' where id = '$id'";
+ return mysql_query($q, $this->connection);
+ }
+
+ function ForumCatTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '' ORDER BY post_date desc";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function ForumCatTopicStick($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '1' ORDER BY post_date desc";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function ShowTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where id = '$id'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function ShowPost($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function ShowPostEdit($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_post where id = '$id'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function CreatForum($owner, $alli, $name, $des, $area) {
+ $q = "INSERT into " . TB_PREFIX . "forum_cat values (0,'$owner','$alli','$name','$des','$area')";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ function CreatTopic($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) {
+ $date = time();
+ $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','','$alliance','$player','$coor','$report')";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) {
+ $date = time();
+ $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ function UpdatePostDate($id) {
+ $date = time();
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set post_date = '$date' where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function EditUpdateTopic($id, $post, $alliance, $player, $coor, $report) {
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function EditUpdatePost($id, $post, $alliance, $player, $coor, $report) {
+ $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function LockTopic($id, $mode) {
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set close = '$mode' where id = '$id'";
+ return mysql_query($q, $this->connection);
+ }
+
+ function DeleteCat($id) {
+ $qs = "DELETE from " . TB_PREFIX . "forum_cat where id = '$id'";
+ $q = "DELETE from " . TB_PREFIX . "forum_topic where cat = '$id'";
+ mysql_query($qs, $this->connection);
+ return mysql_query($q, $this->connection);
+ }
+
+ function DeleteTopic($id) {
+ $qs = "DELETE from " . TB_PREFIX . "forum_topic where id = '$id'";
+ // $q = "DELETE from ".TB_PREFIX."forum_post where topic = '$id'";//
+ return mysql_query($qs, $this->connection); //
+ // mysql_query($q,$this->connection);
+ }
+
+ function DeletePost($id) {
+ $q = "DELETE from " . TB_PREFIX . "forum_post where id = '$id'";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getAllianceName($id) {
+ $q = "SELECT tag from " . TB_PREFIX . "alidata where id = $id";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['tag'];
+ }
+
+ function getAlliancePermission($ref, $field, $mode) {
+ if(!$mode) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where uid = '$ref'";
+ } else {
+ $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where username = '$ref'";
+ }
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray[$field];
+ }
+
+ function getAlliance($id) {
+ $q = "SELECT * from " . TB_PREFIX . "alidata where id = $id";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ function setAlliName($aid, $name, $tag) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set name = '$name', tag = '$tag' where id = $aid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function isAllianceOwner($id) {
+ $q = "SELECT * from " . TB_PREFIX . "alidata where leader = '$id'";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function aExist($ref, $type) {
+ $q = "SELECT $type FROM " . TB_PREFIX . "alidata where $type = '$ref'";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function modifyPoints($aid, $points, $amt) {
+ $q = "UPDATE " . TB_PREFIX . "users set $points = $points + $amt where id = $aid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function modifyPointsAlly($aid, $points, $amt) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set $points = $points + $amt where id = $aid";
+ return mysql_query($q, $this->connection);
+ }
+
+ /*****************************************
+ Function to create an alliance
+ References:
+ *****************************************/
+ function createAlliance($tag, $name, $uid, $max) {
+ $q = "INSERT into " . TB_PREFIX . "alidata values (0,'$name','$tag',$uid,0,0,0,'','',$max,'','','','','','','','','')";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ function procAllyPop($aid) {
+ $ally = $this->getAlliance($aid);
+ $memberlist = $this->getAllMember($ally['id']);
+ $oldrank = 0;
+ foreach($memberlist as $member) {
+ $oldrank += $this->getVSumField($member['id'],"pop");
+ }
+ if($ally['oldrank'] != $oldrank){
+ if($ally['oldrank'] < $oldrank) {
+ $totalpoints = $oldrank - $ally['oldrank'];
+ $this->addclimberrankpopAlly($ally['id'], $totalpoints);
+ $this->updateoldrankAlly($ally['id'], $oldrank);
+ } else
+ if($ally['oldrank'] > $oldrank) {
+ $totalpoints = $ally['oldrank'] - $oldrank;
+ $this->removeclimberrankpopAlly($ally['id'], $totalpoints);
+ $this->updateoldrankAlly($ally['id'], $oldrank);
+ }
+ }
+ }
+
+ /*****************************************
+ Function to insert an alliance new
+ References:
+ *****************************************/
+ function insertAlliNotice($aid, $notice) {
+ $time = time();
+ $q = "INSERT into " . TB_PREFIX . "ali_log values (0,'$aid','$notice',$time)";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ /*****************************************
+ Function to delete alliance if empty
+ References:
+ *****************************************/
+ function deleteAlliance($aid) {
+ $result = mysql_query("SELECT * FROM " . TB_PREFIX . "users where alliance = $aid");
+ $num_rows = mysql_num_rows($result);
+ if($num_rows == 0) {
+ $q = "DELETE FROM " . TB_PREFIX . "alidata WHERE id = $aid";
+ }
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ /*****************************************
+ Function to read all alliance news
+ References:
+ *****************************************/
+ function readAlliNotice($aid) {
+ $q = "SELECT * from " . TB_PREFIX . "ali_log where aid = $aid ORDER BY date DESC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ /*****************************************
+ Function to create alliance permissions
+ References: ID, notice, description
+ *****************************************/
+ function createAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8) {
+
+ $q = "INSERT into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ /*****************************************
+ Function to update alliance permissions
+ References:
+ *****************************************/
+ function deleteAlliPermissions($uid) {
+ $q = "DELETE from " . TB_PREFIX . "ali_permission where uid = '$uid'";
+ return mysql_query($q, $this->connection);
+ }
+ /*****************************************
+ Function to update alliance permissions
+ References:
+ *****************************************/
+ function updateAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7) {
+
+ $q = "UPDATE " . TB_PREFIX . "ali_permission SET rank = '$rank', opt1 = '$opt1', opt2 = '$opt2', opt3 = '$opt3', opt4 = '$opt4', opt5 = '$opt5', opt6 = '$opt6', opt7 = '$opt7' where uid = $uid && alliance =$aid";
+ return mysql_query($q, $this->connection);
+ }
+
+ /*****************************************
+ Function to read alliance permissions
+ References: ID, notice, description
+ *****************************************/
+ function getAlliPermissions($uid, $aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ali_permission where uid = $uid && alliance = $aid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ /*****************************************
+ Function to update an alliance description and notice
+ References: ID, notice, description
+ *****************************************/
+ function submitAlliProfile($aid, $notice, $desc) {
+
+ $q = "UPDATE " . TB_PREFIX . "alidata SET `notice` = '$notice', `desc` = '$desc' where id = $aid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function diplomacyInviteAdd($alli1, $alli2, $type) {
+ $q = "INSERT INTO " . TB_PREFIX . "diplomacy (alli1,alli2,type,accepted) VALUES ($alli1,$alli2," . (int)intval($type) . ",0)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function diplomacyOwnOffers($session_alliance) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getAllianceID($name) {
+ $q = "SELECT id FROM " . TB_PREFIX . "alidata WHERE tag ='" . $this->RemoveXSS($name) . "'";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['id'];
+ }
+
+ function getDiplomacy($aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE id = $aid";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function diplomacyCancelOffer($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function diplomacyInviteAccept($id, $session_alliance) {
+ $q = "UPDATE " . TB_PREFIX . "diplomacy SET accepted = 1 WHERE id = $id AND alli2 = $session_alliance";
+ return mysql_query($q, $this->connection);
+ }
+
+ function diplomacyInviteDenied($id, $session_alliance) {
+ $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance";
+ return mysql_query($q, $this->connection);
+ }
+
+ function diplomacyInviteCheck($session_alliance) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function diplomacyInviteCheck2($ally1, $ally2) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $ally1 AND alli2 = $ally2 accepted = 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getAllianceDipProfile($aid, $type){
+ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '$type' AND accepted = '1' OR alli2 = '$aid' AND type = '$type' AND accepted = '1'";
+ $array = $this->query_return($q);
+ foreach($array as $row){
+ if($row['alli1'] == $aid){
+ $alliance = $this->getAlliance($row['alli2']);
+ }elseif($row['alli2'] == $aid){
+ $alliance = $this->getAlliance($row['alli1']);
+ }
+ $text .= "";
+ $text .= "".$alliance['tag']."
";
+ }
+ if(strlen($text) == 0){
+ $text = "-
";
+ }
+ return $text;
+ }
+
+ function getAllianceWar($aid){
+ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'";
+ $array = $this->query_return($q);
+ foreach($array as $row){
+ if($row['alli1'] == $aid){
+ $alliance = $this->getAlliance($row['alli2']);
+ }elseif($row['alli2'] == $aid){
+ $alliance = $this->getAlliance($row['alli1']);
+ }
+ $text .= "";
+ $text .= "".$alliance['tag']."
";
+ }
+ if(strlen($text) == 0){
+ $text = "-
";
+ }
+ return $text;
+ }
+
+ function getAllianceAlly($aid, $type){
+ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE (alli1 = '$aid' or alli2 = '$aid') AND (type = '$type' AND accepted = '1')";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getAllianceWar2($aid){
+ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function diplomacyExistingRelationships($session_alliance) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 1";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function diplomacyExistingRelationships2($session_alliance) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 1";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function diplomacyCancelExistingRelationship($id, $session_alliance) {
+ $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance OR id = $id AND alli1 = $session_alliance";
+ return mysql_query($q, $this->connection);
+ }
+
+ function checkDiplomacyInviteAccept($aid, $type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $aid AND type = $type AND accepted = 1 OR alli2 = $aid AND type = $type AND accepted = 1";
+ $result = mysql_query($q, $this->connection);
+ if($type == 3){
+ return true;
+ }else{
+ if(mysql_num_rows($result) < 4) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ function setAlliForumLink($aid, $link) {
+ $q = "UPDATE " . TB_PREFIX . "alidata SET `forumlink` = '$link' WHERE id = $aid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getUserAlliance($id) {
+ $q = "SELECT " . TB_PREFIX . "alidata.tag from " . TB_PREFIX . "users join " . TB_PREFIX . "alidata where " . TB_PREFIX . "users.alliance = " . TB_PREFIX . "alidata.id and " . TB_PREFIX . "users.id = $id";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ if($dbarray['tag'] == "") {
+ return "-";
+ } else {
+ return $dbarray['tag'];
+ }
+ }
+
+ function modifyResource($vid, $wood, $clay, $iron, $crop, $mode) {
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set wood = wood - $wood, clay = clay - $clay, iron = iron - $iron, crop = crop - $crop where wref = $vid";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "vdata set wood = wood + $wood, clay = clay + $clay, iron = iron + $iron, crop = crop + $crop where wref = $vid";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function modifyOasisResource($vid, $wood, $clay, $iron, $crop, $mode) {
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "odata set wood = wood - $wood, clay = clay - $clay, iron = iron - $iron, crop = crop - $crop where wref = $vid";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "odata set wood = wood + $wood, clay = clay + $clay, iron = iron + $iron, crop = crop + $crop where wref = $vid";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function getFieldLevel($vid, $field) {
+ $q = "SELECT f" . $field . " from " . TB_PREFIX . "fdata where vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_result($result, 0);
+ }
+
+ function getFieldType($vid, $field) {
+ $q = "SELECT f" . $field . "t from " . TB_PREFIX . "fdata where vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_result($result, 0);
+ }
+
+ function getVSumField($uid, $field) {
+ if($field != "cp"){
+ $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid";
+ }else{
+ $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid and natar = 0";
+ }
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ return $row[0];
+ }
+
+ function updateVillage($vid) {
+ $time = time();
+ $q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid";
+ return mysql_query($q, $this->connection);
+ }
+ function updateOasis($vid) {
+ $time = time();
+ $q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid";
+ return mysql_query($q, $this->connection);
+ }
+
+
+ function setVillageName($vid, $name) {
+ if(!empty($name))
+ {
+ $q = "UPDATE " . TB_PREFIX . "vdata set name = '$name' where wref = $vid";
+ return mysql_query($q, $this->connection);
+ }
+ }
+
+ function modifyPop($vid, $pop, $mode) {
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop + $pop where wref = $vid";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop - $pop where wref = $vid";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function addCP($ref, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set cp = cp + $cp where wref = $ref";
+ return mysql_query($q, $this->connection);
+ }
+
+ function addCel($ref, $cel, $type) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set celebration = $cel, type= $type where wref = $ref";
+ return mysql_query($q, $this->connection);
+ }
+ function getCel() {
+ $time = time();
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where celebration < $time AND celebration != 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function clearCel($ref) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set celebration = 0, type = 0 where wref = $ref";
+ return mysql_query($q, $this->connection);
+ }
+ function setCelCp($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set cp = cp + $cp where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+
+ function clearExpansionSlot($id) {
+ for($i = 1; $i <= 3; $i++) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET exp" . $i . "=0 WHERE exp" . $i . "=" . $id;
+ mysql_query($q, $this->connection);
+ }
+ }
+
+ function getInvitation($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getInvitation2($uid, $aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid and alliance = $aid";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getAliInvitations($aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where alliance = $aid && accept = 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function sendInvitation($uid, $alli, $sender) {
+ $time = time();
+ $q = "INSERT INTO " . TB_PREFIX . "ali_invite values (0,$uid,$alli,$sender,$time,0)";
+ return mysql_query($q, $this->connection) or die(mysql_error());
+ }
+
+ function removeInvitation($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "ali_invite where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function sendMessage($client, $owner, $topic, $message, $send, $alliance, $player, $coor, $report) {
+ $time = time();
+ $q = "INSERT INTO " . TB_PREFIX . "mdata values (0,$client,$owner,'$topic',\"$message\",0,0,$send,$time,0,0,$alliance,$player,$coor,$report)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function setArchived($id) {
+ $q = "UPDATE " . TB_PREFIX . "mdata set archived = 1 where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function setNorm($id) {
+ $q = "UPDATE " . TB_PREFIX . "mdata set archived = 0 where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ /***************************
+ Function to get messages
+ Mode 1: Get inbox
+ Mode 2: Get sent
+ Mode 3: Get message
+ Mode 4: Set viewed
+ Mode 5: Remove message
+ Mode 6: Retrieve archive
+ References: User ID/Message ID, Mode
+ ***************************/
+ function getMessage($id, $mode) {
+ global $session;
+ switch($mode) {
+ case 1:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 ORDER BY time DESC";
+ break;
+ case 2:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id ORDER BY time DESC";
+ break;
+ case 3:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata where id = $id";
+ break;
+ case 4:
+ $q = "UPDATE " . TB_PREFIX . "mdata set viewed = 1 where id = $id AND target = $session->uid";
+ break;
+ case 5:
+ $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,viewed = 1 where id = $id";
+ break;
+ case 6:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1";
+ break;
+ case 7:
+ $q = "UPDATE " . TB_PREFIX . "mdata set delowner = 1 where id = $id";
+ break;
+ case 8:
+ $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,delowner = 1,viewed = 1 where id = $id";
+ break;
+ case 9:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 and deltarget = 0 ORDER BY time DESC";
+ break;
+ case 10:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id and delowner = 0 ORDER BY time DESC";
+ break;
+ case 11:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1 and deltarget = 0";
+ break;
+ }
+ if($mode <= 3 || $mode == 6 || $mode > 8) {
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ } else {
+ return mysql_query($q, $this->connection);
+ }
+ }
+
+ function getDelSent($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $uid and delowner = 1 ORDER BY time DESC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getDelInbox($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and deltarget = 1 ORDER BY time DESC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getDelArchive($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and archived = 1 and deltarget = 1 OR owner = $uid and archived = 1 and delowner = 1 ORDER BY time DESC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function unarchiveNotice($id) {
+ $q = "UPDATE " . TB_PREFIX . "ndata set ntype = archive, archive = 0 where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function archiveNotice($id) {
+ $q = "update " . TB_PREFIX . "ndata set archive = ntype, ntype = 9 where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function removeNotice($id) {
+ $q = "UPDATE " . TB_PREFIX . "ndata set del = 1,viewed = 1 where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function noticeViewed($id) {
+ $q = "UPDATE " . TB_PREFIX . "ndata set viewed = 1 where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function addNotice($uid, $wref, $aid, $type, $topic, $data, $time = 0) {
+ if($time == 0) {
+ $time = time();
+ }
+ $q = "INSERT INTO " . TB_PREFIX . "ndata (id, uid, toWref, ally, topic, ntype, data, time, viewed) values (0,'$uid','$wref','$aid','$topic',$type,'$data',$time,0)";
+ return mysql_query($q, $this->connection) or die(mysql_error());
+ }
+
+ function getNotice($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 0 ORDER BY time DESC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getNotice2($id, $field) {
+ $q = "SELECT ".$field." FROM " . TB_PREFIX . "ndata where `id` = '$id'";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray[$field];
+ }
+
+ function getNotice3($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time DESC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getNotice4($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ndata where id = $id ORDER BY time DESC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function createTradeRoute($uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time) {
+ $x = "UPDATE " . TB_PREFIX . "users SET gold = gold - 2 WHERE id = ".$uid."";
+ mysql_query($x, $this->connection);
+ $timeleft = time()+604800;
+ $q = "INSERT into " . TB_PREFIX . "route values (0,$uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time,$timeleft)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getTradeRoute($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "route where uid = $uid ORDER BY timestamp ASC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getTradeRoute2($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray;
+ }
+
+ function getTradeRouteUid($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['uid'];
+ }
+
+ function editTradeRoute($id,$column,$value,$mode) {
+ if(!$mode){
+ $q = "UPDATE " . TB_PREFIX . "route set $column = $value where id = $id";
+ }else{
+ $q = "UPDATE " . TB_PREFIX . "route set $column = $column + $value where id = $id";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function deleteTradeRoute($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "route where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function addBuilding($wid, $field, $type, $loop, $time, $master, $level) {
+ $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $field . "t=" . $type . " WHERE vref=" . $wid;
+ mysql_query($x, $this->connection) or die(mysql_error());
+ $q = "INSERT into " . TB_PREFIX . "bdata values (0,$wid,$field,$type,$loop,$time,$master,$level)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function removeBuilding($d) {
+ global $building;
+ $jobLoopconID = -1;
+ $SameBuildCount = 0;
+ $jobs = $building->buildArray;
+ for($i = 0; $i < sizeof($jobs); $i++) {
+ if($jobs[$i]['id'] == $d) {
+ $jobDeleted = $i;
+ }
+ if($jobs[$i]['loopcon'] == 1) {
+ $jobLoopconID = $i;
+ }
+ if($jobs[$i]['master'] == 1) {
+ $jobMaster = $i;
+ }
+ }
+ if(count($jobs) > 1 && ($jobs[0]['field'] == $jobs[1]['field'])) {
+ $SameBuildCount = 1;
+ }
+ if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[2]['field'])) {
+ $SameBuildCount = 2;
+ }
+ if(count($jobs) > 2 && ($jobs[1]['field'] == $jobs[2]['field'])) {
+ $SameBuildCount = 3;
+ }
+ if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 8;
+ }
+ if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 9;
+ }
+ if(count($jobs) > 3 && ($jobs[2]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 10;
+ }
+ if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[2]['field'])) {
+ $SameBuildCount = 4;
+ }
+ if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 5;
+ }
+ if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 6;
+ }
+ if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 7;
+ }
+ if($SameBuildCount > 0) {
+ if($SameBuildCount > 3){
+ if($SameBuildCount == 4 or $SameBuildCount == 5){
+ if($jobDeleted == 0){
+ $uprequire = $building->resourceRequired($jobs[1]['field'],$jobs[1]['type'],1);
+ $time = $uprequire['time'];
+ $timestamp = $time+time();
+ $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[1]['id']."";
+ mysql_query($q, $this->connection);
+ }
+ }else if($SameBuildCount == 6){
+ if($jobDeleted == 0){
+ $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1);
+ $time = $uprequire['time'];
+ $timestamp = $time+time();
+ $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id']."";
+ mysql_query($q, $this->connection);
+ }
+ }else if($SameBuildCount == 7){
+ if($jobDeleted == 1){
+ $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1);
+ $time = $uprequire['time'];
+ $timestamp = $time+time();
+ $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id']."";
+ mysql_query($q, $this->connection);
+ }
+ }
+ if($SameBuildCount < 8){
+ $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],2);
+ $time1 = $uprequire1['time'];
+ $timestamp1 = $time1;
+ $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id']."";
+ mysql_query($q1, $this->connection);
+ }else{
+ $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],1);
+ $time1 = $uprequire1['time'];
+ $timestamp1 = $time1;
+ $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id']."";
+ mysql_query($q1, $this->connection);
+ }
+ }else if($d == $jobs[floor($SameBuildCount / 3)]['id'] || $d == $jobs[floor($SameBuildCount / 2) + 1]['id']) {
+ $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=" . $jobs[floor($SameBuildCount / 3)]['timestamp'] . " WHERE master = 0 AND id > ".$d." and (ID=" . $jobs[floor($SameBuildCount / 3)]['id'] . " OR ID=" . $jobs[floor($SameBuildCount / 2) + 1]['id'] . ")";
+ mysql_query($q, $this->connection);
+ }
+ } else {
+ if($jobs[$jobDeleted]['field'] >= 19) {
+ $x = "SELECT f" . $jobs[$jobDeleted]['field'] . " FROM " . TB_PREFIX . "fdata WHERE vref=" . $jobs[$jobDeleted]['wid'];
+ $result = mysql_query($x, $this->connection) or die(mysql_error());
+ $fieldlevel = mysql_fetch_row($result);
+ if($fieldlevel[0] == 0) {
+ $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $jobs[$jobDeleted]['field'] . "t=0 WHERE vref=" . $jobs[$jobDeleted]['wid'];
+ mysql_query($x, $this->connection) or die(mysql_error());
+ }
+ }
+ if(($jobLoopconID >= 0) && ($jobs[$jobDeleted]['loopcon'] != 1)) {
+ if(($jobs[$jobLoopconID]['field'] <= 18 && $jobs[$jobDeleted]['field'] <= 18) || ($jobs[$jobLoopconID]['field'] >= 19 && $jobs[$jobDeleted]['field'] >= 19) || sizeof($jobs) < 3) {
+ $uprequire = $building->resourceRequired($jobs[$jobLoopconID]['field'], $jobs[$jobLoopconID]['type']);
+ $x = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,timestamp=" . (time() + $uprequire['time']) . " WHERE wid=" . $jobs[$jobDeleted]['wid'] . " AND loopcon=1 AND master=0";
+ mysql_query($x, $this->connection) or die(mysql_error());
+ }
+ }
+ }
+ $q = "DELETE FROM " . TB_PREFIX . "bdata where id = $d";
+ return mysql_query($q, $this->connection);
+ }
+
+ function addDemolition($wid, $field) {
+ global $building, $village;
+ $q = "DELETE FROM ".TB_PREFIX."bdata WHERE field=$field AND wid=$wid";
+ mysql_query($q, $this->connection);
+ $uprequire = $building->resourceRequired($field,$village->resarray['f'.$field.'t'],0);
+ $q = "INSERT INTO ".TB_PREFIX."demolition VALUES (".$wid.",".$field.",".($this->getFieldLevel($wid,$field)-1).",".(time()+floor($uprequire['time']/2)).")";
+ return mysql_query($q, $this->connection);
+ }
+
+
+ function getDemolition($wid = 0) {
+ if($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid;
+ } else {
+ $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE timetofinish<=" . time();
+ }
+ $result = mysql_query($q, $this->connection);
+ if(!empty($result)) {
+ return $this->mysql_fetch_all($result);
+ } else {
+ return NULL;
+ }
+ }
+
+ function finishDemolition($wid) {
+ $q = "UPDATE " . TB_PREFIX . "demolition SET timetofinish=" . time() . " WHERE vref=" . $wid;
+ return mysql_query($q, $this->connection);
+ }
+
+ function delDemolition($wid) {
+ $q = "DELETE FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid;
+ return mysql_query($q, $this->connection);
+ }
+
+ function getJobs($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid order by master,timestamp ASC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function FinishWoodcutter($wid) {
+ $time = time()-1;
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = 1 order by master,timestamp ASC";
+ $result = mysql_query($q);
+ $dbarray = mysql_fetch_array($result);
+ $q = "UPDATE ".TB_PREFIX."bdata SET timestamp = $time WHERE id = '".$dbarray['id']."'";
+ $this->query($q);
+ $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 and field <= 18 order by master,timestamp ASC";
+ if(mysql_num_rows($q2) > 0){
+ $result2 = mysql_query($q2);
+ $dbarray2 = mysql_fetch_array($result2);
+ $wc_time = $dbarray['timestamp'];
+ $q2 = "UPDATE ".TB_PREFIX."bdata SET timestamp = timestamp - $wc_time WHERE id = '".$dbarray2['id']."'";
+ $this->query($q2);
+ }
+ }
+
+ function getMasterJobs($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and master = 1 order by master,timestamp ASC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getMasterJobsByField($wid,$field) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 1 order by master,timestamp ASC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getBuildingByField($wid,$field) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getBuildingByField2($wid,$field) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0";
+ $result = mysql_query($q, $this->connection);
+ return mysql_num_rows($result);
+ }
+
+ function getBuildingByType($wid,$type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getBuildingByType2($wid,$type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0";
+ $result = mysql_query($q, $this->connection);
+ return mysql_num_rows($result);
+ }
+
+ function getDorf1Building($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field < 19 and master = 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getDorf2Building($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field > 18 and master = 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function updateBuildingWithMaster($id, $time,$loop) {
+ $q = "UPDATE " . TB_PREFIX . "bdata SET master = 0, timestamp = ".$time.",loopcon = ".$loop." WHERE id = ".$id."";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getVillageByName($name) {
+ $q = "SELECT wref FROM " . TB_PREFIX . "vdata where name = '$name' limit 1";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['wref'];
+ }
+
+ /***************************
+ Function to set accept flag on market
+ References: id
+ ***************************/
+ function setMarketAcc($id) {
+ $q = "UPDATE " . TB_PREFIX . "market set accept = 1 where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ /***************************
+ Function to send resource to other village
+ Mode 0: Send
+ Mode 1: Cancel
+ References: Wood/ID, Clay, Iron, Crop, Mode
+ ***************************/
+ function sendResource($ref, $clay, $iron, $crop, $merchant, $mode) {
+ if(!$mode) {
+ $q = "INSERT INTO " . TB_PREFIX . "send values (0,$ref,$clay,$iron,$crop,$merchant)";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "send where id = $ref";
+ return mysql_query($q, $this->connection);
+ }
+ }
+
+ /***************************
+ Function to get resources back if you delete offer
+ References: VillageRef (vref)
+ Made by: Dzoki
+ ***************************/
+
+ function getResourcesBack($vref, $gtype, $gamt) {
+ //Xtype (1) = wood, (2) = clay, (3) = iron, (4) = crop
+ if($gtype == 1) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` + '$gamt' WHERE wref = $vref";
+ return mysql_query($q, $this->connection);
+ } else
+ if($gtype == 2) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` + '$gamt' WHERE wref = $vref";
+ return mysql_query($q, $this->connection);
+ } else
+ if($gtype == 3) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` + '$gamt' WHERE wref = $vref";
+ return mysql_query($q, $this->connection);
+ } else
+ if($gtype == 4) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` + '$gamt' WHERE wref = $vref";
+ return mysql_query($q, $this->connection);
+ }
+ }
+
+ /***************************
+ Function to get info about offered resources
+ References: VillageRef (vref)
+ Made by: Dzoki
+ ***************************/
+
+ function getMarketField($vref, $field) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "market where vref = '$vref'";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray[$field];
+ }
+
+ function removeAcceptedOffer($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "market where id = $id";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ /***************************
+ Function to add market offer
+ Mode 0: Add
+ Mode 1: Cancel
+ References: Village, Give, Amt, Want, Amt, Time, Alliance, Mode
+ ***************************/
+ function addMarket($vid, $gtype, $gamt, $wtype, $wamt, $time, $alliance, $merchant, $mode) {
+ if(!$mode) {
+ $q = "INSERT INTO " . TB_PREFIX . "market values (0,$vid,$gtype,$gamt,$wtype,$wamt,0,$time,$alliance,$merchant)";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "market where id = $gtype and vref = $vid";
+ return mysql_query($q, $this->connection);
+ }
+ }
+
+ /***************************
+ Function to get market offer
+ References: Village, Mode
+ ***************************/
+ function getMarket($vid, $mode) {
+ $alliance = $this->getUserField($this->getVillageField($vid, "owner"), "alliance", 0);
+ if(!$mode) {
+ $q = "SELECT * FROM " . TB_PREFIX . "market where vref = $vid and accept = 0";
+ } else {
+ $q = "SELECT * FROM " . TB_PREFIX . "market where vref != $vid and alliance = $alliance or vref != $vid and alliance = 0 and accept = 0";
+ }
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ /***************************
+ Function to get market offer
+ References: ID
+ ***************************/
+ function getMarketInfo($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "market where id = $id";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ function setMovementProc($moveid) {
+ $q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where moveid = $moveid";
+ return mysql_query($q, $this->connection);
+ }
+
+ /***************************
+ Function to retrieve used merchant
+ References: Village
+ ***************************/
+ function totalMerchantUsed($vid) {
+ $time = time();
+ $q = "SELECT sum(" . TB_PREFIX . "send.merchant) from " . TB_PREFIX . "send, " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.from = $vid and " . TB_PREFIX . "send.id = " . TB_PREFIX . "movement.ref and " . TB_PREFIX . "movement.proc = 0 and sort_type = 0";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ $q2 = "SELECT sum(ref) from " . TB_PREFIX . "movement where sort_type = 2 and " . TB_PREFIX . "movement.to = $vid and proc = 0";
+ $result2 = mysql_query($q2, $this->connection);
+ $row2 = mysql_fetch_row($result2);
+ $q3 = "SELECT sum(merchant) from " . TB_PREFIX . "market where vref = $vid and accept = 0";
+ $result3 = mysql_query($q3, $this->connection);
+ $row3 = mysql_fetch_row($result3);
+ return $row[0] + $row2[0] + $row3[0];
+ }
+
+ function getMovement($type, $village, $mode) {
+ $time = time();
+ if(!$mode) {
+ $where = "from";
+ } else {
+ $where = "to";
+ }
+ switch($type) {
+ case 0:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 0 ORDER BY endtime ASC";
+ break;
+ case 1:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 6 ORDER BY endtime ASC";
+ break;
+ case 2:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 2 ORDER BY endtime ASC";
+ break;
+ case 3:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
+ break;
+ case 4:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
+ break;
+ case 5:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 5 and proc = 0 ORDER BY endtime ASC";
+ break;
+ case 6:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured = $village and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
+ break;
+ case 7:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC";
+ break;
+ case 8:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC";
+ break;
+ case 34:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
+ break;
+ }
+ $result = mysql_query($q, $this->connection);
+ $array = $this->mysql_fetch_all($result);
+ return $array;
+ }
+
+ function addA2b($ckey, $timestamp, $to, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type) {
+ $q = "INSERT INTO " . TB_PREFIX . "a2b (ckey,time_check,to_vid,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,type) VALUES ('$ckey', '$timestamp', '$to', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10', '$t11', '$type')";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ function getA2b($ckey, $check) {
+ $q = "SELECT * from " . TB_PREFIX . "a2b where ckey = '" . $ckey . "' AND time_check = '" . $check . "'";
+ $result = mysql_query($q, $this->connection);
+ if($result) {
+ return mysql_fetch_assoc($result);
+ } else {
+ return false;
+ }
+ }
+
+ function addMovement($type, $from, $to, $ref, $time, $endtime, $send = 1, $wood = 0, $clay = 0, $iron = 0, $crop = 0, $ref2 = 0) {
+ $q = "INSERT INTO " . TB_PREFIX . "movement values (0,$type,$from,$to,$ref,$ref2,$time,$endtime,0,$send,$wood,$clay,$iron,$crop)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function addAttack($vid, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type, $ctar1, $ctar2, $spy,$b1=0,$b2=0,$b3=0,$b4=0,$b5=0,$b6=0,$b7=0,$b8=0) {
+ $q = "INSERT INTO " . TB_PREFIX . "attacks values (0,$vid,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$type,$ctar1,$ctar2,$spy,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8)";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ function modifyAttack($aid, $unit, $amt) {
+ $unit = 't' . $unit;
+ $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit - $amt where id = $aid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function modifyAttack2($aid, $unit, $amt) {
+ $unit = 't' . $unit;
+ $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit + $amt where id = $aid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getRanking() {
+ $q = "SELECT id,username,alliance,ap,apall,dp,dpall,access FROM " . TB_PREFIX . "users WHERE tribe<=3 AND access<" . (INCLUDE_ADMIN ? "10" : "8");
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getVRanking() {
+ $q = "SELECT v.wref,v.name,v.owner,v.pop FROM " . TB_PREFIX . "vdata AS v," . TB_PREFIX . "users AS u WHERE v.owner=u.id AND u.tribe<=3 AND v.wref != '' AND u.access<" . (INCLUDE_ADMIN ? "10" : "8");
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getARanking() {
+ $q = "SELECT id,name,tag,oldrank,Aap,Adp FROM " . TB_PREFIX . "alidata where id != '' ORDER BY id DESC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getUserByTribe($tribe){
+ $q = "SELECT * FROM " . TB_PREFIX . "users where tribe = $tribe";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getUserByAlliance($aid){
+ $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getHeroRanking() {
+ $q = "SELECT * FROM " . TB_PREFIX . "hero WHERE dead = 0";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getAllMember($aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getAllMember2($aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc LIMIT 1";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function addUnits($vid) {
+ $q = "INSERT into " . TB_PREFIX . "units (vref) values ($vid)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getUnit($vid) {
+ $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ if (!empty($result)) {
+ return mysql_fetch_assoc($result);
+ } else {
+ return NULL;
+ }
+ }
+
+ function getUnitsNumber($vid) {
+ $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_assoc($result);
+ $totalunits = 0;
+ $movingunits = $this->getVillageMovement($vid);
+ for($i=1;$i<=50;$i++){
+ $totalunits += $dbarray['u'.$i];
+ }
+ $totalunits += $dbarray['hero'];
+ $movingunits = $this->getVillageMovement($vid);
+ $reinforcingunits = $this->getEnforceArray($vid,1);
+ $owner = $this->getVillageField($vid,"owner");
+ $ownertribe = $this->getUserField($owner,"tribe",0);
+ $start = ($ownertribe-1)*10+1;
+ $end = ($ownertribe*10);
+ for($i=$start;$i<=$end;$i++){
+ $totalunits += $movingunits['u'.$i];
+ $totalunits += $reinforcingunits['u'.$i];
+ }
+ $totalunits += $movingunits['hero'];
+ $totalunits += $reinforcingunits['hero'];
+ return $totalunits;
+ }
+
+ function getHero($uid=0,$all=0) {
+ if ($all) {
+ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid=$uid";
+ } elseif (!$uid) {
+ $q = "SELECT * FROM ".TB_PREFIX."hero";
+ } else {
+ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE dead=0 AND uid=$uid LIMIT 1";
+ }
+ $result = mysql_query($q, $this->connection);
+ if (!empty($result)) {
+ return $this->mysql_fetch_all($result);
+ } else {
+ return NULL;
+ }
+ }
+
+ function getHeroField($uid,$field){
+ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = $uid";
+ $result = mysql_query($q,$this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function modifyHero($column,$value,$heroid,$mode=0) {
+ if(!$mode) {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE heroid = $heroid";
+ } elseif($mode=1) {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE heroid = $heroid";
+ } else {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE heroid = $heroid";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function modifyHeroByOwner($column,$value,$uid,$mode=0) {
+ if(!$mode) {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE uid = $uid";
+ } elseif($mode=1) {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE uid = $uid";
+ } else {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE uid = $uid";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function modifyHeroXp($column,$value,$heroid) {
+ $q = "UPDATE ".TB_PREFIX."hero SET $column = $column + $value WHERE uid=$heroid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function addTech($vid) {
+ $q = "INSERT into " . TB_PREFIX . "tdata (vref) values ($vid)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function addABTech($vid) {
+ $q = "INSERT into " . TB_PREFIX . "abdata (vref) values ($vid)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getABTech($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "abdata where vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ function addResearch($vid, $tech, $time) {
+ $q = "INSERT into " . TB_PREFIX . "research values (0,$vid,'$tech',$time)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getResearching($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "research where vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function checkIfResearched($vref, $unit) {
+ $q = "SELECT $unit FROM " . TB_PREFIX . "tdata WHERE vref = $vref";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray[$unit];
+ }
+
+ function getTech($vid) {
+ $q = "SELECT * from " . TB_PREFIX . "tdata where vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ function getTraining($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "training where vref = $vid ORDER BY id";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function countTraining($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "training WHERE vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ return $row[0];
+ }
+
+ function trainUnit($vid, $unit, $amt, $pop, $each, $time, $mode) {
+ global $village, $building, $session, $technology;
+
+ if(!$mode) {
+ $barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44);
+ $greatbarracks = array(61,62,63,71,72,73,84,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104);
+ $stables = array(4,5,6,15,16,23,24,25,26,45,46);
+ $greatstables = array(64,65,66,75,76,83,84,85,86,105,106);
+ $workshop = array(7,8,17,18,27,28,47,48);
+ $greatworkshop = array(67,68,77,78,87,88,107,108);
+ $residence = array(9,10,19,20,29,30,49,50);
+ $trapper = array(99);
+
+ if(in_array($unit, $barracks)) {
+ $queued = $technology->getTrainingList(1);
+ } elseif(in_array($unit, $stables)) {
+ $queued = $technology->getTrainingList(2);
+ } elseif(in_array($unit, $workshop)) {
+ $queued = $technology->getTrainingList(3);
+ } elseif(in_array($unit, $residence)) {
+ $queued = $technology->getTrainingList(4);
+ } elseif(in_array($unit, $greatstables)) {
+ $queued = $technology->getTrainingList(6);
+ } elseif(in_array($unit, $greatbarracks)) {
+ $queued = $technology->getTrainingList(5);
+ } elseif(in_array($unit, $greatworkshop)) {
+ $queued = $technology->getTrainingList(7);
+ } elseif(in_array($unit, $trapper)) {
+ $queued = $technology->getTrainingList(8);
+ }
+ $now = time();
+
+ $uid = $this->getVillageField($vid, "owner");
+ $artefact = count($this->getOwnUniqueArtefactInfo2($uid,5,3,0));
+ $artefact1 = count($this->getOwnUniqueArtefactInfo2($vid,5,1,1));
+ $artefact2 = count($this->getOwnUniqueArtefactInfo2($uid,5,2,0));
+ if($artefact > 0){
+ $time = $now+round(($time-$now)/2);
+ $each /= 2;
+ $each = round($each);
+ }else if($artefact1 > 0){
+ $time = $now+round(($time-$now)/2);
+ $each /= 2;
+ $each = round($each);
+ }else if($artefact2 > 0){
+ $time = $now+round(($time-$now)/4*3);
+ $each /= 4;
+ $each = round($each);
+ $each *= 3;
+ $each = round($each);
+ }
+ $foolartefact = $this->getFoolArtefactInfo(5,$vid,$uid);
+ if(count($foolartefact) > 0){
+ foreach($foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $each *= $arte['effect2'];
+ }else{
+ $each /= $arte['effect2'];
+ $each = round($each);
+ }
+ }
+ }
+ if($each == 0){ $each = 1; }
+ $time2 = $now+$each;
+ if(count($queued) > 0) {
+ $time += $queued[count($queued) - 1]['timestamp'] - $now;
+ $time2 += $queued[count($queued) - 1]['timestamp'] - $now;
+ }
+ if($queued[count($queued) - 1]['unit'] == $unit){
+ $time = $amt*$queued[count($queued) - 1]['eachtime'];
+ $q = "UPDATE " . TB_PREFIX . "training SET amt = amt + $amt, timestamp = timestamp + $time WHERE id = ".$queued[count($queued) - 1]['id']."";
+ }else{
+ $q = "INSERT INTO " . TB_PREFIX . "training values (0,$vid,$unit,$amt,$pop,$time,$each,$time2)";
+ }
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "training where id = $vid";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function updateTraining($id, $trained, $each) {
+ $q = "UPDATE " . TB_PREFIX . "training set amt = amt - $trained, timestamp2 = timestamp2 + $each where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function modifyUnit($vref, $array_unit, $array_amt, $array_mode){
+ $i = -1;
+ $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;}
+
+ ++$i;
+ $units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').' '.$array_amt[$i].(($number > $i+1) ? ', ' : '');
+ }
+
+ $q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getEnforce($vid, $from) {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $from and vref = $vid";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ function addEnforce($data) {
+ $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")";
+ mysql_query($q, $this->connection);
+ $id = mysql_insert_id($this->connection);
+ $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0);
+ $start = ($owntribe - 1) * 10 + 1;
+ $end = ($owntribe * 10);
+ //add unit
+ $j = '1';
+ for($i = $start; $i <= $end; $i++) {
+ $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1);
+ $j++;
+ }
+ $this->modifyEnforce($id,'hero',$data['t11'],1);
+ return mysql_insert_id($this->connection);
+ }
+
+ function addEnforce2($data,$tribe,$dead1,$dead2,$dead3,$dead4,$dead5,$dead6,$dead7,$dead8,$dead9,$dead10,$dead11) {
+ $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")";
+ mysql_query($q, $this->connection);
+ $id = mysql_insert_id($this->connection);
+ $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0);
+ $start = ($owntribe - 1) * 10 + 1;
+ $end = ($owntribe * 10);
+ $start2 = ($tribe - 1) * 10 + 1;
+ $start3 = ($tribe - 1) * 10;
+ if($start3 == 0){
+ $start3 = "";
+ }
+ $end2 = ($tribe * 10);
+ //add unit
+ $j = '1';
+ for($i = $start; $i <= $end; $i++) {
+ $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1);
+ $this->modifyEnforce($id, $i, ${dead.$j}, 0);
+ $j++;
+ }
+ $this->modifyEnforce($id,'hero',$data['t11'],1);
+ $this->modifyEnforce($id,'hero',$dead11,0);
+ return mysql_insert_id($this->connection);
+ }
+
+ function modifyEnforce($id, $unit, $amt, $mode) {
+ if($unit != 'hero') { $unit = 'u' . $unit; }
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit - $amt where id = $id";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit + $amt where id = $id";
+ }
+ mysql_query($q, $this->connection);
+ }
+
+ function getEnforceArray($id, $mode) {
+ if(!$mode) {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where id = $id";
+ } else {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id";
+ }
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_assoc($result);
+ }
+
+ function getEnforceVillage($id, $mode) {
+ if(!$mode) {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $id";
+ } else {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id";
+ }
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getVillageMovement($id) {
+ $vinfo = $this->getVillage($id);
+ $vtribe = $this->getUserField($vinfo['owner'], "tribe", 0);
+ $movingunits = array();
+ $outgoingarray = $this->getMovement(3, $id, 0);
+ if(!empty($outgoingarray)) {
+ foreach($outgoingarray as $out) {
+ for($i = 1; $i <= 10; $i++) {
+ $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $out['t' . $i];
+ }
+ $movingunits['hero'] += $out['t11'];
+ }
+ }
+ $returningarray = $this->getMovement(4, $id, 1);
+ if(!empty($returningarray)) {
+ foreach($returningarray as $ret) {
+ if($ret['attack_type'] != 1) {
+ for($i = 1; $i <= 10; $i++) {
+ $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $ret['t' . $i];
+ }
+ $movingunits['hero'] += $ret['t11'];
+ }
+ }
+ }
+ $settlerarray = $this->getMovement(5, $id, 0);
+ if(!empty($settlerarray)) {
+ $movingunits['u' . ($vtribe * 10)] += 3 * count($settlerarray);
+ }
+ return $movingunits;
+ }
+
+ ################# -START- ##################
+ ## WORLD WONDER STATISTICS FUNCTIONS! ##
+ ############################################
+
+ /***************************
+ Function to get all World Wonders
+ Made by: Dzoki
+ ***************************/
+
+ function getWW() {
+ $q = "SELECT * FROM " . TB_PREFIX . "fdata WHERE f99t = 40";
+ $result = mysql_query($q, $this->connection);
+ if(mysql_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /***************************
+ Function to get world wonder level!
+ Made by: Dzoki
+ ***************************/
+
+ function getWWLevel($vref) {
+ $q = "SELECT f99 FROM " . TB_PREFIX . "fdata WHERE vref = $vref";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['f99'];
+ }
+
+ /***************************
+ Function to get world wonder owner ID!
+ Made by: Dzoki
+ ***************************/
+
+ function getWWOwnerID($vref) {
+ $q = "SELECT owner FROM " . TB_PREFIX . "vdata WHERE wref = $vref";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['owner'];
+ }
+
+ /***************************
+ Function to get user alliance name!
+ Made by: Dzoki
+ ***************************/
+
+ function getUserAllianceID($id) {
+ $q = "SELECT alliance FROM " . TB_PREFIX . "users where id = $id";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['alliance'];
+ }
+
+ /***************************
+ Function to get WW name
+ Made by: Dzoki
+ ***************************/
+
+ function getWWName($vref) {
+ $q = "SELECT wwname FROM " . TB_PREFIX . "fdata WHERE vref = $vref";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['wwname'];
+ }
+
+ /***************************
+ Function to change WW name
+ Made by: Dzoki
+ ***************************/
+
+ function submitWWname($vref, $name) {
+ $q = "UPDATE " . TB_PREFIX . "fdata SET `wwname` = '$name' WHERE " . TB_PREFIX . "fdata.`vref` = $vref";
+ return mysql_query($q, $this->connection);
+ }
+
+ //medal functions
+ function addclimberpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc + '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ function addclimberrankpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set clp = clp + '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ function removeclimberrankpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set clp = clp - '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ function setclimberrankpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set clp = '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ function updateoldrank($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set oldrank = '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ function removeclimberpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc - '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ // ALLIANCE MEDAL FUNCTIONS
+ function addclimberpopAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc + '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ function addclimberrankpopAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp + '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ function removeclimberrankpopAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp - '$cp'' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ function updateoldrankAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set oldrank = '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+ function removeclimberpopAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc - '$cp' where id = $user";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getTrainingList() {
+ $q = "SELECT * FROM " . TB_PREFIX . "training where vref != ''";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getNeedDelete() {
+ $time = time();
+ $q = "SELECT uid FROM " . TB_PREFIX . "deleting where timestamp < $time";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function countUser() {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "users where id > 5";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ return $row[0];
+ }
+
+ function countAlli() {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "alidata where id != 0";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ return $row[0];
+ }
+
+ /***************************
+ Function to process MYSQLi->fetch_all (Only exist in MYSQL)
+ References: Result
+ ***************************/
+ function mysql_fetch_all($result) {
+ $all = array();
+ if($result) {
+ while($row = mysql_fetch_assoc($result)) {
+ $all[] = $row;
+ }
+ return $all;
+ }
+ }
+
+ function query_return($q) {
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ /***************************
+ Function to do free query
+ References: Query
+ ***************************/
+ function query($query) {
+ return mysql_query($query, $this->connection);
+ }
+
+ function RemoveXSS($val) {
+ return htmlspecialchars($val, ENT_QUOTES);
+ }
+
+ //MARKET FIXES
+ function getWoodAvailable($wref) {
+ $q = "SELECT wood FROM " . TB_PREFIX . "vdata WHERE wref = $wref";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['wood'];
+ }
+
+ function getClayAvailable($wref) {
+ $q = "SELECT clay FROM " . TB_PREFIX . "vdata WHERE wref = $wref";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['clay'];
+ }
+
+ function getIronAvailable($wref) {
+ $q = "SELECT iron FROM " . TB_PREFIX . "vdata WHERE wref = $wref";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['iron'];
+ }
+
+ function getCropAvailable($wref) {
+ $q = "SELECT crop FROM " . TB_PREFIX . "vdata WHERE wref = $wref";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['crop'];
+ }
+
+ function Getowner($vid) {
+ $s = "SELECT owner FROM " . TB_PREFIX . "vdata where wref = $vid";
+ $result1 = mysql_query($s, $this->connection);
+ $row1 = mysql_fetch_row($result1);
+ return $row1[0];
+ }
+
+ public function debug($time, $uid, $debug_info) {
+ $q = "INSERT INTO " . TB_PREFIX . "debug_info (time,uid,debug_info) VALUES ($time,$uid,$debug_info)";
+ if(mysql_query($q, $this->connection)) {
+ return mysql_insert_id($this->connection);
+ } else {
+ return false;
+ }
+ }
+
+ function populateOasisdata() {
+ $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0";
+ $result2 = mysql_query($q2, $this->connection);
+ while($row = mysql_fetch_array($result2)) {
+ $wid = $row['id'];
+ $basearray = $this->getOMInfo($wid);
+ //We switch type of oasis and instert record with apropriate infomation.
+ $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . ",100,2,'Unoccupied Oasis',".rand(0,2).")";
+ $result = mysql_query($q, $this->connection);
+ }
+ }
+
+ public function getAvailableExpansionTraining() {
+ global $building, $session, $technology, $village;
+ $q = "SELECT (IF(exp1=0,1,0)+IF(exp2=0,1,0)+IF(exp3=0,1,0)) FROM " . TB_PREFIX . "vdata WHERE wref = $village->wid";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ $maxslots = $row[0];
+ $residence = $building->getTypeLevel(25);
+ $palace = $building->getTypeLevel(26);
+ if($residence > 0) {
+ $maxslots -= (3 - floor($residence / 10));
+ }
+ if($palace > 0) {
+ $maxslots -= (3 - floor(($palace - 5) / 5));
+ }
+
+ $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "units WHERE vref = $village->wid";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ $settlers = $row[0];
+ $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "units WHERE vref = $village->wid";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ $chiefs = $row[0];
+
+ $settlers += 3 * count($this->getMovement(5, $village->wid, 0));
+ $current_movement = $this->getMovement(3, $village->wid, 0);
+ if(!empty($current_movement)) {
+ foreach($current_movement as $build) {
+ $settlers += $build['t10'];
+ $chiefs += $build['t9'];
+ }
+ }
+ $current_movement = $this->getMovement(3, $village->wid, 1);
+ if(!empty($current_movement)) {
+ foreach($current_movement as $build) {
+ $settlers += $build['t10'];
+ $chiefs += $build['t9'];
+ }
+ }
+ $current_movement = $this->getMovement(4, $village->wid, 0);
+ if(!empty($current_movement)) {
+ foreach($current_movement as $build) {
+ $settlers += $build['t10'];
+ $chiefs += $build['t9'];
+ }
+ }
+ $current_movement = $this->getMovement(4, $village->wid, 1);
+ if(!empty($current_movement)) {
+ foreach($current_movement as $build) {
+ $settlers += $build['t10'];
+ $chiefs += $build['t9'];
+ }
+ }
+ $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ if(!empty($row)) {
+ foreach($row as $reinf) {
+ $settlers += $reinf[0];
+ }
+ }
+ $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid";
+ $result = mysql_query($q, $this->connection);
+ $row = mysql_fetch_row($result);
+ if(!empty($row)) {
+ foreach($row as $reinf) {
+ $chiefs += $reinf[0];
+ }
+ }
+ $trainlist = $technology->getTrainingList(4);
+ if(!empty($trainlist)) {
+ foreach($trainlist as $train) {
+ if($train['unit'] % 10 == 0) {
+ $settlers += $train['amt'];
+ }
+ if($train['unit'] % 10 == 9) {
+ $chiefs += $train['amt'];
+ }
+ }
+ }
+ // trapped settlers/chiefs calculation required
+
+ $settlerslots = $maxslots * 3 - $settlers - $chiefs * 3;
+ $chiefslots = $maxslots - $chiefs - floor(($settlers + 2) / 3);
+
+ if(!$technology->getTech(($session->tribe - 1) * 10 + 9)) {
+ $chiefslots = 0;
+ }
+ $slots = array("chiefs" => $chiefslots, "settlers" => $settlerslots);
+ return $slots;
+ }
+
+ function addArtefact($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 mysql_query($q, $this->connection);
+ }
+
+ function getOwnArtefactInfo($vref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function getOwnArtefactInfo2($vref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getOwnArtefactInfo3($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $uid";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getOwnArtefactInfoByType($vref, $type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type order by size";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function getOwnArtefactInfoByType2($vref, $type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getOwnUniqueArtefactInfo($id, $type, $size) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND type = $type AND size=$size";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function getOwnUniqueArtefactInfo2($id, $type, $size, $mode) {
+ if(!$mode){
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND active = 1 AND type = $type AND size=$size";
+ }else{
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $id AND active = 1 AND type = $type AND size=$size";
+ }
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getFoolArtefactInfo($type,$vid,$uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vid AND type = 8 AND kind = $type OR owner = $uid AND size > 1 AND active = 1 AND type = 8 AND kind = $type";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function claimArtefact($vref, $ovref, $id) {
+ $time = time();
+ $q = "UPDATE " . TB_PREFIX . "artefacts SET vref = $vref, owner = $id, conquered = $time, active = 1 WHERE vref = $ovref";
+ return mysql_query($q, $this->connection);
+ }
+
+ public function canClaimArtifact($from,$vref,$type,$kind) {
+ $type2 = $type3 = 0;
+ if(count($this->getOwnUniqueArtefactInfo2($this->getVillagefield($from,"owner"),2,2,0)) > 0 && $type == 2){
+ $type2 = 1;
+ }
+ if(count($this->getOwnUniqueArtefactInfo2($this->getVillagefield($from,"owner"),2,3,0)) > 0 && $type == 3){
+ $type3 = 1;
+ }
+ if((count($this->getOwnArtefactInfo2($from)) < 3 && $type2 == 0 && $type3 == 0) or $kind == 11){
+ $DefenderFields = $this->getResourceLevel($vref);
+ $defcanclaim = TRUE;
+ for($i=19;$i<=38;$i++) {
+ if($DefenderFields['f'.$i.'t'] == 27) {
+ $defTresuaryLevel = $DefenderFields['f'.$i];
+ if($defTresuaryLevel > 0) {
+ $defcanclaim = FALSE;
+ } else {
+ $defcanclaim = TRUE;
+ }
+ }
+ }
+ $AttackerFields = $this->getResourceLevel($from);
+ for($i=19;$i<=38;$i++) {
+ if($AttackerFields['f'.$i.'t'] == 27) {
+ $attTresuaryLevel = $AttackerFields['f'.$i];
+ if ($attTresuaryLevel >= 10) {
+ $villageartifact = TRUE;
+ } else {
+ $villageartifact = FALSE;
+ }
+ if ($attTresuaryLevel >= 20){
+ $accountartifact = TRUE;
+ } else {
+ $accountartifact = FALSE;
+ }
+ }
+ }
+ if ($type == 1) {
+ if ($defcanclaim == TRUE && $villageartifact == TRUE) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else if ($type == 2) {
+ if ($defcanclaim == TRUE && $accountartifact == TRUE) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else if ($type == 3) {
+ if ($defcanclaim == TRUE && $accountartifact == TRUE) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else {
+ return FALSE;
+ }
+ }else{
+ return FALSE;
+ }
+ }
+
+ function getArtefactDetails($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id = " . $id . "";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function getMovementById($id){
+ $q = "SELECT * FROM ".TB_PREFIX."movement WHERE moveid = ".$id."";
+ $result = mysql_query($q);
+ $array = $this->mysql_fetch_all($result);
+ return $array;
+ }
+
+ function getLinks($id){
+ $q = 'SELECT * FROM `' . TB_PREFIX . 'links` WHERE `userid` = ' . $id . ' ORDER BY `pos` ASC';
+ return mysql_query($q, $this->connection);
+ }
+
+ function removeLinks($id,$uid){
+ $q = "DELETE FROM " . TB_PREFIX . "links WHERE `id` = ".$id." and `userid` = ".$uid."";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getVilFarmlist($wref){
+ $q = 'SELECT * FROM ' . TB_PREFIX . 'farmlist WHERE wref = ' . $wref . ' ORDER BY wref ASC';
+ $result = mysql_query($q, $this->connection);
+ $dbarray = mysql_fetch_array($result);
+
+ if($dbarray['id']!=0) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ function getRaidList($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "raidlist WHERE id = ".$id."";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function delFarmList($id, $owner) {
+ $q = "DELETE FROM " . TB_PREFIX . "farmlist where id = $id and owner = $owner";
+ return mysql_query($q, $this->connection);
+ }
+
+ function delSlotFarm($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "raidlist where id = $id";
+ return mysql_query($q, $this->connection);
+ }
+
+ function createFarmList($wref, $owner, $name) {
+ $q = "INSERT INTO " . TB_PREFIX . "farmlist (`wref`, `owner`, `name`) VALUES ('$wref', '$owner', '$name')";
+ return mysql_query($q, $this->connection);
+ }
+
+ function addSlotFarm($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) {
+ $q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`, `t7`, `t8`, `t9`, `t10`) VALUES ('$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10')";
+ return mysql_query($q, $this->connection);
+ }
+
+ function editSlotFarm($eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) {
+ $q = "UPDATE " . TB_PREFIX . "raidlist set lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getArrayMemberVillage($uid){
+ $q = 'SELECT a.wref, a.name, b.x, b.y from '.TB_PREFIX.'vdata AS a left join '.TB_PREFIX.'wdata AS b ON b.id = a.wref where owner = '.$uid.' order by capital DESC,pop DESC';
+ $result = mysql_query($q, $this->connection);
+ $array = $this->mysql_fetch_all($result);
+ return $array;
+ }
+
+ function addPassword($uid, $npw, $cpw){
+ $q = "REPLACE INTO `" . TB_PREFIX . "password`(uid, npw, cpw) VALUES ($uid, '$npw', '$cpw')";
+ mysql_query($q, $this->connection) or die(mysql_error());
+ }
+
+ function resetPassword($uid, $cpw){
+ $q = "SELECT npw FROM `" . TB_PREFIX . "password` WHERE uid = $uid AND cpw = '$cpw' AND used = 0";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+
+ if(!empty($dbarray)) {
+ if(!$this->updateUserField($uid, 'password', md5($dbarray['npw']), 1)) return false;
+ $q = "UPDATE `" . TB_PREFIX . "password` SET used = 1 WHERE uid = $uid AND cpw = '$cpw' AND used = 0";
+ mysql_query($q, $this->connection) or die(mysql_error());
+ return true;
+ }
+
+ return false;
+ }
+
+ function getCropProdstarv($wref) {
+ global $bid4,$bid8,$bid9,$sesion,$technology;
+
+ $basecrop = $grainmill = $bakery = 0;
+ $owner = $this->getVrefField($wref, 'owner');
+ $bonus = $this->getUserField($owner, b4, 0);
+
+ $buildarray = $this->getResourceLevel($wref);
+ $cropholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($buildarray['f'.$i.'t'] == 4) {
+ array_push($cropholder,'f'.$i);
+ }
+ if($buildarray['f'.$i.'t'] == 8) {
+ $grainmill = $buildarray['f'.$i];
+ }
+ if($buildarray['f'.$i.'t'] == 9) {
+ $bakery = $buildarray['f'.$i];
+ }
+ }
+ $q = "SELECT type FROM `" . TB_PREFIX . "odata` WHERE conqured = $wref";
+ $oasis = $this->query_return($q);
+ foreach($oasis as $oa){
+ switch($oa['type']) {
+ case 1:
+ case 2:
+ $wood += 1;
+ break;
+ case 3:
+ $wood += 1;
+ $cropo += 1;
+ break;
+ case 4:
+ case 5:
+ $clay += 1;
+ break;
+ case 6:
+ $clay += 1;
+ $cropo += 1;
+ break;
+ case 7:
+ case 8:
+ $iron += 1;
+ break;
+ case 9:
+ $iron += 1;
+ $cropo += 1;
+ break;
+ case 10:
+ case 11:
+ $cropo += 1;
+ break;
+ case 12:
+ $cropo += 2;
+ break;
+ }
+ }
+ for($i=0;$i<=count($cropholder)-1;$i++) { $basecrop+= $bid4[$buildarray[$cropholder[$i]]]['prod']; }
+ $crop = $basecrop + $basecrop * 0.25 * $cropo;
+ if($grainmill >= 1 || $bakery >= 1) {
+ $crop += $basecrop /100 * ($bid8[$grainmill]['attri'] + $bid9[$bakery]['attri']);
+ }
+ if($bonus > time()) {
+ $crop *= 1.25;
+ }
+ $crop *= SPEED;
+ return $crop;
+ }
+
+ //general statistics
+
+ function addGeneralAttack($casualties) {
+ $time = time();
+ $q = "INSERT INTO " . TB_PREFIX . "general values (0,'$casualties','$time',1)";
+ return mysql_query($q, $this->connection) or die(mysql_error());
+ }
+
+ function getAttackByDate($time) {
+ $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1";
+ $result = $this->query_return($q);
+ $attack = 0;
+ foreach($result as $general){
+ if(date("j. M",$time) == date("j. M",$general['time'])){
+ $attack += 1;
+ }
+ }
+ return $attack;
+ }
+
+ function getAttackCasualties($time) {
+ $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1";
+ $result = $this->query_return($q);
+ $casualties = 0;
+ foreach($result as $general){
+ if(date("j. M",$time) == date("j. M",$general['time'])){
+ $casualties += $general['casualties'];
+ }
+ }
+ return $casualties;
+ }
+
+ //end general statistics
+
+ function addFriend($uid, $column, $friend) {
+ $q = "UPDATE " . TB_PREFIX . "users SET $column = $friend WHERE id = $uid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function deleteFriend($uid, $column) {
+ $q = "UPDATE " . TB_PREFIX . "users SET $column = 0 WHERE id = $uid";
+ return mysql_query($q, $this->connection);
+ }
+
+ function checkFriends($uid) {
+ $user = $this->getUserArray($uid, 1);
+ for($i=0;$i<=19;$i++) {
+ if($user['friend'.$i] == 0 && $user['friend'.$i.'wait'] == 0){
+ for($j=$i+1;$j<=19;$j++) {
+ $k = $j-1;
+ if($user['friend'.$j] != 0){
+ $friend = $this->getUserField($uid, "friend".$j, 0);
+ $this->addFriend($uid,"friend".$k,$friend);
+ $this->deleteFriend($uid,"friend".$j);
+ }
+ if($user['friend'.$j.'wait'] == 0){
+ $friendwait = $this->getUserField($uid, "friend".$j."wait", 0);
+ $this->addFriend($sessionuid,"friend".$k."wait",$friendwait);
+ $this->deleteFriend($uid,"friend".$j."wait");
+ }
+ }
+ }
+ }
+ }
+
+ function setVillageEvasion($vid) {
+ $village = $this->getVillage($vid);
+ if($village['evasion'] == 0){
+ $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 1 WHERE wref = $vid";
+ }else{
+ $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 0 WHERE wref = $vid";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function addPrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) {
+ $q = "INSERT INTO " . TB_PREFIX . "prisoners values (0,$wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11)";
+ mysql_query($q, $this->connection);
+ return mysql_insert_id($this->connection);
+ }
+
+ function updatePrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) {
+ $q = "UPDATE " . TB_PREFIX . "prisoners set t1 = t1 + $t1, t2 = t2 + $t2, t3 = t3 + $t3, t4 = t4 + $t4, t5 = t5 + $t5, t6 = t6 + $t6, t7 = t7 + $t7, t8 = t8 + $t8, t9 = t9 + $t9, t10 = t10 + $t10, t11 = t11 + $t11 where wid = $wid and from = $from";
+ return mysql_query($q, $this->connection) or die(mysql_error());
+ }
+
+ function getPrisoners($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getPrisoners2($wid,$from) {
+ $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid and " . TB_PREFIX . "prisoners.from = $from";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getPrisonersByID($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "prisoners where id = $id";
+ $result = mysql_query($q, $this->connection);
+ return mysql_fetch_array($result);
+ }
+
+ function getPrisoners3($from) {
+ $q = "SELECT * FROM " . TB_PREFIX . "prisoners where " . TB_PREFIX . "prisoners.from = $from";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function deletePrisoners($id) {
+ $q = "DELETE from " . TB_PREFIX . "prisoners where id = '$id'";
+ mysql_query($q, $this->connection);
+ }
+};
+
+$database = new MYSQL_DB;
+
+?>
diff --git a/GameEngine/Database/db_MYSQLi.php b/GameEngine/Database/db_MYSQLi.php
new file mode 100644
index 00000000..632847f5
--- /dev/null
+++ b/GameEngine/Database/db_MYSQLi.php
@@ -0,0 +1,3331 @@
+connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+
+ ## Added even MySQL connection for inline mysql commands in temeplate files
+ $con = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
+ mysql_select_db(SQL_DB, $this->connection);
+ }
+
+ function register($username, $password, $email, $tribe, $act) {
+ $time = time();
+ $timep = time() + PROTECTION;
+ if(strtotime(START_TIME) > time()){
+ $timep = (strtotime(START_TIME) + PROTECTION);
+ }
+ $q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)";
+ if(mysql_query($this->connection, $q)) {
+ return mysql_insert_id($this->connection);
+ } else {
+ return false;
+ }
+ }
+
+ function activate($username, $password, $email, $tribe, $locate, $act, $act2) {
+ $time = time();
+ $q = "INSERT INTO " . TB_PREFIX . "activate (username,password,access,email,tribe,timestamp,location,act,act2) VALUES ('$username', '$password', " . USER . ", '$email', $tribe, $time, $locate, '$act', '$act2')";
+ if(mysqli_query($this->connection, $q)) {
+ return mysqli_insert_id($this->connection);
+ } else {
+ return false;
+ }
+ }
+
+ function unreg($username) {
+ $q = "DELETE from " . TB_PREFIX . "activate where username = '$username'";
+ return mysqli_query($this->connection, $q);
+ }
+ function deleteReinf($id) {
+ $q = "DELETE from " . TB_PREFIX . "enforcement where id = '$id'";
+ mysqli_query($this->connection, $q);
+ }
+ function updateResource($vid, $what, $number) {
+
+ $q = "UPDATE " . TB_PREFIX . "vdata set " . $what . "=" . $number . " where wref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_query($this->connection, $q);
+ }
+
+ function checkExist($ref, $mode) {
+
+ if(!$mode) {
+ $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$ref' LIMIT 1";
+ } else {
+ $q = "SELECT email FROM " . TB_PREFIX . "users where email = '$ref' LIMIT 1";
+ }
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function checkExist_activate($ref, $mode) {
+
+ if(!$mode) {
+ $q = "SELECT username FROM " . TB_PREFIX . "activate where username = '$ref' LIMIT 1";
+ } else {
+ $q = "SELECT email FROM " . TB_PREFIX . "activate where email = '$ref' LIMIT 1";
+ }
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public function hasBeginnerProtection($vid) {
+ $q = "SELECT u.protect FROM ".TB_PREFIX."users u,".TB_PREFIX."vdata v WHERE u.id=v.owner AND v.wref=".$vid;
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ if(!empty($dbarray)) {
+ if(time()<$dbarray[0]) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ function updateUserField($ref, $field, $value, $switch) {
+ if(!$switch) {
+ $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where username = '$ref'";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "users set $field = '$value' where id = '$ref'";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getSitee($uid) {
+ $q = "SELECT id from " . TB_PREFIX . "users where sit1 = $uid or sit2 = $uid";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getVilWref($x, $y) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata where x = $x AND y = $y";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['id'];
+ }
+
+ function caststruc($user) {
+ //loop search village user
+ $query = mysqli_query($this->connection, "SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user."");
+ while($villaggi_array = mysqli_fetch_array($query, MYSQLI_BOTH))
+
+ //loop structure village
+ $query1 = mysqli_query($this->connection, "SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref']."");
+ $strutture= mysqli_fetch_array($query1, MYSQLI_BOTH);
+ return $strutture;
+ }
+
+ function removeMeSit($uid, $uid2) {
+ $q = "UPDATE " . TB_PREFIX . "users set sit1 = 0 where id = $uid and sit1 = $uid2";
+ mysqli_query($this->connection, $q);
+ $q2 = "UPDATE " . TB_PREFIX . "users set sit2 = 0 where id = $uid and sit2 = $uid2";
+ mysqli_query($this->connection, $q2);
+ }
+
+ function getUserField($ref, $field, $mode) {
+ if(!$mode) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "users where id = '$ref'";
+ } else {
+ $q = "SELECT $field FROM " . TB_PREFIX . "users where username = '$ref'";
+ }
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray[$field];
+ }
+
+ function getInvitedUser($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where invited = $uid order by regtime desc";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getVrefField($ref, $field){
+ $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = '$ref'";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray[$field];
+ }
+
+ function getVrefCapital($ref){
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where owner = '$ref' and capital = 1";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray;
+ }
+
+ function getStarvation(){
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where starv != 0 and owner != 3";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getActivateField($ref, $field, $mode) {
+ if(!$mode) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "activate where id = '$ref'";
+ } else {
+ $q = "SELECT $field FROM " . TB_PREFIX . "activate where username = '$ref'";
+ }
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray[$field];
+ }
+
+ function login($username, $password) {
+ $q = "SELECT password,sessid FROM " . TB_PREFIX . "users where username = '$username'";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ if($dbarray['password'] == md5($password)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function checkActivate($act) {
+ $q = "SELECT * FROM " . TB_PREFIX . "activate where act = '$act'";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+
+ return $dbarray;
+ }
+
+ function sitterLogin($username, $password) {
+ $q = "SELECT sit1,sit2 FROM " . TB_PREFIX . "users where username = '$username' and access != " . BANNED;
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ if($dbarray['sit1'] != 0) {
+ $q2 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit1'] . " and access != " . BANNED;
+ $result2 = mysqli_query($this->connection, $q2);
+ $dbarray2 = mysqli_fetch_array($result2, MYSQLI_BOTH);
+ }
+ if($dbarray['sit2'] != 0) {
+ $q3 = "SELECT password FROM " . TB_PREFIX . "users where id = " . $dbarray['sit2'] . " and access != " . BANNED;
+ $result3 = mysqli_query($q3, $this->connection);
+ $dbarray3 = mysqli_fetch_array($result3, MYSQLI_BOTH);
+ }
+ if($dbarray['sit1'] != 0 || $dbarray['sit2'] != 0) {
+ if($dbarray2['password'] == md5($password) || $dbarray3['password'] == md5($password)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ function setDeleting($uid, $mode) {
+ $time = time() + 72 * 3600;
+ if(!$mode) {
+ $q = "INSERT into " . TB_PREFIX . "deleting values ($uid,$time)";
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "deleting where uid = $uid";
+ }
+ mysqli_query($this->connection, $q);
+ }
+
+ function isDeleting($uid) {
+ $q = "SELECT timestamp from " . TB_PREFIX . "deleting where uid = $uid";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['timestamp'];
+ }
+
+ function modifyGold($userid, $amt, $mode) {
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "users set gold = gold - $amt where id = $userid";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "users set gold = gold + $amt where id = $userid";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ /*****************************************
+ Function to retrieve user array via Username or ID
+ Mode 0: Search by Username
+ Mode 1: Search by ID
+ References: Alliance ID
+ *****************************************/
+
+ function getUserArray($ref, $mode) {
+ if(!$mode) {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where username = '$ref'";
+ } else {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where id = $ref";
+ }
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function activeModify($username, $mode) {
+ $time = time();
+ if(!$mode) {
+ $q = "INSERT into " . TB_PREFIX . "active VALUES ('$username',$time)";
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "active where username = '$username'";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addActiveUser($username, $time) {
+ $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)";
+ if(mysqli_query($this->connection, $q)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function updateActiveUser($username, $time) {
+ $q = "REPLACE into " . TB_PREFIX . "active values ('$username',$time)";
+ $q2 = "UPDATE " . TB_PREFIX . "users set timestamp = $time where username = '$username'";
+ $exec1 = mysqli_query($this->connection, $q);
+ $exec2 = mysqli_query($this->connection, $q2);
+ if($exec1 && $exec2) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function checkactiveSession($username, $sessid) {
+ $q = "SELECT username FROM " . TB_PREFIX . "users where username = '$username' and sessid = '$sessid' LIMIT 1";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result) != 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function submitProfile($uid, $gender, $location, $birthday, $des1, $des2) {
+ $q = "UPDATE " . TB_PREFIX . "users set gender = $gender, location = '$location', birthday = '$birthday', desc1 = '$des1', desc2 = '$des2' where id = $uid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function gpack($uid, $gpack) {
+ $q = "UPDATE " . TB_PREFIX . "users set gpack = '$gpack' where id = $uid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function GetOnline($uid) {
+ $q = "SELECT sit FROM " . TB_PREFIX . "online where uid = $uid";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['sit'];
+ }
+
+ function UpdateOnline($mode, $name = "", $time = "", $uid = 0) {
+ global $session;
+ if($mode == "login") {
+ $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 0)";
+ return mysqli_query($this->connection, $q);
+ } else if($mode == "sitter") {
+ $q = "INSERT IGNORE INTO " . TB_PREFIX . "online (name, uid, time, sit) VALUES ('$name', '$uid', " . time() . ", 1)";
+ return mysqli_query($this->connection, $q);
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "online WHERE name ='" . addslashes($session->username) . "'";
+ return mysqli_query($this->connection, $q);
+ }
+ }
+
+ function generateBase($sector) {
+ switch($sector) {
+ case 1:
+ $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x < 0 and y > 0 and occupied = 0";
+ break;
+ case 2:
+ $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x > 0 and y > 0 and occupied = 0";
+ break;
+ case 3:
+ $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x < 0 and y < 0 and occupied = 0";
+ break;
+ case 4:
+ $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x > 0 and y < 0 and occupied = 0";
+ break;
+ }
+ $result = mysqli_query($this->connection, $q);
+ $num_rows = mysqli_num_rows($result);
+ $result = $this->mysqli_fetch_all($result);
+ $base = rand(0, ($num_rows-1));
+ return $result[$base]['id'];
+ }
+
+ function setFieldTaken($id) {
+ $q = "UPDATE " . TB_PREFIX . "wdata set occupied = 1 where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addVillage($wid, $uid, $username, $capital) {
+ $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->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ }
+
+ function addResourceFields($vid, $type) {
+ switch($type) {
+ case 1:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,4,4,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 2:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 3:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 4:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 5:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,3,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 6:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,4,4,1,3,4,4,4,4,4,4,4,4,4,4,4,2,4,4,1,15)";
+ break;
+ case 7:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 8:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 9:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,4,1,1,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 10:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,4,1,2,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ case 11:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,3,1,1,3,1,4,4,3,3,2,2,3,1,4,4,2,4,4,1,15)";
+ break;
+ case 12:
+ $q = "INSERT into " . TB_PREFIX . "fdata (vref,f1t,f2t,f3t,f4t,f5t,f6t,f7t,f8t,f9t,f10t,f11t,f12t,f13t,f14t,f15t,f16t,f17t,f18t,f26,f26t) values($vid,1,4,1,1,2,2,3,4,4,3,3,4,4,1,4,2,1,2,1,15)";
+ break;
+ }
+ return mysqli_query($this->connection, $q);
+ }
+ function isVillageOases($wref) {
+ $q = "SELECT id, oasistype FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['oasistype'];
+ }
+
+ public function VillageOasisCount($vref) {
+ $q = "SELECT count(*) FROM `".TB_PREFIX."odata` WHERE conqured=$vref";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ return $row[0];
+ }
+
+ public function countOasisTroops($vref){
+ //count oasis troops: $troops_o
+ $troops_o=0;
+ $o_unit2=mysqli_query("select * from ".TB_PREFIX."units where `vref`='".$vref."'");
+ $o_unit=mysqli_fetch_array($o_unit2, MYSQLI_BOTH);
+
+ for ($i=1;$i<51;$i++)
+ {
+ $troops_o+=$o_unit[$i];
+ }
+ $troops_o+=$o_unit['hero'];
+
+ $o_unit2=mysqli_query("select * from ".TB_PREFIX."enforcement where `vref`='".$vref."'");
+ while ($o_unit=@mysqil_fetch_array($o_unit2, MYSQLI_BOTH))
+ {
+ for ($i=1;$i<51;$i++)
+ {
+ $troops_o+=$o_unit[$i];
+ }
+ $troops_o+=$o_unit['hero'];
+ }
+ return $troops_o;
+ }
+
+ public function canConquerOasis($vref,$wref) {
+ $AttackerFields = $this->getResourceLevel($vref);
+ for($i=19;$i<=38;$i++) {
+ if($AttackerFields['f'.$i.'t'] == 37) { $HeroMansionLevel = $AttackerFields['f'.$i]; }
+ }
+ if($this->VillageOasisCount($vref) < floor(($HeroMansionLevel-5)/5)) {
+ $OasisInfo = $this->getOasisInfo($wref);
+ $troopcount = $this->countOasisTroops($wref);
+ if($OasisInfo['conqured'] == 0 || $OasisInfo['conqured'] != 0 && $OasisInfo['loyalty'] < 99 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured']))) && $troopcount == 0) {
+ $CoordsVillage = $this->getCoor($vref);
+ $CoordsOasis = $this->getCoor($wref);
+ if(abs($CoordsOasis['x']-$CoordsVillage['x'])<=3 && abs($CoordsOasis['y']-$CoordsVillage['y'])<=3) {
+ return True;
+ } else {
+ return False;
+ }
+ } else {
+ return False;
+ }
+ } else {
+ return False;
+ }
+ }
+
+
+
+ public function conquerOasis($vref,$wref) {
+ $vinfo = $this->getVillage($vref);
+ $uid = $vinfo['owner'];
+ $q = "UPDATE `".TB_PREFIX."odata` SET conqured=$vref,loyalty=100,lastupdated=".time().",owner=$uid,name='Occupied Oasis' WHERE wref=$wref";
+ return mysqli_query($this->connection, $q);
+ }
+
+ public function modifyOasisLoyalty($wref) {
+ if($this->isVillageOases($wref) != 0) {
+ $OasisInfo = $this->getOasisInfo($wref);
+ if($OasisInfo['conqured'] != 0) {
+ $LoyaltyAmendment = floor(100 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured']))));
+ $q = "UPDATE `".TB_PREFIX."odata` SET loyalty=loyalty-$LoyaltyAmendment WHERE wref=$wref";
+ return mysqli_query($this->connection, $q);
+ }
+ }
+ }
+
+ function populateOasis() {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0";
+ $result = mysqli_query($this->connection, $q);
+ while($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
+ $wid = $row['id'];
+
+ $this->addUnits($wid);
+
+ }
+ }
+
+ function populateOasisUnits($wid, $high) {
+ $basearray = $this->getMInfo($wid);
+ $basearray = $this->getOasisInfo($wid);
+ if($basearray2['high'] == 0){
+ $max = rand(15,30);
+ }elseif($basearray2['high'] == 1){
+ $max = rand(70,90);
+ }elseif($basearray2['high'] == 2){
+ $max = rand(100,140);
+ }
+ //each Troop is a Set for oasis type like mountains have rats spiders and snakes fields tigers elphants clay wolves so on stonger one more not so less
+ switch($basearray['oasistype']) {
+ case 1:
+ case 2:
+ //+25% lumber per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max.")";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 3:
+ //+25% lumber and +25% crop per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 4:
+ case 5:
+ //+25% clay per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max.")";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 6:
+ //+25% clay and +25% crop per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 7:
+ case 8:
+ //+25% iron per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max.")";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 9:
+ //+25% iron and +25% crop
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 10:
+ case 11:
+ //+25% crop per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 12:
+ //+50% crop per hour
+ $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ }
+ }
+
+ function populateOasisUnits2() {
+ $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0";
+ $result2 = mysqli_query($this->connection, $q2);
+ while($row = mysqli_fetch_array($result2, MYSQLI_BOTH)) {
+ $wid = $row['id'];
+ switch($row['oasistype']) {
+ case 1:
+ case 2:
+ //+25% lumber oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,10)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <= '10'";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 3:
+ //+25% lumber and +25% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(5,15)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u35 <= '10' AND u36 <= '10' AND u37 <='10'";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 4:
+ case 5:
+ //+25% clay oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <= '10'";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 6:
+ //+25% clay and +25% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u35 = u35 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u35 <='10'";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 7:
+ case 8:
+ //+25% iron oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u32 = u32 + '".rand(5,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <= '10'";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 9:
+ //+25% iron and +25% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(15,20)."', u32 = u32 + '".rand(10,15)."', u34 = u34 + '".rand(0,10)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u32 <= '10' AND u34 <='10'";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 10:
+ case 11:
+ //+25% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(5,15)."', u33 = u33 + '".rand(5,10)."', u37 = u37 + '".rand(0,10)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u37 <='10' AND u39 <='10'";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ case 12:
+ //+50% crop oasis
+ $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(10,15)."', u33 = u33 + '".rand(5,10)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND u31 <= '10' AND u33 <= '10' AND u38 <='10'AND u39 <='10'";
+ $result = mysqli_query($this->connection, $q);
+ break;
+ }
+ }
+ }
+
+ function removeOases($wref) {
+ $q = "UPDATE ".TB_PREFIX."odata SET conqured = 0, owner = 2, name = 'Unoccupied Oasis' WHERE wref = $wref";
+ return mysqli_query($this->connection, $q);
+ }
+
+
+ /***************************
+ Function to retrieve type of village via ID
+ References: Village ID
+ ***************************/
+ function getVillageType($wref) {
+ $q = "SELECT id, fieldtype FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['fieldtype'];
+ }
+
+
+
+ /*****************************************
+ Function to retrieve if is ocuped via ID
+ References: Village ID
+ *****************************************/
+ function getVillageState($wref) {
+ $q = "SELECT oasistype,occupied FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ if($dbarray['occupied'] != 0 || $dbarray['oasistype'] != 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function getProfileVillages($uid) {
+ $q = "SELECT capital,wref,name,pop,created from " . TB_PREFIX . "vdata where owner = $uid order by pop desc";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getProfileMedal($uid) {
+ $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "medal where userid = $uid and del = 0 order by id desc";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+
+ }
+
+ function getProfileMedalAlly($uid) {
+ $q = "SELECT id,categorie,plaats,week,img,points from " . TB_PREFIX . "allimedal where allyid = $uid and del = 0 order by id desc";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+
+ }
+
+ function getVillageID($uid) {
+ $q = "SELECT wref FROM " . TB_PREFIX . "vdata WHERE owner = $uid";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['wref'];
+ }
+
+
+ function getVillagesID($uid) {
+ $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC";
+ $result = mysqli_query($this->connection, $q);
+ $array = $this->mysqli_fetch_all($result);
+ $newarray = array();
+ for($i = 0; $i < count($array); $i++) {
+ array_push($newarray, $array[$i]['wref']);
+ }
+ return $newarray;
+ }
+
+ function getVillagesID2($uid) {
+ $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC";
+ $result = mysqli_query($this->connection, $q);
+ $array = $this->mysqli_fetch_all($result);
+ return $array;
+ }
+
+ function getVillage($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ public function getVillageBattleData($vid) {
+ $q = "SELECT u.id,u.tribe,v.capital,f.f40 AS wall FROM ".TB_PREFIX."users u,".TB_PREFIX."fdata f,".TB_PREFIX."vdata v WHERE u.id=v.owner AND f.vref=v.wref AND v.wref=".$vid;
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ public function getPopulation($uid) {
+ $q = "SELECT sum(pop) AS pop FROM ".TB_PREFIX."vdata WHERE owner=".$uid;
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['pop'];
+ }
+
+ function getOasisV($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function getMInfo($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "vdata ON " . TB_PREFIX . "vdata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function getOMInfo($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata left JOIN " . TB_PREFIX . "odata ON " . TB_PREFIX . "odata.wref = " . TB_PREFIX . "wdata.id where " . TB_PREFIX . "wdata.id = $id";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function getOasis($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getOasisInfo($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = $wid";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ function getVillageField($ref, $field) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "vdata where wref = $ref";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray[$field];
+
+ }
+
+ function getOasisField($ref, $field) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "odata where wref = $ref";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray[$field];
+ }
+
+ function setVillageField($ref, $field, $value) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set $field = '$value' where wref = $ref";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function setVillageLevel($ref, $field, $value) {
+ $q = "UPDATE " . TB_PREFIX . "fdata set " . $field . " = '" . $value . "' where vref = " . $ref . "";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getResourceLevel($vid) {
+ $q = "SELECT * from " . TB_PREFIX . "fdata where vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ function getAdminLog() {
+ $q = "SELECT id,user,log,time from " . TB_PREFIX . "admin_log where id != 0 ORDER BY id ASC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getCoor($wref) {
+ if ($wref !=""){
+ $q = "SELECT x,y FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+ }
+
+ function CheckForum($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function CountCat($id) {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where cat = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ return $row[0];
+ }
+
+ function LastTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' order by post_date";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function CheckLastTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function CheckLastPost($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function LastPost($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function CountTopic($id) {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where owner = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+
+ $qs = "SELECT count(id) FROM " . TB_PREFIX . "forum_topic where owner = '$id'";
+ $results = mysqli_query($qs, $this->connection);
+ $rows = mysqli_fetch_row($results);
+ return $row[0] + $rows[0];
+ }
+
+ function CountPost($id) {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "forum_post where topic = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ return $row[0];
+ }
+
+ function ForumCat($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_cat where alliance = '$id' ORDER BY id";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function ForumCatEdit($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_cat where id = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function ForumCatAlliance($id) {
+ $q = "SELECT alliance from " . TB_PREFIX . "forum_cat where id = $id";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['alliance'];
+ }
+
+ function ForumCatName($id) {
+ $q = "SELECT forum_name from " . TB_PREFIX . "forum_cat where id = $id";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['forum_name'];
+ }
+
+ function CheckCatTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function CheckResultEdit($alli) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_edit where alliance = '$alli'";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function CheckCloseTopic($id) {
+ $q = "SELECT close from " . TB_PREFIX . "forum_topic where id = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['close'];
+ }
+
+ function CheckEditRes($alli) {
+ $q = "SELECT result from " . TB_PREFIX . "forum_edit where alliance = '$alli'";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['result'];
+ }
+
+ function CreatResultEdit($alli, $result) {
+ $q = "INSERT into " . TB_PREFIX . "forum_edit values (0,'$alli','$result')";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function UpdateResultEdit($alli, $result) {
+ $date = time();
+ $q = "UPDATE " . TB_PREFIX . "forum_edit set result = '$result' where alliance = '$alli'";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getVillageType2($wref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['oasistype'];
+ }
+
+ function getVillageType3($wref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "wdata where id = $wref";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray;
+ }
+
+ function getFLData($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "farmlist where id = $id";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function checkVilExist($wref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = '$wref'";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function checkOasisExist($wref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "odata where wref = '$wref'";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function UpdateEditTopic($id, $title, $cat) {
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set title = '$title', cat = '$cat' where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function UpdateEditForum($id, $name, $des) {
+ $q = "UPDATE " . TB_PREFIX . "forum_cat set forum_name = '$name', forum_des = '$des' where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function StickTopic($id, $mode) {
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set stick = '$mode' where id = '$id'";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function ForumCatTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '' ORDER BY post_date desc";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function ForumCatTopicStick($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where cat = '$id' AND stick = '1' ORDER BY post_date desc";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function ShowTopic($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_topic where id = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function ShowPost($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_post where topic = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function ShowPostEdit($id) {
+ $q = "SELECT * from " . TB_PREFIX . "forum_post where id = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function CreatForum($owner, $alli, $name, $des, $area) {
+ $q = "INSERT into " . TB_PREFIX . "forum_cat values (0,'$owner','$alli','$name','$des','$area')";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function CreatTopic($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) {
+ $date = time();
+ $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','','$alliance','$player','$coor','$report')";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) {
+ $date = time();
+ $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function UpdatePostDate($id) {
+ $date = time();
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set post_date = '$date' where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function EditUpdateTopic($id, $post, $alliance, $player, $coor, $report) {
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function EditUpdatePost($id, $post, $alliance, $player, $coor, $report) {
+ $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function LockTopic($id, $mode) {
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set close = '$mode' where id = '$id'";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function DeleteCat($id) {
+ $qs = "DELETE from " . TB_PREFIX . "forum_cat where id = '$id'";
+ $q = "DELETE from " . TB_PREFIX . "forum_topic where cat = '$id'";
+ mysqli_query($qs, $this->connection);
+ return mysqli_query($this->connection, $q);
+ }
+
+ function DeleteTopic($id) {
+ $qs = "DELETE from " . TB_PREFIX . "forum_topic where id = '$id'";
+ // $q = "DELETE from ".TB_PREFIX."forum_post where topic = '$id'";//
+ return mysqli_query($qs, $this->connection); //
+ // mysqli_query($q,$this->connection);
+ }
+
+ function DeletePost($id) {
+ $q = "DELETE from " . TB_PREFIX . "forum_post where id = '$id'";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getAllianceName($id) {
+ $q = "SELECT tag from " . TB_PREFIX . "alidata where id = $id";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['tag'];
+ }
+
+ function getAlliancePermission($ref, $field, $mode) {
+ if(!$mode) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where uid = '$ref'";
+ } else {
+ $q = "SELECT $field FROM " . TB_PREFIX . "ali_permission where username = '$ref'";
+ }
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray[$field];
+ }
+
+ function getAlliance($id) {
+ $q = "SELECT * from " . TB_PREFIX . "alidata where id = $id";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ function setAlliName($aid, $name, $tag) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set name = '$name', tag = '$tag' where id = $aid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function isAllianceOwner($id) {
+ $q = "SELECT * from " . TB_PREFIX . "alidata where leader = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function aExist($ref, $type) {
+ $q = "SELECT $type FROM " . TB_PREFIX . "alidata where $type = '$ref'";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function modifyPoints($aid, $points, $amt) {
+ $q = "UPDATE " . TB_PREFIX . "users set $points = $points + $amt where id = $aid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function modifyPointsAlly($aid, $points, $amt) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set $points = $points + $amt where id = $aid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ /*****************************************
+ Function to create an alliance
+ References:
+ *****************************************/
+ function createAlliance($tag, $name, $uid, $max) {
+ $q = "INSERT into " . TB_PREFIX . "alidata values (0,'$name','$tag',$uid,0,0,0,'','',$max,'','','','','','','','','')";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function procAllyPop($aid) {
+ $ally = $this->getAlliance($aid);
+ $memberlist = $this->getAllMember($ally['id']);
+ $oldrank = 0;
+ foreach($memberlist as $member) {
+ $oldrank += $this->getVSumField($member['id'],"pop");
+ }
+ if($ally['oldrank'] != $oldrank){
+ if($ally['oldrank'] < $oldrank) {
+ $totalpoints = $oldrank - $ally['oldrank'];
+ $this->addclimberrankpopAlly($ally['id'], $totalpoints);
+ $this->updateoldrankAlly($ally['id'], $oldrank);
+ } else
+ if($ally['oldrank'] > $oldrank) {
+ $totalpoints = $ally['oldrank'] - $oldrank;
+ $this->removeclimberrankpopAlly($ally['id'], $totalpoints);
+ $this->updateoldrankAlly($ally['id'], $oldrank);
+ }
+ }
+ }
+
+ /*****************************************
+ Function to insert an alliance new
+ References:
+ *****************************************/
+ function insertAlliNotice($aid, $notice) {
+ $time = time();
+ $q = "INSERT into " . TB_PREFIX . "ali_log values (0,'$aid','$notice',$time)";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ /*****************************************
+ Function to delete alliance if empty
+ References:
+ *****************************************/
+ function deleteAlliance($aid) {
+ $result = mysqli_query("SELECT * FROM " . TB_PREFIX . "users where alliance = $aid");
+ $num_rows = mysqli_num_rows($result);
+ if($num_rows == 0) {
+ $q = "DELETE FROM " . TB_PREFIX . "alidata WHERE id = $aid";
+ }
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ /*****************************************
+ Function to read all alliance news
+ References:
+ *****************************************/
+ function readAlliNotice($aid) {
+ $q = "SELECT * from " . TB_PREFIX . "ali_log where aid = $aid ORDER BY date DESC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ /*****************************************
+ Function to create alliance permissions
+ References: ID, notice, description
+ *****************************************/
+ function createAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8) {
+
+ $q = "INSERT into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ /*****************************************
+ Function to update alliance permissions
+ References:
+ *****************************************/
+ function deleteAlliPermissions($uid) {
+ $q = "DELETE from " . TB_PREFIX . "ali_permission where uid = '$uid'";
+ return mysqli_query($this->connection, $q);
+ }
+ /*****************************************
+ Function to update alliance permissions
+ References:
+ *****************************************/
+ function updateAlliPermissions($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7) {
+
+ $q = "UPDATE " . TB_PREFIX . "ali_permission SET rank = '$rank', opt1 = '$opt1', opt2 = '$opt2', opt3 = '$opt3', opt4 = '$opt4', opt5 = '$opt5', opt6 = '$opt6', opt7 = '$opt7' where uid = $uid && alliance =$aid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ /*****************************************
+ Function to read alliance permissions
+ References: ID, notice, description
+ *****************************************/
+ function getAlliPermissions($uid, $aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ali_permission where uid = $uid && alliance = $aid";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ /*****************************************
+ Function to update an alliance description and notice
+ References: ID, notice, description
+ *****************************************/
+ function submitAlliProfile($aid, $notice, $desc) {
+
+ $q = "UPDATE " . TB_PREFIX . "alidata SET `notice` = '$notice', `desc` = '$desc' where id = $aid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function diplomacyInviteAdd($alli1, $alli2, $type) {
+ $q = "INSERT INTO " . TB_PREFIX . "diplomacy (alli1,alli2,type,accepted) VALUES ($alli1,$alli2," . (int)intval($type) . ",0)";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function diplomacyOwnOffers($session_alliance) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 0";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getAllianceID($name) {
+ $q = "SELECT id FROM " . TB_PREFIX . "alidata WHERE tag ='" . $this->RemoveXSS($name) . "'";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['id'];
+ }
+
+ function getDiplomacy($aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE id = $aid";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function diplomacyCancelOffer($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function diplomacyInviteAccept($id, $session_alliance) {
+ $q = "UPDATE " . TB_PREFIX . "diplomacy SET accepted = 1 WHERE id = $id AND alli2 = $session_alliance";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function diplomacyInviteDenied($id, $session_alliance) {
+ $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function diplomacyInviteCheck($session_alliance) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 0";
+ $result = mysql_query($this->connection, $q);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function diplomacyInviteCheck2($ally1, $ally2) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $ally1 AND alli2 = $ally2 accepted = 0";
+ $result = mysql_query($this->connection, $q);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getAllianceDipProfile($aid, $type){
+ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '$type' AND accepted = '1' OR alli2 = '$aid' AND type = '$type' AND accepted = '1'";
+ $array = $this->query_return($q);
+ foreach($array as $row){
+ if($row['alli1'] == $aid){
+ $alliance = $this->getAlliance($row['alli2']);
+ }elseif($row['alli2'] == $aid){
+ $alliance = $this->getAlliance($row['alli1']);
+ }
+ $text .= "";
+ $text .= "".$alliance['tag']."
";
+ }
+ if(strlen($text) == 0){
+ $text = "-
";
+ }
+ return $text;
+ }
+
+ function getAllianceWar($aid){
+ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'";
+ $array = $this->query_return($q);
+ foreach($array as $row){
+ if($row['alli1'] == $aid){
+ $alliance = $this->getAlliance($row['alli2']);
+ }elseif($row['alli2'] == $aid){
+ $alliance = $this->getAlliance($row['alli1']);
+ }
+ $text .= "";
+ $text .= "".$alliance['tag']."
";
+ }
+ if(strlen($text) == 0){
+ $text = "-
";
+ }
+ return $text;
+ }
+
+ function getAllianceAlly($aid, $type){
+ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE (alli1 = '$aid' or alli2 = '$aid') AND (type = '$type' AND accepted = '1')";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getAllianceWar2($aid){
+ $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function diplomacyExistingRelationships($session_alliance) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 1";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function diplomacyExistingRelationships2($session_alliance) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $session_alliance AND accepted = 1";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function diplomacyCancelExistingRelationship($id, $session_alliance) {
+ $q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance OR id = $id AND alli1 = $session_alliance";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function checkDiplomacyInviteAccept($aid, $type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $aid AND type = $type AND accepted = 1 OR alli2 = $aid AND type = $type AND accepted = 1";
+ $result = mysqli_query($this->connection, $q);
+ if($type == 3){
+ return true;
+ }else{
+ if(mysqli_num_rows($result) < 4) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ function setAlliForumLink($aid, $link) {
+ $q = "UPDATE " . TB_PREFIX . "alidata SET `forumlink` = '$link' WHERE id = $aid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getUserAlliance($id) {
+ $q = "SELECT " . TB_PREFIX . "alidata.tag from " . TB_PREFIX . "users join " . TB_PREFIX . "alidata where " . TB_PREFIX . "users.alliance = " . TB_PREFIX . "alidata.id and " . TB_PREFIX . "users.id = $id";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ if($dbarray['tag'] == "") {
+ return "-";
+ } else {
+ return $dbarray['tag'];
+ }
+ }
+
+ function modifyResource($vid, $wood, $clay, $iron, $crop, $mode) {
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set wood = wood - $wood, clay = clay - $clay, iron = iron - $iron, crop = crop - $crop where wref = $vid";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "vdata set wood = wood + $wood, clay = clay + $clay, iron = iron + $iron, crop = crop + $crop where wref = $vid";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function modifyOasisResource($vid, $wood, $clay, $iron, $crop, $mode) {
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "odata set wood = wood - $wood, clay = clay - $clay, iron = iron - $iron, crop = crop - $crop where wref = $vid";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "odata set wood = wood + $wood, clay = clay + $clay, iron = iron + $iron, crop = crop + $crop where wref = $vid";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getFieldLevel($vid, $field) {
+ $q = "SELECT f" . $field . " from " . TB_PREFIX . "fdata where vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return mysql_result($result, 0);
+ }
+
+ function getFieldType($vid, $field) {
+ $q = "SELECT f" . $field . "t from " . TB_PREFIX . "fdata where vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return mysql_result($result, 0);
+ }
+
+ function getVSumField($uid, $field) {
+ if($field != "cp"){
+ $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid";
+ }else{
+ $q = "SELECT sum(" . $field . ") FROM " . TB_PREFIX . "vdata where owner = $uid and natar = 0";
+ }
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ return $row[0];
+ }
+
+ function updateVillage($vid) {
+ $time = time();
+ $q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid";
+ return mysqli_query($this->connection, $q);
+ }
+ function updateOasis($vid) {
+ $time = time();
+ $q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid";
+ return mysqli_query($this->connection, $q);
+ }
+
+
+ function setVillageName($vid, $name) {
+ if(!empty($name))
+ {
+ $q = "UPDATE " . TB_PREFIX . "vdata set name = '$name' where wref = $vid";
+ return mysqli_query($this->connection, $q);
+ }
+ }
+
+ function modifyPop($vid, $pop, $mode) {
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop + $pop where wref = $vid";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "vdata set pop = pop - $pop where wref = $vid";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addCP($ref, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set cp = cp + $cp where wref = $ref";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addCel($ref, $cel, $type) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set celebration = $cel, type= $type where wref = $ref";
+ return mysqli_query($this->connection, $q);
+ }
+ function getCel() {
+ $time = time();
+ $q = "SELECT * FROM " . TB_PREFIX . "vdata where celebration < $time AND celebration != 0";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function clearCel($ref) {
+ $q = "UPDATE " . TB_PREFIX . "vdata set celebration = 0, type = 0 where wref = $ref";
+ return mysqli_query($this->connection, $q);
+ }
+ function setCelCp($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set cp = cp + $cp where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function clearExpansionSlot($id) {
+ for($i = 1; $i <= 3; $i++) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET exp" . $i . "=0 WHERE exp" . $i . "=" . $id;
+ mysqli_query($this->connection, $q);
+ }
+ }
+
+ function getInvitation($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getInvitation2($uid, $aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where uid = $uid and alliance = $aid";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getAliInvitations($aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ali_invite where alliance = $aid && accept = 0";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function sendInvitation($uid, $alli, $sender) {
+ $time = time();
+ $q = "INSERT INTO " . TB_PREFIX . "ali_invite values (0,$uid,$alli,$sender,$time,0)";
+ return mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ }
+
+ function removeInvitation($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "ali_invite where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function sendMessage($client, $owner, $topic, $message, $send, $alliance, $player, $coor, $report) {
+ $time = time();
+ $q = "INSERT INTO " . TB_PREFIX . "mdata values (0,$client,$owner,'$topic',\"$message\",0,0,$send,$time,0,0,$alliance,$player,$coor,$report)";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function setArchived($id) {
+ $q = "UPDATE " . TB_PREFIX . "mdata set archived = 1 where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function setNorm($id) {
+ $q = "UPDATE " . TB_PREFIX . "mdata set archived = 0 where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ /***************************
+ Function to get messages
+ Mode 1: Get inbox
+ Mode 2: Get sent
+ Mode 3: Get message
+ Mode 4: Set viewed
+ Mode 5: Remove message
+ Mode 6: Retrieve archive
+ References: User ID/Message ID, Mode
+ ***************************/
+ function getMessage($id, $mode) {
+ global $session;
+ switch($mode) {
+ case 1:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 ORDER BY time DESC";
+ break;
+ case 2:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id ORDER BY time DESC";
+ break;
+ case 3:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata where id = $id";
+ break;
+ case 4:
+ $q = "UPDATE " . TB_PREFIX . "mdata set viewed = 1 where id = $id AND target = $session->uid";
+ break;
+ case 5:
+ $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,viewed = 1 where id = $id";
+ break;
+ case 6:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1";
+ break;
+ case 7:
+ $q = "UPDATE " . TB_PREFIX . "mdata set delowner = 1 where id = $id";
+ break;
+ case 8:
+ $q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,delowner = 1,viewed = 1 where id = $id";
+ break;
+ case 9:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $id and send = 0 and archived = 0 and deltarget = 0 ORDER BY time DESC";
+ break;
+ case 10:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $id and delowner = 0 ORDER BY time DESC";
+ break;
+ case 11:
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata where target = $id and send = 0 and archived = 1 and deltarget = 0";
+ break;
+ }
+ if($mode <= 3 || $mode == 6 || $mode > 8) {
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ } else {
+ return mysqli_query($this->connection, $q);
+ }
+ }
+
+ function getDelSent($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner = $uid and delowner = 1 ORDER BY time DESC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getDelInbox($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and deltarget = 1 ORDER BY time DESC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getDelArchive($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target = $uid and archived = 1 and deltarget = 1 OR owner = $uid and archived = 1 and delowner = 1 ORDER BY time DESC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function unarchiveNotice($id) {
+ $q = "UPDATE " . TB_PREFIX . "ndata set ntype = archive, archive = 0 where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function archiveNotice($id) {
+ $q = "update " . TB_PREFIX . "ndata set archive = ntype, ntype = 9 where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function removeNotice($id) {
+ $q = "UPDATE " . TB_PREFIX . "ndata set del = 1,viewed = 1 where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function noticeViewed($id) {
+ $q = "UPDATE " . TB_PREFIX . "ndata set viewed = 1 where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addNotice($uid, $wref, $aid, $type, $topic, $data, $time = 0) {
+ if($time == 0) {
+ $time = time();
+ }
+ $q = "INSERT INTO " . TB_PREFIX . "ndata (id, uid, toWref, ally, topic, ntype, data, time, viewed) values (0,'$uid','$wref','$aid','$topic',$type,'$data',$time,0)";
+ return mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ }
+
+ function getNotice($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 0 ORDER BY time DESC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getNotice2($id, $field) {
+ $q = "SELECT ".$field." FROM " . TB_PREFIX . "ndata where `id` = '$id'";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray[$field];
+ }
+
+ function getNotice3($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time DESC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getNotice4($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "ndata where id = $id ORDER BY time DESC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function createTradeRoute($uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time) {
+ $x = "UPDATE " . TB_PREFIX . "users SET gold = gold - 2 WHERE id = ".$uid."";
+ mysqli_query($x, $this->connection);
+ $timeleft = time()+604800;
+ $q = "INSERT into " . TB_PREFIX . "route values (0,$uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time,$timeleft)";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getTradeRoute($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "route where uid = $uid ORDER BY timestamp ASC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getTradeRoute2($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray;
+ }
+
+ function getTradeRouteUid($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['uid'];
+ }
+
+ function editTradeRoute($id,$column,$value,$mode) {
+ if(!$mode){
+ $q = "UPDATE " . TB_PREFIX . "route set $column = $value where id = $id";
+ }else{
+ $q = "UPDATE " . TB_PREFIX . "route set $column = $column + $value where id = $id";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function deleteTradeRoute($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "route where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addBuilding($wid, $field, $type, $loop, $time, $master, $level) {
+ $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $field . "t=" . $type . " WHERE vref=" . $wid;
+ mysqli_query($x, $this->connection) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $q = "INSERT into " . TB_PREFIX . "bdata values (0,$wid,$field,$type,$loop,$time,$master,$level)";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function removeBuilding($d) {
+ global $building;
+ $jobLoopconID = -1;
+ $SameBuildCount = 0;
+ $jobs = $building->buildArray;
+ for($i = 0; $i < sizeof($jobs); $i++) {
+ if($jobs[$i]['id'] == $d) {
+ $jobDeleted = $i;
+ }
+ if($jobs[$i]['loopcon'] == 1) {
+ $jobLoopconID = $i;
+ }
+ if($jobs[$i]['master'] == 1) {
+ $jobMaster = $i;
+ }
+ }
+ if(count($jobs) > 1 && ($jobs[0]['field'] == $jobs[1]['field'])) {
+ $SameBuildCount = 1;
+ }
+ if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[2]['field'])) {
+ $SameBuildCount = 2;
+ }
+ if(count($jobs) > 2 && ($jobs[1]['field'] == $jobs[2]['field'])) {
+ $SameBuildCount = 3;
+ }
+ if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 8;
+ }
+ if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 9;
+ }
+ if(count($jobs) > 3 && ($jobs[2]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 10;
+ }
+ if(count($jobs) > 2 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[2]['field'])) {
+ $SameBuildCount = 4;
+ }
+ if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[1]['field'] && $jobs[1]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 5;
+ }
+ if(count($jobs) > 3 && ($jobs[0]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 6;
+ }
+ if(count($jobs) > 3 && ($jobs[1]['field'] == $jobs[2]['field'] && $jobs[2]['field'] == $jobs[3]['field'])) {
+ $SameBuildCount = 7;
+ }
+ if($SameBuildCount > 0) {
+ if($SameBuildCount > 3){
+ if($SameBuildCount == 4 or $SameBuildCount == 5){
+ if($jobDeleted == 0){
+ $uprequire = $building->resourceRequired($jobs[1]['field'],$jobs[1]['type'],1);
+ $time = $uprequire['time'];
+ $timestamp = $time+time();
+ $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[1]['id']."";
+ mysqli_query($this->connection, $q);
+ }
+ }else if($SameBuildCount == 6){
+ if($jobDeleted == 0){
+ $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1);
+ $time = $uprequire['time'];
+ $timestamp = $time+time();
+ $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id']."";
+ mysqli_query($this->connection, $q);
+ }
+ }else if($SameBuildCount == 7){
+ if($jobDeleted == 1){
+ $uprequire = $building->resourceRequired($jobs[2]['field'],$jobs[2]['type'],1);
+ $time = $uprequire['time'];
+ $timestamp = $time+time();
+ $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=".$timestamp." WHERE id=".$jobs[2]['id']."";
+ mysqli_query($this->connection, $q);
+ }
+ }
+ if($SameBuildCount < 8){
+ $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],2);
+ $time1 = $uprequire1['time'];
+ $timestamp1 = $time1;
+ $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id']."";
+ mysqli_query($q1, $this->connection);
+ }else{
+ $uprequire1 = $building->resourceRequired($jobs[$jobMaster]['field'],$jobs[$jobMaster]['type'],1);
+ $time1 = $uprequire1['time'];
+ $timestamp1 = $time1;
+ $q1 = "UPDATE " . TB_PREFIX . "bdata SET level=level-1,timestamp=".$timestamp1." WHERE id=".$jobs[$jobMaster]['id']."";
+ mysqli_query($q1, $this->connection);
+ }
+ }else if($d == $jobs[floor($SameBuildCount / 3)]['id'] || $d == $jobs[floor($SameBuildCount / 2) + 1]['id']) {
+ $q = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,level=level-1,timestamp=" . $jobs[floor($SameBuildCount / 3)]['timestamp'] . " WHERE master = 0 AND id > ".$d." and (ID=" . $jobs[floor($SameBuildCount / 3)]['id'] . " OR ID=" . $jobs[floor($SameBuildCount / 2) + 1]['id'] . ")";
+ mysqli_query($this->connection, $q);
+ }
+ } else {
+ if($jobs[$jobDeleted]['field'] >= 19) {
+ $x = "SELECT f" . $jobs[$jobDeleted]['field'] . " FROM " . TB_PREFIX . "fdata WHERE vref=" . $jobs[$jobDeleted]['wid'];
+ $result = mysqli_query($x, $this->connection) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $fieldlevel = mysqli_fetch_row($result);
+ if($fieldlevel[0] == 0) {
+ $x = "UPDATE " . TB_PREFIX . "fdata SET f" . $jobs[$jobDeleted]['field'] . "t=0 WHERE vref=" . $jobs[$jobDeleted]['wid'];
+ mysqli_query($x, $this->connection) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ }
+ }
+ if(($jobLoopconID >= 0) && ($jobs[$jobDeleted]['loopcon'] != 1)) {
+ if(($jobs[$jobLoopconID]['field'] <= 18 && $jobs[$jobDeleted]['field'] <= 18) || ($jobs[$jobLoopconID]['field'] >= 19 && $jobs[$jobDeleted]['field'] >= 19) || sizeof($jobs) < 3) {
+ $uprequire = $building->resourceRequired($jobs[$jobLoopconID]['field'], $jobs[$jobLoopconID]['type']);
+ $x = "UPDATE " . TB_PREFIX . "bdata SET loopcon=0,timestamp=" . (time() + $uprequire['time']) . " WHERE wid=" . $jobs[$jobDeleted]['wid'] . " AND loopcon=1 AND master=0";
+ mysqli_query($x, $this->connection) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ }
+ }
+ }
+ $q = "DELETE FROM " . TB_PREFIX . "bdata where id = $d";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addDemolition($wid, $field) {
+ global $building, $village;
+ $q = "DELETE FROM ".TB_PREFIX."bdata WHERE field=$field AND wid=$wid";
+ mysqli_query($this->connection, $q);
+ $uprequire = $building->resourceRequired($field,$village->resarray['f'.$field.'t'],0);
+ $q = "INSERT INTO ".TB_PREFIX."demolition VALUES (".$wid.",".$field.",".($this->getFieldLevel($wid,$field)-1).",".(time()+floor($uprequire['time']/2)).")";
+ return mysqli_query($this->connection, $q);
+ }
+
+
+ function getDemolition($wid = 0) {
+ if($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid;
+ } else {
+ $q = "SELECT * FROM " . TB_PREFIX . "demolition WHERE timetofinish<=" . time();
+ }
+ $result = mysqli_query($this->connection, $q);
+ if(!empty($result)) {
+ return $this->mysqli_fetch_all($result);
+ } else {
+ return NULL;
+ }
+ }
+
+ function finishDemolition($wid) {
+ $q = "UPDATE " . TB_PREFIX . "demolition SET timetofinish=" . time() . " WHERE vref=" . $wid;
+ return mysqli_query($this->connection, $q);
+ }
+
+ function delDemolition($wid) {
+ $q = "DELETE FROM " . TB_PREFIX . "demolition WHERE vref=" . $wid;
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getJobs($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid order by master,timestamp ASC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function FinishWoodcutter($wid) {
+ $time = time()-1;
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = 1 order by master,timestamp ASC";
+ $result = mysqli_query($q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ $q = "UPDATE ".TB_PREFIX."bdata SET timestamp = $time WHERE id = '".$dbarray['id']."'";
+ $this->query($q);
+ $q2 = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and loopcon = 1 and field <= 18 order by master,timestamp ASC";
+ if(mysqli_num_rows($q2) > 0){
+ $result2 = mysqli_query($q2);
+ $dbarray2 = mysql_fetch_array($result2);
+ $wc_time = $dbarray['timestamp'];
+ $q2 = "UPDATE ".TB_PREFIX."bdata SET timestamp = timestamp - $wc_time WHERE id = '".$dbarray2['id']."'";
+ $this->query($q2);
+ }
+ }
+
+ function getMasterJobs($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and master = 1 order by master,timestamp ASC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getMasterJobsByField($wid,$field) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 1 order by master,timestamp ASC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getBuildingByField($wid,$field) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getBuildingByField2($wid,$field) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field = $field and master = 0";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_num_rows($result);
+ }
+
+ function getBuildingByType($wid,$type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getBuildingByType2($wid,$type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and type = $type and master = 0";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_num_rows($result);
+ }
+
+ function getDorf1Building($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field < 19 and master = 0";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getDorf2Building($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid and field > 18 and master = 0";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function updateBuildingWithMaster($id, $time,$loop) {
+ $q = "UPDATE " . TB_PREFIX . "bdata SET master = 0, timestamp = ".$time.",loopcon = ".$loop." WHERE id = ".$id."";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getVillageByName($name) {
+ $q = "SELECT wref FROM " . TB_PREFIX . "vdata where name = '$name' limit 1";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['wref'];
+ }
+
+ /***************************
+ Function to set accept flag on market
+ References: id
+ ***************************/
+ function setMarketAcc($id) {
+ $q = "UPDATE " . TB_PREFIX . "market set accept = 1 where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ /***************************
+ Function to send resource to other village
+ Mode 0: Send
+ Mode 1: Cancel
+ References: Wood/ID, Clay, Iron, Crop, Mode
+ ***************************/
+ function sendResource($ref, $clay, $iron, $crop, $merchant, $mode) {
+ if(!$mode) {
+ $q = "INSERT INTO " . TB_PREFIX . "send values (0,$ref,$clay,$iron,$crop,$merchant)";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "send where id = $ref";
+ return mysqli_query($this->connection, $q);
+ }
+ }
+
+ /***************************
+ Function to get resources back if you delete offer
+ References: VillageRef (vref)
+ Made by: Dzoki
+ ***************************/
+
+ function getResourcesBack($vref, $gtype, $gamt) {
+ //Xtype (1) = wood, (2) = clay, (3) = iron, (4) = crop
+ if($gtype == 1) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` + '$gamt' WHERE wref = $vref";
+ return mysqli_query($this->connection, $q);
+ } else
+ if($gtype == 2) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` + '$gamt' WHERE wref = $vref";
+ return mysqli_query($this->connection, $q);
+ } else
+ if($gtype == 3) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` + '$gamt' WHERE wref = $vref";
+ return mysqli_query($this->connection, $q);
+ } else
+ if($gtype == 4) {
+ $q = "UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` + '$gamt' WHERE wref = $vref";
+ return mysqli_query($this->connection, $q);
+ }
+ }
+
+ /***************************
+ Function to get info about offered resources
+ References: VillageRef (vref)
+ Made by: Dzoki
+ ***************************/
+
+ function getMarketField($vref, $field) {
+ $q = "SELECT $field FROM " . TB_PREFIX . "market where vref = '$vref'";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray[$field];
+ }
+
+ function removeAcceptedOffer($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "market where id = $id";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ /***************************
+ Function to add market offer
+ Mode 0: Add
+ Mode 1: Cancel
+ References: Village, Give, Amt, Want, Amt, Time, Alliance, Mode
+ ***************************/
+ function addMarket($vid, $gtype, $gamt, $wtype, $wamt, $time, $alliance, $merchant, $mode) {
+ if(!$mode) {
+ $q = "INSERT INTO " . TB_PREFIX . "market values (0,$vid,$gtype,$gamt,$wtype,$wamt,0,$time,$alliance,$merchant)";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "market where id = $gtype and vref = $vid";
+ return mysqli_query($this->connection, $q);
+ }
+ }
+
+ /***************************
+ Function to get market offer
+ References: Village, Mode
+ ***************************/
+ function getMarket($vid, $mode) {
+ $alliance = $this->getUserField($this->getVillageField($vid, "owner"), "alliance", 0);
+ if(!$mode) {
+ $q = "SELECT * FROM " . TB_PREFIX . "market where vref = $vid and accept = 0";
+ } else {
+ $q = "SELECT * FROM " . TB_PREFIX . "market where vref != $vid and alliance = $alliance or vref != $vid and alliance = 0 and accept = 0";
+ }
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ /***************************
+ Function to get market offer
+ References: ID
+ ***************************/
+ function getMarketInfo($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "market where id = $id";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ function setMovementProc($moveid) {
+ $q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where moveid = $moveid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ /***************************
+ Function to retrieve used merchant
+ References: Village
+ ***************************/
+ function totalMerchantUsed($vid) {
+ $time = time();
+ $q = "SELECT sum(" . TB_PREFIX . "send.merchant) from " . TB_PREFIX . "send, " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.from = $vid and " . TB_PREFIX . "send.id = " . TB_PREFIX . "movement.ref and " . TB_PREFIX . "movement.proc = 0 and sort_type = 0";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ $q2 = "SELECT sum(ref) from " . TB_PREFIX . "movement where sort_type = 2 and " . TB_PREFIX . "movement.to = $vid and proc = 0";
+ $result2 = mysqli_query($this->connection, $q2);
+ $row2 = mysqli_fetch_row($result2);
+ $q3 = "SELECT sum(merchant) from " . TB_PREFIX . "market where vref = $vid and accept = 0";
+ $result3 = mysqli_query($q3, $this->connection);
+ $row3 = mysqli_fetch_row($result3);
+ return $row[0] + $row2[0] + $row3[0];
+ }
+
+ function getMovement($type, $village, $mode) {
+ $time = time();
+ if(!$mode) {
+ $where = "from";
+ } else {
+ $where = "to";
+ }
+ switch($type) {
+ case 0:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 0 ORDER BY endtime ASC";
+ break;
+ case 1:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 6 ORDER BY endtime ASC";
+ break;
+ case 2:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 2 ORDER BY endtime ASC";
+ break;
+ case 3:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
+ break;
+ case 4:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
+ break;
+ case 5:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 5 and proc = 0 ORDER BY endtime ASC";
+ break;
+ case 6:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured = $village and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
+ break;
+ case 7:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC";
+ break;
+ case 8:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC";
+ break;
+ case 34:
+ $q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
+ break;
+ }
+ $result = mysqli_query($this->connection, $q);
+ $array = $this->mysqli_fetch_all($result);
+ return $array;
+ }
+
+ function addA2b($ckey, $timestamp, $to, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type) {
+ $q = "INSERT INTO " . TB_PREFIX . "a2b (ckey,time_check,to_vid,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,type) VALUES ('$ckey', '$timestamp', '$to', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10', '$t11', '$type')";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function getA2b($ckey, $check) {
+ $q = "SELECT * from " . TB_PREFIX . "a2b where ckey = '" . $ckey . "' AND time_check = '" . $check . "'";
+ $result = mysqli_query($this->connection, $q);
+ if($result) {
+ return mysqli_fetch_assoc($result);
+ } else {
+ return false;
+ }
+ }
+
+ function addMovement($type, $from, $to, $ref, $time, $endtime, $send = 1, $wood = 0, $clay = 0, $iron = 0, $crop = 0, $ref2 = 0) {
+ $q = "INSERT INTO " . TB_PREFIX . "movement values (0,$type,$from,$to,$ref,$ref2,$time,$endtime,0,$send,$wood,$clay,$iron,$crop)";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addAttack($vid, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type, $ctar1, $ctar2, $spy,$b1=0,$b2=0,$b3=0,$b4=0,$b5=0,$b6=0,$b7=0,$b8=0) {
+ $q = "INSERT INTO " . TB_PREFIX . "attacks values (0,$vid,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$type,$ctar1,$ctar2,$spy,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8)";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function modifyAttack($aid, $unit, $amt) {
+ $unit = 't' . $unit;
+ $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit - $amt where id = $aid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function modifyAttack2($aid, $unit, $amt) {
+ $unit = 't' . $unit;
+ $q = "UPDATE " . TB_PREFIX . "attacks set $unit = $unit + $amt where id = $aid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getRanking() {
+ $q = "SELECT id,username,alliance,ap,apall,dp,dpall,access FROM " . TB_PREFIX . "users WHERE tribe<=3 AND access<" . (INCLUDE_ADMIN ? "10" : "8");
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getVRanking() {
+ $q = "SELECT v.wref,v.name,v.owner,v.pop FROM " . TB_PREFIX . "vdata AS v," . TB_PREFIX . "users AS u WHERE v.owner=u.id AND u.tribe<=3 AND v.wref != '' AND u.access<" . (INCLUDE_ADMIN ? "10" : "8");
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getARanking() {
+ $q = "SELECT id,name,tag,oldrank,Aap,Adp FROM " . TB_PREFIX . "alidata where id != '' ORDER BY id DESC";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getUserByTribe($tribe){
+ $q = "SELECT * FROM " . TB_PREFIX . "users where tribe = $tribe";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getUserByAlliance($aid){
+ $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getHeroRanking() {
+ $q = "SELECT * FROM " . TB_PREFIX . "hero WHERE dead = 0";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getAllMember($aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getAllMember2($aid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc LIMIT 1";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function addUnits($vid) {
+ $q = "INSERT into " . TB_PREFIX . "units (vref) values ($vid)";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getUnit($vid) {
+ $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ if (!empty($result)) {
+ return mysqli_fetch_assoc($result);
+ } else {
+ return NULL;
+ }
+ }
+
+ function getUnitsNumber($vid) {
+ $q = "SELECT * from " . TB_PREFIX . "units where vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_assoc($result);
+ $totalunits = 0;
+ $movingunits = $this->getVillageMovement($vid);
+ for($i=1;$i<=50;$i++){
+ $totalunits += $dbarray['u'.$i];
+ }
+ $totalunits += $dbarray['hero'];
+ $movingunits = $this->getVillageMovement($vid);
+ $reinforcingunits = $this->getEnforceArray($vid,1);
+ $owner = $this->getVillageField($vid,"owner");
+ $ownertribe = $this->getUserField($owner,"tribe",0);
+ $start = ($ownertribe-1)*10+1;
+ $end = ($ownertribe*10);
+ for($i=$start;$i<=$end;$i++){
+ $totalunits += $movingunits['u'.$i];
+ $totalunits += $reinforcingunits['u'.$i];
+ }
+ $totalunits += $movingunits['hero'];
+ $totalunits += $reinforcingunits['hero'];
+ return $totalunits;
+ }
+
+ function getHero($uid=0,$all=0) {
+ if ($all) {
+ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid=$uid";
+ } elseif (!$uid) {
+ $q = "SELECT * FROM ".TB_PREFIX."hero";
+ } else {
+ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE dead=0 AND uid=$uid LIMIT 1";
+ }
+ $result = mysqli_query($this->connection, $q);
+ if (!empty($result)) {
+ return $this->mysqli_fetch_all($result);
+ } else {
+ return NULL;
+ }
+ }
+
+ function getHeroField($uid,$field){
+ $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = $uid";
+ $result = mysqli_query($q,$this->connection);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function modifyHero($column,$value,$heroid,$mode=0) {
+ if(!$mode) {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE heroid = $heroid";
+ } elseif($mode=1) {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE heroid = $heroid";
+ } else {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE heroid = $heroid";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function modifyHeroByOwner($column,$value,$uid,$mode=0) {
+ if(!$mode) {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $value WHERE uid = $uid";
+ } elseif($mode=1) {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + $value WHERE uid = $uid";
+ } else {
+ $q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - $value WHERE uid = $uid";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function modifyHeroXp($column,$value,$heroid) {
+ $q = "UPDATE ".TB_PREFIX."hero SET $column = $column + $value WHERE uid=$heroid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addTech($vid) {
+ $q = "INSERT into " . TB_PREFIX . "tdata (vref) values ($vid)";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addABTech($vid) {
+ $q = "INSERT into " . TB_PREFIX . "abdata (vref) values ($vid)";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getABTech($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "abdata where vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ function addResearch($vid, $tech, $time) {
+ $q = "INSERT into " . TB_PREFIX . "research values (0,$vid,'$tech',$time)";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getResearching($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "research where vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function checkIfResearched($vref, $unit) {
+ $q = "SELECT $unit FROM " . TB_PREFIX . "tdata WHERE vref = $vref";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray[$unit];
+ }
+
+ function getTech($vid) {
+ $q = "SELECT * from " . TB_PREFIX . "tdata where vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ function getTraining($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "training where vref = $vid ORDER BY id";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function countTraining($vid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "training WHERE vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ return $row[0];
+ }
+
+ function trainUnit($vid, $unit, $amt, $pop, $each, $time, $mode) {
+ global $village, $building, $session, $technology;
+
+ if(!$mode) {
+ $barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44);
+ $greatbarracks = array(61,62,63,71,72,73,84,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104);
+ $stables = array(4,5,6,15,16,23,24,25,26,45,46);
+ $greatstables = array(64,65,66,75,76,83,84,85,86,105,106);
+ $workshop = array(7,8,17,18,27,28,47,48);
+ $greatworkshop = array(67,68,77,78,87,88,107,108);
+ $residence = array(9,10,19,20,29,30,49,50);
+ $trapper = array(99);
+
+ if(in_array($unit, $barracks)) {
+ $queued = $technology->getTrainingList(1);
+ } elseif(in_array($unit, $stables)) {
+ $queued = $technology->getTrainingList(2);
+ } elseif(in_array($unit, $workshop)) {
+ $queued = $technology->getTrainingList(3);
+ } elseif(in_array($unit, $residence)) {
+ $queued = $technology->getTrainingList(4);
+ } elseif(in_array($unit, $greatstables)) {
+ $queued = $technology->getTrainingList(6);
+ } elseif(in_array($unit, $greatbarracks)) {
+ $queued = $technology->getTrainingList(5);
+ } elseif(in_array($unit, $greatworkshop)) {
+ $queued = $technology->getTrainingList(7);
+ } elseif(in_array($unit, $trapper)) {
+ $queued = $technology->getTrainingList(8);
+ }
+ $now = time();
+
+ $uid = $this->getVillageField($vid, "owner");
+ $artefact = count($this->getOwnUniqueArtefactInfo2($uid,5,3,0));
+ $artefact1 = count($this->getOwnUniqueArtefactInfo2($vid,5,1,1));
+ $artefact2 = count($this->getOwnUniqueArtefactInfo2($uid,5,2,0));
+ if($artefact > 0){
+ $time = $now+round(($time-$now)/2);
+ $each /= 2;
+ $each = round($each);
+ }else if($artefact1 > 0){
+ $time = $now+round(($time-$now)/2);
+ $each /= 2;
+ $each = round($each);
+ }else if($artefact2 > 0){
+ $time = $now+round(($time-$now)/4*3);
+ $each /= 4;
+ $each = round($each);
+ $each *= 3;
+ $each = round($each);
+ }
+ $foolartefact = $this->getFoolArtefactInfo(5,$vid,$uid);
+ if(count($foolartefact) > 0){
+ foreach($foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $each *= $arte['effect2'];
+ }else{
+ $each /= $arte['effect2'];
+ $each = round($each);
+ }
+ }
+ }
+ if($each == 0){ $each = 1; }
+ $time2 = $now+$each;
+ if(count($queued) > 0) {
+ $time += $queued[count($queued) - 1]['timestamp'] - $now;
+ $time2 += $queued[count($queued) - 1]['timestamp'] - $now;
+ }
+ if($queued[count($queued) - 1]['unit'] == $unit){
+ $time = $amt*$queued[count($queued) - 1]['eachtime'];
+ $q = "UPDATE " . TB_PREFIX . "training SET amt = amt + $amt, timestamp = timestamp + $time WHERE id = ".$queued[count($queued) - 1]['id']."";
+ }else{
+ $q = "INSERT INTO " . TB_PREFIX . "training values (0,$vid,$unit,$amt,$pop,$time,$each,$time2)";
+ }
+ } else {
+ $q = "DELETE FROM " . TB_PREFIX . "training where id = $vid";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function updateTraining($id, $trained, $each) {
+ $q = "UPDATE " . TB_PREFIX . "training set amt = amt - $trained, timestamp2 = timestamp2 + $each where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function modifyUnit($vref, $array_unit, $array_amt, $array_mode){
+ $i = -1;
+ $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;}
+
+ ++$i;
+ $units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').' '.$array_amt[$i].(($number > $i+1) ? ', ' : '');
+ }
+
+ $q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getEnforce($vid, $from) {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $from and vref = $vid";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ function addEnforce($data) {
+ $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")";
+ mysqli_query($this->connection, $q);
+ $id = mysqli_insert_id($this->connection);
+ $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0);
+ $start = ($owntribe - 1) * 10 + 1;
+ $end = ($owntribe * 10);
+ //add unit
+ $j = '1';
+ for($i = $start; $i <= $end; $i++) {
+ $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1);
+ $j++;
+ }
+ $this->modifyEnforce($id,'hero',$data['t11'],1);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function addEnforce2($data,$tribe,$dead1,$dead2,$dead3,$dead4,$dead5,$dead6,$dead7,$dead8,$dead9,$dead10,$dead11) {
+ $q = "INSERT into " . TB_PREFIX . "enforcement (vref,`from`) values (" . $data['to'] . "," . $data['from'] . ")";
+ mysqli_query($this->connection, $q);
+ $id = mysqli_insert_id($this->connection);
+ $owntribe = $this->getUserField($this->getVillageField($data['from'], "owner"), "tribe", 0);
+ $start = ($owntribe - 1) * 10 + 1;
+ $end = ($owntribe * 10);
+ $start2 = ($tribe - 1) * 10 + 1;
+ $start3 = ($tribe - 1) * 10;
+ if($start3 == 0){
+ $start3 = "";
+ }
+ $end2 = ($tribe * 10);
+ //add unit
+ $j = '1';
+ for($i = $start; $i <= $end; $i++) {
+ $this->modifyEnforce($id, $i, $data['t' . $j . ''], 1);
+ $this->modifyEnforce($id, $i, ${dead.$j}, 0);
+ $j++;
+ }
+ $this->modifyEnforce($id,'hero',$data['t11'],1);
+ $this->modifyEnforce($id,'hero',$dead11,0);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function modifyEnforce($id, $unit, $amt, $mode) {
+ if($unit != 'hero') { $unit = 'u' . $unit; }
+ if(!$mode) {
+ $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit - $amt where id = $id";
+ } else {
+ $q = "UPDATE " . TB_PREFIX . "enforcement set $unit = $unit + $amt where id = $id";
+ }
+ mysqli_query($this->connection, $q);
+ }
+
+ function getEnforceArray($id, $mode) {
+ if(!$mode) {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where id = $id";
+ } else {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id";
+ }
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_assoc($result);
+ }
+
+ function getEnforceVillage($id, $mode) {
+ if(!$mode) {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where vref = $id";
+ } else {
+ $q = "SELECT * from " . TB_PREFIX . "enforcement where `from` = $id";
+ }
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getVillageMovement($id) {
+ $vinfo = $this->getVillage($id);
+ $vtribe = $this->getUserField($vinfo['owner'], "tribe", 0);
+ $movingunits = array();
+ $outgoingarray = $this->getMovement(3, $id, 0);
+ if(!empty($outgoingarray)) {
+ foreach($outgoingarray as $out) {
+ for($i = 1; $i <= 10; $i++) {
+ $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $out['t' . $i];
+ }
+ $movingunits['hero'] += $out['t11'];
+ }
+ }
+ $returningarray = $this->getMovement(4, $id, 1);
+ if(!empty($returningarray)) {
+ foreach($returningarray as $ret) {
+ if($ret['attack_type'] != 1) {
+ for($i = 1; $i <= 10; $i++) {
+ $movingunits['u' . (($vtribe - 1) * 10 + $i)] += $ret['t' . $i];
+ }
+ $movingunits['hero'] += $ret['t11'];
+ }
+ }
+ }
+ $settlerarray = $this->getMovement(5, $id, 0);
+ if(!empty($settlerarray)) {
+ $movingunits['u' . ($vtribe * 10)] += 3 * count($settlerarray);
+ }
+ return $movingunits;
+ }
+
+ ################# -START- ##################
+ ## WORLD WONDER STATISTICS FUNCTIONS! ##
+ ############################################
+
+ /***************************
+ Function to get all World Wonders
+ Made by: Dzoki
+ ***************************/
+
+ function getWW() {
+ $q = "SELECT * FROM " . TB_PREFIX . "fdata WHERE f99t = 40";
+ $result = mysqli_query($this->connection, $q);
+ if(mysqli_num_rows($result)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /***************************
+ Function to get world wonder level!
+ Made by: Dzoki
+ ***************************/
+
+ function getWWLevel($vref) {
+ $q = "SELECT f99 FROM " . TB_PREFIX . "fdata WHERE vref = $vref";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['f99'];
+ }
+
+ /***************************
+ Function to get world wonder owner ID!
+ Made by: Dzoki
+ ***************************/
+
+ function getWWOwnerID($vref) {
+ $q = "SELECT owner FROM " . TB_PREFIX . "vdata WHERE wref = $vref";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['owner'];
+ }
+
+ /***************************
+ Function to get user alliance name!
+ Made by: Dzoki
+ ***************************/
+
+ function getUserAllianceID($id) {
+ $q = "SELECT alliance FROM " . TB_PREFIX . "users where id = $id";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['alliance'];
+ }
+
+ /***************************
+ Function to get WW name
+ Made by: Dzoki
+ ***************************/
+
+ function getWWName($vref) {
+ $q = "SELECT wwname FROM " . TB_PREFIX . "fdata WHERE vref = $vref";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['wwname'];
+ }
+
+ /***************************
+ Function to change WW name
+ Made by: Dzoki
+ ***************************/
+
+ function submitWWname($vref, $name) {
+ $q = "UPDATE " . TB_PREFIX . "fdata SET `wwname` = '$name' WHERE " . TB_PREFIX . "fdata.`vref` = $vref";
+ return mysqli_query($this->connection, $q);
+ }
+
+ //medal functions
+ function addclimberpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc + '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ function addclimberrankpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set clp = clp + '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ function removeclimberrankpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set clp = clp - '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ function setclimberrankpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set clp = '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ function updateoldrank($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set oldrank = '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ function removeclimberpop($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "users set Rc = Rc - '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ // ALLIANCE MEDAL FUNCTIONS
+ function addclimberpopAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc + '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ function addclimberrankpopAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp + '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ function removeclimberrankpopAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set clp = clp - '$cp'' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ function updateoldrankAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set oldrank = '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+ function removeclimberpopAlly($user, $cp) {
+ $q = "UPDATE " . TB_PREFIX . "alidata set Rc = Rc - '$cp' where id = $user";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getTrainingList() {
+ $q = "SELECT * FROM " . TB_PREFIX . "training where vref != ''";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getNeedDelete() {
+ $time = time();
+ $q = "SELECT uid FROM " . TB_PREFIX . "deleting where timestamp < $time";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function countUser() {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "users where id > 5";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ return $row[0];
+ }
+
+ function countAlli() {
+ $q = "SELECT count(id) FROM " . TB_PREFIX . "alidata where id != 0";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ return $row[0];
+ }
+
+ /***************************
+ Function to process MYSQLi->fetch_all (Only exist in MYSQL)
+ References: Result
+ ***************************/
+ function mysqli_fetch_all($result) {
+ $all = array();
+ if($result) {
+ while($row = mysqli_fetch_assoc($result)) {
+ $all[] = $row;
+ }
+ return $all;
+ }
+ }
+
+ function query_return($q) {
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ /***************************
+ Function to do free query
+ References: Query
+ ***************************/
+ function query($query) {
+ return mysqli_query($query, $this->connection);
+ }
+
+ function RemoveXSS($val) {
+ return htmlspecialchars($val, ENT_QUOTES);
+ }
+
+ //MARKET FIXES
+ function getWoodAvailable($wref) {
+ $q = "SELECT wood FROM " . TB_PREFIX . "vdata WHERE wref = $wref";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['wood'];
+ }
+
+ function getClayAvailable($wref) {
+ $q = "SELECT clay FROM " . TB_PREFIX . "vdata WHERE wref = $wref";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['clay'];
+ }
+
+ function getIronAvailable($wref) {
+ $q = "SELECT iron FROM " . TB_PREFIX . "vdata WHERE wref = $wref";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['iron'];
+ }
+
+ function getCropAvailable($wref) {
+ $q = "SELECT crop FROM " . TB_PREFIX . "vdata WHERE wref = $wref";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+ return $dbarray['crop'];
+ }
+
+ function Getowner($vid) {
+ $s = "SELECT owner FROM " . TB_PREFIX . "vdata where wref = $vid";
+ $result1 = mysqli_query($s, $this->connection);
+ $row1 = mysqli_fetch_row($result1);
+ return $row1[0];
+ }
+
+ public function debug($time, $uid, $debug_info) {
+ $q = "INSERT INTO " . TB_PREFIX . "debug_info (time,uid,debug_info) VALUES ($time,$uid,$debug_info)";
+ if(mysqli_query($this->connection, $q)) {
+ return mysqli_insert_id($this->connection);
+ } else {
+ return false;
+ }
+ }
+
+ function populateOasisdata() {
+ $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0";
+ $result2 = mysqli_query($this->connection, $q2);
+ while($row = mysql_fetch_array($result2)) {
+ $wid = $row['id'];
+ $basearray = $this->getOMInfo($wid);
+ //We switch type of oasis and instert record with apropriate infomation.
+ $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . ",100,2,'Unoccupied Oasis',".rand(0,2).")";
+ $result = mysqli_query($this->connection, $q);
+ }
+ }
+
+ public function getAvailableExpansionTraining() {
+ global $building, $session, $technology, $village;
+ $q = "SELECT (IF(exp1=0,1,0)+IF(exp2=0,1,0)+IF(exp3=0,1,0)) FROM " . TB_PREFIX . "vdata WHERE wref = $village->wid";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ $maxslots = $row[0];
+ $residence = $building->getTypeLevel(25);
+ $palace = $building->getTypeLevel(26);
+ if($residence > 0) {
+ $maxslots -= (3 - floor($residence / 10));
+ }
+ if($palace > 0) {
+ $maxslots -= (3 - floor(($palace - 5) / 5));
+ }
+
+ $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "units WHERE vref = $village->wid";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ $settlers = $row[0];
+ $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "units WHERE vref = $village->wid";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ $chiefs = $row[0];
+
+ $settlers += 3 * count($this->getMovement(5, $village->wid, 0));
+ $current_movement = $this->getMovement(3, $village->wid, 0);
+ if(!empty($current_movement)) {
+ foreach($current_movement as $build) {
+ $settlers += $build['t10'];
+ $chiefs += $build['t9'];
+ }
+ }
+ $current_movement = $this->getMovement(3, $village->wid, 1);
+ if(!empty($current_movement)) {
+ foreach($current_movement as $build) {
+ $settlers += $build['t10'];
+ $chiefs += $build['t9'];
+ }
+ }
+ $current_movement = $this->getMovement(4, $village->wid, 0);
+ if(!empty($current_movement)) {
+ foreach($current_movement as $build) {
+ $settlers += $build['t10'];
+ $chiefs += $build['t9'];
+ }
+ }
+ $current_movement = $this->getMovement(4, $village->wid, 1);
+ if(!empty($current_movement)) {
+ foreach($current_movement as $build) {
+ $settlers += $build['t10'];
+ $chiefs += $build['t9'];
+ }
+ }
+ $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ if(!empty($row)) {
+ foreach($row as $reinf) {
+ $settlers += $reinf[0];
+ }
+ }
+ $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "enforcement WHERE `from` = $village->wid";
+ $result = mysqli_query($this->connection, $q);
+ $row = mysqli_fetch_row($result);
+ if(!empty($row)) {
+ foreach($row as $reinf) {
+ $chiefs += $reinf[0];
+ }
+ }
+ $trainlist = $technology->getTrainingList(4);
+ if(!empty($trainlist)) {
+ foreach($trainlist as $train) {
+ if($train['unit'] % 10 == 0) {
+ $settlers += $train['amt'];
+ }
+ if($train['unit'] % 10 == 9) {
+ $chiefs += $train['amt'];
+ }
+ }
+ }
+ // trapped settlers/chiefs calculation required
+
+ $settlerslots = $maxslots * 3 - $settlers - $chiefs * 3;
+ $chiefslots = $maxslots - $chiefs - floor(($settlers + 2) / 3);
+
+ if(!$technology->getTech(($session->tribe - 1) * 10 + 9)) {
+ $chiefslots = 0;
+ }
+ $slots = array("chiefs" => $chiefslots, "settlers" => $settlerslots);
+ return $slots;
+ }
+
+ function addArtefact($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->connection, $q);
+ }
+
+ function getOwnArtefactInfo($vref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function getOwnArtefactInfo2($vref) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getOwnArtefactInfo3($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $uid";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getOwnArtefactInfoByType($vref, $type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type order by size";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function getOwnArtefactInfoByType2($vref, $type) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getOwnUniqueArtefactInfo($id, $type, $size) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND type = $type AND size=$size";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function getOwnUniqueArtefactInfo2($id, $type, $size, $mode) {
+ if(!$mode){
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND active = 1 AND type = $type AND size=$size";
+ }else{
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $id AND active = 1 AND type = $type AND size=$size";
+ }
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getFoolArtefactInfo($type,$vid,$uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vid AND type = 8 AND kind = $type OR owner = $uid AND size > 1 AND active = 1 AND type = 8 AND kind = $type";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function claimArtefact($vref, $ovref, $id) {
+ $time = time();
+ $q = "UPDATE " . TB_PREFIX . "artefacts SET vref = $vref, owner = $id, conquered = $time, active = 1 WHERE vref = $ovref";
+ return mysqli_query($this->connection, $q);
+ }
+
+ public function canClaimArtifact($from,$vref,$type,$kind) {
+ $type2 = $type3 = 0;
+ if(count($this->getOwnUniqueArtefactInfo2($this->getVillagefield($from,"owner"),2,2,0)) > 0 && $type == 2){
+ $type2 = 1;
+ }
+ if(count($this->getOwnUniqueArtefactInfo2($this->getVillagefield($from,"owner"),2,3,0)) > 0 && $type == 3){
+ $type3 = 1;
+ }
+ if((count($this->getOwnArtefactInfo2($from)) < 3 && $type2 == 0 && $type3 == 0) or $kind == 11){
+ $DefenderFields = $this->getResourceLevel($vref);
+ $defcanclaim = TRUE;
+ for($i=19;$i<=38;$i++) {
+ if($DefenderFields['f'.$i.'t'] == 27) {
+ $defTresuaryLevel = $DefenderFields['f'.$i];
+ if($defTresuaryLevel > 0) {
+ $defcanclaim = FALSE;
+ } else {
+ $defcanclaim = TRUE;
+ }
+ }
+ }
+ $AttackerFields = $this->getResourceLevel($from);
+ for($i=19;$i<=38;$i++) {
+ if($AttackerFields['f'.$i.'t'] == 27) {
+ $attTresuaryLevel = $AttackerFields['f'.$i];
+ if ($attTresuaryLevel >= 10) {
+ $villageartifact = TRUE;
+ } else {
+ $villageartifact = FALSE;
+ }
+ if ($attTresuaryLevel >= 20){
+ $accountartifact = TRUE;
+ } else {
+ $accountartifact = FALSE;
+ }
+ }
+ }
+ if ($type == 1) {
+ if ($defcanclaim == TRUE && $villageartifact == TRUE) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else if ($type == 2) {
+ if ($defcanclaim == TRUE && $accountartifact == TRUE) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else if ($type == 3) {
+ if ($defcanclaim == TRUE && $accountartifact == TRUE) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else {
+ return FALSE;
+ }
+ }else{
+ return FALSE;
+ }
+ }
+
+ function getArtefactDetails($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id = " . $id . "";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function getMovementById($id){
+ $q = "SELECT * FROM ".TB_PREFIX."movement WHERE moveid = ".$id."";
+ $result = mysqli_query($q);
+ $array = $this->mysqli_fetch_all($result);
+ return $array;
+ }
+
+ function getLinks($id){
+ $q = 'SELECT * FROM `' . TB_PREFIX . 'links` WHERE `userid` = ' . $id . ' ORDER BY `pos` ASC';
+ return mysqli_query($this->connection, $q);
+ }
+
+ function removeLinks($id,$uid){
+ $q = "DELETE FROM " . TB_PREFIX . "links WHERE `id` = ".$id." and `userid` = ".$uid."";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getVilFarmlist($wref){
+ $q = 'SELECT * FROM ' . TB_PREFIX . 'farmlist WHERE wref = ' . $wref . ' ORDER BY wref ASC';
+ $result = mysqli_query($this->connection, $q);
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+
+ if($dbarray['id']!=0) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ function getRaidList($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "raidlist WHERE id = ".$id."";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function delFarmList($id, $owner) {
+ $q = "DELETE FROM " . TB_PREFIX . "farmlist where id = $id and owner = $owner";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function delSlotFarm($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "raidlist where id = $id";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function createFarmList($wref, $owner, $name) {
+ $q = "INSERT INTO " . TB_PREFIX . "farmlist (`wref`, `owner`, `name`) VALUES ('$wref', '$owner', '$name')";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addSlotFarm($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) {
+ $q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`, `t7`, `t8`, `t9`, `t10`) VALUES ('$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10')";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function editSlotFarm($eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) {
+ $q = "UPDATE " . TB_PREFIX . "raidlist set lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function getArrayMemberVillage($uid){
+ $q = 'SELECT a.wref, a.name, b.x, b.y from '.TB_PREFIX.'vdata AS a left join '.TB_PREFIX.'wdata AS b ON b.id = a.wref where owner = '.$uid.' order by capital DESC,pop DESC';
+ $result = mysqli_query($this->connection, $q);
+ $array = $this->mysqli_fetch_all($result);
+ return $array;
+ }
+
+ function addPassword($uid, $npw, $cpw){
+ $q = "REPLACE INTO `" . TB_PREFIX . "password`(uid, npw, cpw) VALUES ($uid, '$npw', '$cpw')";
+ mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ }
+
+ function resetPassword($uid, $cpw){
+ $q = "SELECT npw FROM `" . TB_PREFIX . "password` WHERE uid = $uid AND cpw = '$cpw' AND used = 0";
+ $result = mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH);
+
+ if(!empty($dbarray)) {
+ if(!$this->updateUserField($uid, 'password', md5($dbarray['npw']), 1)) return false;
+ $q = "UPDATE `" . TB_PREFIX . "password` SET used = 1 WHERE uid = $uid AND cpw = '$cpw' AND used = 0";
+ mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ return true;
+ }
+
+ return false;
+ }
+
+ function getCropProdstarv($wref) {
+ global $bid4,$bid8,$bid9,$sesion,$technology;
+
+ $basecrop = $grainmill = $bakery = 0;
+ $owner = $this->getVrefField($wref, 'owner');
+ $bonus = $this->getUserField($owner, b4, 0);
+
+ $buildarray = $this->getResourceLevel($wref);
+ $cropholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($buildarray['f'.$i.'t'] == 4) {
+ array_push($cropholder,'f'.$i);
+ }
+ if($buildarray['f'.$i.'t'] == 8) {
+ $grainmill = $buildarray['f'.$i];
+ }
+ if($buildarray['f'.$i.'t'] == 9) {
+ $bakery = $buildarray['f'.$i];
+ }
+ }
+ $q = "SELECT type FROM `" . TB_PREFIX . "odata` WHERE conqured = $wref";
+ $oasis = $this->query_return($q);
+ foreach($oasis as $oa){
+ switch($oa['type']) {
+ case 1:
+ case 2:
+ $wood += 1;
+ break;
+ case 3:
+ $wood += 1;
+ $cropo += 1;
+ break;
+ case 4:
+ case 5:
+ $clay += 1;
+ break;
+ case 6:
+ $clay += 1;
+ $cropo += 1;
+ break;
+ case 7:
+ case 8:
+ $iron += 1;
+ break;
+ case 9:
+ $iron += 1;
+ $cropo += 1;
+ break;
+ case 10:
+ case 11:
+ $cropo += 1;
+ break;
+ case 12:
+ $cropo += 2;
+ break;
+ }
+ }
+ for($i=0;$i<=count($cropholder)-1;$i++) { $basecrop+= $bid4[$buildarray[$cropholder[$i]]]['prod']; }
+ $crop = $basecrop + $basecrop * 0.25 * $cropo;
+ if($grainmill >= 1 || $bakery >= 1) {
+ $crop += $basecrop /100 * ($bid8[$grainmill]['attri'] + $bid9[$bakery]['attri']);
+ }
+ if($bonus > time()) {
+ $crop *= 1.25;
+ }
+ $crop *= SPEED;
+ return $crop;
+ }
+
+ //general statistics
+
+ function addGeneralAttack($casualties) {
+ $time = time();
+ $q = "INSERT INTO " . TB_PREFIX . "general values (0,'$casualties','$time',1)";
+ return mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ }
+
+ function getAttackByDate($time) {
+ $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1";
+ $result = $this->query_return($q);
+ $attack = 0;
+ foreach($result as $general){
+ if(date("j. M",$time) == date("j. M",$general['time'])){
+ $attack += 1;
+ }
+ }
+ return $attack;
+ }
+
+ function getAttackCasualties($time) {
+ $q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1";
+ $result = $this->query_return($q);
+ $casualties = 0;
+ foreach($result as $general){
+ if(date("j. M",$time) == date("j. M",$general['time'])){
+ $casualties += $general['casualties'];
+ }
+ }
+ return $casualties;
+ }
+
+ //end general statistics
+
+ function addFriend($uid, $column, $friend) {
+ $q = "UPDATE " . TB_PREFIX . "users SET $column = $friend WHERE id = $uid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function deleteFriend($uid, $column) {
+ $q = "UPDATE " . TB_PREFIX . "users SET $column = 0 WHERE id = $uid";
+ return mysqli_query($this->connection, $q);
+ }
+
+ function checkFriends($uid) {
+ $user = $this->getUserArray($uid, 1);
+ for($i=0;$i<=19;$i++) {
+ if($user['friend'.$i] == 0 && $user['friend'.$i.'wait'] == 0){
+ for($j=$i+1;$j<=19;$j++) {
+ $k = $j-1;
+ if($user['friend'.$j] != 0){
+ $friend = $this->getUserField($uid, "friend".$j, 0);
+ $this->addFriend($uid,"friend".$k,$friend);
+ $this->deleteFriend($uid,"friend".$j);
+ }
+ if($user['friend'.$j.'wait'] == 0){
+ $friendwait = $this->getUserField($uid, "friend".$j."wait", 0);
+ $this->addFriend($sessionuid,"friend".$k."wait",$friendwait);
+ $this->deleteFriend($uid,"friend".$j."wait");
+ }
+ }
+ }
+ }
+ }
+
+ function setVillageEvasion($vid) {
+ $village = $this->getVillage($vid);
+ if($village['evasion'] == 0){
+ $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 1 WHERE wref = $vid";
+ }else{
+ $q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 0 WHERE wref = $vid";
+ }
+ return mysqli_query($this->connection, $q);
+ }
+
+ function addPrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) {
+ $q = "INSERT INTO " . TB_PREFIX . "prisoners values (0,$wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11)";
+ mysqli_query($this->connection, $q);
+ return mysqli_insert_id($this->connection);
+ }
+
+ function updatePrisoners($wid,$from,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) {
+ $q = "UPDATE " . TB_PREFIX . "prisoners set t1 = t1 + $t1, t2 = t2 + $t2, t3 = t3 + $t3, t4 = t4 + $t4, t5 = t5 + $t5, t6 = t6 + $t6, t7 = t7 + $t7, t8 = t8 + $t8, t9 = t9 + $t9, t10 = t10 + $t10, t11 = t11 + $t11 where wid = $wid and from = $from";
+ return mysqli_query($this->connection, $q) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
+ }
+
+ function getPrisoners($wid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getPrisoners2($wid,$from) {
+ $q = "SELECT * FROM " . TB_PREFIX . "prisoners where wref = $wid and " . TB_PREFIX . "prisoners.from = $from";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function getPrisonersByID($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "prisoners where id = $id";
+ $result = mysqli_query($this->connection, $q);
+ return mysqli_fetch_array($result, MYSQLI_BOTH);
+ }
+
+ function getPrisoners3($from) {
+ $q = "SELECT * FROM " . TB_PREFIX . "prisoners where " . TB_PREFIX . "prisoners.from = $from";
+ $result = mysqli_query($this->connection, $q);
+ return $this->mysqli_fetch_all($result);
+ }
+
+ function deletePrisoners($id) {
+ $q = "DELETE from " . TB_PREFIX . "prisoners where id = '$id'";
+ mysqli_query($this->connection, $q);
+ }
+};
+
+$database = new MYSQLi_DB;
+
+?>
diff --git a/GameEngine/Form.php b/GameEngine/Form.php
new file mode 100644
index 00000000..69c22939
--- /dev/null
+++ b/GameEngine/Form.php
@@ -0,0 +1,81 @@
+errorarray = $_SESSION['errorarray'];
+ $this->valuearray = $_SESSION['valuearray'];
+ $this->errorcount = count($this->errorarray);
+
+ unset($_SESSION['errorarray']);
+ unset($_SESSION['valuearray']);
+ }
+ else {
+ $this->errorcount = 0;
+ }
+ }
+
+ public function addError($field,$error) {
+ $this->errorarray[$field] = $error;
+ $this->errorcount = count($this->errorarray);
+ }
+
+ public function getError($field) {
+ if(array_key_exists($field,$this->errorarray)) {
+ return $this->errorarray[$field];
+ }
+ else {
+ return "";
+ }
+ }
+
+ public function getValue($field) {
+ if(array_key_exists($field,$this->valuearray)) {
+ return $this->valuearray[$field];
+ }
+ else {
+ return "";
+ }
+ }
+
+ public function getDiff($field,$cookie) {
+ if(array_key_exists($field,$this->valuearray) && $this->valuearray[$field] != $cookie) {
+ return $this->valuearray[$field];
+ }
+ else {
+ return $cookie;
+ }
+ }
+
+ public function getRadio($field,$value) {
+ if(array_key_exists($field,$this->valuearray) && $this->valuearray[$field] == $value) {
+ return "checked";
+ }
+ else {
+ return "";
+ }
+ }
+
+ public function returnErrors() {
+ return $this->errorcount;
+ }
+
+ public function getErrors() {
+ return $this->errorarray;
+ }
+};
+?>
\ No newline at end of file
diff --git a/GameEngine/Game/WorldWonderName.php b/GameEngine/Game/WorldWonderName.php
new file mode 100644
index 00000000..91c888bb
--- /dev/null
+++ b/GameEngine/Game/WorldWonderName.php
@@ -0,0 +1,16 @@
+submitWWname($_POST['vref'],$_POST['wwname']);
+header("Location: ../../build.php?id=99&n");
+
+?>
\ No newline at end of file
diff --git a/GameEngine/Generator.php b/GameEngine/Generator.php
new file mode 100644
index 00000000..94f90425
--- /dev/null
+++ b/GameEngine/Generator.php
@@ -0,0 +1,165 @@
+generateRandStr(16));
+ }
+
+ public function generateRandStr($length){
+ $randstr = "";
+ for($i=0; $i<$length; $i++){
+ $randnum = mt_rand(0,61);
+ if($randnum < 10){
+ $randstr .= chr($randnum+48);
+ }else if($randnum < 36){
+ $randstr .= chr($randnum+55);
+ }else{
+ $randstr .= chr($randnum+61);
+ }
+ }
+ return $randstr;
+ }
+
+ public function encodeStr($str,$length) {
+ $encode = md5($str);
+ return substr($encode,0,$length);
+ }
+
+ public function procDistanceTime($coor,$thiscoor,$ref,$mode) {
+ global $bid28,$bid14,$building;
+ $xdistance = ABS($thiscoor['x'] - $coor['x']);
+ if($xdistance > WORLD_MAX) {
+ $xdistance = (2 * WORLD_MAX + 1) - $xdistance;
+ }
+ $ydistance = ABS($thiscoor['y'] - $coor['y']);
+ if($ydistance > WORLD_MAX) {
+ $ydistance = (2 * WORLD_MAX + 1) - $ydistance;
+ }
+ $distance = SQRT(POW($xdistance,2)+POW($ydistance,2));
+ if(!$mode) {
+ if($ref == 1) {
+ $speed = 16;
+ }
+ else if($ref == 2) {
+ $speed = 12;
+ }
+ else if($ref == 3) {
+ $speed = 24;
+ }
+ else if($ref == 300) {
+ $speed = 5;
+ }
+ else {
+ $speed = 1;
+ }
+ }
+ else {
+ $speed = $ref;
+ if($building->getTypeLevel(14) != 0 && $distance >= TS_THRESHOLD) {
+ $speed = $speed * ($bid14[$building->gettypeLevel(14)]['attri']/100) ;
+ }
+ }
+ if($speed!=0){
+ return round(($distance/$speed) * 3600 / INCREASE_SPEED);
+ }else{
+ return round($distance * 3600 / INCREASE_SPEED);
+ }
+ }
+
+ public function getTimeFormat($time) {
+ $min = 0;
+ $hr = 0;
+ $days = 0;
+ while($time >= 60) :
+ $time -= 60;
+ $min += 1;
+ endwhile;
+ while ($min >= 60) :
+ $min -= 60;
+ $hr += 1;
+ endwhile;
+ if ($min < 10) {
+ $min = "0".$min;
+ }
+ if($time < 10) {
+ $time = "0".$time;
+ }
+ return $hr.":".$min.":".$time;
+ }
+
+public function procMtime($time, $pref = 3) {
+ /*
+ $timezone = 7;
+ switch($timezone) {
+ case 7:
+ $time -= 3600;
+ break;
+ }
+ */
+- $time += 3600*0; //Edit this yourself
++ $time += 0; //Edit this yourself
+
+$today = date('d',time())-1;
+if (date('Ymd',time()) == date('Ymd',$time)) {
+ $day = "today";
+ }elseif($today == date('d',$time)){
+ $day = "yesterday";
+ }
+ else {
+ switch($pref) {
+ case 1:
+ $day = date("m/j/y",$time);
+ break;
+ case 2:
+ $day = date("j/m/y",$time);
+ break;
+ case 3:
+ $day = date("j.m.y",$time);
+ break;
+ default:
+ $day = date("y/m/j",$time);
+ break;
+ }
+ }
+ $new = date("H:i:s",$time);
+ if ($pref=="9"||$pref==9)
+ return $new;
+ else
+ return array($day,$new);
+ }
+
+
+ public function getBaseID($x,$y) {
+ return ((WORLD_MAX-$y) * (WORLD_MAX*2+1)) + (WORLD_MAX +$x + 1);
+ }
+
+ public function getMapCheck($wref) {
+ return substr(md5($wref),5,2);
+ }
+
+ public function pageLoadTimeStart() {
+ $starttime = microtime();
+ $startarray = explode(" ", $starttime);
+ //$starttime = $startarray[1] + $startarray[0];
+ return $startarray[0];
+ }
+
+ public function pageLoadTimeEnd() {
+ $endtime = microtime();
+ $endarray = explode(" ", $endtime);
+ //$endtime = $endarray[1] + $endarray[0];
+ return $endarray[0];
+ }
+
+};
+$generator = new Generator;
\ No newline at end of file
diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php
new file mode 100644
index 00000000..892d7a21
--- /dev/null
+++ b/GameEngine/Lang/en.php
@@ -0,0 +1,374 @@
+Plus");
+define("CONTACT","Contact us!");
+define("GAME_RULES","Game Rules");
+
+//MENU
+define("REG","Register");
+define("FORUM","Forum");
+define("CHAT","Chat");
+define("IMPRINT","Imprint");
+define("MORE_LINKS","More Links");
+define("TOUR","Game Tour");
+
+
+//ERRORS
+define("USRNM_EMPTY","(Username empty)");
+define("USRNM_TAKEN","(Name is already in use.)");
+define("USRNM_SHORT","(min. ".USRNM_MIN_LENGTH." figures)");
+define("USRNM_CHAR","(Invalid Characters)");
+define("PW_EMPTY","(Password empty)");
+define("PW_SHORT","(min. ".PW_MIN_LENGTH." figures)");
+define("PW_INSECURE","(Password insecure. Please choose a more secure one.)");
+define("EMAIL_EMPTY","(Email Empty)");
+define("EMAIL_INVALID","(Invalid email address)");
+define("EMAIL_TAKEN","(Email is already in use)");
+define("TRIBE_EMPTY","Please choose a tribe.");
+define("AGREE_ERROR","You have to agree to the game rules and the general terms & conditions in order to register.");
+define("LOGIN_USR_EMPTY","Enter name.");
+define("LOGIN_PASS_EMPTY","Enter password.");
+define("EMAIL_ERROR","Email does not match existing");
+define("PASS_MISMATCH","Passwords do not match");
+define("ALLI_OWNER","Please appoint an alliance owner before deleting");
+define("SIT_ERROR","Sitter already set");
+define("USR_NT_FOUND","Name does not exist.");
+define("LOGIN_PW_ERROR","The password is wrong.");
+define("WEL_TOPIC","Useful tips & information ");
+define("ATAG_EMPTY","Tag empty");
+define("ANAME_EMPTY","Name empty");
+define("ATAG_EXIST","Tag taken");
+define("ANAME_EXIST","Name taken");
+define("NOT_OPENED_YET","Server not started yet.");
+define("REGISTER_CLOSED","The register is closed. You can't register to this server.");
+define("NAME_EMPTY","Please insert name");
+define("NAME_NO_EXIST","There is no user with the name ");
+define("ID_NO_EXIST","There is no user with the id ");
+define("SAME_NAME","You can't invite yourself");
+define("ALREADY_INVITED"," already invited");
+define("ALREADY_IN_ALLY"," already in this alliance");
+
+//COPYRIGHT
+define("TRAVIAN_COPYRIGHT","TravianZ 100% Open Source Travian Clone.");
+
+//BUILD.TPL
+define("CUR_PROD","Current production");
+define("NEXT_PROD","Production at level ");
+
+//BUILDINGS
+define("B1","Woodcutter");
+define("B1_DESC","The Woodcutter cuts down trees in order to produce lumber. The further you extend the woodcutter the more lumber is produced by him.");
+define("B2","Clay Pit");
+define("B2_DESC","Clay is produced here. By increasing its level you increase its clay production.");
+define("B3","Iron Mine");
+define("B3_DESC","Here miners produce the precious resource iron. By increasing the mine`s level you increase its iron production.");
+define("B4","Cropland");
+define("B4_DESC","Your population`s food is produced here. By increasing the farm`s level you increase its crop production.");
+
+//DORF1
+define("LUMBER","Lumber");
+define("CLAY","Clay");
+define("IRON","Iron");
+define("CROP","Crop");
+define("LEVEL","Level");
+define("CROP_COM",CROP." consumption");
+define("PER_HR","per hour");
+define("PROD_HEADER","Production");
+define("MULTI_V_HEADER","Villages");
+define("ANNOUNCEMENT","Announcement");
+define("GO2MY_VILLAGE","Go to my village");
+define("VILLAGE_CENTER","Village centre");
+define("FINISH_GOLD","Finish all construction and research orders in this village immediately for 2 Gold?");
+define("WAITING_LOOP","(waiting loop)");
+define("HRS","(hrs.)");
+define("DONE_AT","done at");
+define("CANCEL","cancel");
+define("LOYALTY","Loyalty:");
+define("CALCULATED_IN","Calculated in");
+define("SEVER_TIME","Server time:");
+
+//QUEST
+define("Q_CONTINUE","Continue with the next task.");
+define("Q_REWARD","Your reward:");
+define("Q0","Welcome to ");
+define("Q0_DESC","As I see you have been made chieftain of this little village. I will be your counselor for the first few days and never leave your (right hand) side.");
+define("Q0_OPT1","To the first task.");
+define("Q0_OPT2","Look around on your own.");
+define("Q0_OPT3","Play no tasks.");
+
+define("Q1","Task 1: Woodcutter");
+define("Q1_DESC","There are four green forests around your village. Construct a woodcutter on one of them. Lumber is an important resource for our new settlement.");
+define("Q1_ORDER","Order:<\/p>Construct a woodcutter.");
+define("Q1_RESP","Yes, that way you gain more lumber.I helped a bit and completed the order instantly.");
+define("Q1_REWARD","Woodcutter instantly completed.");
+
+define("Q2","Task 2: Crop");
+define("Q2_DESC","Now your subjects are hungry from working all day. Extend a cropland to improve your subjects' supply. Come back here once the building is complete.");
+define("Q2_ORDER","Order:<\/p>Extend one cropland.");
+define("Q2_RESP","Very good. Now your subjects have enough to eat again...");
+
+define("Q3","Task 3: Your Village's Name");
+define("Q3_DESC","Creative as you are you can grant your village the ultimate name.\r\n
\r\nClick on 'profile' in the left hand menu and then select 'change profile'...");
+define("Q3_ORDER","Order:<\/p>Change your village's name to something nice.");
+define("Q3_RESP","Wow, a great name for their village. It could have been the name of my village!...");
+
+define("Q4","Task 4: Other Players");
+define("Q4_DESC","In ". SERVER_NAME ." you play along with billions of other players. Click 'statistics' in the top menu to look up your rank and enter it here.");
+define("Q4_ORDER","Order:<\/p>Look for your rank in the statistics and enter it here.");
+define("Q4_BUTN","complete task");
+define("Q4_RESP","Exactly! That's your rank.");
+
+define("Q5","Task 5: Two Building Orders");
+define("Q5_DESC","Build an iron mine and a clay pit. Of iron and clay one can never have enough.");
+define("Q5_ORDER","Order:<\/p>- Extend one iron mine.<\/li>
- Extend one clay pit.<\/li><\/ul>");
+define("Q5_RESP","As you noticed, building orders take rather long. The world of ". SERVER_NAME ." will continue to spin even if you are offline. Even in a few months there will be many new things for you to discover.\r\n
\r\nThe best thing to do is occasionally checking your village and giving you subjects new tasks to do.");
+
+define("Q6","Message From The Taskmaster");
+define("Q6_DESC","You are to be informed that a nice reward is waiting for you at the taskmaster.
Hint: The message has been generated automatically. An answer is not necessary.");
+
+define("Q5","Task 5: Two Building Orders");
+define("Q5_DESC","Build an iron mine and a clay pit. Of iron and clay one can never have enough.");
+define("Q5_ORDER","Order:<\/p>- Extend one iron mine.<\/li>
- Extend one clay pit.<\/li><\/ul>");
+define("Q5_RESP","As you noticed, building orders take rather long. The world of ". SERVER_NAME ." will continue to spin even if you are offline. Even in a few months there will be many new things for you to discover.\r\n
\r\nThe best thing to do is occasionally checking your village and giving you subjects new tasks to do.");
+
+//======================================================//
+//================ UNITS - DO NOT EDIT! ================//
+//======================================================//
+define("U0","Hero");
+
+//ROMAN UNITS
+define("U1","Legionnaire");
+define("U2","Praetorian");
+define("U3","Imperian");
+define("U4","Equites Legati");
+define("U5","Equites Imperatoris");
+define("U6","Equites Caesaris");
+define("U7","Battering Ram");
+define("U8","Fire Catapult");
+define("U9","Senator");
+define("U10","Settler");
+
+//TEUTON UNITS
+define("U11","Clubswinger");
+define("U12","Spearman");
+define("U13","Axeman");
+define("U14","Scout");
+define("U15","Paladin");
+define("U16","Teutonic Knight");
+define("U17","Ram");
+define("U18","Catapult");
+define("U19","Chief");
+define("U20","Settler");
+
+//GAUL UNITS
+define("U21","Phalanx");
+define("U22","Swordsman");
+define("U23","Pathfinder");
+define("U24","Theutates Thunder");
+define("U25","Druidrider");
+define("U26","Haeduan");
+define("U27","Ram");
+define("U28","Trebuchet");
+define("U29","Chieftain");
+define("U30","Settler");
+define("U99","Trap");
+
+//NATURE UNITS
+define("U31","Rat");
+define("U32","Spider");
+define("U33","Snake");
+define("U34","Bat");
+define("U35","Wild Boar");
+define("U36","Wolf");
+define("U37","Bear");
+define("U38","Crocodile");
+define("U39","Tiger");
+define("U40","Elephant");
+
+//NATARS UNITS
+define("U41","Pikeman");
+define("U42","Thorned Warrior");
+define("U43","Guardsman");
+define("U44","Birds Of Prey");
+define("U45","Axerider");
+define("U46","Natarian Knight");
+define("U47","War Elephant");
+define("U48","Ballista");
+define("U49","Natarian Emperor");
+define("U50","Natarian Settler");
+
+//MONSTER UNITS
+define("U51","Monster Peon");
+define("U52","Monster Hunter");
+define("U53","Monster Warrior");
+define("U54","Ghost");
+define("U55","Monster Steed");
+define("U56","Monster War Steed");
+define("U57","Monster Ram");
+define("U58","Monster Catapult");
+define("U59","Monster Chief");
+define("U60","Monster Settler");
+
+// RESOURCES
+define("R1","Lumber");
+define("R2","Clay");
+define("R3","Iron");
+define("R4","Crop");
+
+//INDEX.php
+define("LOGIN","Login");
+define("PLAYERS","Players");
+define("ACTIVE","Active");
+define("ONLINE","Online");
+define("TUTORIAL","Tutorial");
+define("PLAYER_STATISTICS","Player statistics");
+define("TOTAL_PLAYERS","".PLAYERS." in total");
+define("ACTIVE_PLAYERS","Active players");
+define("ONLINE_PLAYERS","".PLAYERS." online");
+define("MP_STRATEGY_GAME","".SERVER_NAME." - the multiplayer strategy game");
+define("WHAT_IS","".SERVER_NAME." is one of the most popular browser games in the world. As a player in ".SERVER_NAME.", you will build your own empire, recruit a mighty army, and fight with your allies for game world hegemony.");
+define("REGISTER_FOR_FREE","Register here for free!");
+define("LATEST_GAME_WORLD","Latest game world");
+define("LATEST_GAME_WORLD2","Register on the latest
game world and enjoy
the advantages of
being one of the
first players.");
+define("PLAY_NOW","Play ".SERVER_NAME." now");
+define("LEARN_MORE","Learn more
about ".SERVER_NAME."!");
+define("LEARN_MORE2","Now with a revolutionised
server system, completely new
graphics
This clone is The Shiz!");
+define("COMUNITY","Community");
+define("BECOME_COMUNITY","Become part of our community now!");
+define("BECOME_COMUNITY2","Become a part of one of
the biggest gaming
communities in the
world.");
+define("NEWS","News");
+define("SCREENSHOTS","Screenshots");
+define("LEARN1","Upgrade your fields and mines to increase your resource production. You will need resources to construct buildings and train soldiers.");
+define("LEARN2","Construct and expand the buildings in your village. Buildings improve your overall infrastructure, increase your resource production and allow you to research, train and upgrade your troops.");
+define("LEARN3","View and interact with your surroundings. You can make new friends or new enemies, make use of the nearby oases and observe as your empire grows and becomes stronger.");
+define("LEARN4","Follow your improvement and success and compare yourself to other players. Look at the Top 10 rankings and fight to win a weekly medal.");
+define("LEARN5","Receive detailed reports about your adventures, trades and battles. Don't forget to check the brand new reports about the happenings taking place in your surroundings.");
+define("LEARN6","Exchange information and conduct diplomacy with other players. Always remember that communication is the key to winning new friends and solving old conflicts.");
+define("LOGIN_TO","Log in to ". SERVER_NAME);
+define("REGIN_TO","Register in ". SERVER_NAME);
+define("P_ONLINE","Players online: ");
+define("P_TOTAL","Players in total: ");
+define("CHOOSE","Please choose a server.");
+define("STARTED"," The server started ". round((time()-COMMENCE)/86400) ." days ago.");
+
+//ANMELDEN.php
+define("NICKNAME","Nickname");
+define("EMAIL","Email");
+define("PASSWORD","Password");
+define("ROMANS","Romans");
+define("TEUTONS","Teutons");
+define("GAULS","Gauls");
+define("NW","North West");
+define("NE","North East");
+define("SW","South West");
+define("SE","South East");
+define("RANDOM","random");
+define("ACCEPT_RULES"," I accept the game rules and general terms and conditions.");
+define("ONE_PER_SERVER","Each player may only own ONE account per server.");
+define("BEFORE_REGISTER","Before you register an account you should read the instructions of TravianX to see the specific advantages and disadvantages of the three tribes.");
+define("BUILDING_UPGRADING","Building:");
+define("HOURS","hours");
+
+
+//ATTACKS ETC.
+define("TROOP_MOVEMENTS","Troop Movements:");
+define("ARRIVING_REINF_TROOPS","Arriving reinforcing troops");
+define("ARRIVING_REINF_TROOPS_SHORT","Reinf.");
+define("OWN_ATTACKING_TROOPS","Own attacking troops");
+define("ATTACK","Attack");
+define("OWN_REINFORCING_TROOPS","Own reinforcing troops");
+define("TROOPS_DORF","Troops:");
+
+
+//LOGIN.php
+define("COOKIES","You must have cookies enabled to be able to log in. If you share this computer with other people you should log out after each session for your own safety.");
+define("NAME","Name");
+define("PW_FORGOTTEN","Password forgotten?");
+define("PW_REQUEST","Then you can request a new one which will be sent to your email address.");
+define("PW_GENERATE","Generate new password.");
+define("EMAIL_NOT_VERIFIED","Email not verified!");
+define("EMAIL_FOLLOW","Follow this link to activate your account.");
+define("VERIFY_EMAIL","Verify Email.");
+define("SERVER_STARTS_IN","Server will start in: ");
+define("START_NOW","START NOW");
+
+
+//404.php
+define("NOTHING_HERE","Nothing here!");
+define("WE_LOOKED","We looked 404 times already but can't find anything");
+
+//TIME RELATED
+define("CALCULATED","Calculated in");
+define("SERVER_TIME","Server time:");
+
+//MASSMESSAGE.php
+define("MASS","Message Content");
+define("MASS_SUBJECT","Subject:");
+define("MASS_COLOR","Message color:");
+define("MASS_REQUIRED","All fields required");
+define("MASS_UNITS","Images (units):");
+define("MASS_SHOWHIDE","Show/Hide");
+define("MASS_READ","Read this: after adding smilie, you have to add left or right after number otherwise image will won't work");
+define("MASS_CONFIRM","Confirmation");
+define("MASS_REALLY","Do you really want to send MassIGM?");
+define("MASS_ABORT","Aborting right now");
+define("MASS_SENT","Mass IGM was sent");
+
+
+/*
+|--------------------------------------------------------------------------
+| Index
+|--------------------------------------------------------------------------
+*/
+
+ $lang['index'][0][1] = "Welcome to " . SERVER_NAME . "";
+ $lang['index'][0][2] = "Manual";
+ $lang['index'][0][3] = "Play now, for free!";
+ $lang['index'][0][4] = "What is " . SERVER_NAME . "";
+ $lang['index'][0][5] = "" . SERVER_NAME . " is a browser game featuring an engaging ancient world with thousands of other real players.It`s free to play and requires no downloads.";
+ $lang['index'][0][6] = "Click here to play " . SERVER_NAME . "";
+ $lang['index'][0][7] = "Total players";
+ $lang['index'][0][8] = "Players active";
+ $lang['index'][0][9] = "Players online";
+ $lang['index'][0][10] = "About the game";
+ $lang['index'][0][11] = "You will begin as the chief of a tiny village and will embark on an exciting quest.";
+ $lang['index'][0][12] = "Build up villages, wage wars or establish trade routes with your neighbours.";
+ $lang['index'][0][13] = "Play with and against thousands of other real players and conquer the the world of Travian.";
+ $lang['index'][0][14] = "News";
+ $lang['index'][0][15] = "FAQ";
+ $lang['index'][0][16] = "Screenshots";
+ $lang['forum'] = "Forum";
+ $lang['register'] = "Register";
+ $lang['login'] = "Login";
+
+
+?>
diff --git a/GameEngine/Lang/es.php b/GameEngine/Lang/es.php
new file mode 100644
index 00000000..ca7c734e
--- /dev/null
+++ b/GameEngine/Lang/es.php
@@ -0,0 +1,300 @@
+Plus");
+define("CONTACT","Contactenos!");
+
+//MENU
+define("REG","Registarse");
+define("FORUM","Foro");
+define("CHAT","Chat");
+define("IMPRINT","Imprimir");
+define("MORE_LINKS","Enlaces");
+define("TOUR","Tutorial");
+
+//ERRORS
+define("USRNM_EMPTY","(Nombre de usuario vací)");
+define("USRNM_TAKEN","(El nombre ya esta en uso.)");
+define("USRNM_SHORT","(min. ".USRNM_MIN_LENGTH." caracteres)");
+define("USRNM_CHAR","(Caracteres inválidos)");
+define("PW_EMPTY","(Contraseña en blanco)");
+define("PW_SHORT","(min. ".PW_MIN_LENGTH." caracteres)");
+define("PW_INSECURE","(Contrasena insegura. Por favor escoja una con ma´s seguridad.)");
+define("EMAIL_EMPTY","(Correo en blanco)");
+define("EMAIL_INVALID","(Direccio´n de correo inva´lida)");
+define("EMAIL_TAKEN","(El correo ya esta´ en uso)");
+define("TRIBE_EMPTY","
- Por favor escoja una tribu.
");
+define("AGREE_ERROR","- Tiene que estar de acuerdo con las reglas y condicio´n de uso antes de registrarse.
");
+define("LOGIN_USR_EMPTY","Nombre vacío.");
+define("LOGIN_PASS_EMPTY","Contraseña.");
+define("EMAIL_ERROR","El correo electrónico no existe");
+define("PASS_MISMATCH","Las contraseñas no coinciden");
+define("ALLI_OWNER","Por favor escoja un líder de alianza antes de borrarla.");
+define("SIT_ERROR","Cuidador ya configurado");
+define("USR_NT_FOUND","Nombre no existente.");
+define("LOGIN_PW_ERROR","La contraseña es incorrecta.");
+define("WEL_TOPIC","Concejos útiles e información ");
+define("ATAG_EMPTY","Etiqueta vacía");
+define("ANAME_EMPTY","Nombre vacío");
+define("ATAG_EXIST","Etiqueta en uso");
+define("ANAME_EXIST","Nombre en uso");
+
+//COPYRIGHT
+define("TRAVIAN_COPYRIGHT","TravianX Clon de Travian 100% Código Libre.");
+
+//BUILD.TPL
+define("CUR_PROD","Producción actual ");
+define("NEXT_PROD","Producción al nivel ");
+
+//BUILDINGS
+define("B1","Leñador");
+define("B1_DESC","El leñador tala árboles para producir madera. Cuanto más se aumenta su nivel produce más madera.");
+define("B2","Barrera");
+define("B2_DESC","La arcilla se produce aquí. Al incrementar el nivel aumentará la producción de arcilla.");
+define("B3","Mina de Hierro");
+define("B3_DESC","Aquí los mineros producen produce el valioso hierro. Cuanto más se amplíen las minas, más hierro se produce.");
+define("B4","Granja");
+define("B4_DESC","La comida de tu pobleción se produce aquí. Incrementando el nivel de las granjas aumentas la producción de grano.");
+
+//DORF1
+define("LUMBER","Madera");
+define("CLAY","Arcilla");
+define("IRON","Hierro");
+define("CROP","Grano");
+define("LEVEL","Nivel");
+define("CROP_COM",CROP." consumido");
+define("PER_HR","por hora");
+define("PROD_HEADER","Producción");
+define("MULTI_V_HEADER","Villas");
+define("ANNOUNCEMENT","Anuncio");
+define("GO2MY_VILLAGE","Ir a mi villa");
+define("VILLAGE_CENTER","Centro de la Villa");
+define("FINISH_GOLD","¿Terminar todas las construcciones e investigaciones en esta aldea por 2 oros?");
+define("WAITING_LOOP","(lazo de espera)");
+define("HRS","(hrs.)");
+define("DONE_AT","listo a las ");
+define("CANCEL","cancelar");
+
+//QUEST
+define("Q_CONTINUE","Continuar con la siguiente misión.");
+define("Q_REWARD","Su recompensa:");
+define("Q0","¡Biemvenido a ");
+define("Q0_DESC","Veo que se le ha nombrado jefe de este pequeño pueblo. Seré su concejero y mano derecha los primeros días.<\/i>
Puede empesar cumpliendo unas simples tareas por las que será recompensado ¿desea realizarlas?");
+define("Q0_OPT1","Si, comenzar con las tareas.");
+define("Q0_OPT2","Vuelvo\u00a0despues\u00a0en\u00a0un\u00a0rato.");
+define("Q0_OPT3","No gracias, no me interesa.");
+
+define("Q1","Misión 1: Construye un leñador");
+define("Q1_DESC","Alrededor de la aldea hay cuatro bosques verdes. Construye un leñador en cada uno de ellos. La madera es un recurso importante para un nuevo asentamiento");
+define("Q1_ORDER","Orden:<\/p> mejorar un leñador.");
+define("Q1_RESP","Si, de esa manera usted gana mas madera. Ayudé un poquito y completé la orden.");
+define("Q1_REWARD","Finalización inmediata del leñador.");
+
+define("Q2","Misión 2: Cereal");
+define("Q2_DESC","Ahora sus súbditos estan hambrientos por haber trabajado todo el día. Extienda sus granjas para mejorar sus reservas. Regrese cuando la granja esté realizada.");
+define("Q2_ORDER","Order:<\/p>mejorar una granja.");
+define("Q2_RESP","Muy bien. Ahora sus súbditos tiene suficiente comida...");
+
+define("Q3","Misión 3: El Nombre de tu aldea");
+define("Q3_DESC","Creativo como eres le puedes dar el nombre a tu aldea. Haz click en perfil en el lado izquierdo del menú y selecciona cambiar perfil");
+define("Q3_ORDER","Order:<\/p>Change your village's name to something nice.");
+define("Q3_RESP","Wow, un buen nombre para su pueblo. Podría haber nombrado el mio igual...");
+
+define("Q4","Misión 4: Otros jugadores.");
+define("Q4_DESC","En ". SERVER_NAME . " juegas junto con billones de otros jugadores. Haz click en 'Estadisticas' en el menú de arriba para ver tu ranking.");
+define("Q4_ORDER","Orden: <\/p>Buscar tu ranking en las estadisticas e introducirlo aquí.");
+define("Q4_BUTN","completar misión");
+define("Q4_RESP","¡Exactamente! Ese es tu rango.");
+
+define("Q5","Misión 5: Dos ordenes de construcción");
+define("Q5_DESC","Construye una mina de hierro y un barrera. El hierro y el barro nunca son suficientes");
+define("Q5_ORDER","Orden:<\/p>- Ampliar una mina de hierro.<\/li>
- Ampliar una barrera.<\/li><\/ul>");
+define("Q5_RESP","Como habrás notado las ordenes de construcción toman mas tiempo. El mundo de ". SERVER_NAME ." continuará girando incluso si estás desconectado. En unos meses habrán muchas cosas para descubrir.
Lo mejor que puedes hacer es ocacionalmente entrar a tu pueblo y asignar a sus pobladores nuevas tareas y cosas para hacer.");
+
+define("Q6","Mensaje del Taskmaster");
+define("Q6_DESC","Se le informa que tiene un premio del taskmaster esperandolo.
No es necesario responder este mensaje.");
+
+//======================================================//
+//================ UNITS - DO NOT EDIT! ================//
+//======================================================//
+//ROMAN UNITS
+define("U1","Legionnario");
+define("U2","Praetoriano");
+define("U3","Imperiano");
+define("U4","Equites Legati");
+define("U5","Equites Imperatoris");
+define("U6","Equites Caesaris");
+define("U7","Ariete");
+define("U8","Catapulta de fuego");
+define("U9","Senador");
+define("U10","Colono");
+
+//TEUTON UNITS
+define("U11","Clubswinger");
+define("U12","Lancero");
+define("U13","Hachero");
+define("U14","Explorador");
+define("U15","Paladin");
+define("U16","Caballero Teutón");
+define("U17","Ariete");
+define("U18","Catapulta");
+define("U19","Jefe Teutón");
+define("U20","Colono");
+
+//GAUL UNITS
+define("U21","Phalange");
+define("U22","Espadachín");
+define("U23","Pionero");
+define("U24","Trueno de Tutatis");
+define("U25","Druida");
+define("U26","Haeduan");
+define("U27","Ariete");
+define("U28","Trebuchet");
+define("U29","Jefe Galo");
+define("U30","Colono");
+
+//NATURE UNITS
+define("U31","Rata");
+define("U32","Araña");
+define("U33","Serpiente");
+define("U34","Murciélago");
+define("U35","Javalí");
+define("U36","Lobo");
+define("U37","Oso");
+define("U38","Cocodrilo");
+define("U39","Tigre");
+define("U40","Elefante");
+
+//NATARS UNITS
+define("U41","Piquero");
+define("U42","Guerrero Espinoso");
+define("U43","Defensor");
+define("U44","Pájaro de Presa");
+define("U45","Hachero Jinete");
+define("U46","Caballero Natariano");
+define("U47","Elefante de Guerra");
+define("U48","Ballesta");
+define("U49","Emperador Natariano");
+
+//INDEX.php
+define("LOGIN","Entrar");
+define("PLAYERS","Jugadores");
+define("ONLINE","Conectados");
+define("TUTORIAL","Tutorial");
+define("PLAYER_STATISTICS","Estadísticas de Jugadores");
+define("TOTAL_PLAYERS","".PLAYERS." en total");
+define("ACTIVE_PLAYERS","jugadores activos");
+define("ONLINE_PLAYERS","".PLAYERS." conectados");
+define("MP_STRATEGY_GAME","".SERVER_NAME." - el juego de estrategia multijugador.");
+define("WHAT_IS","".SERVER_NAME." es uno de los juegos onlines más conocidos en el mundo. Como jugador de ".SERVER_NAME." puedes construir tu propio imperio, reclutar tu propio ejercito y pelear con tus aliados para la conquista del mundo.");
+define("REGISTER_FOR_FREE","Registrase aquí gratis!");
+define("LATEST_GAME_WORLD","Nuevo mundo");
+define("LATEST_GAME_WORLD2","Registrate en el último
mundo y disfruta
las ventajas de
ser uno de los
primeros jugadores.");
+define("PLAY_NOW","Jugar ".SERVER_NAME." ahora");
+define("LEARN_MORE","Aprende más sobre ".SERVER_NAME."!");
+define("LEARN_MORE2","Ahora con un revolucionario
sistema y gráficos
completamente nuevos
Este clon es el mejor!");
+define("COMUNITY","Comunidad");
+define("BECOME_COMUNITY","Unete ahora!");
+define("BECOME_COMUNITY2","Forma parte de una
de la mayor comunida
de jugadores del mundo.");
+define("NEWS","Noticias");
+define("SCREENSHOTS","Galería de Imágenes");
+define("LEARN1","Mejora tus sembrados y minas para aumentar la producción de recursos. Necesitarás recursos para construir y entrenar soldados.");
+define("LEARN2","Construlle y mejora los edificios en tu aldea. Los edificios mejoran la infraestructura, aumentan la producción y te permiten investigar, entrenar y equipar tus tropas.");
+define("LEARN3","Observa e interactúa con tus alrededores. Puedes hacer nuevos amigos o enemigos, Utiliza los oasis cercanos y asegura que tu imperio crezca y se fortalezca.");
+define("LEARN4","Sigue tus logros y compárate con otros jugadores. Mira la tabla de los 10 mejores y lucha por obtener una medalla de la semana.");
+define("LEARN5","Recibe reportes detallados de tus aventuras, intercambio y batallas.");
+define("LEARN6","Intercambia información y sé diplomático con otros jugadores. Siempre recuerda que la comunicación es la llave para obtener nuevos amigos y resolver viejas disputas.");
+define("LOGIN_TO","Entrar a ". SERVER_NAME);
+define("REGIN_TO","Registrarse en ". SERVER_NAME);
+define("P_ONLINE","Jugadores en línea: ");
+define("P_TOTAL","Jugadores en total: ");
+define("CHOOSE","Escoja un servidor por favor.");
+define("STARTED"," El servidor empezó hace ". round((time()-COMMENCE)/86400) ." días.");
+
+//ANMELDEN.php
+define("NICKNAME","Sobrenombre");
+define("EMAIL","Correo");
+define("PASSWORD","Contraseña");
+define("ROMANS","Romanos");
+define("TEUTONS","Germanos");
+define("GAULS","Galos");
+define("NW","Noroeste");
+define("NE","Noreste");
+define("SW","Suroeste");
+define("SE","Sureste");
+define("RANDOM","al azar");
+define("ACCEPT_RULES"," Estoy de acuerdo con las reglas y las condiciones generales de uso.");
+define("ONE_PER_SERVER","Cada jugador puede tener solo una cuenta en el servidor.");
+define("BEFORE_REGISTER","Si deseas ver un resumen de las ventajas y desventajas de cada raza, puedes hacerlo aquí.");
+define("BUILDING_UPGRADING","Construyendo:");
+define("HOURS","horas");
+
+
+//ATTACKS ETC.
+define("TROOP_MOVEMENTS","movimientos de tropa:");
+define("ARRIVING_REINF_TROOPS","Llegando refuerzos");
+define("ARRIVING_REINF_TROOPS_SHORT","Refuer.");
+define("OWN_ATTACKING_TROOPS","Tropas atacando");
+define("ATTACK","Ataque");
+define("OWN_REINFORCING_TROOPS","Refuerzos despachados");
+define("TROOPS_DORF","Tropas:");
+
+
+//LOGIN.php
+define("COOKIES","Tienes que tener las cookies habilitadas para poder entrar. Si compartes ordenador con más jugadores o estás en un lugar público, asegúrate de cerrar la sesión cuando salgas por tu propia seguridad.");
+define("NAME","Nombre");
+define("PW_FORGOTTEN","Olvidó la contraseña?");
+define("PW_REQUEST","Entonces puede solicitar una que le será enviada a su dirección de correo.");
+define("PW_GENERATE","Pedir nueva contraseña");
+define("EMAIL_NOT_VERIFIED","Correo no verificado!");
+define("EMAIL_FOLLOW","Sigue este vínculo para activar este enlace.");
+define("VERIFY_EMAIL","Verificar Correo.");
+
+
+//404.php
+define("NOTHING_HERE","No hay nada ahí!");
+define("WE_LOOKED","Buscamos 404 veces pero no encontramos nada");
+
+//TIME RELATED
+define("CALCULATED","Calculado en");
+define("SERVER_TIME","Tiempo funcionando:");
+
+//MASSMESSAGE.php
+define("MASS","Contenido del mensaje");
+define("MASS_SUBJECT","Asunto:");
+define("MASS_COLOR","Color del Mensaje:");
+define("MASS_REQUIRED","Todos los campos son requeridos");
+define("MASS_UNITS","Imagenes (unidades):");
+define("MASS_SHOWHIDE","Mostrar/Ocultar");
+define("MASS_READ","Lee esto: despues de enviar un smiley, hay que añadir a la izquierda o la derecha después de un número de otro modo la imagen no funciona.");
+define("MASS_CONFIRM","Confirmación");
+define("MASS_REALLY","Realmente quieres enviar un mensaje en masa?");
+define("MASS_ABORT","Abortar?");
+define("MASS_SENT","El mensaje en masa fue enviado");
+
+//BUILDINGS
+define("ACADEMY_NAME","Academia");
+define("BARRACK_NAME","Barraca");
+
+?>
\ No newline at end of file
diff --git a/GameEngine/Lang/ru.php b/GameEngine/Lang/ru.php
new file mode 100644
index 00000000..7de8c090
--- /dev/null
+++ b/GameEngine/Lang/ru.php
@@ -0,0 +1,454 @@
+Plus");
+define("CONTACT","Связь с нами!");
+define("GAME_RULES","Правила игры");
+
+//MENU
+define("REG","Регистрация");
+define("FORUM","Форум");
+define("CHAT","Чат");
+define("IMPRINT","Распечатать");
+define("MORE_LINKS","Больше");
+define("TOUR","Турнир");
+
+
+//ERRORS
+define("USRNM_EMPTY","(пустое имя пользователя)");
+define("USRNM_TAKEN","(Имя уже используется)");
+define("USRNM_SHORT","(мин. ".USRNM_MIN_LENGTH." символов)");
+define("USRNM_CHAR","(Неверные символы)");
+define("PW_EMPTY","(Пустой пароль)");
+define("PW_SHORT","(мин. ".PW_MIN_LENGTH." символов)");
+define("PW_INSECURE","(Простой пароль. Придумайте более сложный)");
+define("EMAIL_EMPTY","(Пустой email)");
+define("EMAIL_INVALID","(Неправильный email)");
+define("EMAIL_TAKEN","(Email уже используется)");
+define("TRIBE_EMPTY"," - Выберите племя.
");
+define("AGREE_ERROR","- Вы должны принять правила игры и общие условия и условия для того, чтобы зарегистрироваться.
");
+define("LOGIN_USR_EMPTY","Введите имя.");
+define("LOGIN_PASS_EMPTY","Введите паролб.");
+define("EMAIL_ERROR","Электронный адрес не соответствует существующему");
+define("PASS_MISMATCH","Пароли не совпадают");
+define("ALLI_OWNER","Пожалуйста, назначьте владельца перед удалением");
+define("SIT_ERROR","Уже установленно");
+define("USR_NT_FOUND","Имя пользователя не существует.");
+define("LOGIN_PW_ERROR","Пароль неправильный.");
+define("WEL_TOPIC","Useful tips & information ");
+define("ATAG_EMPTY","Тэг пуст");
+define("ANAME_EMPTY","Название пустое");
+define("ATAG_EXIST","Тэг принят");
+define("ANAME_EXIST","Название принято");
+define("NOT_OPENED_YET","Сервер еще не запущен.");
+
+//COPYRIGHT
+define("TRAVIAN_COPYRIGHT","TravianX 100% Open Source Travian Clone.");
+
+//BUILD.TPL
+define("CUR_PROD","Текущее производство");
+define("NEXT_PROD","Производство на уровне ");
+
+//BUILDINGS
+define("B1","Лесопилка");
+define("B1_DESC","На лесопилке идет производство древесины. С увеличением уровня развития здания увеличивается его производительность.");
+define("B2","Глиняный карьер");
+define("B2_DESC","На глиняном карьере добывают сырье глину. С развитием глиняного карьера увеличивается его производительность.");
+define("B3","Железный карьер");
+define("B3_DESC","На железных рудниках шахтеры добывают ценное сырье – железо. С развитием рудника увеличивается его производительность.");
+define("B4","Ферма");
+define("B4_DESC","На фермах выращивают зерно для обеспечения продовольствием населения. С развитием фермы увеличивается ее производительность.");
+
+//DORF1
+define("LUMBER","Древесина");
+define("CLAY","Глина");
+define("IRON","Железо");
+define("CROP","Зерно");
+define("LEVEL","Уровень");
+define("CROP_COM","Потребление зерна");
+define("DURATION","Время строительства");
+define("PER_HR","в час");
+define("PROD_HEADER","Производство");
+define("MULTI_V_HEADER","Деревни");
+define("ANNOUNCEMENT","Объявление");
+define("GO2MY_VILLAGE","Войти в мою деревню");
+define("VILLAGE_CENTER","Центр деревни");
+define("FINISH_GOLD","Завершить все строительство и исследования в деревне за 2 золота?");
+define("WAITING_LOOP","(очередь)");
+define("HRS","ч.");
+define("DONE_AT","будет завершено в");
+define("CANCEL","отмена");
+define("LOYALTY","Лояльность:");
+define("CALCULATED_IN","Создана за");
+define("SEVER_TIME","Время сервера:");
+define("MILISECS","мс");
+
+//QUEST
+define("Q_CONTINUE","Перейти к следующему заданию.");
+define("Q_REWARD","Ваша награда:");
+define("Q0","Добро пожаловать ");
+define("Q0_DESC","As I see you have been made chieftain of this little village. I will be your counselor for the first few days and never leave your (right hand) side.");
+define("Q0_OPT1","To the first task.");
+define("Q0_OPT2","Look around on your own.");
+define("Q0_OPT3","Play no tasks.");
+
+define("Q1","Task 1: Woodcutter");
+define("Q1_DESC","There are four green forests around your village. Construct a woodcutter on one of them. Lumber is an important resource for our new settlement.");
+define("Q1_ORDER","Order:<\/p>Construct a woodcutter.");
+define("Q1_RESP","Yes, that way you gain more lumber.I helped a bit and completed the order instantly.");
+define("Q1_REWARD","Woodcutter instantly completed.");
+
+define("Q2","Task 2: Crop");
+define("Q2_DESC","Now your subjects are hungry from working all day. Extend a cropland to improve your subjects' supply. Come back here once the building is complete.");
+define("Q2_ORDER","Order:<\/p>Extend one cropland.");
+define("Q2_RESP","Very good. Now your subjects have enough to eat again...");
+
+define("Q3","Task 3: Your Village's Name");
+define("Q3_DESC","Creative as you are you can grant your village the ultimate name.\r\n
\r\nClick on 'profile' in the left hand menu and then select 'change profile'...");
+define("Q3_ORDER","Order:<\/p>Change your village's name to something nice.");
+define("Q3_RESP","Wow, a great name for their village. It could have been the name of my village!...");
+
+define("Q4","Task 4: Other Players");
+define("Q4_DESC","In ". SERVER_NAME ." you play along with billions of other players. Click 'statistics' in the top menu to look up your rank and enter it here.");
+define("Q4_ORDER","Order:<\/p>Look for your rank in the statistics and enter it here.");
+define("Q4_BUTN","complete task");
+define("Q4_RESP","Exactly! That's your rank.");
+
+define("Q5","Task 5: Two Building Orders");
+define("Q5_DESC","Build an iron mine and a clay pit. Of iron and clay one can never have enough.");
+define("Q5_ORDER","Order:<\/p>- Extend one iron mine.<\/li>
- Extend one clay pit.<\/li><\/ul>");
+define("Q5_RESP","As you noticed, building orders take rather long. The world of ". SERVER_NAME ." will continue to spin even if you are offline. Even in a few months there will be many new things for you to discover.\r\n
\r\nThe best thing to do is occasionally checking your village and giving you subjects new tasks to do.");
+
+define("Q6","Message From The Taskmaster");
+define("Q6_DESC","You are to be informed that a nice reward is waiting for you at the taskmaster.
Hint: The message has been generated automatically. An answer is not necessary.");
+
+define("Q5","Task 5: Two Building Orders");
+define("Q5_DESC","Build an iron mine and a clay pit. Of iron and clay one can never have enough.");
+define("Q5_ORDER","Order:<\/p>- Extend one iron mine.<\/li>
- Extend one clay pit.<\/li><\/ul>");
+define("Q5_RESP","As you noticed, building orders take rather long. The world of ". SERVER_NAME ." will continue to spin even if you are offline. Even in a few months there will be many new things for you to discover.\r\n
\r\nThe best thing to do is occasionally checking your village and giving you subjects new tasks to do.");
+
+//======================================================//
+//================ UNITS - DO NOT EDIT! ================//
+//======================================================//
+define("U0","Герой");
+
+//ROMAN UNITS
+define("U1","Легионер");
+define("U2","Преторианец");
+define("U3","Империанец");
+define("U4","Конный разведчик");
+define("U5","Конница императора");
+define("U6","Конница Цезаря");
+define("U7","Таран");
+define("U8","Огненная катапульта");
+define("U9","Сенатор");
+define("U10","Поселенец");
+
+//TEUTON UNITS
+define("U11","Дубинщик");
+define("U12","Копейщик");
+define("U13","Топорщик");
+define("U14","Скаут");
+define("U15","Паладин");
+define("U16","Тевтонская конница");
+define("U17","Стенобитное орудие");
+define("U18","Катапульта");
+define("U19","Вождь");
+define("U20","Поселенец");
+
+//GAUL UNITS
+define("U21","Фаланга");
+define("U22","Мечник");
+define("U23","Следопыт");
+define("U24","Тевтатский гром");
+define("U25","Друид-всадник");
+define("U26","Эдуйская конница");
+define("U27","Стенобитное орудие");
+define("U28","Требушет");
+define("U29","Предводитель");
+define("U30","Поселенец");
+
+//NATURE UNITS
+define("U31","Крыса");
+define("U32","Паук");
+define("U33","Змея");
+define("U34","Летучая мышь");
+define("U35","Кабан");
+define("U36","Волк");
+define("U37","Медведь");
+define("U38","Крокодил");
+define("U39","Тигр");
+define("U40","Слон");
+
+//NATARS UNITS
+define("U41","Пикейщик");
+define("U42","Дубинщик с шипами");
+define("U43","Гвардеец");
+define("U44","Ворон");
+define("U45","Всадник с топором");
+define("U46","Рыцарь Натаров");
+define("U47","Боевой слон");
+define("U48","Балиста");
+define("U49","Принц Натаров");
+define("U50","Поселенец");
+
+//MONSTER UNITS
+define("U51","Monster Peon");
+define("U52","Monster Hunter");
+define("U53","Monster Warrior");
+define("U54","Ghost");
+define("U55","Monster Steed");
+define("U56","Monster War Steed");
+define("U57","Monster Ram");
+define("U58","Monster Catapult");
+define("U59","Monster Chief");
+define("U60","Monster Settler");
+
+//INDEX.php
+define("LOGIN","Логин");
+define("PLAYERS","Игроки");
+define("ONLINE","Онлайн");
+define("TUTORIAL","Учебник");
+define("PLAYER_STATISTICS","Статистика пользователя");
+define("TOTAL_PLAYERS","Общее число игроков");
+define("ACTIVE_PLAYERS","Активные пользователи");
+define("ONLINE_PLAYERS",PLAYERS." онлайн");
+define("MP_STRATEGY_GAME","".SERVER_NAME." - многопользовательская онлайн игра");
+define("WHAT_IS","".SERVER_NAME." одна из самых популярных браузерных игр в мире. В качестве игрока вы увеличиваете и развиваете свои владения, тренируете войска и вместе с альянсом сражаетесь за господство над игровым миром.");
+define("REGISTER_FOR_FREE","Зарегистрироваться!");
+define("LATEST_GAME_WORLD","Новый сервер");
+define("LATEST_GAME_WORLD2","Зарегистрируйтесь на самом
новом сервере и наслаждайтесь
преимуществом первого игрока.");
+define("PLAY_NOW","Играть ".SERVER_NAME." сейчас");
+define("LEARN_MORE","Узнать
больше о ".SERVER_NAME."!");
+define("LEARN_MORE2","Now with a revolutionised
server system, completely new
graphics
This clone is The Shiz!");
+define("COMUNITY","Community");
+define("BECOME_COMUNITY","Become part of our community now!");
+define("BECOME_COMUNITY2","Become a part of one of
the biggest gaming
communities in the
world.");
+define("NEWS","Новости");
+define("SCREENSHOTS","Скриншоты");
+define("LEARN1","Upgrade your fields and mines to increase your resource production. You will need resources to construct buildings and train soldiers.");
+define("LEARN2","Construct and expand the buildings in your village. Buildings improve your overall infrastructure, increase your resource production and allow you to research, train and upgrade your troops.");
+define("LEARN3","View and interact with your surroundings. You can make new friends or new enemies, make use of the nearby oases and observe as your empire grows and becomes stronger.");
+define("LEARN4","Follow your improvement and success and compare yourself to other players. Look at the Top 10 rankings and fight to win a weekly medal.");
+define("LEARN5","Receive detailed reports about your adventures, trades and battles. Don't forget to check the brand new reports about the happenings taking place in your surroundings.");
+define("LEARN6","Exchange information and conduct diplomacy with other players. Always remember that communication is the key to winning new friends and solving old conflicts.");
+define("LOGIN_TO","Log in to ". SERVER_NAME);
+define("REGIN_TO","Зарегистрироваться на ". SERVER_NAME);
+define("P_ONLINE","Players online: ");
+define("P_TOTAL","Players in total: ");
+define("CHOOSE","Please choose a server.");
+define("STARTED"," The server started ". round((time()-COMMENCE)/86400) ." days ago.");
+
+//ANMELDEN.php
+define("NICKNAME","Логин");
+define("EMAIL","Email");
+define("PASSWORD","Пароль");
+define("ROMANS","Римляне");
+define("TEUTONS","Германцы");
+define("GAULS","Галлы");
+define("NW","Северо-запад");
+define("NE","Северо-восток");
+define("SW","Юго-запад");
+define("SE","Юго-восток");
+define("RANDOM","случайно");
+define("ACCEPT_RULES"," Я согласен с условиями и предупреждениями.");
+define("ONE_PER_SERVER","Каждый игром имеет право иметь только один аккаунт на сервере.");
+define("BEFORE_REGISTER","Перед тем как зарегистрироваться прочитайте инструкции TravianX чтобы понять особенности различных игровых племен на сервере.");
+define("BUILDING_UPGRADING","Строительство:");
+define("HOURS","ч.");
+
+
+//ATTACKS ETC.
+define("TROOP_MOVEMENTS","Перемещения войск:");
+define("ARRIVING_REINF_TROOPS","Прибытие войск");
+define("ARRIVING_REINF_TROOPS_SHORT","Приб.");
+define("OWN_ATTACKING_TROOPS","Собственные атакующие войска");
+define("ATTACK","Атака");
+define("OWN_REINFORCING_TROOPS","Собственные прибивающие войска");
+define("TROOPS_DORF","Войска:");
+
+
+//LOGIN.php
+define("COOKIES","You must have cookies enabled to be able to log in. If you share this computer with other people you should log out after each session for your own safety.");
+define("NAME","Имя");
+define("PW_FORGOTTEN","Забыли пароль?");
+define("PW_REQUEST","Вы можете запросить другой пароль на свой почтовый адрес.");
+define("PW_GENERATE","Создать новый пароль.");
+define("EMAIL_NOT_VERIFIED","Email nне принят!");
+define("EMAIL_FOLLOW","Проследуйте по следующей ссылке чтобы активировать аккаунт.");
+define("VERIFY_EMAIL","Email подтвержден.");
+
+
+//404.php
+define("NOTHING_HERE","Ничего тут!");
+define("WE_LOOKED","Мы посмотрели 404 раза и ничего не нашли");
+
+//TIME RELATED
+define("CALCULATED","Саздана за");
+define("SERVER_TIME","Время сервера:");
+
+//MASSMESSAGE.php
+define("MASS","Сообщение");
+define("MASS_SUBJECT","Тема:");
+define("MASS_COLOR","Цвет сообщения:");
+define("MASS_REQUIRED","Все поля рекомендуемые");
+define("MASS_UNITS","Картинки (еденицы):");
+define("MASS_SHOWHIDE","Показать/Скрыть");
+define("MASS_READ","Read this: after adding smilie, you have to add left or right after number otherwise image will won't work");
+define("MASS_CONFIRM","Confirmation");
+define("MASS_REALLY","Do you really want to send MassIGM?");
+define("MASS_ABORT","Aborting right now");
+define("MASS_SENT","Mass IGM was sent");
+
+
+/*
+|--------------------------------------------------------------------------
+| Index
+|--------------------------------------------------------------------------
+*/
+
+ $lang['index'][0][1] = "Welcome to " . SERVER_NAME . "";
+ $lang['index'][0][2] = "Manual";
+ $lang['index'][0][3] = "Play now, for free!";
+ $lang['index'][0][4] = "What is " . SERVER_NAME . "";
+ $lang['index'][0][5] = "" . SERVER_NAME . " is a browser game featuring an engaging ancient world with thousands of other real players.It`s free to play and requires no downloads.";
+ $lang['index'][0][6] = "Click here to play " . SERVER_NAME . "";
+ $lang['index'][0][7] = "Total players";
+ $lang['index'][0][8] = "Players active";
+ $lang['index'][0][9] = "Players online";
+ $lang['index'][0][10] = "About the game";
+ $lang['index'][0][11] = "You will begin as the chief of a tiny village and will embark on an exciting quest.";
+ $lang['index'][0][12] = "Build up villages, wage wars or establish trade routes with your neighbours.";
+ $lang['index'][0][13] = "Play with and against thousands of other real players and conquer the the world of Travian.";
+ $lang['index'][0][14] = "News";
+ $lang['index'][0][15] = "FAQ";
+ $lang['index'][0][16] = "Screenshots";
+ $lang['forum'] = "Forum";
+ $lang['register'] = "Регистрация";
+ $lang['login'] = "Login";
+
+/*
+|--------------------------------------------------------------------------
+| top_menu
+|--------------------------------------------------------------------------
+*/
+ $lang['header'] = array (
+ 0 => 'Обзор деревни',
+ 1 => 'Центр деревни',
+ 2 => 'Карта',
+ 3 => 'Статистика',
+ 4 => 'Отчеты',
+ 5 => 'Сообщения',
+ 6 => 'Plus меню');
+
+ $lang['buildings'] = array (
+ 1 => "Лесопилка",
+ 2 => "Глиняный карьер",
+ 3 => "Железный рудник",
+ 4 => "Ферма",
+ 5 => "Лесопильный завод",
+ 6 => "Кирпичный завод",
+ 7 => "Сталелитейный завод",
+ 8 => "Мукомольная мельница",
+ 9 => "Пекарня",
+ 10 => "Склад",
+ 11 => "Амбар",
+ 12 => "Кузня",
+ 13 => "Оружейня",
+ 14 => "Арена",
+ 15 => "Главное здание",
+ 16 => "Пункт сбора",
+ 17 => "Рынок",
+ 18 => "Посольство",
+ 19 => "Казарма",
+ 20 => "Канюшня",
+ 21 => "Мастерская",
+ 22 => "Академия",
+ 23 => "Тайник",
+ 24 => "Ратуша",
+ 25 => "Резиденция",
+ 26 => "Дворец",
+ 27 => "Сокровищница",
+ 28 => "Торговая палата",
+ 29 => "Большая казарма",
+ 30 => "Большая конюшня",
+ 31 => "Городская стена",
+ 32 => "Земляной вал",
+ 33 => "Изгородь",
+ 34 => "Каменотес",
+ 35 => "Пивоваренный завод",
+ 36 => "Капканщик",
+ 37 => "Таверна",
+ 38 => "Большой склад",
+ 39 => "Большой амбар",
+ 40 => "Чудо Света",
+ 41 => "Водопой",
+ 42 => "Большая мастерская",
+ 43 => "Ошибка",
+ 44 => " (уровень ");
+
+ $lang['fields'] = array (
+ 0 => ' уровень',
+ 1 => 'Лесопилка уровень',
+ 2 => 'Глиняный карьер уровень ',
+ 3 => 'Железный рудник уровень',
+ 4 => 'Ферма уровень',
+ 5 => 'Наружняя строительная площадка',
+ 6 => 'Строительная площадка',
+ 7 => 'Строительная площадка пункта сбора');
+
+ $lang['npc'] = array (
+ 0 => 'NPC торговец');
+
+ $lang['upgrade'] = array (
+ 0 => 'Здание уже на максимальном уровне',
+ 1 => 'Максимальный уровень здания строится',
+ 2 => 'Здание будет снесено',
+ 3 => 'Стоимость строительства до уровня ',
+ 4 => 'Рабочие заняты.',
+ 5 => 'Не хватает еды. Развивайте фермы.',
+ 6 => 'Постройте склад.',
+ 7 => 'Постройте амбар.',
+ 8 => 'Достаточно ресурсов будет ',
+ 9 => ' в ',
+ 10 => 'Улучшить до уровня ',
+ 11 => 'сегодня',
+ 12 => 'завтра');
+
+ $lang['movement'] = array (
+ 0 => 'в ');
+
+ $lang['troops'] = array (
+ 0 => 'нет',
+ 1 => 'Герой');
+?>
diff --git a/GameEngine/Lang/zh_tw.php b/GameEngine/Lang/zh_tw.php
new file mode 100644
index 00000000..cd23fe6b
--- /dev/null
+++ b/GameEngine/Lang/zh_tw.php
@@ -0,0 +1,372 @@
+Plus");
+define("CONTACT","聯絡我們!");
+define("GAME_RULES","遊戲規定");
+
+//MENU
+define("REG","註冊");
+define("FORUM","論壇");
+define("CHAT","聊天室");
+define("IMPRINT","Imprint");
+define("MORE_LINKS","更多連結");
+define("TOUR","Game Tour");
+
+
+//ERRORS
+define("USRNM_EMPTY","(Username empty)");
+define("USRNM_TAKEN","(Name is already in use.)");
+define("USRNM_SHORT","(min. ".USRNM_MIN_LENGTH." figures)");
+define("USRNM_CHAR","(Invalid Characters)");
+define("PW_EMPTY","(Password empty)");
+define("PW_SHORT","(min. ".PW_MIN_LENGTH." figures)");
+define("PW_INSECURE","(Password insecure. Please choose a more secure one.)");
+define("EMAIL_EMPTY","(Email Empty)");
+define("EMAIL_INVALID","(Invalid email address)");
+define("EMAIL_TAKEN","(Email is already in use)");
+define("TRIBE_EMPTY","
- Please choose a tribe.
");
+define("AGREE_ERROR","- You have to agree to the game rules and the general terms & conditions in order to register.
");
+define("LOGIN_USR_EMPTY","Enter name.");
+define("LOGIN_PASS_EMPTY","Enter password.");
+define("EMAIL_ERROR","Email does not match existing");
+define("PASS_MISMATCH","Passwords do not match");
+define("ALLI_OWNER","Please appoint an alliance owner before deleting");
+define("SIT_ERROR","Sitter already set");
+define("USR_NT_FOUND","Name does not exist.");
+define("LOGIN_PW_ERROR","The password is wrong.");
+define("WEL_TOPIC","Useful tips & information ");
+define("ATAG_EMPTY","Tag empty");
+define("ANAME_EMPTY","Name empty");
+define("ATAG_EXIST","Tag taken");
+define("ANAME_EXIST","Name taken");
+define("NOT_OPENED_YET","Server not started yet.");
+define("REGISTER_CLOSED","The register is closed. You can't register to this server.");
+define("NAME_EMPTY","Please insert name");
+define("NAME_NO_EXIST","There is no user with the name ");
+define("ID_NO_EXIST","There is no user with the id ");
+define("SAME_NAME","You can't invite yourself");
+define("ALREADY_INVITED"," already invited");
+define("ALREADY_IN_ALLY"," already in this alliance");
+
+//COPYRIGHT
+define("TRAVIAN_COPYRIGHT","TravianZ 100% Open Source Travian Clone.");
+
+//BUILD.TPL
+define("CUR_PROD","目前的產量");
+define("NEXT_PROD","產量在等級 ");
+
+//BUILDINGS
+define("B1","伐木場");
+define("B1_DESC","伐木場是砍伐木材的地方.伐木場等級越高,單位時間內能砍伐的木材也就越多.");
+define("B2","泥坑");
+define("B2_DESC","泥坑是生產泥土的地方.泥坑等級越高,單位時間內生產的磚塊也就越多.");
+define("B3","鐵礦場");
+define("B3_DESC","鐵礦場是用來採集鐵礦的.鐵礦場等級越高,每小時能採集的鐵礦就越多.");
+define("B4","農場");
+define("B4_DESC","農場是為居民生產糧食的地方.農場等級越高,所能生產的糧食也就越多.");
+
+//DORF1
+define("LUMBER","木材");
+define("CLAY","磚塊");
+define("IRON","鋼鐵");
+define("CROP","穀物");
+define("LEVEL","等級");
+define("CROP_COM",CROP." consumption");
+define("PER_HR","每小時");
+define("PROD_HEADER","生產");
+define("MULTI_V_HEADER","村莊");
+define("ANNOUNCEMENT","Announcement");
+define("GO2MY_VILLAGE","回到我的村莊");
+define("VILLAGE_CENTER","地圖中心");
+define("FINISH_GOLD","花費2金,結束這個村莊當前建築任務或者兵種研發, 升級的任務. (除了皇宮和行宮)");
+define("WAITING_LOOP","(等待建築)");
+define("HRS","(hrs.)");
+define("DONE_AT","結束在");
+define("CANCEL","取消");
+define("LOYALTY","Loyalty:");
+define("CALCULATED_IN","產生在");
+define("SEVER_TIME","伺服器時間:");
+
+//QUEST
+define("Q_CONTINUE","Continue with the next task.");
+define("Q_REWARD","Your reward:");
+define("Q0","Welcome to ");
+define("Q0_DESC","As I see you have been made chieftain of this little village. I will be your counselor for the first few days and never leave your (right hand) side.");
+define("Q0_OPT1","To the first task.");
+define("Q0_OPT2","Look around on your own.");
+define("Q0_OPT3","Play no tasks.");
+
+define("Q1","Task 1: Woodcutter");
+define("Q1_DESC","There are four green forests around your village. Construct a woodcutter on one of them. Lumber is an important resource for our new settlement.");
+define("Q1_ORDER","Order:<\/p>Construct a woodcutter.");
+define("Q1_RESP","Yes, that way you gain more lumber.I helped a bit and completed the order instantly.");
+define("Q1_REWARD","Woodcutter instantly completed.");
+
+define("Q2","Task 2: Crop");
+define("Q2_DESC","Now your subjects are hungry from working all day. Extend a cropland to improve your subjects' supply. Come back here once the building is complete.");
+define("Q2_ORDER","Order:<\/p>Extend one cropland.");
+define("Q2_RESP","Very good. Now your subjects have enough to eat again...");
+
+define("Q3","Task 3: Your Village's Name");
+define("Q3_DESC","Creative as you are you can grant your village the ultimate name.\r\n
\r\nClick on 'profile' in the left hand menu and then select 'change profile'...");
+define("Q3_ORDER","Order:<\/p>Change your village's name to something nice.");
+define("Q3_RESP","Wow, a great name for their village. It could have been the name of my village!...");
+
+define("Q4","Task 4: Other Players");
+define("Q4_DESC","In ". SERVER_NAME ." you play along with billions of other players. Click 'statistics' in the top menu to look up your rank and enter it here.");
+define("Q4_ORDER","Order:<\/p>Look for your rank in the statistics and enter it here.");
+define("Q4_BUTN","complete task");
+define("Q4_RESP","Exactly! That's your rank.");
+
+define("Q5","Task 5: Two Building Orders");
+define("Q5_DESC","Build an iron mine and a clay pit. Of iron and clay one can never have enough.");
+define("Q5_ORDER","Order:<\/p>- Extend one iron mine.<\/li>
- Extend one clay pit.<\/li><\/ul>");
+define("Q5_RESP","As you noticed, building orders take rather long. The world of ". SERVER_NAME ." will continue to spin even if you are offline. Even in a few months there will be many new things for you to discover.\r\n
\r\nThe best thing to do is occasionally checking your village and giving you subjects new tasks to do.");
+
+define("Q6","Message From The Taskmaster");
+define("Q6_DESC","You are to be informed that a nice reward is waiting for you at the taskmaster.
Hint: The message has been generated automatically. An answer is not necessary.");
+
+define("Q5","Task 5: Two Building Orders");
+define("Q5_DESC","Build an iron mine and a clay pit. Of iron and clay one can never have enough.");
+define("Q5_ORDER","Order:<\/p>- Extend one iron mine.<\/li>
- Extend one clay pit.<\/li><\/ul>");
+define("Q5_RESP","As you noticed, building orders take rather long. The world of ". SERVER_NAME ." will continue to spin even if you are offline. Even in a few months there will be many new things for you to discover.\r\n
\r\nThe best thing to do is occasionally checking your village and giving you subjects new tasks to do.");
+
+//======================================================//
+//================ UNITS - DO NOT EDIT! ================//
+//======================================================//
+define("U0","英雄");
+
+//ROMAN UNITS
+define("U1","Legionnaire");
+define("U2","Praetorian");
+define("U3","Imperian");
+define("U4","Equites Legati");
+define("U5","Equites Imperatoris");
+define("U6","Equites Caesaris");
+define("U7","Battering Ram");
+define("U8","Fire Catapult");
+define("U9","Senator");
+define("U10","Settler");
+
+//TEUTON UNITS
+define("U11","Clubswinger");
+define("U12","Spearman");
+define("U13","Axeman");
+define("U14","Scout");
+define("U15","Paladin");
+define("U16","Teutonic Knight");
+define("U17","Ram");
+define("U18","Catapult");
+define("U19","Chief");
+define("U20","Settler");
+
+//GAUL UNITS
+define("U21","Phalanx");
+define("U22","Swordsman");
+define("U23","Pathfinder");
+define("U24","Theutates Thunder");
+define("U25","Druidrider");
+define("U26","Haeduan");
+define("U27","Ram");
+define("U28","Trebuchet");
+define("U29","Chieftain");
+define("U30","Settler");
+define("U99","Trap");
+
+//NATURE UNITS
+define("U31","Rat");
+define("U32","Spider");
+define("U33","Snake");
+define("U34","Bat");
+define("U35","Wild Boar");
+define("U36","Wolf");
+define("U37","Bear");
+define("U38","Crocodile");
+define("U39","Tiger");
+define("U40","Elephant");
+
+//NATARS UNITS
+define("U41","Pikeman");
+define("U42","Thorned Warrior");
+define("U43","Guardsman");
+define("U44","Birds Of Prey");
+define("U45","Axerider");
+define("U46","Natarian Knight");
+define("U47","War Elephant");
+define("U48","Ballista");
+define("U49","Natarian Emperor");
+define("U50","Natarian Settler");
+
+//MONSTER UNITS
+define("U51","Monster Peon");
+define("U52","Monster Hunter");
+define("U53","Monster Warrior");
+define("U54","Ghost");
+define("U55","Monster Steed");
+define("U56","Monster War Steed");
+define("U57","Monster Ram");
+define("U58","Monster Catapult");
+define("U59","Monster Chief");
+define("U60","Monster Settler");
+
+// RESOURCES
+define("R1","Lumber");
+define("R2","Clay");
+define("R3","Iron");
+define("R4","Crop");
+
+//INDEX.php
+define("LOGIN","Login");
+define("PLAYERS","Players");
+define("ACTIVE","Active");
+define("ONLINE","Online");
+define("TUTORIAL","Tutorial");
+define("PLAYER_STATISTICS","Player statistics");
+define("TOTAL_PLAYERS","".PLAYERS." in total");
+define("ACTIVE_PLAYERS","Active players");
+define("ONLINE_PLAYERS","".PLAYERS." online");
+define("MP_STRATEGY_GAME","".SERVER_NAME." - the multiplayer strategy game");
+define("WHAT_IS","".SERVER_NAME." is one of the most popular browser games in the world. As a player in ".SERVER_NAME.", you will build your own empire, recruit a mighty army, and fight with your allies for game world hegemony.");
+define("REGISTER_FOR_FREE","Register here for free!");
+define("LATEST_GAME_WORLD","Latest game world");
+define("LATEST_GAME_WORLD2","Register on the latest
game world and enjoy
the advantages of
being one of the
first players.");
+define("PLAY_NOW","Play ".SERVER_NAME." now");
+define("LEARN_MORE","Learn more
about ".SERVER_NAME."!");
+define("LEARN_MORE2","Now with a revolutionised
server system, completely new
graphics
This clone is The Shiz!");
+define("COMUNITY","Community");
+define("BECOME_COMUNITY","Become part of our community now!");
+define("BECOME_COMUNITY2","Become a part of one of
the biggest gaming
communities in the
world.");
+define("NEWS","News");
+define("SCREENSHOTS","Screenshots");
+define("LEARN1","Upgrade your fields and mines to increase your resource production. You will need resources to construct buildings and train soldiers.");
+define("LEARN2","Construct and expand the buildings in your village. Buildings improve your overall infrastructure, increase your resource production and allow you to research, train and upgrade your troops.");
+define("LEARN3","View and interact with your surroundings. You can make new friends or new enemies, make use of the nearby oases and observe as your empire grows and becomes stronger.");
+define("LEARN4","Follow your improvement and success and compare yourself to other players. Look at the Top 10 rankings and fight to win a weekly medal.");
+define("LEARN5","Receive detailed reports about your adventures, trades and battles. Don't forget to check the brand new reports about the happenings taking place in your surroundings.");
+define("LEARN6","Exchange information and conduct diplomacy with other players. Always remember that communication is the key to winning new friends and solving old conflicts.");
+define("LOGIN_TO","Log in to ". SERVER_NAME);
+define("REGIN_TO","Register in ". SERVER_NAME);
+define("P_ONLINE","Players online: ");
+define("P_TOTAL","Players in total: ");
+define("CHOOSE","Please choose a server.");
+define("STARTED"," The server started ". round((time()-COMMENCE)/86400) ." days ago.");
+
+//ANMELDEN.php
+define("NICKNAME","暱稱");
+define("EMAIL","電郵信箱");
+define("PASSWORD","密碼");
+define("ROMANS","羅馬人");
+define("TEUTONS","條頓人");
+define("GAULS","高盧人");
+define("NW","西北方");
+define("NE","東北方");
+define("SW","西南方");
+define("SE","東南方");
+define("RANDOM","隨機");
+define("ACCEPT_RULES"," 我接受本遊戲的 遊戲規定 和 條款.");
+define("ONE_PER_SERVER","每個服務器,每個玩家只能擁有一個帳戶.");
+define("BEFORE_REGISTER","在你創造帳號之前請你務必閱讀 遊戲說明 了解 TravianX 3個種族的優點和缺點");
+define("BUILDING_UPGRADING","建築:");
+define("HOURS","小時");
+
+
+//ATTACKS ETC.
+define("TROOP_MOVEMENTS","軍隊移動:");
+define("ARRIVING_REINF_TROOPS","Arriving reinforcing troops");
+define("ARRIVING_REINF_TROOPS_SHORT","Reinf.");
+define("OWN_ATTACKING_TROOPS","Own attacking troops");
+define("ATTACK","攻擊");
+define("OWN_REINFORCING_TROOPS","Own reinforcing troops");
+define("TROOPS_DORF","軍隊:");
+
+
+//LOGIN.php
+define("COOKIES","You must have cookies enabled to be able to log in. If you share this computer with other people you should log out after each session for your own safety.");
+define("NAME","名稱");
+define("PW_FORGOTTEN","忘記密碼?");
+define("PW_REQUEST","Then you can request a new one which will be sent to your email address.");
+define("PW_GENERATE","產生一組新密碼.");
+define("EMAIL_NOT_VERIFIED","電子郵件帳號不正確!");
+define("EMAIL_FOLLOW","Follow this link to activate your account.");
+define("VERIFY_EMAIL","驗證郵件.");
+
+
+//404.php
+define("NOTHING_HERE","Nothing here!");
+define("WE_LOOKED","We looked 404 times already but can't find anything");
+
+//TIME RELATED
+define("CALCULATED","產生在");
+define("SERVER_TIME","伺服器時間:");
+
+//MASSMESSAGE.php
+define("MASS","Message Content");
+define("MASS_SUBJECT","主旨:");
+define("MASS_COLOR","Message color:");
+define("MASS_REQUIRED","All fields required");
+define("MASS_UNITS","Images (units):");
+define("MASS_SHOWHIDE","Show/Hide");
+define("MASS_READ","Read this: after adding smilie, you have to add left or right after number otherwise image will won't work");
+define("MASS_CONFIRM","Confirmation");
+define("MASS_REALLY","Do you really want to send MassIGM?");
+define("MASS_ABORT","Aborting right now");
+define("MASS_SENT","Mass IGM was sent");
+
+
+/*
+|--------------------------------------------------------------------------
+| Index
+|--------------------------------------------------------------------------
+*/
+
+ $lang['index'][0][1] = "Welcome to " . SERVER_NAME . "";
+ $lang['index'][0][2] = "Manual";
+ $lang['index'][0][3] = "這是免費的, 現在就加入!";
+ $lang['index'][0][4] = "What is " . SERVER_NAME . "";
+ $lang['index'][0][5] = "" . SERVER_NAME . " 是 網頁遊戲 是架構於瀏覽器的遊戲
TRAVIAN世界內有數千至數萬名玩家,一名玩家就是一個村莊的領主,以外交、權謀、諜戰、結盟、分工等等謀略,成為中世紀霸主
這是 免費的 而且 不用下載.";
+ $lang['index'][0][6] = "點擊這裡玩 " . SERVER_NAME . "";
+ $lang['index'][0][7] = "總人數";
+ $lang['index'][0][8] = "活躍的玩家";
+ $lang['index'][0][9] = "在線的玩家";
+ $lang['index'][0][10] = "About the game";
+ $lang['index'][0][11] = "You will begin as the chief of a tiny village and will embark on an exciting quest.";
+ $lang['index'][0][12] = "Build up villages, wage wars or establish trade routes with your neighbours.";
+ $lang['index'][0][13] = "Play with and against thousands of other real players and conquer the the world of Travian.";
+ $lang['index'][0][14] = "新聞";
+ $lang['index'][0][15] = "說明";
+ $lang['index'][0][16] = "遊戲截圖";
+ $lang['forum'] = "論壇";
+ $lang['register'] = "註冊";
+ $lang['login'] = "登入";
+
+
+?>
diff --git a/GameEngine/Logging.php b/GameEngine/Logging.php
new file mode 100644
index 00000000..62394a3c
--- /dev/null
+++ b/GameEngine/Logging.php
@@ -0,0 +1,110 @@
+query($q);
+ }
+ }
+
+ public function addLoginLog($id,$ip) {
+ global $database;
+ if(LOG_LOGIN) {
+ $q = "Insert into ".TB_PREFIX."login_log values (0,$id,'$ip')";
+ $database->query($q);
+ }
+ }
+
+ public function addBuildLog($wid,$building,$level,$type) {
+ global $database;
+ if(LOG_BUILD) {
+ if($type) {
+ $log = "Start Construction of ";
+ }
+ else {
+ $log = "Start Upgrade of ";
+ }
+ $log .= $building." at level ".$level;
+ $q = "Insert into ".TB_PREFIX."build_log values (0,$wid,'$log')";
+ $database->query($q);
+ }
+ }
+
+ public function addTechLog($wid,$tech,$level) {
+ global $database;
+ if(LOG_TECH) {
+ $log = "Upgrading of tech ".$tech." to level ".$level;
+ $q = "Insert into ".TB_PREFIX."tech_log values (0,$wid,'$log')";
+ $database->query($q);
+ }
+ }
+
+ public function goldFinLog($wid) {
+ global $database;
+ if(LOG_GOLD_FIN) {
+ $log = "Finish construction and research with gold";
+ $q = "Insert into ".TB_PREFIX."gold_fin_log values (0,$wid,'$log')";
+ $database->query($q);
+ }
+ }
+
+ public function addAdminLog() {
+ global $database;
+ }
+
+ public function addMarketLog($wid,$type,$data) {
+ global $database;
+ if(LOG_MARKET) {
+ if($type == 1) {
+ $log = "Sent ".$data[0].",".$data[1].",".$data[2].",".$data[3]." to village ".$data[4];
+ }
+ else if($type == 2) {
+ $log = "Traded resource between ".$wid." and ".$data[0]." market ref is ".$data[1];
+ }
+ $q = "Insert into ".TB_PREFIX."market_log values (0,$wid,'$log')";
+ $database->query($q);
+ }
+ }
+
+ public function addWarLog() {
+ global $database;
+ }
+
+ public function clearLogs() {
+ global $database;
+ }
+
+ public function debug($time,$uid,$debug_info) {
+ global $database;
+
+ //$debugFile = "/tmp/debug";
+ //$fh = fopen($debugFile, 'a') or die('No debug file');
+ //fwrite($fh,"\n".date("Y-m-d H:i:s")." : ".$time.",".$uid.",".$debug_info."\n");
+ //fclose($fh);
+
+ $q = "INSERT INTO ".TB_PREFIX."debug_log (time,uid,debug_info) VALUES ($time,$uid,'$debug_info')";
+ $database->query($q);
+ }
+};
+
+$logging = new Logging;
+//$logging->debug(time(),2,'Logging.php loaded');
+?>
diff --git a/GameEngine/Mailer.php b/GameEngine/Mailer.php
new file mode 100644
index 00000000..4d097a56
--- /dev/null
+++ b/GameEngine/Mailer.php
@@ -0,0 +1,95 @@
+
\ No newline at end of file
diff --git a/GameEngine/Market.php b/GameEngine/Market.php
new file mode 100644
index 00000000..055ddb6f
--- /dev/null
+++ b/GameEngine/Market.php
@@ -0,0 +1,358 @@
+loadMarket();
+ if(isset($_SESSION['loadMarket']))
+ {
+ $this->loadOnsale();
+ unset($_SESSION['loadMarket']);
+ }
+ if(isset($post['ft']))
+ {
+ switch($post['ft'])
+ {
+ case "mk1": $this->sendResource($post); break;
+ case "mk2": $this->addOffer($post); break;
+ case "mk3": $this->tradeResource($post); break;
+ }
+ }
+ }
+
+ public function procRemove($get)
+ {
+ global $database,$village,$session;
+
+ if(isset($get['t']) && $get['t'] == 1)
+ {
+ $this->filterNeed($get);
+ }
+ else if(isset($get['t']) && $get['t'] ==2 && isset($get['a']) && $get['a'] == 5 && isset($get['del']))
+ {
+ //GET ALL FIELDS FROM MARKET
+ $type = $database->getMarketField($village->wid,"gtype");
+ $amt = $database->getMarketField($village->wid,"gamt");
+ $vref = $village->wid;
+ $database->getResourcesBack($vref,$type,$amt);
+ $database->addMarket($village->wid,$get['del'],0,0,0,0,0,0,1);
+ header("Location: build.php?id=".$get['id']."&t=2");
+ }
+ if(isset($get['t']) && $get['t'] == 1 && isset($get['a']) && $get['a'] == $session->mchecker && !isset($get['del']))
+ {
+ $session->changeChecker();
+ $this->acceptOffer($get);
+ }
+ }
+
+ public function merchantAvail()
+ {
+ return $this->merchant - $this->used;
+ }
+
+ private function loadMarket()
+ {
+ global $session,$building,$bid28,$bid17,$database,$village;
+
+ $this->recieving = $database->getMovement(0,$village->wid,1);
+ $this->sending = $database->getMovement(0,$village->wid,0);
+ $this->return = $database->getMovement(2,$village->wid,1);
+ $this->merchant = ($building->getTypeLevel(17) > 0)? $bid17[$building->getTypeLevel(17)]['attri'] : 0;
+ $this->used = $database->totalMerchantUsed($village->wid);
+ $this->onmarket = $database->getMarket($village->wid,0);
+ $this->maxcarry = ($session->tribe == 1)? 500 : (($session->tribe == 2)? 1000 : 750);
+ $this->maxcarry *= TRADER_CAPACITY;
+ if($building->getTypeLevel(28) != 0)
+ {
+ $this->maxcarry *= $bid28[$building->getTypeLevel(28)]['attri'] / 100;
+ }
+ }
+
+ private function sendResource($post)
+ {
+ global $database,$village,$session,$generator,$logging;
+
+ $wtrans = (isset($post['r1']) && $post['r1'] != "")? $post['r1'] : 0;
+ $ctrans = (isset($post['r2']) && $post['r2'] != "")? $post['r2'] : 0;
+ $itrans = (isset($post['r3']) && $post['r3'] != "")? $post['r3'] : 0;
+ $crtrans = (isset($post['r4']) && $post['r4'] != "")? $post['r4'] : 0;
+ $wtrans = str_replace("-", "", $wtrans);
+ $ctrans = str_replace("-", "", $ctrans);
+ $itrans = str_replace("-", "", $itrans);
+ $crtrans = str_replace("-", "", $crtrans);
+ $availableWood = $database->getWoodAvailable($village->wid);
+ $availableClay = $database->getClayAvailable($village->wid);
+ $availableIron = $database->getIronAvailable($village->wid);
+ $availableCrop = $database->getCropAvailable($village->wid);
+ if($session->access == BANNED)
+ {
+ header("Location: banned.php");
+ }
+ else if($availableWood >= $post['r1'] AND $availableClay >= $post['r2'] AND $availableIron >= $post['r3'] AND $availableCrop >= $post['r4'])
+ {
+ $resource = array($wtrans,$ctrans,$itrans,$crtrans);
+ $reqMerc = ceil((array_sum($resource)-0.1)/$this->maxcarry);
+
+ if($this->merchantAvail() != 0 && $reqMerc <= $this->merchantAvail())
+ {
+ $id = $post['getwref'];
+ $coor = $database->getCoor($id);
+ if($database->getVillageState($id))
+ {
+ $timetaken = $generator->procDistanceTime($coor,$village->coor,$session->tribe,0);
+ $res = $resource[0]+$resource[1]+$resource[2]+$resource[3];
+ if($res!=0)
+ {
+ $reference = $database->sendResource($resource[0],$resource[1],$resource[2],$resource[3],$reqMerc,0);
+ $database->modifyResource($village->wid,$resource[0],$resource[1],$resource[2],$resource[3],0);
+ $database->addMovement(0,$village->wid,$id,$reference,time(),time()+$timetaken,$post['send3']);
+ $logging->addMarketLog($village->wid,1,array($resource[0],$resource[1],$resource[2],$resource[3],$id));
+ }
+ }
+ }
+ header("Location: build.php?id=".$post['id']);
+ }
+ else
+ {
+ // something
+ }
+ }
+
+ private function addOffer($post)
+ {
+ global $database,$village,$session;
+
+
+ if($post['rid1'] == $post['rid2'])
+ {
+ // Trading res for res of same type (invalid)
+ header("Location: build.php?id=".$post['id']."&t=2&e2");
+ }
+ elseif($post['m1'] > (2 * $post['m2']))
+ {
+ // Trade is for more than 2x (invalid)
+ header("Location: build.php?id=".$post['id']."&t=2&e2");
+ }
+ elseif($post['m2'] > (2 * $post['m1']))
+ {
+ // Trade is for less than 0.5x (invalid)
+ header("Location: build.php?id=".$post['id']."&t=2&e2");
+ }
+ else
+ {
+ $wood = ($post['rid1'] == 1)? $post['m1'] : 0;
+ $clay = ($post['rid1'] == 2)? $post['m1'] : 0;
+ $iron = ($post['rid1'] == 3)? $post['m1'] : 0;
+ $crop = ($post['rid1'] == 4)? $post['m1'] : 0;
+ $availableWood = $database->getWoodAvailable($village->wid);
+ $availableClay = $database->getClayAvailable($village->wid);
+ $availableIron = $database->getIronAvailable($village->wid);
+ $availableCrop = $database->getCropAvailable($village->wid);
+
+ if($session->access == BANNED)
+ {
+ header("Location: banned.php");
+ }
+
+ elseif($availableWood >= $wood AND $availableClay >= $clay AND $availableIron >= $iron AND $availableCrop >= $crop)
+ {
+ $reqMerc = 1;
+
+ if(($wood+$clay+$iron+$crop) > $this->maxcarry)
+ {
+ $reqMerc = round(($wood+$clay+$iron+$crop)/$this->maxcarry);
+
+ if(($wood+$clay+$iron+$crop) > $this->maxcarry*$reqMerc)
+ {
+ $reqMerc += 1;
+ }
+ }
+ if($this->merchantAvail() != 0 && $reqMerc <= $this->merchantAvail())
+ {
+ if($database->modifyResource($village->wid,$wood,$clay,$iron,$crop,0))
+ {
+ $time = 0;
+ if(isset($_POST['d1']))
+ {
+ $time = $_POST['d2'] * 3600;
+ }
+ $alliance = (isset($post['ally']) && $post['ally'] == 1)? $session->userinfo['alliance'] : 0;
+ $database->addMarket($village->wid,$post['rid1'],$post['m1'],$post['rid2'],$post['m2'],$time,$alliance,$reqMerc,0);
+ }
+ // Enough merchants
+ header("Location: build.php?id=".$post['id']."&t=2");
+ }
+ else
+ {
+ // Not enough merchants
+ header("Location: build.php?id=".$post['id']."&t=2&e3");
+ }
+ }
+ else
+ {
+ // not enough resources
+ header("Location: build.php?id=".$post['id']."&t=2&e1");
+ }
+ }
+ }
+
+ private function acceptOffer($get)
+ {
+ global $database,$village,$session,$logging,$generator;
+
+ $infoarray = $database->getMarketInfo($get['g']);
+ $reqMerc = 1;
+ if($infoarray['wamt'] > $this->maxcarry)
+ {
+ $reqMerc = round($infoarray['wamt']/$this->maxcarry);
+ if($infoarray['wamt'] > $this->maxcarry*$reqMerc)
+ {
+ $reqMerc += 1;
+ }
+ }
+ $myresource = $hisresource = array(1=>0,0,0,0);
+ $myresource[$infoarray['wtype']] = $infoarray['wamt'];
+ $mysendid = $database->sendResource($myresource[1],$myresource[2],$myresource[3],$myresource[4],$reqMerc,0);
+ $hisresource[$infoarray['gtype']] = $infoarray['gamt'];
+ $hissendid = $database->sendResource($hisresource[1],$hisresource[2],$hisresource[3],$hisresource[4],$infoarray['merchant'],0);
+ $hiscoor = $database->getCoor($infoarray['vref']);
+ $mytime = $generator->procDistanceTime($hiscoor,$village->coor,$session->tribe,0);
+ $targettribe = $database->getUserField($database->getVillageField($infoarray['vref'],"owner"),"tribe",0);
+ $histime = $generator->procDistanceTime($village->coor,$hiscoor,$targettribe,0);
+ $database->addMovement(0,$village->wid,$infoarray['vref'],$mysendid,time(),$mytime+time());
+ $database->addMovement(0,$infoarray['vref'],$village->wid,$hissendid,time(),$histime+time());
+ $resource = array(1=>0,0,0,0);
+ $resource[$infoarray['wtype']] = $infoarray['wamt'];
+ $database->modifyResource($village->wid,$resource[1],$resource[2],$resource[3],$resource[4],0);
+ $database->setMarketAcc($get['g']);
+ $database->removeAcceptedOffer($get['g']);
+ $logging->addMarketLog($village->wid,2,array($infoarray['vref'],$get['g']));
+ header("Location: build.php?id=".$get['id']);
+ }
+
+ private function loadOnsale()
+ {
+ global $database,$village,$session,$multisort,$generator;
+
+ $displayarray = $database->getMarket($village->wid,1);
+ $holderarray = array();
+ foreach($displayarray as $value)
+ {
+ $targetcoor = $database->getCoor($value['vref']);
+ $duration = $generator->procDistanceTime($targetcoor,$village->coor,$session->tribe,0);
+ if($duration <= $value['maxtime'] || $value['maxtime'] == 0)
+ {
+ $value['duration'] = $duration;
+ array_push($holderarray,$value);
+ }
+ }
+ $this->onsale = $multisort->sorte($holderarray, "'duration'", true, 2);
+ }
+
+ private function filterNeed($get)
+ {
+ if(isset($get['v']) || isset($get['s']) || isset($get['b']))
+ {
+ $holder = $holder2 = array();
+ if(isset($get['v']) && $get['v'] == "1:1")
+ {
+ foreach($this->onsale as $equal)
+ {
+ if($equal['wamt'] <= $equal['gamt'])
+ {
+ array_push($holder,$equal);
+ }
+ }
+ }
+ else
+ {
+ $holder = $this->onsale;
+ }
+ foreach($holder as $sale)
+ {
+ if(isset($get['s']) && isset($get['b']))
+ {
+ if($sale['gtype'] == $get['s'] && $sale['wtype'] == $get['b'])
+ {
+ array_push($holder2,$sale);
+ }
+ }
+ else if(isset($get['s']) && !isset($get['b']))
+ {
+ if($sale['gtype'] == $get['s'])
+ {
+ array_push($holder2,$sale);
+ }
+ }
+ else if(isset($get['b']) && !isset($get['s']))
+ {
+ if($sale['wtype'] == $get['b'])
+ {
+ array_push($holder2,$sale);
+ }
+ }
+ else
+ {
+ $holder2 = $holder;
+ }
+ }
+ $this->onsale = $holder2;
+ }
+ else
+ {
+ $this->loadOnsale();
+ }
+ }
+
+ private function tradeResource($post)
+ {
+ global $session,$database,$village;
+
+ $wwvillage = $database->getResourceLevel($village->wid);
+ if($wwvillage['f99t']!=40)
+ {
+ if($session->userinfo['gold'] >= 3)
+ {
+ //kijken of ze niet meer gs invoeren dan ze hebben
+ if($session->access == BANNED)
+ {
+ header("Location: banned.php");
+ }
+ else if (($post['m2'][0]+$post['m2'][1]+$post['m2'][2]+$post['m2'][3])<=(round($village->awood)+round($village->aclay)+round($village->airon)+round($village->acrop)))
+ {
+ $database->setVillageField($village->wid,"wood",$post['m2'][0]);
+ $database->setVillageField($village->wid,"clay",$post['m2'][1]);
+ $database->setVillageField($village->wid,"iron",$post['m2'][2]);
+ $database->setVillageField($village->wid,"crop",$post['m2'][3]);
+ $database->modifyGold($session->uid,3,0);
+ header("Location: build.php?id=".$post['id']."&t=3&c");;
+ }
+ else
+ {
+ header("Location: build.php?id=".$post['id']."&t=3");
+ }
+ }
+ else
+ {
+ header("Location: build.php?id=".$post['id']."&t=3");
+ }
+ }
+ }
+};
+
+$market = new Market;
+?>
\ No newline at end of file
diff --git a/GameEngine/Message.php b/GameEngine/Message.php
new file mode 100644
index 00000000..881cc1ef
--- /dev/null
+++ b/GameEngine/Message.php
@@ -0,0 +1,576 @@
+getMessages();
+ $this->getNotice();
+ if($this->totalMessage > 0) {
+ $this->unread = $this->checkUnread();
+ }
+ if($this->totalNotice > 0) {
+ $this->nunread = $this->checkNUnread();
+ }
+ if(isset($_SESSION['reply'])) {
+ $this->reply = $_SESSION['reply'];
+ unset($_SESSION['reply']);
+ }
+ }
+
+ public function procMessage($post) {
+ if(isset($post['ft'])) {
+ switch($post['ft']) {
+ case "m1":
+ $this->quoteMessage($post['id']);
+ break;
+ case "m2":
+ if ($post['an'] == "[ally]"){
+ $this->sendAMessage($post['be'],addslashes($post['message']));
+ }else{
+ $this->sendMessage($post['an'],$post['be'],addslashes($post['message']));
+ }
+ header("Location: nachrichten.php?t=2");
+ break;
+ case "m3":
+ case "m4":
+ case "m5":
+ if(isset($post['delmsg_x'])) {
+ $this->removeMessage($post);
+ $this->header($get);
+ }
+ if(isset($post['archive_x'])) {
+ $this->archiveMessage($post);
+ }
+ if(isset($post['start_x'])) {
+ $this->unarchiveMessage($post);
+ }
+ break;
+ case "m6":
+ $this->createNote($post);
+ break;
+ case "m7":
+ $this->addFriends($post);
+ break;
+ }
+ }
+ }
+
+ public function noticeType($get) {
+ global $session, $database;
+ if(isset($get['t'])) {
+ if($get['t'] == 1) {
+ $type = array(8, 15, 16, 17);
+ }
+ if($get['t'] == 2) {
+ $type = array(10, 11, 12, 13);
+ }
+ if($get['t'] == 3) {
+ $type = array(1, 2, 3, 4, 5, 6, 7);
+ }
+ if($get['t'] == 4) {
+ $type = array(0, 18, 19, 20, 21);
+ }
+ if($get['t'] == 5) {
+ if(!$session->plus){
+ header("Location: berichte.php");
+ } else {
+ $type = 9;
+ }
+ }
+ if (!is_array($type)) { $type = array($type); }
+ $this->noticearray = $this->filter_by_value($database->getNotice($session->uid), "ntype", $type);
+ $this->notice = $this->filter_by_value($database->getNotice3($session->uid), "ntype", $type);
+ }
+ if(isset($get['id'])) {
+ $this->readingNotice = $this->getReadNotice($get['id']);
+ }
+ }
+
+ public function procNotice($post) {
+ if(isset($post["del_x"])) {
+ $this->removeNotice($post);
+ }
+ if(isset($post['archive_x'])) {
+ $this->archiveNotice($post);
+ }
+ if(isset($post['start_x'])) {
+ $this->unarchiveNotice($post);
+ }
+ }
+
+ public function quoteMessage($id) {
+ foreach($this->inbox as $message) {
+ if($message['id'] == $id) {
+ $message = preg_replace('/\[message\]/', '', $message);
+ $message = preg_replace('/\[\/message\]/', '', $message);
+ for($i=1;$i<=$message['alliance'];$i++){
+ $message = preg_replace('/\[alliance'.$i.'\]/', '[alliance0]', $message);
+ $message = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance0]', $message);
+ }
+ for($i=0;$i<=$message['player'];$i++){
+ $message = preg_replace('/\[player'.$i.'\]/', '[player0]', $message);
+ $message = preg_replace('/\[\/player'.$i.'\]/', '[/player0]', $message);
+ }
+ for($i=0;$i<=$message['coor'];$i++){
+ $message = preg_replace('/\[coor'.$i.'\]/', '[coor0]', $message);
+ $message = preg_replace('/\[\/coor'.$i.'\]/', '[/coor0]', $message);
+ }
+ for($i=0;$i<=$message['report'];$i++){
+ $message = preg_replace('/\[report'.$i.'\]/', '[report0]', $message);
+ $message = preg_replace('/\[\/report'.$i.'\]/', '[/report0]', $message);
+ }
+ $this->reply = $_SESSION['reply'] = $message;
+ header("Location: nachrichten.php?t=1&id=" . $message['owner']);
+ }
+ }
+ }
+
+ public function loadMessage($id) {
+ global $database, $session;
+ if($this->findInbox($id)) {
+ foreach($this->inbox as $message) {
+ if($message['id'] == $id) {
+ $this->reading = $message;
+ }
+ }
+ }
+ if($this->findSent($id)) {
+ foreach($this->sent as $message) {
+ if($message['id'] == $id) {
+ $this->reading = $message;
+ }
+ }
+ }
+ if($session->plus && $this->findArchive($id)) {
+ foreach($this->archived as $message) {
+ if($message['id'] == $id) {
+ $this->reading = $message;
+ }
+ }
+ }
+ if($this->reading['viewed'] == 0) {
+ $database->getMessage($id, 4);
+ }
+ }
+
+ private function filter_by_value_except($array, $index, $value) {
+ $newarray = array();
+ if(is_array($array) && count($array) > 0) {
+ foreach(array_keys($array) as $key) {
+ $temp[$key] = $array[$key][$index];
+
+ if($temp[$key] != $value) {
+ array_push($newarray, $array[$key]);
+ //$newarray[$key] = $array[$key];
+ }
+ }
+ }
+ return $newarray;
+ }
+
+ private function filter_by_value($array, $index, $value) {
+ $newarray = array();
+ if(is_array($array) && count($array) > 0) {
+ foreach(array_keys($array) as $key) {
+ $temp[$key] = $array[$key][$index];
+
+ if(in_array($temp[$key], $value)) {
+ array_push($newarray, $array[$key]);
+ //$newarray[$key] = $array[$key];
+ }
+ }
+ }
+ return $newarray;
+ }
+
+ private function getNotice() {
+ global $database, $session;
+ $this->allNotice = $database->getNotice3($session->uid);
+ $this->noticearray = $this->filter_by_value_except($database->getNotice($session->uid), "ntype", 9);
+ $this->notice = $this->filter_by_value_except($this->allNotice, "ntype", 9);
+ $this->totalNotice = count($this->allNotice);
+ }
+
+ private function removeMessage($post) {
+ global $database,$session;
+ for($i = 1; $i <= 10; $i++) {
+ if(isset($post['n' . $i])) {
+ $message1 = mysql_query("SELECT * FROM " . TB_PREFIX . "mdata where id = ".$post['n' . $i]."");
+ $message = mysql_fetch_array($message1);
+ if($message['target'] == $session->uid && $message['owner'] == $session->uid){
+ $database->getMessage($post['n' . $i], 8);
+ }else if($message['target'] == $session->uid){
+ $database->getMessage($post['n' . $i], 5);
+ }else if($message['owner'] == $session->uid){
+ $database->getMessage($post['n' . $i], 7);
+ }
+ }
+ }
+ header("Location: nachrichten.php");
+ }
+
+ private function archiveMessage($post) {
+ global $database;
+ for($i = 1; $i <= 10; $i++) {
+ if(isset($post['n' . $i])) {
+ $database->setArchived($post['n' . $i]);
+ }
+ }
+ header("Location: nachrichten.php");
+ }
+
+ private function unarchiveMessage($post) {
+ global $database;
+ for($i = 1; $i <= 10; $i++) {
+ if(isset($post['n' . $i])) {
+ $database->setNorm($post['n' . $i]);
+ }
+ }
+ header("Location: nachrichten.php");
+ }
+
+ private function removeNotice($post) {
+ global $database;
+ for($i = 1; $i <= 10; $i++) {
+ if(isset($post['n' . $i])) {
+ $database->removeNotice($post['n' . $i], 5);
+ }
+ }
+ header("Location: berichte.php");
+ }
+
+ private function archiveNotice($post) {
+ global $database;
+ for($i = 1; $i <= 10; $i++) {
+ if(isset($post['n' . $i])) {
+ $database->archiveNotice($post['n' . $i]);
+ }
+ }
+ header("Location: berichte.php");
+ }
+
+ private function unarchiveNotice($post) {
+ global $database;
+ for($i = 1; $i <= 10; $i++) {
+ if(isset($post['n' . $i])) {
+ $database->unarchiveNotice($post['n' . $i]);
+ }
+ }
+ header("Location: berichte.php");
+ }
+
+ private function getReadNotice($id) {
+ global $database;
+ foreach($this->allNotice as $notice) {
+ if($notice['id'] == $id) {
+ $database->noticeViewed($notice['id']);
+ return $notice;
+ }
+ }
+ }
+
+ public function loadNotes() {
+ global $session;
+ if(file_exists("GameEngine/Notes/" . md5($session->username) . ".txt")) {
+ $this->note = file_get_contents("GameEngine/Notes/" . md5($session->username) . ".txt");
+ } else {
+ $this->note = "";
+ }
+ }
+
+ private function createNote($post) {
+ global $session;
+ if($session->plus) {
+ $ourFileHandle = fopen("GameEngine/Notes/" . md5($session->username) . ".txt", 'w');
+ fwrite($ourFileHandle, $post['notizen']);
+ fclose($ourFileHandle);
+ }
+ }
+
+ private function getMessages() {
+ global $database, $session;
+ $this->inbox = $database->getMessage($session->uid, 1);
+ $this->sent = $database->getMessage($session->uid, 2);
+ $this->inbox1 = $database->getMessage($session->uid, 9);
+ $this->sent1 = $database->getMessage($session->uid, 10);
+ if($session->plus) {
+ $this->archived = $database->getMessage($session->uid, 6);
+ $this->archived1 = $database->getMessage($session->uid, 11);
+ }
+ $this->totalMessage = count($this->inbox) + count($this->sent);
+ }
+
+ private function sendAMessage($topic,$text) {
+ global $session,$database;
+ $allmembersQ = mysql_query("SELECT id FROM ".TB_PREFIX."users WHERE alliance='".$session->alliance."'");
+ $userally = $database->getUserField($session->uid,"alliance",0);
+ $permission=mysql_fetch_array(mysql_query("SELECT opt7 FROM ".TB_PREFIX."ali_permission WHERE uid='".$session->uid."'"));
+
+ if(WORD_CENSOR) {
+ $topic = $this->wordCensor($topic);
+ $text = $this->wordCensor($text);
+ }
+ if($topic == "") {
+ $topic = "No subject";
+ }
+ if(!preg_match('/\[message\]/',$text) && !preg_match('/\[\/message\]/',$text)){
+ $text = "[message]".$text."[/message]";
+ $alliance = $player = $coor = $report = 0;
+ for($i=0;$i<=$alliance;$i++){
+ if(preg_match('/\[alliance'.$i.'\]/',$text) && preg_match('/\[\/alliance'.$i.'\]/',$text)){
+ $alliance1 = preg_replace('/\[message\](.*?)\[\/alliance'.$i.'\]/is', '', $text);
+ if(preg_match('/\[alliance'.$i.'\]/',$alliance1) && preg_match('/\[\/alliance'.$i.'\]/',$alliance1)){
+ $j = $i+1;
+ $alliance2 = preg_replace('/\[\/alliance'.$i.'\](.*?)\[\/message\]/is', '', $text);
+ $alliance1 = preg_replace('/\[alliance'.$i.'\]/', '[alliance'.$j.']', $alliance1);
+ $alliance1 = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance'.$j.']', $alliance1);
+ $text = $alliance2."[/alliance".$i."]".$alliance1;
+ $alliance += 1;
+ }
+ }
+ }
+ for($i=0;$i<=$player;$i++){
+ if(preg_match('/\[player'.$i.'\]/',$text) && preg_match('/\[\/player'.$i.'\]/',$text)){
+ $player1 = preg_replace('/\[message\](.*?)\[\/player'.$i.'\]/is', '', $text);
+ if(preg_match('/\[player'.$i.'\]/',$player1) && preg_match('/\[\/player'.$i.'\]/',$player1)){
+ $j = $i+1;
+ $player2 = preg_replace('/\[\/player'.$i.'\](.*?)\[\/message\]/is', '', $text);
+ $player1 = preg_replace('/\[player'.$i.'\]/', '[player'.$j.']', $player1);
+ $player1 = preg_replace('/\[\/player'.$i.'\]/', '[/player'.$j.']', $player1);
+ $text = $player2."[/player".$i."]".$player1;
+ $player += 1;
+ }
+ }
+ }
+ for($i=0;$i<=$coor;$i++){
+ if(preg_match('/\[coor'.$i.'\]/',$text) && preg_match('/\[\/coor'.$i.'\]/',$text)){
+ $coor1 = preg_replace('/\[message\](.*?)\[\/coor'.$i.'\]/is', '', $text);
+ if(preg_match('/\[coor'.$i.'\]/',$coor1) && preg_match('/\[\/coor'.$i.'\]/',$coor1)){
+ $j = $i+1;
+ $coor2 = preg_replace('/\[\/coor'.$i.'\](.*?)\[\/message\]/is', '', $text);
+ $coor1 = preg_replace('/\[coor'.$i.'\]/', '[coor'.$j.']', $coor1);
+ $coor1 = preg_replace('/\[\/coor'.$i.'\]/', '[/coor'.$j.']', $coor1);
+ $text = $coor2."[/coor".$i."]".$coor1;
+ $coor += 1;
+ }
+ }
+ }
+ for($i=0;$i<=$report;$i++){
+ if(preg_match('/\[report'.$i.'\]/',$text) && preg_match('/\[\/report'.$i.'\]/',$text)){
+ $report1 = preg_replace('/\[message\](.*?)\[\/report'.$i.'\]/is', '', $text);
+ if(preg_match('/\[report'.$i.'\]/',$report1) && preg_match('/\[\/report'.$i.'\]/',$report1)){
+ $j = $i+1;
+ $report2 = preg_replace('/\[\/report'.$i.'\](.*?)\[\/message\]/is', '', $text);
+ $report1 = preg_replace('/\[report'.$i.'\]/', '[report'.$j.']', $report1);
+ $report1 = preg_replace('/\[\/report'.$i.'\]/', '[/report'.$j.']', $report1);
+ $text = $report2."[/report".$i."]".$report1;
+ $report += 1;
+ }
+ }
+ }
+ if($permission[opt7]==1){
+ if ($userally != 0) {
+ while ($allmembers = mysql_fetch_array($allmembersQ)) {
+ $database->sendMessage($allmembers[id],$session->uid,$topic,$text,0,$alliance,$player,$coor,$report);
+ }
+ }
+ }
+ }
+ }
+
+ private function sendMessage($recieve, $topic, $text) {
+ global $session, $database;
+ $user = $database->getUserField($recieve, "id", 1);
+ if(WORD_CENSOR) {
+ $topic = $this->wordCensor($topic);
+ $text = $this->wordCensor($text);
+ }
+ if($topic == "") {
+ $topic = "No subject";
+ }
+ if(!preg_match('/\[message\]/',$text) && !preg_match('/\[\/message\]/',$text)){
+ $text = "[message]".$text."[/message]";
+ $alliance = $player = $coor = $report = 0;
+ for($i=0;$i<=$alliance;$i++){
+ if(preg_match('/\[alliance'.$i.'\]/',$text) && preg_match('/\[\/alliance'.$i.'\]/',$text)){
+ $alliance1 = preg_replace('/\[message\](.*?)\[\/alliance'.$i.'\]/is', '', $text);
+ if(preg_match('/\[alliance'.$i.'\]/',$alliance1) && preg_match('/\[\/alliance'.$i.'\]/',$alliance1)){
+ $j = $i+1;
+ $alliance2 = preg_replace('/\[\/alliance'.$i.'\](.*?)\[\/message\]/is', '', $text);
+ $alliance1 = preg_replace('/\[alliance'.$i.'\]/', '[alliance'.$j.']', $alliance1);
+ $alliance1 = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance'.$j.']', $alliance1);
+ $text = $alliance2."[/alliance".$i."]".$alliance1;
+ $alliance += 1;
+ }
+ }
+ }
+ for($i=0;$i<=$player;$i++){
+ if(preg_match('/\[player'.$i.'\]/',$text) && preg_match('/\[\/player'.$i.'\]/',$text)){
+ $player1 = preg_replace('/\[message\](.*?)\[\/player'.$i.'\]/is', '', $text);
+ if(preg_match('/\[player'.$i.'\]/',$player1) && preg_match('/\[\/player'.$i.'\]/',$player1)){
+ $j = $i+1;
+ $player2 = preg_replace('/\[\/player'.$i.'\](.*?)\[\/message\]/is', '', $text);
+ $player1 = preg_replace('/\[player'.$i.'\]/', '[player'.$j.']', $player1);
+ $player1 = preg_replace('/\[\/player'.$i.'\]/', '[/player'.$j.']', $player1);
+ $text = $player2."[/player".$i."]".$player1;
+ $player += 1;
+ }
+ }
+ }
+ for($i=0;$i<=$coor;$i++){
+ if(preg_match('/\[coor'.$i.'\]/',$text) && preg_match('/\[\/coor'.$i.'\]/',$text)){
+ $coor1 = preg_replace('/\[message\](.*?)\[\/coor'.$i.'\]/is', '', $text);
+ if(preg_match('/\[coor'.$i.'\]/',$coor1) && preg_match('/\[\/coor'.$i.'\]/',$coor1)){
+ $j = $i+1;
+ $coor2 = preg_replace('/\[\/coor'.$i.'\](.*?)\[\/message\]/is', '', $text);
+ $coor1 = preg_replace('/\[coor'.$i.'\]/', '[coor'.$j.']', $coor1);
+ $coor1 = preg_replace('/\[\/coor'.$i.'\]/', '[/coor'.$j.']', $coor1);
+ $text = $coor2."[/coor".$i."]".$coor1;
+ $coor += 1;
+ }
+ }
+ }
+ for($i=0;$i<=$report;$i++){
+ if(preg_match('/\[report'.$i.'\]/',$text) && preg_match('/\[\/report'.$i.'\]/',$text)){
+ $report1 = preg_replace('/\[message\](.*?)\[\/report'.$i.'\]/is', '', $text);
+ if(preg_match('/\[report'.$i.'\]/',$report1) && preg_match('/\[\/report'.$i.'\]/',$report1)){
+ $j = $i+1;
+ $report2 = preg_replace('/\[\/report'.$i.'\](.*?)\[\/message\]/is', '', $text);
+ $report1 = preg_replace('/\[report'.$i.'\]/', '[report'.$j.']', $report1);
+ $report1 = preg_replace('/\[\/report'.$i.'\]/', '[/report'.$j.']', $report1);
+ $text = $report2."[/report".$i."]".$report1;
+ $report += 1;
+ }
+ }
+ }
+ $database->sendMessage($user, $session->uid, $topic, $text, 0, $alliance, $player, $coor, $report);
+ }
+ }
+
+ //7 = village, attacker, att tribe, u1 - u10, lost %, w,c,i,c , cap
+ //8 = village, attacker, att tribe, enforcement
+ private function sendNotice($from, $vid, $fowner, $owner, $type, $extra) {
+
+ }
+
+ public function sendWelcome($uid, $username) {
+ global $database;
+ $welcomemsg = file_get_contents("GameEngine/Admin/welcome.tpl");
+ $welcomemsg = preg_replace("'%USER%'", $username, $welcomemsg);
+ $welcomemsg = preg_replace("'%START%'", date("y.m.d", COMMENCE), $welcomemsg);
+ $welcomemsg = preg_replace("'%TIME%'", date("H:i", COMMENCE), $welcomemsg);
+ $welcomemsg = preg_replace("'%PLAYERS%'", $database->countUser(), $welcomemsg);
+ $welcomemsg = preg_replace("'%ALLI%'", $database->countAlli(), $welcomemsg);
+ $welcomemsg = preg_replace("'%SERVER_NAME%'", SERVER_NAME, $welcomemsg);
+ $welcomemsg = "[message]".$welcomemsg."[/message]";
+ return $database->sendMessage($uid, 5, WEL_TOPIC, addslashes($welcomemsg), 0, 0, 0, 0, 0);
+ }
+
+ private function wordCensor($text) {
+ $censorarray = explode(",", CENSORED);
+ foreach($censorarray as $key => $value) {
+ $censorarray[$key] = "/" . $value . "/i";
+ }
+ return preg_replace($censorarray, "****", $text);
+ }
+
+ private function checkUnread() {
+ foreach($this->inbox as $message) {
+ if($message['viewed'] == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private function checkNUnread() {
+ foreach($this->allNotice as $notice) {
+ if($notice['viewed'] == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private function findInbox($id) {
+ foreach($this->inbox as $message) {
+ if($message['id'] == $id) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private function findSent($id) {
+ foreach($this->sent as $message) {
+ if($message['id'] == $id) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private function findArchive($id) {
+ foreach($this->archived as $message) {
+ if($message['id'] == $id) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public function addFriends($post) {
+ global $database;
+ for($i=0;$i<=19;$i++) {
+ if($post['addfriends'.$i] != ""){
+ $uid = $database->getUserField($post['addfriends'.$i], "id", 1);
+ $added = 0;
+ for($j=0;$j<=$i;$j++) {
+ if($added == 0){
+ $user = $database->getUserField($post['myid'], "friend".$j, 0);
+ $userwait = $database->getUserField($post['myid'], "friend".$j."wait", 0);
+ $exist = 0;
+ for($k=0;$k<=19;$k++){
+ $user1 = $database->getUserField($post['myid'], "friend".$k, 0);
+ if($user1 == $uid or $uid == $post['myid']){
+ $exist = 1;
+ }
+ }
+ if($user == 0 && $userwait == 0 && $exist == 0){
+ $added1 = 0;
+ for($l=0;$l<=19;$l++){
+ $user2 = $database->getUserField($uid, "friend".$l, 0);
+ $userwait2 = $database->getUserField($uid, "friend".$l."wait", 0);
+ if($user2 == 0 && $userwait2 == 0 && $added1 == 0){
+ $database->addFriend($uid,"friend".$l."wait",$post['myid']);
+ $added1 = 1;
+ }
+ }
+ $database->addFriend($post['myid'],"friend".$j,$uid);
+ $database->addFriend($post['myid'],"friend".$j."wait",$uid);
+ $added = 1;
+ }
+ }
+ }
+ }
+ }
+ header("Location: nachrichten.php?t=1");
+ }
+
+}
+;
\ No newline at end of file
diff --git a/GameEngine/Multisort.php b/GameEngine/Multisort.php
new file mode 100644
index 00000000..97b03d19
--- /dev/null
+++ b/GameEngine/Multisort.php
@@ -0,0 +1,54 @@
+
\ No newline at end of file
diff --git a/GameEngine/Notes/DO NOT REMOVE THIS FOLDER.txt b/GameEngine/Notes/DO NOT REMOVE THIS FOLDER.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/GameEngine/Prevention/empty.txt b/GameEngine/Prevention/empty.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/GameEngine/Prevention/lock.lock b/GameEngine/Prevention/lock.lock
new file mode 100644
index 00000000..e69de29b
diff --git a/GameEngine/Profile.php b/GameEngine/Profile.php
new file mode 100644
index 00000000..4189c0d7
--- /dev/null
+++ b/GameEngine/Profile.php
@@ -0,0 +1,168 @@
+access!=BANNED){
+ $this->updateProfile($post);
+ }else{
+ header("Location: banned.php");
+ }
+ break;
+ case "p3":
+ if($session->access!=BANNED){
+ $this->updateAccount($post);
+ }else{
+ header("Location: banned.php");
+ }
+ break;
+ }
+ }
+ if(isset($post['s'])) {
+ switch($post['s']) {
+ case "4":
+ if($session->access!=BANNED){
+ $this->gpack($post);
+ }else{
+ header("Location: banned.php");
+ }
+ break;
+ }
+ }
+ }
+
+ public function procSpecial($get) {
+ global $session;
+ if(isset($get['e'])) {
+ switch($get['e']) {
+ case 2:
+ if($session->access!=BANNED){
+ $this->removeMeSit($get);
+ }else{
+ header("Location: banned.php");
+ }
+ break;
+ case 3:
+ if($session->access!=BANNED){
+ $this->removeSitter($get);
+ }else{
+ header("Location: banned.php");
+ }
+ break;
+ case 4:
+ if($session->access!=BANNED){
+ $this->cancelDeleting($get);
+ }else{
+ header("Location: banned.php");
+ }
+ break;
+ }
+ }
+ }
+
+ private function updateProfile($post) {
+ global $database;
+ $birthday = $post['jahr'].'-'.$post['monat'].'-'.$post['tag'];
+ $database->submitProfile($database->RemoveXSS($post['uid']),$database->RemoveXSS($post['mw']),$database->RemoveXSS($post['ort']),$database->RemoveXSS($birthday),$database->RemoveXSS($post['be2']),$database->RemoveXSS($post['be1']));
+ $varray = $database->getProfileVillages($post['uid']);
+ for($i=0;$i<=count($varray)-1;$i++) {
+ $database->setVillageName($database->RemoveXSS($varray[$i]['wref']),$post['dname'.$i]);
+ }
+ header("Location: spieler.php?uid=".$post['uid']);
+ }
+
+ private function gpack($post) {
+ global $database, $session;
+ $database->gpack($database->RemoveXSS($session->uid),$database->RemoveXSS($post['custom_url']));
+ header("Location: spieler.php?uid=".$session->uid);
+ }
+
+ private function updateAccount($post) {
+ global $database,$session,$form;
+ if($post['pw2'] == $post['pw3']) {
+ if($database->login($session->username,$post['pw1'])) {
+ if ($_POST['uid'] != $session->uid){
+ die("Hacking Attempr");
+ } else {
+ $database->updateUserField($post['uid'],"password",md5($post['pw2']),1);
+ }
+ }
+ else {
+ $form->addError("pw",LOGIN_PW_ERROR);
+ }
+ }
+ else {
+ $form->addError("pw",PASS_MISMATCH);
+ }
+ if($post['email_alt'] == $session->userinfo['email']) {
+ $database->updateUserField($post['uid'],"email",$post['email_neu'],1);
+ }
+ else {
+ $form->addError("email",EMAIL_ERROR);
+ }
+ if($post['del'] && md5($post['del_pw']) == $session->userinfo['password']) {
+ $database->setDeleting($post['uid'],0);
+ }
+ else {
+ $form->addError("del",PASS_MISMATCH);
+ }
+ if($post['v1'] != "") {
+ $sitid = $database->getUserField($post['v1'],"id",1);
+ if($sitid == $session->userinfo['sit1'] || $sitid == $session->userinfo['sit2']) {
+ $form->addError("sit",SIT_ERROR);
+ }
+ else if($sitid != $session->uid){
+ if($session->userinfo['sit1'] == 0) {
+ $database->updateUserField($post['uid'],"sit1",$sitid,1);
+ }
+ else if($session->userinfo['sit2'] == 0) {
+ $database->updateUserField($post['uid'],"sit2",$sitid,1);
+ }
+ }
+ }
+ $_SESSION['errorarray'] = $form->getErrors();
+ header("Location: spieler.php?s=3");
+ }
+
+ private function removeSitter($get) {
+ global $database,$session;
+ if($get['a'] == $session->checker) {
+ if($session->userinfo['sit'.$get['type']] == $get['id']) {
+ $database->updateUserField($session->uid,"sit".$get['type'],0,1);
+ }
+ $session->changeChecker();
+ }
+ header("Location: spieler.php?s=".$get['s']);
+ }
+
+ private function cancelDeleting($get) {
+ global $database,$session;
+ $database->setDeleting($get['id'],1);
+ header("Location: spieler.php?s=".$get['s']);
+ }
+
+ private function removeMeSit($get) {
+ global $database,$session;
+ if($get['a'] == $session->checker) {
+ $database->removeMeSit($get['id'],$session->uid);
+ $session->changeChecker();
+ }
+ header("Location: spieler.php?s=".$get['s']);
+ }
+};
+$profile = new Profile;
+?>
diff --git a/GameEngine/Protection.php b/GameEngine/Protection.php
new file mode 100644
index 00000000..0d4fac97
--- /dev/null
+++ b/GameEngine/Protection.php
@@ -0,0 +1,26 @@
+
\ No newline at end of file
diff --git a/GameEngine/Ranking.php b/GameEngine/Ranking.php
new file mode 100644
index 00000000..c551f59a
--- /dev/null
+++ b/GameEngine/Ranking.php
@@ -0,0 +1,545 @@
+rankarray;
+ }
+
+ public function getUserRank($id) {
+ $ranking = $this->getRank();
+ $users = "SELECT * FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8") . "";
+ $users2 = mysql_num_rows(mysql_query($users));
+ $users3 = $users2+1;
+ if(count($ranking) > 0) {
+ for($i=0;$i<($users3);$i++) {
+ if( isset( $ranking[$i]['userid'] ) )
+ {
+ if($ranking[$i]['userid'] == $id && $ranking[$i] != "pad") {
+ $myrank = $i;
+ }
+ }
+ }
+ }
+ return $myrank;
+ }
+
+ public function procRankReq($get) {
+ global $village, $session, $database;
+ if(isset($get['id'])) {
+ switch($get['id']) {
+ case 1:
+ $this->procRankArray();
+ break;
+ case 8:
+ $this->procHeroRankArray();
+ $this->getStart($this->searchRank($session->uid, "owner"));
+ break;
+ case 11:
+ $this->procRankRaceArray(1);
+ $this->getStart($this->searchRank($session->uid, "userid"));
+ break;
+ case 12:
+ $this->procRankRaceArray(2);
+ $this->getStart($this->searchRank($session->uid, "userid"));
+ break;
+ case 13:
+ $this->procRankRaceArray(3);
+ $this->getStart($this->searchRank($session->uid, "userid"));
+ break;
+ case 31:
+ $this->procAttRankArray();
+ $this->getStart($this->searchRank($session->uid, "userid"));
+ break;
+ case 32:
+ $this->procDefRankArray();
+ $this->getStart($this->searchRank($session->uid, "userid"));
+ break;
+ case 2:
+ $this->procVRankArray();
+ $this->getStart($this->searchRank($village->wid, "wref"));
+ break;
+ case 4:
+ $this->procARankArray();
+ if($get['aid'] == 0) {
+ $this->getStart(1);
+ } else {
+ $this->getStart($this->searchRank($get['aid'], "id"));
+ }
+ break;
+ case 41:
+ $this->procAAttRankArray();
+ if($get['aid'] == 0) {
+ $this->getStart(1);
+ } else {
+ $this->getStart($this->searchRank($get['aid'], "id"));
+ }
+ break;
+ case 42:
+ $this->procADefRankArray();
+ if($get['aid'] == 0) {
+ $this->getStart(1);
+ } else {
+ $this->getStart($this->searchRank($get['aid'], "id"));
+ }
+ break;
+ }
+ } else {
+ $this->procRankArray();
+ $this->getStart($this->searchRank($session->uid, "userid"));
+ }
+ }
+
+ public function procRank($post) {
+ if(isset($post['ft'])) {
+ switch($post['ft']) {
+ case "r1":
+ case "r31":
+ case "r32":
+ if(isset($post['rank']) && $post['rank'] != "") {
+ $this->getStart($post['rank']);
+ }
+ if(isset($post['name']) && $post['name'] != "") {
+ $this->getStart($this->searchRank(stripslashes($post['name']), "username"));
+ }
+ break;
+ case "r2":
+ case "r4":
+ case "r42":
+ case "r41":
+ if(isset($post['rank']) && $post['rank'] != "") {
+ $this->getStart($post['rank']);
+ }
+ if(isset($post['name']) && $post['name'] != "") {
+ $this->getStart($this->searchRank(stripslashes($post['name']), "name"));
+ }
+ break;
+ }
+ }
+ }
+
+ private function getStart($search) {
+ $multiplier = 1;
+ if(!is_numeric($search)) {
+ $_SESSION['search'] = $search;
+ } else {
+ if($search > count($this->rankarray)) {
+ $search = count($this->rankarray) - 1;
+ }
+ while($search > (20 * $multiplier)) {
+ $multiplier += 1;
+ }
+ $start = 20 * $multiplier - 19 - 1;
+ $_SESSION['search'] = $search;
+ $_SESSION['start'] = $start;
+ }
+ }
+
+ public function getAllianceRank($id) {
+ $this->procARankArray();
+ while(1) {
+ if(count($this->rankarray) > 1) {
+ $key = key($this->rankarray);
+ if($this->rankarray[$key]["id"] == $id) {
+ return $key;
+ break;
+ } else {
+ if(!next($this->rankarray)) {
+ return false;
+ break;
+ }
+ }
+ } else {
+ return 1;
+ }
+ }
+ }
+
+ public function searchRank($name, $field) {
+ while(1) {
+ $key = key($this->rankarray);
+ if($this->rankarray[$key][$field] == $name) {
+ return $key;
+ break;
+ } else {
+ if(!next($this->rankarray)) {
+ if($field != "userid"){
+ return $name;
+ break;
+ }else{
+ return 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public function procRankArray() {
+ global $database, $multisort;
+ if($database->countUser() > 0){
+ $holder = array();
+ if(SHOW_NATARS == True){
+ $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.oldrank oldrank, " . TB_PREFIX . "users.alliance alliance, (
+
+ SELECT SUM( " . TB_PREFIX . "vdata.pop )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid
+ )totalpop, (
+
+ SELECT COUNT( " . TB_PREFIX . "vdata.wref )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid AND type != 99
+ )totalvillages, (
+
+ SELECT " . TB_PREFIX . "alidata.tag
+ FROM " . TB_PREFIX . "alidata, " . TB_PREFIX . "users
+ WHERE " . TB_PREFIX . "alidata.id = " . TB_PREFIX . "users.alliance
+ AND " . TB_PREFIX . "users.id = userid
+ )allitag
+ FROM " . TB_PREFIX . "users
+ WHERE " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . "
+ AND " . TB_PREFIX . "users.tribe <= 5 ORDER BY totalpop DESC, totalvillages DESC, userid DESC";
+ }else{
+ $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.oldrank oldrank, " . TB_PREFIX . "users.alliance alliance, (
+
+ SELECT SUM( " . TB_PREFIX . "vdata.pop )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid
+ )totalpop, (
+
+ SELECT COUNT( " . TB_PREFIX . "vdata.wref )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid AND type != 99
+ )totalvillages, (
+
+ SELECT " . TB_PREFIX . "alidata.tag
+ FROM " . TB_PREFIX . "alidata, " . TB_PREFIX . "users
+ WHERE " . TB_PREFIX . "alidata.id = " . TB_PREFIX . "users.alliance
+ AND " . TB_PREFIX . "users.id = userid
+ )allitag
+ FROM " . TB_PREFIX . "users
+ WHERE " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . "
+ AND " . TB_PREFIX . "users.tribe <= 3 ORDER BY totalpop DESC, totalvillages DESC, userid DESC";
+ }
+
+ $result = (mysql_query($q));
+ while($row = mysql_fetch_assoc($result)) {
+ $datas[] = $row;
+ }
+
+ foreach($datas as $result) {
+ $value['userid'] = $result['userid'];
+ $value['username'] = $result['username'];
+ $value['oldrank'] = $result['oldrank'];
+ $value['alliance'] = $result['alliance'];
+ $value['aname'] = $result['allitag'];
+ $value['totalpop'] = $result['totalpop'];
+ $value['totalvillage'] = $result['totalvillages'];
+ array_push($holder, $value);
+ }
+
+ $newholder = array("pad");
+ foreach($holder as $key) {
+ array_push($newholder, $key);
+ }
+ $this->rankarray = $newholder;
+ }
+ }
+
+ private function procRankRaceArray($race) {
+ global $database, $multisort;
+ //$array = $database->getRanking();
+ $holder = array();
+ //$value['totalvillage'] = count($database->getVillagesID($value['id']));
+ //$value['totalvillage'] = count($database->getVillagesID($value['id']));
+ //$value['totalpop'] = $database->getVSumField($value['id'],"pop");
+ //$value['aname'] = $database->getAllianceName($value['alliance']);
+ $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.tribe tribe, " . TB_PREFIX . "users.username username," . TB_PREFIX . "users.alliance alliance, (
+
+ SELECT SUM( " . TB_PREFIX . "vdata.pop )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid
+ )totalpop, (
+
+ SELECT COUNT( " . TB_PREFIX . "vdata.wref )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid AND type != 99
+ )totalvillages, (
+
+ SELECT " . TB_PREFIX . "alidata.tag
+ FROM " . TB_PREFIX . "alidata, " . TB_PREFIX . "users
+ WHERE " . TB_PREFIX . "alidata.id = " . TB_PREFIX . "users.alliance
+ AND " . TB_PREFIX . "users.id = userid
+ )allitag
+ FROM " . TB_PREFIX . "users
+ WHERE " . TB_PREFIX . "users.tribe = $race AND " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . "
+ ORDER BY totalpop DESC, totalvillages DESC, userid DESC";
+
+
+ $result = (mysql_query($q));
+ while($row = mysql_fetch_assoc($result)) {
+ $datas[] = $row;
+ }
+
+ if(mysql_num_rows($result)) {
+
+
+ foreach($datas as $result) {
+ //$value = $array[$result['userid']];
+ $value['userid'] = $result['userid'];
+ $value['username'] = $result['username'];
+ $value['alliance'] = $result['alliance'];
+ $value['aname'] = $result['allitag'];
+ $value['totalpop'] = $result['totalpop'];
+ $value['totalvillage'] = $result['totalvillages'];
+ //SELECT (SELECT SUM(".TB_PREFIX."vdata.pop) FROM ".TB_PREFIX."vdata WHERE ".TB_PREFIX."vdata.owner = 2) totalpop, (SELECT COUNT(".TB_PREFIX."vdata.wref) FROM ".TB_PREFIX."vdata WHERE ".TB_PREFIX."vdata.owner = 2) totalvillages, (SELECT ".TB_PREFIX."alidata.tag FROM ".TB_PREFIX."alidata WHERE ".TB_PREFIX."alidata.id = ".TB_PREFIX."users.alliance AND ".TB_PREFIX."users.id = 2);
+ array_push($holder, $value);
+ }
+ } else {
+ $value['userid'] = 0;
+ $value['username'] = "No User";
+ $value['alliance'] = "";
+ $value['aname'] = "";
+ $value['totalpop'] = "";
+ $value['totalvillage'] = "";
+ array_push($holder, $value);
+ }
+ //$holder = $multisort->sorte($holder, "'totalvillage'", false, 2, "'totalpop'", false, 2);
+ $newholder = array("pad");
+ foreach($holder as $key) {
+ array_push($newholder, $key);
+ }
+ $this->rankarray = $newholder;
+ }
+
+ private function procAttRankArray() {
+ global $database, $multisort;
+ //$array = $database->getRanking();
+ $holder = array();
+
+ //$value['totalvillage'] = count($database->getVillagesID($value['id']));
+ //$value['totalpop'] = $database->getVSumField($value['id'],"pop");
+ $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.apall, (
+
+ SELECT COUNT( " . TB_PREFIX . "vdata.wref )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid AND type != 99
+ )totalvillages, (
+
+ SELECT SUM( " . TB_PREFIX . "vdata.pop )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid
+ )pop
+ FROM " . TB_PREFIX . "users
+ WHERE " . TB_PREFIX . "users.apall >=0 AND " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . " AND " . TB_PREFIX . "users.tribe <= 3
+ ORDER BY " . TB_PREFIX . "users.apall DESC, pop DESC, userid DESC";
+ $result = mysql_query($q) or die(mysql_error());
+ while($row = mysql_Fetch_assoc($result)) {
+ $datas[] = $row;
+ }
+
+ foreach($datas as $key => $row) {
+ //$value = $array[$row['userid']];
+ $value['username'] = $row['username'];
+ $value['totalvillages'] = $row['totalvillages'];
+ //$value['totalvillage'] = $row['totalvillages'];
+ $value['id'] = $row['userid'];
+ $value['totalpop'] = $row['pop'];
+ $value['apall'] = $row['apall'];
+ array_push($holder, $value);
+ printf("\n\n", $value['username'], $value['totalvillages'], $value['totalpop'], $value['apall']);
+ }
+
+ //$holder = $multisort->sorte($holder, "'ap'", false, 2, "'totalvillages'", false, 2, "'ap'", false, 2);
+ $newholder = array("pad");
+ foreach($holder as $key) {
+ array_push($newholder, $key);
+ }
+ $this->rankarray = $newholder;
+ }
+
+ private function procDefRankArray() {
+ //global $database, $multisort;
+ //$array = $database->getRanking();
+ $holder = array();
+ $q = "SELECT " . TB_PREFIX . "users.id userid, " . TB_PREFIX . "users.username username, " . TB_PREFIX . "users.dpall, (
+
+ SELECT COUNT( " . TB_PREFIX . "vdata.wref )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid AND type != 99
+ )totalvillages, (
+
+ SELECT SUM( " . TB_PREFIX . "vdata.pop )
+ FROM " . TB_PREFIX . "vdata
+ WHERE " . TB_PREFIX . "vdata.owner = userid
+ )pop
+ FROM " . TB_PREFIX . "users
+ WHERE " . TB_PREFIX . "users.dpall >=0 AND " . TB_PREFIX . "users.access < " . (INCLUDE_ADMIN ? "10" : "8") . " AND " . TB_PREFIX . "users.tribe <= 3
+ ORDER BY " . TB_PREFIX . "users.dpall DESC, pop DESC, userid DESC";
+ $result = mysql_query($q) or die(mysql_error());
+ while($row = mysql_Fetch_assoc($result)) {
+ $datas[] = $row;
+ }
+
+ foreach($datas as $key => $row) {
+ //$value = $array[$row['userid']];
+ $value['username'] = $row['username'];
+ $value['totalvillages'] = $row['totalvillages'];
+ //$value['totalvillage'] = $row['totalvillages'];
+ $value['id'] = $row['userid'];
+ $value['totalpop'] = $row['pop'];
+ $value['dpall'] = $row['dpall'];
+ array_push($holder, $value);
+
+ }
+
+ //$holder = $multisort->sorte($holder, "'dpall'", false, 2, "'totalvillage'", false, 2, "'dpall'", false, 2);
+ $newholder = array("pad");
+ foreach($holder as $key) {
+ array_push($newholder, $key);
+ }
+ $this->rankarray = $newholder;
+ }
+
+ private function procVRankArray() {
+ global $database, $multisort;
+ $array = $database->getVRanking();
+ $holder = array();
+ foreach($array as $value) {
+ $coor = $database->getCoor($value['wref']);
+ $value['x'] = $coor['x'];
+ $value['y'] = $coor['y'];
+ $value['user'] = $database->getUserField($value['owner'], "username", 0);
+
+ array_push($holder, $value);
+ }
+ $holder = $multisort->sorte($holder, "'x'", true, 2, "'y'", true, 2, "'pop'", false, 2);
+ $newholder = array("pad");
+ foreach($holder as $key) {
+ array_push($newholder, $key);
+ }
+ $this->rankarray = $newholder;
+ }
+
+ public function procARankArray() {
+ global $database, $multisort;
+ $array = $database->getARanking();
+ $holder = array();
+
+ foreach($array as $value) {
+ $memberlist = $database->getAllMember($value['id']);
+ $totalpop = 0;
+ foreach($memberlist as $member) {
+ $totalpop += $database->getVSumField($member['id'], "pop");
+ }
+ $value['players'] = count($memberlist);
+ $value['totalpop'] = $totalpop;
+ if(!isset($value['avg'])) {
+ $value['avg'] = @round($totalpop / count($memberlist));
+ } else {
+ $value['avg'] = 0;
+ }
+
+ array_push($holder, $value);
+ }
+ $holder = $multisort->sorte($holder, "'totalpop'", false, 2);
+ $newholder = array("pad");
+ foreach($holder as $key) {
+ array_push($newholder, $key);
+ }
+ $this->rankarray = $newholder;
+ }
+
+ private function procHeroRankArray() {
+ global $database, $multisort;
+ $array = $database->getHeroRanking();
+ $holder = array();
+ foreach($array as $value) {
+ $value['owner'] = $database->getUserField($value['uid'], "username", 0);
+ $value['level'];
+ $value['uid'];
+
+ array_push($holder, $value);
+ }
+ $holder = $multisort->sorte($holder, "'experience'", false, 2);
+ $newholder = array("pad");
+ foreach($holder as $key) {
+ array_push($newholder, $key);
+ }
+ $this->rankarray = $newholder;
+ }
+
+ private function procAAttRankArray() {
+ global $database, $multisort;
+ $array = $database->getARanking();
+ $holder = array();
+ foreach($array as $value) {
+ $memberlist = $database->getAllMember($value['id']);
+ $totalap = 0;
+ foreach($memberlist as $member) {
+ $totalap += $member['ap'];
+ }
+ $value['players'] = count($memberlist);
+ $value['totalap'] = $totalap;
+ if($value['avg'] > 0) {
+ $value['avg'] = round($totalap / count($memberlist));
+ } else {
+ $value['avg'] = 0;
+ }
+
+ array_push($holder, $value);
+ }
+ $holder = $multisort->sorte($holder, "'totalap'", false, 2);
+ $newholder = array("pad");
+ foreach($holder as $key) {
+ array_push($newholder, $key);
+ }
+ $this->rankarray = $newholder;
+ }
+
+ private function procADefRankArray() {
+ global $database, $multisort;
+ $array = $database->getARanking();
+ $holder = array();
+ foreach($array as $value) {
+ $memberlist = $database->getAllMember($value['id']);
+ $totaldp = 0;
+ foreach($memberlist as $member) {
+ $totaldp += $member['dp'];
+ }
+ $value['players'] = count($memberlist);
+ $value['totaldp'] = $totaldp;
+ if($value['avg'] > 0) {
+ $value['avg'] = round($totalap / count($memberlist));
+ } else {
+ $value['avg'] = 0;
+ }
+
+ array_push($holder, $value);
+ }
+ $holder = $multisort->sorte($holder, "'totaldp'", false, 2);
+ $newholder = array("pad");
+ foreach($holder as $key) {
+ array_push($newholder, $key);
+ }
+ $this->rankarray = $newholder;
+ }
+ }
+ ;
+
+ $ranking = new Ranking;
+
+?>
diff --git a/GameEngine/Session.php b/GameEngine/Session.php
new file mode 100644
index 00000000..b184e95c
--- /dev/null
+++ b/GameEngine/Session.php
@@ -0,0 +1,193 @@
+time = time();
+ session_start();
+
+ $this->logged_in = $this->checkLogin();
+
+ if($this->logged_in && TRACK_USR) {
+ $database->updateActiveUser($this->username, $this->time);
+ }
+ if(isset($_SESSION['url'])) {
+ $this->referrer = $_SESSION['url'];
+ } else {
+ $this->referrer = "/";
+ }
+ $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
+ $this->SurfControl();
+ }
+
+ public function Login($user) {
+ global $database, $generator, $logging;
+ $this->logged_in = true;
+ $_SESSION['sessid'] = $generator->generateRandID();
+ $_SESSION['username'] = $user;
+ $_SESSION['checker'] = $generator->generateRandStr(3);
+ $_SESSION['mchecker'] = $generator->generateRandStr(5);
+ $_SESSION['qst'] = $database->getUserField($_SESSION['username'], "quest", 1);
+ if(!isset($_SESSION['wid'])) {
+ $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1');
+ $data = mysql_fetch_assoc($query);
+ $_SESSION['wid'] = $data['wref'];
+ } else
+ if($_SESSION['wid'] == '') {
+ $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $database->getUserField($_SESSION['username'], "id", 1) . ' LIMIT 1');
+ $data = mysql_fetch_assoc($query);
+ $_SESSION['wid'] = $data['wref'];
+ }
+ $this->PopulateVar();
+
+ $logging->addLoginLog($this->uid, $_SERVER['REMOTE_ADDR']);
+ $database->addActiveUser($_SESSION['username'], $this->time);
+ $database->updateUserField($_SESSION['username'], "sessid", $_SESSION['sessid'], 0);
+
+ header("Location: dorf1.php");
+ }
+
+ public function Logout() {
+ global $database;
+ $this->logged_in = false;
+ $database->updateUserField($_SESSION['username'], "sessid", "", 0);
+ if(ini_get("session.use_cookies")) {
+ $params = session_get_cookie_params();
+ setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
+ }
+ session_destroy();
+ session_start();
+ }
+
+ public function changeChecker() {
+ global $generator;
+ $this->checker = $_SESSION['checker'] = $generator->generateRandStr(3);
+ $this->mchecker = $_SESSION['mchecker'] = $generator->generateRandStr(5);
+ }
+
+ private function checkLogin(){
+ global $database;
+ if(isset($_SESSION['username']) && isset($_SESSION['sessid'])) {
+ //Get and Populate Data
+ $this->PopulateVar();
+ //update database
+ $database->addActiveUser($_SESSION['username'], $this->time);
+ $database->updateUserField($_SESSION['username'], "timestamp", $this->time, 0);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private function PopulateVar() {
+ global $database;
+ $this->userarray = $this->userinfo = $database->getUserArray($_SESSION['username'], 0);
+ $this->username = $this->userarray['username'];
+ $this->uid = $_SESSION['id_user'] = $this->userarray['id'];
+ $this->gpack = $this->userarray['gpack'];
+ $this->access = $this->userarray['access'];
+ $this->plus = ($this->userarray['plus'] > $this->time);
+ $this->goldclub = $this->userarray['goldclub'];
+ $this->villages = $database->getVillagesID($this->uid);
+ $this->tribe = $this->userarray['tribe'];
+ $this->isAdmin = $this->access >= MODERATOR;
+ $this->alliance = $_SESSION['alliance_user'] = $this->userarray['alliance'];
+ $this->checker = $_SESSION['checker'];
+ $this->mchecker = $_SESSION['mchecker'];
+ $this->sit = $database->GetOnline($this->uid);
+ $this->sit1 = $this->userarray['sit1'];
+ $this->sit2 = $this->userarray['sit2'];
+ $this->cp = floor($this->userarray['cp']);
+ $this->gold = $this->userarray['gold'];
+ $this->oldrank = $this->userarray['oldrank'];
+ $_SESSION['ok'] = $this->userarray['ok'];
+ if($this->userarray['b1'] > $this->time) {
+ $this->bonus1 = 1;
+ }
+ if($this->userarray['b2'] > $this->time) {
+ $this->bonus2 = 1;
+ }
+ if($this->userarray['b3'] > $this->time) {
+ $this->bonus3 = 1;
+ }
+ if($this->userarray['b4'] > $this->time) {
+ $this->bonus4 = 1;
+ }
+ }
+
+ private function SurfControl(){
+ if(SERVER_WEB_ROOT) {
+ $page = $_SERVER['SCRIPT_NAME'];
+ } else {
+ $explode = explode("/", $_SERVER['SCRIPT_NAME']);
+ $i = count($explode) - 1;
+ $page = $explode[$i];
+
+ }
+ $pagearray = array("index.php", "anleitung.php", "tutorial.php", "login.php", "activate.php", "anmelden.php", "xaccount.php");
+ if(!$this->logged_in) {
+ if(!in_array($page, $pagearray) || $page == "logout.php") {
+ header("Location: login.php");
+ }
+ } else {
+ if(in_array($page, $pagearray)) {
+ header("Location: dorf1.php");
+ }
+
+ }
+ }
+};
+$session = new Session;
+$form = new Form;
+$message = new Message;
+?>
diff --git a/GameEngine/Technology.php b/GameEngine/Technology.php
new file mode 100644
index 00000000..8f0958f6
--- /dev/null
+++ b/GameEngine/Technology.php
@@ -0,0 +1,736 @@
+U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,U12,U13,U14,U15,U16,U17,U18,U19,U20,U21,U22,U23,U24,U25,U26,U27,U28,U29,U30,U31,U32,U33,U34,U35,U36,U37,U38,U39,U40,U41,U42,U43,U44,U45,U46,U47,U48,U49,U50,U99,U0);
+
+ public function grabAcademyRes() {
+ global $village;
+ $holder = array();
+ foreach($village->researching as $research) {
+ if(substr($research['tech'],0,1) == "t"){
+ array_push($holder,$research);
+ }
+ }
+ return $holder;
+ }
+
+ public function getABUpgrades($type='a') {
+ global $village;
+ $holder = array();
+ foreach($village->researching as $research) {
+ if(substr($research['tech'],0,1) == $type){
+ array_push($holder,$research);
+ }
+ }
+ return $holder;
+ }
+
+ public function isResearch($tech,$type) {
+ global $village;
+ 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;
+ }
+ }
+ return false;
+ }
+ }
+
+ public function procTech($post) {
+ if(isset($post['ft'])) {
+ switch($post['ft']) {
+ case "t1":
+ $this->procTrain($post);
+ break;
+ case "t3":
+ $this->procTrain($post,true);
+ break;
+ }
+ }
+ }
+
+ public function procTechno($get) {
+ global $village;
+ if(isset($get['a'])) {
+ switch($village->resarray['f'.$get['id'].'t']) {
+ case 22:
+ $this->researchTech($get);
+ break;
+ case 13:
+ $this->upgradeArmour($get);
+ break;
+ case 12:
+ $this->upgradeSword($get);
+ break;
+ }
+ }
+ }
+
+ public function getTrainingList($type) {
+ global $database,$village;
+ $trainingarray = $database->getTraining($village->wid);
+ $listarray = array();
+ $barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44);
+ $greatbarracks = array(61,62,63,71,72,73,84,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104);
+ $stables = array(4,5,6,15,16,23,24,25,26,45,46);
+ $greatstables = array(64,65,66,75,76,83,84,85,86,105,106);
+ $workshop = array(7,8,17,18,27,28,47,48);
+ $greatworkshop = array(67,68,77,78,87,88,107,108);
+ $residence = array(9,10,19,20,29,30,49,50);
+ $trapper = array(99);
+ if(count($trainingarray) > 0) {
+ foreach($trainingarray as $train) {
+ if($type == 1 && in_array($train['unit'],$barracks)) {
+ $train['name'] = $this->unarray[$train['unit']];
+ array_push($listarray,$train);
+ }
+ if($type == 2 && in_array($train['unit'],$stables)) {
+ $train['name'] = $this->unarray[$train['unit']];
+ array_push($listarray,$train);
+ }
+ if($type == 3 && in_array($train['unit'],$workshop)) {
+ $train['name'] = $this->unarray[$train['unit']];
+ array_push($listarray,$train);
+ }
+ if($type == 4 && in_array($train['unit'],$residence)) {
+ $train['name'] = $this->unarray[$train['unit']];
+ array_push($listarray,$train);
+ }
+ if($type == 5 && in_array($train['unit'],$greatbarracks)) {
+ $train['name'] = $this->unarray[$train['unit']-60];
+ $train['unit'] -= 60;
+ array_push($listarray,$train);
+ }
+ if($type == 6 && in_array($train['unit'],$greatstables)) {
+ $train['name'] = $this->unarray[$train['unit']-60];
+ $train['unit'] -= 60;
+ array_push($listarray,$train);
+ }
+ if($type == 7 && in_array($train['unit'],$greatworkshop)) {
+ $train['name'] = $this->unarray[$train['unit']-60];
+ $train['unit'] -= 60;
+ array_push($listarray,$train);
+ }
+ if($type == 8 && in_array($train['unit'],$trapper)) {
+ $train['name'] = $this->unarray[$train['unit']];
+ array_push($listarray,$train);
+ }
+ }
+ }
+ return $listarray;
+ }
+
+ public function getUnitList() {
+ global $database,$village;
+ $unitarray = func_num_args() == 1? $database->getUnit(func_get_arg(0)) : $village->unitall;
+ $listArray = array();
+ for($i=1;$iunarray);$i++) {
+ $holder = array();
+ if($unitarray['u'.$i] != 0 && $unitarray['u'.$i] != "") {
+ $holder['id'] = $i;
+ $holder['name'] = $this->unarray[$i];
+ $holder['amt'] = $unitarray['u'.$i];
+ array_push($listArray,$holder);
+ }
+ }if($unitarray['hero'] != 0 && $unitarray['hero'] != "") {
+ $holder['id'] = "hero";
+ $holder['name'] = $this->unarray[$i];
+ $holder['amt'] = $unitarray['hero'];
+ array_push($listArray,$holder);
+ }
+ return $listArray;
+ }
+
+ public function maxUnit($unit,$great=false) {
+ $unit = "u".$unit;
+ global $village,$$unit;
+ $unitarray = $$unit;
+ $res = array();
+ $res = mysql_fetch_assoc(mysql_query("SELECT maxstore, maxcrop, wood, clay, iron, crop FROM ".TB_PREFIX."vdata WHERE wref = ".$village->wid)) or die(mysql_error());
+ if ($res['wood'] > $res['maxstore']){$res['wood'] = $res['maxstore'];}
+ if ($res['clay'] > $res['maxstore']){$res['clay'] = $res['maxstore'];}
+ if ($res['iron'] > $res['maxstore']){$res['iron'] = $res['maxstore'];}
+ if ($res['crop'] > $res['maxcrop']){$res['crop'] = $res['maxcrop'];}
+ $woodcalc = floor($res['wood'] / ($unitarray['wood'] * ($great?3:1)));
+ $claycalc = floor($res['clay'] / ($unitarray['clay'] * ($great?3:1)));
+ $ironcalc = floor($res['iron'] / ($unitarray['iron'] * ($great?3:1)));
+ if($res['crop']>0){
+ $cropcalc = floor($res['crop'] / ($unitarray['crop'] * ($great?3:1)));
+ }else{
+ $cropcalc = 0;
+ }
+ if($unit != "u99"){
+ $popcalc = floor($village->getProd("crop")/$unitarray['pop']);
+ }else{
+ $popcalc = $village->getProd("crop");
+ }
+ return min($woodcalc,$claycalc,$ironcalc,$cropcalc);
+ }
+
+ public function maxUnitPlus($unit,$great=false) {
+ $unit = "u".$unit;
+ global $village,$$unit;
+ $unitarray = $$unit;
+ $res = array();
+ $res = mysql_fetch_assoc(mysql_query("SELECT maxstore, maxcrop, wood, clay, iron, crop FROM ".TB_PREFIX."vdata WHERE wref = ".$village->wid)) or die(mysql_error());
+ $totalres = $res['wood']+$res['clay']+$res['iron']+$res['crop'];
+ $totalresunit = ($unitarray['wood'] * ($great?3:1))+($unitarray['clay'] * ($great?3:1))+($unitarray['iron'] * ($great?3:1))+($unitarray['crop'] * ($great?3:1));
+ $max =round($totalres/$totalresunit);
+ return $max;
+ }
+
+ public function getUnits() {
+ global $database,$village;
+ if(func_num_args() == 1) {
+ $base = func_get_arg(0);
+ }
+ $ownunit = func_num_args() == 2? func_get_arg(0) : $database->getUnit($base);
+ $enforcementarray = func_num_args() == 2? func_get_arg(1) : $database->getEnforceVillage($base,0);
+ if(count($enforcementarray) > 0) {
+ foreach($enforcementarray as $enforce) {
+ for($i=1;$i<=50;$i++) {
+ $ownunit['u'.$i] += $enforce['u'.$i];
+ }
+ }
+ }
+ return $ownunit;
+ }
+
+ function getAllUnits($base,$InVillageOnly=False,$mode=0) {
+ global $database;
+ $ownunit = $database->getUnit($base);
+ $ownunit['u99'] -= $ownunit['u99'];
+ $ownunit['u99o'] -= $ownunit['u99o'];
+ $enforcementarray = $database->getEnforceVillage($base,0);
+ if(count($enforcementarray) > 0) {
+ foreach($enforcementarray as $enforce) {
+ for($i=1;$i<=50;$i++) {
+ $ownunit['u'.$i] += $enforce['u'.$i];
+ }
+ $ownunit['hero'] += $enforce['hero'];
+ }
+ }
+ if($mode==0){
+ $prisoners = $database->getPrisoners($base);
+ if(!empty($prisoners)) {
+ foreach($prisoners as $prisoner){
+ $owner = $database->getVillageField($base,"owner");
+ $ownertribe = $database->getUserField($owner,"tribe",0);
+ $start = ($ownertribe-1)*10+1;
+ $end = ($ownertribe*10);
+ for($i=$start;$i<=$end;$i++) {
+ $j = $i-$start+1;
+ $ownunit['u'.$i] += $prisoner['t'.$j];
+ }
+ $ownunit['hero'] += $prisoner['t11'];
+ }
+ }
+ }
+ if(!$InVillageOnly) {
+ $movement = $database->getVillageMovement($base);
+ if(!empty($movement)) {
+ for($i=1;$i<=50;$i++) {
+ $ownunit['u'.$i] += $movement['u'.$i];
+ }
+ $ownunit['hero'] += $movement['hero'];
+ }
+ }
+ return $ownunit;
+ }
+
+ public function meetTRequirement($unit) {
+ global $session;
+ switch($unit) {
+ case 1:
+ if($session->tribe == 1) { return true; } else { return false; }
+ break;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ if($this->getTech($unit) && $session->tribe == 1) { return true; } else { return false; }
+ break;
+ case 10:
+ if($session->tribe == 1) { return true; } else { return false; }
+ break;
+ case 11:
+ if($session->tribe == 2) { return true; } else { return false; }
+ break;
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ if($session->tribe == 2 && $this->getTech($unit)) { return true; } else { return false; }
+ break;
+ case 20:
+ if($session->tribe == 2) { return true; } else { return false; }
+ break;
+ case 21:
+ if($session->tribe == 3) { return true; } else { return false; }
+ break;
+ case 22:
+ case 23:
+ case 24:
+ case 25:
+ case 26:
+ case 27:
+ case 28:
+ if($session->tribe == 3 && $this->getTech($unit)) { return true; } else { return false; }
+ break;
+ case 30:
+ if($session->tribe == 3) { return true; } else { return false; }
+ break;
+ case 31:
+ if($session->tribe == 4) { return true; } else { return false; }
+ break;
+ case 32:
+ case 33:
+ case 34:
+ case 35:
+ case 36:
+ case 37:
+ case 38:
+ if($session->tribe == 4 && $this->getTech($unit)) { return true; } else { return false; }
+ break;
+ case 40:
+ if($session->tribe == 4) { return true; } else { return false; }
+ break;
+ case 41:
+ if($session->tribe == 5) { return true; } else { return false; }
+ break;
+ case 42:
+ case 43:
+ case 44:
+ case 45:
+ case 46:
+ case 47:
+ case 48:
+ if($session->tribe == 5 && $this->getTech($unit)) { return true; } else { return false; }
+ break;
+ case 50:
+ if($session->tribe == 5) { return true; } else { return false; }
+ break;
+ }
+ }
+
+ public function getTech($tech) {
+ global $village;
+ return ($village->techarray['t'.$tech] == 1);
+ }
+
+ private function procTrain($post,$great=false) {
+ global $session;
+ if($session->access != BANNED){
+ $start = ($session->tribe-1)*10+1;
+ $end = ($session->tribe*10);
+ for($i=$start;$i<=($end);$i++) {
+ if(isset($post['t'.$i]) && $post['t'.$i] != 0) {
+ $amt = $post['t'.$i];
+ $amt = intval($amt);
+ if ($amt < 0) $amt = 1;
+ $this->trainUnit($i,$amt,$great);
+ }
+ }
+ if($session->tribe == 3){
+ if(isset($post['t99']) && $post['t99'] != 0) {
+ $amt = $post['t99'];
+ $amt = intval($amt);
+ if ($amt < 0) $amt = 1;
+ $this->trainUnit(99,$amt,$great);
+ }
+ }
+ header("Location: build.php?id=".$post['id']);
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ public function getUpkeep($array,$type,$vid=0,$prisoners=0) {
+ global $database,$session,$village;
+ if($vid==0) { $vid=$village->wid; }
+ $buildarray = array();
+ $buildarray = $database->getResourceLevel($vid);
+ $upkeep = 0;
+ switch($type) {
+ case 0:
+ $start = 1;
+ $end = 50;
+ break;
+ case 1:
+ $start = 1;
+ $end = 10;
+ break;
+ case 2:
+ $start = 11;
+ $end = 20;
+ break;
+ case 3:
+ $start = 21;
+ $end = 30;
+ break;
+ case 4:
+ $start = 31;
+ $end = 40;
+ break;
+ case 5:
+ $start = 41;
+ $end = 50;
+ break;
+ }
+ for($i=$start;$i<=$end;$i++) {
+ $k = $i-$start+1;
+ $unit = "u".$i;
+ $unit2 = "t".$k;
+ global $$unit;
+ $dataarray = $$unit;
+ for($j=19;$j<=38;$j++) {
+ if($buildarray['f'.$j.'t'] == 41) {
+ $horsedrinking = $j;
+ }
+ }
+ if($prisoners == 0){
+ if(isset($horsedrinking)){
+ if(($i==4 && $buildarray['f'.$horsedrinking] >= 10)
+ || ($i==5 && $buildarray['f'.$horsedrinking] >= 15)
+ || ($i==6 && $buildarray['f'.$horsedrinking] == 20)) {
+ $upkeep += ($dataarray['pop']-1) * $array[$unit];
+ } else {
+ $upkeep += $dataarray['pop'] * $array[$unit];
+ }}else{
+ $upkeep += $dataarray['pop'] * $array[$unit];
+ }
+ }else{
+ if(isset($horsedrinking)){
+ if(($i==4 && $buildarray['f'.$horsedrinking] >= 10)
+ || ($i==5 && $buildarray['f'.$horsedrinking] >= 15)
+ || ($i==6 && $buildarray['f'.$horsedrinking] == 20)) {
+ $upkeep += ($dataarray['pop']-1) * $array[$unit2];
+ } else {
+ $upkeep += $dataarray['pop'] * $array[$unit2];
+ }}else{
+ $upkeep += $dataarray['pop'] * $array[$unit2];
+ }
+ }
+ }
+ // $unit = "hero";
+ // global $$unit;
+ // $dataarray = $$unit;
+ if($prisoners == 0){
+ $upkeep += $array['hero'] * 6;
+ }else{
+ $upkeep += $array['t11'] * 6;
+ }
+ $artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,4,3,0));
+ $artefact1 = count($database->getOwnUniqueArtefactInfo2($vid,4,1,1));
+ $artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,4,2,0));
+ if($artefact > 0){
+ $upkeep /= 2;
+ $upkeep = round($upkeep);
+ }else if($artefact1 > 0){
+ $upkeep /= 2;
+ $upkeep = round($upkeep);
+ }else if($artefact2 > 0){
+ $upkeep /= 4;
+ $upkeep = round($upkeep);
+ $upkeep *= 3;
+ }
+ $foolartefact = $database->getFoolArtefactInfo(4,$vid,$session->uid);
+ if(count($foolartefact) > 0){
+ foreach($foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $upkeep *= $arte['effect2'];
+ }else{
+ $upkeep /= $arte['effect2'];
+ $upkeep = round($upkeep);
+ }
+ }
+ }
+ return $upkeep;
+ }
+
+private function trainUnit($unit,$amt,$great=false) {
+ global $session,$database,${'u'.$unit},$building,$village,$bid19,$bid20,$bid21,$bid25,$bid26,$bid29,$bid30,$bid36,$bid41,$bid42;
+
+ if($this->getTech($unit) || $unit%10 <= 1 || $unit == 99) {
+ $footies = array(1,2,3,11,12,13,14,21,22,31,32,33,34,41,42,43,44);
+ $calvary = array(4,5,6,15,16,23,24,25,26,35,36,45,46);
+ $workshop = array(7,8,17,18,27,28,37,38,47,48);
+ $special = array(9,10,19,20,29,30,39,40,49,50);
+ $trapper = array(99);
+ if(in_array($unit,$footies)) {
+ if($great) {
+ $each = round(($bid29[$building->getTypeLevel(29)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
+ } else {
+ $each = round(($bid19[$building->getTypeLevel(19)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
+ }
+ }
+ if(in_array($unit,$calvary)) {
+ if($great) {
+ $each = round(($bid30[$building->getTypeLevel(30)]['attri'] * ($building->getTypeLevel(41)>=1?(1/$bid41[$building->getTypeLevel(41)]['attri']):1) / 100) * ${'u'.$unit}['time'] / SPEED);
+ } else {
+ $each = round(($bid20[$building->getTypeLevel(20)]['attri'] * ($building->getTypeLevel(41)>=1?(1/$bid41[$building->getTypeLevel(41)]['attri']):1) / 100) * ${'u'.$unit}['time'] / SPEED);
+ }
+ }
+ if(in_array($unit,$workshop)) {
+ if($great) {
+ $each = round(($bid42[$building->getTypeLevel(42)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
+ } else {
+ $each = round(($bid21[$building->getTypeLevel(21)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
+ }
+ }
+ if(in_array($unit,$special)) {
+ if($building->getTypeLevel(25) > 0){
+ $each = round(($bid25[$building->getTypeLevel(25)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
+ } else {
+ $each = round(($bid26[$building->getTypeLevel(26)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
+ }
+ }
+ if(in_array($unit,$trapper)) {
+ $each = round(($bid19[$building->getTypeLevel(36)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
+ }
+ if($unit%10 == 0 || $unit%10 == 9 && $unit != 99) {
+ $slots = $database->getAvailableExpansionTraining();
+ if($unit%10 == 0 && $slots['settlers'] <= $amt) { $amt = $slots['settlers']; }
+ if($unit%10 == 9 && $slots['chiefs'] <= $amt) { $amt = $slots['chiefs']; }
+ } else {
+ if($unit != 99){
+ if($this->maxUnit($unit,$great) < $amt) {
+ $amt = 0;
+ }
+ }else{
+ $trainlist = $this->getTrainingList(8);
+ foreach($trainlist as $train) {
+ $train_amt += $train['amt'];
+ }
+ $max = 0;
+ for($i=19;$i<41;$i++){
+ if($village->resarray['f'.$i.'t'] == 36){
+ $max += $bid36[$village->resarray['f'.$i]]['attri'];
+ }
+ }
+ $max1 = $max - ($village->unitarray['u99'] + $train_amt);
+ if($max1 < $amt) {
+ $amt = 0;
+ }
+ }
+ }
+ $wood = ${'u'.$unit}['wood'] * $amt * ($great?3:1);
+ $clay = ${'u'.$unit}['clay'] * $amt * ($great?3:1);
+ $iron = ${'u'.$unit}['iron'] * $amt * ($great?3:1);
+ $crop = ${'u'.$unit}['crop'] * $amt * ($great?3:1);
+ $each = ($each == 0) ? 1 : $each;
+ $time = $each*$amt;
+ if($database->modifyResource($village->wid,$wood,$clay,$iron,$crop,0) && $amt > 0) {
+ $database->trainUnit($village->wid,$unit+($great?60:0),$amt,${'u'.$unit}['pop'],$each,time()+$time,0);
+ }
+ }
+ }
+
+ public function meetRRequirement($tech) {
+ global $session,$building;
+ switch($tech) {
+ case 2:
+ if($building->getTypeLevel(22) >= 1 && $building->getTypeLevel(13) >= 1) { return true; } else { return false; }
+ break;
+ case 3:
+ if($building->getTypeLevel(22) >= 5 && $building->getTypeLevel(12) >= 1) { return true; } else { return false; }
+ break;
+ case 4:
+ case 23:
+ if($building->getTypeLevel(22) >= 5 && $building->getTypeLevel(20) >= 1) { return true; } else { return false; }
+ break;
+ case 5:
+ case 25:
+ if($building->getTypeLevel(22) >= 5 && $building->getTypeLevel(20) >= 5) { return true; } else { return false; }
+ break;
+ case 6:
+ if($building->getTypeLevel(22) >= 15 && $building->getTypeLevel(20) >= 10) { return true; } else { return false; }
+ break;
+ case 9:
+ case 29:
+ if($building->getTypeLevel(22) >= 20 && $building->getTypeLevel(16) >= 10) { return true; } else { return false; }
+ break;
+ case 12:
+ case 32:
+ case 42:
+ if($building->getTypeLevel(22) >= 1 && $building->getTypeLevel(19) >= 3) { return true; } else { return false; }
+ break;
+ case 13:
+ case 33:
+ case 43:
+ if($building->getTypeLevel(22) >= 3 && $building->getTypeLevel(12) >= 1) { return true; } else { return false; }
+ break;
+ case 14:
+ case 34:
+ case 44:
+ if($building->getTypeLevel(22) >= 1 && $building->getTypeLevel(15) >= 5) { return true; } else { return false; }
+ break;
+ case 15:
+ case 35:
+ case 45:
+ if($building->getTypeLevel(22) >= 1 && $building->getTypeLevel(20) >= 3) { return true; } else { return false; }
+ break;
+ case 16:
+ case 26:
+ case 36:
+ case 46:
+ if($building->getTypeLevel(22) >= 15 && $building->getTypeLevel(20) >= 10) { return true; } else { return false; }
+ break;
+ case 7:
+ case 17:
+ case 27:
+ case 37:
+ case 47:
+ if($building->getTypeLevel(22) >= 10 && $building->getTypeLevel(21) >= 1) { return true; } else { return false; }
+ break;
+ case 8:
+ case 18:
+ case 28:
+ case 38:
+ case 48:
+ if($building->getTypeLevel(22) >= 15 && $building->getTypeLevel(21) >= 10) { return true; } else { return false; }
+ break;
+ case 19:
+ case 39:
+ case 49:
+ if($building->getTypeLevel(22) >= 20 && $building->getTypeLevel(16) >= 5) { return true; } else { return false; }
+ break;
+ case 22:
+ if($building->getTypeLevel(22) >= 3 && $building->getTypeLevel(12) >= 1) { return true; } else { return false; }
+ break;
+ case 24:
+ if($building->getTypeLevel(22) >= 5 && $building->getTypeLevel(20) >= 3) { return true; } else { return false; }
+ break;
+ }
+ }
+
+ private function researchTech($get) {
+ //global $database,$session,${'r'.$get['a']},$village,$logging;
+ global $database,$session,${'r'.$get['a']},$bid22,$building,$village,$logging;
+ if($this->meetRRequirement($get['a']) && $get['c'] == $session->mchecker) {
+ $data = ${'r'.$get['a']};
+ $time = time() + round(($data['time'] * ($bid22[$building->getTypeLevel(22)]['attri'] / 100))/SPEED);
+ //$time = time() + round($data['time']/SPEED);
+ $database->modifyResource($village->wid,$data['wood'],$data['clay'],$data['iron'],$data['crop'],0);
+ $database->addResearch($village->wid,"t".$get['a'],$time);
+ $logging->addTechLog($village->wid,"t".$get['a'],1);
+ }
+ $session->changeChecker();
+ header("Location: build.php?id=".$get['id']);
+ }
+
+ private function upgradeSword($get) {
+ global $database,$session,$bid12,$building,$village,$logging;
+ $ABTech = $database->getABTech($village->wid);
+ $CurrentTech = $ABTech["b".$get['a']];
+ $unit = ($session->tribe-1)*10+intval($get['a']);
+ if(($this->getTech($unit) || ($unit % 10) == 1) && ($CurrentTech < $building->getTypeLevel(12)) && $get['c'] == $session->mchecker) {
+ global ${'ab'.strval($unit)};
+ $data = ${'ab'.strval($unit)};
+ $time = time() + round(($data[$CurrentTech+1]['time'] * ($bid12[$building->getTypeLevel(12)]['attri'] / 100))/SPEED);
+ if ($database->modifyResource($village->wid,$data[$CurrentTech+1]['wood'],$data[$CurrentTech+1]['clay'],$data[$CurrentTech+1]['iron'],$data[$CurrentTech+1]['crop'],0)) {
+ $database->addResearch($village->wid,"b".$get['a'],$time);
+ $logging->addTechLog($village->wid,"b".$get['a'],$CurrentTech+1);
+ }
+ }
+ $session->changeChecker();
+ header("Location: build.php?id=".$get['id']);
+ }
+
+ private function upgradeArmour($get) {
+ global $database,$session,$bid13,$building,$village,$logging;
+ $ABTech = $database->getABTech($village->wid);
+ $CurrentTech = $ABTech["a".$get['a']];
+ $unit = ($session->tribe-1)*10+intval($get['a']);
+ if(($this->getTech($unit) || ($unit % 10) == 1) && ($CurrentTech < $building->getTypeLevel(13)) && $get['c'] == $session->mchecker) {
+ global ${'ab'.strval($unit)};
+ $data = ${'ab'.strval($unit)};
+ $time = time() + round(($data[$CurrentTech+1]['time'] * ($bid13[$building->getTypeLevel(13)]['attri'] / 100))/SPEED);
+ if ($database->modifyResource($village->wid,$data[$CurrentTech+1]['wood'],$data[$CurrentTech+1]['clay'],$data[$CurrentTech+1]['iron'],$data[$CurrentTech+1]['crop'],0)) {
+ $database->addResearch($village->wid,"a".$get['a'],$time);
+ $logging->addTechLog($village->wid,"a".$get['a'],$CurrentTech+1);
+ }
+ }
+ $session->changeChecker();
+ header("Location: build.php?id=".$get['id']);
+ }
+
+ public function getUnitName($i) {
+ return $this->unarray[$i];
+ }
+
+ public function finishTech() {
+ global $database,$village;
+ $q = "UPDATE ".TB_PREFIX."research SET timestamp=".(time()-1)." WHERE vref = ".$village->wid;
+ $database->query($q);
+ }
+
+ public function calculateAvaliable($id,$resarray=array()) {
+ global $village,$generator,${'r'.$id};
+ if(count($resarray)==0) {
+ $resarray['wood'] = ${'r'.$id}['wood'];
+ $resarray['clay'] = ${'r'.$id}['clay'];
+ $resarray['iron'] = ${'r'.$id}['iron'];
+ $resarray['crop'] = ${'r'.$id}['crop'];
+ }
+ $rwtime = ($resarray['wood']-$village->awood) / $village->getProd("wood") * 3600;
+ $rcltime = ($resarray['clay']-$village->aclay) / $village->getProd("clay") * 3600;
+ $ritime = ($resarray['iron']-$village->airon) / $village->getProd("iron") * 3600;
+ $rctime = ($resarray['crop']-$village->acrop) / $village->getProd("crop") * 3600;
+ if($village->getProd("crop") >= 0) {
+ $reqtime = max($rwtime,$rcltime,$ritime,$rctime) + time();
+ } else {
+ $reqtime = max($rwtime,$rcltime,$ritime);
+ if($reqtime > $rctime) {
+ $reqtime = 0;
+ } else {
+ $reqtime += time();
+ }
+ }
+ return $generator->procMtime($reqtime);
+ }
+
+ public function checkReinf($id) {
+ global $database;
+ $enforce=$database->getEnforceArray($id,0);
+ $fail='0';
+ for($i=1; $i<50; $i++){
+ if($enforce['u'.$i.'']>0){
+ $fail='1';
+ }
+ }
+ if($fail==0){
+ $database->deleteReinf($id);
+ }
+
+ }
+
+}
+$technology = new Technology;
+?>
\ No newline at end of file
diff --git a/GameEngine/Units.php b/GameEngine/Units.php
new file mode 100644
index 00000000..b0e32587
--- /dev/null
+++ b/GameEngine/Units.php
@@ -0,0 +1,551 @@
+sendTroops($post);
+ }else{
+ $post = $this->loadUnits($post);
+ return $post;
+ }
+ break;
+
+ case "2":
+ if (isset($post['a'])&& $post['a']==533374 && $post['disabledr'] == ""){
+ $this->sendTroops($post);
+ }else{
+ $post = $this->loadUnits($post);
+ return $post;
+ }
+ break;
+
+ case "8":
+ $this->sendTroopsBack($post);
+ break;
+
+ case "3":
+ if (isset($post['a'])&& $post['a']==533374 && $post['disabled'] == ""){
+ $this->sendTroops($post);
+ }else{
+ $post = $this->loadUnits($post);
+ return $post;
+ }
+ break;
+
+ case "4":
+ if (isset($post['a'])&& $post['a']==533374){
+ $this->sendTroops($post);
+ }else{
+ $post = $this->loadUnits($post);
+ return $post;
+ }
+
+ case "5":
+ if (isset($post['a'])&& $post['a']== "new"){
+ $this->Settlers($post);
+ }else{
+ $post = $this->loadUnits($post);
+ return $post;
+ }
+ break;
+ }
+ }
+ }
+ private function loadUnits($post) {
+ global $database,$village,$session,$generator,$logging,$form;
+ // Busqueda por nombre de pueblo
+ // Confirmamos y buscamos las coordenadas por nombre de pueblo
+ if($post['x']!="" && $post['y']!=""){
+ $oid = $database->getVilWref($post['x'],$post['y']);
+ }else if($post['dname']!=""){
+ $oid = $database->getVillageByName(stripslashes($post['dname']));
+ }
+ if($database->isVillageOases($oid) != 0){
+ $too = $database->getOasisField($oid,"conqured");
+ if($too['conqured'] == 0){$disabledr ="disabled=disabled"; $disabled ="disabled=disabled";}else{
+ $disabledr ="";
+ if($session->sit == 0){
+ $disabled ="";
+ }else{
+ $disabled ="disabled=disabled";
+ }
+ }
+ }else{
+ $disabledr ="";
+ if($session->sit == 0){
+ $disabled ="";
+ }else{
+ $disabled ="disabled=disabled";
+ }
+ }
+ if($disabledr != "" && $post['c'] == 2){
+ $form->addError("error","You can't reinforce this village/oasis");
+ }
+ if($disabled != "" && $post['c'] == 3){
+ $form->addError("error","You can't attack this village/oasis with normal attack");
+ }
+ if( !$post['t1'] && !$post['t2'] && !$post['t3'] && !$post['t4'] && !$post['t5'] &&
+ !$post['t6'] && !$post['t7'] && !$post['t8'] && !$post['t9'] && !$post['t10'] && !$post['t11']){
+ $form->addError("error","You need to mark min. one troop");
+ }
+
+ if(!$post['dname'] && !$post['x'] && !$post['y']){
+ $form->addError("error","Insert name or coordinates");
+ }
+
+ if(isset($post['dname']) && $post['dname'] != "") {
+ $id = $database->getVillageByName(stripslashes($post['dname']));
+ if (!isset($id)){
+ $form->addError("error","Village do not exist");
+ }else{
+ $coor = $database->getCoor($id);
+ }
+ }
+ // Busqueda por coordenadas de pueblo
+ // Confirmamos y buscamos las coordenadas por coordenadas de pueblo
+ if(isset($post['x']) && isset($post['y']) && $post['x'] != "" && $post['y'] != "") {
+ $coor = array('x'=>$post['x'], 'y'=>$post['y']);
+ $id = $generator->getBaseID($coor['x'],$coor['y']);
+ if (!$database->getVillageState($id)){
+ $form->addError("error","Coordinates do not exist");
+ }
+ if ($session->tribe == 1){$Gtribe = "";}elseif ($session->tribe == 2){$Gtribe = "1";}elseif ($session->tribe == 3){$Gtribe = "2";}elseif ($session->tribe == 4){$Gtribe = "3";}elseif ($session->tribe == 5){$Gtribe = "4";}
+ for($i=1; $i<11; $i++)
+ {
+ if(isset($post['t'.$i]))
+ {
+
+ if ($post['t'.$i] > $village->unitarray['u'.$Gtribe.$i])
+ {
+ $form->addError("error","You can't send more units than you have");
+ break;
+ }
+
+ if($post['t'.$i]<0)
+ {
+ $form->addError("error","You can't send negative units.");
+ break;
+ }
+
+ }
+ }
+ if ($post['t11'] > $village->unitarray['hero'])
+ {
+ $form->addError("error","You can't send more units than you have");
+ break;
+ }
+
+ if($post['t11']<0)
+ {
+ $form->addError("error","You can't send negative units.");
+ break;
+ }
+ }
+ if ($database->isVillageOases($id) == 0) {
+ if($database->hasBeginnerProtection($id)==1) {
+ $form->addError("error","Player is under beginners protection. You can't attack him");
+ }
+
+ //check if banned/admin:
+ $villageOwner = $database->getVillageField($id,'owner');
+ $userAccess = $database->getUserField($villageOwner,'access',0);
+ if($userAccess == '0' or $userAccess == '8' or $userAccess == '9'){
+ $form->addError("error","Player is Banned. You can't attack him");
+ //break;
+ }
+
+ //check if attacking same village that units are in
+ if($id == $village->wid){
+ $form->addError("error","You cant attack same village you are sending from.");
+ //break;
+ }
+ // Procesamos el array con los errores dados en el formulario
+ if($form->returnErrors() > 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $_POST;
+ header("Location: a2b.php");
+ }else{
+ // Debemos devolver un array con $post, que contiene todos los datos mas
+ // otra variable que definira que el flag esta levantado y se va a enviar y el tipo de envio
+ $villageName = $database->getVillageField($id,'name');
+ $speed= 300;
+ $timetaken = $generator->procDistanceTime($coor,$village->coor,INCREASE_SPEED,1);
+ array_push($post, "$id", "$villageName", "$villageOwner","$timetaken");
+ return $post;
+
+ }
+ }else{
+
+ if($form->returnErrors() > 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $_POST;
+ header("Location: a2b.php");
+ }else{
+
+ $villageName = $database->getOasisField($oid,"name");
+ $speed= 300;
+ $timetaken = $generator->procDistanceTime($coor,$village->coor,INCREASE_SPEED,1);
+ array_push($post, "$id", "$villageName", "2","$timetaken");
+ return $post;
+
+ }
+ }
+
+ }
+ private function sendTroops($post) {
+ global $form, $database, $village, $generator, $session;
+
+ $data = $database->getA2b($post['timestamp_checksum'], $post['timestamp']);
+
+
+
+ $Gtribe = "";
+ if ($session->tribe == '2'){ $Gtribe = "1"; } else if ($session->tribe == '3'){ $Gtribe = "2"; }else if ($session->tribe == '4'){ $Gtribe = "3"; }else if ($session->tribe == '5'){ $Gtribe = "4"; }
+ for($i=1; $i<10; $i++){
+ if(isset($data['u'.$i])){
+
+ if ($data['u'.$i] > $village->unitarray['u'.$Gtribe.$i])
+ {
+ $form->addError("error","You can't send more units than you have");
+ break;
+ }
+
+ if($data['u'.$i]<0)
+ {
+ $form->addError("error","You can't send negative units.");
+ break;
+ }
+
+ }
+ }
+ if ($data['u11'] > $village->unitarray['hero'])
+ {
+ $form->addError("error","You can't send more units than you have");
+ break;
+ }
+
+ if($data['u11']<0)
+ {
+ $form->addError("error","You can't send negative units.");
+ break;
+ }
+ if($form->returnErrors() > 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $_POST;
+ header("Location: a2b.php");
+ } else {
+
+if($session->access != BANNED){
+
+ if($session->tribe == 1){ $u = ""; } elseif($session->tribe == 2){ $u = "1"; } elseif($session->tribe == 3){ $u = "2"; }elseif($session->tribe == 4){ $u = "3"; }else {$u = "4"; }
+
+
+ $database->modifyUnit(
+ $village->wid,
+ array($u."1",$u."2",$u."3",$u."4",$u."5",$u."6",$u."7",$u."8",$u."9",$u.$session->tribe."0","hero"),
+ array($data['u1'],$data['u2'],$data['u3'],$data['u4'],$data['u5'],$data['u6'],$data['u7'],$data['u8'],$data['u9'],$data['u10'],$data['u11']),
+ array(0,0,0,0,0,0,0,0,0,0,0)
+ );
+
+ $query1 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = ' . mysql_escape_string($data['to_vid']));
+ $data1 = mysql_fetch_assoc($query1);
+ $query2 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $data1['owner']);
+ $data2 = mysql_fetch_assoc($query2);
+ $query11 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = ' . mysql_escape_string($village->wid));
+ $data11 = mysql_fetch_assoc($query11);
+ $query21 = mysql_query('SELECT * FROM `' . TB_PREFIX . 'users` WHERE `id` = ' . $data11['owner']);
+ $data21 = mysql_fetch_assoc($query21);
+
+
+
+ $eigen = $database->getCoor($village->wid);
+ $from = array('x'=>$eigen['x'], 'y'=>$eigen['y']);
+ $ander = $database->getCoor($data['to_vid']);
+ $to = array('x'=>$ander['x'], 'y'=>$ander['y']);
+ $start = ($data21['tribe']-1)*10+1;
+ $end = ($data21['tribe']*10);
+
+ $speeds = array();
+ $scout = 1;
+
+ //find slowest unit.
+ for($i=1;$i<=10;$i++){
+ if (isset($data['u'.$i])){
+ if($data['u'.$i] != '' && $data['u'.$i] > 0){
+ if($unitarray) { reset($unitarray); }
+ $unitarray = $GLOBALS["u".(($session->tribe-1)*10+$i)];
+ $speeds[] = $unitarray['speed'];
+ }
+ }
+ }
+ if (isset($data['u11'])) {
+ if($data['u11'] != '' && $data['u11'] > 0){
+ $heroarray = $database->getHero($session->uid);
+ $herodata = $GLOBALS["u".$heroarray[0]['unit']];
+ $speeds[] = $herodata['speed'];
+ }
+ }
+ $artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,2,3,0));
+ $artefact1 = count($database->getOwnUniqueArtefactInfo2($village->wid,2,1,1));
+ $artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,2,2,0));
+ if($artefact > 0){
+ $fastertroops = 3;
+ }else if($artefact1 > 0){
+ $fastertroops = 2;
+ }else if($artefact2 > 0){
+ $fastertroops = 1.5;
+ }else{
+ $fastertroops = 1;
+ }
+ $time = round($generator->procDistanceTime($from,$to,min($speeds),1)/$fastertroops);
+ $foolartefact = $database->getFoolArtefactInfo(2,$village->wid,$session->uid);
+ if(count($foolartefact) > 0){
+ foreach($foolartefact as $arte){
+ if($arte['bad_effect'] == 1){
+ $time *= $arte['effect2'];
+ }else{
+ $time /= $arte['effect2'];
+ $time = round($time);
+ }
+ }
+ }
+ $to_owner = $database->getVillageField($data['to_vid'],"owner");
+ $artefact_2 = count($database->getOwnUniqueArtefactInfo2($to_owner,7,3,0));
+ $artefact1_2 = count($database->getOwnUniqueArtefactInfo2($data['to_vid'],7,1,1));
+ $artefact2_2 = count($database->getOwnUniqueArtefactInfo2($to_owner,7,2,0));
+ $foolartefact2 = $database->getFoolArtefactInfo(7,$data['to_vid'],$to_owner);
+ $good_artefact = 0;
+ if(count($foolartefact2) > 0){
+ foreach($foolartefact2 as $arte){
+ if($arte['bad_effect'] == 0){
+ $good_artefact = 1;
+ }
+ }
+ }
+ if (isset($post['ctar1'])){if($artefact_2 > 0 or $artefact1_2 > 0 or $artefact2_2 > 0 or $good_artefact == 1){$post['ctar1'] = 99;}else{$post['ctar1'] = $post['ctar1'];}}else{ $post['ctar1'] = 0;}
+ if (isset($post['ctar2'])){if($artefact_2 > 0 or $artefact1_2 > 0 or $artefact2_2 > 0 or $good_artefact == 1){$post['ctar2'] = 99;}else{$post['ctar2'] = $post['ctar2'];}}else{ $post['ctar2'] = 0;}
+ if (isset($post['spy'])){$post['spy'] = $post['spy'];}else{ $post['spy'] = 0;}
+ $abdata = $database->getABTech($village->wid);
+ $reference = $database->addAttack(($village->wid),$data['u1'],$data['u2'],$data['u3'],$data['u4'],$data['u5'],$data['u6'],$data['u7'],$data['u8'],$data['u9'],$data['u10'],$data['u11'],$data['type'],$post['ctar1'],$post['ctar2'],$post['spy'],$abdata['b1'],$abdata['b2'],$abdata['b3'],$abdata['b4'],$abdata['b5'],$abdata['b6'],$abdata['b7'],$abdata['b8']);
+ $checkexist = $database->checkVilExist($data['to_vid']);
+ $checkoexist = $database->checkOasisExist($data['to_vid']);
+ if($checkexist or $checkoexist){
+ $database->addMovement(3,$village->wid,$data['to_vid'],$reference,time(),($time+time()));
+ }
+
+ if($form->returnErrors() > 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $_POST;
+ header("Location: a2b.php");
+ }
+ header("Location: build.php?id=39");
+
+}else{
+header("Location: banned.php");
+}
+ }}
+
+ private function sendTroopsBack($post) {
+ global $form, $database, $village, $generator, $session, $technology;
+if($session->access != BANNED){
+ $enforce=$database->getEnforceArray($post['ckey'],0);
+ if(($enforce['from']==$village->wid) || ($enforce['vref']==$village->wid)){
+ $to = $database->getVillage($enforce['from']);
+ $Gtribe = "";
+ if ($database->getUserField($to['owner'],'tribe',0) == '2'){ $Gtribe = "1"; } else if ($database->getUserField($to['owner'],'tribe',0) == '3'){ $Gtribe = "2"; } else if ($database->getUserField($to['owner'],'tribe',0) == '4'){ $Gtribe = "3"; }else if ($database->getUserField($to['owner'],'tribe',0) == '5'){ $Gtribe = "4"; }
+
+ for($i=1; $i<10; $i++){
+ if(isset($post['t'.$i])){
+ if($i!=10){
+ if ($post['t'.$i] > $enforce['u'.$Gtribe.$i])
+ {
+ $form->addError("error","You can't send more units than you have");
+ break;
+ }
+
+ if($post['t'.$i]<0)
+ {
+ $form->addError("error","You can't send negative units.");
+ break;
+ }
+ }
+ } else {
+ $post['t'.$i.'']='0';
+ }
+ }
+ if(isset($post['t11'])){
+ if ($post['t11'] > $enforce['hero'])
+ {
+ $form->addError("error","You can't send more units than you have");
+ break;
+ }
+
+ if($post['t11']<0)
+ {
+ $form->addError("error","You can't send negative units.");
+ break;
+ }
+ } else {
+ $post['t11']='0';
+ }
+
+ if($form->returnErrors() > 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $_POST;
+ header("Location: a2b.php");
+ } else {
+
+ //change units
+ $start = ($database->getUserField($to['owner'],'tribe',0)-1)*10+1;
+ $end = ($database->getUserField($to['owner'],'tribe',0)*10);
+
+ $j='1';
+ for($i=$start;$i<=$end;$i++){
+ $database->modifyEnforce($post['ckey'],$i,$post['t'.$j.''],0); $j++;
+ }
+ $database->modifyEnforce($post['ckey'],'hero',$post['t11'],0); $j++;
+ //get cord
+ $from = $database->getVillage($enforce['from']);
+ $fromcoor = $database->getCoor($enforce['from']);
+ $tocoor = $database->getCoor($enforce['vref']);
+ $fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']);
+ $toCor = array('x'=>$fromcoor['x'], 'y'=>$fromcoor['y']);
+
+ $speeds = array();
+
+ //find slowest unit.
+ for($i=1;$i<=10;$i++){
+ if (isset($post['t'.$i])){
+ if( $post['t'.$i] != '' && $post['t'.$i] > 0){
+ if($unitarray) { reset($unitarray); }
+ $unitarray = $GLOBALS["u".(($session->tribe-1)*10+$i)];
+ $speeds[] = $unitarray['speed'];
+ } else {
+ $post['t'.$i.'']='0';
+ }
+ } else {
+ $post['t'.$i.'']='0';
+ }
+ }
+ if (isset($post['t11'])){
+ if( $post['t11'] != '' && $post['t11'] > 0){
+ $qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner']."";
+ $resulth = mysql_query($qh);
+ $hero_f=mysql_fetch_array($resulth);
+ $hero_unit=$hero_f['unit'];
+ $speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
+ } else {
+ $post['t11']='0';
+ }
+ } else {
+ $post['t11']='0';
+ }
+ $artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,2,3,0));
+ $artefact1 = count($database->getOwnUniqueArtefactInfo2($village->wid,2,1,1));
+ $artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,2,2,0));
+ if($artefact > 0){
+ $fastertroops = 3;
+ }else if($artefact1 > 0){
+ $fastertroops = 2;
+ }else if($artefact2 > 0){
+ $fastertroops = 1.5;
+ }else{
+ $fastertroops = 1;
+ }
+ $time = round($generator->procDistanceTime($fromCor,$toCor,min($speeds),1)/$fastertroops);
+ $foolartefact2 = $database->getFoolArtefactInfo(2,$village->wid,$session->uid);
+ if(count($foolartefact2) > 0){
+ foreach($foolartefact2 as $arte){
+ if($arte['bad_effect'] == 1){
+ $time *= $arte['effect2'];
+ }else{
+ $time /= $arte['effect2'];
+ $time = round($time);
+ }
+ }
+ }
+ $reference = $database->addAttack($enforce['from'],$post['t1'],$post['t2'],$post['t3'],$post['t4'],$post['t5'],$post['t6'],$post['t7'],$post['t8'],$post['t9'],$post['t10'],$post['t11'],2,0,0,0,0);
+ $database->addMovement(4,$village->wid,$enforce['from'],$reference,time(),($time+time()));
+ $technology->checkReinf($post['ckey']);
+
+ header("Location: build.php?id=39");
+
+ }
+ } else {
+ $form->addError("error","You cant change someones troops.");
+ if($form->returnErrors() > 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $_POST;
+ header("Location: a2b.php");
+ }
+ }
+}else{
+header("Location: banned.php");
+}
+ }
+
+ public function Settlers($post) {
+ global $form, $database, $village, $session;
+ if($session->access != BANNED){
+ $mode = CP;
+ $total = count($database->getProfileVillages($session->uid));
+ $need_cps = ${'cp'.$mode}[$total+1];
+ $cps = $session->cp;
+ $rallypoint = $database->getResourceLevel($village->wid);
+ if($rallypoint['f39'] > 0){
+ if($cps >= $need_cps) {
+ $unit = ($session->tribe*10);
+ $database->modifyResource($village->wid,750,750,750,750,0);
+ $database->modifyUnit($village->wid,array($unit),array(3),array(0));
+ $database->addMovement(5,$village->wid,$post['s'],0,time(),time()+$post['timestamp']);
+ header("Location: build.php?id=39");
+
+ if($form->returnErrors() > 0) {
+ $_SESSION['errorarray'] = $form->getErrors();
+ $_SESSION['valuearray'] = $_POST;
+ header("Location: a2b.php");
+ }
+ } else {
+ header("Location: build.php?id=39");
+ }
+ }else{
+ header("Location: dorf1.php");
+ }
+ }else{
+ header("Location: banned.php");
+ }
+ }
+
+ public function Hero($uid) {
+ global $database;
+ $heroarray = $database->getHero($uid);
+ $herodata = $GLOBALS["h".$heroarray[0]['unit']];
+
+ $h_atk = $herodata['atk'] + 5 * floor($heroarray[0]['attack'] * $herodata['atkp'] / 5);
+ $h_di = $herodata['di'] + 5 * floor($heroarray[0]['defence'] * $herodata['dip'] / 5);
+ $h_dc = $herodata['dc'] + 5 * floor($heroarray[0]['defence'] * $herodata['dcp'] / 5);
+ $h_ob = 1 + 0.002 * $heroarray[0]['attackbonus'];
+ $h_db = 1 + 0.002 * $heroarray[0]['defencebonus'];
+
+ return array('heroid'=>$heroarray[0]['heroid'],'unit'=>$heroarray[0]['unit'],'atk'=>$h_atk,'di'=>$h_di,'dc'=>$h_dc,'ob'=>$h_ob,'db'=>$h_db,'health'=>$heroarray[0]['health']);
+ }
+};
+
+$units = new Units;
+
+?>
diff --git a/GameEngine/Village.php b/GameEngine/Village.php
new file mode 100644
index 00000000..560b93b9
--- /dev/null
+++ b/GameEngine/Village.php
@@ -0,0 +1,295 @@
+wid = $_SESSION['wid'];
+ }
+ else {
+ $this->wid = $session->villages[0];
+ }
+ $this->LoadTown();
+ $this->calculateProduction();
+ $this->processProduction();
+ $this->ActionControl();
+ }
+
+ public function getProd($type) {
+ return $this->production[$type];
+ }
+
+ public function getAllUnits($vid) {
+ global $database,$technology;
+ return $technology->getUnits($database->getUnit($vid),$database->getEnforceVillage($vid,0));
+ }
+
+ private function LoadTown() {
+ global $database,$session,$logging,$technology;
+ $this->infoarray = $database->getVillage($this->wid);
+ if($this->infoarray['owner'] != $session->uid && !$session->isAdmin) {
+ unset($_SESSION['wid']);
+ $logging->addIllegal($session->uid,$this->wid,1);
+ $this->wid = $session->villages[0];
+ $this->infoarray = $database->getVillage($this->wid);
+ }
+ $this->resarray = $database->getResourceLevel($this->wid);
+ $this->coor = $database->getCoor($this->wid);
+ $this->type = $database->getVillageType($this->wid);
+ $this->oasisowned = $database->getOasis($this->wid);
+ $this->ocounter = $this->sortOasis();
+ $this->unitarray = $database->getUnit($this->wid);
+ $this->enforcetome = $database->getEnforceVillage($this->wid,0);
+ $this->enforcetoyou = $database->getEnforceVillage($this->wid,1);
+ $this->unitall = $technology->getAllUnits($this->wid);
+ $this->techarray = $database->getTech($this->wid);
+ $this->abarray = $database->getABTech($this->wid);
+ $this->researching = $database->getResearching($this->wid);
+
+ $this->capital = $this->infoarray['capital'];
+ $this->natar = $this->infoarray['natar'];
+ $this->currentcel = $this->infoarray['celebration'];
+ $this->wid = $this->infoarray['wref'];
+ $this->vname = $this->infoarray['name'];
+ $this->awood = $this->infoarray['wood'];
+ $this->aclay = $this->infoarray['clay'];
+ $this->airon = $this->infoarray['iron'];
+ $this->acrop = $this->infoarray['crop'];
+ $this->pop = $this->infoarray['pop'];
+ $this->maxstore = $this->infoarray['maxstore'];
+ $this->maxcrop = $this->infoarray['maxcrop'];
+ $this->allcrop = $this->getCropProd();
+ $this->loyalty = $this->infoarray['loyalty'];
+ $this->master = count($database->getMasterJobs($this->wid));
+ //de gs in town, zetten op max pakhuisinhoud
+ if($this->awood>$this->maxstore){ $this->awood=$this->maxstore; $database->updateResource($this->wid,'wood',$this->maxstore); }
+ if($this->aclay>$this->maxstore){ $this->aclay=$this->maxstore; $database->updateResource($this->wid,'clay',$this->maxstore); }
+ if($this->airon>$this->maxstore){ $this->airon=$this->maxstore; $database->updateResource($this->wid,'iron',$this->maxstore); }
+ if($this->acrop>$this->maxcrop){ $this->acrop=$this->maxcrop; $database->updateResource($this->wid,'crop',$this->maxcrop); }
+
+ }
+
+ private function calculateProduction() {
+ global $technology,$database,$session;
+ $normalA = $database->getOwnArtefactInfoByType($_SESSION['wid'],4);
+ $largeA = $database->getOwnUniqueArtefactInfo($session->uid,4,2);
+ $uniqueA = $database->getOwnUniqueArtefactInfo($session->uid,4,3);
+ $upkeep = $technology->getUpkeep($this->unitall,0,$this->wid);
+ $this->production['wood'] = $this->getWoodProd();
+ $this->production['clay'] = $this->getClayProd();
+ $this->production['iron'] = $this->getIronProd();
+ if ($uniqueA['size']==3 && $uniqueA['owner']==$session->uid){
+ $this->production['crop'] = $this->getCropProd()-$this->pop-(($upkeep)-round($upkeep*0.50));
+
+ }else if ($normalA['type']==4 && $normalA['size']==1 && $normalA['owner']==$session->uid){
+ $this->production['crop'] = $this->getCropProd()-$this->pop-(($upkeep)-round($upkeep*0.25));
+
+ }else if ($largeA['size']==2 && $largeA['owner']==$session->uid){
+ $this->production['crop'] = $this->getCropProd()-$this->pop-(($upkeep)-round($upkeep*0.25));
+
+ }else{
+ $this->production['crop'] = $this->getCropProd()-$this->pop-$upkeep;
+ }
+ }
+
+
+ private function processProduction() {
+ global $database;
+ $timepast = time() - $this->infoarray['lastupdate'];
+ $nwood = ($this->production['wood'] / 3600) * $timepast;
+ $nclay = ($this->production['clay'] / 3600) * $timepast;
+ $niron = ($this->production['iron'] / 3600) * $timepast;
+ $ncrop = ($this->production['crop'] / 3600) * $timepast;
+
+ $database->modifyResource($this->wid,$nwood,$nclay,$niron,$ncrop,1);
+ $database->updateVillage($this->wid);
+ $this->LoadTown();
+ }
+
+ private function getWoodProd() {
+ global $bid1,$bid5,$session;
+ $basewood = $sawmill = 0;
+ $woodholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($this->resarray['f'.$i.'t'] == 1) {
+ array_push($woodholder,'f'.$i);
+ }
+ if($this->resarray['f'.$i.'t'] == 5) {
+ $sawmill = $this->resarray['f'.$i];
+ }
+ }
+ for($i=0;$i<=count($woodholder)-1;$i++) { $basewood+= $bid1[$this->resarray[$woodholder[$i]]]['prod']; }
+ $wood = $basewood + $basewood * 0.25 * $this->ocounter[0];
+ if($sawmill >= 1) {
+ $wood += $basewood / 100 * $bid5[$sawmill]['attri'];
+ }
+ if($session->bonus1 == 1) {
+ $wood *= 1.25;
+ }
+ $wood *= SPEED;
+ return round($wood);
+ }
+
+ private function getClayProd() {
+ global $bid2,$bid6,$session;
+ $baseclay = $clay = $brick = 0;
+ $clayholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($this->resarray['f'.$i.'t'] == 2) {
+ array_push($clayholder,'f'.$i);
+ }
+ if($this->resarray['f'.$i.'t'] == 6) {
+ $brick = $this->resarray['f'.$i];
+ }
+ }
+ for($i=0;$i<=count($clayholder)-1;$i++) { $baseclay+= $bid2[$this->resarray[$clayholder[$i]]]['prod']; }
+ $clay = $baseclay + $baseclay * 0.25 * $this->ocounter[1];
+ if($brick >= 1) {
+ $clay += $baseclay / 100 * $bid6[$brick]['attri'];
+ }
+ if($session->bonus2 == 1) {
+ $clay *= 1.25;
+ }
+ $clay *= SPEED;
+ return round($clay);
+ }
+
+ private function getIronProd() {
+ global $bid3,$bid7,$session;
+ $baseiron = $foundry = 0;
+ $ironholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($this->resarray['f'.$i.'t'] == 3) {
+ array_push($ironholder,'f'.$i);
+ }
+ if($this->resarray['f'.$i.'t'] == 7) {
+ $foundry = $this->resarray['f'.$i];
+ }
+ }
+ for($i=0;$i<=count($ironholder)-1;$i++) { $baseiron+= $bid3[$this->resarray[$ironholder[$i]]]['prod']; }
+ $iron = $baseiron + $baseiron * 0.25 * $this->ocounter[2];
+ if($foundry >= 1) {
+ $iron += $baseiron / 100 * $bid7[$foundry]['attri'];
+ }
+ if($session->bonus3 == 1) {
+ $iron *= 1.25;
+ }
+ $iron *= SPEED;
+ return round($iron);
+ }
+
+ private function getCropProd() {
+ global $bid4,$bid8,$bid9,$session;
+ $basecrop = $grainmill = $bakery = 0;
+ $cropholder = array();
+ for($i=1;$i<=38;$i++) {
+ if($this->resarray['f'.$i.'t'] == 4) {
+ array_push($cropholder,'f'.$i);
+ }
+ if($this->resarray['f'.$i.'t'] == 8) {
+ $grainmill = $this->resarray['f'.$i];
+ }
+ if($this->resarray['f'.$i.'t'] == 9) {
+ $bakery = $this->resarray['f'.$i];
+ }
+ }
+ for($i=0;$i<=count($cropholder)-1;$i++) { $basecrop+= $bid4[$this->resarray[$cropholder[$i]]]['prod']; }
+ $crop = $basecrop + $basecrop * 0.25 * $this->ocounter[3];
+ if($grainmill >= 1 || $bakery >= 1) {
+ $crop += $basecrop /100 * ($bid8[$grainmill]['attri'] + $bid9[$bakery]['attri']);
+ }
+ if($session->bonus4 == 1) {
+ $crop *= 1.25;
+ }
+ $crop *= SPEED;
+ return round($crop);
+ }
+
+ private function sortOasis() {
+ $crop = $clay = $wood = $iron = 0;
+ if (!empty($this->oasisowned)) {
+ foreach ($this->oasisowned as $oasis) {
+ switch($oasis['type']) {
+ case 1:
+ case 2:
+ $wood += 1;
+ break;
+ case 3:
+ $wood += 1;
+ $crop += 1;
+ break;
+ case 4:
+ case 5:
+ $clay += 1;
+ break;
+ case 6:
+ $clay += 1;
+ $crop += 1;
+ break;
+ case 7:
+ case 8:
+ $iron += 1;
+ break;
+ case 9:
+ $iron += 1;
+ $crop += 1;
+ break;
+ case 10:
+ case 11:
+ $crop += 1;
+ break;
+ case 12:
+ $crop += 2;
+ break;
+ }
+ }
+ }
+ return array($wood,$clay,$iron,$crop);
+ }
+
+ private function ActionControl() {
+ global $session;
+ if(SERVER_WEB_ROOT) {
+ $page = $_SERVER['SCRIPT_NAME'];
+ }
+ else {
+ $explode = explode("/",$_SERVER['SCRIPT_NAME']);
+ $i = count($explode)-1;
+ $page = $explode[$i];
+ }
+ if($page == "build.php" && $session->uid != $this->infoarray['owner']) {
+ unset($_SESSION['wid']);
+ header("Location: dorf1.php");
+ }
+ }
+
+};
+$village = new Village;
+$building = new Building;
+
+?>
\ No newline at end of file
diff --git a/GameEngine/favicon.ico b/GameEngine/favicon.ico
new file mode 100644
index 00000000..f8529348
Binary files /dev/null and b/GameEngine/favicon.ico differ
diff --git a/GameEngine/functions.php b/GameEngine/functions.php
new file mode 100644
index 00000000..bd991e03
--- /dev/null
+++ b/GameEngine/functions.php
@@ -0,0 +1,37 @@
+ $repl)
+ {
+ $text = str_replace($sub, $repl, $text);
+ }
+
+ ob_start();
+ eval("?>".$text);
+ $text = ob_get_contents();
+ ob_end_clean();
+ return $text;
+}
+
+?>
\ No newline at end of file
diff --git a/README b/README
new file mode 100644
index 00000000..f2c4f8f2
--- /dev/null
+++ b/README
@@ -0,0 +1,5 @@
+TravianZ is based on TravianX v6.0.0 with some grapich changes from ZravianX.
+I will try to make the best from this version and I will add every fix that I will found to it.
+If you found fix to somthing please give it to me.
+
+* find 'magic_quotes_gpc = Off' and replace with 'magic_quotes_gpc = On' for better options with special characters (you need to restart your appache and mysql for make this change affective)
\ No newline at end of file
diff --git a/Security/Security.class.php b/Security/Security.class.php
new file mode 100644
index 00000000..9e7e6141
--- /dev/null
+++ b/Security/Security.class.php
@@ -0,0 +1,264 @@
+ |
+// +----------------------------------------------------------------------+
+
+// Source Code Highlight
+/* Security Fix; Only dev
+if(isset($_GET['show_source']))
+{
+ highlight_file(__FILE__);
+ exit;
+}
+*/
+
+/**
+ * Provides static functions to help protect against cross site scripting
+ * attacks and helps clean up the php environment upon initializing.
+ *
+ * Based upon Security library by http://kohanaphp.com/
+ *
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+define('PCRE_UNICODE_PROPERTIES', (bool) preg_match('/^\pL$/u', '?'));
+
+class Security
+{
+ // Instance of the security class.
+ protected static $instance;
+ protected $magic_quotes_gpc = FALSE;
+
+ /**
+ * Gets the instance of the Security class.
+ *
+ * @return object Instance of Security
+ */
+ public static function instance()
+ {
+ if(self::$instance === NULL)
+ {
+ //return new Security;
+ }
+
+ //return self::$instance;
+ }
+
+
+ /**
+ * Constructor. Sanitizes global data GET, POST and COOKIE data.
+ * Also makes sure those pesty magic quotes and register globals
+ * don't bother us. This is protected because it really only needs
+ * to be run once.
+ *
+ * @return void
+ */
+ protected function __construct()
+ {
+ if(self::$instance === NULL)
+ {
+ // Check for magic quotes
+ if(get_magic_quotes_runtime())
+ {
+ // Dear lord!! This is bad and deprected. Sort it out ;)
+ set_magic_quotes_runtime(0);
+ }
+
+ if(get_magic_quotes_gpc())
+ {
+ // This is also bad and deprected. See http://php.net/magic_quotes for more information.
+ $this->magic_quotes_gpc = TRUE;
+ }
+
+ // Check for register globals and prevent security issues from arising.
+ if(ini_get('register_globals'))
+ {
+ if(isset($_REQUEST['GLOBALS']))
+ {
+ // No no no.. just kill the script here and now
+ exit('Illegal attack on global variable.');
+ }
+
+ // Get rid of REQUEST
+ $_REQUEST = array();
+
+ // The following globals are standard and shouldn't really be removed
+ $preserve = array('GLOBALS', '_REQUEST', '_GET', '_POST', '_FILES', '_COOKIE', '_SERVER', '_ENV', '_SESSION');
+
+ // Same effect as disabling register_globals
+ foreach($GLOBALS as $key => $value)
+ {
+ if( ! in_array($key, $preserve))
+ {
+ global $$key;
+ $$key = NULL;
+
+ unset($GLOBALS[$key], $$key);
+ }
+ }
+ }
+
+ // Sanitize global data
+
+ if(is_array($_POST))
+ {
+ foreach($_POST as $key => $value)
+ {
+ $_POST[$this->clean_input_keys($key)] = $this->clean_input_data($value);
+ }
+ }
+ else
+ {
+ $_POST = array();
+ }
+
+ if(is_array($_GET))
+ {
+ foreach($_GET as $key => $value)
+ {
+ $_GET[$this->clean_input_keys($key)] = $this->clean_input_data($value);
+ }
+ }
+ else
+ {
+ $_GET = array();
+ }
+
+ if(is_array($_COOKIE))
+ {
+ foreach($_COOKIE as $key => $value)
+ {
+ $_COOKIE[$this->clean_input_keys($key)] = $this->clean_input_data($value);
+ }
+ }
+ else
+ {
+ $_COOKIE = array();
+ }
+
+ // Just make REQUEST a merge of POST and GET. Who really wants cookies in it anyway?
+ $_REQUEST = array_merge($_GET, $_POST);
+
+
+ self::$instance = $this;
+ }
+ }
+
+ /**
+ * Cross site filtering (XSS). Recursive.
+ *
+ * @param string Data to be cleaned
+ * @return mixed
+ */
+ public function xss_clean($data)
+ {
+ // If its empty there is no point cleaning it :\
+ if(empty($data))
+ return $data;
+
+ // Recursive loop for arrays
+ if(is_array($data))
+ {
+ foreach($data as $key => $value)
+ {
+ $data[$key] = $this->xss_clean($data);
+ }
+
+ return $data;
+ }
+
+ // Fix &entity\n;
+ $data = str_replace(array('&','<','>'), array('&','<','>'), $data);
+ $data = preg_replace('/(*\w+)[\x00-\x20]+;/u', '$1;', $data);
+ $data = preg_replace('/(*[0-9A-F]+);*/iu', '$1;', $data);
+ $data = html_entity_decode($data, ENT_COMPAT, 'UTF-8');
+
+ // Remove any attribute starting with "on" or xmlns
+ $data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $data);
+
+ // Remove javascript: and vbscript: protocols
+ $data = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2nojavascript...', $data);
+ $data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2novbscript...', $data);
+ $data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u', '$1=$2nomozbinding...', $data);
+
+ // Only works in IE:
+ $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
+ $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
+ $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#iu', '$1>', $data);
+
+ // Remove namespaced elements (we do not need them)
+ $data = preg_replace('#*\w+:\w[^>]*+>#i', '', $data);
+
+ do
+ {
+ // Remove really unwanted tags
+ $old_data = $data;
+ $data = preg_replace('#*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i', '', $data);
+ }
+ while ($old_data !== $data);
+
+ return $data;
+ }
+
+ /**
+ * Enforces W3C specifications to prevent malicious exploitation.
+ *
+ * @param string Key to clean
+ * @return string
+ */
+ protected function clean_input_keys($data)
+ {
+ $chars = PCRE_UNICODE_PROPERTIES ? '\pL' : 'a-zA-Z';
+
+ if ( ! preg_match('#^[' . $chars . '0-9:_.-]++$#uD', $data))
+ {
+ exit('Illegal key characters in global data');
+ }
+
+ return $data;
+ }
+
+ /**
+ * Escapes data.
+ *
+ * @param mixed Data to clean
+ * @return mixed
+ */
+ protected function clean_input_data($data)
+ {
+ if(is_array($data))
+ {
+ $new_array = array();
+ foreach($data as $key => $value)
+ {
+ $new_array[$this->clean_input_keys($key)] = $this->clean_input_data($value);
+ }
+
+ return $new_array;
+ }
+
+ if($this->magic_quotes_gpc === TRUE)
+ {
+ // Get rid of those pesky magic quotes!
+ $data = stripslashes($data);
+ }
+
+ $data = $this->xss_clean($data);
+
+ return $data;
+ }
+}
+?>
\ No newline at end of file
diff --git a/Security/index.php b/Security/index.php
new file mode 100644
index 00000000..b5bb52b8
--- /dev/null
+++ b/Security/index.php
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/Templates/.htaccess b/Templates/.htaccess
new file mode 100644
index 00000000..85b65c30
--- /dev/null
+++ b/Templates/.htaccess
@@ -0,0 +1,4 @@
+
+Order allow,deny
+Deny from all
+
\ No newline at end of file
diff --git a/Templates/Ajax/.htaccess b/Templates/Ajax/.htaccess
new file mode 100644
index 00000000..85b65c30
--- /dev/null
+++ b/Templates/Ajax/.htaccess
@@ -0,0 +1,4 @@
+
+Order allow,deny
+Deny from all
+
\ No newline at end of file
diff --git a/Templates/Ajax/mapscroll.tpl b/Templates/Ajax/mapscroll.tpl
new file mode 100644
index 00000000..103bdb0c
--- /dev/null
+++ b/Templates/Ajax/mapscroll.tpl
@@ -0,0 +1,147 @@
+ WORLD_MAX)? $x-WORLD_MAX*2-1 : $x;
+$y = ($y < -WORLD_MAX)? $y+WORLD_MAX*2+1 : $y;
+$y = ($y > WORLD_MAX)? $y-WORLD_MAX*2-1 : $y;
+$xm3 = ($x-3) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-2 : $x-3;
+$xm2 = ($x-2) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-1 : $x-2;
+$xm1 = ($x-1) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX : $x-1;
+$xp1 = ($x+1) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX : $x+1;
+$xp2 = ($x+2) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+1 : $x+2;
+$xp3 = ($x+3) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+2: $x+3;
+$ym3 = ($y-3) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-2 : $y-3;
+$ym2 = ($y-2) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-1 : $y-2;
+$ym1 = ($y-1) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX : $y-1;
+$yp1 = ($y+1) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX : $y+1;
+$yp2 = ($y+2) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+1 : $y+2;
+$yp3 = ($y+3) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+2: $y+3;
+$xarray = array($xm3,$xm2,$xm1,$x,$xp1,$xp2,$xp3);
+$yarray = array($ym3,$ym2,$ym1,$y,$yp1,$yp2,$yp3);
+$maparray = array();
+$xcount = 0;
+
+$maparray = '';
+$maparray2 = '';
+for($i=0; $i<=6; $i++){
+ if($xcount != 7){
+ $maparray .= '\''.$generator->getBaseID($xarray[$xcount],$yarray[$i]).'\',';
+ $maparray2 .= $generator->getBaseID($xarray[$xcount],$yarray[$i]).',';
+ if($i==6){
+ $i = -1;
+ $xcount +=1;
+ }
+ }
+}
+header("Content-Type: application/json;");
+
+$maparray = (substr($maparray, 0, -1));
+
+$query2 = "SELECT
+ ".TB_PREFIX."wdata.id AS map_id,
+ ".TB_PREFIX."wdata.fieldtype AS map_fieldtype,
+ ".TB_PREFIX."wdata.oasistype AS map_oasis,
+ ".TB_PREFIX."wdata.x AS map_x,
+ ".TB_PREFIX."wdata.y AS map_y,
+ ".TB_PREFIX."wdata.occupied AS map_occupied,
+ ".TB_PREFIX."wdata.image AS map_image,
+
+ ".TB_PREFIX."odata.conqured AS oasis_conqured,
+ info_user_oasis.username AS oasis_user,
+ info_user_oasis.tribe AS oasis_tribe,
+ info_alliance_oasis.tag AS oasis_alli_name,
+
+ ".TB_PREFIX."vdata.wref AS ville_id,
+ ".TB_PREFIX."vdata.owner AS ville_user,
+ ".TB_PREFIX."vdata.name AS ville_name,
+ ".TB_PREFIX."vdata.capital AS ville_capital,
+ ".TB_PREFIX."vdata.pop AS ville_pop,
+
+ ".TB_PREFIX."users.id AS user_id,
+ ".TB_PREFIX."users.username AS user_username,
+ ".TB_PREFIX."users.tribe AS user_tribe,
+ ".TB_PREFIX."users.alliance AS user_alliance,
+
+ ".TB_PREFIX."alidata.id AS aliance_id,
+ ".TB_PREFIX."alidata.tag AS aliance_name
+
+ FROM ((((((".TB_PREFIX."wdata
+ LEFT JOIN ".TB_PREFIX."vdata ON ".TB_PREFIX."vdata.wref = ".TB_PREFIX."wdata.id )
+ LEFT JOIN ".TB_PREFIX."odata ON ".TB_PREFIX."odata.wref = ".TB_PREFIX."wdata.id )
+ LEFT JOIN ".TB_PREFIX."users AS info_user_oasis ON info_user_oasis.id = ".TB_PREFIX."odata.owner )
+ LEFT JOIN ".TB_PREFIX."alidata AS info_alliance_oasis ON info_alliance_oasis.id = info_user_oasis.alliance )
+ LEFT JOIN ".TB_PREFIX."users ON ".TB_PREFIX."users.id = ".TB_PREFIX."vdata.owner )
+ LEFT JOIN ".TB_PREFIX."alidata ON ".TB_PREFIX."alidata.id = ".TB_PREFIX."users.alliance )
+ where ".TB_PREFIX."wdata.id IN ($maparray)
+ ORDER BY FIND_IN_SET(".TB_PREFIX."wdata.id,'$maparray2')";
+
+$result2 = mysql_query($query2) or die(mysql_error());
+
+$i=0;
+//Load coor array
+$yrow = 0;
+
+$map_js ='';
+while ($donnees = mysql_fetch_assoc($result2)){
+
+$targetalliance=$donnees["aliance_id"];
+$friendarray=$database->getAllianceAlly($donnees["aliance_id"],1);
+$neutralarray=$database->getAllianceAlly($donnees["aliance_id"],2);
+$enemyarray=$database->getAllianceWar2($donnees["aliance_id"]);
+
+$friend = (($friendarray[0]['alli1']>0 and $friendarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($friendarray[0]['alli1']==$_SESSION['alliance_user'] or $friendarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0';
+
+$war = (($enemyarray[0]['alli1']>0 and $enemyarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($enemyarray[0]['alli1']==$_SESSION['alliance_user'] or $enemyarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0';
+
+$neutral = (($neutralarray[0]['alli1']>0 and $neutralarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($neutralarray[0]['alli1']==$_SESSION['alliance_user'] or $neutralarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0';
+
+
+$image = ($donnees['map_occupied'] == 1 && $donnees['map_fieldtype'] > 0)?(($donnees['ville_user'] == $_SESSION['id_user'])? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b30': 'b20' :'b10' : 'b00') : (($targetalliance != 0)? ($friend==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b31': 'b21' :'b11' : 'b01') : ($war==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b32': 'b22' :'b12' : 'b02') : ($neutral==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b35': 'b25' :'b15' : 'b05') : ($targetalliance == $_SESSION['alliance_user']? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b33': 'b23' :'b13' : 'b03') : ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b34': 'b24' :'b14' : 'b04'))))) : ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b34': 'b24' :'b14' : 'b04'))) : $donnees['map_image'];
+if($donnees['ville_user']==3 && $donnees['ville_name']=='WW Buildingplan'){
+$image = "o99";
+}
+ //Javascript map info
+ if($yrow!=7){
+ $map_js .= "[".$donnees['map_x'].",".$donnees['map_y'].",".$donnees['map_fieldtype'].",". ((!empty($donnees['map_oasis'])) ? $donnees['map_oasis'] : 0) .",\"d=".$donnees['map_id']."&c=".$generator->getMapCheck($donnees['map_id'])."\",\"".$image."\"";
+ if($donnees['map_occupied']){
+ if($donnees['map_fieldtype'] != 0){
+ $map_js.= ",\"".$donnees['ville_name']."\",\"".$donnees['user_username']."\",\"".$donnees['ville_pop']."\",\"".$donnees['aliance_name']."\",\"".$donnees['user_tribe']."\"]\n";
+ }
+ }
+ elseif($donnees['map_oasis'] != 0){
+ if ($donnees['oasis_conqured'] != 0){
+ $map_js.= ",\"\",\"".$donnees['oasis_user']."\",\"-\",\"".$donnees['oasis_alli_name']."\",\"".$donnees['oasis_tribe']."\"]";
+ }
+ else{
+ $map_js.="]";
+ }
+ }
+ else{$map_js .= "]";}
+
+ if($i == 6 && $yrow !=6){
+ $i = -1;
+ $yrow +=1;
+ $map_js .= "],[";
+ }
+ else {
+ if($yrow == 6 && $i == 6) {$map_js .= "]";}
+ else {$map_js .= ",";}
+ }
+ $regcount += 1;
+ }
+ else {$map_js .= "]";}
+ ++$i;
+}
+echo '[['.$map_js.']';
\ No newline at end of file
diff --git a/Templates/Ajax/mapscroll2.tpl b/Templates/Ajax/mapscroll2.tpl
new file mode 100644
index 00000000..b2645b89
--- /dev/null
+++ b/Templates/Ajax/mapscroll2.tpl
@@ -0,0 +1,164 @@
+ WORLD_MAX)? $x-WORLD_MAX*2-1 : $x;
+$y = ($y < -WORLD_MAX)? $y+WORLD_MAX*2+1 : $y;
+$y = ($y > WORLD_MAX)? $y-WORLD_MAX*2-1 : $y;
+$xm6 = ($x-6) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-5 : $x-6;
+$xm5 = ($x-5) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-4 : $x-5;
+$xm4 = ($x-4) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-3 : $x-4;
+$xm3 = ($x-3) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-2 : $x-3;
+$xm2 = ($x-2) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-1 : $x-2;
+$xm1 = ($x-1) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX : $x-1;
+$xp1 = ($x+1) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX : $x+1;
+$xp2 = ($x+2) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+1 : $x+2;
+$xp3 = ($x+3) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+2: $x+3;
+$xp4 = ($x+4) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+3 : $x+4;
+$xp5 = ($x+5) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+4 : $x+5;
+$xp6 = ($x+6) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+5: $x+6;
+$ym6 = ($y-6) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-5 : $y-6;
+$ym5 = ($y-5) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-4 : $y-5;
+$ym4 = ($y-4) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-3 : $y-4;
+$ym3 = ($y-3) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-2 : $y-3;
+$ym2 = ($y-2) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-1 : $y-2;
+$ym1 = ($y-1) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX : $y-1;
+$yp1 = ($y+1) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX : $y+1;
+$yp2 = ($y+2) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+1 : $y+2;
+$yp3 = ($y+3) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+2: $y+3;
+$yp4 = ($y+4) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+3: $y+4;
+$yp5 = ($y+5) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+4 : $y+5;
+$yp6 = ($y+6) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+5: $y+6;
+
+$xarray = array($xm6,$xm5,$xm4,$xm3,$xm2,$xm1,$x,$xp1,$xp2,$xp3,$xp4,$xp5,$xp6);
+$yarray = array($ym6,$ym5,$ym4,$ym3,$ym2,$ym1,$y,$yp1,$yp2,$yp3,$yp4,$yp5,$yp6);
+$maparray = array();
+$xcount = 0;
+$maparray = '';
+$maparray2 = '';
+for($i=0; $i<=12; $i++){
+ if($xcount != 13){
+ $maparray .= '\''.$generator->getBaseID($xarray[$xcount],$yarray[$i]).'\',';
+ $maparray2 .= $generator->getBaseID($xarray[$xcount],$yarray[$i]).',';
+ if($i==12){
+ $i = -1;
+ $xcount +=1;
+ }
+ }
+}
+
+$maparray = (substr($maparray, 0, -1));
+$maparray2 = (substr($maparray2, 0, -1));
+//echo $maparray;
+
+$query2 = "SELECT
+ ".TB_PREFIX."wdata.id AS map_id,
+ ".TB_PREFIX."wdata.fieldtype AS map_fieldtype,
+ ".TB_PREFIX."wdata.oasistype AS map_oasis,
+ ".TB_PREFIX."wdata.x AS map_x,
+ ".TB_PREFIX."wdata.y AS map_y,
+ ".TB_PREFIX."wdata.occupied AS map_occupied,
+ ".TB_PREFIX."wdata.image AS map_image,
+
+ ".TB_PREFIX."odata.conqured AS oasis_conqured,
+ info_user_oasis.username AS oasis_user,
+ info_user_oasis.tribe AS oasis_tribe,
+ info_alliance_oasis.tag AS oasis_alli_name,
+
+ ".TB_PREFIX."vdata.wref AS ville_id,
+ ".TB_PREFIX."vdata.owner AS ville_user,
+ ".TB_PREFIX."vdata.name AS ville_name,
+ ".TB_PREFIX."vdata.capital AS ville_capital,
+ ".TB_PREFIX."vdata.pop AS ville_pop,
+
+ ".TB_PREFIX."users.id AS user_id,
+ ".TB_PREFIX."users.username AS user_username,
+ ".TB_PREFIX."users.tribe AS user_tribe,
+ ".TB_PREFIX."users.alliance AS user_alliance,
+
+ ".TB_PREFIX."alidata.id AS aliance_id,
+ ".TB_PREFIX."alidata.tag AS aliance_name
+
+ FROM ((((((".TB_PREFIX."wdata
+ LEFT JOIN ".TB_PREFIX."vdata ON ".TB_PREFIX."vdata.wref = ".TB_PREFIX."wdata.id )
+ LEFT JOIN ".TB_PREFIX."odata ON ".TB_PREFIX."odata.wref = ".TB_PREFIX."wdata.id )
+ LEFT JOIN ".TB_PREFIX."users AS info_user_oasis ON info_user_oasis.id = ".TB_PREFIX."odata.owner )
+ LEFT JOIN ".TB_PREFIX."alidata AS info_alliance_oasis ON info_alliance_oasis.id = info_user_oasis.alliance )
+ LEFT JOIN ".TB_PREFIX."users ON ".TB_PREFIX."users.id = ".TB_PREFIX."vdata.owner )
+ LEFT JOIN ".TB_PREFIX."alidata ON ".TB_PREFIX."alidata.id = ".TB_PREFIX."users.alliance )
+ where ".TB_PREFIX."wdata.id IN ($maparray)
+ ORDER BY FIND_IN_SET(".TB_PREFIX."wdata.id,'$maparray2')";
+
+//echo $query2;
+$result2 = mysql_query($query2) or die(mysql_error());
+
+$i=0;
+$i2=0;
+$yrow = 0;
+$row = 0;
+$coorindex = 0;
+$map_js ='';
+
+while ($donnees = mysql_fetch_assoc($result2)){
+
+$targetalliance=$donnees["aliance_id"];
+$friendarray=$database->getAllianceAlly($donnees["aliance_id"],1);
+$neutralarray=$database->getAllianceAlly($donnees["aliance_id"],2);
+$enemyarray=$database->getAllianceWar2($donnees["aliance_id"]);
+
+$friend = (($friendarray[0]['alli1']>0 and $friendarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($friendarray[0]['alli1']==$_SESSION['alliance_user'] or $friendarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0';
+
+$war = (($enemyarray[0]['alli1']>0 and $enemyarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($enemyarray[0]['alli1']==$_SESSION['alliance_user'] or $enemyarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0';
+
+$neutral = (($neutralarray[0]['alli1']>0 and $neutralarray[0]['alli2']>0 and $donnees["aliance_id"]>0) and ($neutralarray[0]['alli1']==$_SESSION['alliance_user'] or $neutralarray[0]['alli2']==$_SESSION['alliance_user']) and ($_SESSION['alliance_user'] != $targetalliance and $_SESSION['alliance_user'] and $targetalliance)) ? '1':'0';
+
+
+$image = ($donnees['map_occupied'] == 1 && $donnees['map_fieldtype'] > 0)?(($donnees['ville_user'] == $_SESSION['id_user'])? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b30': 'b20' :'b10' : 'b00') : (($targetalliance != 0)? ($friend==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b31': 'b21' :'b11' : 'b01') : ($war==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b32': 'b22' :'b12' : 'b02') : ($neutral==1? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b35': 'b25' :'b15' : 'b05') : ($targetalliance == $_SESSION['alliance_user']? ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b33': 'b23' :'b13' : 'b03') : ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b34': 'b24' :'b14' : 'b04'))))) : ($donnees['ville_pop']>=100? $donnees['ville_pop']>= 250?$donnees['ville_pop']>=500? 'b34': 'b24' :'b14' : 'b04'))) : $donnees['map_image'];
+if($donnees['ville_user']==3 && $donnees['ville_name']=='WW Buildingplan'){
+$image = "o99";
+}
+ //Javascript map info
+ if($yrow!=13){
+ $map_js .= "[".$donnees['map_x'].",".$donnees['map_y'].",".$donnees['map_fieldtype'].",". ((!empty($donnees['map_oasis'])) ? $donnees['map_oasis'] : 0) .",\"d=".$donnees['map_id']."&c=".$generator->getMapCheck($donnees['map_id'])."\",\"".$image."\"";
+ if($donnees['map_occupied']){
+ if($donnees['map_fieldtype'] != 0){
+ $map_js.= ",\"".$donnees['ville_name']."\",\"".$donnees['user_username']."\",\"".$donnees['ville_pop']."\",\"".$donnees['aliance_name']."\",\"".$donnees['user_tribe']."\"]\n";
+ }
+ }
+ elseif($donnees['map_oasis'] != 0){
+ if ($donnees['oasis_conqured'] != 0){
+ $map_js.= ",\"\",\"".$donnees['oasis_user']."\",\"-\",\"".$donnees['oasis_alli_name']."\",\"".$donnees['oasis_tribe']."\"]";
+ }
+ else{
+ $map_js.="]";
+ }
+ }
+ else{$map_js .= "]";}
+
+ if($i == 12 && $yrow !=12){
+ $i = -1;
+ $yrow +=1;
+ $map_js .= "],[";
+ }
+ else {
+ if($yrow == 12 && $i == 12) {$map_js .= "]";}
+ else {$map_js .= ",";}
+ }
+ $regcount += 1;
+ }
+ else {$map_js .= "]";}
+ ++$i;
+}
+echo '[['.$map_js.']';
\ No newline at end of file
diff --git a/Templates/Ajax/plusmap.tpl b/Templates/Ajax/plusmap.tpl
new file mode 100644
index 00000000..e8a5041d
--- /dev/null
+++ b/Templates/Ajax/plusmap.tpl
@@ -0,0 +1,187 @@
+getCoor($z);
+$y = $currentcoor['y'];
+$x = $currentcoor['x'];
+
+$xm13 = ($x-13) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-12 : $x-13;
+$xm6 = ($x-6) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-5 : $x-6;
+$xm5 = ($x-5) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-4 : $x-5;
+$xm4 = ($x-4) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-3 : $x-4;
+$xm3 = ($x-3) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-2 : $x-3;
+$xm2 = ($x-2) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX-1 : $x-2;
+$xm1 = ($x-1) < -WORLD_MAX? $x+WORLD_MAX+WORLD_MAX : $x-1;
+$xp1 = ($x+1) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX : $x+1;
+$xp2 = ($x+2) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+1 : $x+2;
+$xp3 = ($x+3) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+2: $x+3;
+$xp4 = ($x+4) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+3 : $x+4;
+$xp5 = ($x+5) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+4 : $x+5;
+$xp6 = ($x+6) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+5: $x+6;
+$xp13 = ($x+13) > WORLD_MAX? $x-WORLD_MAX-WORLD_MAX+12: $x+13;
+$ym13 = ($y-13) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-12 : $y-13;
+$ym6 = ($y-6) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-5 : $y-6;
+$ym5 = ($y-5) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-4 : $y-5;
+$ym4 = ($y-4) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-3 : $y-4;
+$ym3 = ($y-3) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-2 : $y-3;
+$ym2 = ($y-2) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX-1 : $y-2;
+$ym1 = ($y-1) < -WORLD_MAX? $y+WORLD_MAX+WORLD_MAX : $y-1;
+$yp1 = ($y+1) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX : $y+1;
+$yp2 = ($y+2) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+1 : $y+2;
+$yp3 = ($y+3) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+2: $y+3;
+$yp4 = ($y+4) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+3: $y+4;
+$yp5 = ($y+5) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+4 : $y+5;
+$yp6 = ($y+6) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+5: $y+6;
+$yp13 = ($y+13) > WORLD_MAX? $y-WORLD_MAX-WORLD_MAX+12: $y+13;
+$xarray = array($xm6,$xm5,$xm4,$xm3,$xm2,$xm1,$x,$xp1,$xp2,$xp3,$xp4,$xp5,$xp6);
+$yarray = array($ym6,$ym5,$ym4,$ym3,$ym2,$ym1,$y,$yp1,$yp2,$yp3,$yp4,$yp5,$yp6);
+$maparray = array();
+$xcount = 0;
+for($i=0;$i<=12;$i++) {
+ if($xcount != 13) {
+ array_push($maparray,$database->getMInfo($generator->getBaseID($xarray[$xcount],$yarray[$i])));
+ if($i==12) {
+ $i = -1;
+ $xcount +=1;
+ }
+ }
+}
+echo "{\"lm\":\"