public void AddPlayer(IPokerPlayer p)
 {
     lock (m_GamePlayers)
     {
         m_GamePlayers.Add(p.TableId,(RemotePlayer)p);
     }
 }
Example #2
0
        public void StraightFlush(
            IPokerPlayer pokerPlayer,
            int[] clubes,
            int[] dimonds,
            int[] hearts,
            int[] spades,
            ref List <Type> Win,
            ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                if (clubes.Length >= 5)
                {
                    CheckForStraightFlush(pokerPlayer, clubes, Win, out sorted);
                }

                if (dimonds.Length >= 5)
                {
                    CheckForStraightFlush(pokerPlayer, dimonds, Win, out sorted);
                }

                if (hearts.Length >= 5)
                {
                    CheckForStraightFlush(pokerPlayer, hearts, Win, out sorted);
                }

                if (spades.Length >= 5)
                {
                    CheckForStraightFlush(pokerPlayer, spades, Win, out sorted);
                }
            }
        }
 public void RemovePlayer(IPokerPlayer p)
 {
     lock (m_GamePlayers)
     {
         m_GamePlayers.Remove(p.TableId);
     }
 }
Example #4
0
        public void Flush(
            IPokerPlayer pokerPlayer,
            Label sStatus,
            int name,
            int neededChipsToCall,
            TextBox potStatus,
            ref int raise,
            ref bool raising,
            ref int rounds)
        {
            int fCall  = this.randomGenerator.Next(2, 6);
            int fRaise = this.randomGenerator.Next(3, 7);

            this.Smooth(
                pokerPlayer,
                sStatus,
                name,
                fCall,
                fRaise,
                neededChipsToCall,
                potStatus,
                ref raise,
                ref raising,
                ref rounds);
        }
Example #5
0
        public void Straight(
            IPokerPlayer pokerPlayer,
            int[] Straight,
            ref List <Type> Win,
            ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                var kind = Straight.Select(o => o / 4).Distinct().ToArray();

                for (int index = 0; index < kind.Length - 4; index++)
                {
                    if (kind[index] + 4 == kind[index + 4])
                    {
                        if (kind.Max() - 4 == kind[index])
                        {
                            RankHand(pokerPlayer, Win, kind.Max(), 4, out sorted);
                        }
                        else
                        {
                            RankHand(pokerPlayer, Win, kind[index + 4], 4, out sorted);
                        }
                    }

                    if (kind[index] == 0 && kind[index + 1] == 9 && kind[index + 2] == 10 && kind[index + 3] == 11 &&
                        kind[index + 4] == 12)
                    {
                        RankHand(pokerPlayer, Win, 13, 4, out sorted);
                    }
                }
            }
        }
Example #6
0
        public void StraightFlush(
            IPokerPlayer pokerPlayer,
            int[] clubes,
            int[] dimonds,
            int[] hearts,
            int[] spades,
            ref List<Type> Win,
            ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                if (clubes.Length >= 5)
                {
                    CheckForStraightFlush(pokerPlayer, clubes, Win, out sorted);
                }

                if (dimonds.Length >= 5)
                {
                    CheckForStraightFlush(pokerPlayer, dimonds, Win, out sorted);
                }

                if (hearts.Length >= 5)
                {
                    CheckForStraightFlush(pokerPlayer, hearts, Win, out sorted);
                }

                if (spades.Length >= 5)
                {
                    CheckForStraightFlush(pokerPlayer, spades, Win, out sorted);
                }
            }
        }
Example #7
0
 public void AddPlayer(IPokerPlayer p)
 {
     lock (m_GamePlayers)
     {
         m_GamePlayers.Add(p.TableId, (RemotePlayer)p);
     }
 }
Example #8
0
        public void StraightFlush(
            IPokerPlayer pokerPlayer,
            Label sStatus,
            int name,
            int neededChipsToCall,
            TextBox potStatus,
            ref int raise,
            ref bool raising,
            ref int rounds)
        {
            int sfCall  = this.randomGenerator.Next(1, 3);
            int sfRaise = this.randomGenerator.Next(1, 3);

            if (pokerPlayer.Power <= 913 && pokerPlayer.Power >= 804)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    sfCall,
                    sfRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }
        }
Example #9
0
        public void FourOfAKind(
            IPokerPlayer pokerPlayer,
            Label sStatus,
            int name,
            int neededChipsToCall,
            TextBox potStatus,
            ref int raise,
            ref bool raising,
            ref int rounds)
        {
            int fkCall  = this.randomGenerator.Next(1, 4);
            int fkRaise = this.randomGenerator.Next(2, 5);

            if (pokerPlayer.Power <= 752 && pokerPlayer.Power >= 704)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    fkCall,
                    fkRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }
        }
Example #10
0
        public void Straight(
            IPokerPlayer pokerPlayer,
            Label sStatus,
            int name,
            int neededChipsToCall,
            TextBox potStatus,
            ref int raise,
            ref bool raising,
            ref int rounds)
        {
            int sCall  = this.randomGenerator.Next(3, 6);
            int sRaise = this.randomGenerator.Next(3, 8);

            if (pokerPlayer.Power <= 480 && pokerPlayer.Power >= 410)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    sCall,
                    sRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }

            if (pokerPlayer.Power <= 409 && pokerPlayer.Power >= 407)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    sCall,
                    sRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }

            if (pokerPlayer.Power < 407 && pokerPlayer.Power >= 404)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    sCall,
                    sRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }
        }
Example #11
0
        public void ThreeOfAKind(
            IPokerPlayer pokerPlayer,
            Label sStatus,
            int name,
            int neededChipsToCall,
            TextBox potStatus,
            ref int raise,
            ref bool raising,
            ref int rounds)
        {
            int tCall  = this.randomGenerator.Next(3, 7);
            int tRaise = this.randomGenerator.Next(4, 8);

            if (pokerPlayer.Power <= 390 && pokerPlayer.Power >= 330)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    tCall,
                    tRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }

            if (pokerPlayer.Power <= 327 && pokerPlayer.Power >= 321)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    tCall,
                    tRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }

            if (pokerPlayer.Power < 321 && pokerPlayer.Power >= 303)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    tCall,
                    tRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }
        }
