Rename item-subsystem methods (refactor step 5, items)

getItem→promptPackItem now returns (obj, ok) instead of a nil-signaling
pointer; invName→inventoryName; doPot→applyPotionFuse. C breadcrumbs
kept. Behavior unchanged; suite green.
This commit is contained in:
2026-07-07 02:31:38 +02:00
parent 0554f5d4f1
commit 6d798c56ed
14 changed files with 57 additions and 56 deletions

View File

@@ -137,7 +137,7 @@ func (g *RogueGame) addPack(obj *Object, silent bool) {
g.addmsgf("you now have ")
}
g.msg("%s (%c)", g.invName(obj, !g.Options.Terse), obj.PackCh)
g.msg("%s (%c)", g.inventoryName(obj, !g.Options.Terse), obj.PackCh)
}
}
@@ -236,7 +236,7 @@ func (g *RogueGame) inventory(list []*Object, kind ObjectKind) bool {
g.NObjs++
g.Msgs.MsgEsc = true
line := string(item.PackCh) + ") " + g.invName(item, false)
line := string(item.PackCh) + ") " + g.inventoryName(item, false)
if g.addLine("%s", line) == Escape {
g.Msgs.MsgEsc = false
g.msg("")
@@ -323,7 +323,7 @@ func (g *RogueGame) moveMsg(obj *Object) {
g.addmsgf("you ")
}
g.msg("moved onto %s", g.invName(obj, true))
g.msg("moved onto %s", g.inventoryName(obj, true))
}
// pickyInven allows the player to inventory a single item (pack.c
@@ -337,7 +337,7 @@ func (g *RogueGame) pickyInven() {
}
if len(p.Pack) == 1 {
g.msg("a) %s", g.invName(p.Pack[0], false))
g.msg("a) %s", g.inventoryName(p.Pack[0], false))
return
}
@@ -354,7 +354,7 @@ func (g *RogueGame) pickyInven() {
for _, obj := range p.Pack {
if mch == obj.PackCh {
g.msg("%c) %s", mch, g.invName(obj, false))
g.msg("%c) %s", mch, g.inventoryName(obj, false))
return
}
@@ -363,23 +363,24 @@ func (g *RogueGame) pickyInven() {
g.msg("'%s' not in pack", unctrl(mch))
}
// getItem picks something out of a pack for a purpose (pack.c get_item).
func (g *RogueGame) getItem(purpose string, kind ObjectKind) *Object {
// promptPackItem picks something out of a pack for a purpose (pack.c
// get_item); ok reports whether the player chose an item.
func (g *RogueGame) promptPackItem(purpose string, kind ObjectKind) (obj *Object, ok bool) {
p := &g.Player
if len(p.Pack) == 0 {
g.msg("you aren't carrying anything")
return nil
return nil, false
}
if g.Again {
if g.LastPick != nil {
return g.LastPick
return g.LastPick, true
}
g.msg("you ran out")
return nil
return nil, false
}
for {
@@ -402,7 +403,7 @@ func (g *RogueGame) getItem(purpose string, kind ObjectKind) *Object {
g.After = false
g.msg("")
return nil
return nil, false
}
g.NObjs = 1 // normal case: person types one char
@@ -411,7 +412,7 @@ func (g *RogueGame) getItem(purpose string, kind ObjectKind) *Object {
if !g.inventory(p.Pack, kind) {
g.After = false
return nil
return nil, false
}
continue
@@ -419,7 +420,7 @@ func (g *RogueGame) getItem(purpose string, kind ObjectKind) *Object {
for _, obj := range p.Pack {
if obj.PackCh == ch {
return obj
return obj, true
}
}