From c054b27f628f23fecc505b9e09e78721738f3c4e Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 16 Sep 2026 13:52:58 -0400 Subject: fix: shutdown admission, recovery identity/order, rollback journal retention, pickup merge --- internal/game/inventory_pickup_test.go | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 internal/game/inventory_pickup_test.go (limited to 'internal/game/inventory_pickup_test.go') diff --git a/internal/game/inventory_pickup_test.go b/internal/game/inventory_pickup_test.go new file mode 100644 index 0000000..a0d267e --- /dev/null +++ b/internal/game/inventory_pickup_test.go @@ -0,0 +1,55 @@ +package game + +// Regression: picking up a stackable item must merge into an existing stack +// even when every inventory slot is occupied — capacity is required only +// when a NEW slot is needed, matching the get-all paths. + +import ( + "path/filepath" + "testing" + + "thehouseoficarus/internal/net" + "thehouseoficarus/internal/player" +) + +func TestPickupMergesIntoFullInventory(t *testing.T) { + h := newHarness(t) + h.seedAccount("alice", "pw", false) + p := h.seedCharacter("alice", "alice") + writeSeedFile(t, filepath.Join(h.dir, "items", "chips.yaml"), []byte("id: chips\nname: chips\nstackable: true\n")) + sess := &net.Session{Conn: newChanConn(), Player: p, State: net.StateGame} + h.g.RunOnOwner(func() { + h.g.ItemStore.Reload(h.dir) + for i := 0; i < 28; i++ { + p.SetInvSlot(i, &player.InventorySlot{ItemID: "filler", Quantity: 1}) + } + p.SetInvSlot(0, &player.InventorySlot{ItemID: "chips", Quantity: 10}) + h.g.World.AddGroundItem(1, "chips", 5) + h.g.doGet(sess, "chips") + if got := countChips(p); got != 15 { + t.Errorf("pickup rejected despite existing chip stack: have %d, want 15", got) + } + }) +} + +func TestPickupFullInventoryWithoutStackStillRefused(t *testing.T) { + h := newHarness(t) + h.seedAccount("alice", "pw", false) + p := h.seedCharacter("alice", "alice") + writeSeedFile(t, filepath.Join(h.dir, "items", "chips.yaml"), []byte("id: chips\nname: chips\nstackable: true\n")) + sess := &net.Session{Conn: newChanConn(), Player: p, State: net.StateGame} + h.g.RunOnOwner(func() { + h.g.ItemStore.Reload(h.dir) + for i := 0; i < 28; i++ { + p.SetInvSlot(i, &player.InventorySlot{ItemID: "filler", Quantity: 1}) + } + h.g.World.AddGroundItem(1, "chips", 5) + h.g.doGet(sess, "chips") + if got := countChips(p); got != 0 { + t.Errorf("pickup without an existing stack must be refused, have %d", got) + } + if got := h.g.World.GroundItems(1)["chips"]; got != 5 { + t.Errorf("refused pickup must leave the ground stack intact, have %d", got) + } + }) +} -- cgit v1.2.3