using EscapeRoomEngine.Engine.Runtime.Utilities;
using Realms;

namespace EscapeRoomEngine.Engine.Runtime.Measurements
{
    /// <summary>
    /// A single measurement, consisting of when a puzzle was started and solved, stored in the database.
    /// </summary>
    public class PuzzleMeasurement : EmbeddedObject
    {
        /// <summary>
        /// The relative time since the engine was initialised of when this puzzle was started.
        /// </summary>
        public float TimeStarted { get; set; }
        /// <summary>
        /// The relative time since the engine was initialised of when this puzzle was solved.
        /// </summary>
        public float TimeSolved { get; set; }

        /// <summary>
        /// The total time taken to solve this puzzle during this measurement.
        /// </summary>
        public float Time => TimeSolved - TimeStarted;

        public override string ToString()
        {
            return $"{Time.ToTimeSpan():m':'ss}";
        }
    }
}