using AGVNavigationCore.Models;

namespace AGVNavigationCore.PathFinding.Validation
{
    /// <summary>
    /// 도킹 검증 결과
    /// </summary>
    public class DockingValidationResult
    {
        /// <summary>
        /// 도킹 검증이 필요한지 여부 (목적지가 도킹 대상인 경우)
        /// </summary>
        public bool IsValidationRequired { get; set; }

        /// <summary>
        /// 도킹 검증 통과 여부
        /// </summary>
        public bool IsValid { get; set; }

        /// <summary>
        /// 목적지 노드 ID
        /// </summary>
        public string TargetNodeId { get; set; }

        /// <summary>
        /// 목적지 노드 타입
        /// </summary>
        public NodeType TargetNodeType { get; set; }

        /// <summary>
        /// 필요한 도킹 방향
        /// </summary>
        public AgvDirection RequiredDockingDirection { get; set; }

        /// <summary>
        /// 계산된 경로의 마지막 방향
        /// </summary>
        public AgvDirection CalculatedFinalDirection { get; set; }

        /// <summary>
        /// 검증 오류 메시지 (실패시)
        /// </summary>
        public string ValidationError { get; set; }

        /// <summary>
        /// 기본 생성자
        /// </summary>
        public DockingValidationResult()
        {
            IsValidationRequired = false;
            IsValid = true;
            TargetNodeId = string.Empty;
            RequiredDockingDirection = AgvDirection.Forward;
            CalculatedFinalDirection = AgvDirection.Forward;
            ValidationError = string.Empty;
        }

        /// <summary>
        /// 검증 불필요한 경우 생성
        /// </summary>
        public static DockingValidationResult CreateNotRequired()
        {
            return new DockingValidationResult
            {
                IsValidationRequired = false,
                IsValid = true
            };
        }

        /// <summary>
        /// 검증 성공 결과 생성
        /// </summary>
        public static DockingValidationResult CreateValid(string targetNodeId, NodeType nodeType, AgvDirection requiredDirection, AgvDirection calculatedDirection)
        {
            return new DockingValidationResult
            {
                IsValidationRequired = true,
                IsValid = true,
                TargetNodeId = targetNodeId,
                TargetNodeType = nodeType,
                RequiredDockingDirection = requiredDirection,
                CalculatedFinalDirection = calculatedDirection
            };
        }

        /// <summary>
        /// 검증 실패 결과 생성
        /// </summary>
        public static DockingValidationResult CreateInvalid(string targetNodeId, NodeType nodeType, AgvDirection requiredDirection, AgvDirection calculatedDirection, string error)
        {
            return new DockingValidationResult
            {
                IsValidationRequired = true,
                IsValid = false,
                TargetNodeId = targetNodeId,
                TargetNodeType = nodeType,
                RequiredDockingDirection = requiredDirection,
                CalculatedFinalDirection = calculatedDirection,
                ValidationError = error
            };
        }
    }
}