v0.3.0 — playtest fixes, two new rules, and §7 enforced

This commit is contained in:
Jesse
2026-08-12 21:08:28 -04:00
parent 6ead39c530
commit 1bf1e95058
38 changed files with 8514 additions and 5989 deletions
+22 -5
View File
@@ -28,7 +28,7 @@ import type { GameEvent } from '../engine/events.ts';
import type { Intent } from '../engine/intents.ts';
import { legalActions } from '../engine/legal.ts';
import { createGame } from '../engine/setup.ts';
import type { GameConfig, GameState, PlayerIndex } from '../engine/state.ts';
import type { CardId, GameConfig, GameState, PlayerIndex } from '../engine/state.ts';
import { cuesFor, narrate } from '../sim/narrate.ts';
// Import from the view module, NOT replay.ts — replay.ts writes files and reads process.argv,
// which would pull node:fs into a browser bundle.
@@ -99,6 +99,15 @@ export type Game = {
* something you watch land rather than something you are told about afterwards.
*/
scheduled: number | null;
/**
* The card most recently drawn into hand, or null.
*
* A drawn card arrives among two others that look exactly like it, and nothing said which was new.
* Unlike `scheduled`, this is NOT cleared on the next render: it marks WHICH CARD IS NEW rather
* than that a draw just happened, so it stands until another draw replaces it. Nothing needs to
* clear it when the card is played — no element carries the class once the card leaves the hand.
*/
justDrawn: CardId | null;
};
/** How each intent kind is introduced in the action list, in the order they should appear. */
@@ -133,7 +142,7 @@ export const SOLO_PLAYER = 'Solitaire';
export function newGame(seed: number, config: GameConfig = SOLO_CONFIG): Game {
const state = createGame({ id: `web-${seed}`, seed, config, playerNames: [SOLO_PLAYER] });
const game: Game = { state, seed, history: [], log: [], mustPlayCard: false, cues: [], scheduled: null };
const game: Game = { state, seed, history: [], log: [], mustPlayCard: false, cues: [], scheduled: null, justDrawn: null };
// A history that opens mid-Stage reads as though something was missed. Say what the game IS
// first, then let the clock take over.
game.log.push({ text: 'Game Begins', tone: 'start' });
@@ -349,10 +358,16 @@ export function actionMenu(game: Game): Menu {
* THE HAND, AND WHAT EACH CARD CAN DO.
*
* Built from the same `options` everything else reads, so a verb offered here is one `check` has
* already accepted. Cards keep their order in hand rather than being regrouped: the hand is a row
* of objects the player is looking at, not a list to sort.
* already accepted. Cards are not regrouped or sorted: the hand is a row of objects the player is
* looking at, not a list to sort.
*
* NEWEST FIRST. The engine pushes a drawn card onto the END of the hand, and with the row wrapping
* that put the card you just turned over wherever the eye is least likely to be — reported from
* playtesting. Reversing HERE rather than in the engine is deliberate: the bot iterates its hand to
* generate options, so changing the stored order would reshuffle its tie-breaks and invalidate
* every revenue measurement in TODO.md. `snapshot()` reverses identically for the replay viewers.
*/
const handIds = game.state.decks.hands.get(0) ?? [];
const handIds = [...(game.state.decks.hands.get(0) ?? [])].reverse();
const hand: HandAction[] = handIds.map((cardId) => {
const place = placeable.flatMap((g) => g.items).find((it) => it.subjectKey === `card:${cardId}`);
let playNow: number | null = null;
@@ -653,6 +668,8 @@ function record(game: Game, events: GameEvent[], actor: PlayerIndex | null = nul
// Which timetable slot the die just filled, so the panel can flash it. Last one wins: a batch can
// schedule more than one train, and the most recent is the one the eye should be sent to.
for (const e of events) if (e.type === 'trainScheduled') game.scheduled = e.slot;
// Which card just came into hand, so the row can badge it. Last one wins for the same reason.
for (const e of events) if (e.type === 'cardDrawn') game.justDrawn = e.cardId;
// Keep the log bounded; the full history lives in `history` and can be replayed.
if (game.log.length > 400) game.log.splice(0, game.log.length - 400);
}