namespace DoomDeathmatch.Component.MVC.Model;

public class HealthModel
{
  public float MaxHealth
  {
    get => _maxHealth;
    set
    {
      _maxHealth = Math.Max(value, 1);
      HealthChanged?.Invoke(this);
    }
  }

  public float Health
  {
    get => _health;
    set
    {
      _health = Math.Clamp(value, 0, MaxHealth);
      HealthChanged?.Invoke(this);
    }
  }

  public event Action<HealthModel>? HealthChanged;

  private float _health;
  private float _maxHealth;

  public HealthModel(float parMaxHealth)
  {
    MaxHealth = parMaxHealth;
    Health = parMaxHealth;
  }
}