/** * Load User * @return string * @throws HttpException */ public function actionGetUser() { $fight = Fight::findOne(Yii::$app->request->post('fight')); if (!$fight) { throw new HttpException(404); } /*if(!$fight->check(Yii::$app->request->post('user'))){ throw new HttpException(403); }*/ $game = new Game(); $player = new Player(); $player->setIndex(2); $player->initialize($fight->user); $game->setPlayer2($player); return $this->render('player', ['game' => $game, 'player' => $player]); }
public function actionStart() { $response = ['status' => 0, 'message' => '', 'redirect' => '']; $fight = Fight::findOne(Yii::$app->request->post('id')); if (!$fight) { throw new HttpException(404); } if (Fight::STATUS_NEW != $fight->status) { $response['message'] = 'Игра уже началась'; } else { if ($fight->connect()) { $response['status'] = 1; $response['redirect'] = $fight->getUrl(); } } return json_encode($response); }
/** * Fight Action */ public function actionFight() { $fight = Fight::findOne(Yii::$app->request->get('id')); if (!$fight) { throw new HttpException(404); } /*if(!$fight->check()){ throw new HttpException(403); }*/ return $this->render('fight', ['model' => $fight]); }