Example #12
0
        public void TwoPair(
            IPokerPlayer pokerPlayer,
            Label sStatus,
            int neededChipsToCall,
            TextBox potStatus,
            ref int raise,
            ref bool raising,
            ref int rounds)
        {
            int rCall  = this.randomGenerator.Next(6, 11);
            int rRaise = this.randomGenerator.Next(6, 11);

            if (pokerPlayer.Power <= 290 && pokerPlayer.Power >= 246)
            {
                this.playerActions.PH(
                    pokerPlayer,
                    sStatus,
                    rCall,
                    3,
                    rRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    rounds);
            }

            if (pokerPlayer.Power <= 244 && pokerPlayer.Power >= 234)
            {
                this.playerActions.PH(
                    pokerPlayer,
                    sStatus,
                    rCall,
                    4,
                    rRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    rounds);
            }

            if (pokerPlayer.Power < 234 && pokerPlayer.Power >= 201)
            {
                this.playerActions.PH(
                    pokerPlayer,
                    sStatus,
                    rCall,
                    4,
                    rRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    rounds);
            }
        }
Example #13
0
 public void Check(
     IPokerPlayer pokerPlayer, 
     Label cStatus, 
     ref bool raising)
 {
     cStatus.Text = "Check";
     pokerPlayer.AbleToMakeTurn = false;
     raising = false;
 }
Example #14
0
 public void Check(
     IPokerPlayer pokerPlayer,
     Label cStatus,
     ref bool raising)
 {
     cStatus.Text = "Check";
     pokerPlayer.AbleToMakeTurn = false;
     raising = false;
 }
Example #15
0
        public void PairHand(
            IPokerPlayer pokerPlayer,
            Label sStatus,
            int neededChipsToCall,
            TextBox potStatus,
            ref int raise,
            ref bool raising,
            ref int rounds)
        {
            int rCall  = this.randomGenerator.Next(10, 16);
            int rRaise = this.randomGenerator.Next(10, 13);

            if (pokerPlayer.Power <= 199 && pokerPlayer.Power >= 140)
            {
                this.playerActions.PH(
                    pokerPlayer,
                    sStatus,
                    rCall,
                    6,
                    rRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    rounds);
            }

            if (pokerPlayer.Power <= 139 && pokerPlayer.Power >= 128)
            {
                this.playerActions.PH(
                    pokerPlayer,
                    sStatus,
                    rCall,
                    7,
                    rRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    rounds);
            }

            if (pokerPlayer.Power < 128 && pokerPlayer.Power >= 101)
            {
                this.playerActions.PH(
                    pokerPlayer,
                    sStatus,
                    rCall,
                    9,
                    rRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    rounds);
            }
        }
Example #16
0
        public void PairHand(
            IPokerPlayer pokerPlayer, 
            Label sStatus, 
            int neededChipsToCall, 
            TextBox potStatus,
            ref int raise, 
            ref bool raising, 
            ref int rounds)
        {
            int rCall = this.randomGenerator.Next(10, 16);
            int rRaise = this.randomGenerator.Next(10, 13);
            if (pokerPlayer.Power <= 199 && pokerPlayer.Power >= 140)
            {
                this.playerActions.PH(
                    pokerPlayer, 
                    sStatus, 
                    rCall, 
                    6, 
                    rRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    rounds);
            }

            if (pokerPlayer.Power <= 139 && pokerPlayer.Power >= 128)
            {
                this.playerActions.PH(
                    pokerPlayer, 
                    sStatus, 
                    rCall, 
                    7, 
                    rRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    rounds);
            }

            if (pokerPlayer.Power < 128 && pokerPlayer.Power >= 101)
            {
                this.playerActions.PH(
                    pokerPlayer, 
                    sStatus, 
                    rCall, 
                    9, 
                    rRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    rounds);
            }
        }
Example #17
0
        public PokerEventArgs(PokerEnums.GameAction gameAction, PokerEnums.PlayerAction playerAction, IPokerPlayer player, double amount, double stack)
        {
            this.gameAction   = gameAction;
            this.playerAction = playerAction;
            this.player       = player;
            this.amount       = amount;
            this.stack        = stack;

            cardA = cardB = cardC = Card.Empty;
        }
Example #18
0
 public void Fold(
     IPokerPlayer pokerPlayer,
     Label sStatus,
     ref bool rising)
 {
     rising       = false;
     sStatus.Text = "Fold";
     pokerPlayer.AbleToMakeTurn = false;
     pokerPlayer.OutOfChips     = true;
 }
Example #19
0
 public void Fold(
     IPokerPlayer pokerPlayer, 
     Label sStatus, 
     ref bool rising)
 {
     rising = false;
     sStatus.Text = "Fold";
     pokerPlayer.AbleToMakeTurn = false;
     pokerPlayer.OutOfChips = true;
 }
Example #20
0
        public PokerEventArgs(PokerEnums.GameAction gameAction, Card card, double amount)
        {
            this.cardA      = card;
            this.gameAction = gameAction;
            this.amount     = amount;

            this.playerAction = 0;
            this.player       = null;
            this.stack        = -1;
            cardB             = cardC = Card.Empty;
        }
Example #21
0
 public void RemovePlayer(IPokerPlayer p)
 {
     lock (m_GamePlayers)
     {
         if (m_GamePlayers.ContainsKey(p.TableId))
         {
             m_GamePlayers[p.TableId].EndPokerObserver();
             m_GamePlayers.Remove(p.TableId);
         }
     }
 }
Example #22
0
        public void FullHouse(
            IPokerPlayer pokerPlayer,
            int[] Straight,
            ref List<Type> Win,
            ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                bool done = false;
                double power = pokerPlayer.Power;
                for (int j = 0; j <= 12; j++)
                {
                    var currentKind = Straight.Where(o => o / 4 == j).ToArray();
                    if (currentKind.Length == 3 || done)
                    {
                        if (currentKind.Length == 2)
                        {
                            if (currentKind.Max() / 4 == 0)
                            {
                                RankHand(pokerPlayer, Win, 13, 6, out sorted);

                                break;
                            }

                            if (currentKind.Max() / 4 > 0)
                            {
                                RankHand(pokerPlayer, Win, currentKind.Max() / 4, 7, out sorted);

                                break;
                            }
                        }

                        if (!done)
                        {
                            if (currentKind.Max() / 4 == 0)
                            {
                                pokerPlayer.Power = 13;
                            }
                            else
                            {
                                pokerPlayer.Power = currentKind.Max() / 4;
                            }
                            done = true;
                            j = -1;
                        }
                    }
                }

                if (pokerPlayer.Type != 6)
                {
                    pokerPlayer.Power = power;
                }
            }
        }
