Update Healer Man server
This commit is contained in:
1 parent
9c5fb4c614
commit
bd073fb00f
113 files changed
+4902
-273
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import dungeonCatalog from "../src/game/generated/dungeonLeaderboardCatalog.generated.json" with { type: "json" };
|
||||
|
||||
const knownIds = new Set(dungeonCatalog.dungeons.map((dungeon) => dungeon.id));
|
||||
const modes = ["regular", "biteSized", "randomizedBiteSized"];
|
||||
|
||||
export const DEFAULT_DUNGEON_QUEUE_POLICY = Object.freeze({
|
||||
schemaVersion: 1,
|
||||
disabled: { regular: [], biteSized: [], randomizedBiteSized: [] },
|
||||
});
|
||||
|
||||
function modeForId(id) {
|
||||
if (id.startsWith("randomized-bite-sized-")) return "randomizedBiteSized";
|
||||
if (id.startsWith("bite-sized-")) return "biteSized";
|
||||
return "regular";
|
||||
}
|
||||
|
||||
export function normalizeDungeonQueuePolicy(value) {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value) || value.schemaVersion !== 1
|
||||
|| !value.disabled || typeof value.disabled !== "object" || Array.isArray(value.disabled)) {
|
||||
throw new Error("A version 1 dungeon queue policy is required.");
|
||||
}
|
||||
if (Object.keys(value.disabled).some((mode) => !modes.includes(mode))) {
|
||||
throw new Error("Unknown dungeon queue mode.");
|
||||
}
|
||||
const disabled = {};
|
||||
for (const mode of modes) {
|
||||
const ids = value.disabled[mode];
|
||||
if (!Array.isArray(ids) || ids.some((id) => typeof id !== "string" || !knownIds.has(id) || modeForId(id) !== mode)
|
||||
|| new Set(ids).size !== ids.length) {
|
||||
throw new Error(`Invalid disabled dungeon IDs for ${mode}.`);
|
||||
}
|
||||
disabled[mode] = [...ids].sort();
|
||||
}
|
||||
return { schemaVersion: 1, disabled };
|
||||
}
|
||||
Reference in new issue
Block a user