From 7a15a5d70004b28bf2a710fa0f536af2446e5b17 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 5 Oct 2026 17:49:48 -0400 Subject: fix: production multi-step recipes, drop-weight validation, journal versioning --- internal/game/correct_audit_fixes_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 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 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", -- cgit v1.2.3