/**
  * Creates a new Game model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $Game = new Game();
     if ($Game->load(Yii::$app->request->post()) && $Game->save()) {
         return $this->redirect(['game/index']);
     } else {
         return $this->render('create', ['Game' => $Game]);
     }
 }
예제 #2
0
파일: Game.php 프로젝트: bizley/imperium
 /**
  * Loads game from session.
  * @return Game
  * @throws InvalidValueException
  */
 public static function fromSession()
 {
     $session = Yii::$app->session->get('game');
     if ($session === false) {
         throw new InvalidValueException('Saved game ID not found!');
     }
     $game = new Game();
     $game->load($session);
     return $game;
 }
예제 #3
0
파일: Left.php 프로젝트: edcoreweb/dominox
 /**
  * Handle the event.
  *
  * @param  \App\Models\Game $game
  * @param  \App\WS\Connection $conn
  * @return void
  */
 public function handle($game, $user, $conn)
 {
     $game->load('countUsers');
     foreach ($conn->clients() as $client) {
         $this->send($client, 'game.update', $game);
     }
     foreach ($conn->gameClients($game) as $client) {
         $this->send($client, 'game.left', $user);
     }
 }
예제 #4
0
 /**
  * Load
  * @param string $id
  */
 public function actionLoad($id)
 {
     $game = new Game();
     $game->load($id);
     return $this->redirect(['game/play']);
 }