/// <summary>
 /// Sets how much money is still needed from a specific player as Blind
 /// </summary>
 public void SetBlindNeeded(PlayerInfo p, int amnt)
 {
     if (m_BlindNeeded.ContainsKey(p))
         m_BlindNeeded[p] = amnt;
     else
         m_BlindNeeded.Add(p, amnt);
 }
 public ActionNeededEventArgs(PlayerInfo player, int amountNeeded, bool canFold, int minimumRaiseAmount, int maximumRaiseAmount) : base(player)
 {
     AmountNeeded = amountNeeded;
     CanFold = canFold;
     MinimumRaiseAmount = minimumRaiseAmount;
     MaximumRaiseAmount = maximumRaiseAmount;
 }
 public PlayerInfo SitInGame(PlayerInfo p)
 {
     Game.JoinGame(p);
     Game.GameTable.SitIn(p, -1);
     Game.AfterPlayerSat(p);
     return p;
 }
 public RemotePlayer(PokerGame game, PlayerInfo player, IBluffinClient client, IBluffinServer server, int tableId)
 {
     Game = game;
     Player = player;
     Client = client;
     TableId = tableId;
     Server = server;
 }
 public PotWonEventArgs(PlayerInfo p, int id, int amntWon, PokerHandEnum hand, string[] cards)
     : base(p)
 {
     m_Id = id;
     m_AmountWon = amntWon;
     m_Hand = hand;
     m_Cards = cards;
 }
        private void FoldPlayer(PlayerInfo p)
        {
            if (p.State != PlayerStateEnum.Zombie)
                p.State = PlayerStateEnum.SitIn;

            WaitALittle(Table.Params.WaitingTimes.AfterPlayerAction);

            Observer.RaisePlayerActionTaken(p, GameActionEnum.Fold, -1);
        }
        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 OnCardDiscarded(PlayerInfo p, string[] cards)
 {
     if (!m_Players.ContainsKey(p) || m_Players[p] != null || cards.Length < m_Minimum || cards.Length > m_Maximum)
         return false;
     m_Players[p] = cards;
     if (m_Players.All(x => x.Value != null))
         RaiseCompleted();
     return true;
 }
        public override bool OnMoneyPlayed(PlayerInfo p, int amnt)
        {
            if (Variant.NeedsBringIn)
            {
                Logger.LogDebugInformation("Currently, we need {0}, the bring in !!", Table.CallAmnt(p));
                if (amnt == -1)
                    return false;
            }

            return base.OnMoneyPlayed(p, amnt);
        }
        /// <summary>
        /// Add a player to the table
        /// </summary>
        public bool JoinGame(PlayerInfo p)
        {
            if (IsInitializing || !IsRunning)
            {
                Logger.LogError("Can't join, bad timing: {0}", State);
                return false;
            }

            Observer.RaisePlayerJoined(p);
            return Table.JoinTable(p);
        }
        public static void Compare(PlayerInfo p, PlayerInfo dp)
        {
            Assert.AreEqual(p.Cards.Length, dp.Cards.Length);
            for(int i = 0; i < p.Cards.Length; ++i)
                CompareGameCard.Compare(p.Cards[i],dp.Cards[i]);

            Assert.AreEqual(p.State, dp.State);
            Assert.AreEqual(p.NoSeat, dp.NoSeat);
            Assert.AreEqual(p.Name, dp.Name);
            Assert.AreEqual(p.MoneyBetAmnt, dp.MoneyBetAmnt);
            Assert.AreEqual(p.MoneySafeAmnt, dp.MoneySafeAmnt);
        }
        public int AfterPlayerSat(PlayerInfo p, int noSeat = -1, int moneyAmount = 1500)
        {
            var seat = p.NoSeat == -1 ? null : Table.Seats[p.NoSeat];
            if (seat != null && !seat.IsEmpty)
            {
                if (State > GameStateEnum.WaitForPlayers)
                    Table.NewArrivals.Add(p);

                Observer.RaiseSeatUpdated(seat.Clone());

                m_CurrentModule?.OnSitIn();
                return p.NoSeat;
            }
            return -1;
        }
        private bool SitOut(PlayerInfo p)
        {
            var oldSeat = p.NoSeat;
            if (oldSeat == -1)
                return true;

            p.State = PlayerStateEnum.Zombie;
            if (Table.SeatsContainsPlayer(p) && Table.SitOut(p))
            {
                var seat = new SeatInfo()
                {
                    Player = null,
                    NoSeat = oldSeat,
                };
                Observer.RaiseSeatUpdated(seat);
                return true;
            }
            return false;
        }
 public void PutBlinds(PlayerInfo p)
 {
     Game.PlayMoney(p, BlindNeeded(p));
 }
 public PlayerInfo PlayerNextTo(PlayerInfo p)
 {
     return Game.GameTable.GetSeatOfPlayingPlayerNextTo(Game.GameTable.Seats.Single(x => x.Player == p)).Player;
 }
        private void CallPlayer(PlayerInfo p, int played)
        {
            Table.NbPlayed++;

            WaitALittle(Table.Params.WaitingTimes.AfterPlayerAction);

            Observer.RaisePlayerActionTaken(p, GameActionEnum.Call, played);
        }
 public int BlindNeeded(PlayerInfo p)
 {
     return Game.GameTable.GetBlindNeeded(p);
 }
        private void RaisePlayer(PlayerInfo p, int played)
        {
            // Since every raise "restart" the round, 
            // the number of players who played is the number of AllIn players plus the raising player
            Table.NbPlayed = Table.NbAllIn;
            if (!p.IsAllIn)
                Table.NbPlayed++;

            Table.HigherBet = p.MoneyBetAmnt;

            WaitALittle(Table.Params.WaitingTimes.AfterPlayerAction);

            Observer.RaisePlayerActionTaken(p, GameActionEnum.Raise, played);
        }
 /// <summary>
 /// How much money a player needs to put as Blind
 /// </summary>
 public int GetBlindNeeded(PlayerInfo p)
 {
     if (m_BlindNeeded.ContainsKey(p))
         return m_BlindNeeded[p];
     return 0;
 }
        /// <summary>
        /// When a player leaves the table
        /// </summary>
        public override bool LeaveTable(PlayerInfo p)
        {
            if (!PeopleContainsPlayer(p))
                return false;

            if (!base.LeaveTable(p))
                return false;

            return true;
        }
        private void AddBet(PlayerInfo p, MoneyPot pot, int bet)
        {
            p.MoneyBetAmnt -= bet;
            pot.AddAmount(bet);

            if (bet >= 0 && (p.IsPlaying || p.IsAllIn))
                pot.AttachPlayer(p);
        }
        public SeatInfo SitIn(PlayerInfo p, int preferedSeat)
        {
            if (!RemainingSeats.Any())
            {
                LogManager.Log(LogLevel.Error, "TableInfo.JoinTable", "Not enough seats to join!");
                return null;
            }

            if (p.MoneyAmnt < Params.Lobby.MinimumAmountForBuyIn || p.MoneyAmnt > Params.Lobby.MaximumAmountForBuyIn)
            {
                LogManager.Log(LogLevel.Error, "TableInfo.JoinTable", "Player Money ({0}) is not between Minimum ({1}) and Maximum ({2})", p.MoneyAmnt, Params.Lobby.MinimumAmountForBuyIn, Params.Lobby.MaximumAmountForBuyIn);
                return null;
            }

            if (SeatsContainsPlayer(p))
            {
                LogManager.Log(LogLevel.Error, "TableInfo.JoinTable", "Already someone seated with the same name! Is this you ?");
                return null;
            }

            var seat = preferedSeat;

            if (preferedSeat < 0 || preferedSeat >= Seats.Count || !Seats[preferedSeat].IsEmpty)
                seat = RemainingSeats.First();
            return SitInToTable(p, seat);
        }
        /// <summary>
        /// When a player joined the table
        /// </summary>
        public override bool JoinTable(PlayerInfo p)
        {

            if (PeopleContainsPlayer(p))
            {
                LogManager.Log(LogLevel.Error, "TableInfo.JoinTable", "Already someone with the same name!");
                return false;
            }
            var ok = base.JoinTable(p);
            //if(ok)
            //    ok = SitIn(p);
            //if(!ok)
            //    base.LeaveTable(p);
            return ok;
        }
