diff options
| author | historia <[not public]> | 2026-09-16 21:35:55 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-16 21:35:55 -0400 |
| commit | fea2cc6839ec3ee17940a2dea69622dc6f4deabf (patch) | |
| tree | 9d893525ca20d2cc920e9e866f84f71b605d8ae9 /internal/game/cmd_trigger_utility.go | |
| parent | 35ddd0ad2215760bb1d3dc7724480f179ea33fa6 (diff) | |
| download | thehouseoficarus-fea2cc6839ec3ee17940a2dea69622dc6f4deabf.tar.gz | |
fix: unify crafting ingredient resolution; fix superheat alternatives, quantity gates, and dropped combine byproducts
Diffstat (limited to 'internal/game/cmd_trigger_utility.go')
| -rw-r--r-- | internal/game/cmd_trigger_utility.go | 39 |
1 files changed, 24 insertions, 15 deletions
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}) } |
