From 1aba2bdd23aebed4032333e74aa553c40a31fcbd Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sun, 14 Jun 2026 21:07:26 -0400 Subject: refactor: added docs, split up some components in game package --- internal/game/cmd_get.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'internal/game/cmd_get.go') diff --git a/internal/game/cmd_get.go b/internal/game/cmd_get.go index f4c7426..78a9621 100644 --- a/internal/game/cmd_get.go +++ b/internal/game/cmd_get.go @@ -73,12 +73,10 @@ 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 { - removed, ok := g.World.RemoveReservedGroundItem(p.RoomID, itemID, qty, p.Name) - if !ok { + if _, ok := g.World.RemoveReservedGroundItem(p.RoomID, itemID, qty, p.Name); !ok { sess.WriteLine("That's not yours!") return } - _ = removed slot.Quantity += qty g.AccountStore.SaveCharacter(p) sess.WriteLine(fmt.Sprintf("You pick up %d x %s. (now %d)", qty, def.Name, slot.Quantity)) @@ -90,13 +88,11 @@ func (g *Game) doGet(sess *net.Session, input string) { sess.WriteLine("Your inventory is full.") return } - removed, ok := g.World.RemoveReservedGroundItem(p.RoomID, itemID, qty, p.Name) - if !ok { + if _, ok := g.World.RemoveReservedGroundItem(p.RoomID, itemID, qty, p.Name); !ok { sess.WriteLine("That's not yours!") return } - _ = removed - p.SetInvSlot(freeSlot, g.newInvSlot(itemID, qty)) + p.SetInvSlot(freeSlot, g.newInventorySlot(itemID, qty)) g.AccountStore.SaveCharacter(p) if qty == 1 { sess.WriteLine(fmt.Sprintf("You pick up a %s.", def.Name)) @@ -112,11 +108,9 @@ func (g *Game) doGet(sess *net.Session, input string) { if fs == -1 { break } - removed, ok := g.World.RemoveReservedGroundItem(p.RoomID, itemID, 1, p.Name) - if !ok { + if _, ok := g.World.RemoveReservedGroundItem(p.RoomID, itemID, 1, p.Name); !ok { break } - _ = removed p.SetInvSlot(fs, &player.InventorySlot{ItemID: itemID, Quantity: 1}) picked++ } @@ -318,7 +312,7 @@ func (g *Game) doGetAll(sess *net.Session) { if freeSlot == -1 { if len(picked) > 0 { sess.WriteLine("You can't hold everything but you picked up:") - innerPickupReport(sess, picked) + formatPickupList(sess, picked) } else { sess.WriteLine("Your inventory is full!") } @@ -329,7 +323,7 @@ func (g *Game) doGetAll(sess *net.Session) { if !ok { break } - p.SetInvSlot(freeSlot, g.newInvSlot(itemID, qty)) + p.SetInvSlot(freeSlot, g.newInventorySlot(itemID, qty)) name := itemID if def != nil { name = def.Name @@ -342,7 +336,7 @@ func (g *Game) doGetAll(sess *net.Session) { if freeSlot == -1 { if len(picked) > 0 { sess.WriteLine("You can't hold everything but you picked up:") - innerPickupReport(sess, picked) + formatPickupList(sess, picked) } else { sess.WriteLine("Your inventory is full!") } @@ -371,7 +365,7 @@ func (g *Game) doGetAll(sess *net.Session) { sess.WriteLine("Your inventory is full.") } else { sess.Write("You picked up: ") - innerPickupReport(sess, picked) + formatPickupList(sess, picked) } } -- cgit v1.2.3