using System;
using Server;
using Server.Mobiles;
using Server.Misc;
using Server.Network;

namespace Server.Items
{
	public class Moongate : Item
	{
		[Constructable]
		public Moongate() : base(0x0F6C)
		{
			Movable = false;
			Name = "moongate";
			Light = LightType.Circle300;
		}

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

		public override bool OnMoveOver( Mobile m )
		{
			Point3D loc = new Point3D( 2030, 1631, 8 );

			if ( Clock.GetMoonPhase( Map.Britannia, 3584, 2048 ) == MoonPhase.NewMoon )						// MOONGLOW
				loc = new Point3D( 3958, 2034, 2 );
			else if ( Clock.GetMoonPhase( Map.Britannia, 3584, 2048 ) == MoonPhase.WaxingCrescentMoon )		// BRITAIN
				loc = new Point3D( 2030, 1631, 8 );
			else if ( Clock.GetMoonPhase( Map.Britannia, 3584, 2048 ) == MoonPhase.FirstQuarter )			// JHELOM
				loc = new Point3D( 1173, 3251, 3 );
			else if ( Clock.GetMoonPhase( Map.Britannia, 3584, 2048 ) == MoonPhase.WaxingGibbous )			// YEW
				loc = new Point3D( 1322, 743, 2 );
			else if ( Clock.GetMoonPhase( Map.Britannia, 3584, 2048 ) == MoonPhase.FullMoon )				// MINOC
				loc = new Point3D( 3031, 462, 2 );
			else if ( Clock.GetMoonPhase( Map.Britannia, 3584, 2048 ) == MoonPhase.WaningGibbous )			// TRINSIC
				loc = new Point3D( 2065, 2828, 2 );
			else if ( Clock.GetMoonPhase( Map.Britannia, 3584, 2048 ) == MoonPhase.LastQuarter )			// SKARA BRAE
				loc = new Point3D( 790, 1949, 2 );
			else if ( Clock.GetMoonPhase( Map.Britannia, 3584, 2048 ) == MoonPhase.WaningCrescent )			// MAGINCIA
				loc = new Point3D( 3354, 2551, 12 );

			BaseCreature.TeleportPets( m, loc, Map.Britannia, false );
			m.MoveToWorld ( loc, Map.Britannia );
			m.PlaySound( 0x1FE );

			return false;
		}

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