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


using System;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;


namespace Server.Items
{
	public class basehouseslotdeed : Item
	{	
		public virtual int Slots { get {return 2;} }
		
		private Mobile m_attachedto;
		
		[CommandProperty( AccessLevel.GameMaster )]
		public Mobile AttachedTo
		{
			get { return m_attachedto; }
			set { m_attachedto=value; Modify();}
		}	

		public override string DefaultName
		{
			get { return "Extra House Slot Deed"; }
		}
		
		
		public bool ValidateUser(PlayerMobile user)
		{			
			if(AttachedTo==null)
			{
				user.SendMessage("The owner of this deed no longer exists.  Deleting");
				this.Delete();
				return false;
			}
			if(AttachedTo!=user)
			{
				user.SendMessage("Only {0} may use this deed!",AttachedTo.Name);
				return false;
			}
			if(user.HousesMax>=Slots)
			{
				user.SendMessage("You already have {0} slots!  You may choose another reward.",user.HousesMax);
				Server.Engines.VeteranRewards.RewardSystem.GiveRewardPoint( user );
				Delete();
				return false;
			}
						
			return true;			
		}
		
	
		public override void OnDoubleClick( Mobile from )
		{
			if(from is PlayerMobile && ValidateUser((PlayerMobile)from))
			{
			PlayerMobile pm = from as PlayerMobile;
			
			pm.HousesMax=Slots;
			
			pm.SendMessage("You now have {0} house slots!  You have {1} slot(s) available.",pm.HousesMax,(pm.HousesMax-pm.HousesCur));
			this.Delete();
			}	
		}
		
		public basehouseslotdeed() :  base(0x14F0)
		{
		Movable=false;
		}
		
		
		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );

			list.Add(1060658,"Increases account house slots up to \t{0}", String.Format("{0} Houses",Slots.ToString()));
		}		
	
		public basehouseslotdeed( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 ); // version
			writer.Write((Mobile)m_attachedto);
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
			m_attachedto = reader.ReadMobile();
			
			if(m_attachedto==null)Delete();
		}	
	}
	
	
	public class houseslotdeed2 : basehouseslotdeed
	{	
		public override int Slots { get {return 2;} }
	
		[Constructable]
		public houseslotdeed2()
		{
		Movable=false;
		}
		
		public houseslotdeed2( 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 class houseslotdeed3 : basehouseslotdeed
	{	
		public override int Slots { get {return 3;} }
	
		[Constructable]
		public houseslotdeed3()
		{
		Movable=false;
		}
		
		public houseslotdeed3( 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();
		}		
	
	}	
	
}





