32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
BOSS_INDICATOR_DEATH_FADE_MS,
|
|
BOSS_DEATH_DESPAWN_SECONDS,
|
|
BOSS_DEATH_FADE_SECONDS,
|
|
BOSS_DEATH_HOLD_SECONDS,
|
|
advanceBossIndicatorOpacity,
|
|
bossCanTrackTarget,
|
|
bossDeathOpacity,
|
|
} from "./bossDeathVisuals";
|
|
|
|
describe("boss death visuals", () => {
|
|
it("stops target tracking as soon as boss health reaches zero", () => {
|
|
expect(bossCanTrackTarget(1)).toBe(true);
|
|
expect(bossCanTrackTarget(0)).toBe(false);
|
|
expect(bossCanTrackTarget(-1)).toBe(false);
|
|
});
|
|
|
|
it("fades mechanic indicators to zero over the death transition", () => {
|
|
const halfway = advanceBossIndicatorOpacity(1, true, BOSS_INDICATOR_DEATH_FADE_MS / 2_000);
|
|
expect(halfway).toBeCloseTo(0.5);
|
|
expect(advanceBossIndicatorOpacity(halfway, true, BOSS_INDICATOR_DEATH_FADE_MS / 2_000)).toBe(0);
|
|
expect(advanceBossIndicatorOpacity(0.4, false, 1 / 60)).toBe(1);
|
|
});
|
|
|
|
it("holds the death pose for a few seconds, then fades the model", () => {
|
|
expect(bossDeathOpacity(BOSS_DEATH_HOLD_SECONDS)).toBe(1);
|
|
expect(bossDeathOpacity(BOSS_DEATH_HOLD_SECONDS + BOSS_DEATH_FADE_SECONDS / 2)).toBeCloseTo(0.5);
|
|
expect(bossDeathOpacity(BOSS_DEATH_DESPAWN_SECONDS)).toBe(0);
|
|
});
|
|
});
|