/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Jan-01-2012 10:09:14pm
Filepath: scripts\events and scenarios\Halloween2011\Quests\Quest Items\ShrinkingStaff.cs
Lines of code: 145

Description: 

***********************************************************/


using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Network;
using System.Collections;
using Server.Targeting;

namespace Server.Items
{
	public class ShrinkingStaff : Item
	{
		[Constructable]
		public ShrinkingStaff() : base(3568)
		{
			Name = "a shrinking staff";
			Hue = 2071;
		}
		
		public override void GetProperties( ObjectPropertyList list)
		{
			base.GetProperties( list );
			list.Add( 1060658,"Timeline \t" + "To be deleted after Halloween Event");
		}

		public ShrinkingStaff( Serial serial ) : base( serial )
		{
		}
		
		public override void OnDoubleClick( Mobile from )
		{
			if ( !IsChildOf( from.Backpack ) )
			{
				from.SendLocalizedMessage( 1042010 ); // You must have the object in your backpack to use it.
			}
			else
			{
				from.SendMessage("Target the frog you wish to shrink" );
				from.Target = new FrogTarget( from, this );
			}
		}

		/*private class InternalTimer : Timer
		{
			private Mobile m_From;

			public InternalTimer( Mobile from ) : base( TimeSpan.FromSeconds( 5.0 ) )
			{
				m_From = from;
			}

			protected override void OnTick()
			{
				m_From.EndAction( typeof( AnniversaryCake ) );
			}
		}*/

		private class FrogTarget : Target
		{
			private Mobile m_User;
			private Item m_Staff;

			public FrogTarget( Mobile user, Item staff ) : base ( 10, false, TargetFlags.None )
			{
				m_User = user;
				m_Staff = staff;
			}

			protected override void OnTarget( Mobile from, object target )
			{
				if ( target == from )
				{
					from.SendMessage( "You really don't feel like shrinking yourself today" ); 
				}
				else if (target is HalloweenGreenFrog || target is HalloweenOrangeFrog || target is HalloweenBlackFrog || target is HalloweenBlueFrog || target is HalloweenRedFrog)
				{
					Mobile targ = (Mobile) target;
				
					if (targ.InLOS( from ) && from.InRange( targ, 1 ) && from.Alive && !from.Blessed)  {
						if (targ is HalloweenGreenFrog) {					
							Item greenfrog = from.Backpack.FindItemByType(typeof(ShrunkGreenFrog));
					
							if (greenfrog != null)
							{
								from.SendMessage("This frog has already been captured.");	
							}
							else {
								from.GiveItem(new ShrunkGreenFrog());
								targ.Delete();								
							}
						}
						else if (targ is HalloweenOrangeFrog) {					
							Item orangefrog = from.Backpack.FindItemByType(typeof(ShrunkOrangeFrog));
					
							if (orangefrog != null)
							{
								from.SendMessage("This frog has already been captured.");	
							}
							else {
								from.GiveItem(new ShrunkOrangeFrog());
								targ.Delete();								
							}
						}
						else if (targ is HalloweenBlackFrog) {					
							Item blackfrog = from.Backpack.FindItemByType(typeof(ShrunkBlackFrog));
					
							if (blackfrog != null)
							{
								from.SendMessage("This frog has already been captured.");	
							}
							else {
								from.GiveItem(new ShrunkBlackFrog());
								targ.Delete();								
							}
						}
						else if (targ is HalloweenBlueFrog) {					
							Item bluefrog = from.Backpack.FindItemByType(typeof(ShrunkBlueFrog));
					
							if (bluefrog != null)
							{
								from.SendMessage("This frog has already been captured.");	
							}
							else {
								from.GiveItem(new ShrunkBlueFrog());
								targ.Delete();								
							}
						}
						else if (targ is HalloweenRedFrog) {					
							Item redfrog = from.Backpack.FindItemByType(typeof(ShrunkRedFrog));
					
							if (redfrog != null)
							{
								from.SendMessage("This frog has already been captured.");	
							}
							else {
								from.GiveItem(new ShrunkRedFrog());
								targ.Delete();								
							}
						}
						else {
							from.SendMessage("You decide not to capture this frog as it's not one of the colors requested to be captured" );
						}
					}
					else if (!from.Alive || from.Blessed) {
						from.SendMessage("You cannot shrink the frog in your current state" );
					}
					else if (!targ.InLOS( from )) {
						from.SendMessage("You do not have a clear line of sight to shrink the frog" );
					}
					else if (!targ.InLOS( from )) {
						from.SendMessage("You need to be closer to shrink the frog" );
					}
					else {
						from.SendMessage("Ensure you are alive, in line of sight and next to the frog in order to shrink it" );
					}
				}
				else {
					from.SendMessage("This item seems to only work on special types of frog" );
				}
			}
		}

		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();
		}
	}
}