using System.Collections.Generic;
using Schema;
using VOID.Generic.Dict;
using VOID.Generic.Objects.Unit;
using VOID.Generic.Turn;

namespace VOID.Generic.AI.Schema.Actions
{
    [Description("Starts turn based fight")]
    [Category(SchemaCategory.RealtimeThisUnit)]
    public class UnitStartFight : Action
    {
        public override NodeStatus Tick(object nodeMemory, SchemaAgent agent)
        {
            var unitAgent = (UnitObjectSchemaAgent)agent;
            var hostileUnits = unitAgent.unit.unitSenses.GetUnitsInSightByAttitude(AttitudeType.Hostile); 
            if (hostileUnits.Count == 0) return NodeStatus.Failure;
            var units = new List<UnitObject>();
            units.Add(unitAgent.unit);
            units.AddRange(hostileUnits);
            TurnManager.BuildGameObject(units);
            return NodeStatus.Success;
        }
    }
}