import { describe, expect, it } from "vitest";
import {
  RPG_SOLO_BOSS_DAMAGE_MULTIPLIER,
  RPG_SOLO_BOSS_HEALTH_MULTIPLIER,
  rpgEncounterDifficulty,
} from "./difficulty";

describe("RPG Roguelike encounter difficulty", () => {
  it("gives a solo boss the normal two-boss encounter health budget", () => {
    expect(rpgEncounterDifficulty("boss-room", 0)).toEqual({
      healthMultiplier: RPG_SOLO_BOSS_HEALTH_MULTIPLIER,
      damageMultiplier: RPG_SOLO_BOSS_DAMAGE_MULTIPLIER,
    });
    expect(RPG_SOLO_BOSS_HEALTH_MULTIPLIER).toBeGreaterThan(1.5);
    expect(RPG_SOLO_BOSS_DAMAGE_MULTIPLIER).toBeGreaterThan(1);
    expect(RPG_SOLO_BOSS_DAMAGE_MULTIPLIER).toBeLessThan(2);
  });

  it("raises boss durability per room and pressure per act", () => {
    const first = rpgEncounterDifficulty("boss-room", 0);
    const lateActOne = rpgEncounterDifficulty("boss-room", 2);
    const firstActTwo = rpgEncounterDifficulty("boss-room", 3);

    expect(lateActOne.healthMultiplier).toBeGreaterThan(first.healthMultiplier);
    expect(lateActOne.damageMultiplier).toBe(first.damageMultiplier);
    expect(firstActTwo.healthMultiplier).toBeGreaterThan(lateActOne.healthMultiplier);
    expect(firstActTwo.damageMultiplier).toBeGreaterThan(lateActOne.damageMultiplier);
  });

  it("leaves existing two-boss hallway challenge damage tuning intact", () => {
    expect(rpgEncounterDifficulty("hallway-challenge", 0)).toEqual({
      healthMultiplier: 0.82,
      damageMultiplier: 1,
    });
    const actTwo = rpgEncounterDifficulty("hallway-challenge", 3);
    expect(actTwo.healthMultiplier).toBeCloseTo(0.9);
    expect(actTwo.damageMultiplier).toBe(1);
  });

  it("normalizes invalid route indexes to the first room", () => {
    expect(rpgEncounterDifficulty("boss-room", -4)).toEqual(rpgEncounterDifficulty("boss-room", 0));
    expect(rpgEncounterDifficulty("boss-room", 1.9)).toEqual(rpgEncounterDifficulty("boss-room", 1));
  });
});
