public function handleResidencePalace() { $this->selectedTabIndex = is_numeric($_GET['t']) && 1 <= intval($_GET['t']) && intval($_GET['t']) <= 3 ? intval($_GET['t']) : 0; $_bid_ = $this->buildings[$this->buildingIndex]['item_id']; if ($this->selectedTabIndex == 0) { if (isset($_GET['mc']) && !$this->data['is_capital'] && !$this->data['is_special_village'] && $_bid_ == 26) { $this->data['is_capital'] = TRUE; $m = new BuildModel(); $m->makeVillageAsCapital($this->player->playerId, $this->data['selected_village_id']); $m->dispose(); } $this->childVillagesCount = 0; if (trim($this->data['child_villages_id']) != "") { $this->childVillagesCount = sizeof(explode(",", $this->data['child_villages_id'])); } $itemId = $this->buildings[$this->buildingIndex]['item_id']; $buildingLevel = $this->buildings[$this->buildingIndex]['level']; $this->troopsUpgradeType = QS_TROOP_TRAINING; $this->_getOnlyMyTroops(); $this->troopsUpgrade = array(); $_arr = explode(",", $this->data['troops_training']); foreach ($_arr as $troopStr) { $attack_level = explode(" ", $troopStr); $defense_level = explode(" ", $troopStr); $researches_done = explode(" ", $troopStr); $troopId = explode(" ", $troopStr); list($troopId, $researches_done, $defense_level, $attack_level) = $troopId; if ($researches_done == 1 && $this->_canTrainInBuilding($troopId, $itemId)) { $this->troopsUpgrade[] = array("troopId" => $troopId, "maxNumber" => $this->_getMaxTrainNumber($troopId, $itemId), "currentNumber" => $this->_getCurrentNumberFor($troopId, $itemId)); } } $this->showBuildingForm = FALSE; if ($buildingLevel < 10 || 2 <= $this->childVillagesCount && $_bid_ == 25 || 3 <= $this->childVillagesCount && $_bid_ == 26 || $this->childVillagesCount == 1 && $buildingLevel < 20 && $_bid_ == 25 || $this->childVillagesCount == 1 && $buildingLevel < 15 && $_bid_ == 26 || $this->childVillagesCount == 2 && $buildingLevel < 20 && $_bid_ == 26) { $this->troopsUpgrade = array(); } else { if (1 < sizeof($this->troopsUpgrade)) { if (1 <= $this->troopsUpgrade[0]['currentNumber'] || 3 <= $this->troopsUpgrade[1]['currentNumber']) { $this->troopsUpgrade = array(); } else { if (0 < $this->troopsUpgrade[1]['currentNumber']) { unset($Var_4224[0]); } } } else { if (3 <= $this->troopsUpgrade[0]['currentNumber']) { $this->troopsUpgrade = array(); } } $this->showBuildingForm = 0 < sizeof($this->troopsUpgrade); } if ($this->isPost() && isset($_POST['tf']) && !$this->isGameTransientStopped() && !$this->isGameOver()) { foreach ($_POST['tf'] as $troopId => $num) { $num = intval($num); $existsTroop = FALSE; foreach ($this->troopsUpgrade as $troop) { if ($troop['troopId'] == $troopId) { $existsTroop = TRUE; break; break; } } if ($num <= 0 || !$existsTroop || $this->_getMaxTrainNumber($troopId, $itemId) < $num) { continue; } $troopMetadata = $this->gameMetadata['troops'][$troopId]; $calcConsume = intval($troopMetadata['training_time_consume'] / $this->gameSpeed * (10 / ($this->buildProperties['building']['level'] + 9))); $newTask = new QueueTask($this->troopsUpgradeType, $this->player->playerId, $calcConsume); $newTask->threads = $num; $newTask->villageId = $this->data['selected_village_id']; $newTask->buildingId = $this->buildProperties['building']['item_id']; $newTask->procParams = $troopId; $newTask->tag = $troopMetadata['training_resources']; $this->queueModel->addTask($newTask); } } } else { if ($this->selectedTabIndex == 1) { $this->neededCpValue = $this->totalCpRate = $this->totalCpValue = 0; $m = new BuildModel(); $result = $m->getVillagesCp($this->data['villages_id']); while ($result->next()) { //fix2 part f culture points calculations $cpRate = explode(" ", $result->row['cp']); $this->cpValue = explode(" ", $result->row['cp']); list($this->cpValue, $cpRate) = $this->cpValue; $_39643752 += "cpValue"; $_39643848 += "totalCpRate"; $_39643880 += "totalCpValue"; $_39643880 += "neededCpValue"; } $this->totalCpValue = floor($this->totalCpValue); $m->dispose(); } else { if ($this->selectedTabIndex == 3) { $this->childVillages = array(); $m = new BuildModel(); $result = $m->getChildVillagesFor(trim($this->data['child_villages_id'])); while ($result != NULL && $result->next()) { $this->childVillages[$result->row['id']] = array("id" => $result->row['id'], "rel_x" => $result->row['rel_x'], "rel_y" => $result->row['rel_y'], "village_name" => $result->row['village_name'], "people_count" => $result->row['people_count'], "creation_date" => $result->row['creation_date']); } $m->dispose(); } } } }