Exemple #1
0
 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;
 }