using UnityEngine;

namespace MaskShop
{
    /// <summary>
    /// Type of QTE minigame
    /// </summary>
    public enum QTEType
    {
        TimingBar,        // Press when bar/pointer is in zone
        ReactionTime,     // Press when prompt appears
        ButtonMashing     // Press button rapidly (future expansion)
    }

    /// <summary>
    /// Result quality of a QTE
    /// </summary>
    public enum QTEResult
    {
        Perfect,   // Hit the perfect zone
        Good,      // Hit the good zone
        Bad        // Missed or hit outside zones
    }

    /// <summary>
    /// Configuration for QTE minigames
    /// </summary>
    [CreateAssetMenu(fileName = "New QTE Config", menuName = "Mask Shop/QTE Configuration")]
    public class QTEConfiguration : ScriptableObject
    {
        [Header("Timing Bar Settings")]
        [SerializeField, Range(0.5f, 5f)] private float barSpeed = 2f;
        [SerializeField, Range(0.05f, 0.3f)] private float perfectZoneSize = 0.1f;
        [SerializeField, Range(0.1f, 0.5f)] private float goodZoneSize = 0.25f;

        [Header("Reaction Time Settings")]
        [SerializeField, Range(0.2f, 2f)] private float reactionTimeWindow = 0.5f;
        [SerializeField, Range(0.05f, 0.2f)] private float perfectReactionTime = 0.1f;

        [Header("Visual Feedback")]
        [SerializeField] private Color perfectColor = Color.green;
        [SerializeField] private Color goodColor = Color.yellow;
        [SerializeField] private Color badColor = Color.red;

        [Header("Difficulty Multipliers")]
        [SerializeField, Range(0.5f, 2f)] private float easyMultiplier = 0.7f;
        [SerializeField, Range(0.5f, 2f)] private float normalMultiplier = 1f;
        [SerializeField, Range(0.5f, 2f)] private float hardMultiplier = 1.5f;

        // Properties
        public float BarSpeed => barSpeed;
        public float PerfectZoneSize => perfectZoneSize;
        public float GoodZoneSize => goodZoneSize;
        public float ReactionTimeWindow => reactionTimeWindow;
        public float PerfectReactionTime => perfectReactionTime;
        public Color PerfectColor => perfectColor;
        public Color GoodColor => goodColor;
        public Color BadColor => badColor;

        /// <summary>
        /// Gets the difficulty multiplier for a specific difficulty level
        /// </summary>
        public float GetDifficultyMultiplier(float difficulty)
        {
            if (difficulty < 1f) return easyMultiplier;
            if (difficulty > 1f) return hardMultiplier;
            return normalMultiplier;
        }

        /// <summary>
        /// Calculates adjusted zone size based on difficulty
        /// </summary>
        public float GetAdjustedPerfectZone(float difficulty)
        {
            return perfectZoneSize / GetDifficultyMultiplier(difficulty);
        }

        public float GetAdjustedGoodZone(float difficulty)
        {
            return goodZoneSize / GetDifficultyMultiplier(difficulty);
        }

        public float GetAdjustedSpeed(float difficulty)
        {
            return barSpeed * GetDifficultyMultiplier(difficulty);
        }
    }
}