aboutsummaryrefslogtreecommitdiff
path: root/internal/game/transport_safespot_regression_test.go
blob: fe779945148512fdb92b3cb78528cf135883d366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package game

import "testing"

// TestTransportClearsSafespot: the safespot predicates are room-agnostic, so a
// transport that changes rooms without clearing cover grants melee/hazard
// immunity in the destination and leaves a phantom occupant in the old room.
// Every other teleport path clears it; the transport effect must too.
func TestTransportClearsSafespot(t *testing.T) {
	h := newHarness(t)
	h.seedAccount("alice")
	h.seedCharacter("alice", "alice")
	sess, _ := h.connect("alice")

	h.g.RunOnOwner(func() {
		p := sess.Player
		h.g.safespot.Set(p.Name, SafespotState{Active: true, ObjectDefID: "rock", ObjectIndex: 0, RoomID: p.RoomID})
		if !h.g.isSafespotted(p.Name) {
			t.Fatal("safespot not active before transport")
		}

		h.g.executeTransportEffect(sess, p, &ModDef{ID: "test_transport", Name: "test shuttle", Destination: 2})

		if h.g.safespot.Has(p.Name) {
			t.Fatal("safespot state survived transport; hazard/melee immunity persists in the destination")
		}
		if h.g.isSafespotted(p.Name) {
			t.Fatal("player still counts as safespotted after transport")
		}
		if p.RoomID != 2 {
			t.Fatalf("room after transport = %d, want 2", p.RoomID)
		}
	})
}