Il taccuino: le tappe del capitolo e l'obiettivo di adesso (tasto N)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ApqNBvNbNCwXqR2RLo8QJh
This commit is contained in:
@@ -339,6 +339,11 @@ export class Game {
|
||||
}
|
||||
|
||||
// La mappa: i posti già visti, con la posizione sulla pianta, e le strade che li collegano (uscite fra due posti visti).
|
||||
// Il taccuino: le tappe fatte e quella di adesso (la prima non fatta).
|
||||
notebook() {
|
||||
const steps = this.story.notebook ?? [], at = steps.findIndex(s => !check(s.done, this.state));
|
||||
return { done: (at < 0 ? steps : steps.slice(0, at)).map(s => s.text), now: at < 0 ? null : steps[at].text };
|
||||
}
|
||||
mapPlaces() {
|
||||
return Object.entries(this.story.scenes)
|
||||
.filter(([id, sc]) => sc.map && this.state.flags['visto:' + id])
|
||||
|
||||
+17
@@ -292,6 +292,20 @@ $('to-title').addEventListener('click', () => {
|
||||
});
|
||||
$('close-map').addEventListener('click', () => { $('map').hidden = true; });
|
||||
|
||||
// --- Taccuino: le tappe fatte, barrate, e quella di adesso; in fondo dove chiedere aiuto.
|
||||
function openNotebook() {
|
||||
if (!running) return;
|
||||
const { done, now } = game.notebook();
|
||||
$('notebook-list').replaceChildren(...done.map(t => Object.assign(document.createElement('li'), { textContent: t, className: 'done' })),
|
||||
...(now ? [Object.assign(document.createElement('li'), { textContent: now, className: 'now' })] : []));
|
||||
$('notebook-help').textContent = story.notebookHelp ?? '';
|
||||
$('notebook').hidden = false;
|
||||
// Su uno schermo basso il foglio scorre: si parte dalla tappa di adesso, in fondo.
|
||||
$('notebook-list').scrollTop = $('notebook-list').scrollHeight;
|
||||
}
|
||||
$('notebook-button').addEventListener('click', openNotebook);
|
||||
$('close-notebook').addEventListener('click', () => { $('notebook').hidden = true; });
|
||||
|
||||
// --- Salva su file / Carica: la partita in un file .json da aprire su un altro dispositivo.
|
||||
$('save-file').addEventListener('click', () => {
|
||||
const data = game.savable();
|
||||
@@ -466,9 +480,11 @@ window.addEventListener('keydown', e => {
|
||||
if (debugKey(e)) return;
|
||||
if (!$('credits').hidden) { if (e.key === 'Escape') { if (!$('face').hidden) $('face').hidden = true; else $('credits').hidden = true; } return; }
|
||||
if (!$('pause').hidden) { if (e.key === 'Escape') closePause(); return; }
|
||||
if (!$('notebook').hidden) { if (['Escape', 'n', 'N'].includes(e.key)) $('notebook').hidden = true; return; }
|
||||
if (!$('map').hidden) { if (e.key === 'Escape' || e.key === 'p' || e.key === 'P') $('map').hidden = true; return; }
|
||||
if ((e.key === 'p' || e.key === 'P') && running) { openMap(); return; }
|
||||
if ((e.key === 'h' || e.key === 'H') && running) { showSpots(); return; }
|
||||
if ((e.key === 'n' || e.key === 'N') && running) { openNotebook(); return; }
|
||||
if (!$('intro').hidden && [' ', 'Enter'].includes(e.key)) { e.preventDefault(); nextIntro(); return; }
|
||||
if (e.key === 'm' || e.key === 'M') { toggleMute(); return; }
|
||||
if (!running) return;
|
||||
@@ -514,6 +530,7 @@ function updateUi() {
|
||||
$('map-button').hidden = !running || !!game.dialogue || game.mapPlaces().length < 2;
|
||||
$('pause-button').hidden = !running;
|
||||
$('spots-button').hidden = !running;
|
||||
$('notebook-button').hidden = !running || !story.notebook;
|
||||
if (game.state.ended && !game.speech && !game.queue.length) {
|
||||
running = false;
|
||||
$('ending').hidden = false;
|
||||
|
||||
@@ -44,6 +44,16 @@ export const story = {
|
||||
// La mappa (pulsante «Mappa»): ogni scena con `map: [x, y]` (percentuali della pianta) ci compare quando è
|
||||
// stata visitata; le strade sono le uscite fra scene. Un posto nuovo entra con la sua riga `map`.
|
||||
start: { scene: 'piazza', at: [250, 320] },
|
||||
// Il taccuino (pulsante «Taccuino», tasto N): le tappe del capitolo in ordine. Una tappa è fatta quando la sua
|
||||
// condizione `done` è vera; la prima non fatta è l'obiettivo di adesso. Solo testo: non si sente a voce.
|
||||
notebook: [
|
||||
{ done: 'luccichio', text: 'Il palio è sparito, e la festa è domani. Chiedo in giro: i vecchietti in piazza sanno sempre tutto.' },
|
||||
{ done: 'squama_presa', text: 'La vecchietta ha visto luccicare qualcosa sotto la panchina, in piazza.' },
|
||||
{ done: 'indizio_regolo', text: 'Una squama, grossa e luccicante. Chi l\'ha persa avrà lasciato altre tracce: lassù sotto la Fortezza, magari.' },
|
||||
{ done: 'casetta_aperta', text: 'Le tracce finiscono in una fessura del bastione, buia pesta. Mi serve una torcia: nella casetta dell\'area feste ce n\'è una, ma è chiusa col lucchetto.' },
|
||||
{ done: 'palio_trovato', text: 'Ho la torcia: di corsa alla fessura sotto la Fortezza!' },
|
||||
],
|
||||
notebookHelp: 'Se non so più cosa fare: al Trebbio, la torre dà sempre un consiglio.',
|
||||
// I quattro rioni del Palio: dopo «Nuova partita» si sceglie per chi corre Andrea, e la partita lo ricorda col
|
||||
// flag `rione:<id>`. Le battute che parlano del rione di Andrea lo controllano con `if`.
|
||||
// Per ora si corre solo per Campomigliaio (decisione di Andrea, 24 ottobre: ogni rione vuol dire battute e voci
|
||||
|
||||
Reference in New Issue
Block a user