diff options
Diffstat (limited to 'internal/game/cmd_trigger_enchant.go')
| -rw-r--r-- | internal/game/cmd_trigger_enchant.go | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/internal/game/cmd_trigger_enchant.go b/internal/game/cmd_trigger_enchant.go index 62a3c48..02c9755 100644 --- a/internal/game/cmd_trigger_enchant.go +++ b/internal/game/cmd_trigger_enchant.go @@ -72,23 +72,22 @@ func (g *Game) triggerChipBolts(sess *net.Session, p *player.Player, mod *ModDef return } + outputDef, _ := g.ItemStore.Load(chip.Output) + // Verify the output can be placed BEFORE consuming the bolts: never + // consume inputs into an inventory with nowhere to put the result. + if !craftOutputFits(p, chip.Output, outputDef) { + sess.WriteLine("Your inventory is too full!") + return + } + if p.Action != nil { g.cancelAction(p) } p.RemoveItem(chip.Input, chip.Qty) - placed := false - for i := 0; i < 28; i++ { - slot := p.InvSlot(i) - if slot != nil && slot.ItemID == chip.Output { - slot.Quantity += chip.Qty - placed = true - break - } - } - if !placed { - freeSlot := p.FirstFreeSlot() - p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: chip.Output, Quantity: chip.Qty}) + if !placeCraftOutput(p, chip.Output, outputDef, chip.Qty) { + sess.WriteLine("Your inventory is too full!") + return } g.triggerModReward(sess, p, mod, 1.0) |
