From a5447965e7808d656a5e5d9326a9ca0231148f85 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 5 Oct 2026 19:30:49 -0400 Subject: feat: sym-link containment, batch count prompt for crafting --- internal/game/correct_audit_fixes_test.go | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'internal/game/correct_audit_fixes_test.go') diff --git a/internal/game/correct_audit_fixes_test.go b/internal/game/correct_audit_fixes_test.go index 6177eac..c32b1e5 100644 --- a/internal/game/correct_audit_fixes_test.go +++ b/internal/game/correct_audit_fixes_test.go @@ -1,6 +1,7 @@ package game import ( + "path/filepath" "testing" "thehouseoficarus/internal/behavior" @@ -126,6 +127,45 @@ func TestUsableCraftIndexSelectsSatisfiedRecipe(t *testing.T) { } } +// End-to-end gather: the missing coverage the audit called out. Start a mine +// action on a seeded rock with a pickaxe and tick it to a drop. +func TestGatherYieldsDrop(t *testing.T) { + h := newHarness(t) + h.seedAccount("alice") + p := h.seedCharacter("alice", "alice") + writeSeedFile(t, filepath.Join(h.dir, "objects", "copper_rock.yaml"), + []byte("id: copper_rock\nname: copper rock\ngather:\n skill: mining\n tools: [pickaxe]\n success: {base: 1, cap: 1}\n gather_message: You mine the rock.\n drops:\n - item_id: copper_ore\n weight: 100\n")) + writeSeedFile(t, filepath.Join(h.dir, "items", "pickaxe.yaml"), + []byte("id: pickaxe\nname: pickaxe\ntool:\n type: pickaxe\n speed: 1\n")) + writeSeedFile(t, filepath.Join(h.dir, "items", "copper_ore.yaml"), + []byte("id: copper_ore\nname: copper ore\nstackable: true\n")) + sess := &net.Session{Conn: newChanConn(), Player: p} + sess.SetState(net.StateGame) + h.g.RunOnOwner(func() { + h.g.ItemStore.Reload(h.dir) + h.g.ObjectStore.Reload(h.dir) + h.g.World.EnsureObjectStates(1, []string{"copper_rock"}) + p.SetInvSlot(0, &player.InventorySlot{ItemID: "pickaxe", Quantity: 1}) + obj, _, err := h.g.resolveObjectDef(1, "copper_rock") + if err != nil { + t.Fatalf("resolve object: %v", err) + } + st := h.g.World.GetObjState(1, "copper_rock", 0) + if st == nil { + t.Fatal("no object state after EnsureObjectStates") + } + h.g.startGather(sess, p, obj, st) + if p.Action == nil { + t.Fatalf("gather action did not start: %s", sess.Conn.(*chanConn).Bytes()) + } + h.g.advanceGather(sess, p) // step 0: announce + h.g.advanceGather(sess, p) // step 1: resolve the drop + if got := p.CountItem("copper_ore"); got == 0 { + t.Fatalf("gather yielded no ore (output: %s)", sess.Conn.(*chanConn).Bytes()) + } + }) +} + func TestPlayerDataFileNameCanonicalizesPrefixes(t *testing.T) { for _, in := range []string{ "players/characters/alice.yaml", -- cgit v1.2.3