Esempio n. 1
0
		public void Push(PokerPlayer player)
		{
			if (!Turn.Contains(player))
			{
				Turn.Add(player);
			}
		}
Esempio n. 2
0
		public PokerBetGump(PokerGame game, PokerPlayer player, bool canCall)
			: base(460, 425)
		{
			m_CanCall = canCall;
			m_Game = game;
			m_Player = player;

			Closable = false;
			Disposable = false;
			Dragable = true;
			Resizable = false;
			AddPage(0);

			//this.AddImageTiled( 0, 0, 170, 165, 2624 );
			//this.AddImageTiled( 2, 2, 166, 161, 3604 );
			//this.AddImageTiled( 4, 4, 162, 157, 3504 );
			//this.AddImageTiled( 6, 6, 158, 153, 3604 );
			//this.AddAlphaRegion( 6, 6, 158, 153 );
			AddBackground(0, 0, 200, 130, 9270);

            AddRadio(14, 20, 9727, 9730, true, canCall && (m_Game.CurrentBet - m_Player.RoundBet) > 0 ? (int)Buttons.Call : (int)Buttons.Check);
			AddRadio(14, 50, 9727, 9730, false, (int)Buttons.Fold);
			AddRadio(14, 80, 9727, 9730, false, canCall ? (int)Buttons.Raise : (int)Buttons.Bet);

			AddHtml(50, 24, 60, 45, Color(canCall && (m_Game.CurrentBet - m_Player.RoundBet) > 0 ? "Call" : "Check", COLOR_WHITE), false, false);

            if (canCall && (m_Game.CurrentBet - m_Player.RoundBet) > 0)
            {
                AddHtml(
                    105,
                    24,
                    60,
                    22,
                    Color(
                            m_Game.CurrentBet - player.RoundBet >= player.Currency
                                ? "all-in"
                                : String.Format("{0:#,0}", m_Game.CurrentBet - m_Player.RoundBet),
                        COLOR_GREEN),
                    false,
                    false);
            }

            AddHtml(50, 54, 60, 45, Color("Fold", COLOR_WHITE), false, false);
            AddHtml(50, 84, 60, 45, Color(canCall ? "Raise" : "Bet", COLOR_WHITE), false, false);
            AddTextEntry(105, 84, 60, 22, 455, (int)Buttons.txtBet, game.NextRaise < game.Dealer.BigBlind ? game.Dealer.BigBlind.ToString(CultureInfo.InvariantCulture) : game.NextRaise.ToString());

			AddButton(104, 53, 247, 248, (int)Buttons.Okay, GumpButtonType.Reply, 0);
		}
Esempio n. 3
0
        public void CheckPot(int amount, PokerPlayer player, bool allin = false)
        {
            /*if (allin)
             * {
             *  foreach (PokerPot pokerPot in PokerPots)
             *  {
             *      if (pokerPot.MaxContributionAmountPerPlayer == 0)
             *      {
             *          pokerPot.MaxContributionAmountPerPlayer = amount + player.RoundCurrency;
             *          break;
             *      }
             *
             *      if (amount + player.RoundCurrency < pokerPot.MaxContributionAmountPerPlayer)
             *      {
             *          Dictionary<PokerPlayer, int> newpot = pokerPot.CheckAllIn(amount + player.RoundCurrency);
             *
             *          foreach (PokerPlayer p in Players.Players)
             *          {
             *              p.Mobile.SendMessage(61, "POT DIVISION OCCURRED");
             *          }
             *
             *          newpot = PokerPots.Aggregate(newpot, (current, pot) => pot.DivisionAdjustment(current));
             *
             *          PokerPots.Add(new PokerPot(newpot));
             *          break;
             *      }
             *  }
             * }
             * amount = PokerPots.Aggregate(amount, (current, pokerPot) => pokerPot.CheckContribution(current, player));
             *
             * if (amount > 0)
             * {
             *  foreach (PokerPlayer p in Players.Players)
             *  {
             *      p.Mobile.SendMessage(61, "SPLIT POT CREATED: " + amount + "GP ADDED TO IT");
             *  }
             *
             *  PokerPots.Add(new PokerPot(amount, player));
             * }*/

            var mainpot = PokerPots.FirstOrDefault();

            if (mainpot != null)
            {
                mainpot.AddtoPot(amount, player);
            }
        }
Esempio n. 4
0
		private void DrawPlayers()
		{
			int RADIUS = 240;
			int centerX = CARD_X + ( m_Game.State < PokerGameState.Turn ? 15 : m_Game.State < PokerGameState.River ? 30 : 45 );
			int centerY = CARD_Y + RADIUS;

			if ( m_Game.State > PokerGameState.DealHoleCards )
			{
				int lastX = centerX;
				int lastY = centerY - 85;

				for ( int i = 0; i < m_Player.HoleCards.Count; ++i )
				{
					this.AddBackground( lastX, lastY, 71, 95, 9350 );
					this.AddLabelCropped( lastX + 10, lastY + 5, 80, 60, m_Player.HoleCards[i].GetSuitColor(), m_Player.HoleCards[i].GetRankLetter() );
					this.AddLabelCropped( lastX + 6, lastY + 25, 75, 60, m_Player.HoleCards[i].GetSuitColor(), m_Player.HoleCards[i].GetSuitString() );

					lastX += 30;
				}
			}

			int playerIndex = m_Game.GetIndexFor( m_Player.Mobile );
			int counter = m_Game.Players.Count - 1;

			for ( double i = playerIndex + 1; counter >= 0; ++i )
			{
				if ( i == m_Game.Players.Count )
					i = 0;

				PokerPlayer current = m_Game.Players[(int)i];
				double xdist = RADIUS * Math.Sin( counter * 2.0 * Math.PI / m_Game.Players.Count );
				double ydist = RADIUS * Math.Cos( counter * 2.0 * Math.PI / m_Game.Players.Count );

				int x = centerX + (int)xdist;
				int y = CARD_Y + (int)ydist;

				this.AddBackground( x, y, 101, 65, 9270 ); //changed from 9200.  This is the gump that shows your name and gold left.

				if ( current.HasBlindBet || current.HasDealerButton )
                    this.AddHtml(x, y - 15, 101, 45, Color(Center(current.HasBigBlind ? "(Big Blind)" : current.HasSmallBlind ? "(Small Blind)" : "(Dealer Button)"), COLOR_GREEN), false, false); // changed from COLOR_YELLOW

				this.AddHtml( x, y + 5, 101, 45, Color( Center( current.Mobile.Name ), ( m_Game.Players.Peek() == current ? COLOR_GREEN : !m_Game.Players.Round.Contains( current ) ? COLOR_OFF_WHITE : COLOR_PINK ) ), false, false );
				this.AddHtml( x + 2, y + 24, 101, 45, Color( Center( "(" + current.Gold.ToString( "#,###" ) + ")" ), COLOR_GOLD ), false, false );

				--counter;
			}
		}
Esempio n. 5
0
		public PokerTableGump(PokerGame game, PokerPlayer player)
			: base(0, 0)
		{
			m_Game = game;
			m_Player = player;

			Closable = false;
			Disposable = true;
			Dragable = true;
			Resizable = false;
			AddPage(0);

			if (m_Game.State > PokerGameState.PreFlop)
			{
				DrawCards();
			}

			DrawPlayers();
		}
Esempio n. 6
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from        = state.Mobile;
            int    buyInAmount = 0;

            if (info.ButtonID == 1)
            {
                int balance = Banker.GetBalance(from);
                if (balance >= m_Game.Dealer.MinBuyIn)
                {
                    try
                    {
                        buyInAmount = Convert.ToInt32((info.TextEntries[0]).Text);
                    }
                    catch
                    {
                        from.SendMessage(0x22, "Use numbers without commas to input your buy-in amount (ie 25000)");
                        return;
                    }

                    if (buyInAmount <= balance && buyInAmount >= m_Game.Dealer.MinBuyIn && buyInAmount <= m_Game.Dealer.MaxBuyIn)
                    {
                        PokerPlayer player = new PokerPlayer(from);
                        player.Gold = buyInAmount;
                        m_Game.AddPlayer(player);
                    }
                    else
                    {
                        from.SendMessage(0x22, "You may not join with that amount of gold. Minimum buy-in: " + Convert.ToString(m_Game.Dealer.MinBuyIn) +
                                         ", Maximum buy-in: " + Convert.ToString(m_Game.Dealer.MaxBuyIn));
                    }
                }
                else
                {
                    from.SendMessage(0x22, "You may not join with that amount of gold. Minimum buy-in: " + Convert.ToString(m_Game.Dealer.MinBuyIn) +
                                     ", Maximum buy-in: " + Convert.ToString(m_Game.Dealer.MaxBuyIn));
                }
            }
            else if (info.ButtonID == 2)
            {
                return;
            }
        }
Esempio n. 7
0
        public void CheckLonePlayer()
        {
            int allInCount = Players.Round.Count(t => t.IsAllIn);

            PokerPlayer loner = null;

            if (allInCount == Players.Round.Count - 1)
            {
                foreach (PokerPlayer p in Players.Round.Where(t => !t.IsAllIn))
                {
                    loner = p;
                }
            }

            if (loner != null)
            {
                loner.LonePlayer = true;
            }
        }
Esempio n. 8
0
        public PokerTableGump(PokerGame game, PokerPlayer player)
            : base(0, 0)
        {
            m_Game   = game;
            m_Player = player;

            Closable   = false;
            Disposable = true;
            Dragable   = true;
            Resizable  = false;
            AddPage(0);

            if (m_Game.State > PokerGameState.PreFlop)
            {
                DrawCards();
            }

            DrawPlayers();
        }
Esempio n. 9
0
		public PokerTableGump( PokerGame game, PokerPlayer player )
			: base( 0, 0 )
		{
			m_Game = game;
			m_Player = player;

			this.Closable = true;
			this.Disposable = true;
			this.Dragable = true;
			this.Resizable = false;
			this.AddPage( 0 );

			if ( m_Game.State > PokerGameState.PreFlop )
				DrawCards();

			DrawPlayers();

			if ( m_Game.State > PokerGameState.Inactive )
				this.AddLabel( 350, 340, 148, "Pot: " + m_Game.CommunityGold.ToString( "#,###" ) );
		}
Esempio n. 10
0
		public PokerTableGump( PokerGame game, PokerPlayer player )
			: base( 0, 0 )
		{
			m_Game = game;
			m_Player = player;

			this.Closable = true;
			this.Disposable = true;
			this.Dragable = true;
			this.Resizable = false;
			this.AddPage( 0 );

			if ( m_Game.State > PokerGameState.PreFlop )
				DrawCards();

			DrawPlayers();

			if ( m_Game.State > PokerGameState.Inactive )
				this.AddLabel( 350, 340, 148, "Pot: " + m_Game.CommunityGold.ToString( "#,###" ) );
		}