Example #23
0
        public void FullHouse(
            IPokerPlayer pokerPlayer,
            int[] Straight,
            ref List <Type> Win,
            ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                bool   done  = false;
                double power = pokerPlayer.Power;
                for (int j = 0; j <= 12; j++)
                {
                    var currentKind = Straight.Where(o => o / 4 == j).ToArray();
                    if (currentKind.Length == 3 || done)
                    {
                        if (currentKind.Length == 2)
                        {
                            if (currentKind.Max() / 4 == 0)
                            {
                                RankHand(pokerPlayer, Win, 13, 6, out sorted);

                                break;
                            }

                            if (currentKind.Max() / 4 > 0)
                            {
                                RankHand(pokerPlayer, Win, currentKind.Max() / 4, 7, out sorted);

                                break;
                            }
                        }

                        if (!done)
                        {
                            if (currentKind.Max() / 4 == 0)
                            {
                                pokerPlayer.Power = 13;
                            }
                            else
                            {
                                pokerPlayer.Power = currentKind.Max() / 4;
                            }
                            done = true;
                            j    = -1;
                        }
                    }
                }

                if (pokerPlayer.Type != 6)
                {
                    pokerPlayer.Power = power;
                }
            }
        }
Example #24
0
        public PokerEventArgs(PokerEnums.GameAction gameAction, Card cardA, Card cardB, Card cardC, double amount)
        {
            this.cardA      = cardA;
            this.cardB      = cardB;
            this.cardC      = cardC;
            this.gameAction = gameAction;
            this.amount     = amount;

            this.playerAction = 0;
            this.player       = null;
            this.stack        = -1;
        }
Example #25
0
        public void AddPlayer(IPokerPlayer player, double stackSize)
        {
            var playerInfo = new PlayerInfo();

            playerInfo.Player = player;
            playerInfo.Stack  = stackSize;
            _playersInfo.Add(playerInfo);

            PokerActionPreformed += player.PokerGameActionHandler;

            FireActionEvent(new PokerEventArgs(PokerEnums.GameAction.PlayerJoined, 0, player, -1, stackSize));
        }
Example #26
0
        public PokerTable()
        {
            this.player = new PokerPlayer(new Panel());
            this.firstBot = new PokerPlayer(new Panel());
            this.secondBot = new PokerPlayer(new Panel());
            this.thirdBot = new PokerPlayer(new Panel());
            this.fourthBot = new PokerPlayer(new Panel());
            this.fifthBoth = new PokerPlayer(new Panel());

            Deck teste = new Deck();

            //bools.Add(PlayerFoldTurn); bools.Add(bot1.FoldedTurn); bools.Add(bot2.FoldedTurn); bools.Add(bot3.FoldedTurn); bools.Add(bot4.FoldedTurn); bools.Add(bot5.FoldedTurn);
            call = this.bigBlind;
            MaximizeBox = false;
            MinimizeBox = false;
            updates.Start();
            InitializeComponent();

            // width = this.Width;
            // height = this.Height;
            Shuffle();
            potStatus.Enabled = false;
            playerChips.Enabled = false;
            botOneChips.Enabled = false;
            botTwoChips.Enabled = false;
            botThreeChips.Enabled = false;
            botFourChips.Enabled = false;
            botFiveChips.Enabled = false;
            playerChips.Text = "Chips : " + this.player.Chips;
            botOneChips.Text = "Chips : " + this.firstBot.Chips;
            botTwoChips.Text = "Chips : " + this.secondBot.Chips;
            botThreeChips.Text = "Chips : " + this.thirdBot.Chips;
            botFourChips.Text = "Chips : " + this.fourthBot.Chips;
            botFiveChips.Text = "Chips : " + this.fifthBoth.Chips;
            timer.Interval = (1 * 1 * 1000);
            timer.Tick += TimerTick;
            updates.Interval = (1 * 1 * 100);
            updates.Tick += Update_Tick;
            this.changeBigBlindField.Visible = true;
            this.changeSmallBlindField.Visible = true;
            this.changeBigBlindButton.Visible = true;
            this.changeSmallBlindButton.Visible = true;
            //this.tbBigBlind.Visible = true;
            //this.tbSmallBlind.Visible = true;
            //this.bBigBlind.Visible = true;
            //this.bSmallBlind.Visible = true;
            //this.tbBigBlind.Visible = false;
            //this.tbSmallBlind.Visible = false;
            //this.bBigBlind.Visible = false;
            //this.bSmallBlind.Visible = false;
            raiseAmountField.Text = (this.bigBlind * 2).ToString();
        }
Example #27
0
 public void Call(
     IPokerPlayer pokerPlayer, 
     Label sStatus, 
     ref bool raising, 
     ref int neededChipsToCall,
     TextBox potStatus)
 {
     raising = false;
     pokerPlayer.AbleToMakeTurn = false;
     pokerPlayer.Chips -= neededChipsToCall;
     sStatus.Text = "Call " + neededChipsToCall;
     potStatus.Text = (int.Parse(potStatus.Text) + neededChipsToCall).ToString();
 }
Example #28
0
 public void Call(
     IPokerPlayer pokerPlayer,
     Label sStatus,
     ref bool raising,
     ref int neededChipsToCall,
     TextBox potStatus)
 {
     raising = false;
     pokerPlayer.AbleToMakeTurn = false;
     pokerPlayer.Chips         -= neededChipsToCall;
     sStatus.Text   = "Call " + neededChipsToCall;
     potStatus.Text = (int.Parse(potStatus.Text) + neededChipsToCall).ToString();
 }
