/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Aug-08-2011 09:29:13pm
Filepath: scripts\Items\artifacts\leviathan\OracleOfPoseidon.cs
Lines of code: 94

Description: 

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


using System;
using Server.Network;
using Server;
using Server.Targeting; 
using Server.Items;
using Server.Mobiles;
using Server.Targets;
using Server.Spells.Fourth;

namespace Server.Items
{
	
	public class OracleOfPoseidon : Item, IUsesRemaining
	{	
		private int m_UsesRemaining;
		public bool m_ShowUsesRemaining{ get{ return true; } set{} }

		[CommandProperty( AccessLevel.GameMaster )]
		public int UsesRemaining
		{
			get { return m_UsesRemaining; }
			set { m_UsesRemaining = value; InvalidateProperties(); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool ShowUsesRemaining
		{
			get { return m_ShowUsesRemaining; }
			set { m_ShowUsesRemaining = value; InvalidateProperties(); }
		}

		[Constructable]
		public OracleOfPoseidon() : this( 10 )
		{
		}

		[Constructable]
		public OracleOfPoseidon( int uses ) : base( 3571 )
		{
			Weight = 1.0;
			Hue = 88;
			UsesRemaining = uses;
			Name = "Oracle of Poseidon";
		}

		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 if(!RecallSpell.CheckTravel(null,from.Location,from.Map, from,false))
			{
			}			
			else if(from.Region.IsPartOf( "submersia" ) )
			{
				from.SendMessage("You are already in Submersia!");
			}
			else
			{
				if (this.UsesRemaining > 0)
				{
					this.UsesRemaining--;
					from.SendMessage( "You teleport to a strange land" );
					from.MoveToWorld( new Point3D( 7033, 886, 2 ), Map.Trammel ); 
					Effects.SendLocationEffect( from.Location, from.Map, 0x3709, 30, 10, 286, 0 );
				}
				else
					from.SendMessage("You will need a water gem to recharge this item");
			}					
		}
		
		public OracleOfPoseidon( Serial serial ) : base( serial )
		{
		}
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
			
			writer.Write( (bool) m_ShowUsesRemaining );

			writer.Write( (int) m_UsesRemaining );
			
		}

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

			int version = reader.ReadInt();

			m_ShowUsesRemaining = reader.ReadBool();
			m_UsesRemaining = reader.ReadInt();
			if ( m_UsesRemaining < 1 )
				m_UsesRemaining = 50;
		}
		
		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );

			list.Add( 1060584, m_UsesRemaining.ToString() ); // uses remaining: ~1_val~
		}
		
		
		public override void OnAfterLoad()
		{		
			Misc.ObjectConverter.ConvertItem(this,new ColdHeart());
		}			
	}
}