Rename constants to descriptive names (refactor step 1)

Pure rename, no behavior change; the full suite (RNG goldens,
generation invariants, scripted sessions, save round trip) is
unchanged and green.

- Creature flags: IsHuh→Confused, IsHalu→Hallucinating,
  CanHuh→CanConfuse, CanSee→CanSeeInvisible, IsRun→Awake,
  SeeMonst→SenseMonsters, IsCanc→Cancelled, IsLevit→Levitating,
  IsBlind/IsGreed/IsHaste/IsTarget/IsHeld/IsInvis/IsMean/IsRegen/
  IsFly/IsSlow → Blind/Greedy/Hasted/Targeted/Held/Invisible/Mean/
  Regenerates/Flying/Slowed, IsFound→Found
- Object flags: IsCursed→Cursed, IsKnow→Known, IsMissl→Missile,
  IsMany→Stackable, ObjIsFound→WasFound, IsProt→Protected
- Room flags: IsDark/IsGone/IsMaze → Dark/Gone/Maze; place flags:
  FPass→FPassage, FPNum→FPassNum, FTMask→FTrapMask
- Trap types: TDoor→TrapDoor ... TMyst→TrapMystery
- Item subtypes: P*→Potion* (PLSD→PotionLSD, PMFind→
  PotionDetectMonsters, ...), S*→Scroll* (SIDRorS→
  ScrollIdentifyRingOrStick, ...), R*→Ring* (RAddHit→RingDexterity,
  RNop→RingAdornment, ...), Ws*→Wand* (WsElect→WandLightning, ...),
  weapons (TwoSword→WeaponTwoHandedSword, Shiraken→WeaponShuriken,
  ...), armor (RingMail→ArmorRingMail, ...)
- Counts: Max{Potions,Scrolls,Rings,Sticks,Weapons,Armors} →
  Num{Potion,Scroll,Ring,Wand,Weapon,Armor}Types; NTraps→NumTrapTypes
- Level.NTraps field → TrapCount (also in the save snapshot)
- Original C constant names preserved as comment breadcrumbs in
  types.go so the lineage stays greppable

TODO.md: step 1 moved to Completed, step 2 (typed kinds) promoted to
Next Step.
This commit is contained in:
2026-07-06 21:28:57 +02:00
parent 1133feb0ba
commit e71a2ef3fd
32 changed files with 646 additions and 650 deletions

View File

@@ -19,31 +19,31 @@ func (g *RogueGame) initPlayer() {
// And his suit of armor
obj = newObject()
obj.Type = Armor
obj.Which = RingMail
obj.Arm = aClass[RingMail] - 1
obj.Flags.Set(IsKnow)
obj.Which = ArmorRingMail
obj.Arm = aClass[ArmorRingMail] - 1
obj.Flags.Set(Known)
obj.Count = 1
p.CurArmor = obj
g.addPack(obj, true)
// Give him his weaponry. First a mace.
obj = newObject()
g.initWeapon(obj, Mace)
g.initWeapon(obj, WeaponMace)
obj.HPlus = 1
obj.DPlus = 1
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
g.addPack(obj, true)
p.CurWeapon = obj
// Now a +1 bow
obj = newObject()
g.initWeapon(obj, Bow)
g.initWeapon(obj, WeaponBow)
obj.HPlus = 1
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
g.addPack(obj, true)
// Now some arrows
obj = newObject()
g.initWeapon(obj, Arrow)
g.initWeapon(obj, WeaponArrow)
obj.Count = g.rnd(15) + 25
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
g.addPack(obj, true)
}
@@ -51,7 +51,7 @@ func (g *RogueGame) initPlayer() {
// (init.c init_colors).
func (g *RogueGame) initColors() {
used := make([]bool, len(rainbow))
for i := 0; i < MaxPotions; i++ {
for i := 0; i < NumPotionTypes; i++ {
var j int
for {
j = g.rnd(len(rainbow))
@@ -66,7 +66,7 @@ func (g *RogueGame) initColors() {
// initNames generates the names of the various scrolls (init.c init_names).
func (g *RogueGame) initNames() {
for i := 0; i < MaxScrolls; i++ {
for i := 0; i < NumScrollTypes; i++ {
var cp strings.Builder
nwords := g.rnd(3) + 2
for ; nwords > 0; nwords-- {
@@ -88,7 +88,7 @@ func (g *RogueGame) initNames() {
// (init.c init_stones).
func (g *RogueGame) initStones() {
used := make([]bool, len(stoneTable))
for i := 0; i < MaxRings; i++ {
for i := 0; i < NumRingTypes; i++ {
var j int
for {
j = g.rnd(len(stoneTable))
@@ -107,7 +107,7 @@ func (g *RogueGame) initStones() {
func (g *RogueGame) initMaterials() {
used := make([]bool, len(woods))
metused := make([]bool, len(metals))
for i := 0; i < MaxSticks; i++ {
for i := 0; i < NumWandTypes; i++ {
var str string
for {
if g.rnd(2) == 0 {
@@ -156,14 +156,14 @@ func (g *RogueGame) initProbs() {
sumProbs(g.Items.Scrolls[:])
sumProbs(g.Items.Rings[:])
sumProbs(g.Items.Sticks[:])
sumProbs(g.Items.Weapons[:MaxWeapons]) // C sums MAXWEAPONS, excluding the flame entry
sumProbs(g.Items.Weapons[:NumWeaponTypes]) // C sums MAXWEAPONS, excluding the flame entry
sumProbs(g.Items.Armors[:])
}
// pickColor returns the given color, or a random one if the hero is
// hallucinating (init.c pick_color).
func (g *RogueGame) pickColor(col string) string {
if g.Player.On(IsHalu) {
if g.Player.On(Hallucinating) {
return rainbow[g.rnd(len(rainbow))]
}
return col