/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Jan-01-2012 10:09:15pm
Filepath: scripts\events and scenarios\Thanksgiving 2011\HornOfPlenty.cs
Lines of code: 81

Description: 

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


using System;
using Server;
using Server.Multis;
using Server.Items;
using Server.Mobiles;
using System.Collections;
using Server.Network;
using Server.Spells;
using Server.Targeting;
using Server.Network;
using System.Collections.Generic;

namespace Server.Items
{

	[FlipableAttribute( 18080, 18081 )] 
	public class HornOfPlenty : Item
	{
	
		public bool UseDelay = false;  
		 
		[Constructable]
		public HornOfPlenty() : base( 18080 )
		{		
			Name = "Horn Of Plenty"; 
			Weight = 2.0;
		}
		
		public bool IsOwner( Mobile mob )
		{
			BaseHouse house = BaseHouse.FindHouseAt( this );

			return ( house != null && house.IsOwner( mob ) );
		}

		public override void OnDoubleClick( Mobile from )
		{
			if ( !this.IsLockedDown )
				from.SendLocalizedMessage( 502693 ); // Remember, this only works when locked down.
			else if (UseDelay)
			{
				from.SendMessage( "You must wait before you can retrieve another item" );
			}
			else if (!from.InRange( this, 1 ))
			{
				from.SendMessage( "You are too far away" );
			}
			else if (!UseDelay && from.InRange( this, 1 ) && from.Alive && from != null)
			{
				UseDelay= true;
			
				from.LocalOverheadMessage( MessageType.Regular, 0x3F, true, "* You grab an item from the horn of plenty *" );
			
			
			
				Item gift = new Apple();	
				
				switch ( Utility.Random( 10 ))
				{                                   
					case 0: gift = new Apple(); break;   
					case 1: gift = new Onion(); break;	
					case 2: gift = new Ham(); break;   
					case 3: gift = new CookedBird(); break;	
					case 4: gift = new Turnip(); break;   
					case 5: gift = new Pumpkin(); break;	
					case 6: gift = new Carrot(); break;   
					case 7: gift = new Squash(); break;	
					case 8: gift = new FrenchBread(); break;   
					case 9: gift = new EarOfCorn(); break;	
				}
					
				from.GiveItem(gift);					
			
				Timer.DelayCall( TimeSpan.FromMinutes( 5.0 ), new TimerCallback( ResetDelay ) );
			}
		}
		
		public void ResetDelay( )
		{
			UseDelay = false; 
		}

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