context: using System;
  using Server;
  using Server.Gumps;
  using Server.Network;
  
  namespace Server.Items
  {
  	public class PowerScroll : Item
  	{
  		private SkillName m_Skill;
  		private double m_Value;
  
  		private static SkillName[] m_Skills = new SkillName[]
  			{
  				SkillName.Blacksmith,
  				SkillName.Tailoring,
  				SkillName.Swords,
  				SkillName.Fencing,
  				SkillName.Macing,
  				SkillName.Archery,
  				SkillName.Wrestling,
  				SkillName.Parry,
  				SkillName.Tactics,
  				SkillName.Anatomy,
  				SkillName.Healing,
  				SkillName.Magery,
  				SkillName.Meditation,
  				SkillName.EvalInt,
  				SkillName.MagicResist,
  				SkillName.AnimalTaming,
  				SkillName.AnimalLore,
  				SkillName.Veterinary,
  				SkillName.Musicianship,
  				SkillName.Provocation,
  				SkillName.Discordance,
  				SkillName.Peacemaking
  			};
  
  		private static SkillName[] m_AOSSkills = new SkillName[]
  			{
  				SkillName.Blacksmith,
  				SkillName.Tailoring,
  				SkillName.Swords,
  				SkillName.Fencing,
  				SkillName.Macing,
  				SkillName.Archery,
  				SkillName.Wrestling,
  				SkillName.Parry,
  				SkillName.Tactics,
  				SkillName.Anatomy,
  				SkillName.Healing,
  				SkillName.Magery,
  				SkillName.Meditation,
  				SkillName.EvalInt,
  				SkillName.MagicResist,
  				SkillName.AnimalTaming,
  				SkillName.AnimalLore,
  				SkillName.Veterinary,
  				SkillName.Musicianship,
  				SkillName.Provocation,
  				SkillName.Discordance,
  				SkillName.Peacemaking,
  				SkillName.Chivalry,
  				SkillName.Focus,
  				SkillName.Necromancy,
  				SkillName.Stealing,
  				SkillName.Stealth,
  				SkillName.SpiritSpeak
  			};
  
  		private static SkillName[] m_SESkills = new SkillName[]
  			{
  				SkillName.Blacksmith,
  				SkillName.Tailoring,
  				SkillName.Swords,
  				SkillName.Fencing,
  				SkillName.Macing,
  				SkillName.Archery,
  				SkillName.Wrestling,
  				SkillName.Parry,
  				SkillName.Tactics,
  				SkillName.Anatomy,
  				SkillName.Healing,
  				SkillName.Magery,
  				SkillName.Meditation,
  				SkillName.EvalInt,
  				SkillName.MagicResist,
  				SkillName.AnimalTaming,
  				SkillName.AnimalLore,
  				SkillName.Veterinary,
  				SkillName.Musicianship,
  				SkillName.Provocation,
  				SkillName.Discordance,
  				SkillName.Peacemaking,
  				SkillName.Chivalry,
  				SkillName.Focus,
  				SkillName.Necromancy,
  				SkillName.Stealing,
  				SkillName.Stealth,
  				SkillName.SpiritSpeak,
  				SkillName.Ninjitsu,
  				SkillName.Bushido
  			};
  
  		public static SkillName[] Skills{ get{ return ( Core.SE ? m_SESkills : Core.AOS ? m_AOSSkills : m_Skills ); } }
  
  		public static PowerScroll CreateRandom( int min, int max )
  		{
  			min /= 5;
  			max /= 5;
  
  			SkillName[] skills = PowerScroll.Skills;
  
  			return new PowerScroll( skills[Utility.Random( skills.Length )], 100 + (Utility.RandomMinMax( min, max ) * 5));
  		}
  
  		public static PowerScroll CreateRandomNoCraft( int min, int max )
  		{
  			min /= 5;
  			max /= 5;
  
  			SkillName[] skills = PowerScroll.Skills;
  			SkillName skillName;
  
  			do
  			{
  				skillName = skills[Utility.Random( skills.Length )];
  			} while ( skillName == SkillName.Blacksmith || skillName == SkillName.Tailoring );
  
  			return new PowerScroll( skillName, 100 + (Utility.RandomMinMax( min, max ) * 5));
  		}
  
  		[Constructable]
  		public PowerScroll( SkillName skill, double value ) : base( 0x14F0 )
  		{
  			base.Hue = 0x481;
  			base.Weight = 1.0;
  
  			LootType = LootType.Cursed;
  
  			m_Skill = skill;
  			m_Value = value;
  		}
  
  		public PowerScroll( Serial serial ) : base( serial )
  		{
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public SkillName Skill
  		{
  			get
  			{
  				return m_Skill;
  			}
  			set
  			{
  				m_Skill = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public double Value
  		{
  			get
  			{
  				return m_Value;
  			}
  			set
  			{
  				m_Value = value;
  			}
  		}
  
  		private string GetNameLocalized()
  		{
  			return String.Concat( "#", (1044060 + (int)m_Skill).ToString() );
  		}
  
  		private string GetName()
  		{
  			int index = (int)m_Skill;
  			SkillInfo[] table = SkillInfo.Table;
  
  			if ( index >= 0 && index < table.Length )
  				return table[index].Name.ToLower();
  			else
  				return "???";
  		}
  
  		public override void AddNameProperty(ObjectPropertyList list)
  		{
  			if ( m_Value == 105.0 )
  				list.Add( 1049639, GetNameLocalized() ); // a wonderous scroll of ~1_type~ (105 Skill)
  			else if ( m_Value == 110.0 )
  				list.Add( 1049640, GetNameLocalized() ); // an exalted scroll of ~1_type~ (110 Skill)
  			else if ( m_Value == 115.0 )
  				list.Add( 1049641, GetNameLocalized() ); // a mythical scroll of ~1_type~ (115 Skill)
  			else if ( m_Value == 120.0 )
  				list.Add( 1049642, GetNameLocalized() ); // a legendary scroll of ~1_type~ (120 Skill)
  			else
  				list.Add( "a power scroll of {0} ({1} Skill)", GetName(), m_Value );
  		}
  
  		public override void OnSingleClick( Mobile from )
  		{
  			if ( m_Value == 105.0 )
  				base.LabelTo( from, 1049639, GetNameLocalized() ); // a wonderous scroll of ~1_type~ (105 Skill)
  			else if ( m_Value == 110.0 )
  				base.LabelTo( from, 1049640, GetNameLocalized() ); // an exalted scroll of ~1_type~ (110 Skill)
  			else if ( m_Value == 115.0 )
  				base.LabelTo( from, 1049641, GetNameLocalized() ); // a mythical scroll of ~1_type~ (115 Skill)
  			else if ( m_Value == 120.0 )
  				base.LabelTo( from, 1049642, GetNameLocalized() ); // a legendary scroll of ~1_type~ (120 Skill)
  			else
  				base.LabelTo( from, "a power scroll of {0} ({1} Skill)", GetName(), m_Value );
  		}
  
  		public void Use( Mobile from, bool firstStage )
  		{
  			if ( Deleted )
  				return;
  
  			if ( IsChildOf( from.Backpack ) )
  			{
  
gt: 				Skill skill = from.Skills[m_Skill];