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:
@@ -29,10 +29,10 @@ func run() int {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
cfg := loadConfig()
|
||||
params := loadParams()
|
||||
|
||||
if *scores {
|
||||
game.NewGame(cfg).ShowScores()
|
||||
game.New(params).ShowScores()
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -45,13 +45,13 @@ func run() int {
|
||||
}
|
||||
defer t.Fini()
|
||||
|
||||
cfg.Term = t
|
||||
params.Term = t
|
||||
|
||||
var g *game.RogueGame
|
||||
|
||||
if args := flag.Args(); len(args) == 1 && !*deathDemo {
|
||||
// restore a saved game
|
||||
g, err = game.Restore(args[0], cfg)
|
||||
g, err = game.Restore(args[0], params)
|
||||
if err != nil {
|
||||
t.Fini()
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -59,7 +59,7 @@ func run() int {
|
||||
return 1
|
||||
}
|
||||
} else {
|
||||
g = game.NewGame(cfg)
|
||||
g = game.New(params)
|
||||
}
|
||||
|
||||
if *deathDemo {
|
||||
@@ -81,10 +81,10 @@ func run() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// loadConfig gathers the game configuration from the environment: home
|
||||
// loadParams gathers the game parameters from the environment: home
|
||||
// directory, ROGUEOPTS, user name, wizard mode, and the dungeon seed
|
||||
// (main.c's startup).
|
||||
func loadConfig() game.Config {
|
||||
func loadParams() game.Params {
|
||||
home, _ := os.UserHomeDir()
|
||||
|
||||
name := ""
|
||||
@@ -96,7 +96,7 @@ func loadConfig() game.Config {
|
||||
|
||||
wizard := os.Getenv("ROGUE_WIZARD") != ""
|
||||
|
||||
return game.Config{
|
||||
return game.Params{
|
||||
Seed: chooseSeed(wizard),
|
||||
Name: name,
|
||||
RogueOpts: os.Getenv("ROGUEOPTS"),
|
||||
|
||||
Reference in New Issue
Block a user