V1.2.2
- Quote options and labels containing commas so they no longer split (In Sync: Deep Cuts d12/d15; accusation options in Blue Lantern, Dead Air, Kalahari Expedition and Masquerade) - Validation: strict choice options; flag sync options that look split - Hint sheet: timed games say hints take time off the countdown - How to Play: hint cost covers timed games Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@two-keys/server",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
toAbsolute,
|
||||
type LabyrinthState,
|
||||
} from '../engines/labyrinth';
|
||||
import { NUDGE_AFTER_WRONG, hintPenalty, type StoryState } from '../engines/story';
|
||||
import { NUDGE_AFTER_WRONG, hintPenalty, timeLimitSeconds, type StoryState } from '../engines/story';
|
||||
import { canReplay, isMatch, pointsForKey, subjectOf, type SyncState } from '../engines/sync';
|
||||
import type { Room } from '../rooms/store';
|
||||
import type { Clue, DefuseGame, Game, LabyrinthGame, Lock, StoryGame, SyncGame } from './schemas';
|
||||
@@ -76,6 +76,7 @@ function lockView(game: StoryGame, lock: Lock, s: StoryState): LockView {
|
||||
hints: lock.hints.slice(0, s.hints[lock.id] ?? 0),
|
||||
hintsTotal: lock.hints.length,
|
||||
hintPenaltySeconds: hintPenalty(game),
|
||||
timeLimited: timeLimitSeconds(game) !== null,
|
||||
wrongAttempts,
|
||||
nudge: !solved && wrongAttempts >= NUDGE_AFTER_WRONG,
|
||||
successText: solved ? (lock.successText ?? null) : null,
|
||||
|
||||
@@ -30,7 +30,8 @@ const clueSchema = z.object({
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const optionSchema = z.object({ id: z.string().min(1), label: z.string().min(1) });
|
||||
// Strict: an unquoted comma in `{ id, label: a, b }` adds a stray `b` key instead of failing.
|
||||
const optionSchema = z.object({ id: z.string().min(1), label: z.string().min(1) }).strict();
|
||||
|
||||
const lockSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
|
||||
@@ -180,6 +180,15 @@ function validateSync(game: SyncGame): string[] {
|
||||
for (const q of game.rank) {
|
||||
if (q.items.length !== 4) errors.push(`rank question ${q.id}: needs exactly 4 items, has ${q.items.length}`);
|
||||
}
|
||||
// An unquoted comma in a YAML [flow, list] splits one option into several, e.g. "A craft (woodwork" + "pottery".
|
||||
const lists = [...game.match, ...game.predict].map((q) => [q.id, q.options] as const);
|
||||
for (const [id, options] of [...lists, ...game.rank.map((q) => [q.id, q.items] as const)]) {
|
||||
for (const o of options) {
|
||||
if (o.split('(').length !== o.split(')').length || /^[a-z]/.test(o)) {
|
||||
errors.push(`question ${id}: option "${o}" looks split by an unquoted comma; quote it`);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const r of game.rounds) {
|
||||
if (r.type === 'predict' && !r.subject) errors.push(`round ${r.id}: predict rounds need a subject`);
|
||||
if (r.type === 'rank' && r.subjectPattern && r.subjectPattern.length !== game.rules.questionsPerRound) {
|
||||
|
||||
@@ -191,6 +191,13 @@ describe('results', () => {
|
||||
expect(stateOf(room, 'A').result).toMatchObject({ success: false, outOfTime: true, rank: 'Out of time', nightmareSurvivors: false });
|
||||
});
|
||||
|
||||
it('tells the hint sheet when hints come off a countdown', () => {
|
||||
const timed = getGame('kestrel-heist', 'story');
|
||||
const untimed = getGame('alchemists-vault', 'story');
|
||||
expect(stateOf(playingRoom(timed), 'A').views.A).toMatchObject({ chapters: [{ lock: { timeLimited: true } }] });
|
||||
expect(stateOf(playingRoom(untimed), 'A').views.A).toMatchObject({ chapters: [{ lock: { timeLimited: false } }] });
|
||||
});
|
||||
|
||||
it('a difficulty-5 game with zero hints earns Nightmare Survivors', () => {
|
||||
const game = getGame('kestrel-heist', 'story');
|
||||
expect(game.difficulty).toBe(5);
|
||||
@@ -240,6 +247,23 @@ describe('content validation additions', () => {
|
||||
expect(validateGame(game).join('\n')).toMatch(/exactly 4 items/);
|
||||
});
|
||||
|
||||
it('keeps options that contain commas whole', () => {
|
||||
const deep = getGame('in-sync-deep-cuts', 'sync');
|
||||
expect(deep.predict.find((q) => q.id === 'd12')!.options).toContain('A full, noisy home');
|
||||
expect(deep.predict.find((q) => q.id === 'd15')!.options).toEqual(['An instrument', 'A language', 'A sport', 'A craft (woodwork, pottery, etc.)']);
|
||||
const masq = getGame('masquerade-montague', 'story');
|
||||
if (masq.finale.type !== 'accusation') throw new Error('expected accusation');
|
||||
expect(masq.finale.questions.flatMap((q) => q.options.map((o) => o.label))).toContain(
|
||||
'Stabbed with the armoury dagger, then buried it in a dry cactus pot',
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects a sync option split by an unquoted comma', () => {
|
||||
const game = clone(getGame('in-sync-deep-cuts', 'sync'));
|
||||
game.predict[0].options = ['A craft (woodwork', 'pottery', 'etc.)', 'A sport'];
|
||||
expect(validateGame(game).join('\n')).toMatch(/looks split by an unquoted comma/);
|
||||
});
|
||||
|
||||
it("rejects Overtime tables that don't match the solver's", () => {
|
||||
const game = clone(getGame('tick-tock-overtime', 'defuse'));
|
||||
game.modules.passwords!.words[0] = 'ZEBRA';
|
||||
|
||||
Reference in New Issue
Block a user