Files
leggenda-del-regolo/tests/helpers.mjs
T
manzoloandClaude Opus 5.5 826f5f99ec Prototipo del motore: scena, camminata, verbi, inventario, dialoghi, salvataggio
Motore guidato dai dati con due scene di prova (Piazza e salita alla Fortezza),
percorsi su area concava, clic intelligente e pressione lunga, test della soluzione
completa in node e nel browser con Playwright. Nel documento la leggenda del nonno.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 00:08:00 +02:00

18 lines
715 B
JavaScript

// Fa avanzare il gioco come farebbe un giocatore impaziente: tempo che scorre e battute saltate.
export function settle(game, { maxSteps = 20000 } = {}) {
const said = [];
for (let i = 0; i < maxSteps; i++) {
if (game.speech) {
said.push(game.speech);
game.skip();
}
if (!game.busy && !game.walking && !game.queue.length && !game.task) return said;
game.update(0.05);
}
throw new Error('Il gioco non si ferma: ' + JSON.stringify(game.snapshot()));
}
export function memoryStorage() {
return { data: {}, getItem(k) { return this.data[k] ?? null; }, setItem(k, v) { this.data[k] = String(v); }, removeItem(k) { delete this.data[k]; } };
}