Give item categories and subtypes real types (refactor step 2)
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.
This commit is contained in:
@@ -344,7 +344,7 @@ func (g *RogueGame) rollEm(thatt, thdef *Creature, weap *Object, hurl bool) bool
|
||||
cp = weap.Damage
|
||||
if hurl {
|
||||
if weap.Flags.Has(Missile) && p.CurWeapon != nil &&
|
||||
p.CurWeapon.Which == weap.Launch {
|
||||
WeaponKind(p.CurWeapon.Which) == weap.Launch {
|
||||
cp = weap.HurlDmg
|
||||
hplus += p.CurWeapon.HPlus
|
||||
dplus += p.CurWeapon.DPlus
|
||||
@@ -425,7 +425,7 @@ func (g *RogueGame) thunk(weap *Object, mname string, noend bool) {
|
||||
if g.ToDeath {
|
||||
return
|
||||
}
|
||||
if weap.Type == Weapon {
|
||||
if weap.Kind == KindWeapon {
|
||||
g.addmsg("the %s hits ", g.Items.Weapons[weap.Which].Name)
|
||||
} else {
|
||||
g.addmsg("you hit ")
|
||||
@@ -488,7 +488,7 @@ func (g *RogueGame) bounce(weap *Object, mname string, noend bool) {
|
||||
if g.ToDeath {
|
||||
return
|
||||
}
|
||||
if weap.Type == Weapon {
|
||||
if weap.Kind == KindWeapon {
|
||||
g.addmsg("the %s misses ", g.Items.Weapons[weap.Which].Name)
|
||||
} else {
|
||||
g.addmsg("you missed ")
|
||||
@@ -539,7 +539,7 @@ func (g *RogueGame) killed(tp *Monster, pr bool) {
|
||||
}
|
||||
if ok && g.Depth >= g.MaxDepth {
|
||||
gold := newObject()
|
||||
gold.Type = Gold
|
||||
gold.Kind = KindGold
|
||||
gold.SetGoldVal(g.goldCalc())
|
||||
if g.save(VsMagic) {
|
||||
gold.Arm += g.goldCalc() + g.goldCalc() + g.goldCalc() + g.goldCalc()
|
||||
|
||||
Reference in New Issue
Block a user