Example #29
0
 public void Raised(
     IPokerPlayer pokerPlayer,
     Label sStatus,
     ref bool raising,
     ref int raise,
     ref int neededChipsToCall,
     TextBox potStatus)
 {
     pokerPlayer.Chips         -= Convert.ToInt32(raise);
     sStatus.Text               = "Raise " + raise;
     potStatus.Text             = (int.Parse(potStatus.Text) + Convert.ToInt32(raise)).ToString();
     neededChipsToCall          = Convert.ToInt32(raise);
     raising                    = true;
     pokerPlayer.AbleToMakeTurn = false;
 }
Example #30
0
 public void Raised(
     IPokerPlayer pokerPlayer, 
     Label sStatus, 
     ref bool raising, 
     ref int raise,
     ref int neededChipsToCall, 
     TextBox potStatus)
 {
     pokerPlayer.Chips -= Convert.ToInt32(raise);
     sStatus.Text = "Raise " + raise;
     potStatus.Text = (int.Parse(potStatus.Text) + Convert.ToInt32(raise)).ToString();
     neededChipsToCall = Convert.ToInt32(raise);
     raising = true;
     pokerPlayer.AbleToMakeTurn = false;
 }
Example #31
0
        private static void RankHand(
            IPokerPlayer pokerPlayer,
            List <Type> Win,
            int power,
            int rankOfHand,
            out Type sorted)
        {
            pokerPlayer.Type  = rankOfHand;
            pokerPlayer.Power = power + pokerPlayer.Type * 100;

            Win.Add(new Type {
                Power = pokerPlayer.Power, Current = rankOfHand
            });

            sorted = Win.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();
        }
Example #32
0
        private static void CheckForFlush(IPokerPlayer pokerPlayer, List <Type> Win, int[] colour)
        {
            if (colour.Length >= 5)
            {
                pokerPlayer.Type  = 5;
                pokerPlayer.Power = colour.Max() / 4 + pokerPlayer.Type * 100;

                if (colour.Max() / 4 == 0)
                {
                    pokerPlayer.Power = 13 + pokerPlayer.Type * 100;
                }

                Win.Add(new Type {
                    Power = pokerPlayer.Power, Current = 5
                });
            }
        }
Example #33
0
 public void PairTable(
     IPokerPlayer pokerPlayer, 
     Label sStatus, 
     int neededChipsToCall, 
     TextBox potStatus,
     ref int raise, 
     ref bool raising)
 {
     this.playerActions.HP(
         pokerPlayer, 
         sStatus, 
         16, 
         25, 
         neededChipsToCall, 
         potStatus, 
         ref raise, 
         ref raising);
 }
Example #34
0
 public void PairTable(
     IPokerPlayer pokerPlayer,
     Label sStatus,
     int neededChipsToCall,
     TextBox potStatus,
     ref int raise,
     ref bool raising)
 {
     this.playerActions.HP(
         pokerPlayer,
         sStatus,
         16,
         25,
         neededChipsToCall,
         potStatus,
         ref raise,
         ref raising);
 }
Example #35
0
        public void FullHouse(
            IPokerPlayer pokerPlayer,
            Label sStatus,
            int name,
            int neededChipsToCall,
            TextBox potStatus,
            ref int raise,
            ref bool raising,
            ref int rounds)
        {
            int fhCall  = this.randomGenerator.Next(1, 5);
            int fhRaise = this.randomGenerator.Next(2, 6);

            if (pokerPlayer.Power <= 626 && pokerPlayer.Power >= 620)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    fhCall,
                    fhRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }

            if (pokerPlayer.Power < 620 && pokerPlayer.Power >= 602)
            {
                this.Smooth(
                    pokerPlayer,
                    sStatus,
                    name,
                    fhCall,
                    fhRaise,
                    neededChipsToCall,
                    potStatus,
                    ref raise,
                    ref raising,
                    ref rounds);
            }
        }
Example #36
0
        private static void CheckForStraightFlush(
            IPokerPlayer pokerPlayer,
            int[] colour,
            List <Type> Win,
            out Type sorted)
        {
            if (colour[0] + 4 == colour[4])
            {
                //Straight Flush
                RankHand(pokerPlayer, Win, colour.Max() / 4, 8, out sorted);
            }

            if (colour[0] == 0 && colour[1] == 9 && colour[2] == 10 && colour[3] == 11 && colour[4] == 12)
            {
                //Royal Straight Flush
                RankHand(pokerPlayer, Win, colour.Max() / 4, 9, out sorted);
            }

            sorted = Win.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();
        }
Example #37
0
 public void ThreeOfAKind(IPokerPlayer pokerPlayer, int[] Straight, ref List <Type> Win, ref Type sorted)
 {
     if (pokerPlayer.Type >= -1)
     {
         for (int index = 0; index <= 12; index++)
         {
             var fh = Straight.Where(o => o / 4 == index).ToArray();
             if (fh.Length == 3)
             {
                 if (fh.Max() / 4 == 0)
                 {
                     RankHand(pokerPlayer, Win, 13, 3, out sorted);
                 }
                 else
                 {
                     RankHand(pokerPlayer, Win, fh[0] / 4, 3, out sorted);
                 }
             }
         }
     }
 }
Example #38
0
        public void Flush(
            IPokerPlayer pokerPlayer,
            int[] Straight1,
            ref List <Type> Win,
            ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                var clubes   = Straight1.Where(o => o % 4 == 0).ToArray();
                var diamonds = Straight1.Where(o => o % 4 == 1).ToArray();
                var hearts   = Straight1.Where(o => o % 4 == 2).ToArray();
                var spades   = Straight1.Where(o => o % 4 == 3).ToArray();

                CheckForFlush(pokerPlayer, Win, clubes);

                CheckForFlush(pokerPlayer, Win, diamonds);

                CheckForFlush(pokerPlayer, Win, hearts);

                CheckForFlush(pokerPlayer, Win, spades);
            }
        }
Example #39
0
        public void FourOfAKind(IPokerPlayer pokerPlayer, int[] Straight, ref List<Type> Win, ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                for (int j = 0; j <= 3; j++)
                {
                    if (Straight[j] / 4 == Straight[j + 1] / 4 &&
                        Straight[j] / 4 == Straight[j + 2] / 4 &&
                        Straight[j] / 4 == Straight[j + 3] / 4)
                    {
                        RankHand(pokerPlayer, Win, Straight[j] / 4, 7, out sorted);
                    }

                    if (Straight[j] / 4 == 0 &&
                        Straight[j + 1] / 4 == 0 &&
                        Straight[j + 2] / 4 == 0 &&
                        Straight[j + 3] / 4 == 0)
                    {
                        RankHand(pokerPlayer, Win, 13, 7, out sorted);
                    }
                }
            }
        }
