コード例 #1
0
 /**
  *
  * @return void
  */
 public function _prep()
 {
     $user = Model_Users::current_user();
     if (!$user) {
         $params = array('error' => 'You must be logged in to run a game. ');
         $this->_forward('index', 'index', NULL, $params);
         return FALSE;
     }
     $game_id = $this->_getParam('game');
     // either actively select game or reactivate last played game
     if ($game_id) {
         $game = Ultimatum_Model_Ultgames::getInstance()->get($game_id);
         $player = Ultimatum_Model_Ultplayers::for_user_game($user, $game)->activate();
     } else {
         $player = Ultimatum_Model_Ultplayers::user_active_player($user);
         if (!$player) {
             $params = array('error' => 'cannot find active game');
             $this->_forward('index', 'index', NULL, $params);
             return FALSE;
         }
         $game = $player->get_game();
     }
     // at this point the player and game objects should be set.
     if (!$player) {
         $params = array('errror' => 'You are not a player in game ' . $id);
         $this->_forward('index', 'index', NULL, $params);
         return FALSE;
     }
     $this->view->game = $game;
     $game->activate();
     $this->view->player = $player;
     // there may or may not be a player group specified by paramerters.
     // player_group refers to the group indirectly by the game group id.
     // group refers to the group id directly.
     if ($player_group = $this->_getParam('player_group')) {
         $this->view->player_group = Ultimatum_Model_Ultgamegroups::getInstance()->get($player_group);
     } elseif ($group = $this->_getParam("group", NULL)) {
         $this->view->player_group = $player->player_group($group);
     }
     // there may or may not be a target.
     // the target id is the group id NOT the game group id.
     if ($target = $this->_getParam('target')) {
         $this->view->target = $target_obj = Ultimatum_Model_Ultgroups::getInstance()->get($target);
         $this->view->target_scan = $player->get_scan($target);
     }
     return TRUE;
 }
コード例 #2
0
ファイル: Ultgames.php プロジェクト: BGCX262/zupal-svn-to-git
 /**
  *
  * @param Model_User $pUser
  * @return Ultimatum_Model_Ultplayer
  */
 public function add_user($pUser)
 {
     $player = Ultimatum_Model_Ultplayers::for_user_game($pUser, $this);
     $player->activate();
     return $player;
 }
コード例 #3
0
ファイル: Ultgames.php プロジェクト: BGCX262/zupal-svn-to-git
 /**
  *
  * @param int | Model_Users $pUser
  * @return 
  */
 public function add_player($pUser)
 {
     return Ultimatum_Model_Ultplayers::for_user_game($pUser, $this);
 }