Rename movement/world methods to idiomatic Go; remove all gotos

Refactor step 4. Renames (C breadcrumbs kept in doc comments):
doMove→moveHero, beTrapped→springTrap, rndmove→randomStep,
doRooms→digRooms, doPassages→digPassages, doMaze→digMaze,
chgStr→changeStrength, doRun→startRun, moveStuff→finishMove,
turnref→turnRefresh, moveMonst→moveMonster, doChase→chaseStep,
setOldch→setOldChar, cansee→canSee, roomin→roomIn, runto→runTo,
conn→connectRooms, putpass→putPassage, passnum→numberPassages,
numpass→numberPassage, rndPos→randomPos, rndRoom→randomRoom,
treasRoom→treasureRoom, accntMaze→accountMaze.

All goto/label flows are gone: moveHero uses a retry loop with the
PASSGO corner logic extracted into passageTurn; dispatch re-dispatches
via a loop; chaseStep re-checks via a loop; saveGame uses a labeled
prompt loop. Control flow and RNG call order are unchanged; suite
green.
This commit is contained in:
2026-07-07 02:29:06 +02:00
parent 65a1cd68b8
commit 6850c87ae7
21 changed files with 653 additions and 624 deletions

View File

@@ -80,7 +80,7 @@ func (g *RogueGame) doZap() {
case WandInvisibility:
tp.Flags.Set(Invisible)
if g.cansee(y, x) {
if g.canSee(y, x) {
g.mvaddch(y, x, tp.OldCh)
}
case WandPolymorph:
@@ -186,7 +186,7 @@ func (g *RogueGame) doZap() {
g.Delta.Y = y
g.Delta.X = x
g.runto(g.Delta)
g.runTo(g.Delta)
}
case WandLightning, WandFire, WandCold:
var name string
@@ -243,7 +243,7 @@ func (g *RogueGame) drain() {
if mp.Stats.HP -= cnt; mp.Stats.HP <= 0 {
g.killed(mp, g.seeMonst(mp))
} else {
g.runto(mp.Pos)
g.runTo(mp.Pos)
}
}
}
@@ -339,7 +339,7 @@ func (g *RogueGame) fireBolt(start Coord, dir *Coord, name string) {
}
} else if ch != 'M' || tp.Disguise == 'M' {
if fromHero {
g.runto(pos)
g.runTo(pos)
}
if g.Options.Terse {