public async Task <ResponseGetDeallerCardGameView> GetDeallerCard(RequestGetDeallerCardGameView requestGetDeallerCardGameView) { Game game = await _gameRepository.GetGameWithPlayerGames(requestGetDeallerCardGameView.GameId); Hand hand = await _handRepository.GetHandWithCardsByRoundAndPlayerId(requestGetDeallerCardGameView.RoundId, requestGetDeallerCardGameView.PlayerId); if (game == null || hand == null) { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(string.Format("RoundId: {0}", requestGetDeallerCardGameView.RoundId)); stringBuilder.AppendLine(string.Format("PlayerId: {0}", requestGetDeallerCardGameView.PlayerId)); stringBuilder.AppendLine(string.Format("GameId: {0}", requestGetDeallerCardGameView.GameId)); stringBuilder.AppendLine(string.Format("Message: {0}", SolutionConstants.BUSINESS_LOGIC_GET_ITEM_EXCEPTION_MESSAGE)); string message = stringBuilder.ToString(); throw new BusinessLogicGetItemException(message); } Deck infinityDeck = await _deckProvider.GetAllDeckFromCache(game.Id); List <Card> handCards = hand.HandCards.Select(item => item.Card).ToList(); Card card = DeckExtension.GetCard(infinityDeck); handCards.Add(card); hand.Summary += _gameUtility.GetCardValue(card.Face); if (handCards.Count == GameConstants.TWO_CARDS) { hand.VictoryType = _gameUtility.CheckTypeOfVictory(handCards); if (hand.VictoryType == VictoryType.GoldenPoint) { hand.Summary = GameConstants.BLACKJACK; } } await _handRepository.Update(hand); var handCard = new HandCard(); handCard.CardId = card.Id; handCard.HandId = hand.Id; await _handCardRepository.Create(handCard); _deckProvider.SetDeckInMemoryCashe(game.Id, infinityDeck); var responseView = new ResponseGetDeallerCardGameView(); responseView.HandId = hand.Id; responseView.Card = _mapper.Map <Card, CardGetDeallerCardGameViewItemItem>(card); responseView.Summary = hand.Summary; return(responseView); }
public async Task <ResponseGetDeallerCardGameView> GetDeallerCard([FromBody] RequestGetDeallerCardGameView requestGetDeallerCardGameView) { ResponseGetDeallerCardGameView responseGetDeallerCardGameView = await _gameLogicService.GetDeallerCard(requestGetDeallerCardGameView); return(responseGetDeallerCardGameView); }