You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
543 B
19 lines
543 B
import { z } from "zod";
|
|
|
|
export const diceConfigSchema = z.object({
|
|
defaultSides: z.number().int().min(2).max(1000).default(6).describe("默认骰子面数"),
|
|
});
|
|
|
|
export type DiceToolConfig = z.infer<typeof diceConfigSchema>;
|
|
|
|
export const DEFAULT_DICE_CONFIG: DiceToolConfig = {
|
|
defaultSides: 6,
|
|
};
|
|
|
|
export function parseDiceConfig(raw: unknown): DiceToolConfig {
|
|
const parsed = diceConfigSchema.safeParse(raw);
|
|
if (!parsed.success) {
|
|
throw new Error(`Invalid dice config: ${parsed.error.message}`);
|
|
}
|
|
return parsed.data;
|
|
}
|
|
|