public function load() { parent::load(); $villageId = isset($_GET['id']) && 0 < intval($_GET['id']) ? intval($_GET['id']) : 0; if ($villageId <= 0) { $this->redirect("map.php"); } else { $m = new VillageModel(); $this->mapItemData = $m->getMapItemData($villageId); $this->protect = $m->getVillageProtection($this->mapItemData['player_id']); if (!is_array($this->mapItemData)) { $m->dispose(); $this->redirect("map.php"); } else { if (0 < intval($this->mapItemData['player_id'])) { $this->pageState = $this->mapItemData['is_oasis'] ? 3 : 2; $this->mapItemData['playerType'] = $m->getPlayType(intval($this->mapItemData['player_id'])); } else { $this->pageState = $this->mapItemData['is_oasis'] ? 4 : 1; } $this->lastReport = NULL; if ($this->pageState == 2 || $this->pageState == 3) { if ($this->mapItemData['player_id'] == $this->player->playerId || $this->mapItemData['alliance_id'] == $this->data['alliance_id'] && 0 < intval($this->data['alliance_id'])) { $this->lastReport = $m->getLatestReports($this->mapItemData['player_id'], $this->mapItemData['id']); } else { $fromPlayersId = 0 < intval($this->data['alliance_id']) ? $m->getAlliancePlayersId(intval($this->data['alliance_id'])) : $this->player->playerId; $this->lastReport = $m->getLatestReports2($fromPlayersId, $this->mapItemData['player_id'], $this->mapItemData['id']); } if ($this->pageState == 3) { $this->mapItemData['village_name'] = $m->getVillageName($this->mapItemData['parent_id']); } } else { if ($this->pageState == 1 || $this->pageState == 4) { $this->itemTroops = array(); $t = $this->pageState == 1 ? $this->data['troops_num'] : $this->mapItemData['troops_num']; $incFactor = $this->pageState == 4 ? floor($this->mapItemData['elapsedTimeInSeconds'] / 86400) : 0; $t_arr = explode("|", $t); foreach ($t_arr as $t_str) { $t2_arr = explode(":", $t_str); if (0 - 1 < $t2_arr[0]) { continue; } $t2_arr = explode(",", $t2_arr[1]); foreach ($t2_arr as $t2_str) { $t = explode(" ", $t2_str); if ($t[0] == 99) { continue; } $this->itemTroops[$t[0]] = $t[1] + $incFactor; if ($this->pageState == 4 && 7 * intval($t[0]) < $this->itemTroops[$t[0]]) { $this->itemTroops[$t[0]] = 7 * intval($t[0]); } } } } } $m->dispose(); } } }
public function load() { parent::load(); $this->quiz = trim($this->data['guide_quiz']); if ($this->quiz == GUIDE_QUIZ_COMPLETED) { exit(0); } else { $m = new GuideModel(); $this->taskState = 0; if ($this->quiz == GUIDE_QUIZ_NOTSTARTED || $this->quiz == GUIDE_QUIZ_SUSPENDED) { $this->clientAction = 0 - 1; if (isset($_GET['v']) && $_GET['v'] == "f") { if ($this->quiz == GUIDE_QUIZ_NOTSTARTED) { $m->setGuideTask($this->player->playerId, GUIDE_QUIZ_SUSPENDED); } $m->dispose(); exit(0); } else { if (isset($_GET['v']) && $_GET['v'] == "n") { $this->quiz = "1,200"; $this->clientAction = 1; $m->setGuideTask($this->player->playerId, $this->quiz); } else { $this->taskNumber = isset($_GET['v']) && $_GET['v'] == "s" ? 1 : 0; if ($this->taskNumber == 1) { $this->clientAction = 0; $this->quiz = "0,1"; $m->setGuideTask($this->player->playerId, $this->quiz); } } } } else { $quizArray = explode(",", $this->quiz); $this->taskNumber = $quizArray[1]; if ($this->taskNumber == 200 && isset($_GET['v'])) { if ($_GET['v'] == "y") { $this->taskNumber = 0; $this->clientAction = 1; $this->quiz = GUIDE_QUIZ_NOTSTARTED; $m->setGuideTask($this->player->playerId, $this->quiz); } else { if ($_GET['v'] == "c") { $this->quiz = "0,201,0"; $quizArray = explode(",", $this->quiz); $this->taskNumber = $quizArray[1]; $m->setGuideTask($this->player->playerId, $this->quiz); } } } if ($this->taskNumber == 201) { $this->handleNoQuiz($m, $quizArray[2]); } else { if ($quizArray[0] == 1) { $this->clientAction = $quizArray[0] = 0; $m->setGuideTask($this->player->playerId, implode(",", $quizArray)); $this->newReadQuiz($this->taskNumber, $m, $quizArray); } else { $this->checkForQuiz($this->taskNumber, $m, $quizArray); } } $m->dispose(); } } }