Пример #1
0
        private bool ValidPlayCard(Card card, Player player, Trick trick)
        {
            if (trick.Count == 0)
            {
                if (TurnNumber == 1)
                {
                    return(card.Suit == Suit.Clubs && card.CardRank == 2);
                }
                else
                {
                    if (card.Suit == Suit.Hearts || (card.Suit == Suit.Spades && card.CardRank == 12))
                    {
                        return(CanLeadWithHearts);
                    }
                }
            }

            //If they match the suit its valid
            if (card.Suit == trick.LeadSuit)
            {
                return(true);
            }

            //If they don't match the suit and their hand is not void of the suit, its a bad play
            if (player.HasSuit(trick.LeadSuit))
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
 public bool WinTrick(Trick trick)
 {
     TricksWon.Add(trick);
     _cardsWon.AddRange(trick.OrderedCards);
     if (trick.GetPenaltyPoints() == 26)
     {
         return(false);
     }
     else
     {
         Points += trick.GetPenaltyPoints();
         return(true);
     }
 }
Пример #3
0
        private bool ValidPlayCard(Card card, Player player, Trick trick)
        {
            //First turn has special rules, cannot play a hearts or Qspades. If the player only has the Qspades/hearts then they can play them
            if (TurnNumber == 1)
            {
                if (card.Suit == Suit.Hearts || (card.Suit == Suit.Spades && card.CardRank == Card.QUEEN))
                {
                    if (HasNoValidFirstTurnPlay(player.Hand))
                    {
                        return(true);
                    }
                }
            }

            //Check if the player can lead with hearts as the first play of the trick
            if (trick.Count == 0)
            {
                if (card.Suit == Suit.Hearts || (card.Suit == Suit.Spades && card.CardRank == Card.QUEEN))
                {
                    return(CanLeadWithHearts);
                }
                return(true);
            }

            //If they match the suit its valid
            if (card.Suit == trick.LeadSuit)
            {
                return(true);
            }

            //If they don't match the suit and their hand is not void of the suit, its a bad play
            if (player.HasSuit(trick.LeadSuit))
            {
                return(false);
            }

            return(true);
        }
Пример #4
0
 /// <summary>
 /// Do not add directly to trick.
 /// Returns card that this AI will play
 /// </summary>
 /// <param name="currentTrick"></param>
 public abstract Card GetPlayCard(Trick currentTrick);
Пример #5
0
 /// <summary>
 /// Do not add directly to trick.
 /// Returns card that this AI will play. The card returned will automatically be
 /// removed from your hand.
 /// The two of clubs will be automatically played if you are the lead player, so no need to
 /// implement that into your logic.
 /// </summary>
 public abstract Card GetPlayCard(int trickNumber, Trick currentTrick);