예제 #1
0
        public Deck()
        {
            cards = new Card[52];
            top = 51;
            int index = 0;

            for (int k = 0; k < cards.Length; k++)
            {
                cards[k] = new Card();
            }

            for (int i = 0; i < 4; i++)
            {
                for (int j = 2; j < 15; j++)
                {
                    cards[index].Suit = i;
                    cards[index].Rank = j;
                    index++;
                }
            }
        }
예제 #2
0
 bool CFStraightFlush()
 {
     Dictionary<int, Card> c = new Dictionary<int, Card>();
     for (int x = 0; x < cards.Count; x++)
     {
         if (c.ContainsValue(cards[x]))
             c.Add(cards[x].value, cards[x]);
     }
     List<Card> str = new List<Card>();
     int last = 0;
     int lasts = 0;
     bool acepresent = false;
     List<int> acesuites = new List<int>();
     foreach (KeyValuePair<int, Card> card in c)
     {
         if (last == 0)
         {
             if (card.Key == 1)
             {
                 acepresent = true;
                 acesuites.Add(card.Value.suit);
             }
             last = card.Key;
             str.Add(new Card(1, lasts));
             last = card.Value.suit;
         }
         else if (last + 1 == card.Key && lasts == card.Value.suit)
         {
             last++;
             str.Add(card.Value);
             if (acepresent && card.Key == 13)
             {
                 for (int x = 0; x < acesuites.Count; x++)
                 {
                     if (acesuites[x] == lasts)
                     {
                         str.Add(new Card(1, lasts));
                     }
                 }
             }
         }
         else
         {
             str.Clear();
             last = 0;
             lasts = 0;
         }
     }
     c.Clear();
     if (str.Count >= 5)
     {
         for (int x = str.Count - 5; x < str.Count; x++)
         {
             highcard = str[x];
             if (highcard.value == 1)
                 highcard.value = 14;
             MoveCardToRelavant(str[x].suit, str[x].value);
         }
         str.Clear();
         return true;
     }
     str.Clear();
     return false;
 }
예제 #3
0
 public void AddCard(Card c)
 {
     cards.Add(c);
 }
예제 #4
0
 bool CFFullHouse()
 {
     Dictionary<int, int> c = new Dictionary<int, int>();
     for (int x = 0; x < cards.Count; x++)
     {
         if (c.ContainsKey(cards[x].value))
             c[cards[x].value]++;
         else
             c.Add(cards[x].value, 1);
     }
     bool three = false;
     bool two = false;
     List<Card> relavant = new List<Card>();
     foreach (KeyValuePair<int, int> card in c)
     {
         if (card.Value == 3)
         {
             three = true;
             foreach (Card ca in cards)
             {
                 if (card.Key == ca.value)
                     relavant.Add(ca);
             }
         }
         else if (card.Value == 2)
         {
             two = true;
             foreach (Card ca in cards)
             {
                 if (card.Key == ca.value)
                     relavant.Add(ca);
             }
         }
     }
     if (three && two)
     {
         foreach (Card ca in relavant)
         {
             if (highcard.value < ca.value)
                 highcard = ca;
             MoveCardToRelavant(ca.suit, ca.value);
         }
         return true;
     }
     return false;
 }
예제 #5
0
 bool CFFourOfAKind()
 {
     Dictionary<int, int> count = new Dictionary<int, int>();
     foreach (Card card in cards)
     {
         if (count.ContainsKey(card.value))
             count[card.value]++;
         else
             count.Add(card.value, 1);
     }
     foreach (KeyValuePair<int, int> c in count)
     {
         if (c.Value == 4)
         {
             foreach (Card card in cards)
             {
                 if (card.value == c.Key)
                 {
                     highcard = card;
                     MoveCardToRelavant(card.suit, card.value);
                 }
             }
             return true;
         }
     }
     return false;
 }
예제 #6
0
 public void SetCard(Card c, int cardNum)
 {
     hand.Set(c, cardNum);
 }
예제 #7
0
 public void Set(Card c, int cardNum)
 {
     hand[cardNum] = c;
 }