using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Managers;

namespace Employees
{
    public class Employee : BookedObject
    {
        protected EmployeeData _data;

        protected Sprite icon;

        public EmployeeData Data => _data;
        public Sprite Icon => icon;

        public void SetData(EmployeeData data, Sprite sprite)
        {
            _data = data;
            icon = sprite;
        }

        public override bool CanBook(DateTime start, DateTime endTime)
        {
            //to test!!!
            if(endTime.Subtract(start).TotalMinutes > _data.maxTimeOnEvent)
                return false;

            int weekCount = Calendar.Instance.WeekCountToTime(start);

            if (!bookedTimes.ContainsKey(weekCount))
                bookedTimes.Add(weekCount, new List<Offers.OfferTime>());

            if (!(bookedTimes[weekCount] == null || bookedTimes[weekCount].Count < _data.maxTimeOnEvent))
                return false;

            return base.CanBook(start, endTime);
        }

        public override void Book(DateTime start, DateTime end)
        {
            base.Book(start, end);

            _data.bookedTimes = bookedTimes;
        }
    }
}