Files
healer-man/src/game/runewakerLootCatalog.test.ts
T
2026-09-23 16:14:19 -04:00

52 lines
2.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
RUNEWAKER_LOOT_CATALOG,
rollRunewakerBossLoot,
runewakerBossHasLoot,
runewakerBossLootSource,
} from "./runewakerLootCatalog";
describe("RuneWaker source loot catalog", () => {
it("covers every source-classified boss template with explicit status", () => {
expect(RUNEWAKER_LOOT_CATALOG.bossCount).toBe(RUNEWAKER_LOOT_CATALOG.bosses.length);
expect(RUNEWAKER_LOOT_CATALOG.bossCount).toBeGreaterThanOrEqual(50);
expect(RUNEWAKER_LOOT_CATALOG.bosses.every((boss) => Boolean(boss.status))).toBe(true);
});
it("executes NPC slot and treasure probabilities deterministically", () => {
const sequence = [0, 0, ...Array.from({ length: 28 }, () => 0.999999)];
const drops = rollRunewakerBossLoot("rw-barren-caves-101462", 80, {
random: () => sequence.shift() ?? 0.999999,
now: 12_345,
});
expect(drops[0]).toMatchObject({
itemId: 200004,
name: "Healing Sigil",
quantity: 1,
itemLevel: 80,
sourceBossName: "Anglo",
inventorySlot: "misc",
});
expect(drops[0].stats).toMatchObject({ stamina: 0, armor: 0, meleeWeapon: null });
expect(rollRunewakerBossLoot("rw-barren-caves-101462", 37, {
random: () => 0,
})).toEqual([]);
});
it("keeps no-source tables and unknown bosses fail closed", () => {
const noDrops = RUNEWAKER_LOOT_CATALOG.bosses.find((boss) => boss.status === "no-source-drops")!;
expect(runewakerBossHasLoot(noDrops.bossKey)).toBe(false);
expect(rollRunewakerBossLoot(noDrops.bossKey, 20, { random: () => 0 })).toEqual([]);
expect(runewakerBossLootSource("unknown")).toBeNull();
expect(rollRunewakerBossLoot("unknown", 20)).toEqual([]);
});
it("exposes blocked source paths instead of executing them", () => {
const partial = RUNEWAKER_LOOT_CATALOG.bosses.find((boss) => boss.status === "partial")!;
expect(partial.blockedOutcomeCount).toBeGreaterThan(0);
expect(partial.rolls.flatMap((roll) => roll.outcomes).some((outcome) => (
outcome.runtimeStatus === "blocked" && Boolean(outcome.blockedReason)
))).toBe(true);
});
});