Exemple #1
0
        public void Begin()
        {
            Players.Clear();
            CurrentBet = 0;
            NextRaise  = 0;
            Steps      = 0;

            PokerLogging.createPokerLog(Dealer.TableName);
            foreach (PokerPlayer player in Players.Players)
            {
                if (player.PendingCredit > 0)
                {
                    int balance = Banker.GetBalance(player.Mobile, TypeOfCurrency);
                    if ((player.PendingCredit + player.Currency) > Dealer.MinBuyIn &&
                        (player.PendingCredit + player.Currency) < Dealer.MaxBuyIn && balance >= player.PendingCredit)
                    {
                        player.Currency += player.PendingCredit;
                        Banker.Withdraw(player.Mobile, TypeOfCurrency, player.PendingCredit);
                        player.Mobile.SendMessage(61, "You have withdrawn " + player.PendingCredit + ".");
                        player.PendingCredit = 0;
                    }
                    else if ((player.PendingCredit + player.Currency) > Dealer.MaxBuyIn &&
                             balance >= player.PendingCredit)
                    {
                        int diff = Dealer.MaxBuyIn - player.Currency;

                        if (diff > 0)
                        {
                            player.Currency += diff;
                            Banker.Withdraw(player.Mobile, TypeOfCurrency, diff);
                            player.Mobile.SendMessage(61, "You have withdrawn " + diff + "gp.");
                            player.PendingCredit = 0;
                        }
                        else
                        {
                            player.Mobile.SendMessage(61,
                                                      "You cannot withdraw any further currency as you are at or above the max buy-in.");
                            player.PendingCredit = 0;
                        }
                    }
                    else if ((player.PendingCredit + player.Currency) < Dealer.MinBuyIn)
                    {
                        player.Mobile.SendMessage(61,
                                                  "Your current rebuy-in amount does not meet the minimum buy-in for this hand.");
                        player.PendingCredit = 0;
                    }
                }
            }

            List <PokerPlayer> dispose =
                Players.Players.Where(player => player.RequestLeave || !player.IsOnline() || player.Currency <= 0)
                .ToList();

            foreach (PokerPlayer player in dispose.Where(player => Players.Contains(player)))
            {
                RemovePlayer(player);
            }


            foreach (PokerPlayer player in Players.Players)
            {
                player.ClearGame();
                player.Game = this;

                if (player.Currency >= Dealer.BigBlind && player.IsOnline())
                {
                    Players.Round.Add(player);
                }
            }

            if (DealerButton == null)         //First round / more player
            {
                if (Players.Round.Count == 2) //Only use dealer button and small blind
                {
                    DealerButton = Players.Round[0];
                    SmallBlind   = Players.Round[1];
                    BigBlind     = null;
                }
                else if (Players.Round.Count > 2)
                {
                    DealerButton = Players.Round[0];
                    SmallBlind   = Players.Round[1];
                    BigBlind     = Players.Round[2];
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (Players.Round.Count == 2) //Only use dealer button and small blind
                {
                    if (DealerButton == Players.Round[0])
                    {
                        DealerButton = Players.Round[1];
                        SmallBlind   = Players.Round[0];
                    }
                    else
                    {
                        DealerButton = Players.Round[0];
                        SmallBlind   = Players.Round[1];
                    }

                    BigBlind = null;
                }
                else if (Players.Round.Count > 2)
                {
                    int index = Players.Round.IndexOf(DealerButton);

                    if (index == -1) //Old dealer button was lost :(
                    {
                        DealerButton = null;
                        Begin(); //Start over
                        return;
                    }

                    if (index == Players.Round.Count - 1)
                    {
                        DealerButton = Players.Round[0];
                        SmallBlind   = Players.Round[1];
                        BigBlind     = Players.Round[2];
                    }
                    else if (index == Players.Round.Count - 2)
                    {
                        DealerButton = Players.Round[Players.Round.Count - 1];
                        SmallBlind   = Players.Round[0];
                        BigBlind     = Players.Round[1];
                    }
                    else if (index == Players.Round.Count - 3)
                    {
                        DealerButton = Players.Round[Players.Round.Count - 2];
                        SmallBlind   = Players.Round[Players.Round.Count - 1];
                        BigBlind     = Players.Round[0];
                    }
                    else
                    {
                        DealerButton = Players.Round[index + 1];
                        SmallBlind   = Players.Round[index + 2];
                        BigBlind     = Players.Round[index + 3];
                    }
                }
                else
                {
                    return;
                }
            }

            PokerHand             = new PokerHandObject();
            PokerHand.Community   = new List <Card>();
            PokerHand.StartTime   = DateTime.Now;
            PokerHand.PokerGameId = new PokerHandSerial();

            PokerActions = new List <PokerActionObject>();

            PokerPlayers = new List <PokerPlayerObject>();

            CommunityCards.Clear();
            Deck = new Deck();

            State = PokerGameState.DealHoleCards;

            PokerLogging.StartNewHand(Dealer.TableName);

            PokerHand.InitialPlayers = Players.Players.Count;
            foreach (PokerPlayer player in Players.Players)
            {
                var playerobject = new PokerPlayerObject();

                playerobject.PokerPlayerId = new PokerPlayerSerial();
                playerobject.Serial        = player.Mobile.Serial;
                playerobject.charname      = player.Mobile.RawName;
                playerobject.HoleCards     = new List <Card>();
                playerobject.PokerGameId   = PokerHand.PokerGameId;
                playerobject.Bankroll      = player.Currency;
                PokerPlayers.Add(playerobject);
            }

            if (BigBlind != null)
            {
                BigBlind.Currency     -= Dealer.BigBlind;
                CommunityCurrency     += Dealer.BigBlind;
                BigBlind.RoundCurrency = Dealer.BigBlind;
                BigBlind.RoundBet      = Dealer.BigBlind;
                BigBlind.Bet           = Dealer.BigBlind;
            }
            else
            {
                DealerButton.Currency     -= Dealer.BigBlind;
                CommunityCurrency         += Dealer.BigBlind;
                DealerButton.RoundCurrency = Dealer.BigBlind;
                DealerButton.RoundBet      = Dealer.BigBlind;
                DealerButton.Bet           = Dealer.BigBlind;
            }

            SmallBlind.Currency     -= Dealer.SmallBlind;
            CommunityCurrency       += Dealer.SmallBlind;
            SmallBlind.RoundCurrency = Dealer.SmallBlind;
            SmallBlind.RoundBet      = Dealer.SmallBlind;
            SmallBlind.Bet           = Dealer.SmallBlind;

            NextRaise = Dealer.BigBlind;
            if (PokerPots == null)
            {
                PokerPots = new List <PokerPot>();
            }

            var pokerpotobj = new PokerPot();

            if (BigBlind != null)
            {
                pokerpotobj.AddtoPot(BigBlind.Bet, BigBlind);
                pokerpotobj.AddtoPot(SmallBlind.Bet, SmallBlind);
            }
            else
            {
                pokerpotobj.AddtoPot(SmallBlind.Bet, SmallBlind);
            }
            PokerPots.Add(pokerpotobj);

            if (BigBlind != null)
            {
                //m_Players.Push( m_BigBlind );
                BigBlind.SetBBAction();
                CurrentBet = Dealer.BigBlind;
            }
            else
            {
                //m_Players.Push( m_SmallBlind );
                SmallBlind.SetBBAction();
                CurrentBet = Dealer.BigBlind;
            }

            if (Players.Next() == null)
            {
                return;
            }

            NeedsGumpUpdate = true;
            Timer           = new PokerGameTimer(this);
            Timer.Start();
        }
Exemple #2
0
        public void Begin()
        {
            Players.Clear();
            CurrentBet = 0;
            NextRaise = 0;
            Steps = 0;

            PokerLogging.createPokerLog(Dealer.TableName);
            foreach (PokerPlayer player in Players.Players)
            {
                if (player.PendingCredit > 0)
                {
                    int balance = Banker.GetBalance(player.Mobile, TypeOfCurrency);
                    if ((player.PendingCredit + player.Currency) > Dealer.MinBuyIn &&
                        (player.PendingCredit + player.Currency) < Dealer.MaxBuyIn && balance >= player.PendingCredit)
                    {
                        player.Currency += player.PendingCredit;
                        Banker.Withdraw(player.Mobile, TypeOfCurrency, player.PendingCredit);
                        player.Mobile.SendMessage(61, "You have withdrawn " + player.PendingCredit + ".");
                        player.PendingCredit = 0;
                    }
                    else if ((player.PendingCredit + player.Currency) > Dealer.MaxBuyIn &&
                             balance >= player.PendingCredit)
                    {
                        int diff = Dealer.MaxBuyIn - player.Currency;

                        if (diff > 0)
                        {
                            player.Currency += diff;
                            Banker.Withdraw(player.Mobile, TypeOfCurrency, diff);
                            player.Mobile.SendMessage(61, "You have withdrawn " + diff + "gp.");
                            player.PendingCredit = 0;
                        }
                        else
                        {
                            player.Mobile.SendMessage(61,
                                "You cannot withdraw any further currency as you are at or above the max buy-in.");
                            player.PendingCredit = 0;
                        }
                    }
                    else if ((player.PendingCredit + player.Currency) < Dealer.MinBuyIn)
                    {
                        player.Mobile.SendMessage(61,
                            "Your current rebuy-in amount does not meet the minimum buy-in for this hand.");
                        player.PendingCredit = 0;
                    }
                }
            }

            List<PokerPlayer> dispose =
                Players.Players.Where(player => player.RequestLeave || !player.IsOnline() || player.Currency <= 0)
                    .ToList();

            foreach (PokerPlayer player in dispose.Where(player => Players.Contains(player)))
            {
                RemovePlayer(player);
            }


            foreach (PokerPlayer player in Players.Players)
            {
                player.ClearGame();
                player.Game = this;

                if (player.Currency >= Dealer.BigBlind && player.IsOnline())
                {
                    Players.Round.Add(player);
                }
            }

            if (DealerButton == null) //First round / more player
            {
                if (Players.Round.Count == 2) //Only use dealer button and small blind
                {
                    DealerButton = Players.Round[0];
                    SmallBlind = Players.Round[1];
                    BigBlind = null;
                }
                else if (Players.Round.Count > 2)
                {
                    DealerButton = Players.Round[0];
                    SmallBlind = Players.Round[1];
                    BigBlind = Players.Round[2];
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (Players.Round.Count == 2) //Only use dealer button and small blind
                {
                    if (DealerButton == Players.Round[0])
                    {
                        DealerButton = Players.Round[1];
                        SmallBlind = Players.Round[0];
                    }
                    else
                    {
                        DealerButton = Players.Round[0];
                        SmallBlind = Players.Round[1];
                    }

                    BigBlind = null;
                }
                else if (Players.Round.Count > 2)
                {
                    int index = Players.Round.IndexOf(DealerButton);

                    if (index == -1) //Old dealer button was lost :(
                    {
                        DealerButton = null;
                        Begin(); //Start over
                        return;
                    }

                    if (index == Players.Round.Count - 1)
                    {
                        DealerButton = Players.Round[0];
                        SmallBlind = Players.Round[1];
                        BigBlind = Players.Round[2];
                    }
                    else if (index == Players.Round.Count - 2)
                    {
                        DealerButton = Players.Round[Players.Round.Count - 1];
                        SmallBlind = Players.Round[0];
                        BigBlind = Players.Round[1];
                    }
                    else if (index == Players.Round.Count - 3)
                    {
                        DealerButton = Players.Round[Players.Round.Count - 2];
                        SmallBlind = Players.Round[Players.Round.Count - 1];
                        BigBlind = Players.Round[0];
                    }
                    else
                    {
                        DealerButton = Players.Round[index + 1];
                        SmallBlind = Players.Round[index + 2];
                        BigBlind = Players.Round[index + 3];
                    }
                }
                else
                {
                    return;
                }
            }

            PokerHand = new PokerHandObject();
            PokerHand.Community = new List<Card>();
            PokerHand.StartTime = DateTime.Now;
            PokerHand.PokerGameId = new PokerHandSerial();

            PokerActions = new List<PokerActionObject>();

            PokerPlayers = new List<PokerPlayerObject>();

            CommunityCards.Clear();
            Deck = new Deck();

            State = PokerGameState.DealHoleCards;

            PokerLogging.StartNewHand(Dealer.TableName);

            PokerHand.InitialPlayers = Players.Players.Count;
            foreach (PokerPlayer player in Players.Players)
            {
                var playerobject = new PokerPlayerObject();

                playerobject.PokerPlayerId = new PokerPlayerSerial();
                playerobject.Serial = player.Mobile.Serial;
                playerobject.charname = player.Mobile.RawName;
                playerobject.HoleCards = new List<Card>();
                playerobject.PokerGameId = PokerHand.PokerGameId;
                playerobject.Bankroll = player.Currency;
                PokerPlayers.Add(playerobject);
            }

            if (BigBlind != null)
            {
                BigBlind.Currency -= Dealer.BigBlind;
                CommunityCurrency += Dealer.BigBlind;
                BigBlind.RoundCurrency = Dealer.BigBlind;
                BigBlind.RoundBet = Dealer.BigBlind;
                BigBlind.Bet = Dealer.BigBlind;
            }
            else
            {
                DealerButton.Currency -= Dealer.BigBlind;
                CommunityCurrency += Dealer.BigBlind;
                DealerButton.RoundCurrency = Dealer.BigBlind;
                DealerButton.RoundBet = Dealer.BigBlind;
                DealerButton.Bet = Dealer.BigBlind;                
            }

            SmallBlind.Currency -= Dealer.SmallBlind;
            CommunityCurrency += Dealer.SmallBlind;
            SmallBlind.RoundCurrency = Dealer.SmallBlind;
            SmallBlind.RoundBet = Dealer.SmallBlind;
            SmallBlind.Bet = Dealer.SmallBlind;

            NextRaise = Dealer.BigBlind;
            if (PokerPots == null)
            {
                PokerPots = new List<PokerPot>();
            }

            var pokerpotobj = new PokerPot();

            if (BigBlind != null)
            {
                pokerpotobj.AddtoPot(BigBlind.Bet, BigBlind);
                pokerpotobj.AddtoPot(SmallBlind.Bet, SmallBlind);
            }
            else
            {
                pokerpotobj.AddtoPot(SmallBlind.Bet, SmallBlind);           
            }
            PokerPots.Add(pokerpotobj);

            if (BigBlind != null)
            {
                //m_Players.Push( m_BigBlind );
                BigBlind.SetBBAction();
                CurrentBet = Dealer.BigBlind;
            }
            else
            {
                //m_Players.Push( m_SmallBlind );
                SmallBlind.SetBBAction();
                CurrentBet = Dealer.BigBlind;
            }

            if (Players.Next() == null)
            {
                return;
            }

            NeedsGumpUpdate = true;
            Timer = new PokerGameTimer(this);
            Timer.Start();
        }