context: using System;
  using System.Collections;
  using Server.Targeting;
  using Server.Items;
  using Server.Engines.Harvest;
  using System.Collections.Generic;
  using Server.ContextMenus;
  using Server.Misc;
  using Server.Engines.Craft;
  
  namespace Server.Items
  {
      public class FishingPole : Item, ICraftable, IUsesRemaining, IResource, IQuality
      {
          private Type m_BaitType;
          private bool m_EnhancedBait;
          private HookType m_HookType;
          private int m_HookUses;
          private int m_BaitUses;
          private int m_OriginalHue;
  
          private Mobile m_Crafter;
          private ItemQuality m_Quality;
  
          private AosAttributes m_AosAttributes;
          private AosSkillBonuses m_AosSkillBonuses;
          private CraftResource m_Resource;
          private bool m_PlayerConstructed;
          
          private int m_UsesRemaining;
          private bool m_ShowUsesRemaining;
  
          private int m_LowerStatReq;
  
          [CommandProperty(AccessLevel.GameMaster)]
          public Type BaitType
          {
              get { return m_BaitType; }
              set
              {
                  m_BaitType = value;
  
                  if (m_BaitType == null)
                      m_EnhancedBait = false;
  
                  InvalidateProperties();
              }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public bool EnhancedBait
          {
              get { return m_EnhancedBait; }
              set { m_EnhancedBait = value; InvalidateProperties(); }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public HookType HookType
          {
              get { return m_HookType; }
              set
              {
                  m_HookType = value;
  
                  if (m_HookType == HookType.None)
                      Hue = m_OriginalHue;
  
                  InvalidateProperties();
              }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public int HookUses
          {
              get
              {
                  return m_HookUses;
              }
              set
              {
                  m_HookUses = value;
  
                  if (m_HookUses <= 0)
                  {
                      m_HookUses = 0;
                      HookType = HookType.None;
                  }
  
                  InvalidateProperties();
              }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public int BaitUses
          {
              get
              {
                  return m_BaitUses;
              }
              set
              {
                  m_BaitUses = value;
  
                  if (m_BaitUses <= 0)
                  {
                      m_BaitUses = 0;
                      BaitType = null;
                  }
  
                  InvalidateProperties();
              }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public AosAttributes Attributes
          {
              get { return m_AosAttributes; }
              set { }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public AosSkillBonuses SkillBonuses
          {
              get { return m_AosSkillBonuses; }
              set { }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public CraftResource Resource
          {
              get { return m_Resource; }
              set { m_Resource = value; Hue = CraftResources.GetHue(m_Resource); InvalidateProperties(); }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public bool PlayerConstructed
          {
              get { return m_PlayerConstructed; }
              set { m_PlayerConstructed = value; InvalidateProperties(); }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public int OriginalHue
          {
              get { return m_OriginalHue; }
              set { m_OriginalHue = value; }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public Mobile Crafter
          {
              get { return m_Crafter; }
              set { m_Crafter = value; InvalidateProperties(); }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public ItemQuality Quality
          {
              get { return m_Quality; }
              set 
              { 
                  UnscaleUses();
                  m_Quality = value;
                  ScaleUses();
              }
          }
          
          [CommandProperty(AccessLevel.GameMaster)]
          public int UsesRemaining
          {
              get { return m_UsesRemaining; }
              set { m_UsesRemaining = value; InvalidateProperties(); }
          }
          
          [CommandProperty(AccessLevel.GameMaster)]
          public bool ShowUsesRemaining
          {
              get { return m_ShowUsesRemaining; }
              set { m_ShowUsesRemaining = value; InvalidateProperties(); }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public int LowerStatReq
          {
              get { return m_LowerStatReq; }
              set { m_LowerStatReq = value; InvalidateProperties(); }
          }
  
          [Constructable]
          public FishingPole()
              : base(0x0DC0)
          {
              Layer = Layer.OneHanded;
              Weight = 8.0;
              Resource = CraftResource.RegularWood;
  
              m_BaitType = null;
              m_HookType = HookType.None;
  
              m_AosAttributes = new AosAttributes(this);
              m_AosSkillBonuses = new AosSkillBonuses(this);
              
              UsesRemaining = 150;
          }
  
          public void ScaleUses()
          {
              m_UsesRemaining = (m_UsesRemaining * GetUsesScalar()) / 100;
              InvalidateProperties();
          }
  
          public void UnscaleUses()
          {
              m_UsesRemaining = (m_UsesRemaining * 100) / GetUsesScalar();
          }
  
          public int GetUsesScalar()
          {
              if (m_Quality == ItemQuality.Exceptional)
                  return 200;
  
              return 100;
          }
  
          public int GetStrRequirement()
          {
              return AOS.Scale(10, 100 - m_LowerStatReq);
          }
  
          public void OnFishedHarvest(Mobile from, bool caughtAnything)
          {
              if (m_HookType != HookType.None)
              {
                  HookUses--;
  
                  if (m_HookType == HookType.None)
                      from.SendLocalizedMessage(1149854); //As the magic of the hook fades, it transforms to a normal fishhook.  The fishing pole returns to normal.
              }
  
              if (caughtAnything && m_BaitType != null)
                  BaitUses--;
          }
  
          public override bool AllowEquipedCast(Mobile from)
          {
              if (base.AllowEquipedCast(from))
                  return true;
  
              return (m_AosAttributes.SpellChanneling != 0);
          }
  
          public virtual int GetLuckBonus()
          {
              if (m_Resource == CraftResource.Heartwood)
                  return 0;
  
              CraftResourceInfo resInfo = CraftResources.GetInfo(m_Resource);
  
              if (resInfo == null)
                  return 0;
  
              CraftAttributeInfo attrInfo = resInfo.AttributeInfo;
  
              if (attrInfo == null)
                  return 0;
  
              return attrInfo.WeaponLuck;
          }
  
          public override void OnDoubleClick(Mobile from)
          {
              Fishing.System.BeginHarvesting(from, this);
          }
  
          public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
          {
              base.GetContextMenuEntries(from, list);
  
              BaseHarvestTool.AddContextMenuEntries(from, this, list, Fishing.System);
          }
  
          public override bool CanEquip(Mobile from)
          {
              if (from.Str < GetStrRequirement())
              {
                  from.SendLocalizedMessage(500213); // You are not strong enough to equip that.
                  return false;
              }
  
              return base.CanEquip(from);
          }
  
          public override bool OnEquip(Mobile from)
          {
              int strBonus = m_AosAttributes.BonusStr;
              int dexBonus = m_AosAttributes.BonusDex;
              int intBonus = m_AosAttributes.BonusInt;
  
              if ((strBonus != 0 || dexBonus != 0 || intBonus != 0))
              {
                  Mobile m = from;
  
                  string modName = this.Serial.ToString();
  
                  if (strBonus != 0)
                      m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
  
  
gt:                 if (dexBonus != 0)