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