package emojiCfg

import (
	GoUtil "server/game_util"
	"server/gamedata"
	"server/pkg/github.com/name5566/leaf/log"
)

const (
	CFG_EMOJI = "Emoji"
)

func init() {
	gamedata.InitCfg(CFG_EMOJI)
}

func GetInitList() []int {
	data, err := gamedata.GetData(CFG_EMOJI)
	if err != nil {
		log.Debug("GetInitList err:%v", err)
		return nil
	}
	ret := make([]int, 0, len(data))
	for k, v := range data {
		Init := gamedata.GetIntValue(v, "Init")
		if Init == 1 {
			ret = append(ret, GoUtil.Int(k))
		}
	}
	return ret
}

func GetAllList() []int {
	data, err := gamedata.GetData(CFG_EMOJI)
	if err != nil {
		log.Debug("GetAllList err:%v", err)
		return nil
	}
	ret := make([]int, 0, len(data))
	for k := range data {
		ret = append(ret, GoUtil.Int(k))
	}
	return ret
}

func GetEmojiName(Id int) string {
	data, err := gamedata.GetDataByIntKey(CFG_EMOJI, Id)
	if err != nil {
		log.Debug("GetEmojiName err:%v, Id=%d", err, Id)
		return ""
	}
	return gamedata.GetStringValue(data, "Name")
}
