Esempio n. 1
0
        /// <summary>
        /// Gets a string representation of a Combination
        /// </summary>
        private string GetCombinationString(CardCombination combination)
        {
            string str = "";

            if (combination is FourEqualsCombination)
            {
                str = StringResources.fourEqual;
            }

            if (combination is BelotCombination)
            {
                str = StringResources.belot;
            }

            if (combination is SequentialCombination)
            {
                if (combination.Points == 20)
                {
                    str = StringResources.threeSeq;
                }

                if (combination.Points == 50)
                {
                    str = StringResources.fourSeq;
                }

                if (combination.Points == 100)
                {
                    str = StringResources.fiveSeq;
                }
            }

            return(str);
        }
Esempio n. 2
0
 /// <summary>
 /// Raises the CombinationAnnounced event
 /// </summary>
 protected void RaiseCardCombinationAnnounced(CardCombination combination)
 {
     if (CardCombinationAnnounced != null)
     {
         CardCombinationAnnounced(this, combination);
     }
 }
 /// <summary>
 /// Raises the CombinationAnnounced event
 /// </summary>
 protected void RaiseCardCombinationAnnounced( CardCombination combination )
 {
     if( CardCombinationAnnounced != null )
     {
         CardCombinationAnnounced( this, combination );
     }
 }
Esempio n. 4
0
        public override bool AnnounceCombination(CardCombination combination)
        {
            //TODO implement whether player wants to announce this combination


            RaiseCardCombinationAnnounced(combination);
            return(true);
        }
Esempio n. 5
0
        public void Test(string stringCards, string stringComb,
                         CardCombination expectedCardCombination)
        {
            var expected = Helper.CreateCards(stringComb);
            var comb     = new Combination(Helper.CreateCards(stringCards));

            Assert.AreEqual(expectedCardCombination, comb.CardCombination);
            Assert.AreEqual(expected, comb.FullCombination);
        }
Esempio n. 6
0
 public Poker()
 {
     combo      = new CardCombination();
     players    = new List <Player>();
     blind      = new Blind();
     deck       = new CardStack();
     bigBlind   = 1;
     smallBlind = 0;
     blind.upBlinds(50, 50);
 }