Esempio n. 11
0
        public PokerBetGump(PokerGame game, PokerPlayer player, bool canCall)
            : base(460, 400)
        {
            m_CanCall = canCall;
            m_Game    = game;
            m_Player  = player;

            this.Closable   = false;
            this.Disposable = false;
            this.Dragable   = true;
            this.Resizable  = false;
            this.AddPage(0);

            //this.AddImageTiled( 0, 0, 170, 165, 2624 );
            //this.AddImageTiled( 2, 2, 166, 161, 3604 );
            //this.AddImageTiled( 4, 4, 162, 157, 3504 );
            //this.AddImageTiled( 6, 6, 158, 153, 3604 );
            //this.AddAlphaRegion( 6, 6, 158, 153 );
            this.AddBackground(0, 0, 160, 155, 9270);

            this.AddRadio(14, 10, 9727, 9730, true, (canCall ? (int)Buttons.Call : (int)Buttons.Check));
            this.AddRadio(14, 40, 9727, 9730, false, (int)Buttons.Fold);
            this.AddRadio(14, 70, 9727, 9730, false, (int)Buttons.AllIn);
            this.AddRadio(14, 100, 9727, 9730, false, (canCall ? (int)Buttons.Raise : (int)Buttons.Bet));

            this.AddHtml(45, 14, 60, 45, Color(canCall ? "Call" : "Check", COLOR_WHITE), false, false);

            if (canCall)
            {
                this.AddHtml(75, 14, 60, 22, Color(Center((m_Game.CurrentBet - player.RoundBet >= player.Gold ? "all-in" : String.Format("{0}", (m_Game.CurrentBet - m_Player.RoundBet).ToString("#,###")))), COLOR_GREEN), false, false);
            }

            this.AddHtml(45, 44, 60, 45, Color("Fold", COLOR_WHITE), false, false);
            this.AddHtml(45, 74, 60, 45, Color("All In", COLOR_WHITE), false, false);
            this.AddHtml(45, 104, 60, 45, Color(canCall ? "Raise" : "Bet", COLOR_WHITE), false, false);
            this.AddTextEntry(85, 104, 60, 22, 455, (int)Buttons.txtBet, game.Dealer.BigBlind.ToString());

            this.AddButton(95, 132, 247, 248, (int)Buttons.Okay, GumpButtonType.Reply, 0);
        }
Esempio n. 12
0
        public static void PokerKick_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            if (from == null)
            {
                return;
            }

            IPooledEnumerable eable = from.GetMobilesInRange(0);

            foreach (Mobile m in eable)
            {
                if (m is PlayerMobile)
                {
                    PlayerMobile pm = (PlayerMobile)m;

                    PokerGame game = pm.PokerGame;

                    if (game != null)
                    {
                        PokerPlayer player = game.GetPlayer(m);

                        if (player != null)
                        {
                            game.RemovePlayer(player);
                            from.SendMessage("They have been removed from the poker table");
                            return;
                        }
                    }
                }
            }

            eable.Free();

            from.SendMessage("No one found to kick from a poker table. Make sure you are standing on top of them.");
        }
Esempio n. 13
0
		public PokerBetGump( PokerGame game, PokerPlayer player, bool canCall )
			: base( 460, 400 )
		{
			m_CanCall = canCall;
			m_Game = game;
			m_Player = player;

			this.Closable = false;
			this.Disposable = false;
			this.Dragable = true;
			this.Resizable = false;
			this.AddPage( 0 );

			//this.AddImageTiled( 0, 0, 170, 165, 2624 );
			//this.AddImageTiled( 2, 2, 166, 161, 3604 );
			//this.AddImageTiled( 4, 4, 162, 157, 3504 );
			//this.AddImageTiled( 6, 6, 158, 153, 3604 );
			//this.AddAlphaRegion( 6, 6, 158, 153 );
            this.AddBackground(0, 0, 160, 155, 9270);

			this.AddRadio( 14, 10, 9727, 9730, true, ( canCall ? (int)Buttons.Call : (int)Buttons.Check ) );
			this.AddRadio( 14, 40, 9727, 9730, false, (int)Buttons.Fold );
			this.AddRadio( 14, 70, 9727, 9730, false, (int)Buttons.AllIn );
			this.AddRadio( 14, 100, 9727, 9730, false, ( canCall ? (int)Buttons.Raise : (int)Buttons.Bet ) );

			this.AddHtml( 45, 14, 60, 45, Color( canCall ? "Call" : "Check", COLOR_WHITE ), false, false );

			if ( canCall )
				this.AddHtml( 75, 14, 60, 22, Color( Center( ( m_Game.CurrentBet - player.RoundBet >= player.Gold ? "all-in" : String.Format( "{0}", ( m_Game.CurrentBet - m_Player.RoundBet ).ToString( "#,###" ) ) ) ), COLOR_GREEN ), false, false );

			this.AddHtml( 45, 44, 60, 45, Color( "Fold", COLOR_WHITE ), false, false );
			this.AddHtml( 45, 74, 60, 45, Color( "All In", COLOR_WHITE ), false, false );
			this.AddHtml( 45, 104, 60, 45, Color( canCall ? "Raise" : "Bet", COLOR_WHITE ), false, false );
			this.AddTextEntry( 85, 104, 60, 22, 455, (int)Buttons.txtBet, game.Dealer.BigBlind.ToString() );

			this.AddButton( 95, 132, 247, 248, (int)Buttons.Okay, GumpButtonType.Reply, 0 );
		}
Esempio n. 14
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            if (from == null)
            {
                return;
            }

            PokerPlayer player = m_Game.GetPlayer(from);

            if (player != null)
            {
                if (info.ButtonID == 1)
                {
                    if (m_Game.State == PokerGameState.Inactive)
                    {
                        if (m_Game.Players.Contains(player))
                        {
                            m_Game.RemovePlayer(player);
                        }
                        return;
                    }


                    if (player.RequestLeave)
                    {
                        from.SendMessage(0x22, "You have already submitted a request to leave.");
                    }
                    else
                    {
                        from.SendMessage(0x22, "You have submitted a request to leave the table.");
                        player.RequestLeave = true;
                    }
                }
            }
        }
Esempio n. 15
0
		private static void EventSink_Disconnected(DisconnectedEventArgs e)
		{
			Mobile from = e.Mobile;

			if (from == null)
			{
				return;
			}

			if (!(from is PlayerMobile))
			{
				return;
			}

			var pm = (PlayerMobile)from;

			PokerGame game = pm.PokerGame;

			if (game == null)
			{
				return;
			}

			PokerPlayer player = game.GetPlayer(from);

			if (player != null)
			{
			    Timer.DelayCall(TimeSpan.FromMinutes(1), () =>
			    {
			        if (!player.IsOnline())
			        {
			            player.RequestLeave = true;
			        }
			    });
			}
		}
Esempio n. 16
0
        /*public Dictionary<PokerPlayer, int> CheckAllIn(int maxamount)
        {
            MaxContributionAmountPerPlayer = maxamount;

            return CheckPotDivision();
        }

        public Dictionary<PokerPlayer, int> CheckPotDivision()
        {
            var toreturn = new Dictionary<PokerPlayer, int>();

            foreach (KeyValuePair<PokerPlayer, int> entry in ContributionToPot.ToArray())
            {
                if (entry.Value > MaxContributionAmountPerPlayer)
                {
                    int diff = entry.Value - MaxContributionAmountPerPlayer;
                    toreturn.Add(entry.Key, diff);
                    ContributionToPot[entry.Key] -= diff;
                    PotCurrency -= diff;
                }
            }

            return toreturn;
        }

        public Dictionary<PokerPlayer, int> DivisionAdjustment(Dictionary<PokerPlayer, int> input)
        {
            var toreturn = new Dictionary<PokerPlayer, int>();

            foreach (KeyValuePair<PokerPlayer, int> entry in input)
            {
                if (!ContributionToPot.ContainsKey(entry.Key))
                {
                    if (MaxContributionAmountPerPlayer == 0 && entry.Key.Currency == 0)
                    {
                        MaxContributionAmountPerPlayer = entry.Value;
                    }
                    else if (MaxContributionAmountPerPlayer > 0 && entry.Key.Currency == 0 &&
                             entry.Value < MaxContributionAmountPerPlayer)
                    {
                        MaxContributionAmountPerPlayer = entry.Value;
                    }
                }
                else
                {
                    if (MaxContributionAmountPerPlayer == 0 && entry.Key.Currency == 0)
                    {
                        MaxContributionAmountPerPlayer = entry.Value + ContributionToPot[entry.Key];
                    }
                    else if (MaxContributionAmountPerPlayer > 0 && entry.Key.Currency == 0 &&
                             entry.Value + ContributionToPot[entry.Key] < MaxContributionAmountPerPlayer)
                    {
                        MaxContributionAmountPerPlayer = entry.Value + ContributionToPot[entry.Key];
                    }
                }
            }

            foreach (KeyValuePair<PokerPlayer, int> entry in input)
            {
                int current = 0;
                if (ContributionToPot.ContainsKey(entry.Key))
                {
                    current = ContributionToPot[entry.Key];
                }

                int allowedcontribution = MaxContributionAmountPerPlayer - current;

                if (MaxContributionAmountPerPlayer == 0 || allowedcontribution > 0 && entry.Value < allowedcontribution)
                {
                    ContributionToPot.Add(entry.Key, entry.Value);
                    PotCurrency += entry.Value;
                }
                else if (entry.Value > allowedcontribution && allowedcontribution > 0)
                {
                    int diff = entry.Value - allowedcontribution;
                    ContributionToPot.Add(entry.Key, allowedcontribution);
                    PotCurrency += allowedcontribution;
                    toreturn.Add(entry.Key, diff);
                }
                else
                {
                    toreturn.Add(entry.Key, entry.Value);
                }
            }

            foreach (KeyValuePair<PokerPlayer, int> contributer in ContributionToPot.ToArray())
            {
                if (MaxContributionAmountPerPlayer > 0 && contributer.Value > MaxContributionAmountPerPlayer)
                {
                    int diff = contributer.Value - MaxContributionAmountPerPlayer;
                    PotCurrency -= diff;
                    ContributionToPot[contributer.Key] -= diff;
                    if (toreturn.ContainsKey(contributer.Key))
                    {
                        toreturn[contributer.Key] += diff;
                    }
                    else
                    {
                        toreturn.Add(contributer.Key, contributer.Value);
                    }
                }
            }

            return toreturn;
        }

        public int CheckContribution(int amount, PokerPlayer player)
        {
            int leftover = 0;

            if (MaxContributionAmountPerPlayer == 0)
            {
                if (ContributionToPot.ContainsKey(player))
                {
                    ContributionToPot[player] += amount;
                }
                else
                {
                    ContributionToPot.Add(player, amount);
                }
                PotCurrency += amount;
            }
            else if (MaxContributionAmountPerPlayer > 0)
            {
                if (!ContributionToPot.ContainsKey(player))
                {
                    int allowablecontribution = MaxContributionAmountPerPlayer;

                    if (amount >= allowablecontribution)
                    {
                        ContributionToPot.Add(player, MaxContributionAmountPerPlayer);
                        leftover = amount - allowablecontribution;
                        PotCurrency += MaxContributionAmountPerPlayer;
                    }
                    else
                    {
                        ContributionToPot.Add(player, amount);
                        PotCurrency += amount;
                    }
                }
                else
                {
                    int currcontribution = ContributionToPot[player];

                    if (currcontribution == MaxContributionAmountPerPlayer)
                    {
                        leftover = amount;
                    }
                    else
                    {
                        int allowablecontribution = MaxContributionAmountPerPlayer - currcontribution;

                        if (amount >= allowablecontribution)
                        {
                            ContributionToPot[player] = MaxContributionAmountPerPlayer;
                            leftover = amount - allowablecontribution;
                            PotCurrency += allowablecontribution;
                        }
                        else
                        {
                            ContributionToPot[player] += amount;
                            PotCurrency += amount;
                        }
                    }
                }
            }
            player.Mobile.SendMessage(61, "There is currently: " + PotCurrency);
            return leftover;
        }*/

        public void AddtoPot(int amount, PokerPlayer player)
        {
            if (ContributionToPot.ContainsKey(player))
            {
                ContributionToPot[player] += amount;
                PotCurrency += amount;
            }
            else
            {
                ContributionToPot.Add(player, amount);
                PotCurrency += amount;
            }
        }
