Ejemplo n.º 1
0
        protected virtual void SelectCategory(int gx, int gy, int idx, RuneCodexCategory cat)
        {
            UI.CategoryPoint = new Point2D(gx, gy);
            UI.Category      = cat;

            OnSelected(gx, gy, idx, cat);
        }
Ejemplo n.º 2
0
        public virtual bool AddRunebook(Mobile m, Runebook book, RuneCodexCategory cat, bool message)
        {
            if (m == null || m.Deleted || book == null || book.Deleted || !book.IsAccessibleTo(m))
            {
                return(false);
            }

            if (cat == null)
            {
                var pm = m as PlayerMobile;

                if (pm != null)
                {
                    var ui = Users.FirstOrDefault(uic => uic.User == pm);

                    if (ui != null)
                    {
                        cat = ui.Category ?? Categories[ui.CategoryPoint.X, ui.CategoryPoint.Y];
                    }
                    else
                    {
                        cat = Categories[0, 0];
                    }
                }
                else
                {
                    cat = Categories[0, 0];
                }
            }

            if (book.Entries == null || book.Entries.Count == 0)
            {
                if (message)
                {
                    m.SendMessage("That rune book is empty.");
                }

                return(false);
            }

            if (Categories.Count >= Categories.Capacity)
            {
                if (message)
                {
                    m.SendMessage("This rune codex can't hold more categories.");
                }

                return(false);
            }

            if (cat != null && cat.AddRunebook(m, book, message))
            {
                InvalidateProperties();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        protected virtual void OnSelected(int gx, int gy, int idx, RuneCodexCategory cat)
        {
            if (DoubleClicked)
            {
                OnAccept(null);
                return;
            }

            Refresh(true);
        }
Ejemplo n.º 4
0
        public virtual bool AddRune(Mobile m, RecallRune rune, RuneCodexCategory cat, bool message)
        {
            if (m == null || m.Deleted || rune == null || rune.Deleted || !rune.IsAccessibleTo(m))
            {
                return(false);
            }

            PlayerMobile pm = m as PlayerMobile;

            if (cat == null)
            {
                cat = pm != null && Users.ContainsKey(pm)
                                                  ? (Users[pm].Category ?? Categories[Users[pm].CategoryPoint.X, Users[pm].CategoryPoint.Y])
                                                  : Categories[0, 0];
            }

            Point2D loc = pm != null && Users.ContainsKey(pm) ? Users[pm].EntryPoint : Point2D.Zero;

            if (!rune.Marked || rune.Target == Point3D.Zero || rune.TargetMap == Map.Internal)
            {
                if (message)
                {
                    m.SendMessage("That rune is blank.");
                }

                return(false);
            }

            if (cat != null)
            {
                if (cat.Entries.Count >= cat.Entries.Capacity)
                {
                    if (message)
                    {
                        m.SendMessage("The rune codex category \"{0}\" can't hold more runes.", cat.Description);
                    }

                    return(false);
                }

                if (cat.SetRune(m, rune, loc, message))
                {
                    InvalidateProperties();
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        public virtual bool AddRunebook(Mobile m, Runebook book, RuneCodexCategory cat, bool message)
        {
            if (m == null || m.Deleted || book == null || book.Deleted || !book.IsAccessibleTo(m))
            {
                return(false);
            }

            if (cat == null)
            {
                PlayerMobile pm = m as PlayerMobile;

                cat = pm != null && Users.ContainsKey(pm)
                                                  ? (Users[pm].Category ?? Categories[Users[pm].CategoryPoint.X, Users[pm].CategoryPoint.Y])
                                                  : Categories[0, 0];
            }

            if (book.Entries == null || book.Entries.Count == 0)
            {
                if (message)
                {
                    m.SendMessage("That rune book is empty.");
                }

                return(false);
            }

            if (Categories.Count >= Categories.Capacity)
            {
                if (message)
                {
                    m.SendMessage("This rune codex can't hold more categories.");
                }

                return(false);
            }

            if (cat != null && cat.AddRunebook(m, book, message))
            {
                InvalidateProperties();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 6
0
        public bool Remove(RuneCodexCategory cat)
        {
            for (var x = 0; x < Categories.Width; x++)
            {
                for (var y = 0; y < Categories.Height; y++)
                {
                    if (Categories[x, y] != cat)
                    {
                        continue;
                    }

                    Categories[x, y] = null;
                    InvalidateProperties();
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 7
0
 public virtual string GetCategoryLabel(RuneCodexCategory cat)
 {
     return(cat != null ? cat.Name : String.Empty);
 }
Ejemplo n.º 8
0
		protected virtual void SelectCategory(int gx, int gy, int idx, RuneCodexCategory cat)
		{
			var ui = UI;

			ui.CategoryPoint = new Point2D(gx, gy);
			ui.Category = cat;

			OnSelected(gx, gy, idx, cat);
		}
Ejemplo n.º 9
0
		protected virtual void OnSelected(int gx, int gy, int idx, RuneCodexCategory cat)
		{
			if (DoubleClicked)
			{
				OnAccept(null);
				return;
			}

			Refresh(true);
		}
Ejemplo n.º 10
0
		public virtual string GetCategoryLabel(RuneCodexCategory cat)
		{
			return cat != null ? cat.Name : String.Empty;
		}
Ejemplo n.º 11
0
		protected virtual void CompileCategory(SuperGumpLayout layout, int x, int y, int idx, RuneCodexCategory cat)
		{
			if (x >= Codex.Categories.Width || y >= Codex.Categories.Height)
			{
				return;
			}

			layout.Add(
				"cat/" + idx,
				() =>
				{
					var ui = UI;

					int xOffset = 220 + (x * 70);
					int yOffset = 50 + (y * 70);
					int gx = x + ui.CategoryScroll.X;
					int gy = y + ui.CategoryScroll.Y;

					const int itemID = 8901;
					bool s = cat != null && ui.Category == cat;

					if (cat != null)
					{
						AddButton(xOffset + 5, yOffset + 5, 24024, 24024, b => SelectCategory(gx, gy, idx, cat));
					}
					else if (Codex.CanAddCategories(User))
					{
						AddButton(xOffset + 5, yOffset + 5, 24024, 24024, b => AddCategory(gx, gy, idx));
					}

					AddImageTiled(xOffset, yOffset, 60, 60, 2702);

					if (s)
					{
						AddItem(xOffset + 10, yOffset + 4, itemID, 2050);
						AddItem(xOffset + 10, yOffset + 2, itemID, 1);
					}

					if (cat != null)
					{
						AddItem(xOffset + 10, yOffset, itemID, cat.Hue);
						AddHtml(
							xOffset,
							yOffset + 25,
							60,
							40,
							GetCategoryLabel(cat).WrapUOHtmlTag("center").WrapUOHtmlColor(Color.LawnGreen, false),
							false,
							false);
					}
					else if (Codex.CanAddCategories(User))
					{
						AddImage(xOffset + 25, yOffset, 2511, HighlightHue);
						AddHtml(
							xOffset, yOffset + 25, 60, 40, "Add".WrapUOHtmlTag("center").WrapUOHtmlColor(Color.Yellow, false), false, false);
					}
				});
		}
Ejemplo n.º 12
0
        public bool Drop(Mobile m, RuneCodexCategory cat, bool message)
        {
            if (m == null || m.Deleted || cat == null)
            {
                return(false);
            }

            if (cat.Entries == null || cat.Entries.Count == 0)
            {
                if (message)
                {
                    m.SendMessage("The category \"{0}\" is empty.", cat.Name);
                }

                return(false);
            }

            var cost = CloneEntryChargeCost * cat.Entries.Count;

            if (!ConsumeCharges(cost))
            {
                if (message)
                {
                    m.SendMessage("This action requires {0:#,0} charge{1}.", cost, cost != 1 ? "s" : String.Empty);
                }

                return(false);
            }

            var entries = new Queue <RuneCodexEntry>(cat.Entries.Not(e => e == null));
            var book    = new Runebook();
            var count   = 1;

            while (entries.Count > 0)
            {
                var entry = entries.Dequeue();

                if (entry == null)
                {
                    continue;
                }

                book.Entries.Add(
                    new RunebookEntry(
                        entry.Location,
                        entry.Location,
                        entry.Name,
                        BaseHouse.FindHouseAt(entry.Location, entry.Location, 16)));

                if (book.Entries.Count < 16 && entries.Count > 0)
                {
                    continue;
                }

                m.AddToBackpack(book);

                if (entries.Count == 0)
                {
                    continue;
                }

                book = new Runebook();
                ++count;
            }

            if (message)
            {
                m.SendMessage(
                    "You created {0:#,0} rune book{1} and consumed {2:#,0} charge{3} from the codex.",
                    count,
                    count != 1 ? "s" : String.Empty,
                    cost,
                    cost != 1 ? "s" : String.Empty);
            }

            return(true);
        }
Ejemplo n.º 13
0
        public override void OnAfterDuped(Item newItem)
        {
            base.OnAfterDuped(newItem);

            var c = newItem as RuneCodex;

            if (c == null)
            {
                return;
            }

            c.AddLocked    = AddLocked;
            c.EditLocked   = EditLocked;
            c.RemoveLocked = RemoveLocked;

            c.CloneEntryChargeCost = CloneEntryChargeCost;
            c.RecallChargeCost     = RecallChargeCost;
            c.GateChargeCost       = GateChargeCost;

            c.Charges    = Charges;
            c.Descripton = Descripton;

            c.Categories  = new RuneCodexCategoryGrid();
            c.ChargeTypes = new Dictionary <Type, int>(ChargeTypes);
            c.Users       = new List <UICache>();

            RuneCodexCategory cata, catb;
            RuneCodexEntry    entrya, entryb;

            for (var cx = 0; cx < Categories.Width; cx++)
            {
                for (var cy = 0; cy < Categories.Height; cy++)
                {
                    cata = Categories[cx, cy];

                    if (cata == null)
                    {
                        continue;
                    }

                    catb = new RuneCodexCategory(cata.Name, cata.Description, cata.Hue);

                    c.Categories.SetContent(cx, cy, catb);

                    for (var ex = 0; ex < cata.Entries.Width; ex++)
                    {
                        for (var ey = 0; ey < cata.Entries.Width; ey++)
                        {
                            entrya = cata.Entries[ex, ey];

                            if (entrya == null)
                            {
                                continue;
                            }

                            entryb = new RuneCodexEntry(entrya.Name, entrya.Description, entrya.Location);

                            catb.Entries.SetContent(ex, ey, entryb);
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        protected virtual void CompileCategory(SuperGumpLayout layout, int x, int y, int idx, RuneCodexCategory cat)
        {
            if (x >= Codex.Categories.Width || y >= Codex.Categories.Height)
            {
                return;
            }

            layout.Add(
                "cat/" + idx,
                () =>
            {
                var ui = UI;

                var xOffset = 220 + (x * 70);
                var yOffset = 50 + (y * 70);
                var gx      = x + ui.CategoryScroll.X;
                var gy      = y + ui.CategoryScroll.Y;

                const int itemID = 8901;
                var s            = cat != null && ui.Category == cat;

                if (cat != null)
                {
                    AddButton(xOffset + 5, yOffset + 5, 24024, 24024, b => SelectCategory(gx, gy, idx, cat));
                }
                else if (Codex.CanAddCategories(User))
                {
                    AddButton(xOffset + 5, yOffset + 5, 24024, 24024, b => AddCategory(gx, gy, idx));
                }

                AddImageTiled(xOffset, yOffset, 60, 60, 2702);

                if (s)
                {
                    AddItem(xOffset + 10, yOffset + 4, itemID, 2050);
                    AddItem(xOffset + 10, yOffset + 2, itemID, 1);
                }

                if (cat != null)
                {
                    AddItem(xOffset + 10, yOffset, itemID, cat.Hue);
                    AddHtml(
                        xOffset,
                        yOffset + 25,
                        60,
                        40,
                        GetCategoryLabel(cat).WrapUOHtmlTag("center").WrapUOHtmlColor(Color.LawnGreen, false),
                        false,
                        false);
                }
                else if (Codex.CanAddCategories(User))
                {
                    AddImage(xOffset + 25, yOffset, 2511, HighlightHue);
                    AddHtml(
                        xOffset,
                        yOffset + 25,
                        60,
                        40,
                        "Add".WrapUOHtmlTag("center").WrapUOHtmlColor(Color.Yellow, false),
                        false,
                        false);
                }
            });
        }
Ejemplo n.º 15
0
		public virtual bool AddRune(Mobile m, RecallRune rune, RuneCodexCategory cat, bool message)
		{
			if (m == null || m.Deleted || rune == null || rune.Deleted || !rune.IsAccessibleTo(m))
			{
				return false;
			}

			PlayerMobile pm = m as PlayerMobile;

			if (cat == null)
			{
				cat = pm != null && Users.ContainsKey(pm)
						  ? (Users[pm].Category ?? Categories[Users[pm].CategoryPoint.X, Users[pm].CategoryPoint.Y])
						  : Categories[0, 0];
			}

			Point2D loc = pm != null && Users.ContainsKey(pm) ? Users[pm].EntryPoint : Point2D.Zero;

			if (!rune.Marked || rune.Target == Point3D.Zero || rune.TargetMap == Map.Internal)
			{
				if (message)
				{
					m.SendMessage("That rune is blank.");
				}

				return false;
			}

			if (cat != null)
			{
				if (cat.Entries.Count >= cat.Entries.Capacity)
				{
					if (message)
					{
						m.SendMessage("The rune codex category \"{0}\" can't hold more runes.", cat.Description);
					}

					return false;
				}

				if (cat.SetRune(m, rune, loc, message))
				{
					InvalidateProperties();
					return true;
				}
			}

			return false;
		}
Ejemplo n.º 16
0
        public virtual bool AddRune(Mobile m, RecallRune rune, RuneCodexCategory cat, bool message)
        {
            if (m == null || m.Deleted || rune == null || rune.Deleted || !rune.IsAccessibleTo(m))
            {
                return(false);
            }

            var pm = m as PlayerMobile;

            var loc = Point2D.Zero;

            if (cat == null)
            {
                if (pm != null)
                {
                    var ui = Users.FirstOrDefault(uic => uic.User == pm);

                    if (ui != null)
                    {
                        cat = ui.Category ?? Categories[ui.CategoryPoint.X, ui.CategoryPoint.Y];
                        loc = ui.EntryPoint;
                    }
                    else
                    {
                        cat = Categories[0, 0];
                    }
                }
                else
                {
                    cat = Categories[0, 0];
                }
            }

            if (!rune.Marked || rune.Target == Point3D.Zero || rune.TargetMap == Map.Internal)
            {
                if (message)
                {
                    m.SendMessage("That rune is blank.");
                }

                return(false);
            }

            if (cat != null)
            {
                if (cat.Entries.Count >= cat.Entries.Capacity)
                {
                    if (message)
                    {
                        m.SendMessage("The rune codex category \"{0}\" can't hold more runes.", cat.Description);
                    }

                    return(false);
                }

                if (cat.SetRune(m, rune, loc, message))
                {
                    InvalidateProperties();
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 17
0
		public bool Add(Mobile m, Item item, RuneCodexCategory cat, bool message)
		{
			if (m == null || m.Deleted || item == null || item.Deleted || !item.IsAccessibleTo(m))
			{
				return false;
			}

			if (item is RecallRune)
			{
				return AddRune(m, (RecallRune)item, cat, message);
			}

			if (item is Runebook)
			{
				return AddRunebook(m, (Runebook)item, cat, message);
			}

			#region Master Runebook Support
			//Using Reflection for shards that don't have it installed.
			Type t = item.GetType();

			if (Insensitive.Equals(t.Name, "MasterRunebook"))
			{
				var pi = t.GetProperty("Books");

				if (pi != null && pi.CanRead)
				{
					var obj = pi.GetValue(item, null);

					if (obj is ICollection)
					{
						var ex = new Queue<Runebook>(((ICollection)obj).OfType<Runebook>().Where(r => r.Entries.Count > 0));

						if (ex.Count == 0)
						{
							if (message)
							{
								m.SendMessage("That master rune book is empty.");
							}

							return false;
						}

						if (Categories.Count + ex.Count > Categories.Capacity)
						{
							if (message)
							{
								m.SendMessage("That master rune book won't fit in this rune codex.");
							}

							return false;
						}

						int extracted = 0;

						while (ex.Count > 0)
						{
							var b = ex.Dequeue();

							if (AddRunebook(m, b, cat, message))
							{
								++extracted;
							}
						}

						if (extracted > 0)
						{
							if (message)
							{
								m.SendMessage(
									"You extract {0:#,0} book{1} from the master rune book and add them to the codex.",
									extracted,
									extracted != 1 ? "s" : String.Empty);
							}

							return true;
						}

						if (message)
						{
							m.SendMessage("There was nothing in the master rune book to extract.");
						}
					}
				}

				return false;
			}
			#endregion Master Runebook Support

			if (AddCharges(m, item, message))
			{
				return item.Deleted;
			}

			if (message)
			{
				m.SendMessage("Drop a rune book or recall rune on the codex to add them.");
			}

			return false;
		}
Ejemplo n.º 18
0
		public override void OnAfterDuped(Item newItem)
		{
			base.OnAfterDuped(newItem);

			RuneCodex c = newItem as RuneCodex;

			if (c == null)
			{
				return;
			}

			c.AddLocked = AddLocked;
			c.EditLocked = EditLocked;
			c.RemoveLocked = RemoveLocked;

			c.CloneEntryChargeCost = CloneEntryChargeCost;
			c.RecallChargeCost = RecallChargeCost;
			c.GateChargeCost = GateChargeCost;

			c.Charges = Charges;
			c.Descripton = Descripton;

			c.Categories = new RuneCodexCategoryGrid();
			c.ChargeTypes = new Dictionary<Type, int>(ChargeTypes);
			c.Users = new Dictionary<PlayerMobile, UICache>();

			RuneCodexCategory cata, catb;
			RuneCodexEntry entrya, entryb;

			for (int cx = 0; cx < Categories.Width; cx++)
			{
				for (int cy = 0; cy < Categories.Height; cy++)
				{
					cata = Categories[cx, cy];

					if (cata == null)
					{
						continue;
					}

					catb = new RuneCodexCategory(cata.Name, cata.Description, cata.Hue);

					c.Categories.SetContent(cx, cy, catb);

					for (int ex = 0; ex < cata.Entries.Width; ex++)
					{
						for (int ey = 0; ey < cata.Entries.Width; ey++)
						{
							entrya = cata.Entries[ex, ey];

							if (entrya == null)
							{
								continue;
							}

							entryb = new RuneCodexEntry(entrya.Name, entrya.Description, entrya.Location);

							catb.Entries.SetContent(ex, ey, entryb);
						}
					}
				}
			}
		}
Ejemplo n.º 19
0
		public bool Drop(Mobile m, RuneCodexCategory cat, bool message)
		{
			if (m == null || m.Deleted || cat == null)
			{
				return false;
			}

			if (cat.Entries == null || cat.Entries.Count == 0)
			{
				if (message)
				{
					m.SendMessage("The category \"{0}\" is empty.", cat.Name);
				}

				return false;
			}

			int cost = CloneEntryChargeCost * cat.Entries.Count;

			if (!ConsumeCharges(cost))
			{
				if (message)
				{
					m.SendMessage("This action requires {0:#,0} charge{1}.", cost, cost != 1 ? "s" : String.Empty);
				}

				return false;
			}

			var entries = new Queue<RuneCodexEntry>(cat.Entries.Not(e => e == null));
			Runebook book = new Runebook();
			int count = 1;

			while (entries.Count > 0)
			{
				var entry = entries.Dequeue();

				if (entry == null)
				{
					continue;
				}

				book.Entries.Add(
					new RunebookEntry(
						entry.Location, entry.Location, entry.Name, BaseHouse.FindHouseAt(entry.Location, entry.Location, 16)));

				if (book.Entries.Count < 16 && entries.Count > 0)
				{
					continue;
				}

				m.AddToBackpack(book);

				if (entries.Count == 0)
				{
					continue;
				}

				book = new Runebook();
				++count;
			}

			if (message)
			{
				m.SendMessage(
					"You created {0:#,0} rune book{1} and consumed {2:#,0} charge{3} from the codex.",
					count,
					count != 1 ? "s" : String.Empty,
					cost,
					cost != 1 ? "s" : String.Empty);
			}

			return true;
		}
Ejemplo n.º 20
0
		public bool Remove(RuneCodexCategory cat)
		{
			for (int x = 0; x < Categories.Width; x++)
			{
				for (int y = 0; y < Categories.Height; y++)
				{
					if (Categories[x, y] != cat)
					{
						continue;
					}

					Categories[x, y] = null;
					InvalidateProperties();
					return true;
				}
			}

			return false;
		}
Ejemplo n.º 21
0
        public bool Add(Mobile m, Item item, RuneCodexCategory cat, bool message)
        {
            if (m == null || m.Deleted || item == null || item.Deleted || !item.IsAccessibleTo(m))
            {
                return(false);
            }

            if (item is RecallRune)
            {
                return(AddRune(m, (RecallRune)item, cat, message));
            }

            if (item is Runebook)
            {
                return(AddRunebook(m, (Runebook)item, cat, message));
            }

            #region Master Runebook Support
            //Using Reflection for shards that don't have it installed.
            var t = item.GetType();

            if (Insensitive.Equals(t.Name, "MasterRunebook"))
            {
                var pi = t.GetProperty("Books");

                if (pi != null && pi.CanRead)
                {
                    var obj = pi.GetValue(item, null);

                    if (obj is ICollection)
                    {
                        var ex = new Queue <Runebook>(((ICollection)obj).OfType <Runebook>().Where(r => r.Entries.Count > 0));

                        if (ex.Count == 0)
                        {
                            if (message)
                            {
                                m.SendMessage("That master rune book is empty.");
                            }

                            return(false);
                        }

                        if (Categories.Count + ex.Count > Categories.Capacity)
                        {
                            if (message)
                            {
                                m.SendMessage("That master rune book won't fit in this rune codex.");
                            }

                            return(false);
                        }

                        var extracted = 0;

                        while (ex.Count > 0)
                        {
                            var b = ex.Dequeue();

                            if (AddRunebook(m, b, cat, message))
                            {
                                ++extracted;
                            }
                        }

                        if (extracted > 0)
                        {
                            if (message)
                            {
                                m.SendMessage(
                                    "You extract {0:#,0} book{1} from the master rune book and add them to the codex.",
                                    extracted,
                                    extracted != 1 ? "s" : String.Empty);
                            }

                            return(true);
                        }

                        if (message)
                        {
                            m.SendMessage("There was nothing in the master rune book to extract.");
                        }
                    }
                }

                return(false);
            }
            #endregion Master Runebook Support

            if (AddCharges(m, item, message))
            {
                return(item.Deleted);
            }

            if (message)
            {
                m.SendMessage("Drop a rune book or recall rune on the codex to add them.");
            }

            return(false);
        }
Ejemplo n.º 22
0
		public virtual bool AddRunebook(Mobile m, Runebook book, RuneCodexCategory cat, bool message)
		{
			if (m == null || m.Deleted || book == null || book.Deleted || !book.IsAccessibleTo(m))
			{
				return false;
			}

			if (cat == null)
			{
				PlayerMobile pm = m as PlayerMobile;

				cat = pm != null && Users.ContainsKey(pm)
						  ? (Users[pm].Category ?? Categories[Users[pm].CategoryPoint.X, Users[pm].CategoryPoint.Y])
						  : Categories[0, 0];
			}

			if (book.Entries == null || book.Entries.Count == 0)
			{
				if (message)
				{
					m.SendMessage("That rune book is empty.");
				}

				return false;
			}

			if (Categories.Count >= Categories.Capacity)
			{
				if (message)
				{
					m.SendMessage("This rune codex can't hold more categories.");
				}

				return false;
			}

			if (cat != null && cat.AddRunebook(m, book, message))
			{
				InvalidateProperties();
				return true;
			}

			return false;
		}