From fea2cc6839ec3ee17940a2dea69622dc6f4deabf Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 16 Sep 2026 21:35:55 -0400 Subject: fix: unify crafting ingredient resolution; fix superheat alternatives, quantity gates, and dropped combine byproducts --- internal/game/cmd_trigger_utility.go | 39 ++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'internal/game/cmd_trigger_utility.go') diff --git a/internal/game/cmd_trigger_utility.go b/internal/game/cmd_trigger_utility.go index ca65445..09eabb1 100644 --- a/internal/game/cmd_trigger_utility.go +++ b/internal/game/cmd_trigger_utility.go @@ -187,29 +187,34 @@ func (g *Game) triggerSuperheat(sess *net.Session, p *player.Player, mod *ModDef return } - for _, e := range c.Ingredients { - for _, itemID := range e.Items { - qty := e.Quantity - if qty <= 0 { - qty = 1 - } - if p.CountItem(itemID) < qty { - def, _ := g.ItemStore.Load(itemID) - name := itemID - if def != nil { - name = def.Name - } - sess.WriteLine(fmt.Sprintf("You need %d %s.", qty, name)) - return + // Availability resolves each entry the way consumeIngredients will: ONE + // listed alternative must cover the entry's full quantity. The previous + // hand-rolled loop required EVERY listed alternative, e.g. both a + // bucket AND a jug of water to superheat clay, and could not name the + // missing choice. + for i := range c.Ingredients { + id, qty := craftIngredientSource(&c.Ingredients[i], p.CountItem) + if id != "" { + continue + } + names := make([]string, 0, len(c.Ingredients[i].Items)) + for _, itemID := range c.Ingredients[i].Items { + def, _ := g.ItemStore.Load(itemID) + name := itemID + if def != nil { + name = def.Name } + names = append(names, fmt.Sprintf("%d %s", qty, name)) } + sess.WriteLine(fmt.Sprintf("You need one of: %s.", strings.Join(names, " or "))) + return } if p.Action != nil { g.cancelAction(p) } - consumeIngredients(c, p.HasItem, p.RemoveItem) + consumeIngredients(c, p.CountItem, p.RemoveItem) outputQty := c.OutputQty if outputQty <= 0 { @@ -226,6 +231,10 @@ func (g *Game) triggerSuperheat(sess *net.Session, p *player.Player, mod *ModDef } if !placed { freeSlot := p.FirstFreeSlot() + if freeSlot < 0 { + sess.WriteLine("Your inventory is too full!") + return + } p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: match.ID, Quantity: outputQty}) } -- cgit v1.2.3