using EscapeRoomEngine.Engine.Runtime.Measurements;
using EscapeRoomEngine.Engine.Runtime.Modules;
using EscapeRoomEngine.Engine.Runtime.Utilities;
using NaughtyAttributes;
using UnityEngine;
using UnityEngine.UI;

namespace EscapeRoomEngine.Engine.Runtime.UI
{
    /// <summary>
    /// An entry in the <see cref="PuzzlePlan"/> UI component that displays the name and estimated time for a puzzle.
    /// </summary>
    public class PuzzlePlanEntry : MonoBehaviour
    {
        [BoxGroup("Internal")] [Required] [SerializeField]
        private Text puzzleName, estimatedTime;

        public Vector2 Position
        {
            set
            {
                puzzleName.rectTransform.anchoredPosition = value;
            }
        }
        public PuzzleModuleDescription Puzzle
        {
            set
            {
                puzzleName.text = value.puzzleName;
                estimatedTime.text = $"Time Estimate: {Measure.EstimateTime(value).ToTimeSpan():mm':'ss}";
            }
        }
    }
}