import { z } from "zod"; import { DbShema } from "../db-shema.js"; import { GameShema } from "../game-shema.js"; export const SigameShema = new (class SigameShema { public ZSigameQuestion = z.object({ question_id: DbShema.ZQuestions.shape.question_id, q_text: DbShema.ZQuestions.shape.q_text, q_media_filename: DbShema.ZQuestions.shape.q_media_filename, difficulty: DbShema.ZQuestions.shape.difficulty, answers: DbShema.ZQuestions.shape.answers, q_media_type: DbShema.ZQuestions.shape.q_media_type, a_media_filename: DbShema.ZQuestions.shape.a_media_filename, a_media_type: DbShema.ZQuestions.shape.a_media_type, price: z.union([ z.literal(100), z.literal(200), z.literal(300), z.literal(400), z.literal(500), ]), isPassed: z.boolean(), isEnabledOptions: z.boolean(), type: z.enum(["cat", "auction"]).optional(), }); public sigameStages = [ "guide", // ролик с правилами игры "players-questions-before-game", //вопросы игроков "question-selection", // игрок выбирает вопрос "reading-question", // ведущий зачитывает вопрос "question-timer", // игроки нажимают на кнопку "player-answer", // игрок отвесает на вопрос "answer-discussion", // показ правильного ответа "cat-select", // кот в мешке выбор игрока "auction-betting", // аукцион ставки "type-player-answer", // ответ игрока для типового вопроса "final-intro", // интро перед финалом "final-category-select", // выбор категории для финала "final-betting", // ставки игроков "final-reading-question", // ведущий читает вопрос "final-game", // игроки отвечают на вопрос "final-answer", // ведущий выставляет правильные ответы "extra-questions", // перестрелка на случай нескольких победителей "outro", // результаты ] as const; private ZSigameStages = z.enum(this.sigameStages); public ZSigame = GameShema.ZGame.extend({ categories: z .array( z.object({ category_id: DbShema.ZCategories.shape.category_id, name: DbShema.ZCategories.shape.name, questions: z.array(this.ZSigameQuestion), finalQuestion: z.object({ question_id: DbShema.ZQuestions.shape.question_id, q_text: DbShema.ZQuestions.shape.q_text, q_media_filename: DbShema.ZQuestions.shape.q_media_filename, difficulty: DbShema.ZQuestions.shape.difficulty, answers: DbShema.ZQuestions.shape.answers, q_media_type: DbShema.ZQuestions.shape.q_media_type, a_media_filename: DbShema.ZQuestions.shape.q_media_filename, a_media_type: DbShema.ZQuestions.shape.q_media_type, }), extraQuestions: z.array(this.ZSigameQuestion).nullable(), }), ) .min(1), categoryBlocks: z.array(z.array(z.number())).min(1), currentBlockIdx: z.number(), gameStage: this.ZSigameStages, currentPlayerIdx: z.number().nullable(), playersScore: z.array(z.number()).min(1), currentQuestion: z .object({ categoryIdx: z.number(), questionIdx: z.number(), }) .nullable(), answeringPlayerIdx: z.number().nullable(), auctionBets: z.array( z .object({ bet: z.number(), isAllIn: z.boolean(), }) .nullable(), ), finalCategoriesIds: z.array(z.number()).min(1), excludedFinalCategoriesIds: z.array(z.number()), finalPlayersIdxs: z.array( z.object({ answer: z.string(), isReady: z.boolean(), bet: z.number(), isRight: z.boolean().nullable(), }), ), finalCategoryId: z.number().nullable(), winnerIdx: z.number().nullable(), extraCategoryId: z.number(), extraPlayersIdxs: z.array(z.number()), }); })();