Ejemplo n.º 1
0
 public HoldemBoard(Card first, Card second, Card third)
     : base("Board")
 {
     AddCard(first);
     AddCard(second);
     AddCard(third);
 }
Ejemplo n.º 2
0
 public void AddCardToList(Card c)
 {
     if (cardListToDisplay != null)
     {
         cardListToDisplay.AddCard(c);
         ReloadGraphics();
     }
 }
Ejemplo n.º 3
0
        public CardPictureBox(Card card)
        {
            this.card = card;
            this.SizeMode = PictureBoxSizeMode.StretchImage;
            this.ClientSize = GetImageSize();
            this.heightWidthRatio = (float)ClientSize.Height / (float)ClientSize.Width;

            ReloadImage();
        }
Ejemplo n.º 4
0
        public SelectableCardPictureBox(Card card)
            : base(card)
        {
            highlighted = false;
            this.highlightTransparency = 100;
            this.highlightColor = Color.White;

            this.MouseEnter += new EventHandler(SelectableCardPictureBox_MouseEnter);
            this.MouseLeave += new EventHandler(SelectableCardPictureBox_MouseLeave);
            this.MouseClick += new MouseEventHandler(SelectableCardPictureBox_MouseClick);
        }
Ejemplo n.º 5
0
        private void btnViewAll_Click(object sender, EventArgs e)
        {
            SingleCardSelectDialog d = new SingleCardSelectDialog();
            d.ShowDialog();

            if (d.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                SelectedCard = Card.CreateFromString(d.SelectedCard);
                DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }
Ejemplo n.º 6
0
        private void ReplaceTemplateImageWith(Card matchedCard, Bitmap newImage)
        {
            // Find the path of the template associated with the card
            String targetFile = String.Format("{0}{1}", CardMatchesDirectory, matchedCard.ToFilename("bmp"));

            try
            {
                newImage.Save(targetFile, ImageFormat.Bmp);
                Trace.WriteLine("Successfully replaced " + targetFile + " with new image");
            }
            catch (Exception)
            {
                Trace.WriteLine("Warning! Tried to replace " + targetFile + " with a new image but failed because of an exception");
            }
        }
Ejemplo n.º 7
0
 public void AddCard(Card card)
 {
     cards.Add(card);
 }
Ejemplo n.º 8
0
        /* @param matching points to a card in the set of identical ones (if any) */
        public bool HaveIdenticalFaces(int numIdenticalFaces, out Card matching)
        {
            matching = null;

            for (int i = 0; i < cards.Count; i++)
            {
                int facesCount = 0;
                for (int j = i + 1; j < cards.Count; j++)
                {
                    if (cards[i].Face == cards[j].Face)
                    {
                        facesCount++;
                    }
                }

                if (facesCount >= numIdenticalFaces - 1)
                {
                    matching = cards[i];
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 9
0
        /* Checks that every possible hand is covered in the table */
        public static void TestPercentiles()
        {
            for (CardFace face1 = CardFace.Ace; face1 <= CardFace.King; face1++)
            {
                for (CardSuit suit1 = CardSuit.Clubs; suit1 <= CardSuit.Spades; suit1++)
                {
                    Card c1 = new Card(face1, suit1);

                    for (CardFace face2 = CardFace.Ace; face2 <= CardFace.King; face2++)
                    {
                        for (CardSuit suit2 = CardSuit.Clubs; suit2 <= CardSuit.Spades; suit2++)
                        {
                            Card c2 = new Card(face2, suit2);

                            HoldemHand hand = new HoldemHand(c1, c2);
                            Trace.Assert(HoldemHand.preflopPercentiles.ContainsKey(hand.ToString()), "Percentile not found for: " + hand.ToString());
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public void AddPossibleCardMatch(Card card)
 {
     cardListPanel.AddCardToList(card);
 }
Ejemplo n.º 11
0
        /* Given a string representing a card, returns the equivalent card object
           This seems to be a standard format across poker client.
           Cards are represented by two chars, the first indicating the face
         * and the second indicating the suit. Ex. Ks, Ah, etc. */
        public virtual Card GenerateCardFromString(String card)
        {
            // This should never be different than 2
            Trace.Assert(card.Length == 2, "A string representation of a card was found to be of invalid length: " + card.Length + " instead of 2");

            // Uppercase to simplify checks
            String cardValues = card.ToUpper();

            // Extract components
            Char faceComponent = cardValues[0];
            Char suitComponent = cardValues[1];

            CardFace face = Card.CharToCardFace(faceComponent);
            CardSuit suit = Card.CharToCardSuit(suitComponent);

            Card result = new Card(face, suit);
            return result;
        }
Ejemplo n.º 12
0
 public HoldemBoard(Card first, Card second, Card third, Card fourth, Card fifth)
     : this(first, second, third, fourth)
 {
     AddCard(fifth);
 }
Ejemplo n.º 13
0
 void pictureBox_CardSelected(Card c)
 {
     // bubble up
     if (CardSelected != null) CardSelected(c);
 }
Ejemplo n.º 14
0
            private PairType GetPairType(CardList communityCards, Card matching, Card firstCard, Card secondCard)
            {
                communityCards.Sort(SortUsing.AceHigh);

                // Pocket pair
                if (firstCard.Face == secondCard.Face)
                {
                    if (firstCard.GetFaceValue() >= communityCards.Last.GetFaceValue()) return PairType.Top;
                    else if (firstCard.GetFaceValue() <= communityCards[0].GetFaceValue()) return PairType.Bottom;
                    else return PairType.Middle;
                }
                else
                {
                    // Matched the board
                    if (matching.Face == communityCards.Last.Face) return PairType.Top;
                    else if (matching.Face == communityCards[0].Face) return PairType.Bottom;
                    else return PairType.Middle;
                }
            }
Ejemplo n.º 15
0
 private KickerType GetKickerTypeFromCard(Card c)
 {
     switch (c.Face)
     {
         case CardFace.Ace:
         case CardFace.King:
         case CardFace.Queen:
         case CardFace.Jack:
             return KickerType.High;
         case CardFace.Ten:
         case CardFace.Nine:
         case CardFace.Eight:
         case CardFace.Seven:
             return KickerType.Middle;
         case CardFace.Six:
         case CardFace.Five:
         case CardFace.Four:
         case CardFace.Three:
         case CardFace.Two:
             return KickerType.Low;
         default:
             return KickerType.Unknown;
     }
 }
Ejemplo n.º 16
0
 private void cardListPanel_CardSelected(Card c)
 {
     SelectedCard = c;
     DialogResult = System.Windows.Forms.DialogResult.OK;
     this.Close();               
 }
Ejemplo n.º 17
0
 public void DisplayCard(Card card)
 {
     this.card = card;
     ReloadImage();
 }
Ejemplo n.º 18
0
 public HoldemHand(Card first, Card second)
     : base()
 {
     AddCard(first);
     AddCard(second);
 }