Esempio n. 17
0
        public void RemovePlayer(PokerPlayer player)
        {
            Mobile from = player.Mobile;

            if (from is PlayerMobile)
            {
                var playermob = from as PlayerMobile;
                playermob.PokerJoinTimer = DateTime.UtcNow + TimeSpan.FromMinutes(1);

                playermob.Blessed = false;
            }

            if (from == null || !Players.Contains(player))
            {
                return;
            }

            Players.Players.Remove(player);

            if (Players.Peek() == player) //It is currently their turn, fold them.
            {
                player.CloseGump(typeof(PokerBetGump));
                Timer.m_LastPlayer = null;
                player.Action      = PlayerAction.Fold;
            }

            if (Players.Round.Contains(player))
            {
                Players.Round.Remove(player);
            }

            if (Players.Turn.Contains(player))
            {
                Players.Turn.Remove(player);
            }

            if (Players.Round.Count == 0)
            {
                if (PokerPlayers != null && PokerPlayers.Exists(x => x.Serial == player.Mobile.Serial))
                {
                    PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Credit += CommunityCurrency;
                }
                player.Currency  += CommunityCurrency;
                CommunityCurrency = 0;

                if (GameBackup.PokerGames.Contains(this))
                {
                    GameBackup.PokerGames.Remove(this);
                }
            }

            if (player.Currency > 0)
            {
                if (from.BankBox == null) //Should NEVER happen, but JUST IN CASE!
                {
                    Utility.PushColor(ConsoleColor.Red);
                    Console.WriteLine(
                        "WARNING: Player \"{0}\" with account \"{1}\" had null bank box while trying to deposit {2:#,0} {3}. Player will NOT recieve their gold.",
                        from.Name,
                        from.Account == null ? "(-null-)" : from.Account.Username,
                        player.Currency,
                        (Dealer.IsDonation ? "donation coins" : "gold"));
                    Utility.PopColor();

                    try
                    {
                        using (var op = new StreamWriter("poker_error.log", true))
                        {
                            op.WriteLine(
                                "WARNING: Player \"{0}\" with account \"{1}\" had null bankbox while poker script was trying to deposit {2:#,0} {3}. Player will NOT recieve their gold.",
                                from.Name,
                                from.Account == null ? "(-null-)" : from.Account.Username,
                                player.Currency,
                                (Dealer.IsDonation ? "donation coins" : "gold"));
                        }
                    }
                    catch
                    {}

                    from.SendMessage(
                        0x22,
                        "WARNING: Could not find your bank box. All of your poker money has been lost in this error. Please contact a Game Master to resolve this issue.");
                }
                else
                {
                    if (Banker.Deposit(from, TypeOfCurrency, player.Currency))
                    {
                        from.SendMessage(0x22, "{0:#,0} {1} has been deposited into your bank box.", player.Currency,
                                         (Dealer.IsDonation ? "donation coins" : "gold"));
                    }
                    else
                    {
                        BankCheck check;
                        if (Dealer.IsDonation)
                        {
                            check = new BankCheck(player.Currency, true);
                        }
                        else
                        {
                            check = new BankCheck(player.Currency);
                        }
                        from.Backpack.DropItem(check);
                        from.SendMessage(0x22, "{0:#,0} {1} has been placed in your bag.", player.Currency,
                                         (Dealer.IsDonation ? "donation coins" : "gold"));
                    }
                }
            }

            player.CloseAllGumps();
            ((PlayerMobile)from).PokerGame = null;
            from.Location = Dealer.ExitLocation;
            from.Map      = Dealer.ExitMap;
            from.SendMessage(0x22, "You have left the table");

            NeedsGumpUpdate = true;
        }
Esempio n. 18
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;
            int    buyInAmount;

            if (info.ButtonID != 1)
            {
                return;
            }

            PokerPlayer pokerplayer = m_Game.GetPlayer(from);

            if (pokerplayer != null)
            {
                int balance = Banker.GetBalance(from, m_Game.TypeOfCurrency);

                int currency = pokerplayer.Currency;

                if (balance + currency < m_Game.Dealer.MinBuyIn)
                {
                    from.SendMessage(
                        0x22,
                        "You do not have enough {0} to buy back in to the game. Minimum buy-in: {1:#,0}",
                        (m_Game.Dealer.IsDonation ? "donation coins" : "gold"),
                        m_Game.Dealer.MinBuyIn);

                    return;
                }


                var t = info.GetTextEntry(3);

                if (!Int32.TryParse(t.Text, out buyInAmount))
                {
                    from.SendMessage(0x22, "Use numbers without commas to input your buy-in amount (ie 25000)");
                    return;
                }

                if (buyInAmount > balance)
                {
                    from.SendMessage(
                        0x22,
                        "You do not have enough {0} to cover the specified buy-in amount.",
                        (m_Game.Dealer.IsDonation ? "donation coins" : "gold"));

                    return;
                }

                if (buyInAmount + currency < m_Game.Dealer.MinBuyIn)
                {
                    from.SendMessage(
                        0x22,
                        "You must at least specify an amount that equals the minimum buy-in. Minimum buy-in: {0:#,0}",
                        m_Game.Dealer.MinBuyIn);

                    return;
                }

                if (buyInAmount + currency > m_Game.Dealer.MaxBuyIn)
                {
                    from.SendMessage(
                        0x22,
                        "The specified buy-in amount + your current chips would put you over the max allowable buy-in.  Maximum buy-in: {0:#,0}",
                        m_Game.Dealer.MaxBuyIn);

                    return;
                }

                pokerplayer.PendingCredit = buyInAmount;
                pokerplayer.CloseGump(typeof(PokerTableGump));
                pokerplayer.SendGump(new PokerTableGump(m_Game, pokerplayer));
            }
        }
Esempio n. 19
0
        public static void PokerPlayerAction(PokerPlayer player, PlayerAction action, string tablename, bool isDonation)
        {
            try
            {
                using (var op = new StreamWriter("Logs/Poker/" + tablename + ".log", true))
                {

                        op.WriteLine(
                            "Player {0} with account {1} {4} for {2:#,0} {3}.",
                            player.Mobile.Name,
                            player.Mobile.Account == null ? "(-null-)" : player.Mobile.Account.Username,
                            player.Bet,
                            (isDonation ? "donation coins" : "gold"),
                            player.Action);
                }
            }
            catch
            { }
        }
Esempio n. 20
0
 public static void EndHandCurrency(string tablename, PokerPlayer player, bool isDonation)
 {
     try
     {
         using (var op = new StreamWriter("Logs/Poker/" + tablename + ".log", true))
         {
             op.WriteLine("{0} ended the hand with {1:#,0} {2}.", player.Mobile.Name,
                 player.Currency,
                 (isDonation ? "donation coins" : "gold"));
             op.Close();
         }
     }
     catch
     { }
 }
Esempio n. 21
0
		public ResultEntry( PokerPlayer player )
		{
			m_Player = player;
		}
Esempio n. 22
0
		public PokerGameTimer( PokerGame game )
			: base( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ) )
		{
			m_Game = game;
			m_LastState = PokerGameState.Inactive;
			m_LastPlayer = null;
		}
Esempio n. 23
0
        public void PokerGame_PlayerMadeDecision(PokerPlayer player)
        {
            if (Players.Peek() != player)
            {
                return;
            }

            if (player.Mobile == null)
            {
                return;
            }

            bool resetTurns = false;

            Steps++;

            var pobj = new PokerActionObject(PokerHand.PokerGameId, Steps,
                                             PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).PokerPlayerId, (int)State / 2,
                                             (int)player.Action, 0);

            switch (player.Action)
            {
            case PlayerAction.None:
                break;

            case PlayerAction.Bet:
            {
                NextRaise = player.Bet;
                CheckPot(player.Bet, player);
                PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Debit += player.Bet;
                PokerMessage(player.Mobile, String.Format("I bet {0}.", player.Bet));
                CurrentBet            = player.Bet;
                player.RoundBet       = player.Bet;
                player.Currency      -= player.Bet;
                player.RoundCurrency += player.Bet;
                CommunityCurrency    += player.Bet;
                resetTurns            = true;
                pobj.Amount           = player.Bet;

                break;
            }

            case PlayerAction.Raise:
            {
                PokerMessage(player.Mobile, String.Format("I raise by {0}.", player.Bet));

                NextRaise = player.Bet;

                CurrentBet += player.Bet;

                int diff = CurrentBet - player.RoundBet;

                CheckPot(diff, player);
                PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Debit += diff;
                player.Currency      -= diff;
                player.RoundCurrency += diff;
                player.RoundBet      += diff;
                CommunityCurrency    += diff;
                player.Bet            = diff;
                resetTurns            = true;
                pobj.Amount           = diff;


                break;
            }

            case PlayerAction.Call:
            {
                PokerMessage(player.Mobile, "I call.");

                int diff = CurrentBet - player.RoundBet;     //how much they owe in the pot

                CheckPot(diff, player);
                player.Bet = diff;
                PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Debit += player.Bet;
                player.Currency      -= diff;
                player.RoundCurrency += diff;
                player.RoundBet      += diff;
                CommunityCurrency    += diff;

                pobj.Amount = player.Bet;


                break;
            }

            case PlayerAction.Check:
            {
                if (!player.LonePlayer)
                {
                    PokerMessage(player.Mobile, "Check.");
                }
                pobj.Amount = 0;
                break;
            }

            case PlayerAction.Fold:
            {
                PokerMessage(player.Mobile, "I fold.");
                pobj.Amount = 0;

                PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Folded = 1;

                if (Players.Round.Contains(player))
                {
                    Players.Round.Remove(player);
                }

                if (Players.Turn.Contains(player))
                {
                    Players.Turn.Remove(player);
                }

                if (Players.Round.Count == 1)
                {
                    DoShowdown(true);
                    return;
                }

                foreach (var pokerPot in PokerPots)
                {
                    pokerPot.ContributionToPot.Remove(player);
                }

                break;
            }

            case PlayerAction.AllIn:
            {
                if (!player.IsAllIn)
                {
                    PokerMessage(player.Mobile, player.Forced ? "I call: all-in." : "All in.");


                    int diff = player.Currency - CurrentBet;

                    if (diff > 0)
                    {
                        CurrentBet += diff;
                        NextRaise  += diff;
                    }

                    player.Bet = player.Currency;
                    CheckPot(player.Bet, player, true);
                    PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Debit += player.Currency;
                    player.RoundCurrency += player.Currency;
                    player.RoundBet      += player.Currency;
                    CommunityCurrency    += player.Currency;
                    pobj.Amount           = player.Currency;
                    player.Currency       = 0;


                    //We need to check to see if this is a follow up action, or a first call
                    //before we reset the turns
                    if (Players.Prev() != null)
                    {
                        resetTurns = (Players.Prev().Action == PlayerAction.Check);

                        PokerPlayer prev = Players.Prev();

                        if (prev.Action == PlayerAction.Check ||
                            (prev.Action == PlayerAction.Bet && prev.Bet < player.Bet) ||
                            (prev.Action == PlayerAction.AllIn && prev.Bet < player.Bet) ||
                            (prev.Action == PlayerAction.Call && prev.Bet < player.Bet) ||
                            (prev.Action == PlayerAction.Raise && prev.Bet < player.Bet))
                        {
                            resetTurns = true;
                        }
                    }
                    else
                    {
                        resetTurns = true;
                    }

                    PokerActions.Add(pobj);
                    player.IsAllIn = true;

                    player.Forced = false;
                }

                break;
            }
            }

            PokerLogging.PokerPlayerAction(player, player.Action, Dealer.TableName, Dealer.IsDonation);

            if (!player.IsAllIn)
            {
                PokerActions.Add(pobj);
            }

            if (resetTurns)
            {
                Players.Turn.Clear();
                Players.Push(player);
            }

            Timer.m_LastPlayer = null;
            Timer.hasWarned    = false;

            if (Players.Turn.Count == Players.Round.Count)
            {
                State = (PokerGameState)((int)State + 1);
            }
            else
            {
                AssignNextTurn();
            }

            NeedsGumpUpdate = true;
        }
