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:
+15
-1
@@ -3,7 +3,7 @@ import assert from 'node:assert/strict';
|
||||
import { backgroundOrder } from '../src/engine/render.js';
|
||||
import { story } from '../src/story/story.js';
|
||||
import { solution } from '../src/story/solution.js';
|
||||
import { Game, VERBS, checkSave, introText } from '../src/engine/game.js';
|
||||
import { Game, VERBS, checkSave, introText, shuffledCredits } from '../src/engine/game.js';
|
||||
import { inside } from '../src/engine/geometry.js';
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { settle } from './helpers.mjs';
|
||||
@@ -87,6 +87,20 @@ test('i crediti: ogni voce ha un ruolo e almeno un nome', () => {
|
||||
for (const name of ['Yuri Baldi', 'Francesco Bacci']) assert.ok(all.includes(name), `manca ${name}`);
|
||||
});
|
||||
|
||||
test('i crediti: i nomi di ogni voce escono in ordine casuale, sempre tutti', () => {
|
||||
const idee = story.credits.find(c => c.names.length >= 3).role;
|
||||
const orders = new Set();
|
||||
for (let seed = 1; seed <= 30; seed++) {
|
||||
let x = seed;
|
||||
const random = () => ((x = (x * 16807) % 2147483647) / 2147483647);
|
||||
const out = shuffledCredits(story.credits, random);
|
||||
assert.deepEqual(out.map(c => c.role), story.credits.map(c => c.role), 'le voci restano nel loro ordine');
|
||||
out.forEach((c, i) => assert.deepEqual([...c.names].sort(), [...story.credits[i].names].sort()));
|
||||
orders.add(out.find(c => c.role === idee).names.join('|'));
|
||||
}
|
||||
assert.ok(orders.size > 3, `${idee}: l'ordine non cambia`);
|
||||
});
|
||||
|
||||
test('la soluzione si percorre tutta dall\'inizio alla fine', () => {
|
||||
const saves = [];
|
||||
const g = new Game(story, { onSave: s => saves.push(s) });
|
||||
|
||||
Reference in New Issue
Block a user