Exemple #1
0
        public static bool RemoveTitle(PlayerMobile player, string title, bool message)
        {
            if (player == null)
            {
                return(false);
            }

            CheckAndCreateTitleCollection(player);

            TitleEntry entryToRemove = null;

            foreach (TitleEntry entry in player.m_TitleCollection.m_Titles)
            {
                if (entry.m_TitleName == title)
                {
                    entryToRemove = entry;
                }
            }

            if (entryToRemove != null)
            {
                player.m_TitleCollection.m_Titles.Remove(entryToRemove);

                if (message)
                {
                    player.SendMessage("You have lost the title: " + title + ".");
                }

                return(true);
            }

            return(false);
        }
Exemple #2
0
        public static void AuditTitles(PlayerMobile player)
        {
            CheckAndCreateTitleCollection(player);

            Queue m_Queue = new Queue();

            foreach (TitleEntry entry in player.m_TitleCollection.m_Titles)
            {
                if (!ValidateTitle(player, entry.m_TitleName, true))
                {
                    m_Queue.Enqueue(entry);
                    continue;
                }

                if (!entry.m_Expires)
                {
                    continue;
                }

                if (DateTime.UtcNow >= entry.m_DateExpires)
                {
                    if (DeactivateTitle(player, entry.m_TitleName))
                    {
                        player.SendMessage("Your title of '" + entry.m_TitleName + "' has expired.");
                    }

                    continue;
                }

                else if (DateTime.UtcNow + TimeSpan.FromHours(1) >= entry.m_DateExpires)
                {
                    TimeSpan timeRemaining = entry.m_DateExpires - DateTime.UtcNow;

                    Timer.DelayCall(timeRemaining, delegate
                    {
                        if (player == null)
                        {
                            return;
                        }

                        if (DeactivateTitle(player, entry.m_TitleName))
                        {
                            player.SendMessage("Your title of '" + entry.m_TitleName + "' has expired.");
                        }
                    });

                    continue;
                }
            }

            while (m_Queue.Count > 0)
            {
                TitleEntry entry = (TitleEntry)m_Queue.Dequeue();

                RemoveTitle(player, entry.m_TitleName, true);
            }
        }
Exemple #3
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            //Version 0
            if (version >= 0)
            {
                m_Player = (PlayerMobile)reader.ReadMobile();
                m_NotificationForNonSelectedTitleExpirations = reader.ReadBool();

                int hueCount = reader.ReadInt();
                for (int a = 0; a < hueCount; a++)
                {
                    m_UnlockedHues.Add(reader.ReadInt());
                }

                int titleCount = reader.ReadInt();
                for (int a = 0; a < titleCount; a++)
                {
                    string   titleName   = reader.ReadString();
                    bool     activated   = reader.ReadBool();
                    int      currentHue  = reader.ReadInt();
                    DateTime dateEarned  = reader.ReadDateTime();
                    bool     expires     = reader.ReadBool();
                    DateTime dateExpires = reader.ReadDateTime();

                    TitleEntry titleEntry = new TitleEntry(titleName);

                    titleEntry.m_Activated   = activated;
                    titleEntry.m_CurrentHue  = currentHue;
                    titleEntry.m_DateEarned  = dateEarned;
                    titleEntry.m_Expires     = expires;
                    titleEntry.m_DateExpires = dateExpires;

                    m_Titles.Add(titleEntry);
                }
            }

            //-----

            TitlePersistance.m_TitleCollections.Add(this);
        }
Exemple #4
0
        public static bool AddTitle(PlayerMobile player, string title, bool expires, DateTime expiration, bool message)
        {
            if (player == null)
            {
                return(false);
            }

            CheckAndCreateTitleCollection(player);

            if (HasTitle(player, title))
            {
                TitleEntry oldEntry = GetTitle(player, title);
                oldEntry.m_DateExpires = expiration;

                return(true);
            }

            TitleEntry entry = new TitleEntry(title);

            entry.m_Expires     = expires;
            entry.m_DateExpires = expiration;

            if (message)
            {
                if (expires)
                {
                    string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, expiration, false, true, true, false, false);

                    player.SendMessage("You have earned the title: " + title + " (expires in " + timeRemaining + ").");
                }

                else
                {
                    player.SendMessage("You have earned the title: " + title + ".");
                }
            }

            return(true);
        }