public async Task SetDealBotAndDealler(SetDealBotAndDeallerGameView setDealBotAndDeallerGameView) { Player player = await _playerRepository.Get(setDealBotAndDeallerGameView.PlayerId); Round round = await _roundRepository.Get(setDealBotAndDeallerGameView.RoundId); if (player == null || round == null) { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(string.Format("RoundId: {0}", setDealBotAndDeallerGameView.RoundId)); stringBuilder.AppendLine(string.Format("PlayerId: {0}", setDealBotAndDeallerGameView.PlayerId)); stringBuilder.AppendLine(string.Format("Message: {0}", SolutionConstants.BUSINESS_LOGIC_GET_ITEM_EXCEPTION_MESSAGE)); string message = stringBuilder.ToString(); throw new BusinessLogicGetItemException(message); } if (player.Coins < GameConstants.BOTS_MINIMUM_COINS) { player.Coins = GameConstants.BOTS_COINS; await _playerRepository.Update(player); } var random = new Random(); int dealCoins = random.Next(GameConstants.MINIMUM_DEAL_COINS_FOR_BOT, GameConstants.MAXIMUM_DEAL_COINS_FOR_BOT); var hand = new Hand(); hand.Summary = GameConstants.DEFAULT_SUMMARY_AT_START; hand.Situation = Situation.None; hand.Deal = dealCoins; hand.PlayerId = player.Id; hand.RoundId = round.Id; await _handRepository.Create(hand); }
public async Task SetDealBotAndDealler([FromBody] SetDealBotAndDeallerGameView setDealBotAndDeallerGameView) { await _gameLogicService.SetDealBotAndDealler(setDealBotAndDeallerGameView); }