Example #40
0
        public void FourOfAKind(IPokerPlayer pokerPlayer, int[] Straight, ref List <Type> Win, ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                for (int j = 0; j <= 3; j++)
                {
                    if (Straight[j] / 4 == Straight[j + 1] / 4 &&
                        Straight[j] / 4 == Straight[j + 2] / 4 &&
                        Straight[j] / 4 == Straight[j + 3] / 4)
                    {
                        RankHand(pokerPlayer, Win, Straight[j] / 4, 7, out sorted);
                    }

                    if (Straight[j] / 4 == 0 &&
                        Straight[j + 1] / 4 == 0 &&
                        Straight[j + 2] / 4 == 0 &&
                        Straight[j + 3] / 4 == 0)
                    {
                        RankHand(pokerPlayer, Win, 13, 7, out sorted);
                    }
                }
            }
        }
Example #41
0
        /// <summary>
        /// 庄家与闲家对决。
        /// </summary>
        /// <returns>true:庄家赢,false:闲家赢。</returns>
        public bool HeadsUp(IPokerPlayer player, out bool isDouble)
        {
            PokerCard[] cards_banker     = gamebanker.GetCards();
            PokerCard[] cards_player     = player.GetCards();
            bool        isDouble_banker  = cards_banker[0].Point == cards_banker[1].Point;
            bool        isDouble_player  = cards_player[0].Point == cards_player[1].Point;
            bool        isBankerPointWin =
                (cards_banker.Sum(d => d.Point) >= 10 ? cards_banker.Sum(d => d.Point) - 10 : cards_banker.Sum(d => d.Point))
                >=
                (cards_player.Sum(d => d.Point) >= 10 ? cards_player.Sum(d => d.Point) - 10 : cards_player.Sum(d => d.Point));

            if (!isDouble_banker && !isDouble_player)
            {
                isDouble = false;
                return(isBankerPointWin);
            }
            else if (isDouble_banker && !isDouble_player)
            {
                isDouble = false;
                return(true);
            }
            else if (!isDouble_banker && isDouble_player)
            {
                isDouble = true;
                return(false);
            }
            else if (isDouble_banker && isDouble_player)
            {
                isDouble = true;
                return(isBankerPointWin);
            }
            else
            {
                isDouble = false;
                return(false);
            }
        }
Example #42
0
        public void HighCard(
            IPokerPlayer pokerPlayer,
            int index,
            ref List <Type> Win,
            ref Type sorted,
            ref int[] reserve)
        {
            if (pokerPlayer.Type == -1)
            {
                if (reserve[index] / 4 > reserve[index + 1] / 4)
                {
                    RankHand(pokerPlayer, Win, reserve[index] / 4, -1, out sorted);
                }
                else
                {
                    RankHand(pokerPlayer, Win, reserve[index + 1] / 4, -1, out sorted);
                }

                if (reserve[index] / 4 == 0 || reserve[index + 1] / 4 == 0)
                {
                    RankHand(pokerPlayer, Win, reserve[index] / 4, -1, out sorted);
                }
            }
        }
Example #43
0
 public void RemovePlayer(IPokerPlayer p)
 {
     throw new NotImplementedException();
 }
Example #44
0
        public void FullHouse(
            IPokerPlayer pokerPlayer, 
            Label sStatus, 
            int name, 
            int neededChipsToCall,
            TextBox potStatus, 
            ref int raise, 
            ref bool raising, 
            ref int rounds)
        {
            int fhCall = this.randomGenerator.Next(1, 5);
            int fhRaise = this.randomGenerator.Next(2, 6);
            if (pokerPlayer.Power <= 626 && pokerPlayer.Power >= 620)
            {
                this.Smooth(
                    pokerPlayer, 
                    sStatus, 
                    name, 
                    fhCall, 
                    fhRaise,
                    neededChipsToCall,
                    potStatus, 
                    ref raise,
                    ref raising, 
                    ref rounds);
            }

            if (pokerPlayer.Power < 620 && pokerPlayer.Power >= 602)
            {
                this.Smooth(
                    pokerPlayer, 
                    sStatus, 
                    name, 
                    fhCall, 
                    fhRaise, 
                    neededChipsToCall,
                    potStatus, 
                    ref raise,
                    ref raising, 
                    ref rounds);
            }
        }
Example #45
0
 public void Flush(
     IPokerPlayer pokerPlayer, 
     Label sStatus, 
     int name, 
     int neededChipsToCall, 
     TextBox potStatus,
     ref int raise, 
     ref bool raising, 
     ref int rounds)
 {
     int fCall = this.randomGenerator.Next(2, 6);
     int fRaise = this.randomGenerator.Next(3, 7);
     this.Smooth(
         pokerPlayer, 
         sStatus, 
         name, 
         fCall, 
         fRaise, 
         neededChipsToCall, 
         potStatus, 
         ref raise, 
         ref raising,
         ref rounds);
 }
Example #46
0
        public void Flush(
            IPokerPlayer pokerPlayer,
            int[] Straight1,
            ref List<Type> Win,
            ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                var clubes = Straight1.Where(o => o % 4 == 0).ToArray();
                var diamonds = Straight1.Where(o => o % 4 == 1).ToArray();
                var hearts = Straight1.Where(o => o % 4 == 2).ToArray();
                var spades = Straight1.Where(o => o % 4 == 3).ToArray();

                CheckForFlush(pokerPlayer, Win, clubes);

                CheckForFlush(pokerPlayer, Win, diamonds);

                CheckForFlush(pokerPlayer, Win, hearts);

                CheckForFlush(pokerPlayer, Win, spades);
            }
        }