Esempio n. 24
0
        public void PokerGame_PlayerMadeDecision(PokerPlayer player)
        {
            if (m_Players.Peek() == player)
            {
                if (player.Mobile == null)
                {
                    return;
                }

                bool resetTurns = false;

                switch (player.Action)
                {
                case PlayerAction.None: break;

                case PlayerAction.Bet:
                {
                    PokerMessage(player.Mobile, string.Format("I bet {0}.", player.Bet));
                    m_CurrentBet      = player.Bet;
                    player.RoundBet   = player.Bet;
                    player.Gold      -= player.Bet;
                    player.RoundGold += player.Bet;
                    m_CommunityGold  += player.Bet;
                    resetTurns        = true;

                    break;
                }

                case PlayerAction.Raise:
                {
                    PokerMessage(player.Mobile, string.Format("I raise by {0}.", player.Bet));
                    m_CurrentBet += player.Bet;
                    int diff = m_CurrentBet - player.RoundBet;
                    player.Gold      -= diff;
                    player.RoundGold += diff;
                    player.RoundBet  += diff;
                    m_CommunityGold  += diff;
                    player.Bet        = diff;
                    resetTurns        = true;

                    break;
                }

                case PlayerAction.Call:
                {
                    PokerMessage(player.Mobile, "I call.");

                    int diff = m_CurrentBet - player.RoundBet;                                     //how much they owe in the pot
                    player.Bet        = diff;
                    player.Gold      -= diff;
                    player.RoundGold += diff;
                    player.RoundBet  += diff;
                    m_CommunityGold  += diff;

                    break;
                }

                case PlayerAction.Check:
                {
                    if (!player.LonePlayer)
                    {
                        PokerMessage(player.Mobile, "Check.");
                    }

                    break;
                }

                case PlayerAction.Fold:
                {
                    PokerMessage(player.Mobile, "I fold.");

                    if (m_Players.Round.Contains(player))
                    {
                        m_Players.Round.Remove(player);
                    }
                    if (m_Players.Turn.Contains(player))
                    {
                        m_Players.Turn.Remove(player);
                    }

                    if (m_Players.Round.Count == 1)
                    {
                        DoShowdown(true);
                        return;
                    }

                    break;
                }

                case PlayerAction.AllIn:
                {
                    if (!player.IsAllIn)
                    {
                        if (player.Forced)
                        {
                            PokerMessage(player.Mobile, "I call: all-in.");
                        }
                        else
                        {
                            PokerMessage(player.Mobile, "All in.");
                        }

                        int diff = player.Gold - m_CurrentBet;

                        if (diff > 0)
                        {
                            m_CurrentBet += diff;
                        }

                        player.Bet        = player.Gold;
                        player.RoundGold += player.Gold;
                        player.RoundBet  += player.Gold;
                        m_CommunityGold  += player.Gold;
                        player.Gold       = 0;

                        //We need to check to see if this is a follow up action, or a first call
                        //before we reset the turns
                        if (m_Players.Prev() != null)
                        {
                            resetTurns = (m_Players.Prev().Action == PlayerAction.Check);

                            PokerPlayer prev = m_Players.Prev();

                            if (prev.Action == PlayerAction.Check ||
                                (prev.Action == PlayerAction.Bet && prev.Bet < player.Bet) ||
                                (prev.Action == PlayerAction.AllIn && prev.Bet < player.Bet) ||
                                (prev.Action == PlayerAction.Call && prev.Bet < player.Bet) ||
                                (prev.Action == PlayerAction.Raise && prev.Bet < player.Bet))
                            {
                                resetTurns = true;
                            }
                        }
                        else
                        {
                            resetTurns = true;
                        }

                        player.IsAllIn = true;
                        player.Forced  = false;
                    }

                    break;
                }
                }

                if (resetTurns)
                {
                    m_Players.Turn.Clear();
                    m_Players.Push(player);
                }

                m_Timer.m_LastPlayer = null;
                m_Timer.hasWarned    = false;

                if (m_Players.Turn.Count == m_Players.Round.Count)
                {
                    m_State = (PokerGameState)((int)m_State + 1);
                }
                else
                {
                    AssignNextTurn();
                }

                m_NeedsGumpUpdate = true;
            }
        }
Esempio n. 25
0
        public void AddPlayer(PokerPlayer player)
        {
            Mobile from = player.Mobile;

            if (from == null)
            {
                return;
            }

            if (!m_Dealer.InRange(from.Location, 8))
            {
                from.PrivateOverheadMessage(Server.Network.MessageType.Regular, 0x22, true, "I am too far away to do that", from.NetState);
            }
            else if (GetIndexFor(from) != -1)
            {
                from.SendMessage(0x22, "You are already seated at this table");
            }
            else if (m_Players.Count >= m_Dealer.MaxPlayers)
            {
                from.SendMessage(0x22, "Sorry, that table is full");
            }

            /*else if ( TournamentSystem.TournamentCore.SignedUpTeam( from ) != null || TournamentSystem.TournamentCore.FindTeam( from ) != null )
             *      from.SendMessage( 0x22, "You may not join a poker game while signed up for a tournament." );*/
            else if (Banker.Withdraw(from, player.Gold))
            {
                Point3D seat = Point3D.Zero;

                foreach (Point3D seats in m_Dealer.Seats)
                {
                    if (!m_Dealer.SeatTaken(seats))
                    {
                        seat = seats;
                        break;
                    }
                }

                if (seat == Point3D.Zero)
                {
                    from.SendMessage(0x22, "Sorry, that table is full");
                    return;
                }

                player.Game = this;
                player.Seat = seat;
                player.TeleportToSeat();
                m_Players.Players.Add(player);

                ((PlayerMobile)from).PokerGame = this;
                from.SendMessage(0x22, "You have been seated at the table");

                if (m_Players.Count == 1 && !GameBackup.PokerGames.Contains(this))
                {
                    GameBackup.PokerGames.Add(this);
                }
                else if (m_State == PokerGameState.Inactive && m_Players.Count > 1 && !m_Dealer.TournamentMode)
                {
                    Begin();
                }
                else if (m_State == PokerGameState.Inactive && m_Players.Count >= m_Dealer.MaxPlayers && m_Dealer.TournamentMode)
                {
                    m_Dealer.TournamentMode = false;
                    Begin();
                }

                player.Mobile.CloseGump <PokerTableGump>();
                player.SendGump(new PokerTableGump(this, player));
                m_NeedsGumpUpdate = true;
            }
            else
            {
                from.SendMessage(0x22, "Your bank box lacks the funds to join this poker table");
            }
        }
Esempio n. 26
0
        public void Begin()
        {
            m_Players.Clear();
            m_CurrentBet = 0;

            List <PokerPlayer> dispose = new List <PokerPlayer>();

            foreach (PokerPlayer player in m_Players.Players)
            {
                if (player.RequestLeave || !player.IsOnline())
                {
                    dispose.Add(player);
                }
            }

            foreach (PokerPlayer player in dispose)
            {
                if (m_Players.Contains(player))
                {
                    RemovePlayer(player);
                }
            }

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

                if (player.Gold >= m_Dealer.BigBlind && player.IsOnline())
                {
                    m_Players.Round.Add(player);
                }
            }

            if (m_DealerButton == null)               //First round / more player
            {
                if (m_Players.Round.Count == 2)       //Only use dealer button and small blind
                {
                    m_DealerButton = m_Players.Round[0];
                    m_SmallBlind   = m_Players.Round[1];
                    m_BigBlind     = null;
                }
                else if (m_Players.Round.Count > 2)
                {
                    m_DealerButton = m_Players.Round[0];
                    m_SmallBlind   = m_Players.Round[1];
                    m_BigBlind     = m_Players.Round[2];
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (m_Players.Round.Count == 2)                   //Only use dealer button and small blind
                {
                    if (m_DealerButton == m_Players.Round[0])
                    {
                        m_DealerButton = m_Players.Round[1];
                        m_SmallBlind   = m_Players.Round[0];
                    }
                    else
                    {
                        m_DealerButton = m_Players.Round[0];
                        m_SmallBlind   = m_Players.Round[1];
                    }

                    m_BigBlind = null;
                }
                else if (m_Players.Round.Count > 2)
                {
                    int index = m_Players.Round.IndexOf(m_DealerButton);

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

                    if (index == m_Players.Round.Count - 1)
                    {
                        m_DealerButton = m_Players.Round[0];
                        m_SmallBlind   = m_Players.Round[1];
                        m_BigBlind     = m_Players.Round[2];
                    }
                    else if (index == m_Players.Round.Count - 2)
                    {
                        m_DealerButton = m_Players.Round[m_Players.Round.Count - 1];
                        m_SmallBlind   = m_Players.Round[0];
                        m_BigBlind     = m_Players.Round[1];
                    }
                    else if (index == m_Players.Round.Count - 3)
                    {
                        m_DealerButton = m_Players.Round[m_Players.Round.Count - 2];
                        m_SmallBlind   = m_Players.Round[m_Players.Round.Count - 1];
                        m_BigBlind     = m_Players.Round[0];
                    }
                    else
                    {
                        m_DealerButton = m_Players.Round[index + 1];
                        m_SmallBlind   = m_Players.Round[index + 2];
                        m_BigBlind     = m_Players.Round[index + 3];
                    }
                }
                else
                {
                    return;
                }
            }

            m_CommunityCards.Clear();
            m_Deck = new Deck();

            m_State = PokerGameState.DealHoleCards;

            if (m_BigBlind != null)
            {
                m_BigBlind.Gold     -= m_Dealer.BigBlind;
                m_CommunityGold     += m_Dealer.BigBlind;
                m_BigBlind.RoundGold = m_Dealer.BigBlind;
                m_BigBlind.RoundBet  = m_Dealer.BigBlind;
                m_BigBlind.Bet       = m_Dealer.BigBlind;
            }

            m_SmallBlind.Gold     -= m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;
            m_CommunityGold       += m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;
            m_SmallBlind.RoundGold = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;
            m_SmallBlind.RoundBet  = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;
            m_SmallBlind.Bet       = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;

            if (m_BigBlind != null)
            {
                //m_Players.Push( m_BigBlind );
                m_BigBlind.SetBBAction();
                m_CurrentBet = m_Dealer.BigBlind;
            }
            else
            {
                //m_Players.Push( m_SmallBlind );
                m_SmallBlind.SetBBAction();
                m_CurrentBet = m_Dealer.BigBlind;
            }

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

            m_NeedsGumpUpdate = true;
            m_Timer           = new PokerGameTimer(this);
            m_Timer.Start();
        }
