Esempio n. 1
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);
        }
Esempio 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)
            {
                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);
        }