Move all package-level vars into gameData; finish lint adoption
gochecknoglobals: all 37 package-level tables consolidated into the gameData struct (game/tables.go), built by newGameData() and carried on RogueGame as g.data (set in NewGame and Restore). ObjectKind Glyph()/objectKindForGlyph are now switches; the table-reading subtype Stringer methods are gone; isMagic is a RogueGame method. goconst: repeated words named (potionName/scrollName/ringName/goldName in object.go, wandName/staffName in sticks.go, ripWall in tables.go). exhaustive, testpackage: disabled in .golangci.yml with sneak's approval (2026-07-07). Also reverts misspell's silent corruption of the "ther" scroll-name syllable (it had become "there", changing generated scroll names vs C). Remaining red: cyclop/gocognit/nestif until refactor step 7; mnd awaits a ruling. TODO.md rotated; MEMORY.md lint notes updated.
This commit is contained in:
@@ -13,24 +13,6 @@ type pact struct {
|
||||
straight string
|
||||
}
|
||||
|
||||
// pActions is potions.c p_actions[]. The P_SEEINVIS message is dynamic
|
||||
// (it names the fruit) and is computed in doPot.
|
||||
var pActions = [NumPotionTypes]pact{
|
||||
PotionConfusion: {Confused, DUnconfuse, HuhDuration,
|
||||
"what a tripy feeling!",
|
||||
"wait, what's going on here. Huh? What? Who?"},
|
||||
PotionLSD: {Hallucinating, DComeDown, SeeDuration,
|
||||
"Oh, wow! Everything seems so cosmic!",
|
||||
"Oh, wow! Everything seems so cosmic!"},
|
||||
PotionSeeInvisible: {CanSeeInvisible, DUnsee, SeeDuration, "", ""},
|
||||
PotionBlindness: {Blind, DSight, SeeDuration,
|
||||
"oh, bummer! Everything is dark! Help!",
|
||||
"a cloak of darkness falls around you"},
|
||||
PotionLevitation: {Levitating, DLand, HealTime,
|
||||
"oh, wow! You're floating in the air!",
|
||||
"you start to float in the air"},
|
||||
}
|
||||
|
||||
// quaff drinks a potion from the pack (potions.c quaff).
|
||||
func (g *RogueGame) quaff() {
|
||||
p := &g.Player
|
||||
@@ -100,7 +82,7 @@ func (g *RogueGame) quaff() {
|
||||
g.scr.Hw.Clear()
|
||||
|
||||
for _, tp := range g.Level.Objects {
|
||||
if tp.isMagic() {
|
||||
if g.isMagic(tp) {
|
||||
show = true
|
||||
|
||||
g.scr.Hw.MvAddCh(tp.Pos.Y, tp.Pos.X, Magic)
|
||||
@@ -110,7 +92,7 @@ func (g *RogueGame) quaff() {
|
||||
|
||||
for _, mp := range g.Level.Monsters {
|
||||
for _, tp := range mp.Pack {
|
||||
if tp.isMagic() {
|
||||
if g.isMagic(tp) {
|
||||
show = true
|
||||
|
||||
g.scr.Hw.MvAddCh(mp.Pos.Y, mp.Pos.X, Magic)
|
||||
@@ -208,14 +190,14 @@ func (g *RogueGame) quaff() {
|
||||
// raiseLevel: the guy just magically went up a level (potions.c
|
||||
// raise_level).
|
||||
func (g *RogueGame) raiseLevel() {
|
||||
g.Player.Stats.Exp = eLevels[g.Player.Stats.Lvl-1] + 1
|
||||
g.Player.Stats.Exp = g.data.eLevels[g.Player.Stats.Lvl-1] + 1
|
||||
g.checkLevel()
|
||||
}
|
||||
|
||||
// doPot does a potion with standard setup: it uses a fuse and turns on a
|
||||
// flag (potions.c do_pot).
|
||||
func (g *RogueGame) doPot(kind PotionKind, knowit bool) {
|
||||
pp := &pActions[kind]
|
||||
pp := &g.data.pActions[kind]
|
||||
if !g.Items.Potions[kind].Know {
|
||||
g.Items.Potions[kind].Know = knowit
|
||||
}
|
||||
@@ -240,10 +222,10 @@ func (g *RogueGame) doPot(kind PotionKind, knowit bool) {
|
||||
}
|
||||
|
||||
// isMagic reports whether an object radiates magic (potions.c is_magic).
|
||||
func (o *Object) isMagic() bool {
|
||||
func (g *RogueGame) isMagic(o *Object) bool {
|
||||
switch o.Kind {
|
||||
case KindArmor:
|
||||
return o.Flags.Has(Protected) || o.ArmorClass != aClass[o.Which]
|
||||
return o.Flags.Has(Protected) || o.ArmorClass != g.data.aClass[o.Which]
|
||||
case KindWeapon:
|
||||
return o.HPlus != 0 || o.DPlus != 0
|
||||
case KindPotion, KindScroll, KindWand, KindRing, KindAmulet:
|
||||
|
||||
Reference in New Issue
Block a user