Esempio n. 27
0
        public void RemovePlayer(PokerPlayer player)
        {
            Mobile from = player.Mobile;

            if (from != null && m_Players.Contains(player))
            {
                m_Players.Players.Remove(player);

                if (m_Players.Peek() == player)                   //It is currently their turn, fold them.
                {
                    player.Mobile.CloseGump <PokerBetGump>();
                    m_Timer.m_LastPlayer = null;
                    player.Action        = PlayerAction.Fold;
                }

                if (m_Players.Round.Contains(player))
                {
                    m_Players.Round.Remove(player);
                }
                if (m_Players.Turn.Contains(player))
                {
                    m_Players.Turn.Remove(player);
                }

                if (m_Players.Round.Count == 0)
                {
                    player.Gold    += m_CommunityGold;
                    m_CommunityGold = 0;

                    if (GameBackup.PokerGames.Contains(this))
                    {
                        GameBackup.PokerGames.Remove(this);
                    }
                }

                if (player.Gold > 0)
                {
                    if (from.BankBox == null)                       //Should NEVER happen, but JUST IN CASE!
                    {
                        Utility.PushColor(ConsoleColor.Red);
                        Console.WriteLine("WARNING: Player \"{0}\" with account \"{1}\" had null bankbox while trying to deposit {2} gold. Player will NOT recieve their gold.", from.Name, (from.Account == null ? "(-null-)" : from.Account.Username), player.Gold);
                        Utility.PopColor();

                        try
                        {
                            using (System.IO.StreamWriter op = new System.IO.StreamWriter("poker_error.log", true))
                                op.WriteLine("WARNING: Player \"{0}\" with account \"{1}\" had null bankbox while poker script was trying to deposit {2} gold. Player will NOT recieve their gold.", from.Name, (from.Account == null ? "(-null-)" : from.Account.Username), player.Gold);
                        }
                        catch { }

                        from.SendMessage(0x22, "WARNING: Could not find your bankbox. All of your poker money has been lost in this error. Please contact a Game Master to resolve this issue.");
                    }
                    else
                    {
                        Banker.Deposit(from.BankBox, player.Gold);
                        from.SendMessage(0x22, "{0}gp has been deposited into your bankbox.", player.Gold);
                    }
                }

                player.CloseAllGumps();
                ((PlayerMobile)from).PokerGame = null;
                from.Location = m_Dealer.ExitLocation;
                from.Map      = m_Dealer.ExitMap;
                from.SendMessage(0x22, "You have left the table");

                m_NeedsGumpUpdate = true;
            }
        }
Esempio n. 28
0
        private void DrawPlayers()
        {
            const int RADIUS  = 240;
            const int centerY = CARD_Y + RADIUS;

            int centerX = CARD_X + (m_Game.State < PokerGameState.Turn ? 15 : m_Game.State < PokerGameState.River ? 30 : 45);

            if (m_Game.State > PokerGameState.Inactive && m_Game.CommunityCurrency > 0)
            {
                AddItem(centerX + 30, 340, 3823, m_Game.Dealer.IsDonation ? 1153 : 0);
                AddHtml((centerX + 30) - 78, 343, 200, 20, String.Format("<BASEFONT COLOR=#{1}><B><BIG><CENTER>{0}</CENTER></BIG></B></BASEFONT>",
                                                                         m_Game.CommunityCurrency.ToString("#,0"), m_Game.Dealer.IsDonation ? "FFD700" : "FFFACD"), false, false);
            }

            if (m_Game.State > PokerGameState.DealHoleCards)
            {
                const int lastY = centerY - 85;

                int lastX = centerX;

                foreach (Card c in m_Player.HoleCards)
                {
                    AddBackground(lastX, lastY, 71, 95, 9350);
                    AddLabelCropped(lastX + 10, lastY + 5, 80, 60, c.GetSuitColor(), c.GetRankLetter());
                    AddLabelCropped(lastX + 6, lastY + 25, 75, 60, c.GetSuitColor(), c.GetSuitString());

                    lastX += 30;
                }
            }

            int playerIndex = m_Game.GetIndexFor(m_Player.Mobile);
            int counter     = m_Game.Players.Count - 1;

            for (double i = playerIndex + 1; counter >= 0; ++i)
            {
                if (i == m_Game.Players.Count)
                {
                    i = 0;
                }

                PokerPlayer current = m_Game.Players[(int)i];
                double      xdist   = RADIUS * Math.Sin(counter * 2.0 * Math.PI / m_Game.Players.Count);
                double      ydist   = RADIUS * Math.Cos(counter * 2.0 * Math.PI / m_Game.Players.Count);

                int x = centerX + (int)xdist;
                int y = CARD_Y + (int)ydist;

                AddBackground(x, y, 101, 65, 9270);
                //changed from 9200.  This is the gump that shows your name and gold left.

                if (current.HasDealerButton)
                {
                    AddHtml(
                        x,
                        y - 15,
                        101,
                        45,
                        Color(
                            Center("(Dealer Button)"),
                            COLOR_GREEN),
                        false,
                        false); // changed from COLOR_YELLOW
                }

                AddHtml(
                    x,
                    y + 15,
                    101,
                    45,
                    Color(
                        Center(current.Mobile.RawName.Length > 8 ? (current.Mobile.RawName).Substring(0, 8) : current.Mobile.RawName),
                        m_Game.Players.Peek() == current
                                                         ? COLOR_GREEN
                                                         : !m_Game.Players.Round.Contains(current) ? COLOR_OFF_WHITE : COLOR_PINK),
                    false,
                    false);
                AddHtml(
                    x + 2, y + 30, 101, 45, Color(Center("(" + current.Currency.ToString("#,0") + ")"), COLOR_GOLD), false, false);

                if (current == m_Player)
                {
                    if (current.RoundBet > 0)
                    {
                        AddItem(x + 27, y - 40, 3823, m_Game.Dealer.IsDonation ? 1153 : 0);
                        AddHtml(x, y - 38, 100, 20,
                                String.Format("<BASEFONT COLOR=#{1}><B><BIG><CENTER>{0}</CENTER></BIG></B></BASEFONT>",
                                              current.RoundBet.ToString("#,0"), m_Game.Dealer.IsDonation ? "FFD700" : "FFFACD"), false, false);
                    }
                }
                else
                {
                    if (current.RoundBet > 0)
                    {
                        AddItem(x + 27, y + 70, 3823, m_Game.Dealer.IsDonation ? 1153 : 0);
                        AddHtml(x, y + 72, 100, 20,
                                String.Format("<BASEFONT COLOR=#{1}><B><BIG><CENTER>{0}</CENTER></BIG></B></BASEFONT>",
                                              current.RoundBet.ToString("#,0"), m_Game.Dealer.IsDonation ? "FFD700" : "FFFACD"), false, false);
                    }
                }
                --counter;
            }
        }
Esempio n. 29
0
		public void Push( PokerPlayer player )
		{
			if(!m_Turn.Contains(player))
				m_Turn.Add( player ); ;
		}
Esempio n. 30
0
		public void AddPlayer( PokerPlayer player )
		{
			Mobile from = player.Mobile;

			if ( from == null )
				return;

			if ( !m_Dealer.InRange( from.Location, 8 ) )
				from.PrivateOverheadMessage( Server.Network.MessageType.Regular, 0x22, true, "I am too far away to do that", from.NetState );
			else if ( GetIndexFor( from ) != -1 )
				from.SendMessage( 0x22, "You are already seated at this table" );
			else if ( m_Players.Count >= m_Dealer.MaxPlayers )
				from.SendMessage( 0x22, "Sorry, that table is full" );
			/*else if ( TournamentSystem.TournamentCore.SignedUpTeam( from ) != null || TournamentSystem.TournamentCore.FindTeam( from ) != null )
				from.SendMessage( 0x22, "You may not join a poker game while signed up for a tournament." );*/
			else if ( Banker.Withdraw( from, player.Gold ) )
			{
				Point3D seat = Point3D.Zero;

				foreach ( Point3D seats in m_Dealer.Seats )
					if ( !m_Dealer.SeatTaken( seats ) )
					{
						seat = seats;
						break;
					}

				if ( seat == Point3D.Zero )
				{
					from.SendMessage( 0x22, "Sorry, that table is full" );
					return;
				}

				player.Game = this;
				player.Seat = seat;
				player.TeleportToSeat();
				m_Players.Players.Add( player );

				( (PlayerMobile)from ).PokerGame = this;
				from.SendMessage( 0x22, "You have been seated at the table" );

				if ( m_Players.Count == 1 && !GameBackup.PokerGames.Contains( this ) )
					GameBackup.PokerGames.Add( this );
				else if ( m_State == PokerGameState.Inactive && m_Players.Count > 1 && !m_Dealer.TournamentMode )
					Begin();
				else if ( m_State == PokerGameState.Inactive && m_Players.Count >= m_Dealer.MaxPlayers && m_Dealer.TournamentMode )
				{
					m_Dealer.TournamentMode = false;
					Begin();
				}

				player.CloseGump( typeof( PokerTableGump ) );
				player.SendGump( new PokerTableGump( this, player ) );
				m_NeedsGumpUpdate = true;
			}
			else
				from.SendMessage( 0x22, "Your bank box lacks the funds to join this poker table" );
		}
Esempio n. 31
0
        public void RemovePlayer(PokerPlayer player)
        {
            Mobile from = player.Mobile;

            if (from is PlayerMobile)
            {
                var playermob = from as PlayerMobile;
                playermob.PokerJoinTimer = DateTime.UtcNow + TimeSpan.FromMinutes(1);

                playermob.Blessed = false;
            }

            if (from == null || !Players.Contains(player))
            {
                return;
            }

            Players.Players.Remove(player);

            if (Players.Peek() == player) //It is currently their turn, fold them.
            {
                player.CloseGump(typeof(PokerBetGump));
                Timer.m_LastPlayer = null;
                player.Action = PlayerAction.Fold;
            }

            if (Players.Round.Contains(player))
            {
                Players.Round.Remove(player);
            }

            if (Players.Turn.Contains(player))
            {
                Players.Turn.Remove(player);
            }

            if (Players.Round.Count == 0)
            {
                if (PokerPlayers != null && PokerPlayers.Exists(x => x.Serial == player.Mobile.Serial))
                {
                    PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Credit += CommunityCurrency;
                }
                player.Currency += CommunityCurrency;
                CommunityCurrency = 0;

                if (GameBackup.PokerGames.Contains(this))
                {
                    GameBackup.PokerGames.Remove(this);
                }
            }

            if (player.Currency > 0)
            {
                if (from.BankBox == null) //Should NEVER happen, but JUST IN CASE!
                {
                    Utility.PushColor(ConsoleColor.Red);
                    Console.WriteLine(
                        "WARNING: Player \"{0}\" with account \"{1}\" had null bank box while trying to deposit {2:#,0} {3}. Player will NOT recieve their gold.",
                        from.Name,
                        from.Account == null ? "(-null-)" : from.Account.Username,
                        player.Currency,
                        (Dealer.IsDonation ? "donation coins" : "gold"));
                    Utility.PopColor();

                    try
                    {
                        using (var op = new StreamWriter("poker_error.log", true))
                        {
                            op.WriteLine(
                                "WARNING: Player \"{0}\" with account \"{1}\" had null bankbox while poker script was trying to deposit {2:#,0} {3}. Player will NOT recieve their gold.",
                                from.Name,
                                from.Account == null ? "(-null-)" : from.Account.Username,
                                player.Currency,
                                (Dealer.IsDonation ? "donation coins" : "gold"));
                        }
                    }
                    catch
                    {}

                    from.SendMessage(
                        0x22,
                        "WARNING: Could not find your bank box. All of your poker money has been lost in this error. Please contact a Game Master to resolve this issue.");
                }
                else
                {
                    if (Banker.Deposit(from, TypeOfCurrency, player.Currency))
                    {
                        from.SendMessage(0x22, "{0:#,0} {1} has been deposited into your bank box.", player.Currency,
                            (Dealer.IsDonation ? "donation coins" : "gold"));
                    }
                    else
                    {
                        BankCheck check;
                        if (Dealer.IsDonation)
                            check = new BankCheck(player.Currency, true);
                        else
                        {
                            check = new BankCheck(player.Currency); 
                        }
                        from.Backpack.DropItem(check);
                        from.SendMessage(0x22, "{0:#,0} {1} has been placed in your bag.", player.Currency,
                            (Dealer.IsDonation ? "donation coins" : "gold"));
                    }
                }
            }

            player.CloseAllGumps();
            ((PlayerMobile) from).PokerGame = null;
            from.Location = Dealer.ExitLocation;
            from.Map = Dealer.ExitMap;
            from.SendMessage(0x22, "You have left the table");

            NeedsGumpUpdate = true;
        }
