using System;
using Server;
using Server.Engines.Craft;

namespace Server.Items
{
	public class MortarPestle : BaseTool
	{
		public override CraftSystem CraftSystem{ get{ return DefAlchemy.CraftSystem; } }

		[Constructable]
		public MortarPestle() : base( 0xE9B )
		{
			Weight = 1.0;
		}

		[Constructable]
		public MortarPestle( int uses ) : base( uses, 0xE9B )
		{
			Weight = 1.0;
		}

		public MortarPestle( Serial serial ) : base( serial )
		{
		}

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

			writer.Write( (int) 0 ); // version
		}

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

			int version = reader.ReadInt();
		}

		public override bool OnDragDrop( Mobile from, Item dropped )
		{          		
			Container pack = from.Backpack;
			int mod = 0;

			if ( dropped is Amber ){ mod = dropped.Amount * 1; }
			else if ( dropped is Amethyst ){ mod = dropped.Amount * 3; }
			else if ( dropped is Citrine ){ mod = dropped.Amount * 1; }
			else if ( dropped is Diamond ){ mod = dropped.Amount * 5; }
			else if ( dropped is Emerald ){ mod = dropped.Amount * 3; }
			else if ( dropped is Ruby ){ mod = dropped.Amount * 2; }
			else if ( dropped is Sapphire ){ mod = dropped.Amount * 3; }
			else if ( dropped is StarSapphire ){ mod = dropped.Amount * 4; }
			else if ( dropped is Tourmaline ){ mod = dropped.Amount * 2; }

			if ( from != null && mod > 0 )
			{
				if ( dropped.Amount > 100 )
				{
					from.SendMessage( "You can only grind up 100 gems at a time!" );
					from.AddToBackpack( dropped );
				}
				else
				{
					dropped.Delete();
					from.PlaySound( 0x242 );
					from.SendMessage( "You grind up the gems into a fine powder" );
					from.AddToBackpack( new CrystalPowder(mod) );
				}
			}
			return false;
		}
	}
}