示例#1
0
 public HoldemBoard(Card first, Card second, Card third)
     : base("Board")
 {
     AddCard(first);
     AddCard(second);
     AddCard(third);
 }
示例#2
0
 public void AddCardToList(Card c)
 {
     if (cardListToDisplay != null)
     {
         cardListToDisplay.AddCard(c);
         ReloadGraphics();
     }
 }
示例#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();
        }
        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);
        }
        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();
            }
        }
示例#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");
            }
        }
示例#7
0
 public void AddCard(Card card)
 {
     cards.Add(card);
 }
示例#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;
        }
示例#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());
                        }
                    }
                }
            }
        }
示例#10
0
 public void AddPossibleCardMatch(Card card)
 {
     cardListPanel.AddCardToList(card);
 }
示例#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;
        }
示例#12
0
 public HoldemBoard(Card first, Card second, Card third, Card fourth, Card fifth)
     : this(first, second, third, fourth)
 {
     AddCard(fifth);
 }
 void pictureBox_CardSelected(Card c)
 {
     // bubble up
     if (CardSelected != null) CardSelected(c);
 }
示例#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;
                }
            }
示例#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;
     }
 }
示例#16
0
 private void cardListPanel_CardSelected(Card c)
 {
     SelectedCard = c;
     DialogResult = System.Windows.Forms.DialogResult.OK;
     this.Close();               
 }
示例#17
0
 public void DisplayCard(Card card)
 {
     this.card = card;
     ReloadImage();
 }
示例#18
0
 public HoldemHand(Card first, Card second)
     : base()
 {
     AddCard(first);
     AddCard(second);
 }