feat : add metrial fetcher
This commit is contained in:
@@ -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 })),
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user