tests: scenario rotation integrity check (every 10 rounds)
Combat.scenario.test.js: per-10-round assertion - turnOrderIds no dup, currentTurnParticipantId in turnOrderIds. 299/299 phases pass. NOTE: scenario runs against firebase MOCK. Mock updateDoc merges correctly (real ws adapter would clobber per BUG-4 class). So check validates mock shape, not adapter translation. Layer 2 (ws-contract) covers adapter.
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user