模板优化
This commit is contained in:
parent
ac637b09d2
commit
02979f65a4
|
@ -1,59 +1,59 @@
|
||||||
// Code generated by minotaur-config-export. DO NOT EDIT.
|
// Code generated by minotaur-config-export. DO NOT EDIT.
|
||||||
package example
|
package example
|
||||||
// XXConfig 有索引
|
// IndexConfig 有索引
|
||||||
type XXConfig struct {
|
type IndexConfig struct {
|
||||||
Id int // 任务ID
|
Id int // 任务ID
|
||||||
Count string // 次数
|
Count string // 次数
|
||||||
Info *XXConfigInfo // 信息
|
Info *IndexConfigInfo // 信息
|
||||||
Other map[int]*XXConfigOther // 信息2
|
Other map[int]*IndexConfigOther // 信息2
|
||||||
}
|
}
|
||||||
|
|
||||||
type XXConfigInfo struct {
|
type IndexConfigInfo struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
Info *XXConfigInfoInfo
|
Info *IndexConfigInfoInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
type XXConfigInfoInfo struct {
|
type IndexConfigInfoInfo struct {
|
||||||
Lv int
|
Lv int
|
||||||
Exp *XXConfigInfoInfoExp
|
Exp *IndexConfigInfoInfoExp
|
||||||
}
|
}
|
||||||
|
|
||||||
type XXConfigInfoInfoExp struct {
|
type IndexConfigInfoInfoExp struct {
|
||||||
Mux int
|
Mux int
|
||||||
Count int
|
Count int
|
||||||
}
|
}
|
||||||
|
|
||||||
type XXConfigOther struct {
|
type IndexConfigOther struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
// UNConfig 无索引
|
// EasyConfig 无索引
|
||||||
type UNConfig struct {
|
type EasyConfig struct {
|
||||||
Id int // 任务ID
|
Id int // 任务ID
|
||||||
Count string // 次数
|
Count string // 次数
|
||||||
Info *UNConfigInfo // 信息
|
Info *EasyConfigInfo // 信息
|
||||||
Other map[int]*UNConfigOther // 信息2
|
Other map[int]*EasyConfigOther // 信息2
|
||||||
}
|
}
|
||||||
|
|
||||||
type UNConfigInfo struct {
|
type EasyConfigInfo struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
Info *UNConfigInfoInfo
|
Info *EasyConfigInfoInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
type UNConfigInfoInfo struct {
|
type EasyConfigInfoInfo struct {
|
||||||
Lv int
|
Lv int
|
||||||
Exp *UNConfigInfoInfoExp
|
Exp *EasyConfigInfoInfoExp
|
||||||
}
|
}
|
||||||
|
|
||||||
type UNConfigInfoInfoExp struct {
|
type EasyConfigInfoInfoExp struct {
|
||||||
Mux int
|
Mux int
|
||||||
Count int
|
Count int
|
||||||
}
|
}
|
||||||
|
|
||||||
type UNConfigOther struct {
|
type EasyConfigOther struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,22 @@ import (
|
||||||
|
|
||||||
var json = jsonIter.ConfigCompatibleWithStandardLibrary
|
var json = jsonIter.ConfigCompatibleWithStandardLibrary
|
||||||
var (
|
var (
|
||||||
GameXXConfig map[int]map[string]*XXConfig
|
GameIndexConfig map[int]map[string]*IndexConfig
|
||||||
gameXXConfig map[int]map[string]*XXConfig
|
gameIndexConfig map[int]map[string]*IndexConfig
|
||||||
GameUNConfig *UNConfig
|
GameEasyConfig *EasyConfig
|
||||||
gameUNConfig *UNConfig
|
gameEasyConfig *EasyConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
func LoadConfig(handle func(filename string, config any) error) {
|
func LoadConfig(handle func(filename string, config any) error) {
|
||||||
handle("server.XXConfig.json", &gameXXConfig)
|
gameIndexConfig = make(map[int]map[string]*IndexConfig)
|
||||||
handle("server.UNConfig.json", &gameUNConfig)
|
handle("server.IndexConfig.json", &gameIndexConfig)
|
||||||
|
gameEasyConfig = new(EasyConfig)
|
||||||
|
handle("server.EasyConfig.json", gameEasyConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Refresh() {
|
func Refresh() {
|
||||||
GameXXConfig = gameXXConfig
|
GameIndexConfig = gameIndexConfig
|
||||||
GameUNConfig = gameUNConfig
|
GameEasyConfig = gameEasyConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultLoad(filepath string) {
|
func DefaultLoad(filepath string) {
|
||||||
|
|
|
@ -375,3 +375,10 @@ func (slf *Config) GetVariable() string {
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s*%s", result, slf.Name)
|
return fmt.Sprintf("%s*%s", result, slf.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (slf *Config) GetVariableGen() string {
|
||||||
|
if slf.IndexCount == 0 {
|
||||||
|
return fmt.Sprintf("new(%s)", strings.TrimPrefix(slf.GetVariable(), "*"))
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("make(%s)", slf.GetVariable())
|
||||||
|
}
|
||||||
|
|
|
@ -42,8 +42,13 @@ var (
|
||||||
|
|
||||||
func LoadConfig(handle func(filename string, config any) error) {
|
func LoadConfig(handle func(filename string, config any) error) {
|
||||||
{{range $index, $config := .Configs}}
|
{{range $index, $config := .Configs}}
|
||||||
|
game{{$config.Name}} = {{$config.GetVariableGen}}
|
||||||
|
{{if eq $config.IndexCount 0}}
|
||||||
|
handle("{{$config.Prefix}}{{$config.Name}}.json", game{{$config.Name}})
|
||||||
|
{{else}}
|
||||||
handle("{{$config.Prefix}}{{$config.Name}}.json", &game{{$config.Name}})
|
handle("{{$config.Prefix}}{{$config.Name}}.json", &game{{$config.Name}})
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Refresh() {
|
func Refresh() {
|
||||||
|
|
Loading…
Reference in New Issue