ObjectKind separates what an item is from how it draws: Object.Type (a byte that doubled as the map character) becomes Kind ObjectKind, with Glyph() producing the display character and objectKindForGlyph converting back at the map boundary. KindWand covers the C 'stick' category. The magic-missile bolt uses KindGold, matching C's literal o_type='*' trick, with a comment. PotionKind, ScrollKind, RingKind, WandKind, WeaponKind, ArmorKind and TrapKind are now iota enums with Stringer (names come from the base info tables); Object gains typed accessors (obj.RingKind(), ...) and Launch is typed WeaponKind. beTrapped returns TrapKind. The getItem/inventory/whatis prompt filters take ObjectKind, with KindCallable/KindRingOrStick replacing the C CALLABLE/R_OR_S sentinels; wizard.c's type_name table is subsumed by ObjectKind.String(). IsRing/IsWearing/initWeapon/doPot signatures are typed accordingly. The save format version becomes 5.4.4-go2: the gob field rename would otherwise silently zero Kind when reading old saves. No behavior change; full suite green.
67 lines
1.3 KiB
Go
67 lines
1.3 KiB
Go
package game
|
|
|
|
// armor.c — misc functions for dealing with armor.
|
|
|
|
// wear lets the player put armor on (armor.c wear).
|
|
func (g *RogueGame) wear() {
|
|
p := &g.Player
|
|
obj := g.getItem("wear", KindArmor)
|
|
if obj == nil {
|
|
return
|
|
}
|
|
if p.CurArmor != nil {
|
|
g.addmsg("you are already wearing some")
|
|
if !g.Options.Terse {
|
|
g.addmsg(". You'll have to take it off first")
|
|
}
|
|
g.endmsg()
|
|
g.After = false
|
|
return
|
|
}
|
|
if obj.Kind != KindArmor {
|
|
g.msg("you can't wear that")
|
|
return
|
|
}
|
|
g.wasteTime()
|
|
obj.Flags.Set(Known)
|
|
sp := g.invName(obj, true)
|
|
p.CurArmor = obj
|
|
if !g.Options.Terse {
|
|
g.addmsg("you are now ")
|
|
}
|
|
g.msg("wearing %s", sp)
|
|
}
|
|
|
|
// takeOff gets the armor off of the player's back (armor.c take_off).
|
|
func (g *RogueGame) takeOff() {
|
|
p := &g.Player
|
|
obj := p.CurArmor
|
|
if obj == nil {
|
|
g.After = false
|
|
if g.Options.Terse {
|
|
g.msg("not wearing armor")
|
|
} else {
|
|
g.msg("you aren't wearing any armor")
|
|
}
|
|
return
|
|
}
|
|
if !g.dropCheck(p.CurArmor) {
|
|
return
|
|
}
|
|
p.CurArmor = nil
|
|
if g.Options.Terse {
|
|
g.addmsg("was")
|
|
} else {
|
|
g.addmsg("you used to be")
|
|
}
|
|
g.msg(" wearing %c) %s", obj.PackCh, g.invName(obj, true))
|
|
}
|
|
|
|
// wasteTime does nothing but let other things happen (armor.c waste_time).
|
|
func (g *RogueGame) wasteTime() {
|
|
g.DoDaemons(Before)
|
|
g.DoFuses(Before)
|
|
g.DoDaemons(After)
|
|
g.DoFuses(After)
|
|
}
|