rewrite game types: entry model with flag/artist/song, ordered predictions, remove dishes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
import { z } from "zod"
|
||||
|
||||
// ─── Country Lineup ─────────────────────────────────────────────────
|
||||
// ─── Entry Lineup ───────────────────────────────────────────────────
|
||||
|
||||
export const countrySchema = z.object({
|
||||
code: z.string(),
|
||||
name: z.string(),
|
||||
flag: z.string(),
|
||||
})
|
||||
|
||||
export type Country = z.infer<typeof countrySchema>
|
||||
|
||||
export const entrySchema = z.object({
|
||||
country: countrySchema,
|
||||
artist: z.string(),
|
||||
song: z.string(),
|
||||
})
|
||||
|
||||
export type Entry = z.infer<typeof entrySchema>
|
||||
|
||||
export const lineupSchema = z.object({
|
||||
year: z.number(),
|
||||
countries: z.array(countrySchema),
|
||||
entries: z.array(entrySchema),
|
||||
})
|
||||
|
||||
export type Lineup = z.infer<typeof lineupSchema>
|
||||
@@ -20,56 +29,21 @@ export type Lineup = z.infer<typeof lineupSchema>
|
||||
|
||||
export const predictionSchema = z.object({
|
||||
playerId: z.string().uuid(),
|
||||
predictedWinner: z.string(),
|
||||
top3: z.array(z.string()).length(3),
|
||||
nulPointsPick: z.string(),
|
||||
first: z.string(),
|
||||
second: z.string(),
|
||||
third: z.string(),
|
||||
last: z.string(),
|
||||
})
|
||||
|
||||
export type Prediction = z.infer<typeof predictionSchema>
|
||||
|
||||
// ─── Dishes ─────────────────────────────────────────────────────────
|
||||
|
||||
export const dishSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
name: z.string(),
|
||||
correctCountry: z.string(),
|
||||
revealed: z.boolean(),
|
||||
})
|
||||
|
||||
export type Dish = z.infer<typeof dishSchema>
|
||||
|
||||
export const dishGuessSchema = z.object({
|
||||
dishId: z.string().uuid(),
|
||||
playerId: z.string().uuid(),
|
||||
guessedCountry: z.string(),
|
||||
})
|
||||
|
||||
export type DishGuess = z.infer<typeof dishGuessSchema>
|
||||
|
||||
// ─── Game State (sent to clients) ───────────────────────────────────
|
||||
|
||||
/** State slice sent to each player — they only see their own prediction */
|
||||
export const gameStateSchema = z.object({
|
||||
lineup: lineupSchema,
|
||||
myPrediction: predictionSchema.nullable(),
|
||||
predictionsLocked: z.boolean(),
|
||||
dishes: z.array(dishSchema),
|
||||
myDishGuesses: z.array(dishGuessSchema),
|
||||
dishResults: z
|
||||
.array(
|
||||
z.object({
|
||||
dish: dishSchema,
|
||||
guesses: z.array(
|
||||
z.object({
|
||||
playerId: z.string().uuid(),
|
||||
displayName: z.string(),
|
||||
guessedCountry: z.string(),
|
||||
correct: z.boolean(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
)
|
||||
.nullable(),
|
||||
predictionSubmitted: z.record(z.string(), z.boolean()),
|
||||
})
|
||||
|
||||
export type GameState = z.infer<typeof gameStateSchema>
|
||||
|
||||
Reference in New Issue
Block a user