aboutsummaryrefslogtreecommitdiff
path: root/internal/game/correct_audit_fixes_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-05 17:49:48 -0400
committerhistoria <[not public]>2026-10-05 17:49:48 -0400
commit7a15a5d70004b28bf2a710fa0f536af2446e5b17 (patch)
tree920705853f79bb13a65fcb2f89cee38e6f2efab8 /internal/game/correct_audit_fixes_test.go
parentec703a39738fefb60817f5659f76f8e683f8d301 (diff)
downloadthehouseoficarus-7a15a5d70004b28bf2a710fa0f536af2446e5b17.tar.gz
fix: production multi-step recipes, drop-weight validation, journal versioning
Diffstat (limited to 'internal/game/correct_audit_fixes_test.go')
-rw-r--r--internal/game/correct_audit_fixes_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/game/correct_audit_fixes_test.go b/internal/game/correct_audit_fixes_test.go
index 681843c..6177eac 100644
--- a/internal/game/correct_audit_fixes_test.go
+++ b/internal/game/correct_audit_fixes_test.go
@@ -7,6 +7,7 @@ import (
"thehouseoficarus/internal/casino"
"thehouseoficarus/internal/item"
"thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
"thehouseoficarus/internal/prediction"
)
@@ -106,6 +107,25 @@ func TestPickupCreditsHonorsRequestedQuantity(t *testing.T) {
// Regression: the player-file classifier must canonicalize repeated "/" and
// "data/" prefixes so a raw-editor path cannot dodge the online check.
+// Regression: availability scans every recipe, but execution used Craft[0], so
+// a player satisfying a later recipe (e.g. oak arrow shafts) got a start-then-
+// abort. usableCraftIndex must pick the satisfied recipe.
+func TestUsableCraftIndexSelectsSatisfiedRecipe(t *testing.T) {
+ g := &Game{}
+ p := player.New("alice")
+ def := &item.ItemDef{
+ ID: "arrow_shaft",
+ Craft: item.CraftList{
+ {Type: "fletching", Level: 1, Ingredients: []item.IngredientEntry{{Items: []string{"logs"}, Quantity: 1}}},
+ {Type: "fletching", Level: 1, Ingredients: []item.IngredientEntry{{Items: []string{"oak_logs"}, Quantity: 1}}},
+ },
+ }
+ p.SetInvSlot(0, &player.InventorySlot{ItemID: "oak_logs", Quantity: 5})
+ if idx := g.usableCraftIndex(p, def); idx != 1 {
+ t.Fatalf("usableCraftIndex = %d, want 1 (the satisfied oak recipe)", idx)
+ }
+}
+
func TestPlayerDataFileNameCanonicalizesPrefixes(t *testing.T) {
for _, in := range []string{
"players/characters/alice.yaml",