package friendCfg

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

const (
	CFG_NPC_FRIENDS = "NPCFriends"
	CFG_CONST       = "FriendConst"
)

func init() {
	gamedata.InitCfg(CFG_NPC_FRIENDS)
	gamedata.InitCfg(CFG_CONST)
}

func IsNpcFriend(Id int) bool {
	_, err := gamedata.GetDataByIntKey(CFG_NPC_FRIENDS, Id)
	if err != nil {
		log.Debug("IsNpcFriend err:%v, Id=%d", err, Id)
		return false
	}
	return true
}

func GetFriendSponsorNum() int {
	data, err := gamedata.GetDataByKey(CFG_CONST, "friend_energy_bonus")
	if err != nil {
		log.Debug("GetFriendSponsorNum err:%v", err)
		return 0
	}
	return gamedata.GetIntValue(data, "Value")
}

func GetFriendLimitNum() int {
	data, err := gamedata.GetDataByKey(CFG_CONST, "friend_limit")
	if err != nil {
		log.Debug("GetFriendLimitNum err:%v", err)
		return 0
	}
	return gamedata.GetIntValue(data, "Value")
}
