Пример #1
0
 /**
  * Lists all the available games to start
  *
  * @return array Array of game IDs and titles
  **/
 public function doGetGames()
 {
     $this->mlog->debug('[' . __METHOD__ . ']');
     $resp = new Response();
     $games = GameQuery::create()->find();
     foreach ($games as $g) {
         $resp->data[] = array('game_id' => $g->getPrimaryKey(), $g->getName());
     }
     return $resp->__toArray();
 }
Пример #2
0
 /**
  * Lists all the available games to start
  *
  * @param int $game_id ID of the game to start
  * @param string Name of your match
  * @return array The new match object
  **/
 public function doCreateMatch($game_id, $game_name)
 {
     $this->mlog->debug('[' . __METHOD__ . ']');
     $resp = new Response();
     try {
         $game = GameQuery::findPk($game_id);
         if ($game instanceof Game) {
             $match = Match::create($game, $game_name);
             $resp->data = $match->__toArray();
         }
     } catch (Exception $ex) {
         $resp->fail(Response::UNKNONWN_EXCEPTION, 'An error occured, please try again later');
     }
     return $resp->__toArray();
 }