package gameServerMgr

import (
	. "Framework/managecenterModel"
)

var (
	mResourceVersionLit = make([]*ResourceVersion, 0)
)

// 解析资源版本信息
func ParseResourceVersionInfo(resourceVersionList []*ResourceVersion) {
	mResourceVersionLit = resourceVersionList
}

//返回所有的资源包列表
func GetResourceVersionList() (resourceVersionList []*ResourceVersion) {
	resourceVersionList = mResourceVersionLit

	return
}

//检测资源
func CheckNewResourceVersion(partnerId, serverId, gameVersionId int32, resourceVersionName string) (availableResourceVersionMap map[string]interface{}, exist bool) {
	_, exist = GetServerItem(partnerId, serverId)
	if !exist {
		return
	}

	//获取服务所在大区Id
	areaId := GetAreaIdByGroupId(serverId)

	//获取大区的资源列表
	var tempResourceVersionList []*ResourceVersion
	for _, resourceVerion := range mResourceVersionLit {
		if resourceVerion.AreaID == areaId {
			tempResourceVersionList = append(tempResourceVersionList, resourceVerion)
		}
	}

	//获取服务器
	serverGroup := GetServerGroup()

	//获取资源版本列表
	availableResourceVersionMap = GetAvailableResource(tempResourceVersionList, partnerId, gameVersionId, resourceVersionName, OfficialOrTest(serverGroup.OfficialOrTest))

	//检测是否有新资源
	if len(availableResourceVersionMap) != 0 && availableResourceVersionMap["IsNewResource"] == true {
		exist = true

		return
	}

	exist = false

	return
}