Esempio n. 32
0
		public void RemovePlayer( PokerPlayer player )
		{
			Mobile from = player.Mobile;

			if ( from != null && m_Players.Contains( player ) )
			{
				m_Players.Players.Remove( player );

				if ( m_Players.Peek() == player ) //It is currently their turn, fold them.
				{
					player.CloseGump( typeof( PokerBetGump ) );
					m_Timer.m_LastPlayer = null;
					player.Action = PlayerAction.Fold;
				}

				if ( m_Players.Round.Contains( player ) )
					m_Players.Round.Remove( player );
				if ( m_Players.Turn.Contains( player ) )
					m_Players.Turn.Remove( player );

				if ( m_Players.Round.Count == 0 )
				{
					player.Gold += m_CommunityGold;
					m_CommunityGold = 0;

					if ( GameBackup.PokerGames.Contains( this ) )
						GameBackup.PokerGames.Remove( this );
				}

				if ( player.Gold > 0 )
				{
					if ( from.BankBox == null ) //Should NEVER happen, but JUST IN CASE!
					{
						Utility.PushColor( ConsoleColor.Red );
						Console.WriteLine( "WARNING: Player \"{0}\" with account \"{1}\" had null bankbox while trying to deposit {2} gold. Player will NOT recieve their gold.", from.Name, ( from.Account == null ? "(-null-)" : from.Account.Username ), player.Gold );
						Utility.PopColor();

						try
						{
							using ( System.IO.StreamWriter op = new System.IO.StreamWriter( "poker_error.log", true ) )
								op.WriteLine( "WARNING: Player \"{0}\" with account \"{1}\" had null bankbox while poker script was trying to deposit {2} gold. Player will NOT recieve their gold.", from.Name, ( from.Account == null ? "(-null-)" : from.Account.Username ), player.Gold );
						}
						catch { }

						from.SendMessage( 0x22, "WARNING: Could not find your bankbox. All of your poker money has been lost in this error. Please contact a Game Master to resolve this issue." );
					}
					else
					{
						Banker.Deposit( from.BankBox, player.Gold );
						from.SendMessage( 0x22, "{0}gp has been deposited into your bankbox.", player.Gold );
					}
				}

				player.CloseAllGumps();
				( (PlayerMobile)from ).PokerGame = null;
				from.Location = m_Dealer.ExitLocation;
				from.Map = m_Dealer.ExitMap;
				from.SendMessage( 0x22, "You have left the table" );

				m_NeedsGumpUpdate = true;
			}
		}
Esempio n. 33
0
        public void PokerGame_PlayerMadeDecision(PokerPlayer player)
        {
            if (Players.Peek() != player)
            {
                return;
            }

            if (player.Mobile == null)
            {
                return;
            }

            bool resetTurns = false;

            Steps++;

            var pobj = new PokerActionObject(PokerHand.PokerGameId, Steps,
                PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).PokerPlayerId, (int) State / 2,
                (int) player.Action, 0);

            switch (player.Action)
            {
                case PlayerAction.None:
                    break;
                case PlayerAction.Bet:
                {
                    NextRaise = player.Bet;
                    CheckPot(player.Bet, player);
                    PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Debit += player.Bet;
                    PokerMessage(player.Mobile, String.Format("I bet {0}.", player.Bet));
                    CurrentBet = player.Bet;
                    player.RoundBet = player.Bet;
                    player.Currency -= player.Bet;
                    player.RoundCurrency += player.Bet;
                    CommunityCurrency += player.Bet;
                    resetTurns = true;
                    pobj.Amount = player.Bet;

                    break;
                }
                case PlayerAction.Raise:
                {

                    PokerMessage(player.Mobile, String.Format("I raise by {0}.", player.Bet));

                    NextRaise = player.Bet;

                    CurrentBet += player.Bet;

                    int diff = CurrentBet - player.RoundBet;

                    CheckPot(diff, player);
                    PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Debit += diff;
                    player.Currency -= diff;
                    player.RoundCurrency += diff;
                    player.RoundBet += diff;
                    CommunityCurrency += diff;
                    player.Bet = diff;
                    resetTurns = true;
                    pobj.Amount = diff;


                    break;
                }
                case PlayerAction.Call:
                {

                    PokerMessage(player.Mobile, "I call.");

                    int diff = CurrentBet - player.RoundBet; //how much they owe in the pot

                    CheckPot(diff, player);
                    player.Bet = diff;
                    PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Debit += player.Bet;
                    player.Currency -= diff;
                    player.RoundCurrency += diff;
                    player.RoundBet += diff;
                    CommunityCurrency += diff;

                    pobj.Amount = player.Bet;


                    break;
                }
                case PlayerAction.Check:
                {
                    if (!player.LonePlayer)
                    {
                        PokerMessage(player.Mobile, "Check.");
                    }
                    pobj.Amount = 0;
                    break;
                }
                case PlayerAction.Fold:
                {
                    PokerMessage(player.Mobile, "I fold.");
                    pobj.Amount = 0;

                    PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Folded = 1;

                    if (Players.Round.Contains(player))
                    {
                        Players.Round.Remove(player);
                    }

                    if (Players.Turn.Contains(player))
                    {
                        Players.Turn.Remove(player);
                    }

                    if (Players.Round.Count == 1)
                    {
                        DoShowdown(true);
                        return;
                    }

                    foreach (var pokerPot in PokerPots)
                    {
                        pokerPot.ContributionToPot.Remove(player);
                    }

                    break;
                }
                case PlayerAction.AllIn:
                {
                    if (!player.IsAllIn)
                    {
                        PokerMessage(player.Mobile, player.Forced ? "I call: all-in." : "All in.");


                        int diff = player.Currency - CurrentBet;

                        if (diff > 0)
                        {
                            CurrentBet += diff;
                            NextRaise += diff;
                        }

                        player.Bet = player.Currency;
                        CheckPot(player.Bet, player, true);
                        PokerPlayers.Find(x => x.Serial == player.Mobile.Serial).Debit += player.Currency;
                        player.RoundCurrency += player.Currency;
                        player.RoundBet += player.Currency;
                        CommunityCurrency += player.Currency;
                        pobj.Amount = player.Currency;
                        player.Currency = 0;


                        //We need to check to see if this is a follow up action, or a first call
                        //before we reset the turns
                        if (Players.Prev() != null)
                        {
                            resetTurns = (Players.Prev().Action == PlayerAction.Check);

                            PokerPlayer prev = Players.Prev();

                            if (prev.Action == PlayerAction.Check ||
                                (prev.Action == PlayerAction.Bet && prev.Bet < player.Bet) ||
                                (prev.Action == PlayerAction.AllIn && prev.Bet < player.Bet) ||
                                (prev.Action == PlayerAction.Call && prev.Bet < player.Bet) ||
                                (prev.Action == PlayerAction.Raise && prev.Bet < player.Bet))
                            {
                                resetTurns = true;
                            }
                        }
                        else
                        {
                            resetTurns = true;
                        }

                        PokerActions.Add(pobj);
                        player.IsAllIn = true;

                        player.Forced = false;
                    }

                    break;
                }
            }

            PokerLogging.PokerPlayerAction(player, player.Action, Dealer.TableName, Dealer.IsDonation);

            if (!player.IsAllIn)
            {
                PokerActions.Add(pobj);
            }

            if (resetTurns)
            {
                Players.Turn.Clear();
                Players.Push(player);
            }

            Timer.m_LastPlayer = null;
            Timer.hasWarned = false;

            if (Players.Turn.Count == Players.Round.Count)
            {
                State = (PokerGameState) ((int) State + 1);
            }
            else
            {
                AssignNextTurn();
            }

            NeedsGumpUpdate = true;
        }
Esempio n. 34
0
		public void PokerGame_PlayerMadeDecision( PokerPlayer player )
		{
			if ( m_Players.Peek() == player )
			{
				if ( player.Mobile == null )
					return;

				bool resetTurns = false;

				switch ( player.Action )
				{
					case PlayerAction.None: break;
					case PlayerAction.Bet:
						{
							PokerMessage( player.Mobile, String.Format( "I bet {0}.", player.Bet ) );
							m_CurrentBet = player.Bet;
							player.RoundBet = player.Bet;
							player.Gold -= player.Bet;
							player.RoundGold += player.Bet;
							m_CommunityGold += player.Bet;
							resetTurns = true;

							break;
						}
					case PlayerAction.Raise:
						{
							PokerMessage( player.Mobile, String.Format( "I raise to {0}.", player.Bet ) );
							m_CurrentBet = player.Bet;
							player.Gold -= player.Bet;
							player.RoundGold += player.Bet;
							player.RoundBet += player.Bet;
							m_CommunityGold += player.Bet;
							resetTurns = true;

							break;
						}
					case PlayerAction.Call:
						{
							PokerMessage( player.Mobile, "I call." );

							int diff = m_CurrentBet - player.RoundBet; //how much they owe in the pot
							player.Bet = diff;
							player.Gold -= diff;
							player.RoundGold += diff;
							player.RoundBet += diff;
							m_CommunityGold += diff;

							break;
						}
					case PlayerAction.Check:
						{
							if ( !player.LonePlayer )
								PokerMessage( player.Mobile, "Check." );

							break;
						}
					case PlayerAction.Fold:
						{
							PokerMessage( player.Mobile, "I fold." );

							if ( m_Players.Round.Contains( player ) )
								m_Players.Round.Remove( player );
							if ( m_Players.Turn.Contains( player ) )
								m_Players.Turn.Remove( player );

							if ( m_Players.Round.Count == 1 )
							{
								DoShowdown( true );
								return;
							}

							break;
						}
					case PlayerAction.AllIn:
						{
							if ( !player.IsAllIn )
							{
								if ( player.Forced )
									PokerMessage( player.Mobile, "I call: all-in." );
								else
									PokerMessage( player.Mobile, "All in." );

								int diff = player.Gold - m_CurrentBet;

								if ( diff > 0 )
									m_CurrentBet += diff;

								player.Bet = player.Gold;
								player.RoundGold += player.Gold;
								player.RoundBet += player.Gold;
								m_CommunityGold += player.Gold;
								player.Gold = 0;

								//We need to check to see if this is a follow up action, or a first call
								//before we reset the turns
								if ( m_Players.Prev() != null )
								{
									resetTurns = ( m_Players.Prev().Action == PlayerAction.Check );

									PokerPlayer prev = m_Players.Prev();

									if ( prev.Action == PlayerAction.Check ||
										( prev.Action == PlayerAction.Bet && prev.Bet < player.Bet ) ||
										( prev.Action == PlayerAction.AllIn && prev.Bet < player.Bet ) ||
										( prev.Action == PlayerAction.Call && prev.Bet < player.Bet ) ||
										( prev.Action == PlayerAction.Raise && prev.Bet < player.Bet ) )
										resetTurns = true;
								}
								else
									resetTurns = true;

								player.IsAllIn = true;
								player.Forced = false;
							}

							break;
						}
				}

				if ( resetTurns )
				{
					m_Players.Turn.Clear();
					m_Players.Push( player );
				}

				m_Timer.m_LastPlayer = null;
				m_Timer.hasWarned = false;

				if ( m_Players.Turn.Count == m_Players.Round.Count )
					m_State = (PokerGameState)( (int)m_State + 1 );
				else
					AssignNextTurn();

				m_NeedsGumpUpdate = true;
			}
		}
