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:
@@ -212,7 +212,7 @@ func (g *RogueGame) comeDown(int) {
|
||||
|
||||
// undo the things
|
||||
for _, tp := range g.Level.Objects {
|
||||
if g.cansee(tp.Pos.Y, tp.Pos.X) {
|
||||
if g.canSee(tp.Pos.Y, tp.Pos.X) {
|
||||
g.mvaddch(tp.Pos.Y, tp.Pos.X, tp.Kind.Glyph())
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ func (g *RogueGame) comeDown(int) {
|
||||
for _, tp := range g.Level.Monsters {
|
||||
g.move(tp.Pos.Y, tp.Pos.X)
|
||||
|
||||
if g.cansee(tp.Pos.Y, tp.Pos.X) {
|
||||
if g.canSee(tp.Pos.Y, tp.Pos.X) {
|
||||
if !tp.On(Invisible) || p.On(CanSeeInvisible) {
|
||||
g.addch(tp.Disguise)
|
||||
} else {
|
||||
@@ -248,13 +248,13 @@ func (g *RogueGame) visuals(int) {
|
||||
}
|
||||
// change the things
|
||||
for _, tp := range g.Level.Objects {
|
||||
if g.cansee(tp.Pos.Y, tp.Pos.X) {
|
||||
if g.canSee(tp.Pos.Y, tp.Pos.X) {
|
||||
g.mvaddch(tp.Pos.Y, tp.Pos.X, g.rndThing())
|
||||
}
|
||||
}
|
||||
|
||||
// change the stairs
|
||||
if !g.SeenStairs && g.cansee(g.Level.Stairs.Y, g.Level.Stairs.X) {
|
||||
if !g.SeenStairs && g.canSee(g.Level.Stairs.Y, g.Level.Stairs.X) {
|
||||
g.mvaddch(g.Level.Stairs.Y, g.Level.Stairs.X, g.rndThing())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user