Files
healer-man/src/game/dungeonLeaderboardCatalog.test.ts
T
2026-09-20 16:46:17 -04:00

45 lines
2.5 KiB
TypeScript

import { readFileSync, writeFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { CLASSES } from "../app/characterCatalog";
import { DUNGEON_DEFINITIONS } from "./dungeonRegistry";
import { dungeonBossesForDifficulty, finalDungeonBoss } from "./dungeonRunStore";
import { isDerivedStockadesDungeonId, STORMWIND_STOCKADE_DUNGEON_ID } from "./dungeonContentSource";
import { BITE_SIZED_STOCKADES_BOSS_CANDIDATES } from "./dungeons/biteSizedStockades";
const stockades = DUNGEON_DEFINITIONS.find((dungeon) => dungeon.id === STORMWIND_STOCKADE_DUNGEON_ID)!;
const biteSizedBosses = BITE_SIZED_STOCKADES_BOSS_CANDIDATES.map((candidate) => (
stockades.bosses.find((boss) => boss.id === candidate.sourceSpawnId)!
));
describe("dungeon leaderboard catalog", () => {
it("keeps the server's final bosses, boss lists, difficulties, and classes aligned with the game", () => {
const catalog = {
dungeons: DUNGEON_DEFINITIONS.map((dungeon) => ({ id: dungeon.id, title: dungeon.title,
finalBossId: isDerivedStockadesDungeonId(dungeon.id)
? biteSizedBosses[0].id
: finalDungeonBoss(dungeon)?.id ?? "",
bosses: (isDerivedStockadesDungeonId(dungeon.id) ? biteSizedBosses : dungeon.bosses)
.map((boss) => ({ id: boss.id, name: boss.name })),
difficulties: dungeon.difficultyVariants.map((difficulty) => ({ id: difficulty.id, name: difficulty.difficulty,
bossIds: isDerivedStockadesDungeonId(dungeon.id)
? biteSizedBosses.map((boss) => boss.id)
: dungeonBossesForDifficulty(dungeon, difficulty.id).map((boss) => boss.id),
finalBossId: isDerivedStockadesDungeonId(dungeon.id)
? biteSizedBosses[0].id
: finalDungeonBoss(dungeon, difficulty.id)?.id ?? "",
...(isDerivedStockadesDungeonId(dungeon.id)
? { finalBossIds: biteSizedBosses.map((boss) => boss.id) }
: {}),
})),
defaultDifficultyId: dungeon.defaultDifficultyId,
})).sort((a, b) => a.id.localeCompare(b.id)),
classes: CLASSES.map((entry) => ({ id: entry.id, name: entry.name })),
};
expect(catalog.dungeons).toHaveLength(86);
expect(catalog.dungeons.filter((dungeon) => dungeon.bosses.length > 0 && !dungeon.finalBossId)).toEqual([]);
const path = "src/game/generated/dungeonLeaderboardCatalog.generated.json";
if (process.env.WRITE_DUNGEON_LEADERBOARD_CATALOG === "1") writeFileSync(path, `${JSON.stringify(catalog, null, 2)}\n`);
expect(JSON.parse(readFileSync(path, "utf8"))).toEqual(catalog);
});
});