UNPKG

@battle-racing/br-common-lib

Version:

Common library for all Battle Racing Repositorios

73 lines (72 loc) 4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.screenHomeViewInputSchema = exports.screenFinishViewInputSchema = exports.screenUpdateGameViewInputSchema = exports.updateBattleViewInputSchema = exports.updateRaceViewInputSchema = exports.screenCountdownParamsSchema = exports.countDownNextViewBattleSchema = exports.countDownNextViewRaceSchema = exports.screenBattleViewConfigSchema = exports.screenRaceViewConfigSchema = exports.screenViewBaseConfigSchema = exports.screenGameTimeLeftSchema = exports.screenCurrentTotalSchema = exports.screenModuleStatusSchema = exports.kartFinalStateSchema = exports.screenViewSchema = exports.screenStatusSchema = void 0; const zod_1 = require("zod"); const Damage_schema_1 = require("../../damage/Damage.schema"); const PowerUpAttributes_schema_1 = require("../../powerUp/PowerUpAttributes.schema"); const Screen_const_1 = require("./Screen.const"); const Kart_const_1 = require("../../kart/Kart.const"); exports.screenStatusSchema = zod_1.z.enum(Screen_const_1.SCREEN_STATUS); exports.screenViewSchema = zod_1.z.enum(Screen_const_1.SCREEN_VIEW); // KART_FINAL_STATE is { FINISHED: 'finished', ... } as const. z.nativeEnum works with it. exports.kartFinalStateSchema = zod_1.z.enum(Kart_const_1.KART_FINAL_STATE); exports.screenModuleStatusSchema = zod_1.z.object({ latestView: exports.screenViewSchema, screenStatus: exports.screenStatusSchema, }); exports.screenCurrentTotalSchema = zod_1.z.object({ current: zod_1.z.number().nullable(), total: zod_1.z.number().nullable(), }); exports.screenGameTimeLeftSchema = zod_1.z.object({ minutes: zod_1.z.number().nullable().optional(), seconds: zod_1.z.number().nullable().optional(), }); exports.screenViewBaseConfigSchema = zod_1.z.object({ position: exports.screenCurrentTotalSchema.optional(), coins: zod_1.z.number().nullable().optional(), gameTimeLeft: exports.screenGameTimeLeftSchema.optional(), powerUp: zod_1.z .union([PowerUpAttributes_schema_1.powerUpNameSchema, zod_1.z.literal('Clear PowerUp')]) .nullable() .optional(), powerUpAnimationTimeSeconds: zod_1.z.number().nullable().optional(), damageEffect: zod_1.z .union([Damage_schema_1.damageEffectNameSchema, zod_1.z.literal('Yellow Flag'), zod_1.z.literal('Red Flag')]) .nullable() .optional(), damageAnimationTimeSeconds: zod_1.z .union([zod_1.z.literal('Infinite'), zod_1.z.number()]) .nullable() .optional(), }); exports.screenRaceViewConfigSchema = exports.screenViewBaseConfigSchema.extend({ laps: exports.screenCurrentTotalSchema.optional(), }); exports.screenBattleViewConfigSchema = exports.screenViewBaseConfigSchema.extend({ lives: exports.screenCurrentTotalSchema.optional(), }); exports.countDownNextViewRaceSchema = zod_1.z.object({ nextView: zod_1.z.literal('Race'), config: exports.screenRaceViewConfigSchema, }); exports.countDownNextViewBattleSchema = zod_1.z.object({ nextView: zod_1.z.literal('Battle'), config: exports.screenBattleViewConfigSchema, }); exports.screenCountdownParamsSchema = zod_1.z.union([exports.countDownNextViewRaceSchema, exports.countDownNextViewBattleSchema]); exports.updateRaceViewInputSchema = zod_1.z.object({ view: zod_1.z.literal('Race'), config: exports.screenRaceViewConfigSchema }); exports.updateBattleViewInputSchema = zod_1.z.object({ view: zod_1.z.literal('Battle'), config: exports.screenBattleViewConfigSchema, }); exports.screenUpdateGameViewInputSchema = zod_1.z.union([exports.updateRaceViewInputSchema, exports.updateBattleViewInputSchema]); exports.screenFinishViewInputSchema = zod_1.z.object({ kartNumber: zod_1.z.number().optional(), kartPosition: exports.screenCurrentTotalSchema, coins: zod_1.z.number(), finalState: exports.kartFinalStateSchema.optional(), }); exports.screenHomeViewInputSchema = zod_1.z.object({ kartNumber: zod_1.z.number().nullable().optional(), });