From a5778c39be5e62624a563540069b2a362e2bfad8 Mon Sep 17 00:00:00 2001 From: Pietro Date: Wed, 4 Apr 2018 18:25:48 +0200 Subject: [PATCH] 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;