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) } }