private void Showdown(Card[] board, ref HandRanker handRanker, int lastToAct)
        {
            var  firstToAct = GetNextActivePlayer(lastToAct);
            Hand playerBestHand;
            var  uncontestedPots = new List <int>();

            for (var potNum = 0; potNum < _potMan.Pots.Count; potNum++)
            {
                uncontestedPots.Add(potNum);
            }

            // evaluate and show hand for first player to act - flag them as winning for now
            playerBestHand = Hand.FindPlayersBestHand(_players[firstToAct].HoleCards(), board);
            BroadcastPlayerHand(firstToAct, playerBestHand);

            handRanker.AddHand(firstToAct, playerBestHand);
            uncontestedPots = uncontestedPots.Except(_potMan.GetPotsInvolvedIn(firstToAct)).ToList();

            // Loop through other active players
            var currPlayer = GetNextActivePlayer(firstToAct);

            do
            {
                var         player = _players[currPlayer];
                EActionType playersAction;
                int         playersAmount;

                // if not first to act then player may fold without showing cards (unless all in)
                // Also don't allow a player to fold if they are involved in a currently uncontested (side) pot
                var potsInvolvedIn = _potMan.GetPotsInvolvedIn(currPlayer);
                if (player.StackSize > 0 && (uncontestedPots.Intersect(potsInvolvedIn).Count() == 0))
                {
                    player.GetAction(EStage.StageShowdown, 0, 0, 0, 0, _potMan.Size(), out playersAction, out playersAmount);
                }
                else
                {
                    playersAction = EActionType.ActionShow;
                }

                if (playersAction == EActionType.ActionFold)
                {
                    _players[currPlayer].IsActive = false;
                    BroadcastAction(EStage.StageShowdown, currPlayer, playersAction, 0);
                }
                else
                {
                    playerBestHand = Hand.FindPlayersBestHand(player.HoleCards(), board);
                    handRanker.AddHand(currPlayer, playerBestHand);
                    uncontestedPots = uncontestedPots.Except(potsInvolvedIn).ToList();

                    BroadcastPlayerHand(currPlayer, playerBestHand);
                }

                currPlayer = GetNextActivePlayer(currPlayer);
            } while (currPlayer != firstToAct);
        }
Example #2
0
        private void Showdown(Card[] board, ref HandRanker handRanker, int lastToAct)
        {
            var firstToAct = GetNextActivePlayer(lastToAct);
            Hand playerBestHand;
            var uncontestedPots = new List<int>();

            for (var potNum = 0; potNum < _potMan.Pots.Count; potNum++)
            {
                uncontestedPots.Add(potNum);
            }

            // evaluate and show hand for first player to act - flag them as winning for now
            playerBestHand = Hand.FindPlayersBestHand(_players[firstToAct].HoleCards(), board);
            BroadcastPlayerHand(firstToAct, playerBestHand);

            handRanker.AddHand(firstToAct, playerBestHand);
            uncontestedPots = uncontestedPots.Except( _potMan.GetPotsInvolvedIn(firstToAct)).ToList();

            // Loop through other active players 
            var currPlayer = GetNextActivePlayer(firstToAct);

            do
            {
                var player = _players[currPlayer];
                EActionType playersAction;
                int playersAmount;

                // if not first to act then player may fold without showing cards (unless all in)
                // Also don't allow a player to fold if they are involved in a currently uncontested (side) pot
                var potsInvolvedIn = _potMan.GetPotsInvolvedIn(currPlayer);
                if (player.StackSize > 0 && (uncontestedPots.Intersect(potsInvolvedIn).Count() == 0))
                {
                    player.GetAction(EStage.StageShowdown, 0, 0, 0, 0, _potMan.Size(), out playersAction, out playersAmount);
                }
                else
                {
                    playersAction = EActionType.ActionShow;
                }

                if (playersAction == EActionType.ActionFold)
                {
                    _players[currPlayer].IsActive = false;
                    BroadcastAction(EStage.StageShowdown, currPlayer, playersAction, 0);
                }
                else
                {
                    playerBestHand = Hand.FindPlayersBestHand(player.HoleCards(), board);
                    handRanker.AddHand(currPlayer, playerBestHand);
                    uncontestedPots = uncontestedPots.Except(potsInvolvedIn).ToList();

                    BroadcastPlayerHand(currPlayer, playerBestHand);
                }

                currPlayer = GetNextActivePlayer(currPlayer);

            } while (currPlayer != firstToAct);
        }