public override bool OnMoneyPlayed(PlayerInfo p, int amnt)
        {
            Logger.LogDebugInformation("Total blinds needed is {0}", Table.TotalBlindNeeded);
            Logger.LogDebugInformation("{0} is putting blind of {1}", p.Name, amnt);

            //What is the need Blind from the player ?
            var needed = Table.GetBlindNeeded(p);

            //If the player isn't giving what we expected from him
            if (amnt != needed)
            {
                //If the player isn't playing enough but it's all he got, time to go All-In
                if (amnt < needed && !p.CanBet(amnt + 1))
                {
                    Logger.LogDebugInformation("Player now All-In !");
                    p.State = PlayerStateEnum.AllIn;
                    Table.NbAllIn++;
                    Table.AddAllInCap(p.MoneyBetAmnt + amnt);
                }
                else //well, it's just not fair to play that
                {
                    Logger.LogWarning("{0} needed to put a blind of {1} and tried {2}", p.Name, needed, amnt);
                    return false;
                }
            }

            //Let's hope the player has enough money ! Time to put the blinds !
            if (!p.TryBet(amnt))
            {
                Logger.LogWarning("{0} just put more money than he actually have ({1} > {2})", p.Name, amnt, p.MoneySafeAmnt);
                return false;
            }

            //Hmmm ... More Money !! 
            Table.TotalPotAmnt += amnt;

            //Take note of the given Blind Amount for the player.
            Table.SetBlindNeeded(p, 0);

            //Take note of the action
            var whatAmIDoing = GameActionEnum.PostAnte;
            if (Table.Params.Blind == BlindTypeEnum.Blinds)
            {
                whatAmIDoing = (needed == Table.Params.GameSize ? GameActionEnum.PostBigBlind : GameActionEnum.PostSmallBlind);
            }
            Logger.LogDebugInformation("{0} POSTED BLIND ({1})", p.Name, whatAmIDoing);
            Observer.RaisePlayerActionTaken(p, whatAmIDoing, amnt);

            //Let's set the HigherBet
            if (amnt > Table.HigherBet)
                Table.HigherBet = amnt;

            Logger.LogDebugInformation("Total blinds still needed is {0}", Table.TotalBlindNeeded);

            DidWeGetAllWeNeeded();
            return true;
        }
        public override bool OnMoneyPlayed(PlayerInfo p, int amnt)
        {
            Logger.LogDebugInformation("Currently, we need {0} minimum money from this player", Table.CallAmnt(p));

            //Validation: Is it the player's turn to play ?
            if (p.NoSeat != Table.NoSeatCurrentPlayer)
            {
                Logger.LogWarning("{0} just played but it wasn't his turn", p.Name);
                return false;
            }

            //The Player is Folding
            if (amnt == -1)
            {
                Logger.LogDebugInformation("{0} FOLDED", p.Name);
                FoldPlayer(p);
                ContinueBettingRound();
                return true;
            }

            var amntNeeded = Table.CallAmnt(p);

            //Validation: Is the player betting under what he needs to Call ?
            if (amnt < amntNeeded)
            {
                //Validation: Can the player bet more ? If yes, this is not fair.
                if (p.CanBet(amnt + 1))
                {
                    Logger.LogWarning("{0} needed to play at least {1} and tried {2}", p.Name, amntNeeded, amnt);
                    return false;
                }

                //Else, well, that's ok, the player is All-In !
                amntNeeded = amnt;
            }

            if (amnt > amntNeeded && amnt < Table.MinRaiseAmnt(p))
            {
                Logger.LogWarning("{0} needed to play at least {1} to raise (CallAmount + MinRaiseAmount) and tried {2}", p.Name, Table.MinRaiseAmnt(p), amnt);
                return false;
            }

            //Let's hope the player has enough money ! Time to Bet!
            if (!p.TryBet(amnt))
            {
                Logger.LogWarning("{0} just put more money than he actually have ({1} > {2})", p.Name, amnt, p.MoneySafeAmnt);
                return false;
            }

            //Update the MinimumRaiseAmount
            Table.MinimumRaiseAmount = Math.Max(Table.MinimumRaiseAmount, amnt - amntNeeded);

            //Is the player All-In?
            if (p.MoneySafeAmnt == 0)
            {
                Logger.LogDebugInformation("Player now All-In !");
                p.State = PlayerStateEnum.AllIn;
                Table.NbAllIn++;
                Table.AddAllInCap(p.MoneyBetAmnt);
            }

            //Hmmm ... More Money !! 
            Table.TotalPotAmnt += amnt;

            //Was it a CALL or a RAISE ?
            if (amnt == amntNeeded)
            {
                Logger.LogDebugInformation("{0} CALLED WITH ${1}", p.Name, amnt);
                CallPlayer(p, amnt);
            }
            else
            {
                Logger.LogDebugInformation("{0} RAISED WITH ${1}", p.Name, amnt);
                RaisePlayer(p, amnt);
            }

            // Ok this player received enough attention !
            ContinueBettingRound();

            return true;
        }
