Rename getDir to promptDirection; rotate TODO (step 5 done)

This commit is contained in:
2026-07-07 02:34:32 +02:00
parent ae79fd5e84
commit f432c8718c
3 changed files with 30 additions and 28 deletions

42
TODO.md
View File

@@ -29,14 +29,21 @@ Refactor ground rules:
# Next Step # Next Step
Refactor step 5: method renames, items/combat/UI subsystems Refactor step 6: extract types from the god object — MessageLine
(invName→inventoryName, rollEm→rollAttacks, doPot→applyPotionFuse, owns the msg/addmsg/endmsg machinery; pack/inventory operations move
getItem→promptPackItem returning (obj, ok), getDir→promptDirection); onto *Player; monster/object list management and map queries
int status codes (attack returning -1) become named results. Two or consolidate onto *Level; RogueGame keeps turn orchestration and
three commits, one subsystem each. cross-system effects only.
# Completed Steps # Completed Steps
- 2026-07-07 Refactor step 5 (refactor/item-combat-ui-renames, three
commits, one subsystem each): items — getItem→promptPackItem now
returning (obj, ok), invName→inventoryName, doPot→applyPotionFuse;
combat — rollEm→rollAttacks, attack/moveMonster/chaseStep return
(removed bool) instead of C -1/0 int codes; UI —
getDir→promptDirection. C breadcrumbs kept; suite green.
- 2026-07-07 Refactor step 4 (refactor/movement-renames): movement/world - 2026-07-07 Refactor step 4 (refactor/movement-renames): movement/world
renames (doMove→moveHero, beTrapped→springTrap, rndmove→randomStep, renames (doMove→moveHero, beTrapped→springTrap, rndmove→randomStep,
doRooms/doPassages/doMaze→digRooms/digPassages/digMaze, doRooms/doPassages/doMaze→digRooms/digPassages/digMaze,
@@ -110,36 +117,31 @@ three commits, one subsystem each.
# Future Steps # Future Steps
1. Refactor step 6: extract types from the god object — MessageLine 1. Refactor step 7: effects dispatch — the giant quaff/readScroll/doZap
owns the msg/addmsg/endmsg machinery; pack/inventory operations move
onto *Player; monster/object list management and map queries
consolidate onto *Level; RogueGame keeps turn orchestration and
cross-system effects only.
2. Refactor step 7: effects dispatch — the giant quaff/readScroll/doZap
switches become per-kind handler tables of small named methods, switches become per-kind handler tables of small named methods,
keeping effect order and RNG call sequence identical. This step also keeping effect order and RNG call sequence identical. This step also
clears the outstanding cyclop/gocognit/nestif lint findings. clears the outstanding cyclop/gocognit/nestif lint findings.
3. Refactor step 8: constructor and style pass per the house 2. Refactor step 8: constructor and style pass per the house
styleguide — game.New(game.Params{...}) replacing NewGame(Config); styleguide — game.New(game.Params{...}) replacing NewGame(Config);
replace the gameEnd panic unwind with error-based turn results where replace the gameEnd panic unwind with error-based turn results where
feasible; 77-column wrap sweep. feasible; 77-column wrap sweep.
4. Docs refresh: update ARCHITECTURE.md Part 2 and README.md for the 3. Docs refresh: update ARCHITECTURE.md Part 2 and README.md for the
post-refactor names; add the C name → Go name rename table. post-refactor names; add the C name → Go name rename table.
5. Playtest hardening pass: play several full games with the tcell 4. Playtest hardening pass: play several full games with the tcell
binary and extend run_test.go to script a deeper multi-level binary and extend run_test.go to script a deeper multi-level
playthrough (descend past level 5, use potions, scrolls, zapping, playthrough (descend past level 5, use potions, scrolls, zapping,
save/restore). Fix any panics, message mismatches, or divergences save/restore). Fix any panics, message mismatches, or divergences
from the C behavior that this uncovers, with regression tests. from the C behavior that this uncovers, with regression tests.
6. Verify the seed-compatibility claim against the C reference on 5. Verify the seed-compatibility claim against the C reference on
c-master: same seed, same dungeon, same item tables, for several c-master: same seed, same dungeon, same item tables, for several
seeds. seeds.
7. Broaden unit test coverage where playtesting finds thin spots 6. Broaden unit test coverage where playtesting finds thin spots
(rings, sticks, wizard commands). (rings, sticks, wizard commands).
8. Tag a release once a full game (Amulet retrieval and score entry) 7. Tag a release once a full game (Amulet retrieval and score entry)
completes without defects. completes without defects.
9. Full-terminal-size support (deferred by explicit decision 8. Full-terminal-size support (deferred by explicit decision
2026-07-06): per-game dungeon dimensions instead of the 80x24 2026-07-06): per-game dungeon dimensions instead of the 80x24
constants; open design questions are resize policy, gameplay constants; open design questions are resize policy, gameplay
tuning at larger sizes, and a --classic 80x24 mode. tuning at larger sizes, and a --classic 80x24 mode.
10. Note: this repo is exempt from the standard policy scaffold. Do not 9. Note: this repo is exempt from the standard policy scaffold. Do not
add Makefile, Dockerfile, or REPO_POLICIES.md. add Makefile, Dockerfile, or REPO_POLICIES.md.

View File

@@ -240,7 +240,7 @@ func (g *RogueGame) dispatch(ch byte) {
g.Kamikaze = true g.Kamikaze = true
} }
if !g.getDir() { if !g.promptDirection() {
g.After = false g.After = false
break break
@@ -269,7 +269,7 @@ func (g *RogueGame) dispatch(ch byte) {
continue // the C goto over: fight by running at it continue // the C goto over: fight by running at it
} }
case 't': case 't':
if !g.getDir() { if !g.promptDirection() {
g.After = false g.After = false
} else { } else {
g.missile(g.Delta.Y, g.Delta.X) g.missile(g.Delta.Y, g.Delta.X)
@@ -334,7 +334,7 @@ func (g *RogueGame) dispatch(ch byte) {
case 's': case 's':
g.search() g.search()
case 'z': case 'z':
if g.getDir() { if g.promptDirection() {
g.doZap() g.doZap()
} else { } else {
g.After = false g.After = false
@@ -360,7 +360,7 @@ func (g *RogueGame) dispatch(ch byte) {
g.After = false // "legal" illegal command g.After = false // "legal" illegal command
case '^': case '^':
g.After = false g.After = false
if g.getDir() { if g.promptDirection() {
g.Delta.Y += p.Pos.Y g.Delta.Y += p.Pos.Y
g.Delta.X += p.Pos.X g.Delta.X += p.Pos.X
@@ -386,7 +386,7 @@ func (g *RogueGame) dispatch(ch byte) {
g.Again = false g.Again = false
case 'm': case 'm':
g.MoveOn = true g.MoveOn = true
if !g.getDir() { if !g.promptDirection() {
g.After = false g.After = false
} else { } else {
ch = g.DirCh ch = g.DirCh

View File

@@ -406,9 +406,9 @@ func (g *RogueGame) isCurrent(obj *Object) bool {
return false return false
} }
// getDir sets up the direction coordinate for use in various "prefix" // promptDirection sets up the direction coordinate for use in various
// commands (misc.c get_dir). // "prefix" commands (misc.c get_dir).
func (g *RogueGame) getDir() bool { func (g *RogueGame) promptDirection() bool {
if g.Again && g.LastDir != 0 { if g.Again && g.LastDir != 0 {
g.Delta = g.lastDelt g.Delta = g.lastDelt
g.DirCh = g.LastDir g.DirCh = g.LastDir