diff --git a/src/tests/Combat.scenario.test.js b/src/tests/Combat.scenario.test.js index 1867cea..e9285aa 100644 --- a/src/tests/Combat.scenario.test.js +++ b/src/tests/Combat.scenario.test.js @@ -256,6 +256,22 @@ test('full 100-round combat scenario', async () => { for (let r = 1; r <= ROUNDS; r++) { await recordAsync(`round ${r} nextTurn`, () => nextTurn()); + // rotation integrity: turnOrderIds no dup, currentTurn valid + if (r % 10 === 0) { + record(`round ${r} rotation-check`, () => { + const enc = currentEncDoc(); + if (!enc) throw new Error('no encounter doc'); + const order = enc.turnOrderIds || []; + const uniq = new Set(order); + if (uniq.size !== order.length) { + throw new Error(`turnOrderIds dup: ${JSON.stringify(order)}`); + } + if (enc.currentTurnParticipantId && !order.includes(enc.currentTurnParticipantId)) { + throw new Error(`currentTurn ${enc.currentTurnParticipantId} not in turnOrderIds`); + } + }); + } + // damage front monster every other round if (r % 2 === 0) record(`round ${r} damage OrcBoss`, () => applyDamage('OrcBoss', 3)); if (r % 3 === 0) record(`round ${r} heal Cleric`, () => applyHeal('Cleric', 2));