Beispiel #1
0
        private void ValidatePlayedCards(Guid playerId, List <Card> cards)
        {
            Player player = Players.Single(o => o.Id.Equals(playerId));

            if (!player.IsThisPlayersTurn)
            {
                throw new InvalidOperationException("It's not this player's turn. ");
            }

            if (cards.Count > 1 && !RuleEngine.AreAllCardsEqual(cards))
            {
                throw new InvalidOperationException("Can only play cards of the same rank. ");
            }

            Card topOfPickUpPack = PickUpPack != null && PickUpPack.Count > 0 ? PickUpPack.Last() : null;

            if (!RuleEngine.IsCardPlayable(cards[0], topOfPickUpPack))
            {
                throw new InvalidCardException("Can't play a " + cards[0].Rank);
            }
        }
Beispiel #2
0
        private void CheckNextPlayerCanPlay()
        {
            var         nextPlayer      = GetNextPlayer();
            List <Card> inPlayCards     = GetActiveHandPart(nextPlayer);
            Card        topOfPickUpPack = PickUpPack != null && PickUpPack.Count > 0 ? PickUpPack.Last() : null;

            nextPlayer.IsAbleToPlay = nextPlayer.PlayerState.Equals(PlayerState.PlayingFaceDownCards) || RuleEngine.AreAnyCardsPlayable(inPlayCards, topOfPickUpPack);
        }