/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\engines\ML Peerless + misc areas\travesty\Keys\KeyTable.cs
Lines of code: 48
***********************************************************/


using System;
using Server;
using Server.Items;

namespace Server.Items
{

	public class KeyTable : Item
	{
	
		[Constructable]
		public KeyTable() : base(2869)
		{
		Name="Key Table";
		Movable=false;
		}
		
		public override void OnDoubleClick( Mobile from )
		{
		if(!from.InRange(this,1))return;
		
		int amt=0;
		
		amt = from.Backpack.GetAmount(typeof(DragonFlameKey));
		if(amt<1){MissingItemMsg(from,"Dragon Flame Key");	return;		}

		amt = from.Backpack.GetAmount(typeof(SerpentFangKey));
		if(amt<1){MissingItemMsg(from,"Serpent Fang Key");	return;		}

		amt = from.Backpack.GetAmount(typeof(TigerClawKey));
		if(amt<1){MissingItemMsg(from,"Tiger Claw Key");	return;		}

		//if we made it here, we have all the components, so we can consume them		
		
		from.Backpack.ConsumeTotal(typeof(DragonFlameKey),1 );
		from.Backpack.ConsumeTotal(typeof(SerpentFangKey),1 );
		from.Backpack.ConsumeTotal(typeof(TigerClawKey),1 );		
		
		//and finally, give key bag
		from.AddToBackpack(new peerlesskeybag(new TravestyKey(), 2,0,1));
		from.SendMessage("You are given a bag of keys which will summon the beast");
		}		
		
		void MissingItemMsg(Mobile from,string type)
		{
		from.SendMessage("You are missing {0}",type);
		}
		
		
		public KeyTable( Serial serial ) : base( serial )
		{
		}
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 );
		}
		
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
		}
	}
	
	

}