aboutsummaryrefslogtreecommitdiff
path: root/internal/game/act_combine.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-17 22:00:33 -0400
committerhistoria <[not public]>2026-09-17 22:00:33 -0400
commit32a3c59cebf2a16277e54d715a67adfdbe00b456 (patch)
tree9bc87011513ef92f0613d9339fc55689f130915d /internal/game/act_combine.go
parentfea2cc6839ec3ee17940a2dea69622dc6f4deabf (diff)
downloadthehouseoficarus-32a3c59cebf2a16277e54d715a67adfdbe00b456.tar.gz
fix: exact casino settlement/refund coverage, journal damage handling, craft output ordering, aggregate ingredient planning
Diffstat (limited to 'internal/game/act_combine.go')
-rw-r--r--internal/game/act_combine.go35
1 files changed, 15 insertions, 20 deletions
diff --git a/internal/game/act_combine.go b/internal/game/act_combine.go
index bc9b6de..b16cf7a 100644
--- a/internal/game/act_combine.go
+++ b/internal/game/act_combine.go
@@ -100,6 +100,15 @@ func (g *Game) advanceCombine(sess *net.Session, p *player.Player) {
return
}
+ // A full inventory must never destroy materials: verify the output
+ // can be placed BEFORE collecting byproducts and consuming.
+ outDef, _ := g.ItemStore.Load(item.ID)
+ if !craftOutputFits(p, item.ID, outDef) {
+ sess.WriteLine("Your inventory is too full!")
+ g.cancelAction(p)
+ return
+ }
+
// Byproducts must be collected BEFORE consumption: the resolver maps
// each ingredient entry to the alternative actually being consumed
// (bucket vs jug of water), which requires the items still present.
@@ -112,26 +121,12 @@ func (g *Game) advanceCombine(sess *net.Session, p *player.Player) {
outputQty = 1
}
- outDef, _ := g.ItemStore.Load(item.ID)
- placed := false
- if outDef != nil && outDef.Stackable {
- for i := 0; i < 28; i++ {
- slot := p.InvSlot(i)
- if slot != nil && slot.ItemID == item.ID {
- slot.Quantity += outputQty
- placed = true
- break
- }
- }
- }
- if !placed {
- freeSlot := p.FirstFreeSlot()
- if freeSlot == -1 {
- sess.WriteLine("Your inventory is too full!")
- g.cancelAction(p)
- return
- }
- p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: item.ID, Quantity: outputQty})
+ if !placeCraftOutput(p, item.ID, outDef, outputQty) {
+ // Defensive: the fits check above should have guaranteed a
+ // stack or slot.
+ sess.WriteLine("Your inventory is too full!")
+ g.cancelAction(p)
+ return
}
// Return the empty containers (and any other byproducts) alongside