using System;
using System.Collections;
using Server.Network;
using Server.Items;
using Server.Targeting;
using Server.Mobiles;

namespace Server.Spells.Chivalry
{
	public class HolyLightCreatureSpell : PaladinSpell
	{
		private static SpellInfo m_Info = new SpellInfo(
				"Holy Light", "Augus Luminos",
				SpellCircle.Seventh, // 0 + 1.75 = 1.75s base cast delay
				-1,
				9002
			);

		public override double RequiredSkill{ get{ return 55.0; } }
		public override int RequiredMana{ get{ return 10; } }
		public override int RequiredTithing{ get{ return 10; } }
		public override int MantraNumber{ get{ return 1060724; } } // Augus Luminos
		public override bool BlocksMovement{ get{ return false; } }

		public HolyLightCreatureSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
		{
		}

		public override bool DelayedDamage{ get{ return false; } }

		public override void OnCast()
		{
			if ( CheckSequence() )
			{
				ArrayList targets = new ArrayList();

			if ((Caster is BaseCreature) && (((BaseCreature)Caster).Controlled || ((BaseCreature)Caster).Summoned ))  //different area of effect if summoned (from animate dead)
			{
					foreach ( Mobile targ in Caster.GetMobilesInRange( 2 ) )
					{
							if ( (Caster == targ || SpellHelper.ValidIndirectTarget( Caster, targ )) && Caster.CanBeHarmful( targ, false ) )
							targets.Add( targ );	
					}
			}
			else
			{

					foreach ( Mobile targ in Caster.GetMobilesInRange( 2 ) )
					{
							if ( targ == Caster )
							continue;

							if ( targ is BaseCreature && (((BaseCreature)targ).Controlled || ((BaseCreature)targ).Summoned ))
							targets.Add( targ );
							else if ( targ.Player )
							targets.Add( targ );
					}
					
			}

				Caster.PlaySound( 0x212 );
				Caster.PlaySound( 0x206 );

				Effects.SendLocationParticles( EffectItem.Create( Caster.Location, Caster.Map, EffectItem.DefaultDuration ), 0x376A, 1, 29, 0x47D, 2, 9962, 0 );
				Effects.SendLocationParticles( EffectItem.Create( new Point3D( Caster.X, Caster.Y, Caster.Z - 7 ), Caster.Map, EffectItem.DefaultDuration ), 0x37C4, 1, 29, 0x47D, 2, 9502, 0 );

				for ( int i = 0; i < targets.Count; ++i )
				{
					Mobile m = (Mobile)targets[i];

					int damage = ComputePowerValue( 20 ) + Utility.RandomMinMax( 0, 2 );

					
				//	if ( damage < 8 )
				//		damage = 8;
					

					Caster.DoHarmful( m );
// 					if (m is PlayerMobile)	((PlayerMobile)m).ReceiveDamageCap=10;//cap received damage at 7
					SpellHelper.Damage( this, m, damage, 0, 0, 0, 0, 100 );
				}
			}

			FinishSequence();
		}
	}
}