Ejemplo n.º 1
0
        protected virtual bool DeterminePair(PlayerHand ph)
        {
            bool isPair = false;

            for (int i = 1; i < 5; i++)
            {
                if (ph[i].Number == ph[i - 1].Number)
                {
                    if (ph[i].Number >= 11)
                    {
                        isPair = true;
                        break;
                    }
                }
            }

            return(isPair);
        }
Ejemplo n.º 2
0
        private void Click_btnReplace(object sender, EventArgs e)
        {
            ProcessHolds();
            btnNewHand.Enabled = true;
            btnReplace.Enabled = false;
            Card[] cs = _dealer.ReplaceCards(_cardsHeld);
            SetCards(cs);
            for (int i = 0; i < 5 - _cardsHeld; i++)
            {
                cards[locs[i]] = cs[i];
            }
            _cardsHeld = 0;
            PlayerHand ph = new PlayerHand(cards[0], cards[1], cards[2], cards[3], cards[4]);
            Hand       h  = _dealer.DetermineHand(ph);

            ulong mon;

            if (h is null)
            {
                mon = 0;
                Program.user.IncrementLosses();
            }
            else
            {
                mon = _bet * h.Multiplier;
                Program.user.IncrementWins();
                Program.user.AddWinnings(mon);
                Program.user.Money += (mon);
            }
            txtMoney.Text = Program.user.Money.ToString();

            btnNewHand.Enabled = false;

            InteractivePause(new TimeSpan(0, 0, 2));

            btnNewHand.Enabled = true;

            _ = new Result(h, mon)
            {
                Visible  = true,
                TopMost  = true,
                Location = this.Location
            };
        }
Ejemplo n.º 3
0
        public bool DetermineStraight(PlayerHand ph)
        {
            bool isStraight = true;

            for (int i = 1; i < 5; i++)
            {
                if (ph[i].Number != ph[i - 1].Number + 1)
                {
                    isStraight = false;
                    break;
                }
            }

            if (ph[0].Number == 2 && ph[1].Number == 3 && ph[2].Number == 4 && ph[3].Number == 5 && ph[4].Number == 14)
            {
                isStraight = true;
            }

            return(isStraight);
        }
Ejemplo n.º 4
0
        protected override bool DeterminePair(PlayerHand ph)
        {
            bool isPair = false;
            int  pairs  = 0;

            for (int i = 1; i < 5; i++)
            {
                if (ph[i].Number == ph[i - 1].Number)
                {
                    pairs++;
                }
            }

            if (pairs == 2)
            {
                isPair = true;
            }

            return(isPair);
        }
Ejemplo n.º 5
0
        private bool DetermineHand(PlayerHand ph)
        {
            bool hasThree = false;
            bool hasPair  = false;
            int  n        = 1;

            for (int i = 1; i < 5; i++)
            {
                if (ph[i].Number == ph[i - 1].Number)
                {
                    n++;
                    hasThree = hasThree ? true : n == 3;
                }
                else
                {
                    hasPair = hasPair ? true : n == 2;
                    n       = 1;
                }
            }
            hasPair = hasPair ? true : n == 2;

            return(hasPair && hasThree);
        }
Ejemplo n.º 6
0
        public virtual bool DetermineHand(PlayerHand ph)
        {
            bool isThree = false;
            int  n       = 1;

            for (int i = 1; i < 5; i++)
            {
                if (ph[i].Number == ph[i - 1].Number)
                {
                    n++;
                    if (n == 3)
                    {
                        isThree = true;
                        break;
                    }
                }
                else
                {
                    n = 1;
                }
            }

            return(isThree);
        }
Ejemplo n.º 7
0
 public override bool IsHand(PlayerHand ph)
 {
     return(DeterminePair(ph));
 }
Ejemplo n.º 8
0
 public override bool IsHand(PlayerHand ph)
 {
     return(DetermineStraight(ph));
 }
Ejemplo n.º 9
0
        public override bool IsHand(PlayerHand ph)
        {
            bool isSF = base.IsHand(ph);

            return(ph[0].Number == 10 && isSF);
        }