Esempio n. 1
0
        public async Task <ResponseGetCardGameView> GetCard(RequestGetCardGameView model)
        {
            var result = new ResponseGetCardGameView();

            if (!(await HandValidation(model.Hand.PlayerId)))
            {
                throw new WrongDataException("Your Data is incorrect");
            }

            Random          random          = new Random((int)DateTime.Now.Ticks);
            Stack <Card>    mixCards        = new Stack <Card>(CardGenerator().OrderBy(x => random.Next()));
            PlayerRoundHand playerRoundHand = await _playerRoundHandRepository.GetPlayerRoundHandByPlayerAndRoundId(model.Hand.PlayerId, model.Round.Id);

            Card card = GetCard(mixCards);

            playerRoundHand.Score += (int)card.Value;
            await SaveHands(card, playerRoundHand.Id);

            await _playerRoundHandRepository.Update(playerRoundHand);

            result.Hand = _maping.MapPlayerRoundHandToPlayerRoundHandGetCardGameViewItem(playerRoundHand, await _cardRepository.GetPlayerRoundHandCards(playerRoundHand.Id));
            return(result);
        }
        public async Task <ResponseGetCardGameView> GetCard(RequestGetCardGameView item)
        {
            ResponseGetCardGameView model = await _gameService.GetCard(item);

            return(model);
        }