diff options
Diffstat (limited to 'internal/game/transport_safespot_regression_test.go')
| -rw-r--r-- | internal/game/transport_safespot_regression_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/game/transport_safespot_regression_test.go b/internal/game/transport_safespot_regression_test.go new file mode 100644 index 0000000..fe77994 --- /dev/null +++ b/internal/game/transport_safespot_regression_test.go @@ -0,0 +1,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) + } + }) +} |
