Example #1
0
        public GameViewModel GetLastRoundInfo()
        {
            Game game = _gameRepository.GetContinueableGame(_userId);

            if (game == null)
            {
                throw new InvalidOperationException("Game is not found");
            }
            List <RoundPlayer> lastRoundInfo = _roundPlayerRepository.GetLastRoundInfo(game.Id).ToList();

            _cardRepository.FillRoundPlayersCards(lastRoundInfo);
            List <PlayerGameViewModel> players = Mapper.Map <List <RoundPlayer>, List <PlayerGameViewModel> >(lastRoundInfo);

            if (players[0].State == RoundPlayerState.None)
            {
                PlayerGameViewModel dealer = players[players.Count - 1];
                dealer.Cards[1] = Constants.BlankCardCode;
                dealer.Score    = 0;
            }
            var roundInfo = new GameViewModel {
                Players = players
            };

            return(roundInfo);
        }