示例#1
0
 // function to compute the difference between two cards by face value used by rankhand function
 private int Difference(Card card1, Card card2)
 {
     return Math.Abs((int)card1.RANK - (int)card2.RANK);
 }
示例#2
0
 // function to remove a single card from the hand.
 public List<Card> RemoveCard(Card cardToRemove)
 {
     // if hand contains the card.  then remove it.
     if (hand.Contains(cardToRemove))
         hand.Remove(cardToRemove);
     return hand;
 }
示例#3
0
 private static int CompareCardsByRank(Card x, Card y)
 {
     int xrank = (int)x.RANK;
     int yrank = (int)y.RANK;
     if (xrank == yrank)
         return 0;
     if (xrank > yrank)
         return -1;
     else
         return 1;
 }
示例#4
0
        // should probably change this to do a binary search.
        public bool ContainsSuit(Card.Suit suit)
        {
            foreach (Card item in hand)
            {
                if (item.SUIT.Equals(suit))
                    return true;

            }
            return false;
        }
示例#5
0
        // should probably change this to do a binary search....rather than linear
        public bool ContainsRank(Card.Rank rank)
        {
            foreach (Card item in hand)
            {
                if (item.RANK.Equals(rank))
                    return true;

            }
            return false;
        }
示例#6
0
 public void AddCard(Card cardToAdd)
 {
     // if the hand doesn't contain the card....go ahead and add it to the hand.
     if (!hand.Contains(cardToAdd))
     {
         if (hand.Count < MaxHandSize)
             hand.Add(cardToAdd);
         else
         {
             //throw new Exception("Error: Tried to add too many cards to the current hand than specified by maxCapacity" +
             //    "\n\nyou should not see this error...there is a major problem");
             //System.Windows.Forms.MessageBox.Show("Tried to add a card to the hand that already exists in the hand.");
         }
     }
 }
示例#7
0
 public Deck()
 {
     deck = new List<Card>();
     // code to iterate through both enumerations of suit and card and add each pair to the deck.
     foreach (Card.Suit suit in Enum.GetValues(typeof(Card.Suit)))
     {
         foreach (Card.Rank rank in Enum.GetValues(typeof(Card.Rank)))
         {
             Card card = new Card(suit, rank);
             deck.Add(card);
         }
     }
 }
示例#8
0
            public Bins()
            {
                pair = new Hand(2, 5);
                twoPair = new Hand(4, 5);
                threeKind = new Hand(3, 5);
                straight = new Hand(5, 5);
                fourKind = new Hand(4, 5);
                fullHouse = new Hand(5, 5);

                // this probably isnt the way to do this...
                highCard = new Card();
                pair.HAND = new List<Card>();
                pair.HAND.Capacity = 2;
                twoPair.HAND = new List<Card>();
                twoPair.HAND.Capacity = 4;
                threeKind.HAND = new List<Card>();
                threeKind.HAND.Capacity = 3;
                straight.HAND = new List<Card>();
                straight.HAND.Capacity = 5;
                flush = new List<Card>[5, 1];
                for (int i = 0; i < 5; i++)
                {
                    flush[i, 0] = new List<Card>();
                    flush[i, 0].Capacity = 5;
                }
                fullHouse.HAND = new List<Card>();
                fullHouse.HAND.Capacity = 5;
                fourKind.HAND = new List<Card>();
                fourKind.HAND.Capacity = 4;
                straightFlush = new List<Card>[5, 1];
                for (int i = 0; i < 5; i++)
                {
                    straightFlush[i, 0] = new List<Card>();
                    straightFlush[i, 0].Capacity = 5;
                }
            }