diff options
| author | historia <[not public]> | 2026-10-06 12:57:23 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-06 12:57:23 -0400 |
| commit | 9666676766bf21364f4fc4d0d1d336e72f2a91b4 (patch) | |
| tree | 0cade34091d7602790dc38cd44053f0b74bbadf2 /internal/combat/state_test.go | |
| parent | 4bc1daaf259e0c19c5fe4a12ec8bc7f6e5a735c1 (diff) | |
| download | thehouseoficarus-9666676766bf21364f4fc4d0d1d336e72f2a91b4.tar.gz | |
refactor: split casino.go, dedup helpers, remove audit docs
Diffstat (limited to 'internal/combat/state_test.go')
| -rw-r--r-- | internal/combat/state_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
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") + } +} |
