diff options
Diffstat (limited to 'internal/game/production_engine.go')
| -rw-r--r-- | internal/game/production_engine.go | 16 |
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 } |
