aboutsummaryrefslogtreecommitdiff
path: root/internal/game/production_engine.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-16 21:35:55 -0400
committerhistoria <[not public]>2026-09-16 21:35:55 -0400
commitfea2cc6839ec3ee17940a2dea69622dc6f4deabf (patch)
tree9d893525ca20d2cc920e9e866f84f71b605d8ae9 /internal/game/production_engine.go
parent35ddd0ad2215760bb1d3dc7724480f179ea33fa6 (diff)
downloadthehouseoficarus-fea2cc6839ec3ee17940a2dea69622dc6f4deabf.tar.gz
fix: unify crafting ingredient resolution; fix superheat alternatives, quantity gates, and dropped combine byproducts
Diffstat (limited to 'internal/game/production_engine.go')
-rw-r--r--internal/game/production_engine.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/internal/game/production_engine.go b/internal/game/production_engine.go
index 65c01b9..9643483 100644
--- a/internal/game/production_engine.go
+++ b/internal/game/production_engine.go
@@ -229,7 +229,7 @@ func (g *Game) advanceProduction(sess *net.Session, p *player.Player) bool {
for i := 0; i < 28; i++ {
slot := p.InvSlot(i)
if slot != nil && slot.ItemID == item.ID {
- consumeIngredients(craft, p.HasItem, p.RemoveItem)
+ consumeIngredients(craft, p.CountItem, p.RemoveItem)
slot.Quantity += outputQty
placed = true
break
@@ -237,7 +237,7 @@ func (g *Game) advanceProduction(sess *net.Session, p *player.Player) bool {
}
}
if !placed {
- consumeIngredients(craft, p.HasItem, p.RemoveItem)
+ consumeIngredients(craft, p.CountItem, p.RemoveItem)
freeSlot := p.FirstFreeSlot()
if freeSlot == -1 {
sess.WriteLine("Your inventory is too full!")
@@ -272,7 +272,7 @@ func (g *Game) advanceProduction(sess *net.Session, p *player.Player) bool {
}
sess.WriteLine(msg)
} else {
- consumeIngredients(craft, p.HasItem, p.RemoveItem)
+ consumeIngredients(craft, p.CountItem, p.RemoveItem)
if craft.Fail != "" {
freeSlot := p.FirstFreeSlot()
@@ -322,8 +322,14 @@ func (g *Game) collectByproducts(p *player.Player, item *item.ItemDef) []string
if len(e.Byproducts) == 0 {
continue
}
- for i, id := range e.Items {
- if p.HasItem(id) && i < len(e.Byproducts) && e.Byproducts[i] != "" {
+ // The byproduct must match the alternative that will actually be
+ // consumed (the same craftIngredientSource resolution
+ // consumeIngredients uses), not the first alternative merely
+ // present: with a bucket and a jug of water both in the inventory,
+ // consuming the bucket must return the empty bucket.
+ id, _ := craftIngredientSource(&e, p.CountItem)
+ for i, alt := range e.Items {
+ if alt == id && i < len(e.Byproducts) && e.Byproducts[i] != "" {
byproducts = append(byproducts, e.Byproducts[i])
break
}