diff options
Diffstat (limited to 'internal/game/correct_audit_fixes_test.go')
| -rw-r--r-- | internal/game/correct_audit_fixes_test.go | 20 |
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", |
