From 9666676766bf21364f4fc4d0d1d336e72f2a91b4 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 6 Oct 2026 12:57:23 -0400 Subject: refactor: split casino.go, dedup helpers, remove audit docs --- internal/combat/state_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'internal/combat/state_test.go') diff --git a/internal/combat/state_test.go b/internal/combat/state_test.go index 8005ba3..d21bc0d 100644 --- a/internal/combat/state_test.go +++ b/internal/combat/state_test.go @@ -19,3 +19,23 @@ func TestTrackerEnterReleasesPreviousMob(t *testing.T) { t.Fatal("mobB still marked in combat after leave") } } + +// Regression: two players claiming the same mob must not leave a dangling +// combatants entry for the displaced player; otherwise that player's later +// Leave deletes the new owner's mobTargets claim and unlocks a live fight. +func TestTrackerEnterDisplacesOtherPlayer(t *testing.T) { + tr := NewTracker() + tr.Enter("alice", "mobA") + tr.Enter("bob", "mobA") + if !tr.IsMobInCombat("mobA") { + t.Fatal("mobA should still be in combat after the second claim") + } + if tr.MobTarget("mobA") != "bob" { + t.Fatalf("mobTarget = %q, want bob", tr.MobTarget("mobA")) + } + // Alice was displaced; her leave must not unlock Bob's fight. + tr.Leave("alice") + if !tr.IsMobInCombat("mobA") || tr.MobTarget("mobA") != "bob" { + t.Fatal("alice's leave unlocked the mob bob is still fighting") + } +} -- cgit v1.2.3