60 lines
2.3 KiB
TypeScript
60 lines
2.3 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,
|
|
bossDeathDespawnSeconds,
|
|
bossDeathHoldSeconds,
|
|
bossDeathOpacity,
|
|
consumeBossIndicatorPatch,
|
|
createBossIndicatorPatchState,
|
|
updateBossIndicatorPatchState,
|
|
} 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("patches indicator meshes once per defeat, including a replacement boss", () => {
|
|
let state = createBossIndicatorPatchState(false);
|
|
expect(state.pending).toBe(false);
|
|
|
|
state = updateBossIndicatorPatchState(state, true);
|
|
expect(state.pending).toBe(true);
|
|
state = consumeBossIndicatorPatch(state);
|
|
expect(state.pending).toBe(false);
|
|
expect(updateBossIndicatorPatchState(state, true)).toBe(state);
|
|
|
|
state = updateBossIndicatorPatchState(state, false);
|
|
expect(state.pending).toBe(false);
|
|
state = updateBossIndicatorPatchState(state, true);
|
|
expect(state.pending).toBe(true);
|
|
});
|
|
|
|
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);
|
|
});
|
|
|
|
it("keeps Gravehorn visible through its full authored fall", () => {
|
|
const hold = bossDeathHoldSeconds("gravehorn-triceratops");
|
|
expect(hold).toBeGreaterThan(5.73);
|
|
expect(bossDeathOpacity(5.73, "gravehorn-triceratops")).toBe(1);
|
|
expect(bossDeathOpacity(bossDeathDespawnSeconds("gravehorn-triceratops"), "gravehorn-triceratops")).toBe(0);
|
|
});
|
|
});
|