Esempio n. 7
0
 /// <summary>
 /// Raises the CardCombinationAnnouncing event
 /// </summary>
 protected bool RaiseCardCombinationAnnouncing(CardCombination combination)
 {
     if (CardCombinationAnnouncing != null)
     {
         return(CardCombinationAnnouncing(this, combination));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 8
0
        private string GetCombinationString(CardCombination combination)
        {
            StringBuilder sb = new StringBuilder();

            foreach (Card card in combination.Cards)
            {
                sb.Append(card.ToString() + " ");
            }

            return(sb.ToString());
        }
Esempio n. 9
0
        private bool HumanCardCombinationAnnouncing(Player player, CardCombination combination)
        {
            bool isAnnounced = false;

            _combinationForm.Combination = combination;
            isAnnounced = (_combinationForm.ShowDialog() == DialogResult.OK);

            if (isAnnounced)
            {
                CombinationAnnounced(player, combination);
            }

            return(isAnnounced);
        }
Esempio n. 10
0
        public void Statistics_Score_Hands()
        {
            int simulationCount  = 1000000;
            var cardCombinations = new List <CardCombination>();

            var deck  = new Deck();
            var cards = new List <Card>();

            for (int i = 0; i < simulationCount; i++)
            {
                deck.Regroup();
                deck.Shuffle();

                cards.Clear();
                for (int j = 0; j < 7; j++)
                {
                    cards.Add(deck.Draw());
                }

                var cardCombination = _combinationEvaluator.EvaluateCards(cards);
                cardCombinations.Add(cardCombination);
            }

            cardCombinations = cardCombinations.OrderByDescending(combination => combination.Score).ToList();
            var             previousCombinationType = (int)CombinationType.RoyalFlush;
            CardCombination previousCombination     = null;

            foreach (var cardCombination in cardCombinations)
            {
                if ((int)cardCombination.Type > previousCombinationType)
                {
                    var cardsString         = CardsBuilder.BuildStringFromCards(cardCombination.Cards);
                    var previousCardsString = CardsBuilder.BuildStringFromCards(cardCombination.Cards);
                    throw new Exception(
                              $"{cardsString} is a {cardCombination.Type} with {cardCombination.Score} that is lower in score than {previousCardsString}-{previousCombination.Type}-{previousCombination.Score}");
                }

                previousCombination     = cardCombination;
                previousCombinationType = (int)cardCombination.Type;
            }
        }
Esempio n. 11
0
 public override bool AnnounceCombination(CardCombination combination)
 {
     return(RaiseCardCombinationAnnouncing(combination));
 }
Esempio n. 12
0
 public void AddCombination(Player player, CardCombination combination)
 {
     _mapCombinationToPlayer.Add(combination, player);
 }
Esempio n. 13
0
        private void OnVisibleChanged(object sender, EventArgs e)
        {
            if (this.Visible)
            {
                #region _hands

                int rowsSN = 0;
                int rowsWE = 0;

                foreach (Hand hand in _hands)
                {
                    int cols = 0;
                    foreach (Card card in hand)
                    {
                        if (hand.Winner.Position == PlayerPosition.South || hand.Winner.Position == PlayerPosition.North)
                        {
                            CardPictureBox cpb = new CardPictureBox();
                            cpb.Width    = IMAGE_WIDTH;
                            cpb.Height   = IMAGE_HEIGTH;
                            cpb.Card     = card;
                            cpb.Location = new Point(cols * (IMAGE_WIDTH + PAD_WIDTH) + PAD_WIDTH, rowsSN * (IMAGE_HEIGTH + PAD_HEIGTH) + PAD_HEIGTH);

                            _panelSNHands.Controls.Add(cpb);
                        }
                        else
                        {
                            CardPictureBox cpb = new CardPictureBox();
                            cpb.Width    = IMAGE_WIDTH;
                            cpb.Height   = IMAGE_HEIGTH;
                            cpb.Card     = card;
                            cpb.Location = new Point(cols * (IMAGE_WIDTH + PAD_WIDTH) + PAD_WIDTH, rowsWE * (IMAGE_HEIGTH + PAD_HEIGTH) + PAD_HEIGTH);

                            _panelWEHands.Controls.Add(cpb);
                        }
                        cols++;
                    }

                    if (hand.Winner.Position == PlayerPosition.South || hand.Winner.Position == PlayerPosition.North)
                    {
                        rowsSN++;
                    }
                    else
                    {
                        rowsWE++;
                    }
                }

                #endregion

                #region Combinations

                int lastSNlabelTop = 0;
                int lastWElabelTop = 0;

                foreach (KeyValuePair <CardCombination, Player> kv in _mapCombinationToPlayer)
                {
                    CardCombination combination = kv.Key;
                    Player          player      = kv.Value;

                    Label labelCombination = new Label();
                    labelCombination.Text   = GetCombinationString(combination);
                    labelCombination.Width  = 160;
                    labelCombination.Height = LABEL_HEIGHT;
                    labelCombination.Font   = _labelFont;

                    Label labelPoints = new Label();
                    labelPoints.Text   = combination.Points.ToString();
                    labelPoints.Width  = 40;
                    labelPoints.Height = LABEL_HEIGHT;
                    labelPoints.Font   = _labelFont;

                    PictureBox pictureCounted = new PictureBox();
                    pictureCounted.Width    = LABEL_HEIGHT;
                    pictureCounted.Height   = LABEL_HEIGHT;
                    pictureCounted.SizeMode = PictureBoxSizeMode.StretchImage;
                    if (combination.IsCounted)
                    {
                        pictureCounted.Image = Properties.Resources.yes;
                    }
                    else
                    {
                        pictureCounted.Image = Properties.Resources.no;
                    }

                    if (player.Position == PlayerPosition.South || player.Position == PlayerPosition.North)
                    {
                        labelCombination.Location = new Point(0, lastSNlabelTop);
                        labelPoints.Location      = new Point(160, lastSNlabelTop);
                        pictureCounted.Location   = new Point(200, lastSNlabelTop);

                        _panelSNCombinations.Controls.Add(labelCombination);
                        _panelSNCombinations.Controls.Add(labelPoints);
                        _panelSNCombinations.Controls.Add(pictureCounted);
                        lastSNlabelTop += LABEL_HEIGHT;
                    }
                    else
                    {
                        labelCombination.Location = new Point(0, lastWElabelTop);
                        labelPoints.Location      = new Point(160, lastWElabelTop);
                        pictureCounted.Location   = new Point(200, lastWElabelTop);

                        _panelWECombinations.Controls.Add(labelCombination);
                        _panelWECombinations.Controls.Add(labelPoints);
                        _panelWECombinations.Controls.Add(pictureCounted);
                        lastWElabelTop += LABEL_HEIGHT;
                    }
                }

                #endregion

                _labelSNPointsReal.Text = _deal.RawNorthSouthPoints.ToString();
                _labelWEPointsReal.Text = _deal.RawEastWestPoints.ToString();
            }
        }
Esempio n. 14
0
        private void CombinationAnnounced(Player player, CardCombination combination)
        {
            _passedAnnouncesForm.AddMessage(player.Name, GetCombinationString(combination), false);

            _dealResultForm.AddCombination(player, combination);
        }