using NaughtyAttributes;
using UnityEngine;

namespace EscapeRoomEngine.Engine.Runtime.Modules
{
    /// <summary>
    /// The <see cref="ModuleDescription"/> for a <see cref="DoorModule"/>. Includes the description of the connected door.
    /// </summary>
    [CreateAssetMenu(menuName = "Modules/Puzzle")]
    public class PuzzleModuleDescription : ModuleDescription
    {
        [Tooltip("Each puzzle has a name that will be used to display it to the game master.")]
        [InfoBox("Changes to the name or version of the puzzle change its ID, which means it will not be connected with any of its previous measures any more.", EInfoBoxType.Warning)]
        public string puzzleName;
        [InfoBox("Puzzle measurements will only be combined for the same puzzle with the same version. If large changes are made to the puzzle that might influence its measurements, the version should be incremented.")]
        public int puzzleVersion = 1;

        /// <summary>
        /// The ID of the puzzle is used in the database.
        /// </summary>
        public int Id => puzzleName.GetHashCode() + puzzleVersion;

        public override string ToString()
        {
            return $"{puzzleName} v{puzzleVersion} ({Id})";
        }
    }
}