Voci: anche le risposte del motore e le scelte dei dialoghi hanno la voce; make ascolta le riascolta con Whisper; rifatte quelle storpiate
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ApqNBvNbNCwXqR2RLo8QJh
This commit is contained in:
+5
-2
@@ -15,6 +15,9 @@ const DEFAULT_LINES = {
|
||||
drop: 'Non è roba mia da buttare.',
|
||||
with: 'Non funziona.',
|
||||
};
|
||||
const HAVE_IT = 'Ce l\'ho già.', DROPPED = 'Questo non mi serve: via.', KEEP_IT = 'Meglio tenerlo: potrebbe servirmi.';
|
||||
// Le battute che il motore dice da sé (quando la storia non ne ha una): anche loro hanno la voce (make voci).
|
||||
export const ENGINE_LINES = [...Object.values(DEFAULT_LINES).filter(Boolean), HAVE_IT, DROPPED, KEEP_IT];
|
||||
const SPEED = 95;
|
||||
// Solo profilo, come i cicli di camminata: 'up' e 'down' lasciano il verso com'è.
|
||||
const FACING = { left: -1, right: 1 };
|
||||
@@ -181,9 +184,9 @@ export class Game {
|
||||
}
|
||||
if (def.actions?.[verb]) return def.actions[verb];
|
||||
if (verb === 'walk') return h?.exit ? [{ go: h.exit.scene, at: h.exit.at, face: h.exit.face }] : [];
|
||||
if (verb === 'take' && !h) return [{ say: 'Ce l\'ho già.' }];
|
||||
if (verb === 'take' && !h) return [{ say: HAVE_IT }];
|
||||
// Si butta solo quello che non serve alla storia (`droppable`): gli oggetti indispensabili restano.
|
||||
if (verb === 'drop' && !h) return def.droppable ? [{ say: 'Questo non mi serve: via.' }, { drop: target }] : [{ say: 'Meglio tenerlo: potrebbe servirmi.' }];
|
||||
if (verb === 'drop' && !h) return def.droppable ? [{ say: DROPPED }, { drop: target }] : [{ say: KEEP_IT }];
|
||||
return DEFAULT_LINES[verb] ? [{ say: DEFAULT_LINES[verb] }] : [];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Voci dei personaggi: un mp3 per battuta (generati da tools/voci.mjs), cercati per chi parla e testo.
|
||||
// Senza assets/voices/index.json, o per una battuta nuova non ancora generata, il gioco resta muto e va avanti.
|
||||
|
||||
import { ENGINE_LINES } from './game.js';
|
||||
|
||||
export const voiceKey = (who, text) => `${who}|${text}`;
|
||||
|
||||
// Tutte le battute della storia, ovunque stiano (scene, oggetti, dialoghi, rami `if`), più le righe dell'introduzione
|
||||
@@ -12,12 +14,15 @@ export function voiceLines(story) {
|
||||
if (Array.isArray(value)) return value.forEach(visit);
|
||||
if (!value || typeof value !== 'object') return;
|
||||
if (typeof value.say === 'string') add(value.who ?? 'andrea', value.say);
|
||||
// Le scelte dei dialoghi: Andrea ripete a voce l'opzione scelta (quando non ha una `say` sua).
|
||||
if (Array.isArray(value.options)) for (const o of value.options) if (typeof o.text === 'string' && o.say == null) add('andrea', o.text);
|
||||
Object.values(value).forEach(visit);
|
||||
};
|
||||
for (const line of story.intro ?? []) for (const text of typeof line === 'string' ? [line] : Object.values(line.rione)) add('andrea', text);
|
||||
visit(story.scenes);
|
||||
visit(story.items);
|
||||
visit(story.dialogues);
|
||||
for (const text of ENGINE_LINES) add('andrea', text);
|
||||
return [...seen.values()];
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1509,7 +1509,7 @@ export const story = {
|
||||
take: [{ if: 'chiavetta_presa', then: [{ say: 'Non c\'è più niente da prendere.' }], else: [{ say: 'Le dita non passano fra le sbarre. Ci vorrebbe qualcosa di lungo e sottile... e appiccicoso.' }] }],
|
||||
},
|
||||
with: {
|
||||
stecco_gomma: [{ if: 'chiavetta_presa', then: [{ say: 'La chiavetta l\'ho già ripescata.' }], else: [{ say: 'Giù lo stecco, piano piano... la gomma tocca la chiavetta...' }, { say: 'Presa!' }, { give: 'chiavetta' }, { set: 'chiavetta_presa' }] }],
|
||||
stecco_gomma: [{ if: 'chiavetta_presa', then: [{ say: 'La chiavetta l\'ho già ripescata.' }], else: [{ say: 'Giù lo stecco, piano piano... la gomma tocca la chiavetta...' }, { say: 'Eccola, presa!' }, { give: 'chiavetta' }, { set: 'chiavetta_presa' }] }],
|
||||
stecco: [{ say: 'Lo stecco ci arriva, ma la chiavetta non si attacca. Serve qualcosa di appiccicoso in cima.' }],
|
||||
gomma: [{ say: 'La gomma da sola non ci arriva. Serve qualcosa per spingerla giù.' }],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user