using Schema;
using VOID.Generic.Objects.Unit.Actions;
using VOID.Generic.Objects.Unit.Actions.Exceptions;

namespace VOID.Generic.AI.Schema.Actions
{
    [Description("Starts turn based fight")]
    [Category(SchemaCategory.CombatThisUnit)]
    public class UnitEndTurn : Action
    {
        public override NodeStatus Tick(object nodeMemory, SchemaAgent agent)
        {
            var unitAgent = (UnitObjectSchemaAgent)agent;
            if (!unitAgent.unit || !unitAgent.unit.basicState.turnManager || !unitAgent.unit.unitState.isSelfTurn)
                return NodeStatus.Failure;

            unitAgent.unit.OrderInstantly(new EndTurnAction(unitAgent.unit));

            return NodeStatus.Success;
        }
    }
}