Exact source used by this build. SHA-256: 166ea7fe1f6f932cb796ab30c9b8c22593caaaa62d8ff2294cfee32b27a0b8f1.
1 import { z } from "zod";
2 import { SeasonSchema } from "../seasons/schema";
3
4 export const WeatherSchema = z.enum(["sunny", "rain", "storm", "wind", "snow"]);
5 export type Weather = z.infer<typeof WeatherSchema>;
6 export const WeatherOddsSchema = z.record(SeasonSchema, z.record(WeatherSchema, z.number().finite().nonnegative())).superRefine((odds, context) => {
7 for (const [season, weights] of Object.entries(odds)) {
8 if (Math.abs(Object.values(weights).reduce((sum, weight) => sum + weight, 0) - 1) > 0.000001) context.addIssue({ code: "custom", message: `${season} weather odds must sum to one` });
9 }
10 });
11 export const WeatherVisualsSchema = z.record(WeatherSchema, z.object({
12 color: z.number().int().min(0).max(0xffffff), opacity: z.number().min(0).max(1),
13 particleColor: z.number().int().min(0).max(0xffffff),
14 particleKind: z.enum(["none", "rain", "snow", "wind"]), particleCount: z.number().int().nonnegative(),
15 }));
16