public function startApp() { $lv = new LayoutView(); if ($this->LayoutView->userWantsToPlay()) { $gm = new GameModel($this->userDAL, $this->SessionManager); $this->View = new GameView($gm); if ($this->View->userChoseScissors()) { $result = $gm->playGame(choice::$scissors); } else { if ($this->View->userChosePaper()) { $result = $gm->playGame(choice::$paper); } else { if ($this->View->userChoseRock()) { $result = $gm->playGame(choice::$rock); } } } } else { $this->SessionManager->SessionUnsetGameSessions(); $loggedinUsername = $this->SessionManager->SessionGetLoggedInUser(); $userStats = $this->userDAL->getUserStats($loggedinUsername); $userProfilePic = $this->userDAL->getProfilePicUrl($loggedinUsername); $this->View = new StartView($userStats, $this->SessionManager, $userProfilePic); if ($this->View->userWantsToSubmitPic()) { if ($this->View->userPicUrlValid()) { $this->userDAL->changeUserPic($this->View->getPicUrlInput(), $loggedinUsername); $this->View->setImageChangeSuccessMessage(); } else { $this->View->setImageChangeFailureMessage(); } } else { if ($this->View->userChoseGameMode()) { $this->SessionManager->SessionRoundsToWin($this->View->getHowManyRoundsToBePlayed()); header("location:?game"); } } } return $this->View; }
static function init() { $init['user'] = $_SESSION['user']; $host = $_SERVER['HTTP_HOST']; if (substr($host, 0, 7) != 'http://') { $host = 'http://' . $host; } $init['app'] = array('host' => $host); $query = self::_reffer(); if (isset($query['gid'])) { $gid = $query['gid']; $game = GameModel::get($gid); $game['user'] = UserBusiness::publicShow($game['uid']); $game['createtime'] = date('Y-m-d H:i:s', $game['createtime']); $init['game'] = $game; } return $init; }
public function getVersionAction() { $params = $this->_arrParam; Zend_Loader::loadClass("GameModel"); if (isset($params["game_id"])) { $model = new GameModel(); $result = $model->getVersion($params["game_id"]); if ($result) { $data = array("code" => 1, "content" => $result); } else { $data = array("code" => 0, "content" => "Game not found"); } } else { $data = array("code" => 0, "content" => "Invalid parameters"); } echo json_encode($data); exit; }
public static function jet_to($placeId) { // 1. Validate the input $placeId = floor(htmlentities($placeId)); if (!is_numeric($placeId) || $placeId < 1 || $placeId > 6) { Redirect::to('game/'); return false; } // 2. Set user_location to choosen location. switch ($placeId) { case 1: $location = Options::get('LOCATION_1'); break; case 2: $location = Options::get('LOCATION_2'); break; case 3: $location = Options::get('LOCATION_3'); break; case 4: $location = Options::get('LOCATION_4'); break; case 5: $location = Options::get('LOCATION_5'); break; case 6: $location = Options::get('LOCATION_6'); break; } Session::set('user_location', $location); // 3. Add 10% debt interests if any GameModel::add_debt_interests(); // 4. Add 1 day to game_date and check if it didn't hit the game limit (end of the game) Session::set('game_date', strtotime('+1 day', Session::get('game_date'))); if (Session::get('game_date') > Options::get('END_GAME_DATE')) { Redirect::to('game/final_score/'); return false; } // 5. Re-roll drugs prices GameModel::reroll_products_prices(); // 6. Check for random encounters $rand = mt_rand(1, 100); if ($rand <= 100) { GameModel::random_encounter(); } return true; }
public function top_scores() { $this->View->render('info/top_scores', array('ranking' => GameModel::get_ranking())); }
public function action() { GameModel::action(); Redirect::to('game/'); }