/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\items\uoparrot\PetParrotStatue.cs
Lines of code: 176
***********************************************************/


using System;
using Server.Network;
using Server;
using Server.Targeting; 
using Server.Items;
using Server.Multis;
using Server.Mobiles;
using Server.Targets;
using System.Collections;
using Server.ContextMenus; 
using Server.Misc; 
using Server.Regions;

namespace Server.Items
{
	public class PetParrotStatue : Item
	{

		[Constructable]
		public PetParrotStatue() : base( 11675 )
		{
			Name = "A pet parrot statue";
			Hue = Utility.RandomList(41, 495, 567, 48, 131, 75, 1001); //Regular ML loot hues
			Weight = 0;
		}
		
		[Constructable]
		public PetParrotStatue(int hue) : base( 11675 )
		{
			Name = "A pet parrot statue";
			Hue = hue;		
			Weight = 0;
		}		
		
		private string GetHueName()
		{
			switch ( Hue )
			{
				case 41:   return "Red";
				case 495:  return "Blue";
				case 567:  return "Green";       			//Regular Hues
				case 48:   return "Orange";
				case 131:  return "Pink";
				case 75:   return "Light Green";
				case 1001: return "Grey";
				
				case 2419: return "Dull Copper";
				case 2406: return "Shadow Iron";
				case 2413: return "Copper";
				case 2418: return "Bronze";    			//Metal Hues
				case 2213: return "Gold";
				case 2425: return "Agapite";
				case 2207: return "Verite";
				case 2219: return "Valorite";
				
				case 3: return "Roulette Reward Blue";
				case 23: return "Roulette Reward Purple";
				case 38: return "Roulette Reward Red";
				case 43: return "Roulette Reward Orange";    			//Roulette Hues
				case 53: return "Roulette Reward Yellow";
				case 68: return "Roulette Reward Lime";
				case 88: return "Roulette Reward Cyan";
				case 667: return "Roulette Reward Swamp Green";
				
				case 1190: return "Oakwood";
				case 1191: return "Ashwood";
				case 1192: return "Yewwood";				//Wood Hues
				case 1193: return "Heartwood";
				case 1194: return "Bloodwood";    			
				case 1151: return "Frostwood";
				
				case 1281: return "Paragon Gold";
				case 1158: return "Violet Courage";
				case 1266: return "Invulnerability Blue";	//Tokuno Pigment Hues
				case 1150: return "Luna White";
				case 1167: return "Dryad Green";
				case 1109: return "Shadow Black";
				case 33:   return "Berserker Red";
				case 1420: return "Nox Green";
				case 1644: return "Rum Red";
				case 1359: return "Fire Orange";
				
				case 1169: return "Banana Yellow";
				case 1155: return "Dark Green";
				case 1164: return "Greenish Blue";		    //Reward Cloth + Misc Hues 
				case 1160: return "Azure";
				case 1162: return "Sea Green";
				case 2210: return "Forest Green";
				case 1324: return "Aquamarine";
				case 1157: return "Blood Red";
				case 1165: return "Sky Blue";
				case 1168: return "Rose Pink";
				case 2101: return "Spirit Silver";
				case 1166: return "Bubblegum Pink";
				case 1364: return "Insight Blue";
				case 1172: return "Reddish Blue";
				case 1156: return "Navy Blue";
				case 1175: return "Shadow Grey";
				case 1152: return "Frost Blue";
				case 1161: return "Blaze Phoenix";
				case 1154: return "Icy Water";
				case 1153: return "Snowy White";
				case 1177: return "Liquid Honey";
				case 0:    return "Cosmic Stripe";
				
			}	
		return "";
		}
		
		
		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			
			list.Add(1060658,"Color \t{0}", GetHueName());
		}
		
		public override void OnDoubleClick( Mobile from )
		{
			if ( !IsChildOf( from.Backpack ) )
			{
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			}
			else
			{
				from.Target = new TargetPerch( this );
				from.SendMessage( "Target the perch you wish your parrot to sit on" );
			}					
		}
		
		//public bool IsOwner( Mobile mob )
		//{
		//	BaseHouse house = BaseHouse.FindHouseAt( this );        

		//	return ( house != null && house.IsOwner( mob ) );
		//}
		
		private class TargetPerch : Target 
		{ 
			private PetParrotStatue m_PetParrotStatue;

			public TargetPerch( PetParrotStatue knife ) : base( 15, false, TargetFlags.None )
			{
				m_PetParrotStatue = knife;
			}
			
			protected override void OnTarget( Mobile from, object target ) 
			{ 
				if ( target is ParrotPerch) 
				{	
					ParrotPerch c = (ParrotPerch)target; 
					
					if (c.hasparrot)
					{
					from.SendMessage("This perch is already occupied!");
					return;
					}
					
					BaseHouse house = BaseHouse.FindHouseAt( from );

					//**Must exist a condition to check that the parrot placer owns the house**
					//if ( house != null && !house.IsOwner( from ) );
					//{
					//from.SendMessage("You must be the owner of this house to place the parrot");
					//return;
					//}
					
					if (c.IsLockedDown)
					{
						from.SendMessage("Welcome your new parrot! Don't forget to feed it wafers");
						Map map = c.Map;
			
						PetParrot parrot = new PetParrot();
						parrot.Hue = m_PetParrotStatue.Hue;
						int x = c.X;
						int y = c.Y;
						int z = c.Z + 9;
						parrot.ControlSlots=0; 
						parrot.Controlled = true;
						parrot.ControlMaster = from;
						parrot.MoveToWorld( new Point3D( x, y, z ), c.Map );
						parrot.ParrotPerch=c;
						c.hasparrot=true;
						m_PetParrotStatue.Delete();
					}
					else
					{
						from.SendMessage("The parrot perch must be locked down!");
					}
				}
				else
				{
					from.SendMessage("That is not a parrot perch");
				}
			}
		}

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