context: using System;
  using Server.Targeting;
  
  namespace Server.Items
  {
      public interface ICommodity /* added IsDeedable prop so expansion-based deedables can determine true/false */
      {
          int DescriptionNumber { get; }
          bool IsDeedable { get; }
      }
  
      public class CommodityDeed : Item
      {
          private Item m_Commodity;
  
          [CommandProperty(AccessLevel.GameMaster)]
          public Item Commodity { get { return m_Commodity; } }
  
          public CommodityDeed(Item commodity)
              : base(0x14F0)
          {
              Weight = 1.0;
              Hue = 0x47;
  
              m_Commodity = commodity;
  
              LootType = LootType.Blessed;
          }
  
          [Constructable]
          public CommodityDeed()
              : this(null)
          {
          }
  
          public CommodityDeed(Serial serial)
              : base(serial)
          {
          }
  
          public override int LabelNumber
          {
              get
              {
                  return m_Commodity == null ? 1047016 : 1047017;
              }
          }
          public bool SetCommodity(Item item)
          {
              InvalidateProperties();
  
              if (m_Commodity == null && item is ICommodity && ((ICommodity)item).IsDeedable)
              {
                  m_Commodity = item;
                  m_Commodity.Internalize();
                  InvalidateProperties();
  
                  return true;
              }
              else
              {
                  return false;
              }
          }
  
          public override void Serialize(GenericWriter writer)
          {
              base.Serialize(writer);
  
              writer.Write((int)1); // version
  
              writer.Write(m_Commodity);
          }
  
          public override void Deserialize(GenericReader reader)
          {
              base.Deserialize(reader);
  
              int version = reader.ReadInt();
  
              m_Commodity = reader.ReadItem();
  
              switch ( version )
              {
                  case 0:
                      {
                          if (m_Commodity != null)
                          {
                              Hue = 0x592;
                          }
                          break;
                      }
              }
          }
  
          public override void OnDelete()
          {
              if (m_Commodity != null)
                  m_Commodity.Delete();
  
              base.OnDelete();
          }
  
          public override void GetProperties(ObjectPropertyList list)
          {
              base.GetProperties(list);
  
              if (m_Commodity != null)
              {
                  string args;
  
                  if (m_Commodity.Name == null)
                      args = String.Format("#{0}\t{1}", (m_Commodity is ICommodity) ? ((ICommodity)m_Commodity).DescriptionNumber : m_Commodity.LabelNumber, m_Commodity.Amount);
                  else
                      args = String.Format("{0}\t{1}", m_Commodity.Name, m_Commodity.Amount);
  
                  list.Add(1060658, args); // ~1_val~: ~2_val~
              }
              else
              {
                  list.Add(1060748); // unfilled
              }
          }
  
          public override void OnSingleClick(Mobile from)
          {
              base.OnSingleClick(from);
  
              if (m_Commodity != null)
              {
                  string args;
  
                  if (m_Commodity.Name == null)
                      args = String.Format("#{0}\t{1}", (m_Commodity is ICommodity) ? ((ICommodity)m_Commodity).DescriptionNumber : m_Commodity.LabelNumber, m_Commodity.Amount);
                  else
                      args = String.Format("{0}\t{1}", m_Commodity.Name, m_Commodity.Amount);
  
                  LabelTo(from, 1060658, args); // ~1_val~: ~2_val~
              }
          }
  
          public override void OnDoubleClick(Mobile from)
          {
              int number;
  
              BankBox box = from.FindBankNoCreate();
              CommodityDeedBox cox = CommodityDeedBox.Find(this);
  			
              // Veteran Rewards mods
              if (m_Commodity != null)
              {
                  if (box != null && IsChildOf(box))
                  {
                      number = 1047031; // The commodity has been redeemed.
  
                      box.DropItem(m_Commodity);
  
                      m_Commodity = null;
                      Delete();
                  }
                  else if (cox != null)
                  {
                      if (cox.IsSecure)
                      {
                          number = 1047031; // The commodity has been redeemed.
  
                          cox.DropItem(m_Commodity);
  
                          m_Commodity = null;
                          Delete();
                      }
                      else
                          number = 1080525; // The commodity deed box must be secured before you can use it.
                  }
                  else
                  {
                      if (Core.ML)
                      {
                          number = 1080526; // That must be in your bank box or commodity deed box to use it.
                      }
                      else
                      {
                          number = 1047024; // To claim the resources ....
                      }
                  }
              }
              else if (cox != null && !cox.IsSecure)
              {
                  number = 1080525; // The commodity deed box must be secured before you can use it.
              }
              else if ((box == null || !IsChildOf(box)) && cox == null)
              {
                  if (Core.ML)
                  {
                      number = 1080526; // That must be in your bank box or commodity deed box to use it.
                  }
                  else
                  {
                      number = 1047026; // That must be in your bank box to use it.
                  }
              }
              else
              {
                  number = 1047029; // Target the commodity to fill this deed with.
  
  
gt:                 from.Target = new InternalTarget(this);