Exemple #24
0
 private void SetCallButtonName(PlayerInfo p)
 {
     var table = m_Game.Table;
     var s = "CALL";
     if (table.CanCheck(p))
         s = "CHECK";
     else if (table.HigherBet >= p.MoneyAmnt)
         s = "ALL-IN";
     btnCall.Text = s;
 }
 public void RaisePlayerActionNeeded(PlayerInfo p, int amountNeeded, bool canFold, int minimumRaiseAmount, int maximumRaiseAmount)
 {
     PlayerActionNeeded(m_Game, new ActionNeededEventArgs(p, amountNeeded, canFold, minimumRaiseAmount, maximumRaiseAmount));
 }
 public void RaisePlayerJoined(PlayerInfo p)
 {
     PlayerJoined(m_Game, new PlayerInfoEventArgs(p));
 }
 public void RaisePlayerHoleCardsChanged(PlayerInfo p)
 {
     PlayerHoleCardsChanged(m_Game, new PlayerInfoEventArgs(p));
 }
 public PotWonEventArgs(PlayerInfo p, int id, int amntWon)
     : base(p)
 {
     m_Id = id;
     m_AmountWon = amntWon;
 }
 public void RaisePlayerActionTaken(PlayerInfo p, GameActionEnum action, int amnt)
 {
     PlayerActionTaken(m_Game, new PlayerActionEventArgs(p, action, amnt));
 }
 /// <summary>
 /// Attach a player to the MoneyPot
 /// </summary>
 public void AttachPlayer(PlayerInfo p, HandEvaluationResult h = null)
 {
     m_AttachedPlayers.Add(new WinningPlayer() { Player = p, Hand = h });
 }