예제 #1
0
        private async Task DistributeEndCardsForDealer(GamePlayer dealer)
        {
            var         createdPlayerCards = new List <PlayerCard>();
            List <Card> deck = await _cardRepository.GetSpecifiedAmount(CardValue.AmountOfEndCardsForDealer);

            for (int iterator = deck.Count(); iterator > 0 && dealer.CardScore < CardValue.MaxDealerCardScore; iterator--)
            {
                Card       card = PopCardsFromDeck(deck, CardValue.OneCard).First();
                PlayerCard createdPlayerCard = CustomMapper.MapPlayerCard(dealer, card);
                dealer.PlayerCards.Add(createdPlayerCard);
                createdPlayerCards.Add(createdPlayerCard);
                dealer.CardScore = CountCardScore(dealer.PlayerCards);
            }

            await _gamePlayerRepository.Update(dealer);

            await _playerCardRepository.CreateMany(createdPlayerCards);
        }