Example #1
0
        public IActionResult Start(string userId, int gameId)
        {
            try
            {
                Game game;

                var isExist = _gameService.Exist(userId);
                if (isExist)
                {
                    game = _gameService.GetCurrentGame(userId);
                }
                else
                {
                    game = _gameService.GetNewGame(userId);
                }
                game.Id = gameId;

                _deckService.Shuffle(game);
                _deckService.Deal(game, ConstantsList.maxPlayerCards);

                string url = ConstantsList.gameStartUrl + userId;
                return(Redirect(url));
            }
            catch (Exception e)
            {
                return(BadRequest(e.ToString()));
            }
        }