Example #47
0
        public void Straight(
            IPokerPlayer pokerPlayer,
            int[] Straight,
            ref List<Type> Win,
            ref Type sorted)
        {
            if (pokerPlayer.Type >= -1)
            {
                var kind = Straight.Select(o => o / 4).Distinct().ToArray();

                for (int index = 0; index < kind.Length - 4; index++)
                {
                    if (kind[index] + 4 == kind[index + 4])
                    {
                        if (kind.Max() - 4 == kind[index])
                        {
                            RankHand(pokerPlayer, Win, kind.Max(), 4, out sorted);
                        }
                        else
                        {
                            RankHand(pokerPlayer, Win, kind[index + 4], 4, out sorted);
                        }
                    }

                    if (kind[index] == 0 && kind[index + 1] == 9 && kind[index + 2] == 10 && kind[index + 3] == 11 &&
                        kind[index + 4] == 12)
                    {
                        RankHand(pokerPlayer, Win, 13, 4, out sorted);
                    }
                }
            }
        }
Example #48
0
        public void TwoPair(
            IPokerPlayer pokerPlayer, 
            Label sStatus, 
            int neededChipsToCall, 
            TextBox potStatus,
            ref int raise, 
            ref bool raising, 
            ref int rounds)
        {
            int rCall = this.randomGenerator.Next(6, 11);
            int rRaise = this.randomGenerator.Next(6, 11);
            if (pokerPlayer.Power <= 290 && pokerPlayer.Power >= 246)
            {
                this.playerActions.PH(
                    pokerPlayer, 
                    sStatus, 
                    rCall, 
                    3, 
                    rRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    rounds);
            }

            if (pokerPlayer.Power <= 244 && pokerPlayer.Power >= 234)
            {
                this.playerActions.PH(
                    pokerPlayer, 
                    sStatus, 
                    rCall, 
                    4, 
                    rRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    rounds);
            }

            if (pokerPlayer.Power < 234 && pokerPlayer.Power >= 201)
            {
                this.playerActions.PH(
                    pokerPlayer, 
                    sStatus, 
                    rCall, 
                    4, 
                    rRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    rounds);
            }
        }
Example #49
0
        private static void RankHand(
            IPokerPlayer pokerPlayer,
            List<Type> Win,
            int power,
            int rankOfHand,
            out Type sorted)
        {
            pokerPlayer.Type = rankOfHand;
            pokerPlayer.Power = power + pokerPlayer.Type * 100;

            Win.Add(new Type { Power = pokerPlayer.Power, Current = rankOfHand });

            sorted = Win.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();
        }
Example #50
0
        public void ThreeOfAKind(
            IPokerPlayer pokerPlayer, 
            Label sStatus, 
            int name, 
            int neededChipsToCall,
            TextBox potStatus, 
            ref int raise, 
            ref bool raising, 
            ref int rounds)
        {
            int tCall = this.randomGenerator.Next(3, 7);
            int tRaise = this.randomGenerator.Next(4, 8);
            if (pokerPlayer.Power <= 390 && pokerPlayer.Power >= 330)
            {
                this.Smooth(
                    pokerPlayer, 
                    sStatus, 
                    name, 
                    tCall, 
                    tRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    ref rounds);
            }

            if (pokerPlayer.Power <= 327 && pokerPlayer.Power >= 321)
            {
                this.Smooth(
                    pokerPlayer, 
                    sStatus, 
                    name, 
                    tCall, 
                    tRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    ref rounds);
            }

            if (pokerPlayer.Power < 321 && pokerPlayer.Power >= 303)
            {
                this.Smooth(
                    pokerPlayer, 
                    sStatus, 
                    name, 
                    tCall, 
                    tRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    ref rounds);
            }
        }
Example #51
0
        public void PairTwoPair(
            IPokerPlayer pokerPlayer,
            int index,
            ref List<Type> Win,
            ref Type sorted,
            ref int[] reserve)
        {
            if (pokerPlayer.Type >= -1)
            {
                bool msgbox = false;
                bool msgbox1 = false;
                for (int tc = 16; tc >= 12; tc--)
                {
                    int max = tc - 12;
                    for (int k = 1; k <= max; k++)
                    {
                        if (tc - k < 12)
                        {
                            max--;
                        }

                        if (tc - k >= 12)
                        {
                            if (reserve[tc] / 4 == reserve[tc - k] / 4)
                            {
                                if (reserve[tc] / 4 != reserve[index] / 4 && reserve[tc] / 4 != reserve[index + 1] / 4 &&
                                    pokerPlayer.Type == 1)
                                {
                                    if (!msgbox)
                                    {
                                        if (reserve[index + 1] / 4 == 0)
                                        {
                                            pokerPlayer.Type = 2;
                                            pokerPlayer.Power = reserve[index] / 4 * 2 + 13 * 4 + pokerPlayer.Type * 100;
                                            Win.Add(new Type { Power = pokerPlayer.Power, Current = 2 });
                                            sorted =
                                                Win.OrderByDescending(op => op.Current)
                                                    .ThenByDescending(op => op.Power)
                                                    .First();
                                        }

                                        if (reserve[index] / 4 == 0)
                                        {
                                            pokerPlayer.Type = 2;
                                            pokerPlayer.Power = reserve[index + 1] / 4 * 2 + 13 * 4 +
                                                                pokerPlayer.Type * 100;
                                            Win.Add(new Type { Power = pokerPlayer.Power, Current = 2 });
                                            sorted =
                                                Win.OrderByDescending(op => op.Current)
                                                    .ThenByDescending(op => op.Power)
                                                    .First();
                                        }

                                        if (reserve[index + 1] / 4 != 0)
                                        {
                                            pokerPlayer.Type = 2;
                                            pokerPlayer.Power = reserve[tc] / 4 * 2 + reserve[index + 1] / 4 * 2 +
                                                                pokerPlayer.Type * 100;
                                            Win.Add(new Type { Power = pokerPlayer.Power, Current = 2 });
                                            sorted =
                                                Win.OrderByDescending(op => op.Current)
                                                    .ThenByDescending(op => op.Power)
                                                    .First();
                                        }

                                        if (reserve[index] / 4 != 0)
                                        {
                                            pokerPlayer.Type = 2;
                                            pokerPlayer.Power = reserve[tc] / 4 * 2 + reserve[index] / 4 * 2 +
                                                                pokerPlayer.Type * 100;
                                            Win.Add(new Type { Power = pokerPlayer.Power, Current = 2 });
                                            sorted =
                                                Win.OrderByDescending(op => op.Current)
                                                    .ThenByDescending(op => op.Power)
                                                    .First();
                                        }
                                    }

                                    msgbox = true;
                                }

                                if (pokerPlayer.Type == -1)
                                {
                                    if (!msgbox1)
                                    {
                                        if (reserve[index] / 4 > reserve[index + 1] / 4)
                                        {
                                            if (reserve[tc] / 4 == 0)
                                            {
                                                pokerPlayer.Type = 0;
                                                pokerPlayer.Power = 13 + reserve[index] / 4 + pokerPlayer.Type * 100;
                                                Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                                                sorted =
                                                    Win.OrderByDescending(op => op.Current)
                                                        .ThenByDescending(op => op.Power)
                                                        .First();
                                            }
                                            else
                                            {
                                                pokerPlayer.Type = 0;
                                                pokerPlayer.Power = reserve[tc] / 4 + reserve[index] / 4 +
                                                                    pokerPlayer.Type * 100;
                                                Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                                                sorted =
                                                    Win.OrderByDescending(op => op.Current)
                                                        .ThenByDescending(op => op.Power)
                                                        .First();
                                            }
                                        }
                                        else
                                        {
                                            if (reserve[tc] / 4 == 0)
                                            {
                                                pokerPlayer.Type = 0;
                                                pokerPlayer.Power = 13 + reserve[index + 1] + pokerPlayer.Type * 100;
                                                Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                                                sorted =
                                                    Win.OrderByDescending(op => op.Current)
                                                        .ThenByDescending(op => op.Power)
                                                        .First();
                                            }
                                            else
                                            {
                                                pokerPlayer.Type = 0;
                                                pokerPlayer.Power = reserve[tc] / 4 + reserve[index + 1] / 4 +
                                                                    pokerPlayer.Type * 100;
                                                Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                                                sorted =
                                                    Win.OrderByDescending(op => op.Current)
                                                        .ThenByDescending(op => op.Power)
                                                        .First();
                                            }
                                        }
                                    }

                                    msgbox1 = true;
                                }
                            }
                        }
                    }
                }
            }
        }
