aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_get.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/cmd_get.go')
-rw-r--r--internal/game/cmd_get.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/internal/game/cmd_get.go b/internal/game/cmd_get.go
index 515d2ab..7a5181f 100644
--- a/internal/game/cmd_get.go
+++ b/internal/game/cmd_get.go
@@ -270,8 +270,10 @@ func (g *Game) doGetAll(sess *net.Session) {
continue
}
if itemID == "credits" {
- taken, ok := g.World.RemoveReservedItem(p.RoomID, itemID, 999999, p.Name)
- if !ok {
+ // Same capped-removal rule as pickupCredits: the request is a
+ // sentinel above any possible stock, not an exact quantity.
+ taken := g.World.RemoveAvailableItem(p.RoomID, itemID, 999999, p.Name)
+ if taken <= 0 {
continue
}
p.Credits += taken
@@ -368,11 +370,11 @@ func (g *Game) doGetAll(sess *net.Session) {
}
func (g *Game) pickupCredits(sess *net.Session, p *player.Player, itemID string) {
- qty, ok := g.World.RemoveReservedItem(p.RoomID, itemID, 999999, p.Name)
- if !ok {
- sess.WriteLine("That's not yours!")
- return
- }
+ // Take whatever credits are accessible: a sentinel quantity far above
+ // any possible stock. RemoveReservedItem is all-or-nothing and would
+ // reject a request larger than the stack; RemoveAvailableItem caps the
+ // removal at what is actually on the ground.
+ qty := g.World.RemoveAvailableItem(p.RoomID, itemID, 999999, p.Name)
if qty <= 0 {
return
}