예제 #1
0
        public bool AutoConsume(PlayerMobile m)
        {
            if (m == null || m.Deleted)
            {
                return(false);
            }

            if (TitleHue == null)
            {
                m.SendMessage(0x22, "This ancient scroll has lost whatever power it once had.");
                m.PrivateOverheadMessage(MessageType.Label, 1287, true, "*The scroll disintegrates in your hands*", m.NetState);

                LoggingCustom.Log("HueScrollsInvalid.txt", String.Format("{0} -> {1} ({2})", m, this, TitleHue));

                Delete();

                return(false);
            }

            if (!CanConsume(m, false))
            {
                return(false);
            }

            TitleProfile p = CustomTitles.EnsureProfile(m);

            if (p == null)
            {
                return(false);
            }

            GrantHue(m, p);
            return(true);
        }
예제 #2
0
        public override void OnDoubleClick(Mobile m)
        {
            var pm = (PlayerMobile)m;

            if (TitleHue == null)
            {
                pm.SendMessage(0x22, "THIS HUE DOES NOT EXIST, PLEASE PAGE IN.");
                Delete();
                return;
            }

            TitleProfile p = CustomTitles.EnsureProfile(pm);

            if (p == null)
            {
                return;
            }

            if (p.Contains(TitleHue))
            {
                pm.SendMessage(0x22, "YOU ALREADY OWN THIS HUE.  THIS SHOULDN'T HAPPEN.  PLEASE PAGE IN.");
                return;
            }

            GrantHue(pm, p);
        }
예제 #3
0
        public override void OnDoubleClick(Mobile m)
        {
            if (!this.CheckDoubleClick(m, true, false, 2, true) || !(m is PlayerMobile))
            {
                return;
            }

            if (TitleHue == null)
            {
                m.SendMessage(0x22, "This ancient scroll has lost whatever power it once had.");
                m.PrivateOverheadMessage(MessageType.Label, 1287, true, "*The scroll disintegrates in your hands*", m.NetState);

                LoggingCustom.Log("HueScrollsInvalid.txt", String.Format("{0} -> {1} ({2})", m, this, TitleHue));

                Delete();

                return;
            }

            if (!CanConsume((PlayerMobile)m, true))
            {
                return;
            }

            var pm = (PlayerMobile)m;

            TitleProfile p = CustomTitles.EnsureProfile(pm);

            if (p == null)
            {
                return;
            }

            if (_Gump != null)
            {
                _Gump.Close(true);
                _Gump = null;
            }

            _Gump = SuperGump.Send(
                new ScrollConfirmGump(
                    pm,
                    null,
                    TitleHue,
                    b => GrantHue(pm, p),
                    b =>
            {
                pm.SendMessage(0x55, "You choose to not use the title hue scroll.");
                _Gump = null;
            }));
        }
예제 #4
0
        public static void SendTitlesGump(PlayerMobile pm)
        {
            if (pm == null || pm.Deleted)
            {
                return;
            }

            TitleProfile p = EnsureProfile(pm);

            if (p != null)
            {
                new CustomTitlesGump(pm, p).Send();
            }
        }
예제 #5
0
        public static void RevokeTitles(PlayerMobile pm)
        {
            if (pm == null || pm.Deleted)
            {
                return;
            }

            TitleProfile p = EnsureProfile(pm);

            if (p != null)
            {
                p.Titles.Clear();
            }
        }
예제 #6
0
        public static void GrantTitles(PlayerMobile pm)
        {
            if (pm == null || pm.Deleted)
            {
                return;
            }

            TitleProfile p = EnsureProfile(pm);

            if (p != null)
            {
                p.Titles.AddRange(TitleRegistry.Values.Not(p.Titles.Contains));
            }
        }
예제 #7
0
        public CustomTitlesGump(PlayerMobile user, TitleProfile titles)
            : base(user, null, 100, 100)
        {
            Modal   = false;
            CanMove = true;
            Sorted  = true;

            ForceRecompile = true;

            AutoRefreshRate = TimeSpan.FromMilliseconds(100);

            _TitleProfile  = titles;
            EntriesPerPage = 11;
        }
