forked from phenom/healer-man
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,40 @@
|
||||
import type { DungeonCatalogEntry } from "./dungeonCatalog";
|
||||
|
||||
export type DungeonQueueMode = "regular" | "biteSized" | "randomizedBiteSized";
|
||||
|
||||
export interface DungeonQueuePolicy {
|
||||
readonly schemaVersion: 1;
|
||||
readonly disabled: Readonly<Record<DungeonQueueMode, readonly string[]>>;
|
||||
}
|
||||
|
||||
export const DEFAULT_DUNGEON_QUEUE_POLICY: DungeonQueuePolicy = {
|
||||
schemaVersion: 1,
|
||||
disabled: { regular: [], biteSized: [], randomizedBiteSized: [] },
|
||||
};
|
||||
|
||||
export function queueModeForDungeon(dungeon: DungeonCatalogEntry): DungeonQueueMode {
|
||||
if (dungeon.category !== "bite-sized") return "regular";
|
||||
return dungeon.id.startsWith("randomized-bite-sized-") ? "randomizedBiteSized" : "biteSized";
|
||||
}
|
||||
|
||||
export function dungeonEnabledForQueue(policy: DungeonQueuePolicy, dungeon: DungeonCatalogEntry): boolean {
|
||||
return !policy.disabled[queueModeForDungeon(dungeon)].includes(dungeon.id);
|
||||
}
|
||||
|
||||
export function normalizeDungeonQueuePolicy(value: unknown): DungeonQueuePolicy {
|
||||
if (!value || typeof value !== "object" || !("schemaVersion" in value) || value.schemaVersion !== 1
|
||||
|| !("disabled" in value) || !value.disabled || typeof value.disabled !== "object") {
|
||||
throw new Error("Invalid dungeon queue policy.");
|
||||
}
|
||||
const disabled = value.disabled as Record<string, unknown>;
|
||||
for (const mode of ["regular", "biteSized", "randomizedBiteSized"] as const) {
|
||||
if (!Array.isArray(disabled[mode]) || !disabled[mode].every((id: unknown) => typeof id === "string")) {
|
||||
throw new Error("Invalid dungeon queue policy.");
|
||||
}
|
||||
}
|
||||
return { schemaVersion: 1, disabled: {
|
||||
regular: [...disabled.regular as string[]],
|
||||
biteSized: [...disabled.biteSized as string[]],
|
||||
randomizedBiteSized: [...disabled.randomizedBiteSized as string[]],
|
||||
} };
|
||||
}
|
||||
Reference in new issue
Block a user