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:
@@ -103,7 +103,7 @@ func (g *RogueGame) putThings() {
|
||||
attachObj(&g.Level.Objects, obj)
|
||||
// Put it somewhere
|
||||
obj.Pos, _ = g.findFloor(nil, 0, false)
|
||||
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, obj.Type)
|
||||
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, obj.Kind.Glyph())
|
||||
}
|
||||
}
|
||||
// If he is really deep in the dungeon and he hasn't found the amulet
|
||||
@@ -114,7 +114,7 @@ func (g *RogueGame) putThings() {
|
||||
obj.Damage = "0x0"
|
||||
obj.HurlDmg = "0x0"
|
||||
obj.Arm = 11
|
||||
obj.Type = Amulet
|
||||
obj.Kind = KindAmulet
|
||||
// Put it somewhere
|
||||
obj.Pos, _ = g.findFloor(nil, 0, false)
|
||||
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, Amulet)
|
||||
@@ -134,7 +134,7 @@ func (g *RogueGame) treasRoom() {
|
||||
tp := g.newThing()
|
||||
tp.Pos = mp
|
||||
attachObj(&g.Level.Objects, tp)
|
||||
g.Level.SetChar(mp.Y, mp.X, tp.Type)
|
||||
g.Level.SetChar(mp.Y, mp.X, tp.Kind.Glyph())
|
||||
}
|
||||
|
||||
// fill up room with monsters from the next level down
|
||||
|
||||
Reference in New Issue
Block a user