public function handleHerosMansion() { $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && intval($_GET['t']) == 1 ? intval($_GET['t']) : 0; if ($this->selectedTabIndex == 0) { $this->hasHero = 0 < intval($this->data['hero_troop_id']); $this->troopsUpgradeType = QS_TROOP_TRAINING_HERO; if (!$this->hasHero) { $this->_getOnlyMyTroops(TRUE); if ($_GET['k'] == $this->data['update_key'] && !isset($this->queueModel->tasksInQueue[$this->troopsUpgradeType]) && isset($this->troops[intval($_GET['a'])]) && 0 < $this->troops[intval($_GET['a'])] && !$this->isGameTransientStopped() && !$this->isGameOver()) { $troopId = intval($_GET['a']); $troopMetadata = $this->gameMetadata['troops'][$troopId]; $nResources = array("1" => $troopMetadata['training_resources'][1] * 2, "2" => $troopMetadata['training_resources'][2] * 2, "3" => $troopMetadata['training_resources'][3] * 2, "4" => $troopMetadata['training_resources'][4] * 2); if (!$this->isResourcesAvailable($nResources)) { } else { $calcConsume = intval($troopMetadata['training_time_consume'] / $this->gameSpeed * (10 / ($this->buildProperties['building']['level'] + 9))) * 12; $newTask = new QueueTask($this->troopsUpgradeType, $this->player->playerId, $calcConsume); $newTask->procParams = $troopId . " " . $this->data['selected_village_id']; $newTask->tag = $nResources; $this->queueModel->addTask($newTask); } } } else { if ($this->isPost() && isset($_POST['hname']) && trim($_POST['hname']) != "") { $this->data['hero_name'] = trim($_POST['hname']); $m = new BuildModel(); $m->changeHeroName($this->player->playerId, $this->data['hero_name']); $m->dispose(); } } } else { if ($this->selectedTabIndex == 1) { $this->villageOases = array(); $m = new BuildModel(); $result = $m->getVillageOases(trim($this->data['village_oases_id'])); while ($result != NULL && $result->next()) { $this->villageOases[$result->row['id']] = array("id" => $result->row['id'], "rel_x" => $result->row['rel_x'], "rel_y" => $result->row['rel_y'], "image_num" => $result->row['image_num'], "allegiance_percent" => $result->row['allegiance_percent']); } $m->dispose(); if (!$this->isGameTransientStopped() && !$this->isGameOver()) { $oasisId = intval($_GET['a']); $newTask = new QueueTask(QS_LEAVEOASIS, $this->player->playerId, floor(21600 / $this->gameSpeed)); $newTask->villageId = $this->data['selected_village_id']; $newTask->buildingId = $oasisId; $newTask->procParams = $this->villageOases[$oasisId]['rel_x'] . " " . $this->villageOases[$oasisId]['rel_y']; $this->queueModel->addTask($newTask); } else { if (isset($_GET['qid']) && 0 < intval($_GET['qid'])) { $this->queueModel->cancelTask($this->player->playerId, intval($_GET['qid'])); } } } } }