using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

[Serializable]
public class MissionCondition
{
    [SerializeField]
    public MissionTypeEnum Type;

    [SerializeField]
    public List<RequiredSubject> RequiredElements = new List<RequiredSubject>();

    public MissionCondition(MissionTypeEnum type) { Type = type; }

    public bool IsConditionMeeted()
    {
        return RequiredElements.Where(element => element.CheckCondition()).Count() == RequiredElements.Count();
    }


    public MissionCondition Build()
    {
        switch(Type)
        {
            case MissionTypeEnum.Kill:
            {
                return new KillMissionCondition(this);
            }
            case MissionTypeEnum.Collect:
            {
                return new CollectMissionCondition(this);
            }
            default:
            {
                throw new Exception($"MissionCondition - Build - unrecognized type: {Type}");
            }
        }
    }
}