From 8fe9e3c3fef0049df82281a62afe35dda516dfe2 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 18 Sep 2026 17:48:26 -0400 Subject: fix: close combat ghost, admin traversal, login throttle, journal double-pay, and quality/economy gaps --- internal/world/ground_quality_test.go | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 internal/world/ground_quality_test.go (limited to 'internal/world/ground_quality_test.go') diff --git a/internal/world/ground_quality_test.go b/internal/world/ground_quality_test.go new file mode 100644 index 0000000..e287642 --- /dev/null +++ b/internal/world/ground_quality_test.go @@ -0,0 +1,43 @@ +package world + +import "testing" + +// TestGroundPreservesQualityAcrossDropAndPickup pins the deferred item-quality +// fix: a partially-used max_quality item dropped on the ground must not come +// back at full quality when picked up. +func TestGroundPreservesQualityAcrossDropAndPickup(t *testing.T) { + w := New(t.TempDir()) + w.AddGroundItemQ(1, "lighter", 1, 42, 100) + + if q, mq, ok := w.AccessibleGroundQuality(1, "lighter", "alice"); !ok || q != 42 || mq != 100 { + t.Fatalf("ground quality = (%d,%d,%v), want (42,100,true)", q, mq, ok) + } + removed, q, mq, ok := w.RemoveReservedItemQ(1, "lighter", 1, "alice") + if !ok || removed != 1 || q != 42 || mq != 100 { + t.Fatalf("pickup = (%d,%d,%d,%v), want (1,42,100,true)", removed, q, mq, ok) + } +} + +// TestGroundMergeRequiresMatchingQuality: a full-quality spawn stack must not +// absorb a used player-dropped stack (which would erase the charge). +func TestGroundMergeRequiresMatchingQuality(t *testing.T) { + w := New(t.TempDir()) + w.AddGroundItemQ(1, "lighter", 1, 100, 100) + w.AddGroundItemQ(1, "lighter", 1, 20, 100) + if got := len(w.GroundItemsDetailed(1)); got != 2 { + t.Fatalf("distinct-quality entries merged: %d entries, want 2", got) + } +} + +// TestRemoveGroundItemSkipsReserved: the firemaking helper has no owner, so it +// must never consume another player's reserved loot. +func TestRemoveGroundItemSkipsReserved(t *testing.T) { + w := New(t.TempDir()) + w.AddReservedItem(1, "log", 3, "bob") + if got := w.RemoveGroundItem(1, "log", 3); got != 0 { + t.Fatalf("RemoveGroundItem consumed a reserved stack: took %d", got) + } + if got := w.AccessibleGround(1, "bob")["log"]; got != 3 { + t.Fatalf("bob's reserved stock = %d, want 3", got) + } +} -- cgit v1.2.3