package handbookCfg

import (
	"server/game/mod/item"
	"server/gamedata"
	"server/pkg/github.com/name5566/leaf/log"
)

const (
	CFG_HANDBOOK       = "Handbook"
	CFG_HANDBOOK_CONST = "HandbookConst"
)

func init() {
	gamedata.InitCfg(CFG_HANDBOOK)
	gamedata.InitCfg(CFG_HANDBOOK_CONST)
}

func GetHandbookReward(Type string) []*item.Item {
	data, err := gamedata.GetDataByKey(CFG_HANDBOOK, Type)
	if err != nil {
		log.Debug("GetHandbookReward err:%v, Type=%s", err, Type)
		return nil
	}
	return gamedata.GetItemList(data, "Items")
}

func GetHandbookCollectReward() []*item.Item {
	data, err := gamedata.GetDataByKey(CFG_HANDBOOK_CONST, "collect_item")
	if err != nil {
		log.Debug("GetHandbookCollectReward err:%v", err)
		return nil
	}
	return gamedata.GetItemList(data, "Value")
}
