tooling: audit-state pause+resume paired, guard advance-while-paused
Audit bug: pause fired turn%12, no resume in same iter. nextTurn then called on paused encounter → threw 'Encounter not running'. Throw is correct feature behavior (nextTurn refuses when paused); audit misuse. Fix: togglePause twice (pause+resume) in one iteration, plus guard 'advance-while-paused' check before nextTurn call. Result: 6 audit artifacts → 0 violations / 100 rounds. Confirms BUG-1 resolved as side effect of BUG-2 dup-id fix. Replay verify: 10 rounds, 103 turns, no skip/dupe. TODO: BUG-1 + BUG-2 marked RESOLVED/FIXED.
This commit is contained in:
@@ -110,7 +110,10 @@ for (let roundN = 1; roundN <= ROUNDS; roundN++) {
|
||||
const np = makeParticipant({ id: `r${totalTurns}`, name:`R${totalTurns}`, type:'monster', initiative:9, maxHp:100, currentHp:100 });
|
||||
try { e = { ...e, ...addParticipant(e, np).patch }; } catch (err) {}
|
||||
}
|
||||
if (totalTurns % 12 === 0) { try { e = { ...e, ...togglePause(e).patch }; } catch (err) {} }
|
||||
if (totalTurns % 12 === 0) {
|
||||
try { e = { ...e, ...togglePause(e).patch }; } catch (err) {}
|
||||
try { e = { ...e, ...togglePause(e).patch }; } catch (err) {}
|
||||
}
|
||||
|
||||
// advance until round wraps or cap
|
||||
const cap = (e.participants.length + 4) * 2;
|
||||
@@ -118,6 +121,7 @@ for (let roundN = 1; roundN <= ROUNDS; roundN++) {
|
||||
const seenThisRound = [];
|
||||
while (e.round === startRound && guard < cap) {
|
||||
if (e.currentTurnParticipantId) seenThisRound.push(e.currentTurnParticipantId);
|
||||
if (e.isPaused) { check('advance-while-paused', false, 'paused at advance'); break; }
|
||||
let t;
|
||||
try { t = nextTurn(e); } catch (err) { check('nextTurn-throws', false, err.message); break; }
|
||||
e = { ...e, ...t.patch };
|
||||
|
||||
Reference in New Issue
Block a user