Add public profiles and cosmetic shop
All checks were successful
Deploy MineGeo to Dokploy / deploy (push) Successful in 7m10s
All checks were successful
Deploy MineGeo to Dokploy / deploy (push) Successful in 7m10s
This commit is contained in:
41
shared/profile-cosmetics.ts
Normal file
41
shared/profile-cosmetics.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { z } from "zod";
|
||||
import { profileCosmeticIds } from "./profile-cosmetic-ids";
|
||||
|
||||
export const profileCosmeticIdSchema = z.enum(profileCosmeticIds);
|
||||
export type { ProfileCosmeticId } from "./profile-cosmetic-ids";
|
||||
|
||||
export const profileCosmeticActionSchema = z.discriminatedUnion("action", [
|
||||
z
|
||||
.object({
|
||||
action: z.literal("purchase"),
|
||||
cosmeticId: profileCosmeticIdSchema,
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
action: z.literal("equip"),
|
||||
cosmeticId: profileCosmeticIdSchema.nullable(),
|
||||
})
|
||||
.strict(),
|
||||
]);
|
||||
|
||||
export const cosmeticShopStateSchema = z
|
||||
.object({
|
||||
balance: z.number().int().nonnegative(),
|
||||
owned: z.array(profileCosmeticIdSchema),
|
||||
equipped: profileCosmeticIdSchema.nullable(),
|
||||
catalog: z.array(
|
||||
z
|
||||
.object({
|
||||
id: profileCosmeticIdSchema,
|
||||
name: z.string().min(1).max(48),
|
||||
description: z.string().min(1).max(160),
|
||||
price: z.number().int().positive(),
|
||||
rarity: z.enum(["common", "rare", "epic", "legendary"]),
|
||||
})
|
||||
.strict(),
|
||||
),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type CosmeticShopState = z.infer<typeof cosmeticShopStateSchema>;
|
||||
Reference in New Issue
Block a user