Exemplo n.º 1
0
        /// <summary>
        /// Handles the JailInfo command, stating to the player information about their jailtime
        /// </summary>
        private static void OnJailInfoCommand(CommandEventArgs e)
        {
            JailEntry jail = GetCurrentJail(e.Mobile);

            if (jail != null)
            {
                if (jail.AutoRelease)
                {
                    TimeSpan left = jail.EndTime - DateTime.Now;

                    if (left > TimeSpan.Zero)
                    {
                        e.Mobile.SendMessage("Your sentence will expire in {0} days, {1} hours and {2} minutes.", left.Days, left.Hours, left.Minutes);
                    }
                    else if (jail.EndTime > DateTime.Now)
                    {
                        // Force the release of this one only
                        Release(jail, null);
                    }
                }
                else
                {
                    e.Mobile.SendMessage("Your sentence has no auto release date. A staff member will have to manually release you.");
                }
                return;
            }
            else
            {
                e.Mobile.SendMessage("You must be jailed to use this.");
            }
        }
Exemplo n.º 2
0
        public PlayerJailGump(JailEntry jail, Mobile jailer) : base(100, 100)
        {
            m_Jail   = jail;
            m_Jailer = jailer;

            MakeGump();
        }
        public JailAccountGump(Mobile offender, Mobile user, JailEntry jail, Account account) : base(100, 100)
        {
            m_Offender     = offender;
            m_User         = user;
            m_ExistingJail = jail;
            m_Account      = account;

            MakeGump();
        }
