Rename constructor to game.New(game.Params) per styleguide
NewGame(Config) becomes New(Params), and Restore takes Params too, so the package's primary type gets the canonical New() constructor with a named-field Params struct (styleguide points 139, 159). cmd/rogue and all tests updated; ARCHITECTURE.md constructor references corrected. Pure rename, suite green.
This commit is contained in:
@@ -1076,7 +1076,7 @@ that `game` itself has no third-party imports:
|
||||
go.mod module git.eeqj.de/sneak/rgoue
|
||||
cmd/rogue/main.go package main — flag parsing, constructs RogueGame, calls Run
|
||||
game/ package game — the port, one .go file per .c file
|
||||
game.go RogueGame struct, NewGame, Run (main.c)
|
||||
game.go RogueGame struct, New, Run (main.c)
|
||||
rng.go seeded LCG (main.c: rnd/roll + RN macro)
|
||||
types.go Coord, Stats, flags, constants (rogue.h)
|
||||
object.go Object type (rogue.h THING _o arm)
|
||||
@@ -1120,7 +1120,7 @@ coherent, but everything is reachable from `g`.
|
||||
|
||||
```go
|
||||
// RogueGame is one complete game of Rogue: all state that was global in the
|
||||
// C implementation, plus the terminal it plays on. Construct with NewGame,
|
||||
// C implementation, plus the terminal it plays on. Construct with New,
|
||||
// then call Run.
|
||||
type RogueGame struct {
|
||||
// --- identity / RNG ---
|
||||
@@ -1193,15 +1193,15 @@ The command.c/io.c/things.c file-statics become lowercase fields of `RogueGame`,
|
||||
### Entrypoints
|
||||
|
||||
```go
|
||||
func NewGame(opts Config) *RogueGame // Config: seed, name, ROGUEOPTS string, score path, wizard
|
||||
func (g *RogueGame) Run() error // main.c main()+playit(): init tables, first level, daemons, loop
|
||||
func (g *RogueGame) command() // one turn (command.c)
|
||||
func Restore(path string, opts Config) (*RogueGame, error) // save.c restore()
|
||||
func New(params Params) *RogueGame // Params: seed, name, ROGUEOPTS string, score path, wizard
|
||||
func (g *RogueGame) Run() error // main.c main()+playit(): init tables, first level, daemons, loop
|
||||
func (g *RogueGame) command() // one turn (command.c)
|
||||
func Restore(path string, params Params) (*RogueGame, error) // save.c restore()
|
||||
```
|
||||
|
||||
`cmd/rogue/main.go` is a thin shell: flags (`-s` scores, `-d` death demo,
|
||||
save-file arg, `SEED`/`ROGUEOPTS` env), `NewGame(...)` or `Restore(...)`,
|
||||
`Run()`, exit code.
|
||||
save-file arg, `SEED`/`ROGUEOPTS` env), `New(...)` or `Restore(...)`, `Run()`,
|
||||
exit code.
|
||||
|
||||
## 4. Core types
|
||||
|
||||
@@ -1366,7 +1366,7 @@ type Room struct {
|
||||
tables that are never written after init** (the only permitted package-level
|
||||
data — they are ROM, not state): `monsterTable [26]MonsterKind` (name, carry %,
|
||||
flags, stats), `initDam` weapon table, base `objInfo` tables (copied into
|
||||
`RogueGame.Items` at NewGame so per-game mutation — probability resumming,
|
||||
`RogueGame.Items` at New so per-game mutation — probability resumming,
|
||||
`oi_know`, `oi_guess` — stays instance-local), `eLevels`, `rainbow`, `stones`,
|
||||
`woods`, `metals`, `sylls`, trap names, help text, `lvlMons`/`wandMons` spawn
|
||||
strings, `hNames`/`mNames` combat messages.
|
||||
@@ -1634,6 +1634,6 @@ defers.
|
||||
- **Determinism test:** scripted input sequence against a fixed seed must
|
||||
produce identical final state across runs (guards hidden nondeterminism — map
|
||||
iteration, time dependence).
|
||||
- **Save round-trip:** NewGame → play N scripted turns → save → restore →
|
||||
compare full state.
|
||||
- **Save round-trip:** New → play N scripted turns → save → restore → compare
|
||||
full state.
|
||||
- `go vet` + `gofmt` clean at every commit.
|
||||
|
||||
Reference in New Issue
Block a user