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
+4 -6
View File
@@ -66,18 +66,16 @@ describe('undo + redo roundtrip', () => {
expect(snap(afterRedo)).toEqual(snap(newEnc));
});
test('togglePause', async () => {
test('togglePause excluded from undo (no log entry)', async () => {
const { storage, ctx } = mockCtx();
let e = enc([p('a',10),p('b',20)]);
e = await startEncounter(e, ctx);
await storage.setDoc(ctx.encPath, e);
const before = snap(e);
const newEnc = await togglePause(e, ctx);
const last = storage.logs().at(-1);
const afterUndo = await undoLast(ctx, newEnc);
expect(snap(afterUndo)).toEqual(before);
const afterRedo = await redoLast(ctx, afterUndo, last);
expect(snap(afterRedo)).toEqual(snap(newEnc));
// state flips (isPaused), but no log written
expect(newEnc.isPaused).toBe(true);
expect(storage.logs()).toHaveLength(1); // start only
});
test('applyHpChange damage restores HP on undo, re-applies on redo', async () => {