Esempio n. 1
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. 2
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. 3
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. 4
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;
            }
        }