From a5778c39be5e62624a563540069b2a362e2bfad8 Mon Sep 17 00:00:00 2001 From: Pietro Date: Wed, 4 Apr 2018 18:25:48 +0200 Subject: [PATCH 1/5] Fixed a building bug You can only build one palace in the whole account. --- GameEngine/Building.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/GameEngine/Building.php b/GameEngine/Building.php index 81254cd5..556f4cb3 100755 --- a/GameEngine/Building.php +++ b/GameEngine/Building.php @@ -642,6 +642,24 @@ class Building { } } + /** + * Search through all user's villages if the castle is built or not + * + * @return boolean Returns true if the castle is already built in the whole account, otherwise returns false + */ + + public function isCastleBuilt(){ + global $database, $session; + + $villages = $database->getProfileVillages($session->uid); + foreach ($villages as $vil){ + if(in_array(26, $database->getResourceLevel($vil['wref']))){ + return true; + } + } + return false; + } + private function meetRequirement($id) { global $village,$session,$database; @@ -678,7 +696,7 @@ class Building { case 23: return !$isBuilt || $this->getTypeLevel($id) == 10; case 24: return $this->getTypeLevel(22) >= 10 && $this->getTypeLevel(15) >= 10 && !$isBuilt; case 25: return $this->getTypeLevel(15) >= 5 && $this->getTypeLevel(26) == 0 && !$isBuilt; - case 26: return $this->getTypeLevel(18) >= 1 && $this->getTypeLevel(15) >= 5 && $this->getTypeLevel(25) == 0 && !$isBuilt; + case 26: return $this->getTypeLevel(18) >= 1 && $this->getTypeLevel(15) >= 5 && $this->getTypeLevel(25) == 0 && !$isBuilt && !$this->isCastleBuilt(); case 27: return $this->getTypeLevel(15) >= 10 && !$isBuilt; case 28: return $this->getTypeLevel(17) == 20 && $this->getTypeLevel(20) >= 10 && !$isBuilt; case 29: return $this->getTypeLevel(19) == 20 && $village->capital == 0 && !$isBuilt; From 92d928969d47465dda4b4b32fc9be40373a9bec4 Mon Sep 17 00:00:00 2001 From: Pietro Date: Wed, 4 Apr 2018 18:27:35 +0200 Subject: [PATCH 2/5] Fixed a little thing and some cleanup "Construct new building" is now shown correctly when trying to build something. Some cleanup. --- Templates/Build/avaliable.tpl | 115 ++++++++-------------------------- 1 file changed, 25 insertions(+), 90 deletions(-) diff --git a/Templates/Build/avaliable.tpl b/Templates/Build/avaliable.tpl index 36b99618..17089f1d 100644 --- a/Templates/Build/avaliable.tpl +++ b/Templates/Build/avaliable.tpl @@ -103,7 +103,7 @@ $residenceBuildInProgress = $residenceOrPalaceInProgress['residence']; $palaceBuildInProgress = $residenceOrPalaceInProgress['palace']; ?> -
+

tribe == 5 && $id != 39) { } } if((($warehouse == 0 && $warehouse1 == 0) || $warehouse == 20) && $mainbuilding >= 1 && $id != 39 && $id != 40) { -include("avaliable/warehouse.tpl"); + include("avaliable/warehouse.tpl"); } if((($greatwarehouse == 0 && $greatwarehouse1 == 0) || $greatwarehouse == 20) && $mainbuilding >= 10 && ($largeA['owner'] == $session->uid || $normalA['vref'] == $village->wid || $village->natar==1) && ($id != 39 && $id != 40)) { include("avaliable/greatwarehouse.tpl"); @@ -141,96 +141,64 @@ if((($greatgranary == 0 && $greatgranary1 == 0) || $greatgranary == 20) && $main include("avaliable/greatgranary.tpl"); } if((($trapper == 0 && $trapper1 == 0) || $trapper == 20) && $rallypoint >= 1 && $session->tribe == 3 && $id != 39 && $id != 40) { -include("avaliable/trapper.tpl"); + include("avaliable/trapper.tpl"); } if($rallypoint == 0 && $rallypoint1 == 0 && $id != 40) { -include("avaliable/rallypoint.tpl"); + include("avaliable/rallypoint.tpl"); } if($embassy == 0 && $embassy1 == 0 && $id != 39 && $id != 40 && $mainbuilding >= 1) { -include("avaliable/embassy.tpl"); + include("avaliable/embassy.tpl"); } //fix hero if($hero == 0 && $hero1 == 0 && $mainbuilding >= 3 && $rallypoint >= 1 && $id != 39 && $id != 40) { -include("avaliable/hero.tpl"); + include("avaliable/hero.tpl"); } //fix barracks if($rallypoint >= 1 && $mainbuilding >= 3 && $barrack == 0 && $barrack1 == 0 && $id != 39 && $id != 40) { -include("avaliable/barracks.tpl"); + include("avaliable/barracks.tpl"); } if($mainbuilding >= 3 && $academy >= 1 && $armoury == 0 && $armoury1 == 0 && $id != 39 && $id != 40) { -include("avaliable/armoury.tpl"); + include("avaliable/armoury.tpl"); } if($cropland >= 5 && $grainmill == 0 && $grainmill1 == 0 && $id != 39 && $id != 40) { -include("avaliable/grainmill.tpl"); + include("avaliable/grainmill.tpl"); } //fix marketplace if($granary >= 1 && $warehouse >= 1 && $mainbuilding >= 3 && $market == 0 && $market1 == 0 && $id != 39 && $id != 40) { -include("avaliable/marketplace.tpl"); + include("avaliable/marketplace.tpl"); } if($mainbuilding >= 5 && $residence == 0 && $residence1 == 0 && $id != 39 && $id != 40 && $palace == 0 && !$palaceBuildInProgress) { -include("avaliable/residence.tpl"); + include("avaliable/residence.tpl"); } if($academy == 0 && $academy1 == 0 && $mainbuilding >= 3 && $barrack >= 3 && $id != 39 && $id != 40) { -include("avaliable/academy.tpl"); + include("avaliable/academy.tpl"); } - -if($palace == 0 && $palace1 == 0 && $village->natar == 0 && $embassy >= 1 && $mainbuilding >= 5 && $id != 39 && $id != 40 && $residence == 0 && $residence1 == 0) { - -//Fix Castle -//id user -$user = $session->uid; - - -//loop search village user -$villages = $database->getProfileVillages($user); -foreach ($villages as $villaggi_array){ - - //loop structure village - $query1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".(int) $villaggi_array['wref'].""); - $strutture= mysqli_fetch_array($query1); - if($strutture == false) - $strutture = []; -//search Castle in array structure village -$test = in_array(26,$strutture); - -if ($test){ - break; +if($palace == 0 && $palace1 == 0 && !$building->isCastleBuilt() && $village->natar == 0 && $embassy >= 1 && $mainbuilding >= 5 && $id != 39 && $id != 40 && $residence == 0 && $residence1 == 0) { + include("avaliable/palace.tpl"); } - -} - -//if Castle no ready include palace.tpl -if (!$test && !$residenceBuildInProgress){ - include("avaliable/palace.tpl"); -} - -//end Fix -} - - if($blacksmith == 0 && $blacksmith1 == 0 && $academy >= 3 && $mainbuilding >= 3 && $id != 39 && $id != 40) { -include("avaliable/blacksmith.tpl"); + include("avaliable/blacksmith.tpl"); } if($stonemasonslodge == 0 && $stonemasonslodge1 == 0 && $palace >= 3 && $mainbuilding >= 5 && $id != 39 && $id != 40) { -include("avaliable/stonemason.tpl"); + include("avaliable/stonemason.tpl"); } if($stable == 0 && $stable1 == 0 && $blacksmith >= 3 && $academy >= 5 && $id != 39 && $id != 40) { -include("avaliable/stable.tpl"); + include("avaliable/stable.tpl"); } if($treasury == 0 && $treasury1 == 0 && $village->natar == 0 && $mainbuilding >= 10 && $id != 39 && $id != 40) { -include("avaliable/treasury.tpl"); + include("avaliable/treasury.tpl"); } if($brickyard == 0 && $brickyard1 == 0 && $claypit >= 10 && $mainbuilding >= 5 && $id != 39 && $id != 40 ) { -include("avaliable/brickyard.tpl"); + include("avaliable/brickyard.tpl"); } if($sawmill == 0 && $sawmill1 == 0 && $woodcutter >= 10 && $mainbuilding >= 5 && $id != 39 && $id != 40) { - include("avaliable/sawmill.tpl"); + include("avaliable/sawmill.tpl"); } if($ironfoundry == 0 && $ironfoundry1 == 0 && $ironmine >= 10 && $mainbuilding >= 5 && $id != 39 && $id != 40) { - include("avaliable/ironfoundry.tpl"); + include("avaliable/ironfoundry.tpl"); } if($workshop == 0 && $workshop1 == 0 && $academy >= 10 && $mainbuilding >= 5 && $id != 39 && $id != 40) { - include("avaliable/workshop.tpl"); + include("avaliable/workshop.tpl"); } if($tournamentsquare == 0 && $tournamentsquare1 == 0 && $rallypoint >= 15 && $id != 39 && $id != 40) { include("avaliable/tsquare.tpl"); @@ -295,41 +263,8 @@ if($residence == 0 && $mainbuilding <= 4) { if($academy == 0 && ($mainbuilding <= 2 || $barrack <= 2)) { include("soon/academy.tpl"); } -if($embassy == 0 || $mainbuilding >= 2 && $mainbuilding <= 4 && $village->natar == 0) { -//Fix Castle -//id user -$user = $session->uid; - -//connect to DB -//mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); -//mysqli_select_db(SQL_DB); - -//loop search village user -$villages = $database->getProfileVillages($user); -foreach ($villages as $villaggi_array){ - - //loop structure village - $query1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".(int) $villaggi_array['wref'].""); - $strutture= mysqli_fetch_array($query1); - -//search Castle in array structure village - if($strutture !== false) - $test = in_array(26,$strutture); - else - $test = in_array(26,[]); -if ($test){ - break; - } - -} - - -//if Castle no ready include palace.tpl -if (!$test){ - include("soon/palace.tpl"); -} - -//end Fix +if($embassy == 0 || $mainbuilding >= 2 && $mainbuilding <= 4 && !$building->isCastleBuilt() && $village->natar == 0) { + include("soon/palace.tpl"); } if($blacksmith == 0 && ($academy <= 2 || $mainbuilding <= 2)) { include("soon/blacksmith.tpl"); @@ -445,7 +380,7 @@ if($greatworkshop == 0 && $workshop >= 15 && $village->capital == 0 && GREAT_WKS include("soon/greatworkshop.tpl"); } ?> -