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); }
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); }
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); }