namespace Models.Game
{
    /// <summary>
    /// The Cell class represents a cell in the application.
    /// </summary>
    public class Cell : Position, IEquatable<Cell>
    {
        /// <summary>
        /// The value of the cell.
        /// </summary>
        private int? _value;
        public int? Value {
            get => _value;
            set
            {
                if (value < 0)
                {
                    throw new Exception("La valeur doit être supérieure à 0");
                }
                this._value = value;
            }
        }

        /// <summary>
        /// The fact that the cell is dangerous or not.
        /// </summary>
        private bool IsDangerous { get; set; }

        /// <summary>
        /// Atribute to know if the cell is a penalty cell.
        /// </summary>
        private bool Penalty { get; set; }

        /// <summary>
        /// Constructor of the Cell class.
        /// </summary>
        /// <param name="x">the x position</param>
        /// <param name="y">the y position</param>
        /// <param name="isDangerous">if the cell is a dangerous cell or not</param>
        public Cell(int x, int y,bool isDangerous = false):base(x,y)
        {
            IsDangerous = isDangerous;
            Penalty = false;
        }

        /// <summary>
        /// Function in order to return the fact that the cell is dangerous or not.
        /// </summary>
        /// <returns>If the cell is dangerous or not</returns>
        public bool GetCellType() => IsDangerous;

        /// <summary>
        /// Redefine the equal operation between cells.
        /// </summary>
        /// <param name="other">The object to compare with the current cell.</param>
        /// <returns>true if the specified object is equal to the current cell; otherwise, false.</returns>
        public bool Equals(Cell? other)
        {
            if (other == null) return false;
            if (this.X == other.X && this.Y == other.Y) return true;
            return false;
        }
    }
}