/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\items\resources\Masterpiece Resources\Rare\MagesRest.cs
Lines of code: 90
***********************************************************/


using System;
using Server;
using Server.Targeting;

namespace Server.Items
{
	public class MagesRest : Item
	{
	
		[Constructable]
		public MagesRest() : this( 1 )
		{
		}
	
		[Constructable]
		public MagesRest( int amount ) : base( 3636 )
		{
			Hue = 1151;
			Name = "Scroll of Mage's Rest";
			Weight = 1.0;
			Stackable = true;
			Amount = amount;
		}

		public MagesRest( Serial serial ) : base( serial )
		{
		}
		
		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			list.Add(1060658,"Masterpiece Bonus \t{0}","+1 Faster Cast Recovery (20 Points)");
		}

		public override void OnDoubleClick( Mobile from )
		{
			if ( !IsChildOf( from.Backpack ) )
			{
				from.SendLocalizedMessage( 1060640 );
			}
			else
			{
				from.Target = new WeaponTarget( this );
				from.SendMessage( "Empower which weapon?" );
			}					
		}
		
		private class WeaponTarget : Target
		{
			private MagesRest m_MagesRest;

			public WeaponTarget( MagesRest powder ) : base( 2, false, TargetFlags.None )
			{
				m_MagesRest = powder;
			}
			
			protected override void OnTarget( Mobile from, object targeted ) 
			{ 
				if ( targeted is BaseWeapon )
				{
					BaseWeapon wp = (BaseWeapon)targeted;

					if ( wp.IsChildOf( from.Backpack ) && m_MagesRest.IsChildOf( from.Backpack ) && wp.MasterPiecePoints >= 20 )
					{
						if( wp.Attributes.CastRecovery < 3 )
						{
							from.FixedParticles( 0x37C4, 1, 8, 9916, 90, 3, EffectLayer.Head );
							from.FixedParticles( 0x37C4, 1, 8, 9502, 90, 4, EffectLayer.Head );
							from.PlaySound( 0x210 );
							from.FixedParticles( 0x373A, 1, 17, 9903, 90, 4, EffectLayer.Head );
							from.PlaySound( 0x244 );
							wp.Attributes.CastRecovery += 1;
							wp.MasterPiecePoints -= 20;
							from.SendMessage( "Your weapon gives you the power to recover from spells quicker" );
							m_MagesRest.Consume();
							
							if ( wp.Attributes.CastRecovery > 3)
								wp.Attributes.CastRecovery = 3;
						}
						else
							from.SendMessage( "That item has reached the maximum faster cast recovery allowed" );
					}
					else if (wp.MasterPiecePoints <= 19)
						from.SendMessage( "You either don't have enough points or the item is not a Masterpiece" );
				}
				else
					from.SendMessage( "That cannot be empowered" );
			}
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 );
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}
	}
}ÿ