/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\Items\Skill Items\Ninjitsu\Shuriken.cs
Lines of code: 76
***********************************************************/


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

namespace Server.Items
{
	[Flipable( 0x27AC, 0x27F7 )]
	public class Shuriken : Item, IUsesRemaining, ICraftable
	{
		private int m_UsesRemaining;

		private Poison m_Poison;

		[CommandProperty( AccessLevel.GameMaster )]
		public int UsesRemaining
		{
			get { return m_UsesRemaining; }
			set { m_UsesRemaining = value; InvalidateProperties(); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public Poison Poison
		{
			get{ return m_Poison; }
			set{ m_Poison = value; InvalidateProperties(); }
		}

		public bool ShowUsesRemaining{ get{ return true; } set{} }

		[Constructable]
		public Shuriken() : this( 1 )
		{
		}

		[Constructable]
		public Shuriken( int amount ) : base( 0x27AC )
		{
			Weight = 1.0;

			m_UsesRemaining = amount;
		}

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

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			
			if(m_UsesRemaining>0)
			{
			if ( m_Poison != null) list.Add( 1062412 + m_Poison.Level, m_UsesRemaining.ToString() );
			else list.Add( 1060584, m_UsesRemaining.ToString() ); // uses remaining: ~1_val~
			}
		}

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

			writer.Write( (int) 1 ); // version

			writer.Write( (int) m_UsesRemaining );

			Poison.Serialize( m_Poison, writer );
		}

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

			int version = reader.ReadInt();

			switch ( version )
			{
				case 1:
				case 0:
				{
					m_UsesRemaining = reader.ReadInt();

					m_Poison = Poison.Deserialize( reader );
					if(version<1)reader.ReadInt();

					break;
				}
			}
		}

		public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue )
		{
			if ( quality == 2 )
				UsesRemaining *= 2;

			return quality;
		}
	}
}