Mappa del paese per spostarsi veloci; Codex nei crediti

Il pulsante «Mappa» (o il tasto P) apre la pianta del paese a gradini: ci sono i posti già visti,
le strade sono le uscite fra loro, un clic porta lì (game.travel, mai durante un dialogo o una
battuta). Ogni scena ha la sua posizione in `map`; un posto nuovo entra con una riga. Test: posti
solo visti, strade, viaggio rifiutato in un dialogo; nel browser dal Trebbio alla Piazza.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UdeKd62opy9PKgpQXtVctF
This commit is contained in:
2026-10-23 15:59:29 +02:00
co-authored by Claude Opus 5.5
parent e743315f0f
commit ce4da39c8d
8 changed files with 123 additions and 1 deletions
+23
View File
@@ -255,6 +255,28 @@ export class Game {
else throw new Error('Effetto sconosciuto: ' + JSON.stringify(e));
}
// La mappa: i posti già visti, con la posizione sulla pianta, e le strade che li collegano (uscite fra due posti visti).
mapPlaces() {
return Object.entries(this.story.scenes)
.filter(([id, sc]) => sc.map && this.state.flags['visto:' + id])
.map(([id, sc]) => ({ id, name: sc.name, at: sc.map, here: id === this.state.scene }));
}
mapRoads() {
const seen = new Set(this.mapPlaces().map(p => p.id)), roads = new Map();
for (const id of seen)
for (const h of this.story.scenes[id].hotspots ?? [])
if (h.exit && seen.has(h.exit.scene) && h.exit.scene !== id) roads.set([id, h.exit.scene].sort().join('|'), [id, h.exit.scene].sort());
return [...roads.values()];
}
// Viaggio dalla mappa: solo verso un posto già visto, e non mentre si parla, si cammina o si sceglie in un dialogo.
travel(scene) {
const sc = this.story.scenes[scene];
if (!sc?.map || !this.state.flags['visto:' + scene] || scene === this.state.scene) return false;
if (this.busy || this.walking || this.dialogue || this.state.ended) return false;
this.go(scene, sc.entry);
return true;
}
go(scene, at, face) {
if (!this.story.scenes[scene]) throw new Error('Scena sconosciuta: ' + scene);
this.state.scene = scene;
@@ -263,6 +285,7 @@ export class Game {
this.path = [];
this.walking = false;
this.back = false;
this.state.flags['visto:' + scene] = true; // per la mappa
this.queue.unshift(...(this.scene.enter ?? []));
this.onSave(this.snapshot());
}