package gamedata

import (

	// "io/ioutil"

	"server/pkg/github.com/name5566/leaf/recordfile"
)

var G_AllConfigs = map[string]interface{}{}

type ConfigData struct {
	data map[string]interface{}
}

func (cd *ConfigData) GetData() map[string]interface{} {
	return cd.data
}

func (cd *ConfigData) SetData(data map[string]interface{}) {
	cd.data = data
}

var G_AllConfigsData = map[string]*recordfile.RecordFile{}
var G_AllConfigsJsonData = map[string]*ConfigData{}

func InitReadAllCfg() {
	// 遍历 Map
	for k, v := range G_AllConfigs {
		rd := readRfNew(v, k)
		G_AllConfigsData[k] = rd
	}

}

func GetConfigByName(name string) *recordfile.RecordFile {
	_, ok := G_AllConfigsData[name]
	if ok {
		return G_AllConfigsData[name]
	} else {
		rd := readRfNew(G_AllConfigs[name], name)
		G_AllConfigsData[name] = rd
	}
	return G_AllConfigsData[name]
}
