forked from phenom/healer-man
31 lines
1.4 KiB
TypeScript
31 lines
1.4 KiB
TypeScript
import type { RomClassId } from "../app/characterCatalog";
|
|
import compactGearCurves from "./generated/romNativeGearCurves.generated.json";
|
|
import { normalizeRomNativeGearStats, type RomNativeGearStats } from "./romNativeStatsTypes";
|
|
|
|
export type RomNativeGearSlot =
|
|
| "head" | "neck" | "shoulder" | "back" | "chest" | "wrist" | "hands" | "waist" | "legs" | "feet"
|
|
| "finger" | "trinket" | "main-hand" | "off-hand" | "ranged";
|
|
|
|
interface CompactCurveCatalog {
|
|
readonly status: string;
|
|
readonly profiles: Readonly<Record<string, Readonly<Record<string, readonly (unknown | { readonly stats?: unknown })[]>>>>;
|
|
}
|
|
|
|
const catalog = compactGearCurves as unknown as CompactCurveCatalog;
|
|
export const ROM_NATIVE_GEAR_REFERENCE_STATUS = catalog.status;
|
|
export const ROM_NATIVE_GEAR_REFERENCE_CLASSES = Object.freeze(Object.keys(catalog.profiles) as RomClassId[]);
|
|
|
|
/** Returns only compact, source-selected native reference values; unsupported class/slot pairs have no payload. */
|
|
export function romNativeGearReference(
|
|
classId: RomClassId,
|
|
slot: RomNativeGearSlot,
|
|
level: number,
|
|
): RomNativeGearStats | null {
|
|
const curve = catalog.profiles[classId]?.[slot];
|
|
if (!curve) return null;
|
|
const safeLevel = Math.max(1, Math.min(79, Math.trunc(Number.isFinite(level) ? level : 1)));
|
|
const entry = curve[safeLevel - 1];
|
|
const raw = entry && typeof entry === "object" && "stats" in entry ? entry.stats : entry;
|
|
return normalizeRomNativeGearStats(raw) ?? null;
|
|
}
|