Exclude pause/resume from undo; fix verify round-wrap false positive

togglePause no longer writes log entry (shared/turn.js). Lifecycle op, not
player action. Undo stack now targets last real action, not flag flip.
Removed dead pause/resume cases from expandUndo.

verify.js false positive: round wrap via non-nextTurn event (removeParticipant)
not detected — cycleActed never reset, actors flagged as acted_twice. Fix:
detect round change on ANY event, drain removed/inactive before finalize
(avoids false skipped when actor removed mid-round).

Tests updated: togglePause logging test asserts no log; undo test asserts
excluded. Repro confirmed via minimal verify case (removeParticipant r1->r2).
This commit is contained in:
david raistrick
2026-07-06 18:30:51 -04:00
parent 2c997de0da
commit bf1fccfd3b
4 changed files with 21 additions and 25 deletions
+3 -15
View File
@@ -304,14 +304,6 @@ function expandUndo(entry, currentEnc) {
redo: { currentTurnParticipantId: snap.currentTurnParticipantId, round: snap.round, turnOrderIds: snap.turnOrderIds || [] },
};
}
case 'pause':
case 'resume': {
return {
encounterPath: encPath,
updates: { isPaused: u.isPaused },
redo: { isPaused: !u.isPaused },
};
}
case 'start_encounter':
case 'end_encounter': {
return {
@@ -456,13 +448,9 @@ async function togglePause(encounter, ctx) {
if (!encounter || !encounter.isStarted) throw new Error('Encounter not started.');
const newPausedState = !encounter.isPaused;
const patch = { isPaused: newPausedState, turnOrderIds: encounter.turnOrderIds };
const log = {
type: newPausedState ? 'pause' : 'resume',
message: `Combat ${newPausedState ? 'paused' : 'resumed'}: "${encounter.name}"`,
delta: { paused: newPausedState },
undo: { isPaused: encounter.isPaused ?? false },
};
return commit(encounter, patch, log, ctx);
// Lifecycle op: no log entry. Pause/resume excluded from undo stack so DM
// undo targets the last player action (damage/condition/etc), not a flag flip.
return commit(encounter, patch, null, ctx);
}
async function addParticipant(encounter, participant, ctx) {