using System.Collections.Generic;
using System.Linq;
using Machinations.FromFlash.machinations.model;

namespace Machinations.Status
{
    public class DelayStatus : IElementStatus
    {
        private readonly List<Resource> m_resources;
        private readonly Delay m_delay;
        private readonly int m_step;

        public DelayStatus(Delay delay, int step)
        {
            m_delay = delay;
            m_resources = delay.Resources.CloneResources();
            m_step = step;
        }

        public int Step { get { return m_step; } }

        public void Restore()
        {
            m_delay.Resources = m_resources.CloneResources();
            m_delay.OnChanged("Status restored");
        }

        public bool NeedNewStatus()
        {
            return !m_resources.SequenceEqual(m_delay.Resources) ;
        }
    }
}