/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\events and scenarios\misc\christmas\PersonalGiftBox.cs
Lines of code: 156
***********************************************************/


using System;
using Server.Items;
using Server.Network;




namespace Server.Items
{
	[Flipable( 0x232A, 0x232B )]
	public class PersonalGiftBox : GiftBox
	{
		Mobile m_owner;
		
		
		[CommandProperty( AccessLevel.GameMaster )]
		public Mobile Owner
		{
			get{ return m_owner; }
			set{ m_owner = value; }
		}			
		
	
		[Constructable]
		public PersonalGiftBox() : this( null )
		{
		}

		[Constructable]
		public PersonalGiftBox( Mobile powner ) : base( Utility.Random( 0x232A, 2 ) )
		{
			Weight = 2.0;
			Hue = Utility.RandomDyedHue();
			Movable=false;
			Owner=powner;			
			
			//add stuff
			for(int i=0;i<10;i++)
			{
				if(0.12>Utility.RandomDouble() || i==1)
				{
					switch(Utility.Random(43))
					{
					case 0:AddItem(new Blight());  break;
					case 1:AddItem(new LuminescentFungi());  break;
					case 2:AddItem(new Corruption());  break;
					case 3:AddItem(new ParasiticPlant());  break;
					case 4:AddItem(new Muculent());  break;
					case 5:AddItem(new DiseasedBark());  break;
					case 6:AddItem(new BarkFragment());  break;
					case 7:AddItem(new PerfectEmerald());  break;
					case 8:AddItem(new DarkSapphire());  break;
					case 9:AddItem(new Turquoise());  break;
					case 10:AddItem(new EcruCitrine());  break;
					case 11:AddItem(new WhitePearl());  break;
					case 12:AddItem(new FireRuby());  break;
					case 13:AddItem(new BlueDiamond());  break;
					case 14:AddItem(new BrilliantAmber());  break;
					case 15:AddItem(new Scourge());  break;
					case 16:AddItem(new Putrefaction());  break;
					case 17:AddItem(new Taint());  break;			
					case 18: AddItem(new RunicHammer(CraftResource.DullCopper, 85 ));break;
					case 19: AddItem(new RunicHammer(CraftResource.ShadowIron, 80 ));break;
					case 20: AddItem(new RunicHammer(CraftResource.Copper, 75 ));break;
					case 21: AddItem(new RunicHammer(CraftResource.Bronze, 70 ));break;
					case 22: AddItem(new RunicHammer(CraftResource.Gold, 65 ));break;
					case 23: AddItem(new RunicHammer(CraftResource.Agapite, 60 ));break;
					case 24: AddItem(new RunicHammer(CraftResource.Verite, 55 ));break;
					case 25: AddItem(new RunicHammer(CraftResource.Valorite, 50 ));break;						
					case 26: AddItem(new RunicSewingKit( CraftResource.SpinedLeather,50));break;
					case 27: AddItem(new RunicSewingKit( CraftResource.HornedLeather,50));break;
					case 28: AddItem(new RunicSewingKit( CraftResource.BarbedLeather,50));break;
					case 29: AddItem(new RunicSaw( CraftResource.Oakwood,70));break;
					case 30: AddItem(new RunicSaw( CraftResource.Ashwood,70));break;
					case 31: AddItem(new RunicSaw( CraftResource.Yewwood,60));break;
					case 32: AddItem(new RunicSaw( CraftResource.Bloodwood,60));break;
					case 33: AddItem(new RunicSaw( CraftResource.Heartwood,50));break;
					case 34: AddItem(new RunicSaw( CraftResource.Frostwood,50));break;
					case 35: AddItem(new RunicTinkerKit(CraftResource.DullCopper, 25 ));break;
					case 36: AddItem(new RunicTinkerKit(CraftResource.ShadowIron, 25 ));break;
					case 37: AddItem(new RunicTinkerKit(CraftResource.Copper, 20 ));break;
					case 38: AddItem(new RunicTinkerKit(CraftResource.Bronze, 15 ));break;
					case 39: AddItem(new RunicTinkerKit(CraftResource.Gold, 15 ));break;
					case 40: AddItem(new RunicTinkerKit(CraftResource.Agapite, 10 ));break;
					case 41: AddItem(new RunicTinkerKit(CraftResource.Verite, 10 ));break;
					case 42: AddItem(new RunicTinkerKit(CraftResource.Valorite, 5 ));break;			
					}			
				}		
			}
		
		
			//other stuff
			for(int i=0;i<10;i++)
			{
				if(0.13>Utility.RandomDouble() || i==1)
				{
					switch(Utility.Random(11))
					{
					case 0:AddItem(new skilldeed(20+(20*Utility.Random(5))));  break;
					case 1:AddItem(new PetBondingDeed());  break;
					case 2:AddItem(new BagOfSending());  break;
					case 3:AddItem(new BankCheck(1000));  break;
					case 4:AddItem(new BankCheck(1000+(1000*Utility.Random(5))));  break;
					case 5:AddItem(new BankCheck(1000+(100*Utility.Random(100))));  break;
					case 6:AddItem(new AshBoard(10+(5*Utility.Random(5))));break;
					case 7:AddItem(new YewBoard(10+(5*Utility.Random(5))));break;
					case 8:AddItem(new BloodwoodBoard(10+(5*Utility.Random(5))));break;
					case 9:AddItem(new HeartwoodBoard(10+(5*Utility.Random(5))));break;
					case 10:AddItem(new FrostwoodBoard(10+(5*Utility.Random(5))));break;
					}			
				}		
			}


			
			//more other stuff
			for(int i=0;i<5;i++)
			{	
				AddItem(SurpriseStocking.RandomDecoration());
			}			
			
			
			
		}
		
		public override void OnDoubleClick( Mobile from )
		{
			if(from.AccessLevel>=AccessLevel.GameMaster)
			{
			base.OnDoubleClick(from);
			return;
			}
		
		
			if(Owner!=null && from!=Owner)
			{
			from.SendMessage("Only {0} can open this gift!",Owner.Name);
			return;
			}
		
		GiftBox newcont = new GiftBox();
		newcont.Hue=this.Hue;
		newcont.ItemID=this.ItemID;		
		
			for ( int i = Items.Count-1; i >= 0; --i )
			{
				if ( i < Items.Count )
				{
					Items[i].SetLastMoved();
					newcont.AddItem(Items[i]);
				}
			}
		
		
		
			if(from.Backpack!=null)
			{
			from.SendMessage("You take the gift and put it in your backpack.");
			from.Backpack.AddItem(newcont);
			}
			else
			{
			from.SendMessage("As your backpack does not exist, the gift remains on the ground");
			newcont.MoveToWorld(this.Location,this.Map);
			}
			
			newcont.OnDoubleClick( from );
		
		this.Delete();
		}

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

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

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

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

			int version = reader.ReadInt();
			m_owner=reader.ReadMobile();
		}
	}
}