diff options
Diffstat (limited to 'internal/game/cmd_get.go')
| -rw-r--r-- | internal/game/cmd_get.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/internal/game/cmd_get.go b/internal/game/cmd_get.go index afd9ae6..d538afc 100644 --- a/internal/game/cmd_get.go +++ b/internal/game/cmd_get.go @@ -11,7 +11,10 @@ import ( func (g *Game) doGet(sess *net.Session, input string) { p := sess.Player g.cancelAction(p) - ground := g.World.GroundItems(p.RoomID) + // Only stock this player may actually take counts: entries reserved + // for another player are invisible to the pickup, so a blocked pickup + // can never half-remove the ground stack. + ground := g.World.AccessibleGround(p.RoomID, p.Name) if len(ground) == 0 { sess.WriteLine("There's nothing on the ground to pick up.") return @@ -75,11 +78,12 @@ func (g *Game) doGet(sess *net.Session, input string) { for i := 0; i < 28; i++ { slot := p.InvSlot(i) if slot != nil && slot.ItemID == itemID { - if _, ok := g.World.RemoveReservedItem(p.RoomID, itemID, qty, p.Name); !ok { + removed, ok := g.World.RemoveReservedItem(p.RoomID, itemID, qty, p.Name) + if !ok { sess.WriteLine("That's not yours!") return } - slot.Quantity += qty + slot.Quantity += removed g.AccountStore.SaveCharacter(p) sess.WriteLine(fmt.Sprintf("You pick up %d x %s. (now %d)", qty, g.itemColorize(sess, def, def.Name), slot.Quantity)) return @@ -130,7 +134,8 @@ func (g *Game) doGet(sess *net.Session, input string) { func (g *Game) doGetAllNamed(sess *net.Session, input string) { p := sess.Player g.cancelAction(p) - ground := g.World.GroundItems(p.RoomID) + // Only takeable stock counts (see doGet). + ground := g.World.AccessibleGround(p.RoomID, p.Name) if len(ground) == 0 { sess.WriteLine("There's nothing on the ground to pick up.") return @@ -252,7 +257,9 @@ func (g *Game) doGetAllNamed(sess *net.Session, input string) { func (g *Game) doGetAll(sess *net.Session) { p := sess.Player g.cancelAction(p) - ground := g.World.GroundItems(p.RoomID) + // Only takeable stock counts (see doGet); the all-or-nothing + // RemoveReservedItem then never aborts a partial pickup. + ground := g.World.AccessibleGround(p.RoomID, p.Name) if len(ground) == 0 { sess.WriteLine("There's nothing on the ground to pick up.") return |