Esempio n. 3
0
        private bool PlayBlinds(PlayerInfo p, int amnt)
        {
            LogManager.Log(LogLevel.MessageVeryLow, "PokerGame.PlayMoney", "Total blinds needed is {0}", GameTable.TotalBlindNeeded);
            LogManager.Log(LogLevel.MessageVeryLow, "PokerGame.PlayMoney", "{0} is putting blind of {1}", p.Name, amnt);

            //What is the need Blind from the player ?
            var needed = GameTable.GetBlindNeeded(p);

            //If the player isn't giving what we expected from him
            if (amnt != needed)
            {
                //If the player isn't playing enough but it's all he got, time to go All-In
                if (amnt < needed && !p.CanBet(amnt + 1))
                {
                    LogManager.Log(LogLevel.MessageVeryLow, "PokerGame.PlayMoney", "Player now All-In !");
                    p.State = PlayerStateEnum.AllIn;
                    Table.NbAllIn++;
                    GameTable.AddAllInCap(p.MoneyBetAmnt + amnt);
                }
                else //well, it's just not fair to play that
                {
                    LogManager.Log(LogLevel.Warning, "PokerGame.PlayMoney", "{0} needed to put a blind of {1} and tried {2}", p.Name, needed, amnt);
                    return false;
                }
            }

            //Let's hope the player has enough money ! Time to put the blinds !
            if (!p.TryBet(amnt))
            {
                LogManager.Log(LogLevel.Warning, "PokerGame.PlayMoney", "{0} just put more money than he actually have ({1} > {2})", p.Name, amnt, p.MoneySafeAmnt);
                return false;
            }

            //Hmmm ... More Money !! 
            Table.TotalPotAmnt += amnt;

            //Notify the change in the player's account
            Observer.RaisePlayerMoneyChanged(p);

            //Take note of the given Blind Amount for the player.
            GameTable.SetBlindNeeded(p, 0);

            //Take note of the action
            var whatAmIDoing = GameActionEnum.PostAnte;
            if(Table.Params.Blind.OptionType == BlindTypeEnum.Blinds)
            {
                var bob = Table.Params.Blind as BlindOptionsBlinds;
                if (bob != null && needed == bob.SmallBlindAmount)
                    whatAmIDoing = GameActionEnum.PostSmallBlind;
                else
                    whatAmIDoing = GameActionEnum.PostBigBlind;
            }
            LogManager.Log(LogLevel.MessageLow, "PokerGame.PlayMoney", "{0} POSTED BLIND ({1})", p.Name, whatAmIDoing);
            Observer.RaisePlayerActionTaken(p, whatAmIDoing, amnt);

            //Let's set the HigherBet
            if (amnt > Table.HigherBet)
                Table.HigherBet = amnt;

            LogManager.Log(LogLevel.MessageVeryLow, "PokerGame.PlayMoney", "Total blinds still needed is {0}", GameTable.TotalBlindNeeded);

            //If we got all the blinds, what are we waiting for ?!
            if (GameTable.TotalBlindNeeded == 0)
                AdvanceToNextGameState(); //Advancing to Playing State
            return true;
        }