Add local save selection and editing

This commit is contained in:
N0VAN0M4LY committed 2026-11-29 15:42:28 +08:00
1 parent 900eb90b42
commit d19baec90b
18 files changed
+634 -4

No files matched your search

@@ -134,6 +134,7 @@ export const InstallRecordSchema = z.object({
unavailablePatches: z.array(UnavailablePatchSchema),
installedAt: z.string(),
lastCheckedAt: z.string().optional(),
currentSaveId: z.string().regex(/^\d+$/).optional(),
/** Relative paths read from the installation source during the last copy or update. */
sourceFiles: z.array(z.string().min(1)).optional(),
});
+46
View File
@@ -0,0 +1,46 @@
import { z } from 'zod';
import { CopyIdSchema } from './install.ts';
export const LocalUserIdSchema = z.string().regex(/^\d+$/);
export const SaveKeysSchema = z.object({ copyId: CopyIdSchema, userId: LocalUserIdSchema });
export const CurrencyEditsSchema = z.object({
silverLions: z.number().int().nonnegative().optional(),
goldenEagles: z.number().int().min(0).max(0x7fffffff).optional(),
gjnCents: z.number().int().nonnegative().optional(),
freeRp: z.number().int().nonnegative().optional(),
});
const SaveSummarySchema = z.object({
userId: LocalUserIdSchema,
login: z.string(),
nick: z.string(),
created: z.string(),
currencies: z.object({
silverLions: z.number(),
goldenEagles: z.number(),
gjnCents: z.number(),
freeRp: z.number(),
}).nullable(),
vehicleCount: z.number().int().nonnegative(),
battleCount: z.number().int().nonnegative(),
lastBattle: z.number().nullable(),
premiumDays: z.number(),
});
export const SaveListSchema = z.object({ saves: z.array(SaveSummarySchema), current: LocalUserIdSchema.nullable() });
export const SaveDetailsSchema = z.object({
save: SaveSummarySchema,
battles: z.array(z.object({
id: z.string(), time: z.number(), won: z.boolean().nullable(), mission: z.string(), mode: z.string(),
vehicles: z.array(z.string()), silverLions: z.number(), researchPoints: z.number(),
})),
owned: z.array(z.string()),
research: z.array(z.object({ name: z.string(), points: z.number() })),
});
export const SaveRegistrationSchema = z.object({
copyId: CopyIdSchema, login: z.string(), password: z.string(), nick: z.string(),
});
export type SaveList = z.output<typeof SaveListSchema>;
export type SaveDetails = z.output<typeof SaveDetailsSchema>;
export type CurrencyEdits = z.output<typeof CurrencyEditsSchema>;
export type SaveRegistration = z.output<typeof SaveRegistrationSchema>;