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:
2026-10-13 23:34:11 +02:00
co-authored by Claude Opus 5.5
parent 62245ca67a
commit bbe44e84c4
38 changed files with 4201 additions and 197 deletions
+25 -3
View File
@@ -1,4 +1,4 @@
import { matchesAnswer, type Role } from '@two-keys/shared';
import { formatClock, matchesAnswer, type Role } from '@two-keys/shared';
import type { Lock, StoryGame } from '../content/schemas';
import { OK, fail, type ActionResult, type Ctx } from './types';
@@ -34,6 +34,28 @@ export function initStory(): StoryState {
}
const state = (ctx: Ctx) => ctx.room.engine as StoryState;
/** What one hint costs in this game. */
export const hintPenalty = (game: StoryGame): number => game.rules.hintPenaltySeconds ?? HINT_PENALTY_SECONDS;
/** The hard limit on elapsed + penalty time, for the games that have one. */
export const timeLimitSeconds = (game: StoryGame): number | null =>
game.rules.timeLimitMinutes ? Math.round(game.rules.timeLimitMinutes * 60) : null;
/** Called on a timer; returns true if the room changed (the time limit ran out). */
export function tickStory(game: StoryGame, ctx: Ctx): boolean {
const limit = timeLimitSeconds(game);
const { room } = ctx;
if (limit === null || room.phase !== 'playing' || room.startedAt === null) return false;
if ((ctx.now - room.startedAt) / 1000 + room.penaltySeconds < limit) return false;
const { finale } = game;
ctx.finish(
false,
finale.failEnding ?? "**Time's up.** The clock beat you this time. Run it back?",
finale.type === 'accusation' ? finale.reveal : null,
);
return true;
}
const atFinale = (game: StoryGame, s: StoryState) => s.chapter >= game.chapters.length;
/** The one lock that can currently be worked on, if any. */
@@ -82,8 +104,8 @@ export function requestHint(game: StoryGame, ctx: Ctx, lockId: string): ActionRe
if (tier >= open.lock.hints.length) return fail('no_more_hints', "That's every hint for this lock.");
s.hints[lockId] = tier + 1;
ctx.room.hintsUsed++;
ctx.addPenalty(HINT_PENALTY_SECONDS);
ctx.toast('all', `Hint ${tier + 1} revealed (+2:00)`);
ctx.addPenalty(hintPenalty(game));
ctx.toast('all', `Hint ${tier + 1} revealed (+${formatClock(hintPenalty(game))})`);
return OK;
}