Decompose ObjectKind.String and doMotion (refactor step 7)

String's tail moves into stringRest; doMotion's erase step moves into
eraseFlight and the inverted loop drops a nesting level. Behavior
unchanged.
This commit is contained in:
2026-07-22 22:06:48 +07:00
parent 71713d68b7
commit 730d91d160
2 changed files with 42 additions and 29 deletions

View File

@@ -77,17 +77,9 @@ func (k ObjectKind) String() string {
return "suit of armor"
case KindRing:
return ringName
case KindWand:
return "wand or staff"
case KindAmulet:
return "amulet"
case KindGold:
return goldName
case KindRingOrStick:
return "ring, wand or staff"
default:
return k.stringRest()
}
return "bizarre thing"
}
// objectKindForGlyph is the reverse of Glyph: what category of item does a
@@ -123,6 +115,23 @@ func (k ObjectKind) MergesInPack() bool {
return k == KindPotion || k == KindScroll || k == KindFood
}
// stringRest names the remaining kinds, including the ring-or-stick
// prompt pseudo-kind (the tail of the C type_name switch).
func (k ObjectKind) stringRest() string {
switch k {
case KindWand:
return "wand or staff"
case KindAmulet:
return "amulet"
case KindGold:
return goldName
case KindRingOrStick:
return "ring, wand or staff"
}
return "bizarre thing"
}
// Object is the _o arm of the C THING union: anything that can lie on the
// floor or ride in a pack.
type Object struct {