Ejemplo n.º 1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (Checked == null)
            {
                return;
            }

            Mobile from = sender.Mobile;

            switch (info.ButtonID)
            {
            case 20:     // Cancel
            {
                break;
            }

            case 21:     // Select All
            {
                Checked.Clear();

                for (int i = 0; i < SourceBook.Entries.Count; i++)
                {
                    Checked.Add(SourceBook.Entries[i]);
                }

                if (!from.HasGump(typeof(PenOfWisdomGump)))
                {
                    from.SendGump(new PenOfWisdomGump(from, Pen, SourceBook, CopyBook, Checked));
                }

                break;
            }

            case 22:     // OK
            {
                if (MarkScrollAmount < Checked.Count || RuneAmount < Checked.Count)
                {
                    from.SendLocalizedMessage(1115364);         // You don't have enough recall runes and Mark scrolls to do that.
                }
                else if (Blank < Checked.Count)
                {
                    from.SendLocalizedMessage(1115330);         // The destination runebook doesn't have enough space.
                }
                else if (!SourceBook.IsChildOf(from.Backpack) && SourceBook.Movable || !CopyBook.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1115329);         // Runebooks you wish to copy must be in your backpack.
                }
                else
                {
                    foreach (RunebookEntry entry in Checked)
                    {
                        CopyBook.Entries.Add(entry);
                    }

                    Container bp = from.Backpack;

                    bp.ConsumeTotal(typeof(MarkScroll), Checked.Count, true);
                    bp.ConsumeTotal(typeof(RecallRune), Checked.Count, true);
                    Pen.UsesRemaining -= 1;
                    Pen.InvalidateProperties();

                    from.SendLocalizedMessage(1115331);         // The Pen magically marks runes and binds them to the runebook.
                    from.SendLocalizedMessage(1115366);         // The pen's magical power is consumed and it crumbles to dust.
                }

                break;
            }

            default:
            {
                int index = info.ButtonID;

                if (Checked.Contains(SourceBook.Entries[index]))
                {
                    Checked.Remove(SourceBook.Entries[index]);
                }
                else
                {
                    Checked.Add(SourceBook.Entries[index]);
                }

                if (!from.HasGump(typeof(PenOfWisdomGump)))
                {
                    from.SendGump(new PenOfWisdomGump(from, Pen, SourceBook, CopyBook, Checked));
                }

                break;
            }
            }
        }
Ejemplo n.º 2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                Item target = ((Item)targeted);

                Container pack = from.Backpack;

                if (pack == null)
                {
                    from.SendMessage("Please ensure you have a pack.");
                    return;
                }

                if (target == null || target.Deleted || !(target is Runebook) || ((Runebook)target).Entries.Count > 0)
                {
                    from.SendMessage("You can only copy to an empty runebook.");
                    return;
                }

                if (target.RootParent != from)
                {
                    from.SendMessage("The runebook you wish to write to must be in your backpack.");
                    return;
                }

                if (ConsumeTotal(pack, ((Runebook)m_Source).Entries.Count, true) > -1)
                {
                    from.SendMessage("This operation requires unmarked recall runes and mark scrolls.");
                    from.SendMessage("Total of each needed: {0}.", ((Runebook)m_Source).Entries.Count);
                    return;
                }

                Type t = typeof(Runebook);

                ConstructorInfo c = t.GetConstructor(Type.EmptyTypes);

                if (c != null)
                {
                    try
                    {
                        from.SendMessage("Writing Copy...");

                        object o = c.Invoke(null);

                        if (o != null && o is Item)
                        {
                            Item newItem = (Item)o;
                            Dupe.CopyProperties(newItem, m_Source);
                            m_Source.OnAfterDuped(newItem);
                            newItem.Parent = null;
                            pack.DropItem(newItem);

                            newItem.InvalidateProperties();
                            from.SendMessage("Done");
                            m_Pen.UsesRemaining -= 1;
                            m_Pen.InvalidateProperties();
                            target.Delete();
                        }
                    }
                    catch
                    {
                        from.SendMessage("Error, please notify a GM!");
                    }
                }
            }