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:
@@ -27,8 +27,8 @@ func (g *RogueGame) NewLevel() {
|
||||
// go with them (the garbage collector is our free_list).
|
||||
g.Level.Monsters = nil
|
||||
g.Level.Objects = nil
|
||||
g.doRooms() // Draw rooms
|
||||
g.doPassages() // Draw passages
|
||||
g.digRooms() // Draw rooms
|
||||
g.digPassages() // Draw passages
|
||||
|
||||
p.NoFood++
|
||||
|
||||
@@ -61,7 +61,7 @@ func (g *RogueGame) NewLevel() {
|
||||
g.SeenStairs = false
|
||||
|
||||
for _, tp := range g.Level.Monsters {
|
||||
tp.Room = g.roomin(tp.Pos)
|
||||
tp.Room = g.roomIn(tp.Pos)
|
||||
}
|
||||
|
||||
hero, _ := g.findFloor(true)
|
||||
@@ -78,8 +78,8 @@ func (g *RogueGame) NewLevel() {
|
||||
}
|
||||
}
|
||||
|
||||
// rndRoom picks a room that is really there (new_level.c rnd_room).
|
||||
func (g *RogueGame) rndRoom() int {
|
||||
// randomRoom picks a room that is really there (new_level.c rnd_room).
|
||||
func (g *RogueGame) randomRoom() int {
|
||||
for {
|
||||
rm := g.rnd(MaxRooms)
|
||||
if !g.Level.Rooms[rm].Flags.Has(Gone) {
|
||||
@@ -98,7 +98,7 @@ func (g *RogueGame) putThings() {
|
||||
}
|
||||
// check for treasure rooms, and if so, put it in.
|
||||
if g.rnd(treasRoomChance) == 0 {
|
||||
g.treasRoom()
|
||||
g.treasureRoom()
|
||||
}
|
||||
// Do MAXOBJ attempts to put things on a level
|
||||
for range MaxObj {
|
||||
@@ -126,9 +126,9 @@ func (g *RogueGame) putThings() {
|
||||
}
|
||||
}
|
||||
|
||||
// treasRoom adds a treasure room (new_level.c treas_room).
|
||||
func (g *RogueGame) treasRoom() {
|
||||
rp := &g.Level.Rooms[g.rndRoom()]
|
||||
// treasureRoom adds a treasure room (new_level.c treas_room).
|
||||
func (g *RogueGame) treasureRoom() {
|
||||
rp := &g.Level.Rooms[g.randomRoom()]
|
||||
|
||||
spots := min((rp.Max.Y-2)*(rp.Max.X-2)-minTreas, maxTreas-minTreas)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user