I nomi dei crediti escono in ordine casuale a ogni apertura
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ApqNBvNbNCwXqR2RLo8QJh
This commit is contained in:
@@ -38,6 +38,18 @@ export const miniature = src => src?.replace(/([^/]+)$/, 'mini/$1') ?? null;
|
||||
// Una riga dell'introduzione: un testo, oppure { rione: { id: testo } } con la riga del rione scelto.
|
||||
export const introText = (line, rione) => typeof line === 'string' ? line : line.rione[rione] ?? Object.values(line.rione)[0];
|
||||
|
||||
// I crediti con i nomi di ogni voce in ordine casuale: nessuno viene sempre per primo.
|
||||
export function shuffledCredits(credits, random = Math.random) {
|
||||
return credits.map(({ role, names }) => {
|
||||
const list = [...names];
|
||||
for (let i = list.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(random() * (i + 1));
|
||||
[list[i], list[j]] = [list[j], list[i]];
|
||||
}
|
||||
return { role, names: list };
|
||||
});
|
||||
}
|
||||
|
||||
export const sayTime = text => Math.max(1.6, 0.9 + text.length * 0.055);
|
||||
|
||||
export function newState(story) {
|
||||
|
||||
+13
-9
@@ -1,6 +1,6 @@
|
||||
// Avvio nel browser: collega motore, disegno e interfaccia HTML (verbi, inventario, dialoghi, fumetti).
|
||||
import { story } from './story/story.js';
|
||||
import { Game, VERBS, VERB_LABELS, checkSave, introText } from './engine/game.js';
|
||||
import { Game, VERBS, VERB_LABELS, checkSave, introText, shuffledCredits } from './engine/game.js';
|
||||
import { Command } from './engine/command.js';
|
||||
import { render, loadAssets, hasBackground, WIDTH, HEIGHT } from './engine/render.js';
|
||||
import { readSave, writeSave, clearSave, readAudio, writeAudio, saveFile, saveFileName, readSaveFile } from './engine/storage.js';
|
||||
@@ -100,14 +100,18 @@ function nextIntro() {
|
||||
$('intro').addEventListener('click', e => { if (e.target !== $('skip-intro')) nextIntro(); });
|
||||
$('skip-intro').addEventListener('click', () => { introLine = story.intro.length; nextIntro(); });
|
||||
|
||||
// --- Crediti: costruiti da story.credits; si aprono dal titolo e dalla fine, Chiudi o Esc tornano indietro.
|
||||
$('credits-list').replaceChildren(...(story.credits ?? []).flatMap(({ role, names }) => {
|
||||
const dt = document.createElement('dt'), dd = document.createElement('dd');
|
||||
dt.textContent = role;
|
||||
dd.replaceChildren(...names.map(n => Object.assign(document.createElement('span'), { textContent: n })));
|
||||
return [dt, dd];
|
||||
}));
|
||||
for (const b of document.querySelectorAll('.open-credits')) b.addEventListener('click', () => { $('credits').hidden = false; });
|
||||
// --- Crediti: costruiti da story.credits, con i nomi di ogni voce rimescolati a ogni apertura; si aprono dal titolo
|
||||
// e dalla fine, Chiudi o Esc tornano indietro.
|
||||
function openCredits() {
|
||||
$('credits-list').replaceChildren(...shuffledCredits(story.credits ?? []).flatMap(({ role, names }) => {
|
||||
const dt = document.createElement('dt'), dd = document.createElement('dd');
|
||||
dt.textContent = role;
|
||||
dd.replaceChildren(...names.map(n => Object.assign(document.createElement('span'), { textContent: n })));
|
||||
return [dt, dd];
|
||||
}));
|
||||
$('credits').hidden = false;
|
||||
}
|
||||
for (const b of document.querySelectorAll('.open-credits')) b.addEventListener('click', openCredits);
|
||||
$('close-credits').addEventListener('click', () => { $('credits').hidden = true; });
|
||||
|
||||
// --- Mappa: i posti visti e le strade fra loro; un clic su un posto ci porta (game.travel).
|
||||
|
||||
Reference in New Issue
Block a user