Example #52
0
        public void Straight(
            IPokerPlayer pokerPlayer, 
            Label sStatus, 
            int name, 
            int neededChipsToCall, 
            TextBox potStatus,
            ref int raise, 
            ref bool raising, 
            ref int rounds)
        {
            int sCall = this.randomGenerator.Next(3, 6);
            int sRaise = this.randomGenerator.Next(3, 8);
            if (pokerPlayer.Power <= 480 && pokerPlayer.Power >= 410)
            {
                this.Smooth(
                    pokerPlayer, 
                    sStatus, 
                    name, 
                    sCall, 
                    sRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    ref rounds);
            }

            if (pokerPlayer.Power <= 409 && pokerPlayer.Power >= 407)
            {
                this.Smooth(
                    pokerPlayer, 
                    sStatus, 
                    name, 
                    sCall, 
                    sRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    ref rounds);
            }

            if (pokerPlayer.Power < 407 && pokerPlayer.Power >= 404)
            {
                this.Smooth(
                    pokerPlayer, 
                    sStatus, 
                    name, 
                    sCall, 
                    sRaise, 
                    neededChipsToCall, 
                    potStatus, 
                    ref raise,
                    ref raising, 
                    ref rounds);
            }
        }
Example #53
0
 public void StraightFlush(
     IPokerPlayer pokerPlayer, 
     Label sStatus, 
     int name, 
     int neededChipsToCall,
     TextBox potStatus, 
     ref int raise, 
     ref bool raising, 
     ref int rounds)
 {
     int sfCall = this.randomGenerator.Next(1, 3);
     int sfRaise = this.randomGenerator.Next(1, 3);
     if (pokerPlayer.Power <= 913 && pokerPlayer.Power >= 804)
     {
         this.Smooth(
             pokerPlayer, 
             sStatus, 
             name, 
             sfCall, 
             sfRaise, 
             neededChipsToCall,
             potStatus,
             ref raise,
             ref raising,
             ref rounds);
     }
 }
Example #54
0
        public void PairFromHand(
            IPokerPlayer pokerPlayer,
            int index,
            ref List<Type> Win,
            ref Type sorted,
            ref int[] Reserve)
        {
            if (pokerPlayer.Type >= -1)
            {
                bool msgbox = false;
                if (Reserve[index] / 4 == Reserve[index + 1] / 4)
                {
                    if (!msgbox)
                    {
                        if (Reserve[index] / 4 == 0)
                        {
                            pokerPlayer.Type = 1;
                            pokerPlayer.Power = 13 * 4 + 100;
                            Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                            sorted = Win.OrderByDescending(op => op.Current).ThenByDescending(op => op.Power).First();
                        }
                        else
                        {
                            pokerPlayer.Type = 1;
                            pokerPlayer.Power = Reserve[index + 1] / 4 * 4 + 100;
                            Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                            sorted = Win.OrderByDescending(op => op.Current).ThenByDescending(op => op.Power).First();
                        }
                    }

                    msgbox = true;
                }

                for (int tc = 16; tc >= 12; tc--)
                {
                    if (Reserve[index + 1] / 4 == Reserve[tc] / 4)
                    {
                        if (!msgbox)
                        {
                            if (Reserve[index + 1] / 4 == 0)
                            {
                                pokerPlayer.Type = 1;
                                pokerPlayer.Power = 13 * 4 + Reserve[index] / 4 + 100;
                                Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                                sorted =
                                    Win.OrderByDescending(op => op.Current).ThenByDescending(op => op.Power).First();
                            }
                            else
                            {
                                pokerPlayer.Type = 1;
                                pokerPlayer.Power = Reserve[index + 1] / 4 * 4 + Reserve[index] / 4 + 100;
                                Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                                sorted =
                                    Win.OrderByDescending(op => op.Current).ThenByDescending(op => op.Power).First();
                            }
                        }

                        msgbox = true;
                    }

                    if (Reserve[index] / 4 == Reserve[tc] / 4)
                    {
                        if (!msgbox)
                        {
                            if (Reserve[index] / 4 == 0)
                            {
                                pokerPlayer.Type = 1;
                                pokerPlayer.Power = 13 * 4 + Reserve[index + 1] / 4 + 100;
                                Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                                sorted =
                                    Win.OrderByDescending(op => op.Current).ThenByDescending(op => op.Power).First();
                            }
                            else
                            {
                                pokerPlayer.Type = 1;
                                pokerPlayer.Power = Reserve[tc] / 4 * 4 + Reserve[index + 1] / 4 + 100;
                                Win.Add(new Type { Power = pokerPlayer.Power, Current = 1 });
                                sorted =
                                    Win.OrderByDescending(op => op.Current).ThenByDescending(op => op.Power).First();
                            }
                        }
                        msgbox = true;
                    }
                }
            }
        }
