feat : add metrial fetcher

This commit is contained in:
2026-09-06 13:59:32 +07:00 Unverified
parent 2808a27406
commit 37d6d6703f
8 changed files with 3827 additions and 8 deletions
+35
View File
@@ -14,6 +14,25 @@ export interface CatalogTalent {
iconKey: string | null;
}
export interface CatalogAscensionMaterial {
key: string;
amount: number;
}
export interface CatalogAscensionGroup {
type: string;
items: CatalogAscensionMaterial[];
}
export interface CatalogMaterial {
key: string;
name: string;
description: string | null;
rarity: number | null;
type: string | null;
imageKey: string;
}
const constellationSchema = z.object({
name: z.string(),
description: z.string(),
@@ -37,6 +56,10 @@ export const characterDetailSchema = z.object({
elementalskill: skillSchema.optional(),
elementalburst: skillSchema.optional(),
}).nullish(),
ascension: z.record(
z.string(),
z.union([z.number().int(), z.record(z.string(), z.number().int())]),
).nullish(),
});
export function cleanLunarisText(value: string): string {
@@ -106,3 +129,15 @@ export function talentSnapshot(
iconKey: iconKey(talent.icon),
}] : []);
}
export function ascensionSnapshot(
value: z.infer<typeof characterDetailSchema>,
): CatalogAscensionGroup[] {
return Object.entries(value.ascension ?? {}).map(([type, entries]) => ({
type,
items:
typeof entries === "number"
? [{ key: type, amount: entries }]
: Object.entries(entries).map(([key, amount]) => ({ key, amount })),
}));
}