aboutsummaryrefslogtreecommitdiff
path: root/internal/combat/state_test.go
blob: 8005ba378c76ab787e1d4ad5d017432029c45082 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package combat

import "testing"

// Regression: re-entering combat must release the previous mob, or that mob
// stays "in combat" forever and no other player can attack it.
func TestTrackerEnterReleasesPreviousMob(t *testing.T) {
	tr := NewTracker()
	tr.Enter("alice", "mobA")
	tr.Enter("alice", "mobB")
	if tr.IsMobInCombat("mobA") {
		t.Fatal("mobA still marked in combat after alice switched targets")
	}
	if !tr.IsMobInCombat("mobB") {
		t.Fatal("mobB not marked in combat")
	}
	tr.Leave("alice")
	if tr.IsMobInCombat("mobB") {
		t.Fatal("mobB still marked in combat after leave")
	}
}