V1.1.0
Add ten new games (18 in total) and the engine features they need. Story: Dead Air, The Masquerade at Montague House, The Kalahari Expedition, The Alchemist's Vault, Submerged: Deep Lab Nereid, The Kestrel Bank Job. Games can now set their own hint penalty and a hard time limit, shown as a countdown; running out ends the game with the fail ending. Defuse: Tick Tock: Overtime. Manuals are now rulesets, so each game has its own solver. Adds indicator lights, per-level strike limits, and the Passwords, Morse Light and Say It Back modules. Sync: In Sync: Deep Cuts. Adds telepathy (typed word) and ranking rounds, and a per-round bar for the key. Labyrinth: The Drowned Catacombs and The Mirror Maze. Adds one-way gates, a relative (no compass) Explorer, a mirrored Navigator map, and mazes with a lantern count other than three. Validation now rejects a maze where a gate can leave the Explorer stuck. Difficulty runs from 1 to 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
import { CLUE_TYPES } from '@two-keys/shared';
|
||||
import { CLUE_TYPES, DEFUSE_MODULES, SYNC_ROUND_TYPES } from '@two-keys/shared';
|
||||
|
||||
const hex = z.string().regex(/^#[0-9a-fA-F]{6}$/, 'expected a #rrggbb colour');
|
||||
const roleInfo = z.object({ name: z.string().min(1), blurb: z.string() });
|
||||
@@ -10,7 +10,7 @@ const header = {
|
||||
title: z.string().min(1),
|
||||
tagline: z.string().min(1),
|
||||
estimatedMinutes: z.number().positive(),
|
||||
difficulty: z.number().int().min(1).max(3),
|
||||
difficulty: z.number().int().min(1).max(5),
|
||||
players: z.object({ min: z.literal(2), max: z.literal(2) }),
|
||||
theme: z.object({ primary: hex, accent: hex, background: hex, headingFont: z.string().min(1) }),
|
||||
roles: z.object({ A: roleInfo, B: roleInfo }),
|
||||
@@ -81,12 +81,22 @@ const finaleSchema = z.discriminatedUnion('type', [
|
||||
clues: z.object({ A: z.array(clueSchema).default([]), B: z.array(clueSchema).default([]) }),
|
||||
lock: lockSchema,
|
||||
successEnding: z.string().min(1),
|
||||
/** Shown if a time limit runs out. */
|
||||
failEnding: z.string().min(1).optional(),
|
||||
}),
|
||||
]);
|
||||
|
||||
const storySchema = z.object({
|
||||
...header,
|
||||
engine: z.literal('story'),
|
||||
rules: z
|
||||
.object({
|
||||
hintPenaltySeconds: z.number().int().nonnegative().optional(),
|
||||
/** Hard limit on the clock (elapsed + penalties). Running out ends the game. */
|
||||
timeLimitMinutes: z.number().positive().optional(),
|
||||
timeLimitLabel: z.string().min(1).optional(),
|
||||
})
|
||||
.default({}),
|
||||
suspects: z
|
||||
.array(z.object({ id: z.string(), name: z.string(), role: z.string(), description: z.string() }))
|
||||
.optional(),
|
||||
@@ -97,14 +107,18 @@ const storySchema = z.object({
|
||||
// ---------- defuse ----------
|
||||
|
||||
const range = z.object({ min: z.number().int().nonnegative(), max: z.number().int().nonnegative() });
|
||||
const moduleId = z.enum(['wires', 'button', 'keypad']);
|
||||
const moduleId = z.enum(DEFUSE_MODULES);
|
||||
const indicators = z.object({ lit: z.array(z.string()), unlit: z.array(z.string()) }).optional();
|
||||
|
||||
const defuseSchema = z.object({
|
||||
...header,
|
||||
engine: z.literal('defuse'),
|
||||
/** Which manual the solver implements. Each manual's rules live in engines/defuse.ts. */
|
||||
ruleset: z.enum(['classic', 'overtime']).default('classic'),
|
||||
device: z.object({
|
||||
serial: z.object({ length: z.number().int().min(2), alphabet: z.string().min(2) }),
|
||||
batteries: range,
|
||||
indicators: z.object({ labels: z.array(z.string().min(1)).min(1), count: range }).optional(),
|
||||
}),
|
||||
levels: z
|
||||
.array(
|
||||
@@ -113,6 +127,7 @@ const defuseSchema = z.object({
|
||||
title: z.string().min(1),
|
||||
timeSeconds: z.number().int().positive(),
|
||||
modules: z.array(moduleId).min(1),
|
||||
strikesOverride: z.number().int().positive().optional(),
|
||||
keyName: z.string().min(1),
|
||||
}),
|
||||
)
|
||||
@@ -129,6 +144,15 @@ const defuseSchema = z.object({
|
||||
symbols: z.record(z.string()),
|
||||
columns: z.array(z.array(z.string()).min(4)).min(1),
|
||||
}),
|
||||
passwords: z
|
||||
.object({
|
||||
columnsCount: z.number().int().positive(),
|
||||
lettersPerColumn: z.number().int().min(2).max(26),
|
||||
words: z.array(z.string().regex(/^[A-Z]+$/)).min(2),
|
||||
})
|
||||
.optional(),
|
||||
morse: z.object({ words: z.record(z.string().regex(/^\d\.\d{3}$/)) }).optional(),
|
||||
simon: z.object({ colors: z.array(z.string()).min(2), stages: range }).optional(),
|
||||
}),
|
||||
manual: z.string().min(1),
|
||||
fixtures: z.object({
|
||||
@@ -136,6 +160,7 @@ const defuseSchema = z.object({
|
||||
z.object({
|
||||
serial: z.string(),
|
||||
batteries: z.number().int(),
|
||||
indicators,
|
||||
wires: z.array(z.string()),
|
||||
expect: z.object({ type: z.literal('cut'), index: z.number().int() }),
|
||||
}),
|
||||
@@ -143,6 +168,7 @@ const defuseSchema = z.object({
|
||||
button: z.array(
|
||||
z.object({
|
||||
batteries: z.number().int(),
|
||||
indicators,
|
||||
label: z.string(),
|
||||
color: z.string(),
|
||||
strip: z.string(),
|
||||
@@ -153,6 +179,20 @@ const defuseSchema = z.object({
|
||||
}),
|
||||
),
|
||||
keypad: z.array(z.object({ symbols: z.array(z.string()), expect: z.array(z.string()) })),
|
||||
passwords: z.array(z.object({ columns: z.array(z.string()), expect: z.string() })).default([]),
|
||||
morse: z
|
||||
.array(z.object({ signal: z.string(), expect: z.object({ word: z.string(), frequency: z.string() }) }))
|
||||
.default([]),
|
||||
simon: z
|
||||
.array(
|
||||
z.object({
|
||||
serial: z.string(),
|
||||
strikes: z.number().int(),
|
||||
flashes: z.array(z.string()),
|
||||
expect: z.array(z.string()),
|
||||
}),
|
||||
)
|
||||
.default([]),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -163,13 +203,20 @@ const questionSchema = z.object({
|
||||
q: z.string().min(1),
|
||||
options: z.array(z.coerce.string()).min(2),
|
||||
});
|
||||
const telepathySchema = z.object({ id: z.string().min(1), q: z.string().min(1) });
|
||||
const rankSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
q: z.string().min(1),
|
||||
items: z.array(z.coerce.string()).min(3),
|
||||
});
|
||||
|
||||
const syncSchema = z.object({
|
||||
...header,
|
||||
engine: z.literal('sync'),
|
||||
rules: z.object({
|
||||
questionsPerRound: z.number().int().positive(),
|
||||
pointsForKey: z.number().int().positive(),
|
||||
/** Default for rounds that don't set their own. */
|
||||
pointsForKey: z.number().int().positive().default(3),
|
||||
replaysPerRound: z.number().int().nonnegative(),
|
||||
}),
|
||||
rounds: z
|
||||
@@ -177,19 +224,26 @@ const syncSchema = z.object({
|
||||
z.object({
|
||||
id: z.string().min(1),
|
||||
title: z.string().min(1),
|
||||
type: z.enum(['match', 'predict']),
|
||||
type: z.enum(SYNC_ROUND_TYPES),
|
||||
subject: z.enum(['A', 'B']).optional(),
|
||||
/** rank rounds: who does the ranking on each question, cycled. */
|
||||
subjectPattern: z.array(z.enum(['A', 'B'])).min(1).optional(),
|
||||
pointsForKey: z.number().int().positive().optional(),
|
||||
blurb: z.string(),
|
||||
keyName: z.string().min(1),
|
||||
}),
|
||||
)
|
||||
.min(1),
|
||||
match: z.array(questionSchema),
|
||||
predict: z.array(questionSchema),
|
||||
match: z.array(questionSchema).default([]),
|
||||
predict: z.array(questionSchema).default([]),
|
||||
telepathy: z.array(telepathySchema).default([]),
|
||||
rank: z.array(rankSchema).default([]),
|
||||
});
|
||||
|
||||
// ---------- labyrinth ----------
|
||||
|
||||
const dir = z.enum(['n', 'e', 's', 'w']);
|
||||
|
||||
const labyrinthSchema = z.object({
|
||||
...header,
|
||||
engine: z.literal('labyrinth'),
|
||||
@@ -198,6 +252,16 @@ const labyrinthSchema = z.object({
|
||||
z.object({ x: z.number().int(), y: z.number().int(), glyph: z.string(), label: z.string().min(1) }),
|
||||
),
|
||||
lanterns: z.array(z.object({ x: z.number().int(), y: z.number().int(), name: z.string().min(1) })),
|
||||
lanternsRequired: z.number().int().positive().default(3),
|
||||
/** One-way gates: you may step from (x, y) in `dir`, never back the other way. */
|
||||
oneWay: z.array(z.object({ x: z.number().int(), y: z.number().int(), dir })).default([]),
|
||||
explorer: z
|
||||
.object({
|
||||
/** `relative` swaps N/E/S/W for forward/left/right/back from the way the Explorer faces. */
|
||||
compass: z.enum(['absolute', 'relative']).default('absolute'),
|
||||
startFacing: dir.default('n'),
|
||||
})
|
||||
.default({}),
|
||||
explorerView: z.object({
|
||||
flavour: z.object({
|
||||
blank: z.string(),
|
||||
@@ -205,9 +269,15 @@ const labyrinthSchema = z.object({
|
||||
lantern: z.string(),
|
||||
exitLocked: z.string(),
|
||||
exitOpen: z.string(),
|
||||
gate: z.string().optional(),
|
||||
}),
|
||||
}),
|
||||
navigatorView: z.object({ showMoveCount: z.boolean().default(true) }),
|
||||
navigatorView: z.object({
|
||||
showMoveCount: z.boolean().default(true),
|
||||
/** `mirror-x` serves the map flipped left to right. */
|
||||
mapTransform: z.enum(['none', 'mirror-x']).default('none'),
|
||||
banner: z.string().optional(),
|
||||
}),
|
||||
scoring: z.object({ trapPenaltySeconds: z.number().nonnegative(), parMoves: z.number().int().positive() }),
|
||||
successEnding: z.string().min(1),
|
||||
});
|
||||
@@ -226,4 +296,4 @@ export type LabyrinthGame = z.infer<typeof labyrinthSchema>;
|
||||
export type Game = z.infer<typeof gameSchema>;
|
||||
export type Clue = z.infer<typeof clueSchema>;
|
||||
export type Lock = z.infer<typeof lockSchema>;
|
||||
export type SyncQuestion = z.infer<typeof questionSchema>;
|
||||
export type SyncQuestion = { id: string; q: string; options?: string[]; items?: string[] };
|
||||
|
||||
Reference in New Issue
Block a user