Exemplo n.º 4
0
        public JailViewGump(Mobile user, JailEntry jail, JailGumpCallback callback) : base(50, 50)
        {
            user.CloseGump(typeof(JailViewGump));

            m_User     = user;
            m_Jail     = jail;
            m_Callback = callback;

            MakeGump();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Views information on the jail status of the target
        /// </summary>
        /// <param name="from">The GM requesting the information</param>
        /// <param name="target">The target being searched for jail information</param>
        private static void OnJailInfoTarget(Mobile from, Mobile target)
        {
            JailEntry jail = GetCurrentJail(target);

            if (jail == null)
            {
                from.SendMessage("That player isn't currently jailed");
            }
            else
            {
                from.SendGump(new JailViewGump(from, jail, null));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Finalizes a jailing action by adding a jail record and moving the mobile into a jail cell
        /// </summary>
        /// <param name="m">The player being jailed</param>
        /// <param name="account">The account of the player being jailed</param>
        /// <param name="from">The GM performing the jailing</param>
        /// <param name="reason">The reason for the jailing</param>
        /// <param name="autorelease">States if the player should be auto released after the sentence is over</param>
        /// <param name="duration">The length of the sentence</param>
        /// <param name="fulljail">States if the full account should be jailed</param>
        /// <param name="comment">An additional comment about the jailing</param>
        public static void CommitJailing(Mobile m, Account account, Mobile from, string reason, bool autorelease, TimeSpan duration, bool fulljail, string comment)
        {
            JailEntry jail = new JailEntry(m, account, from, duration, reason, comment, autorelease, fulljail);

            // Verify if the new entry is valid
            JailEntry existing = null;

            if (!IsValid(jail))
            {
                if (jail.Mobile != null)
                {
                    existing = GetCurrentJail(jail.Mobile);
                }
                else
                {
                    existing = GetCurrentJail(jail.Account);
                }
            }

            if (existing != null)
            {
                // This jailing wont' be committed, if there's a pending player, release them
                CancelJail(m, from);

                from.SendMessage(0x40, "Your new jail report is in conflict with an existing entry. Please review and eventually update the existing jailing.");
                from.SendGump(new JailViewGump(from, existing, null));
                return;
            }

            // The jailing is valid so go on and add it

            m_Jailings.Add(jail);
            FinalizeJail(m);

            // Send jailing review gump to the offender
            if (m != null && m.NetState != null)
            {
                m.SendGump(new PlayerJailGump(jail, from));
            }
            else if (jail.FullJail)               // Handle full account jailing/player relogging
            {
                Mobile mob = GetOnlineMobile(jail.Account);

                if (mob != null)
                {
                    FinalizeJail(mob);
                    mob.SendGump(new PlayerJailGump(jail, from));
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Callback for the Unjail command target
        /// </summary>
        /// <param name="from">The GM using the command</param>
        /// <param name="target">The player being unjailed</param>
        private static void OnUnjailTarget(Mobile from, Mobile target)
        {
            JailEntry jail = GetCurrentJail(target);

            if (jail == null)
            {
                // Not currently jailed
                from.SendMessage("That player isn't currently jailed");
            }
            else
            {
                Release(jail, from);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Forces a release action on a JailEntry. This also adds a comment specifying the moment of the release.
        /// </summary>
        /// <param name="jail">The jail entry to consider expired</param>
        /// <param name="from">The staff member releasing the jailing</param>
        public static void Release(JailEntry jail, Mobile from)
        {
            if (from != null)
            {
                jail.AddComment(from, "Released at {0}", DateTime.Now.ToShortTimeString());
            }

            jail.Release();

            if (m_Jailings.Contains(jail))
            {
                m_Jailings.Remove(jail);
                m_ExpiredJailings.Add(jail);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Verifies if a new jail entry has conflicts with other jail entries
        /// </summary>
        /// <param name="jail">The potential new JailEntry</param>
        /// <returns>True if the new jail entry can be added to the jail</returns>
        private static bool IsValid(JailEntry jail)
        {
            foreach (JailEntry cmp in m_Jailings)
            {
                if (jail.Account == cmp.Account)
                {
                    if (cmp.FullJail && jail.FullJail)
                    {
                        return(false);                        // New jail is full account, and a previous full jail already exists
                    }
                    else if (cmp.Mobile == jail.Mobile && cmp.FullJail == jail.FullJail)
                    {
                        return(false);                        // Jailing the same mobile without full jail
                    }
                }
            }

            return(true);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Loads a file containing the jail entries
        /// </summary>
        /// <param name="filename">The filename to load</param>
        /// <returns></returns>
        private static ArrayList LoadJailFile(string filename)
        {
            ArrayList jailings = new ArrayList();

            XmlDocument dom = new XmlDocument();

            if (System.IO.File.Exists(filename))
            {
                try
                {
                    dom.Load(filename);
                }
                catch {}

                if (dom == null || dom.ChildNodes.Count < 2)
                {
                    return(jailings);
                }

                XmlNode xItems = dom.ChildNodes[1];

                foreach (XmlNode xJail in xItems.ChildNodes)
                {
                    JailEntry jail = null;

                    try                     // If modified manually, some entries might be broken
                    {
                        jail = JailEntry.Load(xJail);
                    }
                    finally
                    {
                        if (jail != null)
                        {
                            jailings.Add(jail);
                        }
                    }
                }
            }

            return(jailings);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Verifies if a JailEntry should be removed from history
        /// </summary>
        /// <param name="jail">The JailEntry object being checked</param>
        /// <returns>True if the JailEntry matches the purge conditions</returns>
        public bool PurgeCheck(JailEntry jail)
        {
            if (jail.Account == null && m_Deleted)
            {
                return(true);
            }
            else if (jail.Account != null && jail.Account.Banned && m_Banned)
            {
                return(true);
            }
            else if (m_Old)
            {
                TimeSpan age = DateTime.Now - jail.JailTime;

                if (age.TotalHours >= m_Hours)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a jailing action by sending the JailReasonGump
        /// </summary>
        /// <param name="from">The GM performing the jailing</param>
        /// <param name="offender">The Mobile being jailed</param>
        /// <param name="forceJail">Specifies whether the jailing of the player should be forced vs an existing account jail</param>
        /// <returns>True if the jailing action is succesful</returns>
        public static bool InitJail(Mobile from, Mobile offender, bool forceJail)
        {
            if (offender == null)
            {
                return(false);
            }

            if (CanBeJailed(offender))
            {
                // Check for existing non-full jail entries
                JailEntry jail = GetAccountJail(offender);

                if (jail != null && !forceJail)
                {
                    // Existing entry: ask for conversion
                    from.SendGump(new JailAccountGump(offender, from, jail, offender.Account as Account));
                    return(false);
                }

                from.SendGump(new JailReasonGump(offender));
                return(true);
            }
            else
            {
                JailEntry jail = GetCurrentJail(offender);

                if (jail != null)
                {
                    from.SendMessage("That player is already jailed. Please review the current jail record.");
                    from.SendGump(new JailViewGump(from, jail, null));
                }
                else
                {
                    from.SendMessage("You can't jail that player because they're either already jailed or a staff member.");
                }
                return(false);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a jailing action by sending the JailReasonGump
        /// </summary>
        /// <param name="from">The GM performing the jailing</param>
        /// <param name="offender">The account being jailed</param>
        /// <returns>True if the jailing can proceed</returns>
        public static bool InitJail(Mobile from, Account offender)
        {
            if (CanBeJailed(offender))
            {
                from.SendGump(new JailReasonGump(offender));
                return(true);
            }
            else
            {
                JailEntry jail = GetCurrentJail(offender);

                if (jail != null)
                {
                    from.SendMessage("That account has already been jailed. Please review the existing jail record.");
                    from.SendGump(new JailViewGump(from, jail, null));
                }
                else
                {
                    from.SendMessage("You can't jail that account because it's either already jailed or a staff account.");
                }

                return(false);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Loads a jailing from an Xml Node
        /// </summary>
        /// <param name="xNode">The XmlNode containing the jailing</param>
        /// <returns>A JailEntry object</returns>
        public static JailEntry Load(XmlNode xNode)
        {
            JailEntry jail = new JailEntry();

            // Account
            string account = xNode.Attributes["Account"].Value;

            if (account != null)
            {
                jail.m_Account = Accounts.GetAccount(account) as Account;
            }

            // Mobile
            int serial = -1;

            try
            {
                serial = Convert.ToInt32(xNode.Attributes["Mobile"].Value, 16);
            }
            catch {};
            if (serial != -1)
            {
                jail.m_Mobile = World.FindMobile((Serial)serial);
            }

            // Jail Time
            DateTime jailtime = DateTime.MinValue;

            try
            {
                jailtime = DateTime.Parse(xNode.Attributes["JailTime"].Value);
            }
            catch {}
            jail.m_JailTime = jailtime;

            // Duration
            TimeSpan duration = TimeSpan.Zero;

            try
            {
                duration = TimeSpan.Parse(xNode.Attributes["Duration"].Value);
            }
            catch {}
            jail.Duration = duration;

            // JailedBy
            jail.m_JailedBy = xNode.Attributes["JailedBy"].Value;

            // Reason
            jail.m_Reason = xNode.Attributes["Reason"].Value;

            // History Record
            jail.m_HistoryRecord = xNode.Attributes["HistoryRecord"].Value;

            // Autorelease
            bool autorelease = false;

            try
            {
                autorelease = bool.Parse(xNode.Attributes["AutoRelease"].Value);
            }
            catch {}
            jail.m_AutoRelease = autorelease;

            // Full jail
            bool fulljail = true;

            try
            {
                fulljail = bool.Parse(xNode.Attributes["FullJail"].Value);
            }
            catch {}
            jail.m_FullJail = fulljail;

            if (xNode.ChildNodes.Count > 0)
            {
                XmlNode xComments = xNode.ChildNodes[0];

                foreach (XmlNode xCom in xComments.ChildNodes)
                {
                    jail.m_Comments.Add(xCom.Attributes["Value"].Value);
                }
            }

            return(jail);
        }
Exemplo n.º 15
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 0:                     // Close

                if (m_Callback != null)
                {
                    try
                    {
                        m_Callback.DynamicInvoke(new object[] { m_User });
                    }
                    catch {}
                }
                break;

            case 1:                     // Previous Page
                m_User.SendGump(new JailListingGump(m_User, m_MasterList, m_Page - 1, m_Callback));
                break;

            case 2:                     // Next Page
                m_User.SendGump(new JailListingGump(m_User, m_MasterList, m_Page + 1, m_Callback));
                break;

            default:

                int type  = info.ButtonID / 10;
                int index = info.ButtonID % 10;

                JailEntry jail = m_Jailings[index];

                if (jail != null)
                {
                    switch (type)
                    {
                    case 1:                                     // View Information

                        m_User.SendGump(new JailViewGump(m_User, jail, new JailGumpCallback(JailListingCallback)));
                        break;

                    case 2:                                     // View Account details

                        m_User.SendGump(new JailListingGump(m_User, m_MasterList, m_Page, m_Callback));

                        if (jail.Account != null)
                        {
                            m_User.SendGump(new AdminGump(m_User, AdminGumpPage.AccountDetails_Information, 0, null, "Requested by the Jail System", jail.Account));
                        }
                        break;

                    case 3:                                     // View Player props

                        m_User.SendGump(new JailListingGump(m_User, m_MasterList, m_Page, m_Callback));

                        if (m_User.AccessLevel < AccessLevel.Lead)
                        {
                            return;
                        }

                        if (jail.Mobile != null)
                        {
                            m_User.SendGump(new PropertiesGump(m_User, jail.Mobile));
                        }
                        break;
                    }
                }
                break;
            }
        }
Exemplo n.º 16
0
        private void MakeGump()
        {
            this.Closable   = true;
            this.Disposable = true;
            this.Dragable   = true;
            this.Resizable  = false;

            this.AddPage(0);
            this.AddBackground(0, 0, 420, 315, 9250);

            this.AddImageTiled(15, 15, 16, 285, 2624);

            // Title
            this.AddAlphaRegion(35, 15, 370, 20);
            this.AddLabel(40, 15, GreenHue, string.Format("Jail Listing: Displaying {0} records", m_MasterList.Count));

            // Table headers: Account
            this.AddImageTiled(35, 40, 110, 20, 9304);
            this.AddAlphaRegion(35, 40, 110, 20);
            this.AddLabel(40, 40, LabelHue, @"Account");

            // Player
            this.AddImageTiled(150, 40, 110, 20, 9304);
            this.AddAlphaRegion(150, 40, 110, 20);
            this.AddLabel(155, 40, LabelHue, @"Player");

            // Reason
            this.AddImageTiled(265, 40, 140, 20, 9304);
            this.AddAlphaRegion(265, 40, 140, 20);
            this.AddLabel(270, 40, LabelHue, @"Reason");

            // Table Background
            this.AddAlphaRegion(35, 65, 110, 200);

            this.AddImageTiled(150, 65, 110, 200, 3604);
            this.AddAlphaRegion(150, 65, 110, 200);

            this.AddAlphaRegion(265, 65, 140, 200);

            this.AddAlphaRegion(35, 270, 370, 30);

            // Close: Button 0
            this.AddButton(45, 275, 4017, 4018, 0, GumpButtonType.Reply, 0);
            this.AddLabel(80, 275, LabelHue, @"Close");

            if (m_MasterList.Count == 0)
            {
                return;
            }

            m_Jailings = new JailEntry[10];

            // Data Section. Verify bounds
            if (m_Page * 10 >= m_MasterList.Count)
            {
                // Show last page
                m_Page = (m_MasterList.Count - 1) / 10;
            }

            if (m_Page > 0)
            {
                // Prev Page: Button 1
                this.AddButton(335, 275, 4014, 4015, 1, GumpButtonType.Reply, 0);
            }

            if (m_Page < (m_MasterList.Count - 1) / 10)
            {
                // Next Page: Button 2
                this.AddButton(370, 275, 4005, 4006, 2, GumpButtonType.Reply, 0);
            }

            for (int i = m_Page * 10; i < m_Page * 10 + 10 && i < m_MasterList.Count; i++)
            {
                int index = i - m_Page * 10;

                JailEntry jail = m_MasterList[i] as JailEntry;
                m_Jailings[index] = jail;

                // Jail Details: Buttons from 10 to 19
                this.AddButton(15, 67 + index * 20, 5601, 5605, 10 + index, GumpButtonType.Reply, 0);

                // Account details: Buttons from 20 to 29
                if (jail.Account != null && m_User.AccessLevel == AccessLevel.Administrator)
                {
                    this.AddButton(35, 69 + index * 20, 2224, 2224, 20 + index, GumpButtonType.Reply, 0);
                }

                // Account name
                if (jail.Account != null)
                {
                    this.AddLabelCropped(55, 65 + index * 20, 90, 20, LabelHue, jail.Account.Username);
                }
                else
                {
                    this.AddLabelCropped(55, 65 + index * 20, 90, 20, RedHue, "Deleted");
                }

                // Player name
                if (jail.Mobile != null)
                {
                    // Player props: Buttons from 30 to 39
                    if (m_User.AccessLevel >= AccessLevel.Lead)
                    {
                        this.AddButton(150, 69 + index * 20, 2224, 2224, 30 + index, GumpButtonType.Reply, 0);
                    }
                    this.AddLabelCropped(170, 65 + index * 20, 90, 20, LabelHue, jail.Mobile.Name);
                }
                else
                {
                    this.AddLabelCropped(170, 65 + index * 20, 90, 20, LabelHue, "N/A");
                }

                // Reason
                this.AddLabelCropped(270, 65 + index * 20, 140, 20, LabelHue, jail.Reason);
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Verifies if a given jail entry is active or if it's a historical one
 /// </summary>
 /// <param name="jail">The JailEntry to verify</param>
 /// <returns>True if the jail entry is currently active, false if it's historical</returns>
 public static bool IsActive(JailEntry jail)
 {
     return(m_Jailings.Contains(jail));
 }