Ejemplo n.º 1
0
        public static bool IsCardPlayable(Card playersCard, Card tableCard)
        {
            if (tableCard == null) // no cards down, so can play anything
            {
                return true;
            }

            return Rules[tableCard.Rank].Contains(playersCard.Rank);
        }
Ejemplo n.º 2
0
 public static bool AreAnyCardsPlayable(List<Card> playersCards, Card tableCard)
 {
     return playersCards.Any(playersCard => IsCardPlayable(playersCard, tableCard));
 }
Ejemplo n.º 3
0
        private void RemoveCardFromHand(Card card)
        {
            Card matchingInHandCard = CurrentPlayer.Hand.InHandCards.SingleOrDefault(o => o.Rank == card.Rank && o.Suit == card.Suit);

            if (matchingInHandCard != null)
            {
                CurrentPlayer.Hand.InHandCards.Remove(matchingInHandCard);
                return;
            }

            Card matchingFaceUpCard = CurrentPlayer.Hand.FaceUpCards.SingleOrDefault(o => o.Rank == card.Rank && o.Suit == card.Suit);

            if (matchingFaceUpCard != null)
            {
                CurrentPlayer.Hand.FaceUpCards.Remove(matchingFaceUpCard);
                return;
            }

            Card matchingFaceDownCard = CurrentPlayer.Hand.FaceDownCards.SingleOrDefault(o => o.Rank == card.Rank && o.Suit == card.Suit);

            if (matchingFaceDownCard != null)
            {
                CurrentPlayer.Hand.FaceDownCards.Remove(matchingFaceDownCard);
            }
        }