/**
 * Level value object — constrained to 1..10.
 *
 * "I can't believe it's not Haskell": invalid states are unrepresentable.
 * Level progression (next) and combat modifiers (diff) belong to later stories.
 */
export class Level {
  #value: number;

  private constructor(n: number) {
    this.#value = n;
  }

  static create(n: number): Level {
    if (n < 1 || n > 10) {
      throw new Error(`Level must be between 1 and 10, got ${n}`);
    }
    return new Level(n);
  }

  get value(): number {
    return this.#value;
  }

  /** Maximum health for this level: 1000 until level 6, 1500 from level 6 onward. */
  static maxHealthForLevel(level: number): number {
    return level >= 6 ? 1500 : 1000;
  }

  /** Signed level difference: this level minus target level. Positive = this is higher. */
  diff(target: Level): number {
    return this.value - target.value;
  }
}
