diff --git a/GameEngine/Admin/Mods/natarbuildingplan.php b/GameEngine/Admin/Mods/natarbuildingplan.php index 056be321..71e71bfc 100644 --- a/GameEngine/Admin/Mods/natarbuildingplan.php +++ b/GameEngine/Admin/Mods/natarbuildingplan.php @@ -33,6 +33,13 @@ for($i=1;$i<=$amt;$i++) { $database->addABTech($wid); $q = "UPDATE ".TB_PREFIX."units SET u41 = u41 + '150000', u42 = u42 + '150000', u43 = u43 + '150000', u44 = u44 + '150000', u45 = u45 + '150000', u46 = u46 + '150000', u47 = u47 + '150000', u48 = u48 + '150000' , u49 = u49 + '150000', u50 = u50 + '150000' WHERE vref = '".$wid."'"; mysql_query($q); + $desc = 'With this ancient construction plan you will able to build World Wonder to level 50. to build further, your alliance must hold at least two plans.'; + + unset($i); + unset($vname); + unset($effect); + $vname = 'Ancient Construction Plan'; + $database->addArtefact($wid, 3, 11, 3, 'Ancient Construction Plan', $desc, 0, 'typeww.gif'); } diff --git a/GameEngine/Admin/Mods/natarend.php b/GameEngine/Admin/Mods/natarend.php index fed5ce6c..7d15c52b 100644 --- a/GameEngine/Admin/Mods/natarend.php +++ b/GameEngine/Admin/Mods/natarend.php @@ -26,7 +26,7 @@ for($i=1;$i<=$amt;$i++) { $time = time(); $q = "insert into `s1_vdata`(`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`,`natar`) values ('$wid','3','WW village',0,233,232,0,0,80000.00,80000.00,80000.00,80000,80000.00,80000,1314974534,100,0,0,0,$time,1)"; mysql_query($q) or die(mysql_error()); - $q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid,0,1,0,4,0,1,0,3,0,2,0,2,0,3,0,4,0,4,0,3,0,3,0,4,0,4,0,1,0,4,0,2,0,1,0,2,20,17,20,11,20,15,20,10,10,22,10,25,0,0,0,0,10,19,0,0,0,0,0,0,10,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,0,0,1,40,'World Wonder')"; + $q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid,0,1,0,4,0,1,0,3,0,2,0,2,0,3,0,4,0,4,0,3,0,3,0,4,0,4,0,1,0,4,0,2,0,1,0,2,20,17,20,11,20,15,20,10,10,22,10,25,0,0,0,0,10,19,0,0,0,0,0,0,10,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,0,0,0,0,'World Wonder')"; mysql_query($q); $database->addUnits($wid); $database->addTech($wid); diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 9c058e3b..79246fa7 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -118,7 +118,6 @@ class Automation { $this->oasisResoucesProduce(); $this->pruneResource(); $this->pruneOResource(); - $this->MasterBuilder(); if(!file_exists("GameEngine/Prevention/culturepoints.txt") or time()-filemtime("GameEngine/Prevention/culturepoints.txt")>10) { $this->culturePoints(); } @@ -165,6 +164,7 @@ class Automation { $this->demolitionComplete(); } $this->updateStore(); + $this->MasterBuilder(); } function activeCropDead(){ @@ -2928,7 +2928,8 @@ private function demolitionComplete() { }else{ $inbuild = 1; } - if($bdata < $inbuild && $buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop){ + $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) { @@ -2940,7 +2941,6 @@ private function demolitionComplete() { }else{ $database->updateBuildingWithMaster($master['id'],$time,1); } - $usergold = $database->getUserField($owner,'gold',0); $gold = $usergold-1; $database->updateUserField($owner,'gold',$gold,1); $database->modifyResource($master['wid'],$buildwood,$buildclay,$buildiron,$buildcrop,0); diff --git a/GameEngine/Building.php b/GameEngine/Building.php index 99c7e92e..59d93478 100644 --- a/GameEngine/Building.php +++ b/GameEngine/Building.php @@ -64,7 +64,9 @@ class Building { 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']); @@ -392,7 +394,7 @@ class Building { } private function meetRequirement($id) { - global $village; + global $village,$database; switch($id) { case 1: case 2: @@ -491,8 +493,8 @@ class Building { if($this->getTypeLevel(15) >= 10 && $village->capital == 0) { return true; } else { return false; } break; case 40: - //need to check if have ww buildplan too - if($village->natar == 1) { return true; } else { return false; } + $wwbuildingplan = count($database->getOwnArtefactInfoByType2($village->wid,11)); + if($village->natar == 1 && $wwbuildingplan > 0) { return true; } else { return false; } break; case 41: if($this->getTypeLevel(16) >= 10 && $this->getTypeLevel(20) == 20) { return true; } else { return false; } diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 55ea453b..9c8aa799 100644 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -1997,6 +1997,12 @@ 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); } @@ -2612,11 +2618,19 @@ $result = mysql_query($q, $this->connection); return mysql_fetch_array($result); } + function getOwnArtefactInfoByType($vref, $type) { $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type"; $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); diff --git a/Templates/Build/avaliable.tpl b/Templates/Build/avaliable.tpl index 4f2aec41..c356ec06 100644 --- a/Templates/Build/avaliable.tpl +++ b/Templates/Build/avaliable.tpl @@ -44,6 +44,7 @@ $greatgranary = $building->getTypeLevel(39); $greatworkshop = $building->getTypeLevel(42); $ww = $building->getTypeLevel(40); $wwinbuild = count($database->getBuildingByType($village->wid,40)); +$wwbuildingplan = count($database->getOwnArtefactInfoByType2($village->wid,11)); foreach ($database->getJobs($_SESSION['wid']) as $bdata) { $UnderConstruction = strtolower(str_replace(array(" ","'"),"",$building->procResType($bdata['type']))); @@ -54,7 +55,7 @@ foreach ($database->getJobs($_SESSION['wid']) as $bdata) { ?>

Construct new building

natar == 1){ //need to check if have ww buildplan too +if($ww == 0 && $wwinbuild == 0 && $village->natar == 1 && $wwbuildingplan > 0){ include("avaliable/ww.tpl"); } if($mainbuilding == 0 && $id != 39 && $id != 40) { diff --git a/Templates/Build/ww.tpl b/Templates/Build/ww.tpl index 0f088f3f..f03ae0a0 100644 --- a/Templates/Build/ww.tpl +++ b/Templates/Build/ww.tpl @@ -42,6 +42,6 @@ echo 'You can not change the name of the World Wonder after level 10. ?>

\ No newline at end of file diff --git a/Templates/Build/wwupgrade.tpl b/Templates/Build/wwupgrade.tpl new file mode 100644 index 00000000..a0925250 --- /dev/null +++ b/Templates/Build/wwupgrade.tpl @@ -0,0 +1,156 @@ +resarray['f'.$id.'t']; +$bindicate = $building->canBuild($id,$bid); +$wwlevel = $village->resarray['f'.$id]; +if($wwlevel > 49){ +$needed_plan = 1; +}else{ +$needed_plan = 0; +} +$alli_users = $database->getUserByAlliance($session->alliance); +$wwbuildingplan = 0; +if(!empty(($alli_users))){ +foreach($alli_users as $users){ +$villages = $database->getVillageID($users['id']); +foreach($villages as $village){ +$plan = count($database->getOwnArtefactInfoByType2($village,11)); +if($plan > 0){ +$wwbuildingplan += 1; +} +} +} +} +if($wwbuildingplan == $needed_plan){ +if($bindicate == 1) { + echo "

Building already at max level

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

Building max level under construction

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

Building presently being demolished

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

Costs for upgrading to level resarray['f'.$id]+1+$loopsame+$doublebuild+$master; ?>:
+Lumber | Clay | Iron | Crop | Crop consumption | durationgetTimeFormat($uprequire['time']); +if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1) { + echo "|\"NPC"; + } ?>
+The workers are already at work."; + if($session->goldclub){ +?>
+gold >= 1 && $village->master == 0){ + echo "Constructing with master builder "; + echo '(costs: Gold1)'; + }else{ + echo "Constructing with master builder"; + echo '(costs: Gold1)'; + } + }else{ + if($session->gold >= 1 && $village->master == 0){ + echo "Constructing with master builder "; + echo '(costs: Gold1)'; + }else{ + echo "Constructing with master builder"; + echo '(costs: Gold1)'; + } + } + } + } + else if($bindicate == 3) { + echo "The workers are already at work. (waiting loop)"; + if($session->goldclub){ +?>
+gold >= 1 && $village->master == 0){ + echo "Constructing with master builder "; + echo '(costs: Gold1)'; + }else{ + echo "Constructing with master builder"; + echo '(costs: Gold1)'; + } + }else{ + if($session->gold >= 1 && $village->master == 0){ + echo "Constructing with master builder "; + echo '(costs: Gold1)'; + }else{ + echo "Constructing with master builder"; + echo '(costs: Gold1)'; + } + } + } + } + else if($bindicate == 4) { + echo "Not enough food. Expand cropland."; + } + else if($bindicate == 5) { + echo "Upgrade Warehouse."; + } + else if($bindicate == 6) { + echo "Upgrade Granary."; + } + else if($bindicate == 7) { + $neededtime = $building->calculateAvaliable($id,$village->resarray['f'.$id.'t'],1+$loopsame+$doublebuild+$master); + echo "Enough resources ".$neededtime[0]." at ".$neededtime[1].""; + if($session->goldclub){ +?>
+gold >= 1 && $village->master == 0){ + echo "Constructing with master builder "; + echo '(costs: Gold1)'; + }else{ + echo "Constructing with master builder"; + echo '(costs: Gold1)'; + } + }else{ + if($session->gold >= 1 && $village->master == 0){ + echo "Constructing with master builder "; + echo '(costs: Gold1)'; + }else{ + echo "Constructing with master builder"; + echo '(costs: Gold1)'; + } + } + } + } + else if($bindicate == 8) { + if($session->access==BANNED){ + echo "Upgrade to level "; + } + else if($id <= 18) { + echo "checker\">Upgrade to level "; + } + else { + echo "checker\">Upgrade to level "; + } + echo $village->resarray['f'.$id]+1; + echo "."; + } + else if($bindicate == 9) { + if($session->access==BANNED){ + echo "Upgrade to level "; + } + else if($id <= 18) { + echo "checker\">Upgrade to level "; + } + else { + echo "checker\">Upgrade to level "; + } + echo $village->resarray['f'.$id]+($loopsame > 0 ? 2:1); + echo ". (waiting loop) "; + } +} + }else{ + echo "Need more WW construction plan."; + } + +?>