Example #55
0
 public void FourOfAKind(
     IPokerPlayer pokerPlayer, 
     Label sStatus, 
     int name, 
     int neededChipsToCall,
     TextBox potStatus, 
     ref int raise, 
     ref bool raising, 
     ref int rounds)
 {
     int fkCall = this.randomGenerator.Next(1, 4);
     int fkRaise = this.randomGenerator.Next(2, 5);
     if (pokerPlayer.Power <= 752 && pokerPlayer.Power >= 704)
     {
         this.Smooth(
             pokerPlayer, 
             sStatus, 
             name, 
             fkCall, 
             fkRaise,
             neededChipsToCall, 
             potStatus, 
             ref raise,
             ref raising, 
             ref rounds);
     }
 }
Example #56
0
 public void ThreeOfAKind(IPokerPlayer pokerPlayer, int[] Straight, ref List<Type> Win, ref Type sorted)
 {
     if (pokerPlayer.Type >= -1)
     {
         for (int index = 0; index <= 12; index++)
         {
             var fh = Straight.Where(o => o / 4 == index).ToArray();
             if (fh.Length == 3)
             {
                 if (fh.Max() / 4 == 0)
                 {
                     RankHand(pokerPlayer, Win, 13, 3, out sorted);
                 }
                 else
                 {
                     RankHand(pokerPlayer, Win, fh[0] / 4, 3, out sorted);
                 }
             }
         }
     }
 }
Example #57
0
        private static void CheckForStraightFlush(
            IPokerPlayer pokerPlayer, 
            int[] colour, 
            List<Type> Win,
            out Type sorted)
        {
            if (colour[0] + 4 == colour[4])
            {
                //Straight Flush
                RankHand(pokerPlayer, Win, colour.Max() / 4, 8, out sorted);
            }

            if (colour[0] == 0 && colour[1] == 9 && colour[2] == 10 && colour[3] == 11 && colour[4] == 12)
            {
                //Royal Straight Flush
                RankHand(pokerPlayer, Win, colour.Max() / 4, 9, out sorted);
            }

            sorted = Win.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();
        }
Example #58
0
        public void HighCard(
            IPokerPlayer pokerPlayer,
            int index,
            ref List<Type> Win,
            ref Type sorted,
            ref int[] reserve)
        {
            if (pokerPlayer.Type == -1)
            {
                if (reserve[index] / 4 > reserve[index + 1] / 4)
                {
                    RankHand(pokerPlayer, Win, reserve[index] / 4, -1, out sorted);
                }
                else
                {
                    RankHand(pokerPlayer, Win, reserve[index + 1] / 4, -1, out sorted);
                }

                if (reserve[index] / 4 == 0 || reserve[index + 1] / 4 == 0)
                {
                    RankHand(pokerPlayer, Win, reserve[index] / 4, -1, out sorted);
                }
            }
        }
Example #59
0
        private static void CheckForFlush(IPokerPlayer pokerPlayer, List<Type> Win, int[] colour)
        {
            if (colour.Length >= 5)
            {
                pokerPlayer.Type = 5;
                pokerPlayer.Power = colour.Max() / 4 + pokerPlayer.Type * 100;

                if (colour.Max() / 4 == 0)
                {
                    pokerPlayer.Power = 13 + pokerPlayer.Type * 100;
                }

                Win.Add(new Type { Power = pokerPlayer.Power, Current = 5 });
            }
        }
Example #60
0
        private void Smooth(
            IPokerPlayer pokerPlayer, 
            Label botStatus, 
            int name, 
            int n, 
            int r, 
            int neededChipsToCall,
            TextBox potStatus, 
            ref int raise,
            ref bool raising, 
            ref int rounds)
        {
            int rnd = this.randomGenerator.Next(1, 3);
            if (neededChipsToCall <= 0)
            {
                this.playerActions.Check(pokerPlayer, botStatus, ref raising);
            }
            else
            {
                if (neededChipsToCall >= PlayerActions.RoundN(pokerPlayer.Chips, n))
                {
                    if (pokerPlayer.Chips > neededChipsToCall)
                    {
                        this.playerActions.Call(
                            pokerPlayer, 
                            botStatus, 
                            ref raising, 
                            ref neededChipsToCall, 
                            potStatus);
                    }
                    else if (pokerPlayer.Chips <= neededChipsToCall)
                    {
                        raising = false;
                        pokerPlayer.AbleToMakeTurn = false;
                        pokerPlayer.Chips = 0;
                        botStatus.Text = "Call " + pokerPlayer.Chips;
                        potStatus.Text = (int.Parse(potStatus.Text) + pokerPlayer.Chips).ToString();
                    }
                }
                else
                {
                    if (raise > 0)
                    {
                        if (pokerPlayer.Chips >= raise * 2)
                        {
                            raise *= 2;

                            this.playerActions.Raised(
                                pokerPlayer, 
                                botStatus, 
                                ref raising,
                                ref raise,
                                ref neededChipsToCall,
                                potStatus);
                        }
                        else
                        {
                            this.playerActions.Call(
                                pokerPlayer, 
                                botStatus, 
                                ref raising, 
                                ref neededChipsToCall,
                                potStatus);
                        }
                    }
                    else
                    {
                        raise = neededChipsToCall * 2;

                        this.playerActions.Raised(
                            pokerPlayer, 
                            botStatus, 
                            ref raising, 
                            ref raise,
                            ref neededChipsToCall,
                            potStatus);
                    }
                }
            }

            if (pokerPlayer.Chips <= 0)
            {
                pokerPlayer.OutOfChips = true;
            }
        }