예제 #8
0
        public static TitleProfile EnsureProfile(PlayerMobile pm)
        {
            if (!CMOptions.ModuleEnabled || pm == null)
            {
                return(null);
            }

            TitleProfile p;

            if (!Profiles.TryGetValue(pm, out p))
            {
                Profiles.Add(pm, p = new TitleProfile(pm));
            }
            else if (p == null)
            {
                Profiles[pm] = p = new TitleProfile(pm);
            }

            return(p);
        }
        private void GrantTitle(PlayerMobile pm, TitleProfile p)
        {
            if (Title == null || pm == null || p == null)
            {
                return;
            }

            if (p.Contains(Title))
            {
                pm.SendMessage(0x22, "YOU ALREADY OWN THIS TITLE.  THIS SHOULDN'T HAPPEN.  PLEASE PAGE IN.");
                return;
            }

            p.Add(Title);

            pm.PrivateOverheadMessage(
                MessageType.Label, 1287, true,
                "*You have gained the title: " + (!pm.Female ? Title.MaleTitle : Title.FemaleTitle) + "*", pm.NetState);

            Delete();
        }
예제 #10
0
        private void GrantHue(PlayerMobile pm, TitleProfile p)
        {
            if (TitleHue == null || pm == null || p == null)
            {
                return;
            }

            if (p.Contains(TitleHue))
            {
                pm.SendMessage(0x22, "YOU ALREADY OWN THIS HUE.  THIS SHOULDN'T HAPPEN.  PLEASE PAGE IN.");
                return;
            }

            p.Add(TitleHue);

            pm.PrivateOverheadMessage(
                MessageType.Label, 1287, true,
                "*You have gained the title hue: " + TitleHue.Hue + "*", pm.NetState);

            Delete();
        }
예제 #11
0
        private void GrantHue(PlayerMobile pm, TitleProfile p)
        {
            if (TitleHue == null || pm == null || p == null)
            {
                return;
            }

            if (p.Contains(TitleHue))
            {
                pm.SendMessage(0x22, "You already own this title hue.");
                return;
            }

            p.Add(TitleHue);

            pm.PrivateOverheadMessage(
                MessageType.Label, 1287, true, "*The scroll crumbles in your hands as you absorb its power*", pm.NetState);

            LoggingCustom.Log("HueScrollsUsed.txt", String.Format("{0} -> {1} ({2})", pm, this, TitleHue));

            Delete();
        }
예제 #12
0
        private static bool DeserializeProfiles(GenericReader reader)
        {
            int version = reader.GetVersion();

            switch (version)
            {
            case 0:
            {
                reader.ReadBlockDictionary(
                    () =>
                    {
                        var p          = new TitleProfile(reader);
                        PlayerMobile s = p.Owner;

                        return(new KeyValuePair <PlayerMobile, TitleProfile>(s, p));
                    },
                    Profiles);
            }
            break;
            }

            return(true);
        }
예제 #13
0
        public bool CanConsume(PlayerMobile pm, bool message)
        {
            if (TitleHue == null)
            {
                return(false);
            }

            if (BoundToMobile != null && BoundToMobile != pm)
            {
                if (message)
                {
                    pm.SendMessage(54, "This scroll is bound to another entity.");
                }

                return(false);
            }

            TitleProfile p = CustomTitles.EnsureProfile(pm);

            if (p == null)
            {
                return(false);
            }

            if (p.Contains(TitleHue))
            {
                if (message)
                {
                    pm.SendMessage(0x22, "You already own this title hue.");
                }

                return(false);
            }

            return(true);
        }
예제 #14
0
		public static TitleProfile EnsureProfile(PlayerMobile pm)
		{
			if (!CMOptions.ModuleEnabled || pm == null)
			{
				return null;
			}

			TitleProfile p;

			if (!Profiles.TryGetValue(pm, out p))
			{
				Profiles.Add(pm, p = new TitleProfile(pm));
			}
			else if (p == null)
			{
				Profiles[pm] = p = new TitleProfile(pm);
			}

			return p;
		}
예제 #15
0
		private void GrantHue(PlayerMobile pm, TitleProfile p)
		{
			if (TitleHue == null || pm == null || p == null)
			{
				return;
			}

			if (p.Contains(TitleHue))
			{
				pm.SendMessage(0x22, "You already own this title hue.");
				return;
			}

			p.Add(TitleHue);

			pm.PrivateOverheadMessage(
				MessageType.Label, 1287, true, "*The scroll crumbles in your hands as you absorb its power*", pm.NetState);

			LoggingCustom.Log("HueScrollsUsed.txt", String.Format("{0} -> {1} ({2})", pm, this, TitleHue));

			Delete();
		}
예제 #16
0
        private static bool DeserializeProfiles(GenericReader reader)
        {
            int version = reader.GetVersion();

            switch (version)
            {
                case 0:
                {
                    reader.ReadBlockDictionary(
                        () =>
                        {
                            var p = new TitleProfile(reader);
                            PlayerMobile s = p.Owner;

                            return new KeyValuePair<PlayerMobile, TitleProfile>(s, p);
                        },
                        Profiles);
                }
                    break;
            }

            return true;
        }