Exemple #1
0
        public async Task <ResponseFindWinnerGameView> FindWinner(RequestFindWinnerGameView item)
        {
            int    score  = 21;
            Player player = await _playerRepository.Get(item.PlayerHand.PlayerId);

            Player dealer = await _playerRepository.Get(item.DealerHand.PlayerId);

            PlayerRoundHand playerHand = await _playerRoundHandRepository.Get(item.PlayerHand.Id);

            PlayerRoundHand dealerHand = await _playerRoundHandRepository.Get(item.DealerHand.Id);

            Round round = await _roundRepository.Get(playerHand.RoundId);

            if (playerHand.Score > score && dealerHand.Score <= score)
            {
                round.Winner      = dealer.Name;
                round.WinnerScore = dealerHand.Score;
            }
            if (dealerHand.Score <= score && dealerHand.Score > playerHand.Score)
            {
                round.Winner      = dealer.Name;
                round.WinnerScore = dealerHand.Score;
            }
            if (dealerHand.Score > score && playerHand.Score > score)
            {
                round.Winner      = "Draw";
                round.WinnerScore = 0;
            }
            if (dealerHand.Score == playerHand.Score)
            {
                round.Winner      = "Draw";
                round.WinnerScore = 0;
            }
            if (dealerHand.Score > score && playerHand.Score <= score)
            {
                round.Winner      = player.Name;
                round.WinnerScore = playerHand.Score;
            }
            if (playerHand.Score <= score && playerHand.Score > dealerHand.Score)
            {
                round.Winner      = player.Name;
                round.WinnerScore = playerHand.Score;
            }
            await _roundRepository.Update(round);

            var result = new ResponseFindWinnerGameView();

            result.Round = _maping.MapRoundToRoundFindWinnerGameViewItem(round);
            return(result);
        }
        public async Task <ResponseFindWinnerGameView> FindWinner(RequestFindWinnerGameView item)
        {
            ResponseFindWinnerGameView model = await _gameService.FindWinner(item);

            return(model);
        }