Esempio n. 35
0
        public void CheckPot(int amount, PokerPlayer player, bool allin = false)
        {
            /*if (allin)
            {
                foreach (PokerPot pokerPot in PokerPots)
                {
                    if (pokerPot.MaxContributionAmountPerPlayer == 0)
                    {
                        pokerPot.MaxContributionAmountPerPlayer = amount + player.RoundCurrency;
                        break;
                    }

                    if (amount + player.RoundCurrency < pokerPot.MaxContributionAmountPerPlayer)
                    {
                        Dictionary<PokerPlayer, int> newpot = pokerPot.CheckAllIn(amount + player.RoundCurrency);

                        foreach (PokerPlayer p in Players.Players)
                        {
                            p.Mobile.SendMessage(61, "POT DIVISION OCCURRED");
                        }

                        newpot = PokerPots.Aggregate(newpot, (current, pot) => pot.DivisionAdjustment(current));

                        PokerPots.Add(new PokerPot(newpot));
                        break;
                    }
                }
            }
            amount = PokerPots.Aggregate(amount, (current, pokerPot) => pokerPot.CheckContribution(current, player));

            if (amount > 0)
            {
                foreach (PokerPlayer p in Players.Players)
                {
                    p.Mobile.SendMessage(61, "SPLIT POT CREATED: " + amount + "GP ADDED TO IT");
                }

                PokerPots.Add(new PokerPot(amount, player));
            }*/

            var mainpot = PokerPots.FirstOrDefault();

            if (mainpot != null)
            {
                mainpot.AddtoPot(amount, player);
            }
        }
Esempio n. 36
0
		protected override void OnTick()
		{
			if ( m_Game.State != PokerGameState.Inactive && m_Game.Players.Count < 2 )
				m_Game.End();

			for ( int i = 0; i < m_Game.Players.Count; ++i )
				if ( !m_Game.Players.Round.Contains( m_Game.Players[i] ) )
					if ( m_Game.Players[i].RequestLeave )
						m_Game.RemovePlayer( m_Game.Players[i] );

			if ( m_Game.NeedsGumpUpdate )
			{
				foreach ( PokerPlayer player in m_Game.Players.Players )
				{
					player.CloseGump( typeof( PokerTableGump ) );
					player.SendGump( new PokerTableGump( m_Game, player ) );
				}

				m_Game.NeedsGumpUpdate = false;
			}

			if ( m_Game.State != m_LastState && m_Game.Players.Round.Count > 1 )
			{
				m_LastState = m_Game.State;
				m_Game.DoRoundAction();
				m_LastPlayer = null;
			}

			if ( m_Game.Players.Peek() != null )
			{
				if ( m_LastPlayer == null )
					m_LastPlayer = m_Game.Players.Peek(); //Changed timer from 25.0 and 30.0 to 45.0 and 60.0

				if ( m_LastPlayer.BetStart.AddSeconds( 45.0 ) <= DateTime.Now /*&& m_LastPlayer.Mobile.HasGump( typeof( PokerBetGump ) )*/ && !hasWarned )
				{
					m_LastPlayer.SendMessage( 0x22, "You have 15 seconds left to make a choice. (You will automatically fold if no choice is made)" );
					hasWarned = true;
				}
				else if ( m_LastPlayer.BetStart.AddSeconds( 60.0 ) <= DateTime.Now /*&& m_LastPlayer.Mobile.HasGump( typeof( PokerBetGump ) )*/ )
				{
					PokerPlayer temp = m_LastPlayer;
					m_LastPlayer = null;

					temp.CloseGump( typeof( PokerBetGump ) );
					temp.Action = PlayerAction.Fold;
					hasWarned = false;
				}
			}
		}
Esempio n. 37
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from        = state.Mobile;
            int    buyInAmount = 0;

            // check for casting / combat

            if (from.Spell != null)
            {
                from.SendLocalizedMessage(1049616); // You are too busy to do that at the moment.
                return;
            }
            else if (from.Criminal)
            {
                from.SendLocalizedMessage(1005561, "", 0x22); // Thou'rt a criminal and cannot escape so easily.
                return;
            }
            else if (SpellHelper.CheckCombat(from, true))
            {
                from.SendLocalizedMessage(1005564, "", 0x22); // Wouldst thou flee during the heat of battle??
                return;
            }
            else if (!SpellHelper.CheckTravel(from, TravelCheckType.RecallFrom))
            {
                from.SendLocalizedMessage(1019004); // You are not allowed to travel there.
                return;
            }

            if (info.ButtonID == 1)
            {
                int balance = Banker.GetBalance(from);
                if (balance >= m_Game.Dealer.MinBuyIn)
                {
                    try
                    {
                        buyInAmount = Convert.ToInt32((info.TextEntries[0]).Text);
                    }
                    catch
                    {
                        from.SendMessage(0x22, "Use numbers without commas to input your buy-in amount (ie 25000)");
                        return;
                    }

                    if (buyInAmount <= balance && buyInAmount >= m_Game.Dealer.MinBuyIn && buyInAmount <= m_Game.Dealer.MaxBuyIn)
                    {
                        PokerPlayer player = new PokerPlayer(from);
                        player.Gold = buyInAmount;
                        m_Game.AddPlayer(player);
                    }
                    else
                    {
                        from.SendMessage(0x22, "You may not join with that amount of gold. Minimum buy-in: " + Convert.ToString(m_Game.Dealer.MinBuyIn) +
                                         ", Maximum buy-in: " + Convert.ToString(m_Game.Dealer.MaxBuyIn));
                    }
                }
                else
                {
                    from.SendMessage(0x22, "You may not join with that amount of gold. Minimum buy-in: " + Convert.ToString(m_Game.Dealer.MinBuyIn) +
                                     ", Maximum buy-in: " + Convert.ToString(m_Game.Dealer.MaxBuyIn));
                }
            }
            else if (info.ButtonID == 2)
            {
                return;
            }
        }
Esempio n. 38
0
 public static void HandWinnings(string tablename, PokerPlayer player, int amount, bool isDonation)
 {
     try
     {
         using (var op = new StreamWriter("Logs/Poker/" + tablename + ".log", true))
         {
             op.WriteLine("{0} has won {1:#,0} {2}.", player.Mobile.RawName,
                 amount,
                 (isDonation ? "donation coins" : "gold"));
             op.Close();
         }
     }
     catch
     { }
 }
Esempio n. 39
0
		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;
			int buyInAmount = 0;

			if ( info.ButtonID == 1 )
			{
				int balance = Banker.GetBalance( from );
				if ( balance >= m_Game.Dealer.MinBuyIn )
				{
					try
					{
						buyInAmount = Convert.ToInt32( ( info.TextEntries[0] ).Text );
					}
					catch
					{
						from.SendMessage( 0x22, "Use numbers without commas to input your buy-in amount (ie 25000)" );
						return;
					}

					if ( buyInAmount <= balance && buyInAmount >= m_Game.Dealer.MinBuyIn && buyInAmount <= m_Game.Dealer.MaxBuyIn )
					{
						PokerPlayer player = new PokerPlayer( from );
						player.Gold = buyInAmount;
						m_Game.AddPlayer( player );
					}
					else
						from.SendMessage( 0x22, "You may not join with that amount of gold. Minimum buy-in: " + Convert.ToString( m_Game.Dealer.MinBuyIn ) +
							", Maximum buy-in: " + Convert.ToString( m_Game.Dealer.MaxBuyIn ) );
				}
				else
					from.SendMessage( 0x22, "You may not join with that amount of gold. Minimum buy-in: " + Convert.ToString( m_Game.Dealer.MinBuyIn ) +
						", Maximum buy-in: " + Convert.ToString( m_Game.Dealer.MaxBuyIn ) );
			}
			else if ( info.ButtonID == 2 )
				return;
		}
Esempio n. 40
0
        public void AddPlayer(PokerPlayer player)
        {
            Mobile from = player.Mobile;

            if (from == null)
            {
                return;
            }

            if (from is PlayerMobile)
            {
                var playermob = from as PlayerMobile;
                if (playermob.PokerJoinTimer > DateTime.UtcNow)
                {
                    TimeSpan nextuse = playermob.PokerJoinTimer - DateTime.UtcNow;
                    from.SendMessage("You cannot join another poker game for " + nextuse.Seconds + " seconds.");
                    return;
                }

                if (playermob.Aggressed.Any(info => (DateTime.UtcNow - info.LastCombatTime) < TimeSpan.FromSeconds(60)))
                {
                    playermob.SendMessage("You cannot join poker while you are in combat!");
                    return;
                }

                if (playermob.Aggressors.Any(info => (DateTime.UtcNow - info.LastCombatTime) < TimeSpan.FromSeconds(60)))
                {
                    playermob.SendMessage("You cannot join poker while you are in combat!");
                    return;
                }

                if (playermob.Party != null)
                {
                    playermob.SendMessage("You cannot join a poker game while in a party.");
                    return;
                }
            }


            if (!Dealer.InRange(from.Location, 8))
            {
                from.PrivateOverheadMessage(MessageType.Regular, 0x22, true, "I am too far away to do that",
                                            from.NetState);
            }
            else if (GetIndexFor(from) != -1)
            {
                from.SendMessage(0x22, "You are already seated at this table");
            }
            else if (Players.Count >= Dealer.MaxPlayers)
            {
                from.SendMessage(0x22, "Sorry, that table is full");
            }
            else if (Banker.Withdraw(from, TypeOfCurrency, player.Currency))
            {
                Point3D seat = Point3D.Zero;

                foreach (Point3D seats in Dealer.Seats.Where(seats => !Dealer.SeatTaken(seats)))
                {
                    seat = seats;
                    break;
                }

                if (seat == Point3D.Zero)
                {
                    from.SendMessage(0x22, "Sorry, that table is full");
                    return;
                }

                player.Game = this;
                player.Seat = seat;
                player.TeleportToSeat();
                Players.Players.Add(player);

                ((PlayerMobile)from).PokerGame = this;
                from.SendMessage(0x22, "You have been seated at the table");

                if (Players.Count == 1 && !GameBackup.PokerGames.Contains(this))
                {
                    GameBackup.PokerGames.Add(this);
                }
                else if (State == PokerGameState.Inactive && Players.Count > 1 && !Dealer.TournamentMode)
                {
                    Begin();
                }
                else if (State == PokerGameState.Inactive && Players.Count >= Dealer.MaxPlayers && Dealer.TournamentMode)
                {
                    Dealer.TournamentMode = false;
                    Begin();
                }

                player.CloseGump(typeof(PokerTableGump));
                player.SendGump(new PokerTableGump(this, player));
                NeedsGumpUpdate = true;
                player.Chat     = true;

                player.Mobile.Blessed = true;
            }
            else
            {
                from.SendMessage(0x22, "Your bank box lacks the funds to join this poker table");
            }
        }
