Exemplo n.º 1
0
        public static void Remove(this TrashProfile profile)
        {
            if (profile == null)
            {
                return;
            }

            if (Profiles.ContainsKey(profile.Owner))
            {
                Profiles.Remove(profile.Owner);
            }

            profile.Delete();
        }
Exemplo n.º 2
0
        private static int InternalProfileSortToday(TrashProfile a, TrashProfile b)
        {
            if (a == b)
            {
                return(0);
            }

            if (a == null)
            {
                return(1);
            }

            if (b == null)
            {
                return(-1);
            }

            if (a.Deleted && b.Deleted)
            {
                return(0);
            }

            if (a.Deleted)
            {
                return(1);
            }

            if (b.Deleted)
            {
                return(-1);
            }

            var when = DateTime.UtcNow;

            var aTotal = a.GetTokenTotal(when);
            var bTotal = b.GetTokenTotal(when);

            if (aTotal > bTotal)
            {
                return(-1);
            }

            if (aTotal < bTotal)
            {
                return(1);
            }

            return(0);
        }
Exemplo n.º 3
0
		private static int InternalProfileSort(TrashProfile a, TrashProfile b)
		{
			if (a == b)
			{
				return 0;
			}

			if (a == null)
			{
				return 1;
			}

			if (b == null)
			{
				return -1;
			}

			if (a.Deleted && b.Deleted)
			{
				return 0;
			}

			if (a.Deleted)
			{
				return 1;
			}

			if (b.Deleted)
			{
				return -1;
			}

			int aTotal = a.GetTokenTotal();
			int bTotal = b.GetTokenTotal();

			if (aTotal > bTotal)
			{
				return -1;
			}

			if (aTotal < bTotal)
			{
				return 1;
			}

			return 0;
		}
Exemplo n.º 4
0
        private static int InternalProfileSort(TrashProfile a, TrashProfile b)
        {
            if (a == b)
            {
                return(0);
            }

            if (a == null)
            {
                return(1);
            }

            if (b == null)
            {
                return(-1);
            }

            if (a.Deleted && b.Deleted)
            {
                return(0);
            }

            if (a.Deleted)
            {
                return(1);
            }

            if (b.Deleted)
            {
                return(-1);
            }

            int aTotal = a.GetTokenTotal();
            int bTotal = b.GetTokenTotal();

            if (aTotal > bTotal)
            {
                return(-1);
            }

            if (aTotal < bTotal)
            {
                return(1);
            }

            return(0);
        }
Exemplo n.º 5
0
        public static TrashProfile EnsureProfile(Mobile m, bool replace = false)
        {
            if (m == null)
            {
                return(null);
            }

            if (!Profiles.ContainsKey(m))
            {
                Profiles.Add(m, new TrashProfile(m));
            }
            else if (replace || Profiles[m] == null || Profiles[m].Deleted)
            {
                Profiles[m] = new TrashProfile(m);
            }

            return(Profiles[m]);
        }
Exemplo n.º 6
0
        private static void InternalAddTrashProperties(Mobile viewer, ExtendedOPL list)
        {
            if (!CMOptions.ModuleEnabled || !CMOptions.UseTrashedProps || viewer == null || viewer.Deleted || list == null ||
                !(viewer is PlayerMobile))
            {
                return;
            }

            TrashProfile p = EnsureProfile(viewer);

            int todayTotal = p.GetTokenTotal(DateTime.UtcNow);
            int total      = p.GetTokenTotal();

            list.Add(
                "<basefont color=#{0:X6}>Total Tokens Earned: {1}", Color.SkyBlue.ToArgb(), total <= 0 ? "0" : total.ToString("#,#"));

            if (CMOptions.DailyLimit > 0)
            {
                const int blocks = 10;
                double    cur    = (Math.Max(0, Math.Min(CMOptions.DailyLimit, (double)todayTotal)) / CMOptions.DailyLimit) * 100.0;
                int       left   = (int)Math.Floor(cur / blocks);
                int       right  = blocks - left;

                list.Add("<basefont color=#{0:X6}>Tokens Earned Today:", Color.SkyBlue.ToArgb());
                list.Add(
                    "[<basefont color=#{0:X6}>{1}<basefont color=#{2:X6}>{3}<basefont color=#{4:X6}>] {5}/{6}",
                    Color.LimeGreen.ToArgb(),
                    new String('=', left),
                    Color.OrangeRed.ToArgb(),
                    new String('=', right),
                    Color.SkyBlue.ToArgb(),
                    todayTotal <= 0 ? "0" : todayTotal.ToString("#,#"),
                    CMOptions.DailyLimit.ToString("#,#"));
            }
            else
            {
                list.Add("Tokens Earned Today: {0}", todayTotal <= 0 ? "0" : todayTotal.ToString("#,#"));
            }

            list.Add("<basefont color=#ffffff>");
        }
Exemplo n.º 7
0
 public static void HandleTrashTokens(TrashProfile p, TrashToken t)
 {
     if (p != null && p.Owner != null && p.Owner is PlayerMobile)
     {
         CheckProgress<ItemConquest>((PlayerMobile) p.Owner, t);
     }
 }
Exemplo n.º 8
0
		public static TrashProfile EnsureProfile(Mobile m, bool replace = false)
		{
			if (m == null)
			{
				return null;
			}

			if (!Profiles.ContainsKey(m))
			{
				Profiles.Add(m, new TrashProfile(m));
			}
			else if (replace || Profiles[m] == null || Profiles[m].Deleted)
			{
				Profiles[m] = new TrashProfile(m);
			}

			return Profiles[m];
		}
Exemplo n.º 9
0
		private static int InternalProfileSortToday(TrashProfile a, TrashProfile b)
		{
			if (a == b)
			{
				return 0;
			}

			if (a == null)
			{
				return 1;
			}

			if (b == null)
			{
				return -1;
			}

			if (a.Deleted && b.Deleted)
			{
				return 0;
			}

			if (a.Deleted)
			{
				return 1;
			}

			if (b.Deleted)
			{
				return -1;
			}

			DateTime when = DateTime.UtcNow;

			int aTotal = a.GetTokenTotal(when);
			int bTotal = b.GetTokenTotal(when);

			if (aTotal > bTotal)
			{
				return -1;
			}

			if (aTotal < bTotal)
			{
				return 1;
			}

			return 0;
		}