import test from 'node:test'; import assert from 'node:assert/strict'; import { existsSync, readFileSync } from 'node:fs'; import { Game } from '../src/engine/game.js'; import { story } from '../src/story/story.js'; import { settle } from './helpers.mjs'; test('Baldoria al campo principale: ogni tanto sventola il bandierone, sennò sta fermo', () => { const g = new Game(story); g.go('polisportiva_principale'); settle(g); const p = g.people().find(p => p.who === 'baldoria'); assert.ok(p, 'Baldoria è in scena'); const poses = new Set(); for (let t = 0; t < 9; t += 0.05) { g.time = t; poses.add(g.personPose(p)); } assert.ok(poses.has('wave') && poses.has('wave2') && poses.has('stand') && poses.has('blink')); g.time = 3; assert.equal(g.personPose(p), 'stand', 'fuori dallo sventolio, fermo'); const sheet = JSON.parse(readFileSync(new URL('../assets/characters/baldoria.json', import.meta.url))); for (const f of ['stand', 'blink', 'talk', 'explain', 'wave', 'wave2', 'cheer', 'laugh']) assert.ok(sheet.frames[f], f); assert.ok(existsSync(new URL('../assets/characters/baldoria.png', import.meta.url))); }); test('si parla con Baldoria: le risposte e il saluto', () => { const g = new Game(story); g.go('polisportiva_principale'); settle(g); g.act('talk', 'baldoria'); settle(g); assert.equal(g.dialogue?.id, 'baldoria'); const said = []; for (const text of ['Baldoria! Ma che ci fai col bandierone al campo?', 'Guarda che qui la Sampdoria non ci gioca.', 'Hai visto passare il palio, per caso?']) { g.choose(g.options().findIndex(o => o.text === text)); said.push(...settle(g).filter(s => s.who === 'baldoria').map(s => s.text)); } assert.ok(said.includes('Forza Doria!')); assert.equal(said.length, 4); g.choose(g.options().findIndex(o => o.text === 'Ciao, Baldoria.')); settle(g); assert.equal(g.dialogue, null); });