feat : update
This commit is contained in:
+17
-4
@@ -24,6 +24,8 @@ export interface CatalogAscensionGroup {
|
||||
items: CatalogAscensionMaterial[];
|
||||
}
|
||||
|
||||
export type CatalogLevelingGroup = CatalogAscensionGroup;
|
||||
|
||||
export interface CatalogMaterial {
|
||||
key: string;
|
||||
name: string;
|
||||
@@ -50,10 +52,13 @@ const skillSchema = z.object({
|
||||
icon: z.string(),
|
||||
});
|
||||
|
||||
const attributeSchema = z.record(z.string(), z.union([z.number(), z.string()]));
|
||||
|
||||
export const characterDetailSchema = z.object({
|
||||
info: z.object({
|
||||
element: z.string().optional(),
|
||||
weapon: z.string().optional(),
|
||||
attributes: z.array(attributeSchema).nullish(),
|
||||
}).nullish(),
|
||||
constellations: z.record(z.string(), constellationSchema).nullish(),
|
||||
skills: z.object({
|
||||
@@ -65,9 +70,8 @@ export const characterDetailSchema = z.object({
|
||||
z.string(),
|
||||
z.union([z.number().int(), z.record(z.string(), z.number().int())]),
|
||||
).nullish(),
|
||||
attributes: z.array(
|
||||
z.record(z.string(), z.union([z.number(), z.string()])),
|
||||
).nullish(),
|
||||
leveling: z.record(z.string(), z.record(z.string(), z.number().int())).nullish(),
|
||||
attributes: z.array(attributeSchema).nullish(),
|
||||
});
|
||||
|
||||
export function cleanLunarisText(value: string): string {
|
||||
@@ -150,10 +154,19 @@ export function ascensionSnapshot(
|
||||
}));
|
||||
}
|
||||
|
||||
export function levelingSnapshot(
|
||||
value: z.infer<typeof characterDetailSchema>,
|
||||
): CatalogLevelingGroup[] {
|
||||
return Object.entries(value.leveling ?? {}).map(([type, entries]) => ({
|
||||
type,
|
||||
items: Object.entries(entries).map(([key, amount]) => ({ key, amount })),
|
||||
}));
|
||||
}
|
||||
|
||||
export function baseStatsSnapshot(
|
||||
value: z.infer<typeof characterDetailSchema>,
|
||||
): CatalogBaseStat[] {
|
||||
const level90 = value.attributes?.find((entry) => entry.level === 90);
|
||||
const level90 = (value.info?.attributes ?? value.attributes)?.find((entry) => entry.level === 90);
|
||||
if (!level90) return [];
|
||||
return Object.entries(level90)
|
||||
.filter(([key]) => key !== "level" && key !== "ascension")
|
||||
|
||||
Reference in New Issue
Block a user