Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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");
            }
        }
Ejemplo n.º 5
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;
			}
		}
Ejemplo n.º 6
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" );
		}
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
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");
            }
        }
Ejemplo n.º 9
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.SendMessage(0x22, "You have left the table");

                m_NeedsGumpUpdate = true;
            }
        }
Ejemplo n.º 10
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);
                    new PokerPersistence();
                }
                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");
            }
        }
Ejemplo n.º 11
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));
            }
        }