Exemple #1
0
        /// <summary>
        /// Removes all posting actions (antes and blinds) while adding their values to the pot
        /// This is done, because posting is involuntary and doesn't say anything about a player's playing style
        /// </summary>
        /// <param name="aquiredPokerRound">The Poker round from which to remove posting actions</param>
        /// <param name="potAfterPosting">The pot, that the posted amounts will be added to</param>
        /// <returns></returns>
        static bool NoActionsLeftAfterRemovingPostingActionsFromRound(
            ref IAquiredPokerRound aquiredPokerRound, ref double potAfterPosting)
        {
            try
            {
                // if no action in round initiate Player removal
                if (aquiredPokerRound.Actions.Count < 1)
                {
                    return(true);
                }

                // remove first actions in round as long as they are posting actions
                while (aquiredPokerRound[0].What == ActionTypes.P)
                {
                    // Update pot
                    potAfterPosting += aquiredPokerRound[0].Ratio;

                    // Remove
                    aquiredPokerRound.RemoveAction(0);

                    // If no action left initiate Player removal
                    if (aquiredPokerRound.Actions.Count < 1)
                    {
                        return(true);
                    }
                }
            }
            catch (Exception excep)
            {
                excep.Data.Add("Round: ", aquiredPokerRound.ToString());
                Log.Error("Unhandled", excep);
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Add a given Poker round to the Player
        /// </summary>
        /// <param name="aquiredRound">Poker Round to add</param>
        public IAquiredPokerPlayer AddRound(IAquiredPokerRound aquiredRound)
        {
            try
            {
                if (aquiredRound == null)
                {
                    throw new ArgumentNullException(
                              "aquiredRound", "Could be caused because wrong correct Round type was passed in.");
                }

                if (Count < 4)
                {
                    Rounds.Add(aquiredRound);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("aquiredRound",
                                                          "Tried to add BettingRound when Count is >= 4 already");
                }
            }
            catch (Exception excep)
            {
                Log.Error("Unexpected", excep);
            }

            return(this);
        }
Exemple #3
0
        /// <summary>
        /// Remove Posting and set BettingRound to null if no actions were left
        /// Antes and Blinds will be added to pot during removal
        /// </summary>
        /// <param name="aquiredHand">PokerHand</param>
        /// <returns>The pot at the beginning of the hand - containing blinds and antes</returns>
        protected virtual double RemovePostingActionsAndCalculatePotAfterPosting(ref IAquiredPokerHand aquiredHand)
        {
            double sumOfAllPostingAmounts = 0;
            var    playersToRemove        = new List <IAquiredPokerPlayer>();

            foreach (IAquiredPokerPlayer aquiredPlayer in aquiredHand)
            {
                // Does player have a round?
                if (aquiredPlayer.Count > (int)Streets.PreFlop)
                {
                    IAquiredPokerRound preflopRound = aquiredPlayer[Streets.PreFlop];

                    if (NoActionsLeftAfterRemovingPostingActionsFromRound(ref preflopRound, ref sumOfAllPostingAmounts))
                    {
                        // Must have been a sitout, otherwise he's have at least a preflop fold left
                        playersToRemove.Add(aquiredPlayer);
                    }
                }
                else
                {
                    // if player has no round, remove him b/c there is nothing he contributed to the hand
                    // not even a fold (so he was probably sitting out)
                    playersToRemove.Add(aquiredPlayer);
                }
            }

            foreach (IAquiredPokerPlayer aquiredPlayer in playersToRemove)
            {
                aquiredHand.RemovePlayer(aquiredPlayer);
            }

            return(sumOfAllPostingAmounts);
        }
Exemple #4
0
        protected virtual void ProcessRound(Streets street, IAquiredPokerRound aquiredPokerRound, IConvertedPokerPlayer convertedPlayer)
        {
            try
            {
                FoundAction = true;

                // Ignore returned chips (they didn't add or substract from the pot
                // and this action was not "done" by the player
                if (aquiredPokerRound[ActionCount].What != ActionTypes.U)
                {
                    IConvertedPokerAction convertedAction =
                        _actionConverter.Convert(
                            aquiredPokerRound[ActionCount], ref Pot, ref ToCall, _aquiredHand.TotalPot);

                    SequenceForCurrentRound.Add(
                        _convertedActionWithId.New.InitializeWith(convertedAction, convertedPlayer.Position));

                    SetActionSequenceAndAddActionTo(convertedPlayer, convertedAction, street);
                }
            }
            catch (Exception excep)
            {
                Log.Error("Unhandled", excep);
            }
        }
Exemple #5
0
        void ParseRiver(IAquiredPokerPlayer aquiredPlayer)
        {
            IAquiredPokerRound aquiredRound = GetPlayerActionsFor(StreetsParser.River, aquiredPlayer.Name);

            if (aquiredRound.Actions.Count > 0)
            {
                aquiredPlayer.AddRound(aquiredRound);
            }
        }
Exemple #6
0
        IAquiredPokerRound GetPlayerActionsFor(string streetHistory, string playerName)
        {
            IAquiredPokerRound aquiredRound = _aquiredRoundMake.New;

            foreach (IAquiredPokerAction action in PlayerActionsParser.Parse(streetHistory, playerName).PlayerActions)
            {
                aquiredRound.Add(action);
            }

            return(aquiredRound);
        }
Exemple #7
0
        void ParseTurnAndRiver(IAquiredPokerPlayer aquiredPlayer)
        {
            IAquiredPokerRound aquiredRound = GetPlayerActionsFor(StreetsParser.Turn, aquiredPlayer.Name);

            if (aquiredRound.Actions.Count > 0)
            {
                aquiredPlayer.AddRound(aquiredRound);
            }

            // The only reason to parse River if no Turn actions were found, is to find eventual Winning Actions
            if (StreetsParser.HasRiver)
            {
                ParseRiver(aquiredPlayer);
            }
        }
 public void InvokeProcessRound(Streets street, IAquiredPokerRound aquiredPokerRound, IConvertedPokerPlayer convertedPlayer)
 {
     ProcessRound(street, aquiredPokerRound, convertedPlayer);
 }