context: using System;
  using System.Collections.Generic;
  using Server.ContextMenus;
  using Server.Engines.Craft;
  using Server.Gumps;
  using Server.Mobiles;
  using Server.Multis;
  using Server.Network;
  
  namespace Server.Items
  {
      public class Runebook : Item, ISecurable, ICraftable
  	{
  		public override bool IsArtifact { get { return true; } }
          public static readonly TimeSpan UseDelay = TimeSpan.FromSeconds(7.0);
  
          private BookQuality m_Quality;
  		
          [CommandProperty(AccessLevel.GameMaster)]		
          public BookQuality Quality
          {
              get
              {
                  return this.m_Quality;
              }
              set
              {
                  this.m_Quality = value;
                  this.InvalidateProperties();
              }
          }
  
          private List<RunebookEntry> m_Entries;
          private string m_Description;
          private int m_CurCharges, m_MaxCharges;
          private int m_DefaultIndex;
          private SecureLevel m_Level;
          private Mobile m_Crafter;
  		
          private DateTime m_NextUse;
  		
          private List<Mobile> m_Openers = new List<Mobile>();
  
          [CommandProperty(AccessLevel.GameMaster)]
          public DateTime NextUse
          {
              get
              {
                  return this.m_NextUse;
              }
              set
              {
                  this.m_NextUse = value;
              }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public Mobile Crafter
          {
              get
              {
                  return this.m_Crafter;
              }
              set
              {
                  this.m_Crafter = value;
                  this.InvalidateProperties();
              }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public SecureLevel Level
          {
              get
              {
                  return this.m_Level;
              }
              set
              {
                  this.m_Level = value;
              }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public string Description
          {
              get
              {
                  return this.m_Description;
              }
              set
              {
                  this.m_Description = value;
                  this.InvalidateProperties();
              }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public int CurCharges
          {
              get
              {
                  return this.m_CurCharges;
              }
              set
              {
                  this.m_CurCharges = value;
              }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public int MaxCharges
          {
              get
              {
                  return this.m_MaxCharges;
              }
              set
              {
                  this.m_MaxCharges = value;
              }
          }
  		
          public List<Mobile> Openers
          {
              get
              {
                  return this.m_Openers;
              }
              set
              {
                  this.m_Openers = value;
              }
          }
  
          public override int LabelNumber
          {
              get
              {
                  return 1041267;
              }
          }// runebook
  
          public virtual int MaxEntries { get { return 16; } }
  
          [Constructable]
          public Runebook(int maxCharges, int id = 0x22C5)
              : base(Core.AOS ? id : 0xEFA)
          {
              this.Weight = (Core.SE ? 1.0 : 3.0);
              this.LootType = LootType.Blessed;
              this.Hue = 0x461;
  
              this.Layer = (Core.AOS ? Layer.Invalid : Layer.OneHanded);
  
              this.m_Entries = new List<RunebookEntry>();
  
              this.m_MaxCharges = maxCharges;
  
              this.m_DefaultIndex = -1;
  
              this.m_Level = SecureLevel.CoOwners;
          }
  
          [Constructable]
          public Runebook()
              : this(Core.SE ? 12 : 6)
          {
          }
  
          public List<RunebookEntry> Entries
          {
              get
              {
                  return this.m_Entries;
              }
          }
  
          public int DefaultIndex
          {
              get { return m_DefaultIndex; }
              set { m_DefaultIndex = value; }
          }
  
          public RunebookEntry Default
          {
              get
              {
                  if (this.m_DefaultIndex >= 0 && this.m_DefaultIndex < this.m_Entries.Count)
                      return this.m_Entries[this.m_DefaultIndex];
  
                  return null;
              }
              set
              {
                  if (value == null)
                      this.m_DefaultIndex = -1;
                  else
                      this.m_DefaultIndex = this.m_Entries.IndexOf(value);
              }
          }
  
          public Runebook(Serial serial)
              : base(serial)
          {
          }
  
          public override bool AllowEquipedCast(Mobile from)
          {
              return true;
          }
  
          public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
          {
              base.GetContextMenuEntries(from, list);
              SetSecureLevelEntry.AddTo(from, this, list);
          }
  
          public override void Serialize(GenericWriter writer)
          {
              base.Serialize(writer);
  
              writer.Write((int)3);
  
              writer.Write((byte)this.m_Quality);	
  
              writer.Write(this.m_Crafter);
  
              writer.Write((int)this.m_Level);
  
              writer.Write(this.m_Entries.Count);
  
              for (int i = 0; i < this.m_Entries.Count; ++i)
                  this.m_Entries[i].Serialize(writer);
  
              writer.Write(this.m_Description);
              writer.Write(this.m_CurCharges);
              writer.Write(this.m_MaxCharges);
              writer.Write(this.m_DefaultIndex);
          }
  
          public override void Deserialize(GenericReader reader)
          {
              base.Deserialize(reader);
  
              this.LootType = LootType.Blessed;
  
              if (Core.SE && this.Weight == 3.0)
                  this.Weight = 1.0;
  
              int version = reader.ReadInt();
  
              switch ( version )
              {
                  case 3:
                      {
                          this.m_Quality = (BookQuality)reader.ReadByte();		
                          goto case 2;
                      }
                  case 2:
                      {
                          this.m_Crafter = reader.ReadMobile();
                          goto case 1;
                      }
                  case 1:
                      {
  
gt:                         this.m_Level = (SecureLevel)reader.ReadInt();