aboutsummaryrefslogtreecommitdiff
path: root/internal/game/correct_audit_fixes_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-05 19:30:49 -0400
committerhistoria <[not public]>2026-10-05 19:30:49 -0400
commita5447965e7808d656a5e5d9326a9ca0231148f85 (patch)
tree618d46ccf2119658d0a6cc9e7b7a27fd75c0fee0 /internal/game/correct_audit_fixes_test.go
parent1091d0fae96d152c11aec1bb2dd949f51ed5aa1e (diff)
downloadthehouseoficarus-a5447965e7808d656a5e5d9326a9ca0231148f85.tar.gz
feat: sym-link containment, batch count prompt for crafting
Diffstat (limited to 'internal/game/correct_audit_fixes_test.go')
-rw-r--r--internal/game/correct_audit_fixes_test.go40
1 files changed, 40 insertions, 0 deletions
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",