Exemplo n.º 1
0
        public static bool HasAccess(Mobile mob, RewardList list, out TimeSpan ts)
        {
            if (list == null)
            {
                ts = TimeSpan.Zero;
                return(false);
            }

            Account acct = mob.Account as Account;

            if (acct == null)
            {
                ts = TimeSpan.Zero;
                return(false);
            }

            TimeSpan totalTime = (DateTime.UtcNow - acct.Created);

            ts = (list.Age - totalTime);

            if (ts <= TimeSpan.Zero)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public static bool CheckIsUsableBy(Mobile from, Item item, object[] args)
        {
            if (m_Lists == null)
            {
                SetupRewardTables();
            }

            bool isRelaxedRules = (item is DyeTub || item is MonsterStatuette);

            Type type = item.GetType();

            for (int i = 0; i < m_Lists.Length; ++i)
            {
                RewardList    list    = m_Lists[i];
                RewardEntry[] entries = list.Entries;
                TimeSpan      ts;

                for (int j = 0; j < entries.Length; ++j)
                {
                    if (entries[j].ItemType == type)
                    {
                        if (args == null && entries[j].Args.Length == 0)
                        {
                            if ((!isRelaxedRules || i > 0) && !HasAccess(from, list, out ts))
                            {
                                from.SendLocalizedMessage(1008126, true, Math.Ceiling(ts.TotalDays / 30.0).ToString()); // Your account is not old enough to use this item. Months until you can use this item :
                                return(false);
                            }

                            return(true);
                        }

                        if (args.Length == entries[j].Args.Length)
                        {
                            bool match = true;

                            for (int k = 0; match && k < args.Length; ++k)
                            {
                                match = (args[k].Equals(entries[j].Args[k]));
                            }

                            if (match)
                            {
                                if ((!isRelaxedRules || i > 0) && !HasAccess(from, list, out ts))
                                {
                                    from.SendLocalizedMessage(1008126, true, Math.Ceiling(ts.TotalDays / 30.0).ToString()); // Your account is not old enough to use this item. Months until you can use this item :
                                    return(false);
                                }

                                return(true);
                            }
                        }
                    }
                }
            }

            // no entry?
            return(true);
        }
Exemplo n.º 3
0
        public static int GetRewardYear(Item item, object[] args)
        {
            if (m_Lists == null)
            {
                SetupRewardTables();
            }

            Type type = item.GetType();

            for (int i = 0; i < m_Lists.Length; ++i)
            {
                RewardList    list    = m_Lists[i];
                RewardEntry[] entries = list.Entries;

                for (int j = 0; j < entries.Length; ++j)
                {
                    if (entries[j].ItemType == type)
                    {
                        if (args == null && entries[j].Args.Length == 0)
                        {
                            return(i + 1);
                        }

                        if (args.Length == entries[j].Args.Length)
                        {
                            bool match = true;

                            for (int k = 0; match && k < args.Length; ++k)
                            {
                                match = (args[k].Equals(entries[j].Args[k]));
                            }

                            if (match)
                            {
                                return(i + 1);
                            }
                        }
                    }
                }
            }

            // no entry?
            return(0);
        }