public async Task <ResponseDoubleGameView> GetDoubleGameView(long playerId, long sessionId) { (Player player, Player dealer, IEnumerable <Player> bots) = await _gameManager.GetAllGamePlayers(playerId, sessionId); ResponseDoubleGameView gameView = DoubleGameViewMapper.GetDoubleGameView(sessionId, dealer, player, bots); IEnumerable <Card> playerCards = await _gameManager.GetCards(player.Id, sessionId); IEnumerable <Card> dealerCards = await _gameManager.GetCards(dealer.Id, sessionId); int playerScore = await _gameManager.GetHandScore(player.Id, sessionId); int dealerScore = await _gameManager.GetHandScore(dealer.Id, sessionId); gameView.Player.Hand = DoubleGameViewMapper.GetHandDoubleGameViewItem(playerCards, playerScore); gameView.Dealer.Hand = DoubleGameViewMapper.GetHandDoubleGameViewItem(dealerCards, dealerScore); (int playerGameState, string playerGameResult) = _gameResultManager.GetGameStateResult(playerScore, dealerScore); gameView.Player.GameResult.State = playerGameState; gameView.Player.GameResult.Result = playerGameResult; foreach (var bot in gameView.Bots) { IEnumerable <Card> botCards = await _gameManager.GetCards(bot.Id, sessionId); int botScore = await _gameManager.GetHandScore(bot.Id, sessionId); (int botGameState, string botGameResult) = _gameResultManager.GetGameStateResult(botScore, dealerScore); bot.Hand = DoubleGameViewMapper.GetHandDoubleGameViewItem(botCards, botScore); bot.GameResult.State = botGameState; bot.GameResult.Result = botGameResult; } return(gameView); }
public static ResponseDoubleGameView GetDoubleGameView(long sessionId, Player dealer, Player player, IEnumerable <Player> bots) { var responseDoubleGameView = new ResponseDoubleGameView { Player = GetPlayerDoubleGameViewItem(player), Dealer = GetDealerDoubleGameViewItem(dealer), Bots = GetPlayerDoubleGameViewItems(bots), SessionId = sessionId }; return(responseDoubleGameView); }
public async Task <IHttpActionResult> Double([FromBody] RequestDoubleGameView request) { try { ResponseDoubleGameView view = await _service.Double(request.PlayerId, request.SessionId); return(Ok(view)); } catch (Exception exception) { Log.Error(exception.Message); return(InternalServerError(exception)); } }
public async Task <ResponseDoubleGameView> Double(long playerId, long sessionId) { await _historyManager.Create(playerId, UserMessages.ChoseToDoubleMessage, sessionId); await GiveCards(1, playerId, sessionId); await GiveCardsToBots(sessionId); await GiveCardsToDealer(sessionId); ResponseDoubleGameView gameView = await _gameViewManager.GetDoubleGameView(playerId, sessionId); await _sessionManager.Close(sessionId); return(gameView); }