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

@@ -16,9 +16,9 @@ type pact struct {
// quaff drinks a potion from the pack (potions.c quaff).
func (g *RogueGame) quaff() {
p := &g.Player
obj := g.getItem("quaff", KindPotion)
obj, ok := g.promptPackItem("quaff", KindPotion)
// Make certain that it is something that we want to drink
if obj == nil {
if !ok {
return
}
@@ -43,7 +43,7 @@ func (g *RogueGame) quaff() {
switch obj.PotionKind() {
case PotionConfusion:
g.doPot(PotionConfusion, !trip)
g.applyPotionFuse(PotionConfusion, !trip)
case PotionPoison:
g.Items.Potions[PotionPoison].Know = true
if p.IsWearing(RingSustainStrength) {
@@ -118,11 +118,11 @@ func (g *RogueGame) quaff() {
g.SeenStairs = g.seenStairs()
}
g.doPot(PotionLSD, true)
g.applyPotionFuse(PotionLSD, true)
case PotionSeeInvisible:
show := p.On(CanSeeInvisible)
g.doPot(PotionSeeInvisible, false)
g.applyPotionFuse(PotionSeeInvisible, false)
if !show {
g.invisOn()
@@ -177,9 +177,9 @@ func (g *RogueGame) quaff() {
g.msg("hey, this tastes great. It make you feel warm all over")
case PotionBlindness:
g.doPot(PotionBlindness, true)
g.applyPotionFuse(PotionBlindness, true)
case PotionLevitation:
g.doPot(PotionLevitation, true)
g.applyPotionFuse(PotionLevitation, true)
}
g.status()
@@ -194,9 +194,9 @@ func (g *RogueGame) raiseLevel() {
g.checkLevel()
}
// doPot does a potion with standard setup: it uses a fuse and turns on a
// flag (potions.c do_pot).
func (g *RogueGame) doPot(kind PotionKind, knowit bool) {
// applyPotionFuse does a potion with standard setup: it uses a fuse and
// turns on a flag (potions.c do_pot).
func (g *RogueGame) applyPotionFuse(kind PotionKind, knowit bool) {
pp := &g.data.pActions[kind]
if !g.Items.Potions[kind].Know {
g.Items.Potions[kind].Know = knowit