Operator battle voices: the official combat lines play by voice slot during battles, one at a time (#73)

Deploy, skill and result lines come from the operators' official voice slots; a newer line takes the channel over (stale callbacks of the replaced line no longer release it), and the result line is spoken by an operator of the player's own battle. Contributed by @Convey123.
This commit is contained in:
Cartethyia authored and GitHub committed 2026-10-06 01:44:46 +08:00
1 parent 8774379d3b
commit 54cdad2602
22 files changed
+823 -49

No files matched your search

+18
View File
@@ -392,6 +392,24 @@ test('snapshot / event wire format (DESIGN §8.2)', () => {
JSON.stringify(snap); // serialisable
});
test('one ENGAGE per unit, on its first attack that hits an enemy (the client\'s 行动开始 voice)', () => {
const h = makeBattle({
defs: { chess: { t_guard: guard({ stats: { atk: 100, maxHp: 5000 } }) }, enemies: { enemy_walker: walker({ atk: 100, hp: 3000 }) } },
units: [{ chessId: 't_guard', row: 9, col: 5 }],
enemies: [{ key: 'enemy_walker' }], content: 'generic', fieldId: 'n:p1',
});
h.run(60); // the walker (0.5 tiles/s) reaches the guard at ~9 s and is attacked from then on
const id = h.unit('t_guard').id;
const engage = h.eventsOf(EV.ENGAGE);
assert.equal(engage.length, 1, 'one event for the whole battle');
assert.deepEqual(engage[0], ['engage', id]);
// it is emitted at the unit's first attack on an enemy — an earlier 命中的攻击 is impossible
const first = h.events.findIndex((e) => e[0] === 'engage');
const earlierAtk = h.events.slice(0, first).findIndex((e) => e[0] === 'atk' && e[1] === id);
assert.equal(earlierAtk, -1, 'no attack of that unit precedes it');
assert.ok(h.events.slice(first).some((e) => e[0] === 'atk' && e[1] === id), 'the attack it belongs to');
});
test('determinism: same seed ⇒ identical result and event stream; different seed may differ', () => {
const ds = getDefaultSource();
const tpl = ds.getWave('act1autochess_05');