Esempio n. 41
0
 public bool Contains(PokerPlayer player)
 {
     return(Players.Contains(player));
 }
Esempio n. 42
0
 public ResultEntry(PokerPlayer player)
 {
     Player = player;
 }
Esempio n. 43
0
		public void Begin()
		{
			m_Players.Clear();
			m_CurrentBet = 0;

			List<PokerPlayer> dispose = new List<PokerPlayer>();

			foreach ( PokerPlayer player in m_Players.Players )
				if ( player.RequestLeave || !player.IsOnline() )
					dispose.Add( player );

			foreach ( PokerPlayer player in dispose )
				if ( m_Players.Contains( player ) )
					RemovePlayer( player );

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

				if ( player.Gold >= m_Dealer.BigBlind && player.IsOnline() )
					m_Players.Round.Add( player );
			}

            if ( m_DealerButton == null || m_SmallBlind == null ) //First round / more player
			{
                if ( m_Players.Round.Count == 2 ) //Only use small blind and big blind
				{
                    m_DealerButton = null;
                    m_SmallBlind = m_Players.Round[0];
                    m_BigBlind = m_Players.Round[1];
				}
				else if ( m_Players.Round.Count > 2 )
				{
					m_DealerButton = m_Players.Round[0];
					m_SmallBlind = m_Players.Round[1];
					m_BigBlind = m_Players.Round[2];
				}
				else
					return;
			}
			else
			{
                if ( m_Players.Round.Count == 2 ) //Only use small blind and big blind
				{
                    if ( m_BigBlind == m_Players.Round[1] )
					{
                        m_SmallBlind = m_Players.Round[1];
                        m_BigBlind = m_Players.Round[0];
					}
					else
					{
                        m_SmallBlind = m_Players.Round[0];
                        m_BigBlind = m_Players.Round[1];
					}

                    m_DealerButton = null;
				}
				else if ( m_Players.Round.Count > 2 )
				{
					int index = m_Players.Round.IndexOf( m_DealerButton );

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

					if ( index == m_Players.Round.Count - 1 )
					{
						m_DealerButton = m_Players.Round[0];
						m_SmallBlind = m_Players.Round[1];
						m_BigBlind = m_Players.Round[2];
					}
					else if ( index == m_Players.Round.Count - 2 )
					{
						m_DealerButton = m_Players.Round[m_Players.Round.Count - 1];
						m_SmallBlind = m_Players.Round[0];
						m_BigBlind = m_Players.Round[1];
					}
					else if ( index == m_Players.Round.Count - 3 )
					{
						m_DealerButton = m_Players.Round[m_Players.Round.Count - 2];
						m_SmallBlind = m_Players.Round[m_Players.Round.Count - 1];
						m_BigBlind = m_Players.Round[0];
					}
					else
					{
						m_DealerButton = m_Players.Round[index + 1];
						m_SmallBlind = m_Players.Round[index + 2];
						m_BigBlind = m_Players.Round[index + 3];
					}
				}
				else
					return;
			}

			m_CommunityCards.Clear();
			m_Deck = new Deck();

			m_State = PokerGameState.DealHoleCards;

			if ( m_BigBlind != null )
			{
				m_BigBlind.Gold -= m_Dealer.BigBlind;
				m_CommunityGold += m_Dealer.BigBlind;
				m_BigBlind.RoundGold = m_Dealer.BigBlind;
				m_BigBlind.RoundBet = m_Dealer.BigBlind;
				m_BigBlind.Bet = m_Dealer.BigBlind;
			}

			m_SmallBlind.Gold -= m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;
			m_CommunityGold += m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;
			m_SmallBlind.RoundGold = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;
			m_SmallBlind.RoundBet = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;
			m_SmallBlind.Bet = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind;

			if ( m_BigBlind != null )
			{
				//m_Players.Push( m_BigBlind );
				m_BigBlind.SetBBAction();
				m_CurrentBet = m_Dealer.BigBlind;
			}
			else
			{
				//m_Players.Push( m_SmallBlind );
				m_SmallBlind.SetBBAction();
				m_CurrentBet = m_Dealer.BigBlind;
			}

			if ( m_Players.Next() == null )
				return;

			m_NeedsGumpUpdate = true;
			m_Timer = new PokerGameTimer( this );
			m_Timer.Start();
		}
Esempio n. 44
0
        protected override void OnTick()
        {
            if (m_Game.State != PokerGameState.Inactive && m_Game.Players.Count < 2)
            {
                m_Game.End();
            }

            for (int i = 0; i < m_Game.Players.Count; ++i)
            {
                if (!m_Game.Players.Round.Contains(m_Game.Players[i]) && m_Game.Players[i].RequestLeave)
                {
                    m_Game.RemovePlayer(m_Game.Players[i]);
                }
            }

            if (m_Game.NeedsGumpUpdate)
            {
                foreach (PokerPlayer player in m_Game.Players.Players)
                {
                    player.CloseGump(typeof(PokerTableGump));
                    player.SendGump(new PokerTableGump(m_Game, player));
                }

                m_Game.NeedsGumpUpdate = false;
            }

            if (m_Game.State != m_LastState && m_Game.Players.Round.Count > 1)
            {
                m_LastState = m_Game.State;
                m_Game.DoRoundAction();
                m_LastPlayer = null;
            }

            if (m_Game.Players.Peek() == null)
            {
                return;
            }

            if (m_LastPlayer == null)
            {
                m_LastPlayer = m_Game.Players.Peek(); //Changed timer from 25.0 and 30.0 to 45.0 and 60.0
            }

            if (m_LastPlayer.BetStart.AddSeconds(15.0) <= DateTime.UtcNow && !hasWarned)
            {
                m_LastPlayer.SendMessage(
                    0x22,
                    "You have 15 seconds left to make a choice. (You will automatically fold if no choice is made)");
                hasWarned = true;
            }
            else if (m_LastPlayer.BetStart.AddSeconds(30.0) <= DateTime.UtcNow)
            {
                m_LastPlayer.KickNumber++;
                if (m_LastPlayer.KickNumber == 2)
                {
                    m_LastPlayer.RequestLeave = true;
                }
                else
                {
                    PokerPlayer temp = m_LastPlayer;
                    m_LastPlayer = null;

                    temp.CloseGump(typeof(PokerBetGump));
                    temp.Action = PlayerAction.Fold;
                    hasWarned   = false;
                }
            }
        }
Esempio n. 45
0
		public bool Contains( PokerPlayer player ) { return m_Players.Contains( player ); }
Esempio n. 46
0
        public PokerPlayer AssignNextTurn()
        {
            PokerPlayer nextTurn = Players.Next();

            if (nextTurn == null)
            {
                return(null);
            }

            if (nextTurn.RequestLeave)
            {
                Players.Push(nextTurn);
                nextTurn.BetStart = DateTime.UtcNow;
                nextTurn.Action   = PlayerAction.Fold;
                return(nextTurn);
            }

            if (nextTurn.IsAllIn)
            {
                Players.Push(nextTurn);
                nextTurn.BetStart = DateTime.UtcNow;
                nextTurn.Action   = PlayerAction.AllIn;
                return(nextTurn);
            }

            if (nextTurn.LonePlayer)
            {
                Players.Push(nextTurn);
                nextTurn.BetStart = DateTime.UtcNow;
                nextTurn.Action   = PlayerAction.Check;
                return(nextTurn);
            }

            bool canCall = false;

            PokerPlayer currentTurn = Players.Peek();

            if (currentTurn != null && currentTurn.Action != PlayerAction.Check &&
                currentTurn.Action != PlayerAction.Fold)
            {
                canCall = true;
            }
            if (currentTurn == null && State == PokerGameState.PreFlop)
            {
                canCall = true;
            }

            Players.Push(nextTurn);
            nextTurn.BetStart = DateTime.UtcNow;

            var         entry = new ResultEntry(nextTurn);
            List <Card> bestCards;

            entry.Rank      = nextTurn.GetBestHand(CommunityCards, out bestCards);
            entry.BestCards = bestCards;

            nextTurn.SendMessage(0x22, String.Format("You have {0}.", HandRanker.RankString(entry)));
            nextTurn.CloseGump(typeof(PokerBetGump));
            nextTurn.SendGump(new PokerBetGump(this, nextTurn, canCall));

            NeedsGumpUpdate = true;

            return(nextTurn);
        }
Esempio n. 47
0
        public void AddPlayer(PokerPlayer player)
        {
            Mobile from = player.Mobile;

            if (from == null)
            {
                return;
            }

            if (from is PlayerMobile)
            {
                var playermob = from as PlayerMobile;
                if (playermob.PokerJoinTimer > DateTime.UtcNow)
                {
                    TimeSpan nextuse = playermob.PokerJoinTimer - DateTime.UtcNow;
                    from.SendMessage("You cannot join another poker game for " + nextuse.Seconds + " seconds.");
                    return;
                }

                if (playermob.Aggressed.Any(info => (DateTime.UtcNow - info.LastCombatTime) < TimeSpan.FromSeconds(60)))
                {
                    playermob.SendMessage("You cannot join poker while you are in combat!");
                    return;
                }

                if (playermob.Aggressors.Any(info => (DateTime.UtcNow - info.LastCombatTime) < TimeSpan.FromSeconds(60)))
                {
                    playermob.SendMessage("You cannot join poker while you are in combat!");
                    return;
                }

                if (playermob.Party != null)
                {
                    playermob.SendMessage("You cannot join a poker game while in a party.");
                    return;
                }
            }


            if (!Dealer.InRange(from.Location, 8))
            {
                from.PrivateOverheadMessage(MessageType.Regular, 0x22, true, "I am too far away to do that",
                    from.NetState);
            }
            else if (GetIndexFor(from) != -1)
            {
                from.SendMessage(0x22, "You are already seated at this table");
            }
            else if (Players.Count >= Dealer.MaxPlayers)
            {
                from.SendMessage(0x22, "Sorry, that table is full");
            }
            else if (Banker.Withdraw(from, TypeOfCurrency, player.Currency))
            {
                Point3D seat = Point3D.Zero;

                foreach (Point3D seats in Dealer.Seats.Where(seats => !Dealer.SeatTaken(seats)))
                {
                    seat = seats;
                    break;
                }

                if (seat == Point3D.Zero)
                {
                    from.SendMessage(0x22, "Sorry, that table is full");
                    return;
                }

                player.Game = this;
                player.Seat = seat;
                player.TeleportToSeat();
                Players.Players.Add(player);

                ((PlayerMobile) from).PokerGame = this;
                from.SendMessage(0x22, "You have been seated at the table");

                if (Players.Count == 1 && !GameBackup.PokerGames.Contains(this))
                {
                    GameBackup.PokerGames.Add(this);
                }
                else if (State == PokerGameState.Inactive && Players.Count > 1 && !Dealer.TournamentMode)
                {
                    Begin();
                }
                else if (State == PokerGameState.Inactive && Players.Count >= Dealer.MaxPlayers && Dealer.TournamentMode)
                {
                    Dealer.TournamentMode = false;
                    Begin();
                }

                player.CloseGump(typeof(PokerTableGump));
                player.SendGump(new PokerTableGump(this, player));
                NeedsGumpUpdate = true;
                player.Chat = true;

                player.Mobile.Blessed = true;
            }
            else
            {
                from.SendMessage(0x22, "Your bank box lacks the funds to join this poker table");
            }
        }