Exemplo n.º 1
0
        public async Task <IHttpActionResult> ContinueRound(ContinueRoundRequestViewModel continueRoundRequestViewModel)
        {
            try
            {
                if (continueRoundRequestViewModel == null)
                {
                    return(BadRequest(GameMessageHelper.ReceivedDataError));
                }

                ContinueRoundResponseViewModel continueRoundResponseViewModel = await _gameService.ContinueRound(continueRoundRequestViewModel);

                return(Ok(continueRoundResponseViewModel));
            }
            catch (Exception ex)
            {
                string message = $"{ex.Source}|{ex.TargetSite}|{ex.StackTrace}|{ex.Message}";
                _logger.Error(message);
                return(BadRequest(GameMessageHelper.GameError));
            }
        }
Exemplo n.º 2
0
        public async Task <ContinueRoundResponseViewModel> ContinueRound(ContinueRoundRequestViewModel continueRoundRequestViewModel)
        {
            List <GamePlayer> players = (await _gamePlayerRepository.GetAllWithCards(continueRoundRequestViewModel.GameId)).ToList();

            if (continueRoundRequestViewModel.ContinueRound)
            {
                players.Where(m => m.Player.Type == (int)PlayerType.Human).First().BetPayCoefficient = BetValueHelper.DefaultCoefficient;
            }

            List <PlayerCard> playerCardsInserted = await DistributeSecondCards(players, continueRoundRequestViewModel.GameId);

            _gamePlayerProvider.DefinePayCoefficientsAfterRoundContinue(players);
            await _gamePlayerRepository.UpdateManyAfterContinueRound(players);

            await _gameRepository.UpdateStage(continueRoundRequestViewModel.GameId, (int)GameStage.ContinueRound);

            List <Log> logs = LogHelper.GetContinueRoundLogs(players, playerCardsInserted, continueRoundRequestViewModel.GameId);
            await _logRepository.CreateMany(logs, ToStringHelper.GetTableName(typeof(Log)));

            ContinueRoundResponseViewModel continueRoundResponseViewModel = GetContinueRoundResponse(players);

            return(continueRoundResponseViewModel);
        }