using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace pcd_g1
{
	public class EffectsManager
	{
		List<IEffect> effects = new List<IEffect>();

		public EffectsManager()
		{
			effects.Add(new NoEffect());
		}

		public IEffect AvailableEffect
		{
			get
			{
				return effects[0];
			}
		}

		public bool HasModal
		{
			get
			{
				return effects[0].IsModal;
			}
		}

		public void Update()
		{
			if (!AvailableEffect.IsSleeping)
			{
				if (AvailableEffect.Update())
				{
					Remove();
				}
			}
		}

		public void Draw(Bitmap inputImage, Graphics input, Graphics output, int inputWidth, int inputHeight, int outputWidth, int outputHeight)
		{
			if (AvailableEffect.IsVisible)
			{
				AvailableEffect.Draw(inputImage, input, output, inputWidth, inputHeight, outputWidth, outputHeight);
			}
		}

		public void Add(IEffect item)
		{
			effects.Insert(0, item);
		}

		public void Remove()
		{
			if (effects.Count > 1)
			{
				effects.RemoveAt(0);
			}
		}
	}

	class NoEffect : IEffect
	{
		public bool IsSleeping { get { return true; } }

		public bool IsModal { get { return false; } }

		public bool IsVisible { get { return true; } }

		public bool Update()
		{
			return false;
		}

		public void Draw(Bitmap inputImage, Graphics input, Graphics output, int inputWidth, int inputHeight, int outputWidth, int outputHeight)
		{
			if (inputWidth == outputWidth && inputHeight == outputHeight)
			{
				output.DrawImage(inputImage, 0, 0);
			}
			else
			{
				output.DrawImage(inputImage, new Rectangle(0, 0, outputWidth, outputHeight));
			}
		}

	}
}
