Exemplo n.º 1
0
        public void Step()
        {
            Game game = _gameRepository.GetContinueableGame(_userId);

            if (game == null)
            {
                throw new InvalidOperationException("Game is not found");
            }
            RoundPlayer user       = _roundPlayerRepository.GetLastRoundPlayerInfo(game.Id, _userId);
            List <Card> roundCards = _cardRepository.GetLastRoundCards(game.Id).ToList();

            if (user.State != RoundPlayerState.None)
            {
                throw new InvalidOperationException("Player can\'t to step when RoundState != None");
            }
            List <long> shuffledCards   = GetShuffledCards(roundCards);
            var         roundPlayerCard = new RoundPlayerCard {
                RoundPlayerId = user.Id, CardId = shuffledCards[0]
            };

            _roundPlayerCardRepository.Add(roundPlayerCard);
            if (!IsStepPossible(game))
            {
                Skip();
            }
        }