Esempio n. 1
0
        public static void RemoveSculpture(TenthAnniversarySculpture sculpture)
        {
            if (m_sculptures.Contains(sculpture))
            {
                m_sculptures.Remove(sculpture);
            }

            if (m_sculptures.Count == 0 && m_Timer != null)
            {
                m_Timer.Stop();
                m_Timer = null;
            }
        }
        public static void DefragTables()
        {
            for (var index = 0; index < m_sculptures.Count; index++)
            {
                TenthAnniversarySculpture sculpture = m_sculptures[index];

                List <Mobile> list = new List <Mobile>(sculpture.RewardCooldown.Keys);

                for (var i = 0; i < list.Count; i++)
                {
                    Mobile m = list[i];

                    if (sculpture.RewardCooldown.ContainsKey(m) && sculpture.RewardCooldown[m] < DateTime.UtcNow)
                    {
                        sculpture.RewardCooldown.Remove(m);
                    }
                }

                list.Clear();
            }

            List <Mobile> remove = new List <Mobile>();

            foreach (KeyValuePair <Mobile, DateTime> kvp in m_LuckTable)
            {
                if (kvp.Value < DateTime.UtcNow)
                {
                    remove.Add(kvp.Key);
                }
            }

            for (var index = 0; index < remove.Count; index++)
            {
                var m = remove[index];

                m_LuckTable.Remove(m);

                if (m.NetState != null)
                {
                    m.SendLocalizedMessage(1079552); //Your luck just ran out.
                }
            }

            remove.Clear();
        }
        public bool IsCoolingDown(Mobile from)
        {
            bool donemessage = false;

            if (m_LuckTable.ContainsKey(from))
            {
                from.SendLocalizedMessage(1079534); // You're still feeling lucky from the last time you touched the sculpture.
                donemessage = true;
            }

            for (var index = 0; index < m_sculptures.Count; index++)
            {
                TenthAnniversarySculpture sculpture = m_sculptures[index];

                if (sculpture.RewardCooldown != null && sculpture.RewardCooldown.ContainsKey(from))
                {
                    if (!donemessage)
                    {
                        TimeSpan left = sculpture.RewardCooldown[from] - DateTime.UtcNow;

                        if (left.TotalHours > 1)
                        {
                            from.SendLocalizedMessage(1079550, ((int)left.TotalHours).ToString());  // You can improve your fortunes again in about ~1_TIME~ hours.
                        }
                        else if (left.TotalMinutes > 1)
                        {
                            from.SendLocalizedMessage(1079548, ((int)left.TotalMinutes).ToString());  // You can improve your fortunes in about ~1_TIME~ minutes.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1079547); // Your fortunes are about to improve.
                        }
                    }

                    return(true);
                }
            }

            return(false);
        }
        public static void RemoveSculpture(TenthAnniversarySculpture sculpture)
        {
            if (m_sculptures.Contains(sculpture))
                m_sculptures.Remove(sculpture);

            if (m_sculptures.Count == 0 && m_Timer != null)
            {
                m_Timer.Stop();
                m_Timer = null;
            }
        }
 public static void AddSculpture(TenthAnniversarySculpture sculpture)
 {
     if (!m_sculptures.Contains(sculpture))
     {
         m_sculptures.Add(sculpture);
         StartTimer();
     }
 }