|
|
@@ -0,0 +1,7493 @@
|
|
|
+package model
|
|
|
+
|
|
|
+import (
|
|
|
+ "errors"
|
|
|
+ "math/rand"
|
|
|
+ "reflect"
|
|
|
+ "rocommon/service"
|
|
|
+ "rocommon/util"
|
|
|
+ "roserver/baseserver/set"
|
|
|
+ "roserver/serverproto"
|
|
|
+ "sort"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+func BaseConfigInit(sConfig service.ConfigServerNode) {
|
|
|
+ path := sConfig.Node.Config + "/"
|
|
|
+ //不同服务器类型做不同配置文件加载(game服务器加载所有配置文件),内存优化处理
|
|
|
+ switch sConfig.Node.Type {
|
|
|
+ case SERVICE_NODE_TYPE_BOSS: //battleboss
|
|
|
+ serverproto.WorldBossCfgLoad(path + "csv/")
|
|
|
+ serverproto.WorldBossChangePlayCfgLoad(path + "csv/")
|
|
|
+ serverproto.NpcCfgLoad(path + "csv/")
|
|
|
+ convertWorldBossCfg()
|
|
|
+
|
|
|
+ case SERVICE_NODE_TYPE_GUILD: //guild
|
|
|
+ serverproto.GuildBossCfgLoad(path + "csv/")
|
|
|
+ serverproto.GuildBossRewardCfgLoad(path + "csv/")
|
|
|
+ serverproto.GuildWarDojoCfgLoad(path + "csv/")
|
|
|
+ serverproto.GuildLvCfgLoad(path + "csv/")
|
|
|
+ serverproto.GlobalCfgLoad(path + "csv/")
|
|
|
+ serverproto.GuildDemonCfgLoad(path + "csv/")
|
|
|
+ serverproto.GuildWarBuffCfgLoad(path + "csv/")
|
|
|
+ convertGlobalCfg() //通用全局属性加载
|
|
|
+ convertGuildLevelCfg() //公会等级相关
|
|
|
+ convertGuildBosRewardsCfg() //公会BOSS奖励
|
|
|
+ convertGuildBattleCfg() //公会战
|
|
|
+ convertGuildDemonCfg() //公会魔王
|
|
|
+ convertGuildWarCfg()
|
|
|
+
|
|
|
+ case SERVICE_NODE_TYPE_DB: //db
|
|
|
+ serverproto.PetCfgLoad(path + "csv/")
|
|
|
+ convertPetCfg() //pet
|
|
|
+
|
|
|
+ case SERVICE_NODE_TYPE_WEBGM: //gmweb
|
|
|
+ //添加到热更新列表中
|
|
|
+ serverproto.CFGNameList["AdvertisingScreen"] = serverproto.AdvertisingScreenLoad
|
|
|
+ serverproto.CFGNameList["CombinedServiceCfg"] = serverproto.CombinedServiceCfgLoad
|
|
|
+
|
|
|
+ case SERVICE_NODE_TYPE_RANK: //rank
|
|
|
+ serverproto.CompetitionCfgLoad(path + "csv/")
|
|
|
+ serverproto.HundredDojoCfgLoad(path + "csv/")
|
|
|
+ serverproto.RobotCfgLoad(path + "csv/")
|
|
|
+ serverproto.RushListCfgLoad(path + "csv/")
|
|
|
+ serverproto.RushListTargetCfgLoad(path + "csv/")
|
|
|
+ serverproto.GlobalCfgLoad(path + "csv/")
|
|
|
+ convertGlobalCfg() //通用全局属性加载
|
|
|
+ convertCompetitionCfg() //赛季玩法
|
|
|
+ convertRobotCfg()
|
|
|
+ convertDaoChang100Cfg() //百人道场
|
|
|
+ convertRushListCfg() //冲榜相关
|
|
|
+
|
|
|
+ case SERVICE_NODE_TYPE_CROSSSERVER:
|
|
|
+ serverproto.TransportCfgLoad(path + "csv/")
|
|
|
+ convertYuanHangTrailCfg() //远航试炼
|
|
|
+ case SERVICE_NODE_TYPE_CROSSRANK: //跨服排行榜
|
|
|
+ serverproto.TopTowerCfgLevelLoad(path + "csv/")
|
|
|
+ serverproto.TopTowerCfgRewardLoad(path + "csv/")
|
|
|
+ convertTopTowerCfg()
|
|
|
+ case SERVICE_NODE_TYPE_GLOBALCROSSMAP:
|
|
|
+ //TODO...
|
|
|
+
|
|
|
+ default:
|
|
|
+ //这边添加需要加载的配置文件列表,每个服务器不一样需要手动添加
|
|
|
+ //热加载,需要加锁处理
|
|
|
+ serverproto.ConfigInit(path + "csv/")
|
|
|
+ convertGlobalCfg() //通用全局属性加载
|
|
|
+ convertUIFuncUnLockCfg() //功能解锁问题
|
|
|
+
|
|
|
+ //处理配置表数据,提高使用效率
|
|
|
+ convertQualityPointCfg()
|
|
|
+ convertCardCfg()
|
|
|
+ convertDropCfg() //关卡掉落
|
|
|
+ convertTaskCfg() //任务数据解析
|
|
|
+ convertParterProgressCfg()
|
|
|
+ convertParterSkillTreeCfg()
|
|
|
+ convertRoleAttributeCfg()
|
|
|
+ convertJobAttrCfg()
|
|
|
+ convertPartnerAttrCfg()
|
|
|
+ convertFashionCfg()
|
|
|
+ convertCardAttCfg()
|
|
|
+ convertEquipCfg()
|
|
|
+ convertEquipRefineCfg()
|
|
|
+ convertFightPowerCfg()
|
|
|
+ convertEquipSuitCfg()
|
|
|
+ //convertSlotCfg() //寻宝数据解析
|
|
|
+ convertChangeJobCfg()
|
|
|
+ convertArenaCfg(int32(sConfig.Node.Zone)) //竞技场
|
|
|
+ convertRobotCfg() //匹配机器人
|
|
|
+ convertWorldBossCfg() //世界boss
|
|
|
+ convertSkillUpEffect() //被动技能
|
|
|
+ convertCompetitionCfg() //赛季玩法
|
|
|
+ convertCompetitionPrizeWheelCfg() //第三赛季转盘
|
|
|
+ convertCardResetCfg() //卡片分解
|
|
|
+ convertShopCfg() //商店
|
|
|
+ convertActiveCodeCfg() //激活码
|
|
|
+ convertSignInCfg() //签到
|
|
|
+ convertMapCfg() //关卡数据
|
|
|
+ convertNatureCfg() //属性对抗处理
|
|
|
+ convertTowerCfg() //爬塔奖励
|
|
|
+ convertEvilCfg() //恶魔协会
|
|
|
+ convertCardCollectCfg() //收集卡片奖励
|
|
|
+ // convertVIPCfg() //vip相关次数
|
|
|
+ convertPetCfg() //pet
|
|
|
+ convertGuildLevelCfg() //公会等级相关
|
|
|
+ convertGuildBosRewardsCfg() //公会BOSS奖励
|
|
|
+ convertGuildBattleCfg() //公会战
|
|
|
+ convertExpeditionCfg() //远征之门
|
|
|
+ convertActivitiesCfg() //精彩活动
|
|
|
+ convertHeadFrameCfg() //头像框
|
|
|
+ convertInvitationCfg() //invitation邀请码
|
|
|
+ convertVipCfg() //VIP
|
|
|
+ convertSummonCfg() //抽卡
|
|
|
+ convertRuneCfg() //卢恩商会
|
|
|
+ convertRushListCfg() //冲榜
|
|
|
+ convertDaoChang100Cfg() //百人道场
|
|
|
+ convertKeepSakeCfg() //藏品
|
|
|
+ convertCardSuitNewCfg() //卡片祝福
|
|
|
+ covertFashionLevelUpCfg() //时装升级
|
|
|
+ convertFashionRandomCfg() //时装洗练
|
|
|
+ converFashionSuitCfg() //套装升级
|
|
|
+ convertRuneShopExploreCfg() // 战令升级
|
|
|
+ convertRuneShopExploreRewardCfg() // 战令
|
|
|
+ convertGuildWarCfg() //公会战
|
|
|
+ convertOnlineTimeRewardCfg() //累计在线时间奖励获取
|
|
|
+ convertQualityFruitCfg() // 潜力果实
|
|
|
+ convertJobChangeCfg() // 职业转职
|
|
|
+ convertSysRewardCfg() //系统补偿数据表
|
|
|
+ convertCompetitionDevineCfg() //占卜
|
|
|
+ convertYuanHangTrailCfg() //远航试炼
|
|
|
+ convertActivitiesKingTaskCfg() // 国王悬赏 任务
|
|
|
+ convertSkillEquipCfg() // 神器
|
|
|
+ convertHeadDataCfg() // 称号系统
|
|
|
+ convertGuildDemonCfg() //公会魔王
|
|
|
+ convertTopTowerCfg() //巅峰之塔
|
|
|
+ convertActivitySignInCfg() //活动签到
|
|
|
+ convertIdolSeasonCfg() //粉丝馈赠
|
|
|
+ convertWishCfg() //许愿宝箱
|
|
|
+ ConvertCombinedServer() //合服
|
|
|
+ }
|
|
|
+
|
|
|
+ util.InfoF("config load success!!!")
|
|
|
+}
|
|
|
+
|
|
|
+// todo...热加载使用
|
|
|
+func ReloadConfig() {
|
|
|
+ sConfig := service.GetServiceConfig()
|
|
|
+ BaseConfigInit(sConfig)
|
|
|
+ util.InfoF("config reloead success!!!")
|
|
|
+}
|
|
|
+func ReloadConfigByName(cfgName string) {
|
|
|
+ sConfig := service.GetServiceConfig()
|
|
|
+ path := sConfig.Node.Config + "/csv/"
|
|
|
+ fuc, ok := serverproto.CFGNameList[cfgName]
|
|
|
+ if ok {
|
|
|
+ fuc(path)
|
|
|
+ //转换数据部分
|
|
|
+ switch cfgName {
|
|
|
+ case "Transport":
|
|
|
+ convertYuanHangTrailCfg()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var AdvSensitiveUtil *util.DFAUtil = nil
|
|
|
+
|
|
|
+func LoadAdvSensitiveWords() {
|
|
|
+ AdvSensitiveUtil = util.NewDFAUtil(nil)
|
|
|
+ for _, val := range serverproto.AdvertisingScreenLoader {
|
|
|
+ //valList := strings.Split(val.Type, ",")
|
|
|
+ util.DFAInsertWord(AdvSensitiveUtil, []string{val.Type})
|
|
|
+ }
|
|
|
+}
|
|
|
+func ReloadAdvSensitiveWords(cfgName string) {
|
|
|
+ sConfig := service.GetServiceConfig()
|
|
|
+ path := sConfig.Node.Config + "/csv/"
|
|
|
+ fuc, ok := serverproto.CFGNameList[cfgName]
|
|
|
+ if ok {
|
|
|
+ serverproto.AdvertisingScreenLoader = map[int32]*serverproto.AdvertisingScreen{}
|
|
|
+ fuc(path)
|
|
|
+ LoadAdvSensitiveWords()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 功能解锁问题
|
|
|
+func convertUIFuncUnLockCfg() {
|
|
|
+ if cfgData, ok := serverproto.UIFuncUnLockCfgLoader[62]; ok {
|
|
|
+ if len(cfgData.UnlockCond) <= 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ k, v := Str2Res(cfgData.UnlockCond[0])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if k == int32(serverproto.TaskType_Level_Battle_Count) {
|
|
|
+ GlobalDaoChangUnlockMapLevelId = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 转换后的属性点消耗
|
|
|
+var AttrConsumeList = map[int32]int32{}
|
|
|
+
|
|
|
+func convertQualityPointCfg() {
|
|
|
+ //QulityPointCfg
|
|
|
+ var idList []int32
|
|
|
+ for _, data := range serverproto.QualityPointCfgLoader {
|
|
|
+ idList = append(idList, data.Count)
|
|
|
+ }
|
|
|
+ sort.Slice(idList, func(i, j int) bool {
|
|
|
+ return idList[i] < idList[j]
|
|
|
+ })
|
|
|
+
|
|
|
+ var count int32 = 1
|
|
|
+ AttrConsumeList[count] = 0
|
|
|
+ for _, id := range idList {
|
|
|
+ cfgData, ok := serverproto.QualityPointCfgLoader[id]
|
|
|
+ if ok {
|
|
|
+ _, ok := AttrConsumeList[id]
|
|
|
+ if !ok {
|
|
|
+ util.PanicF("[QulityPointCfg] data error:%v", id-1)
|
|
|
+ }
|
|
|
+ AttrConsumeList[id+1] = AttrConsumeList[id] + cfgData.Cost
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 卡片数据
|
|
|
+type CardWeightDat struct {
|
|
|
+ CardCfgId int32
|
|
|
+ Weight int32
|
|
|
+}
|
|
|
+
|
|
|
+var CardNormalCfgList []*CardWeightDat
|
|
|
+var CardMiniCfgList []*CardWeightDat
|
|
|
+var CardMvpCfgList []*CardWeightDat
|
|
|
+
|
|
|
+var CardNormalWeightList []int32
|
|
|
+var CardMiniWeightList []int32
|
|
|
+var CardMvpWeightList []int32
|
|
|
+var ConvertCardList = map[int32]*ConvertCardData{}
|
|
|
+
|
|
|
+const (
|
|
|
+ Card_Type_Normal = 1
|
|
|
+ Card_Type_Mini = 2
|
|
|
+ Card_Type_MVP = 3
|
|
|
+)
|
|
|
+
|
|
|
+type ConvertCardData struct {
|
|
|
+ CardCfgId int32
|
|
|
+ AttrList map[int32]float32
|
|
|
+ TriggerBuffList map[int32]*serverproto.TriggerBuffData
|
|
|
+ SourceCfgId int32
|
|
|
+}
|
|
|
+type ConvertCardUnlockData struct {
|
|
|
+ CardSlotId int32
|
|
|
+ ConditionList []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertCardUnlock = map[int32]*ConvertCardUnlockData{}
|
|
|
+
|
|
|
+func convertCardCfg() {
|
|
|
+ CardNormalCfgList = []*CardWeightDat{}
|
|
|
+ CardMiniCfgList = []*CardWeightDat{}
|
|
|
+ CardMvpCfgList = []*CardWeightDat{}
|
|
|
+ CardNormalWeightList = []int32{}
|
|
|
+ CardMiniWeightList = []int32{}
|
|
|
+ CardMvpWeightList = []int32{}
|
|
|
+ ConvertCardList = map[int32]*ConvertCardData{}
|
|
|
+
|
|
|
+ curWeight := map[int32]int32{}
|
|
|
+ for _, data := range serverproto.CardCfgLoader {
|
|
|
+ ConvertCardList[data.CardId] = &ConvertCardData{
|
|
|
+ CardCfgId: data.CardId,
|
|
|
+ AttrList: map[int32]float32{},
|
|
|
+ TriggerBuffList: map[int32]*serverproto.TriggerBuffData{},
|
|
|
+ }
|
|
|
+ for idx := range data.Attribute1 {
|
|
|
+ key, value := Str2Res(data.Attribute1[idx])
|
|
|
+ if key > 0 && value > 0 {
|
|
|
+ ConvertCardList[data.CardId].AttrList[key] = float32(value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for idx := range data.BUFF {
|
|
|
+ buffId, rate, cd, triggType := Str2Res_4(data.BUFF[idx])
|
|
|
+ if buffId > 0 {
|
|
|
+ ConvertCardList[data.CardId].TriggerBuffList[buffId] = &serverproto.TriggerBuffData{
|
|
|
+ BuffId: uint32(buffId),
|
|
|
+ TriggerRatio: float32(rate) * 0.01,
|
|
|
+ Cd: float32(cd),
|
|
|
+ TriggerType: triggType,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if data.CardLevel > 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ weight, _ := curWeight[data.CardType]
|
|
|
+ weight += data.Pro
|
|
|
+ cardData := &CardWeightDat{
|
|
|
+ CardCfgId: data.CardId,
|
|
|
+ Weight: weight,
|
|
|
+ }
|
|
|
+ switch data.CardType {
|
|
|
+ case Card_Type_Normal:
|
|
|
+ CardNormalCfgList = append(CardNormalCfgList, cardData)
|
|
|
+ case Card_Type_Mini:
|
|
|
+ CardMiniCfgList = append(CardMiniCfgList, cardData)
|
|
|
+ case Card_Type_MVP:
|
|
|
+ CardMvpCfgList = append(CardMvpCfgList, cardData)
|
|
|
+ }
|
|
|
+ curWeight[data.CardType] = weight
|
|
|
+ }
|
|
|
+
|
|
|
+ cfgData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Card_Normal)]
|
|
|
+ if ok && cfgData.SVal != "" {
|
|
|
+ valList := strings.Split(cfgData.SVal, "-")
|
|
|
+ for i, _ := range valList {
|
|
|
+ weightVal, _ := Str2Num(valList[i])
|
|
|
+ CardNormalWeightList = append(CardNormalWeightList, int32(weightVal))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ cfgMiniData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Card_Mini)]
|
|
|
+ if ok && cfgMiniData.SVal != "" {
|
|
|
+ valList := strings.Split(cfgMiniData.SVal, "-")
|
|
|
+ for i, _ := range valList {
|
|
|
+ weightVal, _ := Str2Num(valList[i])
|
|
|
+ CardMiniWeightList = append(CardMiniWeightList, int32(weightVal))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ cfgMvpData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Card_Mvp)]
|
|
|
+ if ok && cfgMvpData.SVal != "" {
|
|
|
+ valList := strings.Split(cfgMvpData.SVal, "-")
|
|
|
+ for i, _ := range valList {
|
|
|
+ weightVal, _ := Str2Num(valList[i])
|
|
|
+ CardMvpWeightList = append(CardMvpWeightList, int32(weightVal))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //CardUnlockCfg
|
|
|
+ for _, data := range serverproto.CardUnlockCfgLoader {
|
|
|
+ addData := &ConvertCardUnlockData{
|
|
|
+ CardSlotId: data.CardSlotID,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.UnlockingCondition); idx++ {
|
|
|
+ k, v := Str2Res(data.UnlockingCondition[idx])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ addData.ConditionList = append(addData.ConditionList,
|
|
|
+ &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertCardUnlock[addData.CardSlotId] = addData
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range ConvertCardList {
|
|
|
+ cardCfg, ok := serverproto.CardCfgLoader[data.CardCfgId]
|
|
|
+ if !ok || cardCfg.CardType <= 2 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if cardCfg.CardLevel == 1 || cardCfg.FromCardId == 0 {
|
|
|
+ data.SourceCfgId = data.CardCfgId
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ sourceID := (data.CardCfgId/1000)*1000 + 100 + data.CardCfgId%100
|
|
|
+ _, ok2 := serverproto.CardCfgLoader[data.CardCfgId]
|
|
|
+ if !ok2 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ data.SourceCfgId = sourceID
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func GetCardSource(cardId int32) int32 {
|
|
|
+ cardData, ok := ConvertCardList[cardId]
|
|
|
+ if !ok {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ return cardData.SourceCfgId
|
|
|
+}
|
|
|
+
|
|
|
+// DropCfg数据
|
|
|
+type WeightKeyValueData struct {
|
|
|
+ Weight int32
|
|
|
+ Key int32
|
|
|
+ MinValue int32
|
|
|
+ Maxvalue int32
|
|
|
+}
|
|
|
+
|
|
|
+func (this *WeightKeyValueData) GetValue() int32 {
|
|
|
+ if this.MinValue == this.Maxvalue || this.MinValue > this.Maxvalue {
|
|
|
+ return this.Maxvalue
|
|
|
+ }
|
|
|
+ return this.MinValue + rand.Int31n(this.Maxvalue-this.MinValue+1)
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertDropData struct {
|
|
|
+ Id int32
|
|
|
+ TotalWeight int32 //掉了总权重
|
|
|
+ DropList []*WeightKeyValueData //weight itemId,value
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertPassBox struct {
|
|
|
+ ItemList []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+type DecayData struct {
|
|
|
+ FactorParam int32
|
|
|
+ FactorList []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+type ConvertDecayData struct {
|
|
|
+ Id int32
|
|
|
+ DecayList []*DecayData
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertDecayData) GetDecayList(kvList map[int32]int32, param uint64) {
|
|
|
+ if param <= 0 || len(this.DecayList) <= 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ bFindIdx := false
|
|
|
+ findIdx := 0
|
|
|
+ for idx := 0; idx < len(this.DecayList); idx++ {
|
|
|
+ if this.DecayList[idx].FactorParam > int32(param) {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ bFindIdx = true
|
|
|
+ findIdx = idx
|
|
|
+ }
|
|
|
+ if bFindIdx {
|
|
|
+ if findIdx >= len(this.DecayList) {
|
|
|
+ findIdx = len(this.DecayList) - 1
|
|
|
+ }
|
|
|
+ for k := 0; k < len(this.DecayList[findIdx].FactorList); k++ {
|
|
|
+ kvItem := this.DecayList[findIdx].FactorList[k]
|
|
|
+ kvList[kvItem.Key] += kvItem.Value
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var DropDataList = map[int32]*ConvertDropData{}
|
|
|
+var LevelDropCommonDataList = map[int32]*ConvertDropData{}
|
|
|
+var LevelDropBossDataList = map[int32]*ConvertDropData{}
|
|
|
+var LevelDropHDDataList = map[int32]*ConvertDropData{}
|
|
|
+var ConvertLevelPowerDecayFactorList = map[int32]*ConvertDecayData{}
|
|
|
+var ConvertLevelTimeDecayFactorList = map[int32]*ConvertDecayData{}
|
|
|
+var ConvertLevelSpAdd *serverproto.KeyValueType = nil
|
|
|
+
|
|
|
+//var LevelPassBox = map[int32]*ConvertPassBox{}
|
|
|
+
|
|
|
+func convertDropCfg() {
|
|
|
+ //dropCfg
|
|
|
+ for _, data := range serverproto.DropCfgLoader {
|
|
|
+ convertData := &ConvertDropData{
|
|
|
+ Id: data.Id,
|
|
|
+ TotalWeight: 0,
|
|
|
+ }
|
|
|
+ DropDataList[data.Id] = convertData
|
|
|
+ for index, _ := range data.Drop1 {
|
|
|
+ weightVal, key, minValue, maxValue := Str2Res_4(data.Drop1[index])
|
|
|
+ convertData.TotalWeight += weightVal
|
|
|
+ convertData.DropList = append(convertData.DropList,
|
|
|
+ &WeightKeyValueData{Weight: convertData.TotalWeight, Key: key, MinValue: minValue, Maxvalue: maxValue})
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //levelCfg
|
|
|
+ for _, data := range serverproto.LevelCfgLoader {
|
|
|
+ //关卡drop处理
|
|
|
+ commonData := &ConvertDropData{
|
|
|
+ Id: data.Id,
|
|
|
+ TotalWeight: 0,
|
|
|
+ }
|
|
|
+ LevelDropCommonDataList[data.Id] = commonData
|
|
|
+ for index, _ := range data.DropOl {
|
|
|
+ weightVal, key := Str2Res(data.DropOl[index])
|
|
|
+ commonData.TotalWeight = weightVal
|
|
|
+ commonData.DropList = append(commonData.DropList,
|
|
|
+ &WeightKeyValueData{Weight: commonData.TotalWeight, Key: key})
|
|
|
+ }
|
|
|
+
|
|
|
+ hdCommonData := &ConvertDropData{
|
|
|
+ Id: data.Id,
|
|
|
+ TotalWeight: 0,
|
|
|
+ }
|
|
|
+ LevelDropHDDataList[data.Id] = hdCommonData
|
|
|
+ for index, _ := range data.HdDrop {
|
|
|
+ weightVal, key, val := Str2Res_3(data.HdDrop[index])
|
|
|
+ hdCommonData.TotalWeight = weightVal
|
|
|
+ hdCommonData.DropList = append(hdCommonData.DropList,
|
|
|
+ &WeightKeyValueData{Weight: hdCommonData.TotalWeight, Key: key,
|
|
|
+ MinValue: val, Maxvalue: val})
|
|
|
+ }
|
|
|
+
|
|
|
+ //boss drop处理
|
|
|
+ bossData := &ConvertDropData{
|
|
|
+ Id: data.Id,
|
|
|
+ TotalWeight: 0,
|
|
|
+ }
|
|
|
+ LevelDropBossDataList[data.Id] = bossData
|
|
|
+ for index, _ := range data.Drop {
|
|
|
+ weightVal, key := Str2Res(data.Drop[index])
|
|
|
+ bossData.TotalWeight = weightVal
|
|
|
+ bossData.DropList = append(bossData.DropList,
|
|
|
+ &WeightKeyValueData{Weight: bossData.TotalWeight, Key: key})
|
|
|
+ }
|
|
|
+
|
|
|
+ //难度衰减系数
|
|
|
+ //power
|
|
|
+ parseDecay(data.Id, data.PowerWeaken, ConvertLevelPowerDecayFactorList)
|
|
|
+ //time
|
|
|
+ parseDecay(data.Id, data.StayTimeWeaken, ConvertLevelTimeDecayFactorList)
|
|
|
+
|
|
|
+ //sp add
|
|
|
+ k, v := Str2Res(data.SpAddition)
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ ConvertLevelSpAdd = &serverproto.KeyValueType{Key: k, Value: v}
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func parseDecay(id int32, decayStr string, convertData map[int32]*ConvertDecayData) {
|
|
|
+ decayData := &ConvertDecayData{
|
|
|
+ Id: id,
|
|
|
+ }
|
|
|
+ tmpDataList := strings.Split(decayStr, "|")
|
|
|
+ for idx := 0; idx < len(tmpDataList); idx++ {
|
|
|
+ tmpPramList := strings.Split(tmpDataList[idx], ";")
|
|
|
+ val, _ := Str2Num(tmpPramList[0])
|
|
|
+ tmpDecayData := &DecayData{
|
|
|
+ FactorParam: int32(val),
|
|
|
+ }
|
|
|
+ for k := 1; k < len(tmpPramList); k++ {
|
|
|
+ k, v := Str2Res(tmpPramList[k])
|
|
|
+ if k <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmpDecayData.FactorList = append(tmpDecayData.FactorList, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ decayData.DecayList = append(decayData.DecayList, tmpDecayData)
|
|
|
+ }
|
|
|
+ convertData[decayData.Id] = decayData
|
|
|
+ sort.Slice(decayData.DecayList, func(i, j int) bool {
|
|
|
+ return decayData.DecayList[i].FactorParam < decayData.DecayList[j].FactorParam
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func DropCfgProcess(dropList map[int32]int32, dropId int32) {
|
|
|
+ if dropId <= 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ dropData, ok := serverproto.DropCfgLoader[dropId]
|
|
|
+ convertDropData, ok1 := DropDataList[dropId]
|
|
|
+ if !ok || !ok1 {
|
|
|
+ util.ErrorF("dropProcess drop data not found dropId=%v ok=%v ok1=%v", dropId, ok, ok1)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //万分比随机
|
|
|
+ dropRate := rand.Int31n(10000)
|
|
|
+ if dropRate >= dropData.Rate {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if dropData.DropType <= 0 {
|
|
|
+ //累计权重随机
|
|
|
+ for i := 0; i < int(dropData.Times); i++ {
|
|
|
+ if convertDropData.TotalWeight <= 0 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ dropRate = rand.Int31n(convertDropData.TotalWeight)
|
|
|
+ for _, data := range convertDropData.DropList {
|
|
|
+ if data.Weight > dropRate && data.Key > 0 {
|
|
|
+ dropList[data.Key] += data.GetValue()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else { //drop all
|
|
|
+ for _, data := range convertDropData.DropList {
|
|
|
+ if data.Key > 0 {
|
|
|
+ dropList[data.Key] += data.GetValue() * dropData.Times
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// TargetTask配置数据
|
|
|
+// 解析任务结构数据,避免使用时重复解析
|
|
|
+type ConvertTaskData struct {
|
|
|
+ TaskId uint32
|
|
|
+ TaskType int32
|
|
|
+ PreTaskId uint32 //前置任务ID
|
|
|
+ NextTaskId uint32 //后续接取任务
|
|
|
+ TaskScore int32 //获取奖励后的任务积分
|
|
|
+ IsBeginTask bool
|
|
|
+
|
|
|
+ Condition map[int32][]int32
|
|
|
+ TaskReward []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+type CovertTaskScoreData struct {
|
|
|
+ Idx uint32
|
|
|
+ Active int32
|
|
|
+ RewardList []*serverproto.KeyValueType
|
|
|
+ HDRewardList []*serverproto.KeyValueType //活动期间制定掉落物品
|
|
|
+}
|
|
|
+
|
|
|
+var TargetTaskBeginID uint32 = 0
|
|
|
+var ConvertTaskList = map[uint32]*ConvertTaskData{}
|
|
|
+var ConvertAddTaskList = map[uint32]*ConvertTaskData{}
|
|
|
+var ConvertMainTaskOriginalList = map[uint32]uint32{} //[taskid,originaltask]
|
|
|
+var ConvertDailyTaskScoreRewardList = map[uint32]*CovertTaskScoreData{}
|
|
|
+var ConvertWeekTaskScoreRewardList = map[uint32]*CovertTaskScoreData{}
|
|
|
+
|
|
|
+const (
|
|
|
+ TASK_TYPE_DAILY = 1
|
|
|
+ TASK_TYPE_WEEK = 2
|
|
|
+ TASK_TYPE_MAIN = 3
|
|
|
+
|
|
|
+ TASK_TYPE_TODAY = 4
|
|
|
+ TASK_TYPE_GROWUP = 5
|
|
|
+)
|
|
|
+
|
|
|
+func convertTaskCfg() {
|
|
|
+ //globalCfgData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Target_Task_Begin_ID)]
|
|
|
+ //if ok {
|
|
|
+ // TargetTaskBeginID = uint32(globalCfgData.IVal)
|
|
|
+ //}
|
|
|
+ //
|
|
|
+ //for _, data := range serverproto.TargetTaskCfgLoader {
|
|
|
+ // convertData := &ConvertTaskData{
|
|
|
+ // TaskId: uint32(data.TargetTaskId),
|
|
|
+ // TaskType: data.TargetTaskType,
|
|
|
+ // NextTaskId: uint32(data.FollowTaskOld),
|
|
|
+ // Condition: map[int32][]int32{},
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // //任务条件
|
|
|
+ // for index, _ := range data.TargetTaskCondition {
|
|
|
+ // valueList := strings.Split(data.TargetTaskCondition[index], ":")
|
|
|
+ // if len(valueList) >= 2 {
|
|
|
+ // taskType, _ := Str2Num(valueList[0])
|
|
|
+ // convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
|
|
|
+ // for i := 1; i < len(valueList); i++ {
|
|
|
+ // taskValue, _ := Str2Num(valueList[i])
|
|
|
+ // convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // //任务奖励
|
|
|
+ // for index, _ := range data.TargetReward {
|
|
|
+ // key, value := Str2Res(data.TargetReward[index])
|
|
|
+ // convertData.TaskReward = append(convertData.TaskReward, &serverproto.KeyValueType{
|
|
|
+ // Key: key,
|
|
|
+ // Value: value,
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // ConvertTaskList[convertData.TaskId] = convertData
|
|
|
+ //}
|
|
|
+
|
|
|
+ for _, data := range serverproto.MissionCfgLoader {
|
|
|
+ convertData := &ConvertTaskData{
|
|
|
+ TaskId: uint32(data.MissionID),
|
|
|
+ TaskType: data.MissionType,
|
|
|
+ TaskScore: data.Active,
|
|
|
+ Condition: map[int32][]int32{},
|
|
|
+ }
|
|
|
+
|
|
|
+ //任务条件
|
|
|
+ for index, _ := range data.MissionCondition {
|
|
|
+ valueList := strings.Split(data.MissionCondition[index], ":")
|
|
|
+ if len(valueList) >= 2 {
|
|
|
+ taskType, _ := Str2Num(valueList[0])
|
|
|
+ convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
|
|
|
+ for i := 1; i < len(valueList); i++ {
|
|
|
+ taskValue, _ := Str2Num(valueList[i])
|
|
|
+ convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertTaskList[convertData.TaskId] = convertData
|
|
|
+ ConvertAddTaskList[convertData.TaskId] = convertData
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.LineMissionCfgLoader {
|
|
|
+ convertData := &ConvertTaskData{
|
|
|
+ TaskId: uint32(data.MissionID),
|
|
|
+ TaskType: TASK_TYPE_MAIN,
|
|
|
+ Condition: map[int32][]int32{},
|
|
|
+ }
|
|
|
+
|
|
|
+ if data.BeginMission > 0 {
|
|
|
+ convertData.IsBeginTask = true
|
|
|
+ }
|
|
|
+ convertData.NextTaskId = uint32(data.FollowMissionld)
|
|
|
+
|
|
|
+ //任务条件
|
|
|
+ for index, _ := range data.MissionCondition {
|
|
|
+ valueList := strings.Split(data.MissionCondition[index], ":")
|
|
|
+ if len(valueList) >= 2 {
|
|
|
+ taskType, _ := Str2Num(valueList[0])
|
|
|
+ convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
|
|
|
+ for i := 1; i < len(valueList); i++ {
|
|
|
+ taskValue, _ := Str2Num(valueList[i])
|
|
|
+ convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //任务奖励
|
|
|
+ for index, _ := range data.Reward {
|
|
|
+ key, value := Str2Res(data.Reward[index])
|
|
|
+ convertData.TaskReward = append(convertData.TaskReward, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertTaskList[convertData.TaskId] = convertData
|
|
|
+ if convertData.IsBeginTask {
|
|
|
+ ConvertAddTaskList[convertData.TaskId] = convertData
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, originalTaskData := range ConvertAddTaskList {
|
|
|
+ if !originalTaskData.IsBeginTask {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ ConvertMainTaskOriginalList[originalTaskData.TaskId] = originalTaskData.TaskId
|
|
|
+ if originalTaskData.NextTaskId == 0 || originalTaskData.TaskId == originalTaskData.NextTaskId {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ ConvertMainTaskOriginalList[originalTaskData.NextTaskId] = originalTaskData.TaskId
|
|
|
+ originalTaskProcess(originalTaskData.NextTaskId)
|
|
|
+ }
|
|
|
+
|
|
|
+ //积分奖励
|
|
|
+ for _, data := range serverproto.ActRewardCfgLoader {
|
|
|
+ scoreInfo := &CovertTaskScoreData{
|
|
|
+ Idx: uint32(data.ID),
|
|
|
+ Active: data.Active,
|
|
|
+ }
|
|
|
+ for index, _ := range data.Reward {
|
|
|
+ key, value := Str2Res(data.Reward[index])
|
|
|
+ if key <= 0 || value <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ scoreInfo.RewardList = append(scoreInfo.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ for index, _ := range data.HdDrop {
|
|
|
+ key, value := Str2Res(data.HdDrop[index])
|
|
|
+ if key <= 0 || value <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ scoreInfo.HDRewardList = append(scoreInfo.HDRewardList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ if data.ActiveType == TASK_TYPE_DAILY {
|
|
|
+ ConvertDailyTaskScoreRewardList[scoreInfo.Idx] = scoreInfo
|
|
|
+ } else if data.ActiveType == TASK_TYPE_WEEK {
|
|
|
+ ConvertWeekTaskScoreRewardList[scoreInfo.Idx] = scoreInfo
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func originalTaskProcess(taskId uint32) {
|
|
|
+ if data, ok := serverproto.LineMissionCfgLoader[int32(taskId)]; ok && data.FollowMissionld > 0 {
|
|
|
+ if data.MissionID == data.FollowMissionld {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ConvertMainTaskOriginalList[uint32(data.FollowMissionld)] = ConvertMainTaskOriginalList[taskId]
|
|
|
+ originalTaskProcess(uint32(data.FollowMissionld))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// convertParterProgressCfg
|
|
|
+type ProgressLevelAttr struct {
|
|
|
+ AttrSet map[int32]map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ProgressAttrContainer = map[int32]*ProgressLevelAttr{}
|
|
|
+
|
|
|
+type PartnerSkillSet struct {
|
|
|
+ SkillLevel map[int32][]int32
|
|
|
+}
|
|
|
+
|
|
|
+//var PartnerSkillContainer = map[int32]*PartnerSkillSet{}
|
|
|
+
|
|
|
+func convertParterProgressCfg() {
|
|
|
+ for _, data := range serverproto.ParterProgressCfgLoader {
|
|
|
+ paraStr := "Attribute"
|
|
|
+
|
|
|
+ t := reflect.ValueOf(data).Elem()
|
|
|
+ convertData := &ProgressLevelAttr{
|
|
|
+ AttrSet: map[int32]map[int32]int32{},
|
|
|
+ }
|
|
|
+ for i := 1; i <= int(data.Times); i++ {
|
|
|
+ keyStr := paraStr + strconv.Itoa(i)
|
|
|
+ v := t.FieldByName(keyStr).Interface()
|
|
|
+ var mapAttribute0 = make(map[int32]int32)
|
|
|
+ for _, str := range v.([]string) {
|
|
|
+ attrList := strings.Split(str, ":")
|
|
|
+ if len(attrList) >= 2 {
|
|
|
+ attrId, _ := Str2Num(attrList[0])
|
|
|
+ attrValue, _ := Str2Num(attrList[1])
|
|
|
+ mapAttribute0[int32(attrId)] = int32(attrValue)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ convertData.AttrSet[int32(i-1)] = mapAttribute0
|
|
|
+ }
|
|
|
+ ProgressAttrContainer[data.Id] = convertData
|
|
|
+ }
|
|
|
+ convertStrengthCfg()
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertPartnerSkillIdxList = map[int32]*serverproto.ParterSkillTreeCfg{}
|
|
|
+
|
|
|
+type ConvertSkillSlotData struct {
|
|
|
+ Id int32
|
|
|
+ ConditionList []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertSkillSlotMain = map[int32]*ConvertSkillSlotData{}
|
|
|
+var ConvertSkillSlotPartner = map[int32]*ConvertSkillSlotData{}
|
|
|
+
|
|
|
+func convertParterSkillTreeCfg() {
|
|
|
+ for _, data := range serverproto.ParterSkillTreeCfgLoader {
|
|
|
+ ConvertPartnerSkillIdxList[data.SkillId] = data
|
|
|
+ }
|
|
|
+ convertSkillTree() //技能升级
|
|
|
+
|
|
|
+ for _, data := range serverproto.SkillSlotCfgLoader {
|
|
|
+ mainAddData := &ConvertSkillSlotData{
|
|
|
+ Id: data.ID,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.SCondition); idx++ {
|
|
|
+ k, v := Str2Res(data.SCondition[idx])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ mainAddData.ConditionList = append(mainAddData.ConditionList,
|
|
|
+ &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertSkillSlotMain[mainAddData.Id] = mainAddData
|
|
|
+
|
|
|
+ partnerAddData := &ConvertSkillSlotData{
|
|
|
+ Id: data.ID,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.SParterCondition); idx++ {
|
|
|
+ k, v := Str2Res(data.SParterCondition[idx])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ partnerAddData.ConditionList = append(partnerAddData.ConditionList,
|
|
|
+ &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertSkillSlotPartner[partnerAddData.Id] = partnerAddData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type StrengthCost struct {
|
|
|
+ CostList []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var PartnerStrengthCost = map[int32]*StrengthCost{}
|
|
|
+
|
|
|
+type StrengthAttr struct {
|
|
|
+ AttrSet map[int32]map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var StrengthAttrContainer = map[int32]*StrengthAttr{}
|
|
|
+
|
|
|
+// 伙伴突破 相关配置
|
|
|
+func convertStrengthCfg() {
|
|
|
+ for _, data := range serverproto.ParterProgressCfgLoader {
|
|
|
+ paraStr := "BreachAttribute"
|
|
|
+ convertData := &StrengthAttr{
|
|
|
+ AttrSet: map[int32]map[int32]int32{},
|
|
|
+ }
|
|
|
+ t := reflect.ValueOf(data).Elem()
|
|
|
+ for i := 1; i <= int(data.BreachTimes); i++ {
|
|
|
+ keyStr := paraStr + strconv.Itoa(i)
|
|
|
+ v := t.FieldByName(keyStr)
|
|
|
+ var mapAttribute0 = make(map[int32]int32)
|
|
|
+ for _, str := range v.Interface().([]string) {
|
|
|
+ attrList := strings.Split(str, ":")
|
|
|
+ if len(attrList) >= 2 {
|
|
|
+ attrId, _ := Str2Num(attrList[0])
|
|
|
+ attrValue, _ := Str2Num(attrList[1])
|
|
|
+ mapAttribute0[int32(attrId)] = int32(attrValue)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ convertData.AttrSet[int32(i-1)] = mapAttribute0
|
|
|
+ }
|
|
|
+
|
|
|
+ convertCost := &StrengthCost{}
|
|
|
+ for index, _ := range data.BreachCost {
|
|
|
+ attrList := strings.Split(data.BreachCost[index], ":")
|
|
|
+ if len(attrList) >= 2 {
|
|
|
+ attrId, _ := Str2Num(attrList[0])
|
|
|
+ attrValue, _ := Str2Num(attrList[1])
|
|
|
+
|
|
|
+ convertCost.CostList = append(convertCost.CostList, &serverproto.KeyValueType{
|
|
|
+ Key: int32(attrId),
|
|
|
+ Value: int32(attrValue),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PartnerStrengthCost[data.Id] = convertCost
|
|
|
+
|
|
|
+ StrengthAttrContainer[data.Id] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 主角
|
|
|
+type RoleAttributeSet struct {
|
|
|
+ AttrSet []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var RoleAttrContainer = map[int32]*RoleAttributeSet{}
|
|
|
+
|
|
|
+func convertRoleAttributeCfg() {
|
|
|
+ for _, data := range serverproto.RoleAttributeCfgLoader {
|
|
|
+ convertData := &RoleAttributeSet{}
|
|
|
+ convertData.AttrSet = []*serverproto.KeyValueType{
|
|
|
+ {Key: int32(serverproto.Attr_Life), Value: data.Hp},
|
|
|
+ {Key: int32(serverproto.Attr_Sp), Value: data.Sp},
|
|
|
+ {Key: int32(serverproto.Attr_Attack), Value: data.Atk},
|
|
|
+ {Key: int32(serverproto.Attr_MagicAttack), Value: data.Matk},
|
|
|
+ {Key: int32(serverproto.Attr_Defense), Value: data.Def},
|
|
|
+ {Key: int32(serverproto.Attr_MagicDefense), Value: data.Mdef},
|
|
|
+ {Key: int32(serverproto.Attr_Hit), Value: data.Hit},
|
|
|
+ {Key: int32(serverproto.Attr_Dodge), Value: data.Dodge},
|
|
|
+ {Key: int32(serverproto.Attr_Crit), Value: data.Crit},
|
|
|
+ {Key: int32(serverproto.Attr_Ten), Value: data.Ten},
|
|
|
+ }
|
|
|
+ RoleAttrContainer[data.BaseLv] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 主角
|
|
|
+type JobAttrSet struct {
|
|
|
+ // AttrSet []*serverproto.KeyValueType
|
|
|
+ AttrSet map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var JobAttrContainer = map[int32]*JobAttrSet{}
|
|
|
+
|
|
|
+func convertJobAttrCfg() {
|
|
|
+ for _, data := range serverproto.JobCfgLoader {
|
|
|
+ convertData := &JobAttrSet{
|
|
|
+ AttrSet: map[int32]int32{},
|
|
|
+ }
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_Life)] = data.HpRate
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_Sp)] = data.SpRate
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_Attack)] = data.AtkRate
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_MagicAttack)] = data.MatkRate
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_Defense)] = data.DefRate
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_MagicDefense)] = data.MdefRate
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_Hit)] = data.HitRate
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_Dodge)] = data.DodgeRate
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_Crit)] = data.CritRate
|
|
|
+ convertData.AttrSet[int32(serverproto.Attr_Ten)] = data.TenRate
|
|
|
+ JobAttrContainer[data.Id] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 伙伴
|
|
|
+type PartnerAttrSet struct {
|
|
|
+ AttrSet []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var PartnerAttrContainer = map[int32]*PartnerAttrSet{}
|
|
|
+
|
|
|
+func convertPartnerAttrCfg() {
|
|
|
+ for _, data := range serverproto.ParterCfgLoader {
|
|
|
+ convertData := &PartnerAttrSet{}
|
|
|
+ convertData.AttrSet = []*serverproto.KeyValueType{
|
|
|
+ {Key: int32(serverproto.Attr_Life), Value: data.Hp},
|
|
|
+ {Key: int32(serverproto.Attr_Sp), Value: data.Sp},
|
|
|
+ {Key: int32(serverproto.Attr_Attack), Value: data.Atk},
|
|
|
+ {Key: int32(serverproto.Attr_MagicAttack), Value: data.Matk},
|
|
|
+ {Key: int32(serverproto.Attr_Defense), Value: data.Def},
|
|
|
+ {Key: int32(serverproto.Attr_MagicDefense), Value: data.Mdef},
|
|
|
+ {Key: int32(serverproto.Attr_Hit), Value: data.Hit},
|
|
|
+ {Key: int32(serverproto.Attr_Dodge), Value: data.Dodge},
|
|
|
+ {Key: int32(serverproto.Attr_Crit), Value: data.Crit},
|
|
|
+ {Key: int32(serverproto.Attr_Ten), Value: data.Ten},
|
|
|
+ {Key: int32(serverproto.Attr_AttackSpeed), Value: data.Aspd},
|
|
|
+ }
|
|
|
+ PartnerAttrContainer[data.ParterId] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type FashionAttrSet struct {
|
|
|
+ AttrSet []*serverproto.KeyValueType
|
|
|
+ FashionUseJobList []int32
|
|
|
+ FashionQuality int32
|
|
|
+ //AttrNum int32
|
|
|
+}
|
|
|
+
|
|
|
+//var FashionAttrContainer = map[int32]*FashionAttrSet{}
|
|
|
+
|
|
|
+var ConvertFashionPaperData = map[int32]map[int32]int32{}
|
|
|
+
|
|
|
+func convertFashionCfg() {
|
|
|
+ //for _, cfgData := range serverproto.FashionCfgLoader {
|
|
|
+ // convertData := &FashionAttrSet{}
|
|
|
+ // for _, attrSet := range cfgData.FashionAttr {
|
|
|
+ // key, value := Str2Res(attrSet)
|
|
|
+ // if key <= 0 || value <= 0 {
|
|
|
+ // continue
|
|
|
+ // }
|
|
|
+ // convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
|
|
|
+ // Key: key,
|
|
|
+ // Value: value,
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // for idx := 0; idx < len(cfgData.FashionUseJob); idx++ {
|
|
|
+ // useJob, _ := Str2Num(cfgData.FashionUseJob[idx])
|
|
|
+ // convertData.FashionUseJobList = append(convertData.FashionUseJobList, int32(useJob))
|
|
|
+ // }
|
|
|
+ // //convertData.AttrNum = cfgData.AttrNum
|
|
|
+ // convertData.FashionQuality = cfgData.FashionQuality
|
|
|
+ // //FashionAttrContainer[int32(cfgData.FashionId)] = convertData
|
|
|
+ //}
|
|
|
+ //paper resolveItemList
|
|
|
+ for _, data := range serverproto.FashionPaperCfgLoader {
|
|
|
+ ConvertFashionPaperData[data.PaperId] = map[int32]int32{}
|
|
|
+ for idx := range data.ResolveItem {
|
|
|
+ key, val := Str2Res(data.ResolveItem[idx])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ ConvertFashionPaperData[data.PaperId][key] += val
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type CardAttrSet struct {
|
|
|
+ AttrSet []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var CardAttrContainer = map[int32]*CardAttrSet{}
|
|
|
+
|
|
|
+func convertCardAttCfg() {
|
|
|
+ for _, cfgData := range serverproto.CardCfgLoader {
|
|
|
+ convertData := &CardAttrSet{}
|
|
|
+ for _, attrSet := range cfgData.Attribute1 {
|
|
|
+ key, value := Str2Res(attrSet)
|
|
|
+ if key <= 0 || value <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ CardAttrContainer[int32(cfgData.CardId)] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type EquipAttributeSet struct {
|
|
|
+ AttrSet []*serverproto.KeyValueType
|
|
|
+ SuitId int32
|
|
|
+}
|
|
|
+
|
|
|
+var EquipAttrContainer = map[int32]*EquipAttributeSet{}
|
|
|
+
|
|
|
+func convertEquipCfg() {
|
|
|
+ for _, data := range serverproto.EquipCfgLoader {
|
|
|
+ convertData := &EquipAttributeSet{
|
|
|
+ SuitId: data.Suit,
|
|
|
+ }
|
|
|
+ convertData.AttrSet = []*serverproto.KeyValueType{
|
|
|
+ {Key: int32(serverproto.Attr_Str), Value: data.Str},
|
|
|
+ {Key: int32(serverproto.Attr_Agi), Value: data.Agi},
|
|
|
+ {Key: int32(serverproto.Attr_Int), Value: data.Int},
|
|
|
+ {Key: int32(serverproto.Attr_Vit), Value: data.Vit},
|
|
|
+ {Key: int32(serverproto.Attr_Dex), Value: data.Dex},
|
|
|
+ {Key: int32(serverproto.Attr_Luk), Value: data.Luk},
|
|
|
+
|
|
|
+ {Key: int32(serverproto.Attr_Life), Value: data.Life},
|
|
|
+ {Key: int32(serverproto.Attr_Sp), Value: data.Sp},
|
|
|
+ {Key: int32(serverproto.Attr_Attack), Value: data.Attack},
|
|
|
+ {Key: int32(serverproto.Attr_MagicAttack), Value: data.MagicAttack},
|
|
|
+ {Key: int32(serverproto.Attr_Defense), Value: data.Defense},
|
|
|
+ {Key: int32(serverproto.Attr_MagicDefense), Value: data.MagicDefense},
|
|
|
+ {Key: int32(serverproto.Attr_Hit), Value: data.Hit},
|
|
|
+ {Key: int32(serverproto.Attr_Dodge), Value: data.Dodge},
|
|
|
+ {Key: int32(serverproto.Attr_Crit), Value: data.Crit},
|
|
|
+ {Key: int32(serverproto.Attr_Ten), Value: data.Ten},
|
|
|
+
|
|
|
+ {Key: int32(serverproto.Attr_PhysicDamage_Percent), Value: data.PhysicalDamageBonus},
|
|
|
+ {Key: int32(serverproto.Attr_MagicDamage_Percent), Value: data.MagicDamageBonus},
|
|
|
+ {Key: int32(serverproto.Attr_Attack_Percent), Value: data.AtkPercent},
|
|
|
+ {Key: int32(serverproto.Attr_MagicAttack_Percent), Value: data.MatkPercent},
|
|
|
+ }
|
|
|
+ EquipAttrContainer[data.Id] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 神器id,星级,消耗材料map
|
|
|
+var SkillEquipStarLevelUpCostContainer = map[int32]map[int32]map[int32]int32{}
|
|
|
+
|
|
|
+// 返还 神器id,星级,返还材料map
|
|
|
+var SkillEquipDecomposeReturnContainer = map[int32]map[int32]map[int32]int32{}
|
|
|
+
|
|
|
+// 神器战力
|
|
|
+var SkillEquipAppendFightPowerContainer = map[int32]map[int32]int32{}
|
|
|
+
|
|
|
+// 神器技能 神器id,星级,技能id
|
|
|
+var SkillEquipAppendSkillContainer = map[int32]map[int32]int32{}
|
|
|
+
|
|
|
+// 神器槽位附加属性 槽位等级,属性map
|
|
|
+var SkillEquipSlotAppendAttrContainer = map[int32]map[serverproto.Attr]float32{}
|
|
|
+
|
|
|
+// 神器槽位升级消耗 槽位等级,消耗材料map
|
|
|
+var SkillEquipSlotLevelUpCostContainer = map[int32]map[int32]int32{}
|
|
|
+
|
|
|
+type SkillEquipRemake struct {
|
|
|
+ Id int32 //批次
|
|
|
+ BeginDay int32
|
|
|
+ EndDay int32
|
|
|
+ CurBegin uint64 //当前批次开始
|
|
|
+ CurEnd uint64 //当前批次结束
|
|
|
+ CurForgePool []int32 //当前重铸池子
|
|
|
+ RealPool []int32 //实际重铸池子
|
|
|
+ NextForgePool []int32 //下一批重铸池子
|
|
|
+ NextBegin uint64 //下一轮开始时间
|
|
|
+}
|
|
|
+
|
|
|
+var SkillEquipRemakePool = map[int32]*SkillEquipRemake{}
|
|
|
+
|
|
|
+type RemakeCost struct {
|
|
|
+ CostMap map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+// 重铸消耗
|
|
|
+var SkillEquipRemakeCostContainer = map[int32]*RemakeCost{}
|
|
|
+
|
|
|
+func convertSkillEquipCfg() {
|
|
|
+ for _, data := range serverproto.ArtifactCfgLoader {
|
|
|
+ // 一个id 对应的所有星级的材料消耗
|
|
|
+ costs := map[int32]map[int32]int32{}
|
|
|
+ SkillEquipStarLevelUpCostContainer[data.Id] = costs
|
|
|
+ for k, v := range data.Condition {
|
|
|
+ resList := strings.Split(v, ":")
|
|
|
+ // 当前星级对应的材料消耗 消耗的itemid,itemnum
|
|
|
+ cost := map[int32]int32{}
|
|
|
+ costs[int32(k)] = cost
|
|
|
+ for _, v1 := range resList {
|
|
|
+ r1, r2 := Str2ResBySep(v1, "|")
|
|
|
+ _, ok1 := cost[r1]
|
|
|
+ if ok1 {
|
|
|
+ cost[r1] += r2
|
|
|
+ } else {
|
|
|
+ cost[r1] = r2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 一个id 对应的所有星级的材料返还
|
|
|
+ retResLists := map[int32]map[int32]int32{}
|
|
|
+ SkillEquipDecomposeReturnContainer[data.Id] = retResLists
|
|
|
+ for k, v := range data.SmeltReturn {
|
|
|
+ resList := strings.Split(v, ":")
|
|
|
+ // 当前星级对应的材料返还 itemid,itemnum
|
|
|
+ retRes := map[int32]int32{}
|
|
|
+ retResLists[int32(k)] = retRes
|
|
|
+ for _, v1 := range resList {
|
|
|
+ r1, r2 := Str2ResBySep(v1, "|")
|
|
|
+ _, ok1 := retRes[r1]
|
|
|
+ if ok1 {
|
|
|
+ retRes[r1] += r2
|
|
|
+ } else {
|
|
|
+ retRes[r1] = r2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ appendFights := map[int32]int32{}
|
|
|
+ SkillEquipAppendFightPowerContainer[data.Id] = appendFights
|
|
|
+ for k, v := range data.AddFight {
|
|
|
+ fight, error := Str2Num(v)
|
|
|
+ if error != nil {
|
|
|
+ util.PanicF("convertSkillEquipCfg AddFight id=%d", data.Id)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ appendFights[int32(k)] = int32(fight)
|
|
|
+ }
|
|
|
+
|
|
|
+ //skillList := map[int32]int32{}
|
|
|
+ //SkillEquipAppendSkillContainer[data.Id] = skillList
|
|
|
+ //for k, v := range data.ArtifacFuncId {
|
|
|
+ // skillId, error := Str2Num(v)
|
|
|
+ // if error != nil {
|
|
|
+ // util.ErrorF("convertSkillEquipCfg ArtifacFuncId id=%d", data.Id)
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // skillList[int32(k)] = int32(skillId)
|
|
|
+ //}
|
|
|
+ if len(data.ReforgeCost) >= 1 {
|
|
|
+ costConvert := &RemakeCost{
|
|
|
+ CostMap: map[int32]int32{},
|
|
|
+ }
|
|
|
+ for _, data := range data.ReforgeCost {
|
|
|
+ itemId, itemNum := Str2Res(data)
|
|
|
+ if itemId > 0 && itemNum > 0 {
|
|
|
+ costConvert.CostMap[itemId] += itemNum
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SkillEquipRemakeCostContainer[data.Id] = costConvert
|
|
|
+ }
|
|
|
+
|
|
|
+ if data.Times != 0 {
|
|
|
+ poolData, ok := SkillEquipRemakePool[data.Times]
|
|
|
+ if !ok {
|
|
|
+ convertData := &SkillEquipRemake{
|
|
|
+ Id: data.Times,
|
|
|
+ }
|
|
|
+ startDay, endDay := Str2Res(data.ArtifactDuration[0])
|
|
|
+ convertData.BeginDay = startDay
|
|
|
+ convertData.EndDay = endDay
|
|
|
+
|
|
|
+ convertData.CurForgePool = append(convertData.CurForgePool, data.Id)
|
|
|
+ convertData.RealPool = append(convertData.RealPool, data.Id)
|
|
|
+ SkillEquipRemakePool[data.Times] = convertData
|
|
|
+ } else {
|
|
|
+ poolData.CurForgePool = append(poolData.CurForgePool, data.Id)
|
|
|
+ poolData.RealPool = append(poolData.RealPool, data.Id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for i := 1; i <= len(SkillEquipRemakePool); i++ {
|
|
|
+ curPool, ok := SkillEquipRemakePool[int32(i)]
|
|
|
+ if !ok {
|
|
|
+ //异常(当前批次不应该找不到)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ nextPool, okNext := SkillEquipRemakePool[int32(i+1)]
|
|
|
+ if !okNext {
|
|
|
+ //说明当前批次是最后一批
|
|
|
+ break
|
|
|
+ }
|
|
|
+
|
|
|
+ //初始化下一阶段的重铸池
|
|
|
+ curPool.NextForgePool = append(curPool.NextForgePool, nextPool.CurForgePool...)
|
|
|
+ curPool.NextBegin = nextPool.NextBegin
|
|
|
+
|
|
|
+ //初始化,下一阶段的重铸池子
|
|
|
+ nextPool.RealPool = append(nextPool.RealPool, curPool.RealPool...)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.ArtifactExpCfgLoader {
|
|
|
+ cost := map[int32]int32{}
|
|
|
+ SkillEquipSlotLevelUpCostContainer[data.ArtifactLevel] = cost
|
|
|
+ for _, v := range data.UpgradeCost {
|
|
|
+ r1, r2 := Str2Res(v)
|
|
|
+ _, ok1 := cost[r1]
|
|
|
+ if ok1 {
|
|
|
+ cost[r1] += r2
|
|
|
+ } else {
|
|
|
+ cost[r1] = r2
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ attr := map[serverproto.Attr]float32{}
|
|
|
+ SkillEquipSlotAppendAttrContainer[data.ArtifactLevel] = attr
|
|
|
+ for _, v := range data.Nature {
|
|
|
+ r1, r2 := Str2Res(v)
|
|
|
+ _, ok1 := attr[serverproto.Attr(r1)]
|
|
|
+ if ok1 {
|
|
|
+ attr[serverproto.Attr(r1)] += float32(r2)
|
|
|
+ } else {
|
|
|
+ attr[serverproto.Attr(r1)] = float32(r2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func CheckNeedInitStartTime() {
|
|
|
+ loc := util.GetLoc()
|
|
|
+ startUpTime := service.GetServiceStartupTime()
|
|
|
+ if startUpTime < 0 {
|
|
|
+ util.ErrorF("[SkillEquipRemakePool] data error:%v")
|
|
|
+ }
|
|
|
+ startServer := time.Unix(int64(startUpTime/1000), 0).In(loc).Format(util.DATE_FORMAT1)
|
|
|
+ startUpDayStr := util.GetDayByTimeStr1(startServer)
|
|
|
+
|
|
|
+ for i := 1; i <= len(SkillEquipRemakePool); i++ {
|
|
|
+ _, ok := SkillEquipRemakePool[int32(i)]
|
|
|
+ if !ok {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if SkillEquipRemakePool[int32(i)].CurBegin <= 0 {
|
|
|
+ //计算开服时间
|
|
|
+ startTime := time.Unix(startUpDayStr.Unix()+int64(SkillEquipRemakePool[int32(i)].BeginDay-1)*int64(DaySec), 0).In(loc)
|
|
|
+ SkillEquipRemakePool[int32(i)].CurBegin = uint64(startTime.UnixNano()/1e6) + 3600*5*1000
|
|
|
+
|
|
|
+ if SkillEquipRemakePool[int32(i)].EndDay > 0 {
|
|
|
+ endTime := time.Unix(startUpDayStr.Unix()+int64(SkillEquipRemakePool[int32(i)].EndDay-1)*int64(DaySec), 0).In(loc)
|
|
|
+ SkillEquipRemakePool[int32(i)].CurEnd = uint64(endTime.UnixNano()/1e6) + 3600*5*1000
|
|
|
+ }
|
|
|
+
|
|
|
+ util.InfoF("[SkillEquipRemakePool] CurBegin:%v, CurEnd:%v", SkillEquipRemakePool[int32(i)].CurBegin, SkillEquipRemakePool[int32(i)].CurEnd)
|
|
|
+ }
|
|
|
+
|
|
|
+ if i > 1 {
|
|
|
+ _, ok2 := SkillEquipRemakePool[int32(i-1)]
|
|
|
+ if ok2 {
|
|
|
+ SkillEquipRemakePool[int32(i-1)].NextBegin = SkillEquipRemakePool[int32(i)].CurBegin
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func GetCurForgePool() *SkillEquipRemake {
|
|
|
+ CheckNeedInitStartTime()
|
|
|
+ curTime := util.GetCurrentTime()
|
|
|
+
|
|
|
+ for i := 1; i <= len(SkillEquipRemakePool); i++ {
|
|
|
+ _, ok := SkillEquipRemakePool[int32(i)]
|
|
|
+ if !ok {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ if SkillEquipRemakePool[int32(i)].CurBegin <= 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ if i == 1 {
|
|
|
+ if curTime < SkillEquipRemakePool[int32(i)].CurBegin {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if SkillEquipRemakePool[int32(i)].CurBegin <= curTime {
|
|
|
+ if (SkillEquipRemakePool[int32(i)].CurEnd != 0 && curTime < SkillEquipRemakePool[int32(i)].CurEnd) ||
|
|
|
+ SkillEquipRemakePool[int32(i)].CurEnd == 0 {
|
|
|
+ return SkillEquipRemakePool[int32(i)]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+type EquipRefineSet struct {
|
|
|
+ AttrSet []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var EquipRefineContainer = map[int32]*EquipRefineSet{}
|
|
|
+
|
|
|
+func convertEquipRefineCfg() {
|
|
|
+ for _, data := range serverproto.EquipRefineCfgLoader {
|
|
|
+ convertData := &EquipRefineSet{}
|
|
|
+ for idx := range data.SuitServer {
|
|
|
+ key, value := Str2Res(data.SuitServer[idx])
|
|
|
+ if key <= 0 || value <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ EquipRefineContainer[int32(data.Id)] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type FightPowerSet struct {
|
|
|
+ AttrSet []*serverproto.KeyValueType
|
|
|
+ Mapping int32
|
|
|
+}
|
|
|
+
|
|
|
+var FightPowerContainer = map[int32]*FightPowerSet{}
|
|
|
+
|
|
|
+var ConvertFightPower = map[int32]map[int32]int32{} //[jobtype][attrkey][attrval]
|
|
|
+
|
|
|
+func convertFightPowerCfg() {
|
|
|
+ for _, data := range serverproto.FightCfgLoader {
|
|
|
+ convertData := &FightPowerSet{}
|
|
|
+ for _, attrData := range data.Coefficient {
|
|
|
+ key, value := Str2Res(attrData)
|
|
|
+ if key < 0 || value <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ convertData.Mapping = data.Mapping
|
|
|
+
|
|
|
+ FightPowerContainer[int32(data.Id)] = convertData
|
|
|
+
|
|
|
+ for idx := 0; idx < len(data.Coefficient); idx++ {
|
|
|
+ k, v := Str2Res(data.Coefficient[idx])
|
|
|
+ if _, ok := ConvertFightPower[k]; !ok {
|
|
|
+ ConvertFightPower[k] = map[int32]int32{}
|
|
|
+ }
|
|
|
+ ConvertFightPower[k][data.Id] = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type EquipSuitAttr struct {
|
|
|
+ AttrSet map[int32]map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var SuitAttrContainer = map[int32]*EquipSuitAttr{}
|
|
|
+
|
|
|
+func convertEquipSuitCfg() {
|
|
|
+ for _, data := range serverproto.EquipSuitNewCfgLoader {
|
|
|
+ convertData := &EquipSuitAttr{
|
|
|
+ AttrSet: map[int32]map[int32]int32{},
|
|
|
+ }
|
|
|
+ var mapAttribute0 map[int32]int32
|
|
|
+ mapAttribute0 = make(map[int32]int32)
|
|
|
+ for index, _ := range data.Suit1 {
|
|
|
+ key, value := Str2Res(data.Suit1[index])
|
|
|
+ if key <= 0 || value <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapAttribute0[key] = value
|
|
|
+ }
|
|
|
+ convertData.AttrSet[0] = mapAttribute0
|
|
|
+
|
|
|
+ var mapAttribute1 map[int32]int32
|
|
|
+ mapAttribute1 = make(map[int32]int32)
|
|
|
+ for index, _ := range data.Suit2 {
|
|
|
+ key, value := Str2Res(data.Suit2[index])
|
|
|
+ if key <= 0 || value <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapAttribute1[key] = value
|
|
|
+ }
|
|
|
+ convertData.AttrSet[1] = mapAttribute1
|
|
|
+
|
|
|
+ var mapAttribute2 map[int32]int32
|
|
|
+ mapAttribute2 = make(map[int32]int32)
|
|
|
+ for index, _ := range data.Suit3 {
|
|
|
+ key, value := Str2Res(data.Suit3[index])
|
|
|
+ if key <= 0 || value <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapAttribute2[key] = value
|
|
|
+ }
|
|
|
+ convertData.AttrSet[2] = mapAttribute2
|
|
|
+
|
|
|
+ SuitAttrContainer[int32(data.Id)] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type ChangeCondition struct {
|
|
|
+ Condition map[int32][]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ChangeJobCond = map[int32]*ChangeCondition{}
|
|
|
+
|
|
|
+func convertChangeJobCfg() {
|
|
|
+ for _, data := range serverproto.ConditionCfgLoader {
|
|
|
+ convertData := &ChangeCondition{
|
|
|
+ Condition: make(map[int32][]int32),
|
|
|
+ }
|
|
|
+ for _, subData := range data.Condition {
|
|
|
+ condList := strings.Split(subData, ":")
|
|
|
+ if len(condList) < 2 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ taskType, _ := Str2Num(condList[0])
|
|
|
+ convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
|
|
|
+ for i := 1; i < len(condList); i++ {
|
|
|
+ cfgValue, _ := Str2Num(condList[i])
|
|
|
+ convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(cfgValue))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ChangeJobCond[data.ConditionId] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type ArenaRankSeasonInfo struct {
|
|
|
+ ZoneId int32
|
|
|
+ SeasonId int32
|
|
|
+ RewardInfo []*ArenaRankRewardInfo
|
|
|
+ Duration int32
|
|
|
+ Reset int32
|
|
|
+ StartTimeStr, EndTimeStr string
|
|
|
+ StartTime, EndTime time.Time
|
|
|
+
|
|
|
+ DiffDurationDay int64
|
|
|
+}
|
|
|
+type ArenaRankRewardInfo struct {
|
|
|
+ Left, Right int32
|
|
|
+ RewardList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+// var ConvertArenaSeasonReward = map[int32]*ArenaRankSeasonInfo{} //赛季对应top排行奖励
|
|
|
+var ConvertArenaSeason *ArenaRankSeasonInfo = nil
|
|
|
+
|
|
|
+type ArenaMatchInfo struct {
|
|
|
+ LevelId int32 //段位ID
|
|
|
+ MinScore int32 //段位对应的最低分
|
|
|
+ Score int32 //段位对应的最高分
|
|
|
+ ScoreRewardList, WinRewardList, FailedRewardList map[int32]int32 //段位奖励 胜利奖励 失败奖励
|
|
|
+ WinScore, WinScore1, WinScore2 int32 //score 与强敌胜利获得积分
|
|
|
+ FailedScore, FailedScore1, FailedScore2 int32
|
|
|
+ ScoreSectionLeft, ScoreSectionRight float32 //强弱区间
|
|
|
+ WinStreak []int32
|
|
|
+ //match
|
|
|
+ WinMatchList, FailedMatchList []serverproto.KeyValueType
|
|
|
+ LevelReduce int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertArenaMatch []*ArenaMatchInfo //arena胜利失败奖励
|
|
|
+var ConvertArenaMatchList = map[int32]*ArenaMatchInfo{}
|
|
|
+var ConvertScoreToArenaLevelList = map[int32]int32{} //最低分数对应段位
|
|
|
+var MinTopRankScore int32 = 0 //入top排行榜最低积分(段位的积分)
|
|
|
+
|
|
|
+func convertArenaCfg(zoneId int32) {
|
|
|
+ //clean for reload
|
|
|
+ ConvertArenaMatch = []*ArenaMatchInfo{}
|
|
|
+ ConvertArenaMatchList = map[int32]*ArenaMatchInfo{}
|
|
|
+ ConvertScoreToArenaLevelList = map[int32]int32{}
|
|
|
+ MinTopRankScore = 0
|
|
|
+
|
|
|
+ //ArenaRewardCfg
|
|
|
+ //加载对应服务器赛季数据
|
|
|
+ for _, data := range serverproto.ArenaRewardCfgLoader {
|
|
|
+ if data.Zone != zoneId {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if ConvertArenaSeason == nil {
|
|
|
+ ConvertArenaSeason = &ArenaRankSeasonInfo{
|
|
|
+ ZoneId: data.Zone,
|
|
|
+ SeasonId: 0,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if data.StartTime != "" && data.CloseTime != "" {
|
|
|
+ //loc := util.GetLoc()
|
|
|
+ //sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.StartTime, loc)
|
|
|
+ //if err1 != nil {
|
|
|
+ // util.PanicF("convertArenaCfg startTime err:%v", err1)
|
|
|
+ //}
|
|
|
+ //ConvertArenaSeason.StartTime = sTime
|
|
|
+ ConvertArenaSeason.StartTimeStr = data.StartTime
|
|
|
+
|
|
|
+ //cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.CloseTime, loc)
|
|
|
+ //if err2 != nil {
|
|
|
+ // util.PanicF("convertArenaCfg endTime err:%v", err2)
|
|
|
+ //}
|
|
|
+ //ConvertArenaSeason.EndTime = cTime
|
|
|
+ ConvertArenaSeason.EndTimeStr = data.CloseTime
|
|
|
+ }
|
|
|
+
|
|
|
+ rankRewardInfo := &ArenaRankRewardInfo{
|
|
|
+ RewardList: map[int32]int32{},
|
|
|
+ }
|
|
|
+ if len(data.ArenaRank) > 1 {
|
|
|
+ left, _ := Str2Num(data.ArenaRank[0])
|
|
|
+ right, _ := Str2Num(data.ArenaRank[1])
|
|
|
+ rankRewardInfo.Left = int32(left)
|
|
|
+ rankRewardInfo.Right = int32(right)
|
|
|
+ } else {
|
|
|
+ left, _ := Str2Num(data.ArenaRank[0])
|
|
|
+ rankRewardInfo.Left = int32(left)
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := range data.ArenaReward {
|
|
|
+ key, value := Str2Res(data.ArenaReward[idx])
|
|
|
+ rankRewardInfo.RewardList[key] += value
|
|
|
+ }
|
|
|
+ ConvertArenaSeason.RewardInfo = append(ConvertArenaSeason.RewardInfo, rankRewardInfo)
|
|
|
+ ConvertArenaSeason.Reset = data.Rest
|
|
|
+ }
|
|
|
+ //未找到对应zone数据,默认使用zone=1数据
|
|
|
+ zoneId = 1
|
|
|
+ if ConvertArenaSeason == nil {
|
|
|
+ for _, data := range serverproto.ArenaRewardCfgLoader {
|
|
|
+ if data.Zone != zoneId {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if ConvertArenaSeason == nil {
|
|
|
+ ConvertArenaSeason = &ArenaRankSeasonInfo{
|
|
|
+ ZoneId: data.Zone,
|
|
|
+ SeasonId: 0,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if data.StartTime != "" && data.CloseTime != "" {
|
|
|
+ //loc := util.GetLoc()
|
|
|
+ //sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.StartTime, loc)
|
|
|
+ //if err1 != nil {
|
|
|
+ // util.PanicF("convertArenaCfg startTime err:%v", err1)
|
|
|
+ //}
|
|
|
+ //ConvertArenaSeason.StartTime = sTime
|
|
|
+ ConvertArenaSeason.StartTimeStr = data.StartTime
|
|
|
+
|
|
|
+ //cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.CloseTime, loc)
|
|
|
+ //if err2 != nil {
|
|
|
+ // util.PanicF("convertArenaCfg endTime err:%v", err2)
|
|
|
+ //}
|
|
|
+ //ConvertArenaSeason.EndTime = cTime
|
|
|
+ ConvertArenaSeason.EndTimeStr = data.CloseTime
|
|
|
+ }
|
|
|
+
|
|
|
+ rankRewardInfo := &ArenaRankRewardInfo{
|
|
|
+ RewardList: map[int32]int32{},
|
|
|
+ }
|
|
|
+ if len(data.ArenaRank) > 1 {
|
|
|
+ left, _ := Str2Num(data.ArenaRank[0])
|
|
|
+ right, _ := Str2Num(data.ArenaRank[1])
|
|
|
+ rankRewardInfo.Left = int32(left)
|
|
|
+ rankRewardInfo.Right = int32(right)
|
|
|
+ } else {
|
|
|
+ left, _ := Str2Num(data.ArenaRank[0])
|
|
|
+ rankRewardInfo.Left = int32(left)
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := range data.ArenaReward {
|
|
|
+ key, value := Str2Res(data.ArenaReward[idx])
|
|
|
+ rankRewardInfo.RewardList[key] += value
|
|
|
+ }
|
|
|
+ ConvertArenaSeason.RewardInfo = append(ConvertArenaSeason.RewardInfo, rankRewardInfo)
|
|
|
+ ConvertArenaSeason.Reset = data.Rest
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sort.Slice(ConvertArenaSeason.RewardInfo, func(i, j int) bool {
|
|
|
+ return ConvertArenaSeason.RewardInfo[i].Left < ConvertArenaSeason.RewardInfo[j].Left
|
|
|
+ })
|
|
|
+ ConvertArenaSeason.DiffDurationDay = util.GetDurationDay(ConvertArenaSeason.StartTimeStr, ConvertArenaSeason.EndTimeStr)
|
|
|
+
|
|
|
+ //ArenaLevelCfg
|
|
|
+ var minScore int32 = 0
|
|
|
+ var levelKeyList []int32
|
|
|
+ for _, data := range serverproto.ArenaLevelCfgLoader {
|
|
|
+ levelKeyList = append(levelKeyList, data.ArenaLevelId)
|
|
|
+ }
|
|
|
+ sort.Slice(levelKeyList, func(i, j int) bool {
|
|
|
+ return levelKeyList[i] < levelKeyList[j]
|
|
|
+ })
|
|
|
+ for idx := 0; idx < len(levelKeyList); idx++ {
|
|
|
+ data := serverproto.ArenaLevelCfgLoader[levelKeyList[idx]]
|
|
|
+ info := &ArenaMatchInfo{
|
|
|
+ LevelId: data.ArenaLevelId,
|
|
|
+ Score: data.ArenaLevelScore,
|
|
|
+ ScoreRewardList: map[int32]int32{},
|
|
|
+ WinRewardList: map[int32]int32{},
|
|
|
+ FailedRewardList: map[int32]int32{},
|
|
|
+ WinScore: data.WinScore,
|
|
|
+ WinScore1: data.WinScore1,
|
|
|
+ WinScore2: data.WinScore2,
|
|
|
+ FailedScore: data.LostScore,
|
|
|
+ FailedScore1: data.LostScore1,
|
|
|
+ FailedScore2: data.LostScore2,
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := range data.ArenaLevelReward {
|
|
|
+ key, value := Str2Res(data.ArenaLevelReward[idx])
|
|
|
+ if key > 0 && value > 0 {
|
|
|
+ info.ScoreRewardList[key] = value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for idx := range data.WinReward {
|
|
|
+ key, value := Str2Res(data.WinReward[idx])
|
|
|
+ if key > 0 && value > 0 {
|
|
|
+ info.WinRewardList[key] = value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for idx := range data.FailReward {
|
|
|
+ key, value := Str2Res(data.FailReward[idx])
|
|
|
+ if key > 0 && value > 0 {
|
|
|
+ info.FailedRewardList[key] = value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(data.Section) == 2 {
|
|
|
+ left, _ := Str2Num(data.Section[0])
|
|
|
+ right, _ := Str2Num(data.Section[1])
|
|
|
+ info.ScoreSectionLeft = 1 + float32(left)*0.01
|
|
|
+ info.ScoreSectionRight = 1 + float32(right)*0.01
|
|
|
+ }
|
|
|
+ info.WinStreak = append(info.WinStreak, 0)
|
|
|
+ for idx := range data.WinStreak {
|
|
|
+ val, _ := Str2Num(data.WinStreak[idx])
|
|
|
+ info.WinStreak = append(info.WinStreak, int32(val))
|
|
|
+ }
|
|
|
+ for idx := range data.Win {
|
|
|
+ left, right := Str2Res(data.Win[idx])
|
|
|
+ info.WinMatchList = append(info.WinMatchList, serverproto.KeyValueType{Key: left, Value: right})
|
|
|
+ }
|
|
|
+ for idx := range data.Fail {
|
|
|
+ left, right := Str2Res(data.Fail[idx])
|
|
|
+ info.FailedMatchList = append(info.FailedMatchList, serverproto.KeyValueType{Key: left, Value: right})
|
|
|
+ }
|
|
|
+ info.LevelReduce = data.LevelReduce
|
|
|
+ if minScore == 0 {
|
|
|
+ info.MinScore = minScore
|
|
|
+ } else {
|
|
|
+ info.MinScore = minScore + 1
|
|
|
+ }
|
|
|
+ ConvertArenaMatch = append(ConvertArenaMatch, info)
|
|
|
+ ConvertArenaMatchList[info.LevelId] = info
|
|
|
+ ConvertScoreToArenaLevelList[info.MinScore] = info.LevelId
|
|
|
+ minScore = info.Score
|
|
|
+ }
|
|
|
+ sort.Slice(ConvertArenaMatch, func(i, j int) bool {
|
|
|
+ return ConvertArenaMatch[i].Score < ConvertArenaMatch[j].Score
|
|
|
+ })
|
|
|
+ MinTopRankScore = ConvertArenaMatch[len(ConvertArenaMatch)-3].MinScore
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertDaoChang100Info struct {
|
|
|
+ posIdx int32
|
|
|
+ posIdxType int32
|
|
|
+ PosIdxFuncType int32
|
|
|
+ RewardList []*serverproto.KeyValueType
|
|
|
+ RobotId int32
|
|
|
+ TimeProtect uint64
|
|
|
+ TimeReward uint64
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertDaoChang100List = map[int32]*ConvertDaoChang100Info{}
|
|
|
+
|
|
|
+func convertDaoChang100Cfg() {
|
|
|
+ for _, data := range serverproto.HundredDojoCfgLoader {
|
|
|
+ info := &ConvertDaoChang100Info{
|
|
|
+ posIdx: data.Id,
|
|
|
+ posIdxType: data.AreaType,
|
|
|
+ PosIdxFuncType: data.FunType,
|
|
|
+ RobotId: data.Robot,
|
|
|
+ TimeProtect: uint64(data.TimeProtect) * 60 * 1000,
|
|
|
+ TimeReward: uint64(data.TimeReward) * 60 * 1000,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.RewardList); idx++ {
|
|
|
+ k, v := Str2Res(data.RewardList[idx])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ info.RewardList = append(info.RewardList, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if data.FunType == 1 {
|
|
|
+ if _, ok := ConvertRobotDaoChang100[data.Robot]; !ok {
|
|
|
+ panic("ConvertRobotDaoChang100 nil")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertDaoChang100List[info.posIdx] = info
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertPartnerInfo struct {
|
|
|
+ PartnerId int32
|
|
|
+ EquipList []int32
|
|
|
+ Level int32
|
|
|
+}
|
|
|
+type ConvertRobotInfo struct {
|
|
|
+ RobotId int32
|
|
|
+ RobotName string
|
|
|
+ ArenaId int32
|
|
|
+ Level int32
|
|
|
+ Avatar int32
|
|
|
+ EquipList []int32
|
|
|
+ SkillList []int32
|
|
|
+ Head int32
|
|
|
+ PartnerIdList []*ConvertPartnerInfo
|
|
|
+ FightInfo *serverproto.FightRoleInfo
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertRobotInfo) initFightInfo() {
|
|
|
+ this.FightInfo = &serverproto.FightRoleInfo{
|
|
|
+ IsRobot: true,
|
|
|
+ BriefInfo: &serverproto.CommonPlayerBriefInfo{
|
|
|
+ Uid: uint64(this.RobotId),
|
|
|
+ NickName: this.RobotName,
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertArenaRobot []int32 //[ArenaLevelId,RobotId]
|
|
|
+var ConvertRobot = map[int32]*ConvertRobotInfo{}
|
|
|
+var ConvertRobotDaoChang100 = map[int32]*ConvertRobotInfo{}
|
|
|
+var ConvertRobotCrossTopTower []*ConvertRobotInfo
|
|
|
+
|
|
|
+func convertRobotCfg() {
|
|
|
+ //clean for reload
|
|
|
+ ConvertArenaRobot = []int32{}
|
|
|
+ ConvertRobot = map[int32]*ConvertRobotInfo{}
|
|
|
+ ConvertRobotDaoChang100 = map[int32]*ConvertRobotInfo{}
|
|
|
+
|
|
|
+ for _, data := range serverproto.RobotCfgLoader {
|
|
|
+ //道场使用(段位对应机器人列表)
|
|
|
+ ConvertArenaRobot = append(ConvertArenaRobot, data.RobotId)
|
|
|
+
|
|
|
+ robotData := &ConvertRobotInfo{
|
|
|
+ RobotId: data.RobotId,
|
|
|
+ ArenaId: data.ArenaLevelId,
|
|
|
+ Level: data.RobotLevel,
|
|
|
+ Avatar: data.RobotAvatar,
|
|
|
+ Head: data.RobotHeadPortrait,
|
|
|
+ RobotName: data.RobotName,
|
|
|
+ }
|
|
|
+ for idx := range data.RobotEquip {
|
|
|
+ equipId, _ := Str2Num(data.RobotEquip[idx])
|
|
|
+ robotData.EquipList = append(robotData.EquipList, int32(equipId))
|
|
|
+ }
|
|
|
+ for idx := range data.RobotSkill {
|
|
|
+ skillId, _ := Str2Num(data.RobotSkill[idx])
|
|
|
+ robotData.SkillList = append(robotData.SkillList, int32(skillId))
|
|
|
+ }
|
|
|
+ //伙伴列表
|
|
|
+ for idx := range data.PartnerId {
|
|
|
+ partnerInfo := &ConvertPartnerInfo{}
|
|
|
+ partnerId, _ := Str2Num(data.PartnerId[idx])
|
|
|
+ partnerInfo.PartnerId = int32(partnerId)
|
|
|
+ //伙伴装备
|
|
|
+ partnerEquipStrList := strings.Split(data.PartnerEquip[idx], ":")
|
|
|
+ for j := range partnerEquipStrList {
|
|
|
+ partnerEquipId, _ := Str2Num(partnerEquipStrList[j])
|
|
|
+ partnerInfo.EquipList = append(partnerInfo.EquipList, int32(partnerEquipId))
|
|
|
+ }
|
|
|
+ //伙伴等级
|
|
|
+ partnerLevel, _ := Str2Num(data.PartnerLevel[idx])
|
|
|
+ partnerInfo.Level = int32(partnerLevel)
|
|
|
+
|
|
|
+ robotData.PartnerIdList = append(robotData.PartnerIdList, partnerInfo)
|
|
|
+ }
|
|
|
+ robotData.initFightInfo()
|
|
|
+
|
|
|
+ switch data.SystemType {
|
|
|
+ case 0:
|
|
|
+ ConvertRobot[data.RobotId] = robotData
|
|
|
+ case 1:
|
|
|
+ ConvertRobotDaoChang100[data.RobotId] = robotData
|
|
|
+ case 2:
|
|
|
+ ConvertRobotCrossTopTower = append(ConvertRobotCrossTopTower, robotData)
|
|
|
+ //ConvertRobotCrossTopTower[data.RobotId] = robotData
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// WorldBossCfg
|
|
|
+var ConvertWorldBoss = map[int32][]*ConvertWorldBossData{} //[1,info][2,info][3,info][0,info]
|
|
|
+
|
|
|
+type KillRewardInfo struct {
|
|
|
+ RewardWeight int32
|
|
|
+ DeductionWeight int32
|
|
|
+ RewardList []*serverproto.KeyValueType //1大奖,2中奖,3参与奖
|
|
|
+}
|
|
|
+
|
|
|
+const (
|
|
|
+ SummonBossType_Normal = iota //普通世界boss
|
|
|
+ SummonBossType_ChangePlay //变身世界boss
|
|
|
+)
|
|
|
+
|
|
|
+type ConvertWorldBossData struct {
|
|
|
+ Id int32
|
|
|
+ RefreshId int32
|
|
|
+ SummonId int32
|
|
|
+ SummonType int32 //
|
|
|
+ StartDay int32 //=0表示根据给定的时间来开启[BossBeginTime,BossEndTime]
|
|
|
+ SummonTime []time.Time //刷新时间
|
|
|
+ DurationTime int32
|
|
|
+
|
|
|
+ RollTotalWeight int32
|
|
|
+ DeductionWeight int32
|
|
|
+ RollList []*KillRewardInfo
|
|
|
+ ReduceHp *serverproto.KeyValueType //1大奖,2中奖,3参与奖
|
|
|
+
|
|
|
+ RefreshTime time.Time //刷新boss的时间错,逻辑中使用
|
|
|
+
|
|
|
+ //WorldBossChangePlay
|
|
|
+ BossBeginTimeStamp uint64
|
|
|
+ BossEndTimeStmp uint64
|
|
|
+ BossBeginTime time.Time
|
|
|
+ BossEndTime time.Time
|
|
|
+ ConsumeList map[int32]int32
|
|
|
+ ChangePlayIdList []*serverproto.KeyValueType
|
|
|
+ TotalChangePlayWeight int32
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertWorldBossData) RandChangePlayId() int32 {
|
|
|
+ var retBossId int32 = 0
|
|
|
+ randWeight := rand.Int31n(this.TotalChangePlayWeight) + 1
|
|
|
+ for idx := 0; idx < len(this.ChangePlayIdList); idx++ {
|
|
|
+ retBossId = this.ChangePlayIdList[idx].Key
|
|
|
+ if this.ChangePlayIdList[idx].Value >= randWeight {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retBossId
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertWorldBossList = map[int32]*ConvertWorldBossData{}
|
|
|
+var ConvertWorldBossChangePlayList = map[int32]*ConvertWorldBossData{}
|
|
|
+
|
|
|
+func convertWorldBossCfg() {
|
|
|
+ //WorldBossCfg
|
|
|
+ for _, data := range serverproto.WorldBossCfgLoader {
|
|
|
+ refreshId := data.Id % 4
|
|
|
+ convertData, ok := ConvertWorldBossList[data.Id]
|
|
|
+ if !ok {
|
|
|
+ convertData = &ConvertWorldBossData{
|
|
|
+ RefreshId: refreshId,
|
|
|
+ Id: data.Id,
|
|
|
+ DurationTime: 3600,
|
|
|
+ SummonId: data.SummonId,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ convertData.StartDay = data.StartDay
|
|
|
+ //convertData.Roll = data.Roll
|
|
|
+ convertData.DurationTime = data.LifeTime
|
|
|
+
|
|
|
+ loc := util.GetLoc()
|
|
|
+ for idx := range data.SummonTime {
|
|
|
+ sTime, err := time.ParseInLocation(util.DATE_FORMAT3, data.SummonTime[idx], loc)
|
|
|
+ if err == nil {
|
|
|
+ convertData.SummonTime = append(convertData.SummonTime, sTime)
|
|
|
+ //util.DebugF("bossid=%v summontime=%v", convertData.Id, sTime.String())
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := 0; idx < len(data.Roll); idx++ {
|
|
|
+ rollVal, _ := Str2Num(data.Roll[idx]) //正常概率
|
|
|
+ if rollVal <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ rollVal2, _ := Str2Num(data.Roll2[idx]) //衰减概率
|
|
|
+ if rollVal2 <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.RollTotalWeight += int32(rollVal)
|
|
|
+ convertData.DeductionWeight += int32(rollVal2)
|
|
|
+
|
|
|
+ RollData := &KillRewardInfo{
|
|
|
+ RewardWeight: convertData.RollTotalWeight,
|
|
|
+ DeductionWeight: convertData.DeductionWeight,
|
|
|
+ }
|
|
|
+ if idx == 0 {
|
|
|
+ for idx := 0; idx < len(data.FirstRewardServer); idx++ {
|
|
|
+ key, val := Str2Res(data.FirstRewardServer[idx])
|
|
|
+ if key <= 0 || val <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if idx == 1 {
|
|
|
+ for idx := 0; idx < len(data.SecondRewardServer); idx++ {
|
|
|
+ key, val := Str2Res(data.SecondRewardServer[idx])
|
|
|
+ if key <= 0 || val <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if idx == 2 {
|
|
|
+ for idx := 0; idx < len(data.ThreeRewardServer); idx++ {
|
|
|
+ key, val := Str2Res(data.ThreeRewardServer[idx])
|
|
|
+ if key <= 0 || val <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ key, value := Str2Res(data.AutoHp[0])
|
|
|
+ convertData.ReduceHp = &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ }
|
|
|
+ convertData.RollList = append(convertData.RollList, RollData)
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertWorldBossList[data.Id] = convertData
|
|
|
+ //log.Print("time:", convertData.SummonTime[0].String(), convertData.SummonTime[1].String(), convertData.SummonTime[2].String())
|
|
|
+
|
|
|
+ ConvertWorldBoss[refreshId] = append(ConvertWorldBoss[refreshId], convertData)
|
|
|
+ sort.Slice(ConvertWorldBoss[refreshId], func(i, j int) bool {
|
|
|
+ return ConvertWorldBoss[refreshId][i].StartDay < ConvertWorldBoss[refreshId][j].StartDay
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ //WorldBossChangePlayCfg
|
|
|
+ for _, data := range serverproto.WorldBossChangePlayCfgLoader {
|
|
|
+ convertData := &ConvertWorldBossData{
|
|
|
+ //RefreshId: refreshId,
|
|
|
+ Id: data.Id,
|
|
|
+ DurationTime: data.LifeTime,
|
|
|
+ SummonId: data.SummonId,
|
|
|
+ ConsumeList: map[int32]int32{},
|
|
|
+ }
|
|
|
+ convertData.SummonType = SummonBossType_ChangePlay
|
|
|
+
|
|
|
+ loc := util.GetLoc()
|
|
|
+ for idx := range data.SummonTime {
|
|
|
+ sTime, err := time.ParseInLocation(util.DATE_FORMAT3, data.SummonTime[idx], loc)
|
|
|
+ if err == nil {
|
|
|
+ convertData.SummonTime = append(convertData.SummonTime, sTime)
|
|
|
+ //util.DebugF("bossid=%v summontime=%v", convertData.Id, sTime.String())
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //beginTime endTime
|
|
|
+ tmpStartTimeList := strings.Split(data.StartTime, ";")
|
|
|
+ if tmpStartTimeList[0] == "1" && len(tmpStartTimeList) >= 2 {
|
|
|
+ convertData.BossBeginTime = util.GetTimeByStr(tmpStartTimeList[1])
|
|
|
+ convertData.BossBeginTimeStamp = uint64(convertData.BossBeginTime.UnixNano() / 1e6)
|
|
|
+ }
|
|
|
+ tmpEndTimeList := strings.Split(data.EndTime, ";")
|
|
|
+ if tmpEndTimeList[0] == "1" && len(tmpEndTimeList) >= 2 {
|
|
|
+ convertData.BossEndTime = util.GetTimeByStr(tmpEndTimeList[1])
|
|
|
+ convertData.BossEndTimeStmp = uint64(convertData.BossEndTime.UnixNano() / 1e6)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //consume list
|
|
|
+ Str2ResMapList(data.Consume, convertData.ConsumeList)
|
|
|
+
|
|
|
+ //ChangePlayList
|
|
|
+ var totalWeight int32 = 0
|
|
|
+ for idx := 0; idx < len(data.ChangePlayId); idx++ {
|
|
|
+ k, v := Str2Res(data.ChangePlayId[idx])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ totalWeight += k
|
|
|
+ convertData.ChangePlayIdList = append(convertData.ChangePlayIdList,
|
|
|
+ &serverproto.KeyValueType{
|
|
|
+ Key: v,
|
|
|
+ Value: totalWeight,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ convertData.TotalChangePlayWeight = totalWeight
|
|
|
+
|
|
|
+ for idx := 0; idx < len(data.Roll); idx++ {
|
|
|
+ rollVal, _ := Str2Num(data.Roll[idx]) //正常概率
|
|
|
+ if rollVal <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ rollVal2, _ := Str2Num(data.Roll2[idx]) //衰减概率
|
|
|
+ if rollVal2 <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.RollTotalWeight += int32(rollVal)
|
|
|
+ convertData.DeductionWeight += int32(rollVal2)
|
|
|
+
|
|
|
+ RollData := &KillRewardInfo{
|
|
|
+ RewardWeight: convertData.RollTotalWeight,
|
|
|
+ DeductionWeight: convertData.DeductionWeight,
|
|
|
+ }
|
|
|
+ if idx == 0 {
|
|
|
+ for idx := 0; idx < len(data.FirstRewardServer); idx++ {
|
|
|
+ key, val := Str2Res(data.FirstRewardServer[idx])
|
|
|
+ if key <= 0 || val <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if idx == 1 {
|
|
|
+ for idx := 0; idx < len(data.SecondRewardServer); idx++ {
|
|
|
+ key, val := Str2Res(data.SecondRewardServer[idx])
|
|
|
+ if key <= 0 || val <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if idx == 2 {
|
|
|
+ for idx := 0; idx < len(data.ThreeRewardServer); idx++ {
|
|
|
+ key, val := Str2Res(data.ThreeRewardServer[idx])
|
|
|
+ if key <= 0 || val <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ key, value := Str2Res(data.AutoHp[0])
|
|
|
+ convertData.ReduceHp = &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ }
|
|
|
+ convertData.RollList = append(convertData.RollList, RollData)
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertWorldBossChangePlayList[data.Id] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type SkillAttr struct {
|
|
|
+ AttrList map[int32][]*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertSkillAttr = map[int32]*SkillAttr{}
|
|
|
+
|
|
|
+func convertSkillUpEffect() {
|
|
|
+ for _, data := range serverproto.SkillUpEffectCfgLoader {
|
|
|
+ if data == nil {
|
|
|
+ //有错误,直接返回
|
|
|
+ return
|
|
|
+ }
|
|
|
+ passData := ConvertSkillAttr[data.SkillId]
|
|
|
+ if passData == nil {
|
|
|
+ key, value := Str2Res(data.AddAttributes[0])
|
|
|
+ attrData := &SkillAttr{
|
|
|
+ AttrList: map[int32][]*serverproto.KeyValueType{},
|
|
|
+ }
|
|
|
+ skillLevel := data.Id % 1000
|
|
|
+ attrData.AttrList[skillLevel] = append(attrData.AttrList[skillLevel], &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+
|
|
|
+ ConvertSkillAttr[data.SkillId] = attrData
|
|
|
+ } else {
|
|
|
+ key, value := Str2Res(data.AddAttributes[0])
|
|
|
+ skillLevel := data.Id % 1000
|
|
|
+
|
|
|
+ passData.AttrList[skillLevel] = append(passData.AttrList[skillLevel], &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type keyValList struct {
|
|
|
+ KeyType int32
|
|
|
+ ValList []float32
|
|
|
+ RankList []int32
|
|
|
+}
|
|
|
+type compConditionAndRewardData struct {
|
|
|
+ Id int32 //档位
|
|
|
+ CfgId int32 //配置表ID
|
|
|
+ ConditionList []*keyValList //条件
|
|
|
+ RewardList []map[int32]int32 //对应结算周期奖励
|
|
|
+}
|
|
|
+type CompetitionTypeData struct {
|
|
|
+ CompetitionId int32
|
|
|
+ CompetitionType int32
|
|
|
+ ConditionList map[int32]*compConditionAndRewardData //对应档位数据
|
|
|
+ LastConditionId int32
|
|
|
+
|
|
|
+ //赛季特殊道具ID
|
|
|
+ CompetitionItemList set.Interface
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertCompTypeList = map[int32]*CompetitionTypeData{} //赛季类型数据
|
|
|
+func (this *CompetitionTypeData) GetCompetitionType() int32 {
|
|
|
+ return this.CompetitionType
|
|
|
+}
|
|
|
+
|
|
|
+func (this *CompetitionTypeData) GetRankSection(selfRank, totalRank int64) (int32, bool, int32) {
|
|
|
+ if selfRank <= 0 || totalRank <= 0 {
|
|
|
+ return this.LastConditionId, false, this.LastConditionId
|
|
|
+ } else {
|
|
|
+ if totalRank < GlobalCompetitionSectionTotal {
|
|
|
+ totalRank = GlobalCompetitionSectionTotal
|
|
|
+ }
|
|
|
+ rankPercent := 1 - float32(selfRank)*GlobalCompetitionSectionFactor/float32(totalRank)
|
|
|
+ rankPercent = rankPercent * 100
|
|
|
+ //first rank 直接返回第一档
|
|
|
+ if totalRank > 0 && selfRank == 1 {
|
|
|
+ rankPercent = 100
|
|
|
+ }
|
|
|
+ //rankPercent := (1 - float32(selfRank-1)/float32(totalRank)) * 100
|
|
|
+ for _, data := range this.ConditionList {
|
|
|
+ for _, conditionData := range data.ConditionList {
|
|
|
+ if conditionData.KeyType == 5 {
|
|
|
+ if conditionData.RankList[0] <= int32(selfRank) &&
|
|
|
+ int32(selfRank) <= conditionData.RankList[1] {
|
|
|
+ return data.Id, (data.Id == 1), data.CfgId
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if len(conditionData.ValList) >= 2 &&
|
|
|
+ rankPercent > float32(conditionData.ValList[0]) &&
|
|
|
+ rankPercent <= float32(conditionData.ValList[1]) {
|
|
|
+ return data.Id, (data.Id == 1), data.CfgId
|
|
|
+ // return data.Id, data.Id%int32(len(this.ConditionList)) == 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ util.ErrorF("GetRankSection not find correct sectionId rankPercent=%v [please find cehua!!!]", rankPercent)
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.LastConditionId, false, this.LastConditionId
|
|
|
+}
|
|
|
+
|
|
|
+type CompetitionBeginEndTimeData struct {
|
|
|
+ CalBeginTime, CalEndTime time.Time //根据开服时间计算后的开启和结束时间
|
|
|
+}
|
|
|
+type CompetitionTimeData struct {
|
|
|
+ CompetitionId int32
|
|
|
+ CompetitionType int32 //赛季类型
|
|
|
+ Duration int32 //持续天数,天为单位
|
|
|
+ PeriodEndStrList []int
|
|
|
+ BeginTimeStr, EndTimeStr string //开始/结束时间
|
|
|
+ ResetTime int32 //休赛季时间,天为单位
|
|
|
+
|
|
|
+ RewardTimeStr []string
|
|
|
+ RewardTime []time.Time //周期结算时间
|
|
|
+
|
|
|
+ CalBeginTime, CalEndTime time.Time //根据开服时间计算后的开启和结束时间
|
|
|
+ PeriodEndTimeList []time.Time //中间结算时间点
|
|
|
+}
|
|
|
+
|
|
|
+func (this *CompetitionTimeData) GetCalEndTime() time.Time {
|
|
|
+ return this.CalEndTime
|
|
|
+}
|
|
|
+func (this *CompetitionTimeData) GetCompetitionType() int32 {
|
|
|
+ return this.CompetitionType
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertCompTimeList = map[int32]*CompetitionTimeData{} //赛季时间数据
|
|
|
+var ConvertCompTimeIdList []*CompetitionTimeData //赛季时间顺序数据
|
|
|
+func convertCompetitionCfg() {
|
|
|
+ //clean for reload
|
|
|
+ ConvertCompTimeIdList = []*CompetitionTimeData{}
|
|
|
+ ConvertCompTimeList = map[int32]*CompetitionTimeData{}
|
|
|
+
|
|
|
+ //CompetitionCfg
|
|
|
+ ConvertCompTypeList = map[int32]*CompetitionTypeData{}
|
|
|
+ for _, data := range serverproto.CompetitionCfgLoader {
|
|
|
+ info, ok := ConvertCompTypeList[data.CompetitionId]
|
|
|
+ if !ok {
|
|
|
+ info = &CompetitionTypeData{
|
|
|
+ CompetitionId: data.CompetitionId,
|
|
|
+ CompetitionType: data.CompetitionType,
|
|
|
+ ConditionList: map[int32]*compConditionAndRewardData{},
|
|
|
+ CompetitionItemList: set.New(set.NonThreadSafe),
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //条件
|
|
|
+ conditionData := &compConditionAndRewardData{
|
|
|
+ // Id: data.Id,
|
|
|
+ Id: data.Level,
|
|
|
+ CfgId: data.Id,
|
|
|
+ }
|
|
|
+ for idx := range data.CompetitionCondition {
|
|
|
+ dataList := strings.Split(data.CompetitionCondition[idx], ":")
|
|
|
+ keyType, _ := Str2Num(dataList[0])
|
|
|
+
|
|
|
+ keyData := &keyValList{KeyType: int32(keyType)}
|
|
|
+ for i := 1; i < len(dataList); i++ {
|
|
|
+ if keyType == 5 {
|
|
|
+ val, _ := Str2Num(dataList[i])
|
|
|
+ keyData.RankList = append(keyData.RankList, int32(val))
|
|
|
+ } else {
|
|
|
+ val, _ := Str2Float32(dataList[i])
|
|
|
+ //val, _ := Str2Num(dataList[i])
|
|
|
+ keyData.ValList = append(keyData.ValList, float32(val))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ conditionData.ConditionList = append(conditionData.ConditionList, keyData)
|
|
|
+ }
|
|
|
+
|
|
|
+ //结算奖励
|
|
|
+ if data.CompetitionType == 1 || data.CompetitionType == 2 || data.CompetitionType == 3 || data.CompetitionType == 4 ||
|
|
|
+ data.CompetitionType == 5 {
|
|
|
+ //第一次结算
|
|
|
+ var reward1List = map[int32]int32{}
|
|
|
+ for k := 0; k < len(data.CompetitionReward1); k++ {
|
|
|
+ key, val := Str2Res(data.CompetitionReward1[k])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ reward1List[key] += val
|
|
|
+ }
|
|
|
+ }
|
|
|
+ conditionData.RewardList = append(conditionData.RewardList, reward1List)
|
|
|
+ //第二次结算
|
|
|
+ var reward2List = map[int32]int32{}
|
|
|
+ for k := 0; k < len(data.CompetitionReward2); k++ {
|
|
|
+ key, val := Str2Res(data.CompetitionReward2[k])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ reward2List[key] += val
|
|
|
+ }
|
|
|
+ }
|
|
|
+ conditionData.RewardList = append(conditionData.RewardList, reward2List)
|
|
|
+ //第三次次结算
|
|
|
+ var reward3List = map[int32]int32{}
|
|
|
+ for k := 0; k < len(data.CompetitionReward3); k++ {
|
|
|
+ key, val := Str2Res(data.CompetitionReward3[k])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ reward3List[key] += val
|
|
|
+ }
|
|
|
+ }
|
|
|
+ conditionData.RewardList = append(conditionData.RewardList, reward3List)
|
|
|
+ }
|
|
|
+
|
|
|
+ info.ConditionList[data.Id] = conditionData
|
|
|
+ if info.LastConditionId < data.Id {
|
|
|
+ info.LastConditionId = data.Id
|
|
|
+ }
|
|
|
+
|
|
|
+ //活动道具
|
|
|
+ for idx := 0; idx < len(data.HuodongItem); idx++ {
|
|
|
+ val, _ := Str2Num(data.HuodongItem[idx])
|
|
|
+ if val > 0 {
|
|
|
+ info.CompetitionItemList.Add(int32(val))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertCompTypeList[info.CompetitionId] = info
|
|
|
+ }
|
|
|
+
|
|
|
+ //赛季时间处理
|
|
|
+ for _, data := range serverproto.CompetitionCfgLoader {
|
|
|
+ if data.BeginTime == "" || data.EndTime == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ timeInfo, ok := ConvertCompTimeList[data.CompetitionId]
|
|
|
+ if ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ timeInfo = &CompetitionTimeData{
|
|
|
+ CompetitionId: data.CompetitionId,
|
|
|
+ CompetitionType: data.CompetitionType,
|
|
|
+ ResetTime: data.RestTime,
|
|
|
+ BeginTimeStr: data.BeginTime,
|
|
|
+ EndTimeStr: data.EndTime,
|
|
|
+ }
|
|
|
+
|
|
|
+ for k := 0; k < len(data.CompetitionPeriod); k++ {
|
|
|
+ val, _ := Str2Num(data.CompetitionPeriod[k])
|
|
|
+ if val <= 0 {
|
|
|
+ util.PanicF("CompetitionCfgLoader CompetitionPeriod Invalid!!!")
|
|
|
+ }
|
|
|
+ timeInfo.PeriodEndStrList = append(timeInfo.PeriodEndStrList, val)
|
|
|
+ }
|
|
|
+ sort.Ints(timeInfo.PeriodEndStrList)
|
|
|
+ if len(timeInfo.PeriodEndStrList) <= 0 {
|
|
|
+ util.PanicF("CompetitionCfgLoader CompetitionPeriod Invalid!!!")
|
|
|
+ }
|
|
|
+ timeInfo.Duration = int32(timeInfo.PeriodEndStrList[len(timeInfo.PeriodEndStrList)-1])
|
|
|
+
|
|
|
+ ConvertCompTimeList[timeInfo.CompetitionId] = timeInfo
|
|
|
+ ConvertCompTimeIdList = append(ConvertCompTimeIdList, timeInfo)
|
|
|
+ }
|
|
|
+ sort.Slice(ConvertCompTimeIdList, func(i, j int) bool {
|
|
|
+ return ConvertCompTimeIdList[i].CompetitionId < ConvertCompTimeIdList[j].CompetitionId
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const (
|
|
|
+ WheelRewardType_Level = 1
|
|
|
+ WheelRewardType_Normal = 2
|
|
|
+ WheelRewardType_Mini = 3
|
|
|
+ WheelRewardType_MVp = 4
|
|
|
+)
|
|
|
+
|
|
|
+type CompetitionPrizeWheelInfo struct {
|
|
|
+ ID int32
|
|
|
+ //奖励数据
|
|
|
+ LowRewardKv serverproto.KeyValueType
|
|
|
+ NormalRewardKv serverproto.KeyValueType //normal [掉落ID,数量]
|
|
|
+ MiniRewardKV serverproto.KeyValueType
|
|
|
+ MVPRewardKV serverproto.KeyValueType
|
|
|
+
|
|
|
+ Weight int32
|
|
|
+
|
|
|
+ RewardFactorList map[int]int32 //抽奖概率 1low 2normal 3mini 4mvp
|
|
|
+ MvpFactorList []int32 //4mvp
|
|
|
+}
|
|
|
+type WheelItemInfo struct {
|
|
|
+ Key int32 //道具id
|
|
|
+ Val int32 //道具数量
|
|
|
+ Money int32 //金币消耗
|
|
|
+ Score int32 //积分
|
|
|
+}
|
|
|
+type ConvertPrizeWheelInfo struct {
|
|
|
+ RewardTemplateList []*CompetitionPrizeWheelInfo
|
|
|
+ TotalWeight int32
|
|
|
+ WheelCostItem []*WheelItemInfo //道具/金币消耗 抽一次
|
|
|
+ WheelAllCostItem WheelItemInfo //抽全部道具/金币消耗
|
|
|
+
|
|
|
+ RefreshCostMoney []int32 // 刷新价格(金币)
|
|
|
+ NoMVPRewardNum int32 //前面无大奖次数
|
|
|
+ ItemToMoney int32 //单个道具对应金币数量
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertPrizeWheelInfo) genWheelRewardByType(itemIdx *int32, rewardType int32,
|
|
|
+ kv serverproto.KeyValueType, rewardList *[]*serverproto.WheelRewardItemInfo) {
|
|
|
+ for idx := 0; idx < int(kv.Value); idx++ {
|
|
|
+ *itemIdx++
|
|
|
+ rewardItem := &serverproto.WheelRewardItemInfo{
|
|
|
+ ItemIdx: *itemIdx,
|
|
|
+ RewardType: rewardType, //1
|
|
|
+ }
|
|
|
+ tmpDropReward := map[int32]int32{}
|
|
|
+ DropCfgProcess(tmpDropReward, kv.Key)
|
|
|
+ for k, v := range tmpDropReward {
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ rewardItem.ItemId = k
|
|
|
+ rewardItem.ItemNum = v
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ *rewardList = append(*rewardList, rewardItem)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertPrizeWheelInfo) GenWheelReward(rewardList *[]*serverproto.WheelRewardItemInfo) int32 {
|
|
|
+ if this.TotalWeight <= 0 {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+
|
|
|
+ var tmpRewardList []*serverproto.WheelRewardItemInfo
|
|
|
+ randWeight := rand.Int31n(this.TotalWeight) + 1 //[0,randWeight]
|
|
|
+ templateIdx := 0
|
|
|
+ for idx := 0; idx < len(this.RewardTemplateList); idx++ {
|
|
|
+ templateIdx = idx
|
|
|
+ if randWeight <= this.RewardTemplateList[idx].Weight {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ templateInfo := this.RewardTemplateList[templateIdx]
|
|
|
+ var itemIdx int32 = 0
|
|
|
+ //level
|
|
|
+ this.genWheelRewardByType(&itemIdx, WheelRewardType_Level, templateInfo.LowRewardKv, &tmpRewardList)
|
|
|
+ //normal
|
|
|
+ this.genWheelRewardByType(&itemIdx, WheelRewardType_Normal, templateInfo.NormalRewardKv, &tmpRewardList)
|
|
|
+ //mini
|
|
|
+ this.genWheelRewardByType(&itemIdx, WheelRewardType_Mini, templateInfo.MiniRewardKV, &tmpRewardList)
|
|
|
+ //mvp
|
|
|
+ this.genWheelRewardByType(&itemIdx, WheelRewardType_MVp, templateInfo.MVPRewardKV, &tmpRewardList)
|
|
|
+
|
|
|
+ randArray := GenRandomArrayByLen(len(tmpRewardList))
|
|
|
+ for idx := 0; idx < len(randArray); idx++ {
|
|
|
+ *rewardList = append(*rewardList, tmpRewardList[randArray[idx]-1])
|
|
|
+ }
|
|
|
+ util.DebugF("templateIdx=%v GenWheelReward=%v", templateInfo.ID, *rewardList)
|
|
|
+
|
|
|
+ return templateInfo.ID
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertPrizeWheelInfo) GetTemplateData(templateIdx int32) *CompetitionPrizeWheelInfo {
|
|
|
+ for idx := 0; idx < len(this.RewardTemplateList); idx++ {
|
|
|
+ if this.RewardTemplateList[idx].ID == templateIdx {
|
|
|
+ return this.RewardTemplateList[idx]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertPrizeWheelData *ConvertPrizeWheelInfo
|
|
|
+var ConvertActivityPrizeWheelData = map[int32]*ConvertPrizeWheelInfo{}
|
|
|
+
|
|
|
+func convertCompetitionPrizeWheelCfg() {
|
|
|
+ ConvertPrizeWheelData = &ConvertPrizeWheelInfo{}
|
|
|
+ //赛季转盘
|
|
|
+ for _, cfgData := range serverproto.CompetitionPrizeWheelCfgLoader {
|
|
|
+ convertCompetitionPrizeWheelCfgLoad(cfgData, ConvertPrizeWheelData)
|
|
|
+ }
|
|
|
+
|
|
|
+ //活动转盘
|
|
|
+ for _, cfgData := range serverproto.ActivityRoulettelCfgLoader {
|
|
|
+ if _, ok := ConvertActivityPrizeWheelData[cfgData.ActivitiesId]; !ok {
|
|
|
+ ConvertActivityPrizeWheelData[cfgData.ActivitiesId] = &ConvertPrizeWheelInfo{}
|
|
|
+ }
|
|
|
+ convertActivityPrizeWheelCfgLoad(cfgData, ConvertActivityPrizeWheelData[cfgData.ActivitiesId])
|
|
|
+ }
|
|
|
+}
|
|
|
+func convertCompetitionPrizeWheelCfgLoad(cfgData *serverproto.CompetitionPrizeWheelCfg, tmpData *ConvertPrizeWheelInfo) {
|
|
|
+ //赛季转盘
|
|
|
+ tmpData.TotalWeight += cfgData.ModProbability
|
|
|
+ if cfgData.NoRewardNum > 0 {
|
|
|
+ tmpData.NoMVPRewardNum = cfgData.NoRewardNum
|
|
|
+ }
|
|
|
+ if cfgData.ItemPrice > 0 {
|
|
|
+ tmpData.ItemToMoney = cfgData.ItemPrice
|
|
|
+ }
|
|
|
+ if len(cfgData.RefreshPrice) > 0 && cfgData.RefreshPrice[0] != "" {
|
|
|
+ for idx := 0; idx < len(cfgData.RefreshPrice); idx++ {
|
|
|
+ tmpVal, _ := Str2Num(cfgData.RefreshPrice[idx])
|
|
|
+ tmpData.RefreshCostMoney = append(tmpData.RefreshCostMoney, int32(tmpVal))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ templateData := &CompetitionPrizeWheelInfo{
|
|
|
+ ID: cfgData.Id,
|
|
|
+ Weight: tmpData.TotalWeight,
|
|
|
+ RewardFactorList: map[int]int32{},
|
|
|
+ }
|
|
|
+ //low
|
|
|
+ k, v := Str2Res(cfgData.LowNormalNum[0])
|
|
|
+ templateData.LowRewardKv.Key = v
|
|
|
+ templateData.LowRewardKv.Value = k
|
|
|
+ //normal
|
|
|
+ k, v = Str2Res(cfgData.NormalNum[0])
|
|
|
+ templateData.NormalRewardKv.Key = v
|
|
|
+ templateData.NormalRewardKv.Value = k
|
|
|
+ //mini
|
|
|
+ k, v = Str2Res(cfgData.MiniNum[0])
|
|
|
+ templateData.MiniRewardKV.Key = v
|
|
|
+ templateData.MiniRewardKV.Value = k
|
|
|
+ //mvp
|
|
|
+ k, v = Str2Res(cfgData.MvpNum[0])
|
|
|
+ templateData.MVPRewardKV.Key = v
|
|
|
+ templateData.MVPRewardKV.Value = k
|
|
|
+ for idx := 0; idx < len(cfgData.Probability); idx++ {
|
|
|
+ factor, _ := Str2Num(cfgData.Probability[idx])
|
|
|
+ templateData.RewardFactorList[idx+1] = int32(factor)
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.MvpProbability); idx++ {
|
|
|
+ factor, _ := Str2Num(cfgData.MvpProbability[idx])
|
|
|
+ templateData.MvpFactorList = append(templateData.MvpFactorList, int32(factor))
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(cfgData.RewardOneItem) > 0 && cfgData.RewardOneItem[0] != "" {
|
|
|
+ if len(cfgData.RewardOneItem) != len(cfgData.RewardOneGold) {
|
|
|
+ util.PanicF("convertCompetitionPrizeWheelCfg")
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.RewardOneItem); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.RewardOneItem[idx])
|
|
|
+ score, _ := Str2Num(cfgData.RewardOnePoint[idx])
|
|
|
+ tmpMoney, _ := Str2Num(cfgData.RewardOneGold[idx])
|
|
|
+ tmpWheelInfo := &WheelItemInfo{
|
|
|
+ Key: k,
|
|
|
+ Val: v,
|
|
|
+ Money: int32(tmpMoney),
|
|
|
+ Score: int32(score),
|
|
|
+ }
|
|
|
+ tmpData.WheelCostItem = append(tmpData.WheelCostItem, tmpWheelInfo)
|
|
|
+ }
|
|
|
+
|
|
|
+ k, v := Str2Res(cfgData.RewardAllItem[0])
|
|
|
+ tmpData.WheelAllCostItem.Key = k
|
|
|
+ tmpData.WheelAllCostItem.Val = v
|
|
|
+ tmpData.WheelAllCostItem.Money = cfgData.RewardAdllGold
|
|
|
+ tmpData.WheelAllCostItem.Score = cfgData.RewardAllPoint
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpData.RewardTemplateList = append(tmpData.RewardTemplateList, templateData)
|
|
|
+}
|
|
|
+func convertActivityPrizeWheelCfgLoad(cfgData *serverproto.ActivityRoulettelCfg, tmpData *ConvertPrizeWheelInfo) {
|
|
|
+ //赛季转盘
|
|
|
+ tmpData.TotalWeight += cfgData.ModProbability
|
|
|
+ if cfgData.NoRewardNum > 0 {
|
|
|
+ tmpData.NoMVPRewardNum = cfgData.NoRewardNum
|
|
|
+ }
|
|
|
+ if cfgData.ItemPrice > 0 {
|
|
|
+ tmpData.ItemToMoney = cfgData.ItemPrice
|
|
|
+ }
|
|
|
+ if len(cfgData.RefreshPrice) > 0 && cfgData.RefreshPrice[0] != "" {
|
|
|
+ for idx := 0; idx < len(cfgData.RefreshPrice); idx++ {
|
|
|
+ tmpVal, _ := Str2Num(cfgData.RefreshPrice[idx])
|
|
|
+ tmpData.RefreshCostMoney = append(tmpData.RefreshCostMoney, int32(tmpVal))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ templateData := &CompetitionPrizeWheelInfo{
|
|
|
+ ID: cfgData.Id,
|
|
|
+ Weight: tmpData.TotalWeight,
|
|
|
+ RewardFactorList: map[int]int32{},
|
|
|
+ }
|
|
|
+ //low
|
|
|
+ k, v := Str2Res(cfgData.LowNormalNum[0])
|
|
|
+ templateData.LowRewardKv.Key = v
|
|
|
+ templateData.LowRewardKv.Value = k
|
|
|
+ //normal
|
|
|
+ k, v = Str2Res(cfgData.NormalNum[0])
|
|
|
+ templateData.NormalRewardKv.Key = v
|
|
|
+ templateData.NormalRewardKv.Value = k
|
|
|
+ //mini
|
|
|
+ k, v = Str2Res(cfgData.MiniNum[0])
|
|
|
+ templateData.MiniRewardKV.Key = v
|
|
|
+ templateData.MiniRewardKV.Value = k
|
|
|
+ //mvp
|
|
|
+ k, v = Str2Res(cfgData.MvpNum[0])
|
|
|
+ templateData.MVPRewardKV.Key = v
|
|
|
+ templateData.MVPRewardKV.Value = k
|
|
|
+ for idx := 0; idx < len(cfgData.Probability); idx++ {
|
|
|
+ factor, _ := Str2Num(cfgData.Probability[idx])
|
|
|
+ templateData.RewardFactorList[idx+1] = int32(factor)
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.MvpProbability); idx++ {
|
|
|
+ factor, _ := Str2Num(cfgData.MvpProbability[idx])
|
|
|
+ templateData.MvpFactorList = append(templateData.MvpFactorList, int32(factor))
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(cfgData.RewardOneItem) > 0 && cfgData.RewardOneItem[0] != "" {
|
|
|
+ if len(cfgData.RewardOneItem) != len(cfgData.RewardOneGold) {
|
|
|
+ util.PanicF("convertCompetitionPrizeWheelCfg")
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.RewardOneItem); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.RewardOneItem[idx])
|
|
|
+ tmpMoney, _ := Str2Num(cfgData.RewardOneGold[idx])
|
|
|
+ tmpWheelInfo := &WheelItemInfo{
|
|
|
+ Key: k,
|
|
|
+ Val: v,
|
|
|
+ Money: int32(tmpMoney),
|
|
|
+ }
|
|
|
+ tmpData.WheelCostItem = append(tmpData.WheelCostItem, tmpWheelInfo)
|
|
|
+ }
|
|
|
+
|
|
|
+ k, v := Str2Res(cfgData.RewardAllItem[0])
|
|
|
+ tmpData.WheelAllCostItem.Key = k
|
|
|
+ tmpData.WheelAllCostItem.Val = v
|
|
|
+ tmpData.WheelAllCostItem.Money = cfgData.RewardAdllGold
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpData.RewardTemplateList = append(tmpData.RewardTemplateList, templateData)
|
|
|
+}
|
|
|
+
|
|
|
+// 卡片重置
|
|
|
+var ConvertCardResetList = map[int32]*serverproto.CardReset{} //赛季类型数据
|
|
|
+func convertCardResetCfg() {
|
|
|
+ for _, data := range serverproto.CardResetLoader {
|
|
|
+ index := data.CardType*1000 + data.CardLv
|
|
|
+ if index == 0 {
|
|
|
+ //打印一下日志。有问题的
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ ConvertCardResetList[index] = data
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type ResetSkill struct {
|
|
|
+ BackResource map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+type levelUpInfo struct {
|
|
|
+ HeroLevel map[int32]int32 //技能升级对应的等级限制
|
|
|
+ OpenCost []*serverproto.KeyValueType //解锁消耗
|
|
|
+ UpGradeCost map[int32]*serverproto.KeyValueType //升级消耗
|
|
|
+ ResetBack map[int32]int32 //重置返还
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertSkillTree = map[int32]*levelUpInfo{}
|
|
|
+var ConvertPartnerSkillTree = map[int32]*levelUpInfo{}
|
|
|
+var ConvertResetSkill = map[int32]*serverproto.KeyValueType{}
|
|
|
+var ConvertSkillJobAndStage = map[int32][]*serverproto.KeyValueType{} //[jobType*100+jobStage*10 +jobBranch,skillIdList]
|
|
|
+// var ConvertParterSkillJobAndStage = map[int32][]*serverproto.KeyValueType{} //[jobType*100+jobStage*10 +jobBranch,skillIdList]
|
|
|
+var ConvertBattleAttrSkill = map[int32]map[serverproto.Attr]float32{} //优化属性计算
|
|
|
+
|
|
|
+func convertSkillTree() {
|
|
|
+ //解析伙伴的技能升级数据
|
|
|
+ for _, data := range serverproto.ParterSkillTreeCfgLoader {
|
|
|
+ convertData := &levelUpInfo{
|
|
|
+ HeroLevel: map[int32]int32{},
|
|
|
+ UpGradeCost: map[int32]*serverproto.KeyValueType{},
|
|
|
+ ResetBack: map[int32]int32{},
|
|
|
+ }
|
|
|
+
|
|
|
+ dem, ok := serverproto.SkillDemandCfgLoader[data.OpenLevel]
|
|
|
+ if !ok {
|
|
|
+ panic("技能升级表 对应伙伴技能表错误")
|
|
|
+ }
|
|
|
+ for i, lv := range dem.LvupDemand {
|
|
|
+ level, _ := Str2Num(lv)
|
|
|
+ convertData.HeroLevel[int32(i)] = int32(level)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, openCost := range data.OpenNeedCost {
|
|
|
+ key, val := Str2Res(openCost)
|
|
|
+ if key == 0 && val == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.OpenCost = append(convertData.OpenCost, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(val),
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ var backCount int32 = 0
|
|
|
+ for index, upCost := range dem.LvupCost {
|
|
|
+ key, val := Str2Res(upCost)
|
|
|
+ if key == 0 && val == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.UpGradeCost[int32(index)] = &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(val),
|
|
|
+ }
|
|
|
+
|
|
|
+ //初始化返还数量
|
|
|
+ backCount += val
|
|
|
+ convertData.ResetBack[int32(index+2)] += backCount
|
|
|
+ }
|
|
|
+ ConvertPartnerSkillTree[data.SkillId] = convertData
|
|
|
+ }
|
|
|
+
|
|
|
+ //解析伙伴的技能升级数据
|
|
|
+ for _, data := range serverproto.SkillTreeCfgLoader {
|
|
|
+ convertData := &levelUpInfo{
|
|
|
+ HeroLevel: map[int32]int32{},
|
|
|
+ UpGradeCost: map[int32]*serverproto.KeyValueType{},
|
|
|
+ ResetBack: map[int32]int32{},
|
|
|
+ }
|
|
|
+
|
|
|
+ dem, ok := serverproto.SkillDemandCfgLoader[data.OpenLevel]
|
|
|
+ if !ok {
|
|
|
+ panic("技能升级表 对应主角技能表错误")
|
|
|
+ }
|
|
|
+ for index, rLevel := range dem.LvupDemand {
|
|
|
+ level, _ := Str2Num(rLevel)
|
|
|
+ convertData.HeroLevel[int32(index)] = int32(level)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, openCost := range data.OpenNeedCost {
|
|
|
+ key, val := Str2Res(openCost)
|
|
|
+ if key == 0 && val == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.OpenCost = append(convertData.OpenCost, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(val),
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ var backCount int32 = 0
|
|
|
+ for index, cost := range dem.LvupCost {
|
|
|
+ key, val := Str2Res(cost)
|
|
|
+ if key == 0 && val == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.UpGradeCost[int32(index)] = &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(val),
|
|
|
+ }
|
|
|
+
|
|
|
+ //初始化返还数量
|
|
|
+ backCount += val
|
|
|
+ convertData.ResetBack[int32(index+2)] += backCount
|
|
|
+ }
|
|
|
+ ConvertSkillTree[data.SkillId] = convertData
|
|
|
+ }
|
|
|
+
|
|
|
+ globalCfg, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Reset_Skill_Level_Cost)]
|
|
|
+ if !ok {
|
|
|
+ util.InfoF("skill reset cost config not found")
|
|
|
+ }
|
|
|
+ strList := strings.Split(globalCfg.SVal, ";")
|
|
|
+ for idx := range strList {
|
|
|
+ key, value := Str2Res(strList[idx])
|
|
|
+ if key == 0 && value == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ ConvertResetSkill[int32(idx)] = &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type ShopRefreshCost struct {
|
|
|
+ ItemList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+type SpecialShop struct {
|
|
|
+ ItemList []*SpecialShopItem
|
|
|
+ TotalWeight int32 //权重1
|
|
|
+ TotalWeight1 int32 //权重2
|
|
|
+ TotalWeight2 int32 //权重3
|
|
|
+ TotalWeight3 int32 //权重4
|
|
|
+ TotalWeight4 int32 //权重5
|
|
|
+ RefreshTime []int32
|
|
|
+ RefreshCost map[int32]*ShopRefreshCost
|
|
|
+ RefreshCount int32
|
|
|
+}
|
|
|
+
|
|
|
+type SpecialShopItem struct {
|
|
|
+ ShopItem *serverproto.ShopItem
|
|
|
+ Weight int32
|
|
|
+ Weight1 int32
|
|
|
+ Weight2 int32
|
|
|
+ Weight3 int32
|
|
|
+ Weight4 int32
|
|
|
+}
|
|
|
+
|
|
|
+type RedBagShopTime struct {
|
|
|
+ ShopItem *serverproto.ShopItem
|
|
|
+ ItemList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertShopItemData = map[int32]*serverproto.ShopItem{}
|
|
|
+var ConvertRoleShopData = map[int32]*SpecialShop{}
|
|
|
+var ConvertRedBagShopItemData = map[int32]*RedBagShopTime{}
|
|
|
+
|
|
|
+type ItemCondition struct {
|
|
|
+ Conditions []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertShopItemCondition = map[int32]*ItemCondition{}
|
|
|
+
|
|
|
+func convertShopCfg() {
|
|
|
+ //初始化商店类型
|
|
|
+ for _, shopData := range serverproto.ShopTypeCfgLoader {
|
|
|
+ ConvertRoleShopData[shopData.Id] = &SpecialShop{
|
|
|
+ TotalWeight: 0,
|
|
|
+ TotalWeight1: 0,
|
|
|
+ TotalWeight2: 0,
|
|
|
+ TotalWeight3: 0,
|
|
|
+ TotalWeight4: 0,
|
|
|
+ RefreshCost: make(map[int32]*ShopRefreshCost),
|
|
|
+ }
|
|
|
+ //刷新时间
|
|
|
+ for _, refTime := range shopData.RefreshTime {
|
|
|
+ hour, _ := Str2Num(refTime)
|
|
|
+ ConvertRoleShopData[shopData.Id].RefreshTime = append(ConvertRoleShopData[shopData.Id].RefreshTime, int32(hour))
|
|
|
+ }
|
|
|
+ //刷新消耗
|
|
|
+ for index, costData := range shopData.PayForRefresh {
|
|
|
+ limitRes := strings.Split(costData, ":")
|
|
|
+ if len(limitRes) >= 2 {
|
|
|
+ itemId, _ := Str2Num(limitRes[0])
|
|
|
+ itemNum, _ := Str2Num(limitRes[1])
|
|
|
+ _, ok := ConvertRoleShopData[shopData.Id].RefreshCost[int32(index)]
|
|
|
+ if !ok {
|
|
|
+ refreshCost := &ShopRefreshCost{
|
|
|
+ ItemList: make(map[int32]int32),
|
|
|
+ }
|
|
|
+ refreshCost.ItemList[int32(itemId)] += int32(itemNum)
|
|
|
+ ConvertRoleShopData[shopData.Id].RefreshCost[int32(index)] = refreshCost
|
|
|
+ } else {
|
|
|
+ ConvertRoleShopData[shopData.Id].RefreshCost[int32(index)].ItemList[int32(itemId)] += int32(itemNum)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertRoleShopData[shopData.Id].RefreshCount = shopData.RefreshNum
|
|
|
+ }
|
|
|
+ for _, data := range serverproto.ShopCfgLoader {
|
|
|
+ convertData := &serverproto.ShopItem{}
|
|
|
+ convertData.GoodsId = data.GoodsId
|
|
|
+ convertData.Price = data.PayForNum
|
|
|
+ convertData.CurPrice = data.DiscountPayForNum
|
|
|
+ convertData.Dispercent = data.Proportion
|
|
|
+ convertData.Hot = true
|
|
|
+ convertData.HdItemId = data.HdDrop
|
|
|
+ if data.SellWell == 0 {
|
|
|
+ convertData.Hot = false
|
|
|
+ }
|
|
|
+
|
|
|
+ var limitType int32 = 0
|
|
|
+ limitRes := strings.Split(data.RestrictedType, ":")
|
|
|
+ if len(limitRes) >= 2 {
|
|
|
+ lType, _ := Str2Num(limitRes[0])
|
|
|
+ convertData.LimitType = int32(lType)
|
|
|
+ limitType = convertData.LimitType
|
|
|
+ if len(limitRes) == 2 {
|
|
|
+ lCount, _ := Str2Num(limitRes[1])
|
|
|
+ convertData.Count = int32(lCount)
|
|
|
+ }
|
|
|
+ if len(limitRes) >= 3 {
|
|
|
+ lCircle, _ := Str2Num(limitRes[1])
|
|
|
+ convertData.Circle = int32(lCircle)
|
|
|
+ lCount, _ := Str2Num(limitRes[2])
|
|
|
+ convertData.Count = int32(lCount)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if limitType == 3 {
|
|
|
+ loc := util.GetLoc()
|
|
|
+ if data.BeginTime != "" {
|
|
|
+ sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.BeginTime, loc)
|
|
|
+ if err1 != nil {
|
|
|
+ util.PanicF("convertShop startTime err:%v", err1)
|
|
|
+ }
|
|
|
+ convertData.StartTime = int64(sTime.Unix())
|
|
|
+ }
|
|
|
+ if data.EndTime != "" {
|
|
|
+ cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.EndTime, loc)
|
|
|
+ if err2 != nil {
|
|
|
+ util.PanicF("convertShop endTime err:%v", err2)
|
|
|
+ }
|
|
|
+ convertData.EndTime = int64(cTime.Unix())
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //特殊商店单独处理
|
|
|
+ shopType, ok2 := serverproto.ShopTypeCfgLoader[data.GoodsType]
|
|
|
+ if ok2 && shopType.ShopType == 2 {
|
|
|
+ _, ok4 := ConvertRoleShopData[data.GoodsType]
|
|
|
+ if !ok4 {
|
|
|
+ //道具没有对应的商店。这策划不靠谱!!!!
|
|
|
+ util.PanicF("convertShop shopType not found err:%v", data.GoodsType)
|
|
|
+ }
|
|
|
+ //计算最新的权重
|
|
|
+ ConvertRoleShopData[data.GoodsType].TotalWeight += data.Weight
|
|
|
+ ConvertRoleShopData[data.GoodsType].TotalWeight1 += data.Weight1
|
|
|
+ ConvertRoleShopData[data.GoodsType].TotalWeight2 += data.Weight2
|
|
|
+ ConvertRoleShopData[data.GoodsType].TotalWeight3 += data.Weight3
|
|
|
+ ConvertRoleShopData[data.GoodsType].TotalWeight4 += data.Weight4
|
|
|
+
|
|
|
+ shopItem := &SpecialShopItem{}
|
|
|
+ shopItem.Weight = ConvertRoleShopData[data.GoodsType].TotalWeight
|
|
|
+ shopItem.Weight1 = ConvertRoleShopData[data.GoodsType].TotalWeight1
|
|
|
+ shopItem.Weight2 = ConvertRoleShopData[data.GoodsType].TotalWeight2
|
|
|
+ shopItem.Weight3 = ConvertRoleShopData[data.GoodsType].TotalWeight3
|
|
|
+ shopItem.Weight4 = ConvertRoleShopData[data.GoodsType].TotalWeight4
|
|
|
+
|
|
|
+ shopItem.ShopItem = convertData
|
|
|
+ ConvertRoleShopData[data.GoodsType].ItemList = append(ConvertRoleShopData[data.GoodsType].ItemList, shopItem)
|
|
|
+
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if data.GoodsType == 50 {
|
|
|
+ shopItem := &RedBagShopTime{}
|
|
|
+ shopItem.ShopItem = convertData
|
|
|
+ shopItem.ItemList = make(map[int32]int32)
|
|
|
+ for _, items := range data.Reward {
|
|
|
+ limitRes := strings.Split(items, ":")
|
|
|
+ if len(limitRes) >= 2 {
|
|
|
+ itemId, _ := Str2Num(limitRes[0])
|
|
|
+ itemCount, _ := Str2Num(limitRes[1])
|
|
|
+
|
|
|
+ shopItem.ItemList[int32(itemId)] = int32(itemCount)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertRedBagShopItemData[data.GoodsId] = shopItem
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertShopItemData[data.GoodsId] = convertData
|
|
|
+
|
|
|
+ if len(data.Condition) > 0 {
|
|
|
+ condition := &ItemCondition{}
|
|
|
+ for _, cond := range data.Condition {
|
|
|
+ condId, condArg := Str2Res(cond)
|
|
|
+ if condId != 0 && condArg != 0 {
|
|
|
+ condition.Conditions = append(condition.Conditions, &serverproto.KeyValueType{
|
|
|
+ Key: int32(condId),
|
|
|
+ Value: int32(condArg),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertShopItemCondition[data.GoodsId] = condition
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 比较refTime 和当前时间是否在同一时间段内
|
|
|
+func CheckShopNeedRefresh(refTime int64) bool {
|
|
|
+ if refTime < util.GetTimeSeconds() {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+func GetNextShopRefreshHour(shopType int32, curHour int32) int32 {
|
|
|
+ shopData, ok := ConvertRoleShopData[shopType]
|
|
|
+ if !ok {
|
|
|
+ return -1
|
|
|
+ }
|
|
|
+ for _, data := range shopData.RefreshTime {
|
|
|
+ if curHour < data {
|
|
|
+ return data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return shopData.RefreshTime[0]
|
|
|
+}
|
|
|
+
|
|
|
+func GetShopItemByShopType(shopType int32, vipWeight int32) []int32 {
|
|
|
+ shop, ok1 := serverproto.ShopTypeCfgLoader[shopType]
|
|
|
+ if !ok1 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ if shop.ShopType != 2 || shop.GoodsRefreshNum <= 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ shopData, ok2 := ConvertRoleShopData[shopType]
|
|
|
+ if !ok2 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ if int32(len(shopData.ItemList)) < shop.GoodsRefreshNum {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ var itemList []int32
|
|
|
+ selected := map[int32]int32{}
|
|
|
+ totalWeight := shopData.TotalWeight
|
|
|
+ if vipWeight == 1 {
|
|
|
+ totalWeight = shopData.TotalWeight1
|
|
|
+ } else if vipWeight == 2 {
|
|
|
+ totalWeight = shopData.TotalWeight2
|
|
|
+ } else if vipWeight == 3 {
|
|
|
+ totalWeight = shopData.TotalWeight3
|
|
|
+ } else if vipWeight == 4 {
|
|
|
+ totalWeight = shopData.TotalWeight4
|
|
|
+ }
|
|
|
+ if totalWeight == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ for i := 0; i < int(shop.GoodsRefreshNum); {
|
|
|
+ randWeight := rand.Int31n(totalWeight) //[0,randWeight)
|
|
|
+ for _, data := range shopData.ItemList {
|
|
|
+ weight := data.Weight
|
|
|
+ if vipWeight == 1 {
|
|
|
+ weight = data.Weight1
|
|
|
+ } else if vipWeight == 2 {
|
|
|
+ weight = data.Weight2
|
|
|
+ } else if vipWeight == 3 {
|
|
|
+ weight = data.Weight3
|
|
|
+ } else if vipWeight == 4 {
|
|
|
+ weight = data.Weight4
|
|
|
+ }
|
|
|
+ if weight == 0 { //策划口头补充的需求
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if randWeight <= weight {
|
|
|
+ _, ok3 := selected[data.ShopItem.GoodsId]
|
|
|
+ if ok3 { //找到重复的
|
|
|
+ break
|
|
|
+ }
|
|
|
+
|
|
|
+ itemList = append(itemList, data.ShopItem.GoodsId)
|
|
|
+ selected[data.ShopItem.GoodsId] = 1
|
|
|
+ i++
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return itemList
|
|
|
+}
|
|
|
+
|
|
|
+type SignInData struct {
|
|
|
+ VipLevel int32
|
|
|
+ DaySign []*serverproto.KeyValueType //每日签到奖励
|
|
|
+ AccuSign []*serverproto.KeyValueType //累积签到奖励
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertSignUpData = map[int32]*SignInData{}
|
|
|
+
|
|
|
+func convertSignInCfg() {
|
|
|
+ for _, data := range serverproto.SignInCfgLoader {
|
|
|
+ convertData := SignInData{}
|
|
|
+ if len(data.SignInReward) > 0 {
|
|
|
+ for _, reward := range data.SignInReward {
|
|
|
+ key, val := Str2Res(reward)
|
|
|
+ if key == 0 || val == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.DaySign = append(convertData.DaySign, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(val),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(data.SignInAddReward) > 0 {
|
|
|
+ for _, reward := range data.SignInAddReward {
|
|
|
+ key, val := Str2Res(reward)
|
|
|
+ if key == 0 || val == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.AccuSign = append(convertData.AccuSign, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(val),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ convertData.VipLevel = data.VipLevel
|
|
|
+ ConvertSignUpData[data.ID] = &convertData
|
|
|
+ }
|
|
|
+ if len(ConvertSignUpData)%30 != 0 {
|
|
|
+ util.PanicF("convertSign total count err:%v", len(ConvertSignUpData))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var ActiveCodeList = map[string]struct{}{}
|
|
|
+
|
|
|
+func convertActiveCodeCfg() {
|
|
|
+ for _, val := range serverproto.ActiveCodeCfgLoader {
|
|
|
+ ActiveCodeList[val.Code] = struct{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+func CheckActiveCode(activeCode string) serverproto.ErrorCode {
|
|
|
+ if activeCode == "" {
|
|
|
+ return serverproto.ErrorCode_ERROR_ROLE_ACTIVECODE_ERROR
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(ActiveCodeList) <= 0 {
|
|
|
+ return serverproto.ErrorCode_ERROR_OK
|
|
|
+ }
|
|
|
+
|
|
|
+ if _, ok := ActiveCodeList[activeCode]; !ok {
|
|
|
+ return serverproto.ErrorCode_ERROR_ROLE_ACTIVECODE_ERROR
|
|
|
+ }
|
|
|
+
|
|
|
+ return serverproto.ErrorCode_ERROR_OK
|
|
|
+}
|
|
|
+
|
|
|
+type LevelItem struct {
|
|
|
+ MapId int32
|
|
|
+ LevelId int32
|
|
|
+
|
|
|
+ //boss战小怪
|
|
|
+ MonsterList []*serverproto.KeyValueType
|
|
|
+ BossId int32
|
|
|
+ BossPos int32
|
|
|
+ RageId uint32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertMapItemList = map[int32]*LevelItem{}
|
|
|
+
|
|
|
+func convertMapCfg() {
|
|
|
+ //for _, mapItemData := range serverproto.MapCfgLoader {
|
|
|
+ // var levelId int32 = 1
|
|
|
+ // mapId := mapItemData.Id
|
|
|
+ // for {
|
|
|
+ // tmpId := mapId*10000 + levelId
|
|
|
+ // data, ok := serverproto.LevelCfgLoader[tmpId]
|
|
|
+ // if !ok {
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // addLevelItem := &LevelItem{
|
|
|
+ // MapId: mapId,
|
|
|
+ // LevelId: levelId,
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // //boss战小怪处理
|
|
|
+ // for idx := 0; idx <= len(data.Monsters); idx++ {
|
|
|
+ // loc, monsterId := Str2Res(data.Monsters[idx])
|
|
|
+ // if loc >= 1 && loc <= 6 && monsterId > 0 {
|
|
|
+ // addLevelItem.MonsterList = append(addLevelItem.MonsterList,
|
|
|
+ // &serverproto.KeyValueType{
|
|
|
+ // Key: loc,
|
|
|
+ // Value: monsterId,
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if data.BossId > 0 {
|
|
|
+ // addLevelItem.BossId = data.BossId
|
|
|
+ // addLevelItem.BossPos = data.BossPosition
|
|
|
+ // addLevelItem.RageId = uint32(data.BossRageBuffId)
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // ConvertMapItemList[tmpId] = addLevelItem
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+}
|
|
|
+
|
|
|
+// NatureCfg.csv
|
|
|
+var ConvertNatureMap = map[int32]map[int32][]*serverproto.KeyValueType{}
|
|
|
+
|
|
|
+func convertNatureCfg() {
|
|
|
+ //for _, data := range serverproto.NatureCfgLoader {
|
|
|
+ // if data.AntiNature1 != "" {
|
|
|
+ // convertNatureAttr(1, data.AntiNature1)
|
|
|
+ // }
|
|
|
+ // if data.AntiNature2 != "" {
|
|
|
+ // convertNatureAttr(2, data.AntiNature2)
|
|
|
+ // }
|
|
|
+ // if data.AntiNature3 != "" {
|
|
|
+ // convertNatureAttr(3, data.AntiNature3)
|
|
|
+ // }
|
|
|
+ // if data.AntiNature4 != "" {
|
|
|
+ // convertNatureAttr(4, data.AntiNature4)
|
|
|
+ // }
|
|
|
+ // if data.AntiNature5 != "" {
|
|
|
+ // convertNatureAttr(5, data.AntiNature5)
|
|
|
+ // }
|
|
|
+ // if data.AntiNature6 != "" {
|
|
|
+ // convertNatureAttr(6, data.AntiNature6)
|
|
|
+ // }
|
|
|
+ // if data.AntiNature7 != "" {
|
|
|
+ // convertNatureAttr(7, data.AntiNature7)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+}
|
|
|
+func convertNatureAttr(natureId int32, attr string) {
|
|
|
+ attrList := strings.Split(attr, ";")
|
|
|
+ for idx := range attrList {
|
|
|
+ key, value := Str2Res(attrList[idx])
|
|
|
+ if key > 0 && value > 0 {
|
|
|
+ if ConvertNatureMap[natureId] == nil {
|
|
|
+ ConvertNatureMap[natureId] = map[int32][]*serverproto.KeyValueType{}
|
|
|
+ }
|
|
|
+ ConvertNatureMap[natureId][key] = append(ConvertNatureMap[natureId][key], &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type TowerReward struct {
|
|
|
+ ItemList []*serverproto.KeyValueType
|
|
|
+ ExItemList []*serverproto.KeyValueType
|
|
|
+ FightCheck int32
|
|
|
+ SPAdd *serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertTowerData = map[int32]*TowerReward{}
|
|
|
+var ConvertClimbPowerDecayFactorList = map[int32]*ConvertDecayData{}
|
|
|
+var ConvertClimbTimeDecayFactorList = map[int32]*ConvertDecayData{}
|
|
|
+
|
|
|
+func convertTowerCfg() {
|
|
|
+ for _, tower := range serverproto.ClimbingTowerCfgLoader {
|
|
|
+ convertReward := &TowerReward{}
|
|
|
+ for _, items := range tower.RewardItems {
|
|
|
+ key, value := Str2Res(items)
|
|
|
+ if key == 0 || value == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertReward.ItemList = append(convertReward.ItemList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ for _, special := range tower.SpecialReward {
|
|
|
+ key, value := Str2Res(special)
|
|
|
+ if key == 0 || value == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertReward.ExItemList = append(convertReward.ExItemList, &serverproto.KeyValueType{
|
|
|
+ Key: key,
|
|
|
+ Value: value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ convertReward.FightCheck = tower.FightCheck
|
|
|
+
|
|
|
+ //power
|
|
|
+ parseDecay(tower.Id, tower.PowerWeaken, ConvertClimbPowerDecayFactorList)
|
|
|
+ //time
|
|
|
+ parseDecay(tower.Id, tower.StayTimeWeaken, ConvertClimbTimeDecayFactorList)
|
|
|
+ //sp add
|
|
|
+ k, v := Str2Res(tower.SpAddition)
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ convertReward.SPAdd = &serverproto.KeyValueType{Key: k, Value: v}
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertTowerData[tower.Id] = convertReward
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertEvilBossData struct {
|
|
|
+ EvilLevel int32
|
|
|
+ MaxFightingTime int32
|
|
|
+ MonsterList []*serverproto.KeyValueTypeList
|
|
|
+ LevelReward map[int32]int32
|
|
|
+ LevelTimes int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertEvilBossList = map[int32]*ConvertEvilBossData{}
|
|
|
+
|
|
|
+func convertEvilCfg() {
|
|
|
+ for _, data := range serverproto.EvilCfgLoader {
|
|
|
+ convertData := &ConvertEvilBossData{
|
|
|
+ EvilLevel: data.Id,
|
|
|
+ MaxFightingTime: data.MaxFightingTime,
|
|
|
+ LevelReward: map[int32]int32{},
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.MonsterList); idx++ {
|
|
|
+ //id,addexp,cd,quality,weight
|
|
|
+ v1, v2, v3, v4, v5 := Str2Res_5(data.MonsterList[idx])
|
|
|
+ if v1 > 0 && v2 > 0 && v3 > 0 {
|
|
|
+ monsterData := &serverproto.KeyValueTypeList{
|
|
|
+ Key: v1,
|
|
|
+ }
|
|
|
+ monsterData.ValueList = append(monsterData.ValueList, v2, v3, v4, v5)
|
|
|
+ convertData.MonsterList = append(convertData.MonsterList, monsterData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := 0; idx < len(data.LevelReward); idx++ {
|
|
|
+ key, val := Str2Res(data.LevelReward[idx])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ convertData.LevelReward[key] += val
|
|
|
+ }
|
|
|
+ }
|
|
|
+ convertData.LevelTimes = data.LevelTimes
|
|
|
+
|
|
|
+ ConvertEvilBossList[convertData.EvilLevel] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+type ConvertVIPData struct {
|
|
|
+ VipId int32 //vip等级, 1表示vip0,默认数值
|
|
|
+ EvilFreeRefreshCount int32 //恶魔免费刷新次数 数值0表示无限次数刷新
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertVIPList = map[int32]*ConvertVIPData{}
|
|
|
+var maxVipLevel int32 = 0
|
|
|
+
|
|
|
+func convertVIPCfg() {
|
|
|
+ for _, data := range serverproto.VipCfgLoader {
|
|
|
+ vipData := &ConvertVIPData{
|
|
|
+ VipId: data.Id,
|
|
|
+ EvilFreeRefreshCount: data.FreeTimes,
|
|
|
+ }
|
|
|
+ ConvertVIPList[vipData.VipId-1] = vipData
|
|
|
+ if data.Id > maxVipLevel {
|
|
|
+ maxVipLevel = data.Id - 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+func GetVIPDataByLevel(vipLevel int32) *ConvertVIPData {
|
|
|
+ if vipLevel < 0 {
|
|
|
+ vipLevel = maxVipLevel
|
|
|
+ }
|
|
|
+ if vipLevel > maxVipLevel {
|
|
|
+ vipLevel = maxVipLevel
|
|
|
+ }
|
|
|
+ if data, ok := ConvertVIPList[vipLevel]; ok {
|
|
|
+ return data
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+*/
|
|
|
+
|
|
|
+type CardCollectReward struct {
|
|
|
+ CardId int32
|
|
|
+ CardReward map[int32]*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertCardCollectReward = map[int32]*CardCollectReward{}
|
|
|
+
|
|
|
+func convertCardCollectCfg() {
|
|
|
+ for _, data := range serverproto.CardIdentificationLoader {
|
|
|
+ convertData := &CardCollectReward{
|
|
|
+ CardId: data.Cardid,
|
|
|
+ CardReward: map[int32]*serverproto.KeyValueType{},
|
|
|
+ }
|
|
|
+ limitRes := strings.Split(data.CardReward1[0], ":")
|
|
|
+ if len(limitRes) >= 2 {
|
|
|
+ itemKey, _ := Str2Num(limitRes[0])
|
|
|
+ itemValue, _ := Str2Num(limitRes[1])
|
|
|
+ convertData.CardReward[1] = &serverproto.KeyValueType{
|
|
|
+ Key: int32(itemKey),
|
|
|
+ Value: int32(itemValue),
|
|
|
+ }
|
|
|
+ }
|
|
|
+ limitRes = strings.Split(data.CardReward2[0], ":")
|
|
|
+ if len(limitRes) >= 2 {
|
|
|
+ itemKey, _ := Str2Num(limitRes[0])
|
|
|
+ itemValue, _ := Str2Num(limitRes[1])
|
|
|
+ convertData.CardReward[2] = &serverproto.KeyValueType{
|
|
|
+ Key: int32(itemKey),
|
|
|
+ Value: int32(itemValue),
|
|
|
+ }
|
|
|
+ }
|
|
|
+ limitRes = strings.Split(data.CardReward3[0], ":")
|
|
|
+ if len(limitRes) >= 2 {
|
|
|
+ itemKey, _ := Str2Num(limitRes[0])
|
|
|
+ itemValue, _ := Str2Num(limitRes[1])
|
|
|
+ convertData.CardReward[3] = &serverproto.KeyValueType{
|
|
|
+ Key: int32(itemKey),
|
|
|
+ Value: int32(itemValue),
|
|
|
+ }
|
|
|
+ }
|
|
|
+ limitRes = strings.Split(data.CardReward4[0], ":")
|
|
|
+ if len(limitRes) >= 2 {
|
|
|
+ itemKey, _ := Str2Num(limitRes[0])
|
|
|
+ itemValue, _ := Str2Num(limitRes[1])
|
|
|
+ convertData.CardReward[4] = &serverproto.KeyValueType{
|
|
|
+ Key: int32(itemKey),
|
|
|
+ Value: int32(itemValue),
|
|
|
+ }
|
|
|
+ }
|
|
|
+ limitRes = strings.Split(data.CardReward5[0], ":")
|
|
|
+ if len(limitRes) >= 2 {
|
|
|
+ itemKey, _ := Str2Num(limitRes[0])
|
|
|
+ itemValue, _ := Str2Num(limitRes[1])
|
|
|
+ convertData.CardReward[5] = &serverproto.KeyValueType{
|
|
|
+ Key: int32(itemKey),
|
|
|
+ Value: int32(itemValue),
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertCardCollectReward[data.Cardid] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertGuildLevel = map[int32]int32{}
|
|
|
+var ConvertLeaveGuildTime = map[int32]int32{}
|
|
|
+
|
|
|
+func convertGuildLevelCfg() {
|
|
|
+ for _, data := range serverproto.GuildLvCfgLoader {
|
|
|
+ ConvertGuildLevel[data.Id] = data.ExpRequire
|
|
|
+ }
|
|
|
+
|
|
|
+ cfgData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Leave_Guild_CD)]
|
|
|
+ if !ok {
|
|
|
+ util.PanicF("convertSign total count err:%v", len(ConvertSignUpData))
|
|
|
+ }
|
|
|
+
|
|
|
+ limitRes := strings.Split(cfgData.SVal, ";")
|
|
|
+ for _, res := range limitRes {
|
|
|
+ cdData := strings.Split(res, ":")
|
|
|
+ if len(cdData) >= 2 {
|
|
|
+ cdCount, _ := Str2Num(cdData[0])
|
|
|
+ cdTime, _ := Str2Num(cdData[1])
|
|
|
+
|
|
|
+ ConvertLeaveGuildTime[int32(cdCount)] = int32(cdTime)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// pet
|
|
|
+const (
|
|
|
+ Pet_Type_Normal = 1
|
|
|
+ Pet_Type_Mini = 2
|
|
|
+ Pet_Type_MVP = 3
|
|
|
+)
|
|
|
+
|
|
|
+type PetProgressData struct {
|
|
|
+ PetCfgId int32
|
|
|
+ ProgressList []*ConvertPetProgressDataDetail
|
|
|
+}
|
|
|
+type ConvertPetProgressDataDetail struct {
|
|
|
+ ProgressLevel int32
|
|
|
+ CostZeny int32 //消耗zeny
|
|
|
+ AttrList []*serverproto.KeyValueType
|
|
|
+ RateList []*serverproto.KeyValueType
|
|
|
+
|
|
|
+ //1品质 2进阶等级 3特殊属性
|
|
|
+ ConditionPet1 []*serverproto.KeyValueType //进阶消耗的材料
|
|
|
+ ConditionPet2 []*serverproto.KeyValueType //进阶消耗的材料
|
|
|
+}
|
|
|
+type ConvertPetSkillData struct {
|
|
|
+ SkillId int32
|
|
|
+ RateList []int32 //技能发动概率
|
|
|
+ MaxSkillLevel int32
|
|
|
+}
|
|
|
+type ConvertPetData struct {
|
|
|
+ PetCfgId int32
|
|
|
+ Exp int32 //等级1对应的经验
|
|
|
+ ManualRewardList map[int32]*serverproto.KeyValueType //图鉴奖励
|
|
|
+ Quality int32 //1normal 2mini 3mvp
|
|
|
+ NatureType int32
|
|
|
+ SkillList []*ConvertPetSkillData //技能列表
|
|
|
+ JobType int32
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertPetData) GetSkill(skillId int32) *ConvertPetSkillData {
|
|
|
+ for idx := 0; idx < len(this.SkillList); idx++ {
|
|
|
+ if this.SkillList[idx].SkillId == skillId {
|
|
|
+ return this.SkillList[idx]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+func (this *ConvertPetData) GetSkillRate(skillId, skillLevel int32) int32 {
|
|
|
+ if skillLevel <= 0 {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(this.SkillList); idx++ {
|
|
|
+ if this.SkillList[idx].SkillId == skillId &&
|
|
|
+ this.SkillList[idx].MaxSkillLevel >= skillLevel {
|
|
|
+ return this.SkillList[idx].RateList[int(skillLevel-1)]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertExpData struct {
|
|
|
+ PetLevel int32
|
|
|
+ NormalExp int32
|
|
|
+ NormalAccuExp int32 //累计需要经验
|
|
|
+ NormalZeny int32
|
|
|
+ NormalAccuZeny int32 //累计消耗zeny
|
|
|
+ MiniExp int32
|
|
|
+ MiniAccuExp int32
|
|
|
+ MiniZeny int32
|
|
|
+ MiniAccuZeny int32
|
|
|
+ MvpExp int32
|
|
|
+ MvpAccuExp int32
|
|
|
+ MvpZeny int32
|
|
|
+ MvpAccuZeny int32
|
|
|
+}
|
|
|
+type ConvertBondData struct {
|
|
|
+ BondId int32
|
|
|
+ ConditionList1 []*serverproto.KeyValueType
|
|
|
+ ConditionList2 []*serverproto.KeyValueType
|
|
|
+ ConditionList3 []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+type PetBondFightData struct {
|
|
|
+ FightPower1 []*serverproto.KeyValueType
|
|
|
+ FightPower2 []*serverproto.KeyValueType
|
|
|
+ FightPower3 []*serverproto.KeyValueType
|
|
|
+
|
|
|
+ Attr1List []*serverproto.KeyValueType
|
|
|
+ Attr2List []*serverproto.KeyValueType
|
|
|
+ Attr3List []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+type PetProFightPower struct {
|
|
|
+ AttrMap map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+type PetPartnerFightPower struct {
|
|
|
+ FightPower1 map[int32]int32
|
|
|
+ FightPower2 map[int32]int32
|
|
|
+ FightPower3 map[int32]int32
|
|
|
+}
|
|
|
+type ConvertPetEquipData struct {
|
|
|
+ CfgId int32
|
|
|
+ Type int32 //位置编号
|
|
|
+ Quality int32 //绿色,蓝色,紫色,金色,红色
|
|
|
+ MaxLevel int32
|
|
|
+ AdvanceTargetEquip int32
|
|
|
+ AdvanceCost map[int32]int32
|
|
|
+ SuitId int32
|
|
|
+ LevelUpList map[int32]*ConvertPetEquipLevelUpData
|
|
|
+}
|
|
|
+type ConvertPetEquipLevelUpData struct {
|
|
|
+ Level int32
|
|
|
+ CostList map[int32]int32
|
|
|
+ AttrList map[int32]int32
|
|
|
+ FightPower uint64
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertPetEquipSuitData struct {
|
|
|
+ Id int32
|
|
|
+ ConditionList []*serverproto.KeyValueType
|
|
|
+ AttrList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertPet = map[int32]*ConvertPetData{}
|
|
|
+var ConvertPetProgress = map[int32]*PetProgressData{}
|
|
|
+var ConvertPetExp = map[int32]*ConvertExpData{}
|
|
|
+var ConvertBond []*ConvertBondData
|
|
|
+
|
|
|
+var ConvertBondFight = map[int32]*PetBondFightData{}
|
|
|
+var ConvertPetProFight = map[int32]*PetProFightPower{}
|
|
|
+var ConvertPetPartnerFight = map[int32]*PetPartnerFightPower{}
|
|
|
+var ConvertPetEquip = map[int32]*ConvertPetEquipData{} //[equipcfgid][data]
|
|
|
+var ConvertPteEquipSuit []*ConvertPetEquipSuitData
|
|
|
+
|
|
|
+func getFieldData(fieldName string, data interface{}) []string {
|
|
|
+ tmpDataType := reflect.ValueOf(data).Elem()
|
|
|
+ tmpVal := tmpDataType.FieldByName(fieldName).Interface()
|
|
|
+ switch val := tmpVal.(type) {
|
|
|
+ case []string:
|
|
|
+ return val
|
|
|
+ default:
|
|
|
+ panic(errors.New("field type error"))
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+func convertPetCfg() {
|
|
|
+ //clean for reload
|
|
|
+ ConvertBond = []*ConvertBondData{}
|
|
|
+
|
|
|
+ //progress
|
|
|
+ for _, data := range serverproto.PetProgressCfgLoader {
|
|
|
+ progressData := &PetProgressData{
|
|
|
+ PetCfgId: data.Id,
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := 0; idx < len(data.CostMoney); idx++ {
|
|
|
+ constZeny, _ := Str2Num(data.CostMoney[idx])
|
|
|
+ detailData := &ConvertPetProgressDataDetail{
|
|
|
+ ProgressLevel: int32(idx) + 1,
|
|
|
+ CostZeny: int32(constZeny),
|
|
|
+ }
|
|
|
+
|
|
|
+ //condition
|
|
|
+ tmpCondition1Str := "Condition" + strconv.Itoa(idx+1) + "1"
|
|
|
+ tmpCondition2Str := "Condition" + strconv.Itoa(idx+1) + "2"
|
|
|
+ tmpAttrStr := "Attribute" + strconv.Itoa(idx+1)
|
|
|
+ tmpAttributeRateAddStr := "AttributeRateAdd" + strconv.Itoa(idx+1)
|
|
|
+ convertPetCfg_ProgressCondition(getFieldData(tmpCondition1Str, data), getFieldData(tmpCondition2Str, data), detailData)
|
|
|
+ convertPetCfg_ProgressAttr(getFieldData(tmpAttrStr, data), getFieldData(tmpAttributeRateAddStr, data), detailData)
|
|
|
+ ////condition
|
|
|
+ //switch idx {
|
|
|
+ //case 0:
|
|
|
+ // convertPetCfg_ProgressCondition(data.Condition11, data.Condition12, detailData)
|
|
|
+ // convertPetCfg_ProgressAttr(data.Attribute1, data.AttributeRateAdd1, detailData)
|
|
|
+ //case 1:
|
|
|
+ // convertPetCfg_ProgressCondition(data.Condition21, data.Condition22, detailData)
|
|
|
+ // convertPetCfg_ProgressAttr(data.Attribute2, data.AttributeRateAdd2, detailData)
|
|
|
+ //case 2:
|
|
|
+ // convertPetCfg_ProgressCondition(data.Condition31, data.Condition32, detailData)
|
|
|
+ // convertPetCfg_ProgressAttr(data.Attribute3, data.AttributeRateAdd3, detailData)
|
|
|
+ //case 3:
|
|
|
+ // convertPetCfg_ProgressCondition(data.Condition41, data.Condition42, detailData)
|
|
|
+ // convertPetCfg_ProgressAttr(data.Attribute4, data.AttributeRateAdd4, detailData)
|
|
|
+ //case 4:
|
|
|
+ // convertPetCfg_ProgressCondition(data.Condition51, data.Condition52, detailData)
|
|
|
+ // convertPetCfg_ProgressAttr(data.Attribute5, data.AttributeRateAdd5, detailData)
|
|
|
+ //}
|
|
|
+
|
|
|
+ progressData.ProgressList = append(progressData.ProgressList, detailData)
|
|
|
+
|
|
|
+ ConvertPetProgress[progressData.PetCfgId] = progressData
|
|
|
+
|
|
|
+ progressFight := &PetProFightPower{
|
|
|
+ AttrMap: make(map[int32]int32),
|
|
|
+ }
|
|
|
+ var totalFight int32 = 0
|
|
|
+ for idx, fightPower := range data.AddFight {
|
|
|
+ val, _ := Str2Num(fightPower)
|
|
|
+ totalFight += int32(val)
|
|
|
+ progressFight.AttrMap[int32(idx)] = totalFight
|
|
|
+ }
|
|
|
+ ConvertPetProFight[progressData.PetCfgId] = progressFight
|
|
|
+ }
|
|
|
+ ConvertPetProgress[progressData.PetCfgId] = progressData
|
|
|
+ }
|
|
|
+ //petskillup global
|
|
|
+
|
|
|
+ //pet
|
|
|
+ for _, data := range serverproto.PetCfgLoader {
|
|
|
+ petData := &ConvertPetData{
|
|
|
+ PetCfgId: data.Id,
|
|
|
+ Quality: data.Quality,
|
|
|
+ NatureType: data.NatureType,
|
|
|
+ JobType: data.JobType,
|
|
|
+ }
|
|
|
+ petData.ManualRewardList = map[int32]*serverproto.KeyValueType{}
|
|
|
+ for idx := 0; idx < len(data.PetReward); idx++ {
|
|
|
+ advLevel, key, val := Str2Res_3(data.PetReward[idx])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ petData.ManualRewardList[advLevel] = &serverproto.KeyValueType{Key: key, Value: val}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //skill
|
|
|
+ convertPetCfg_Skill(data.Skill1, data.Skill1Rate, petData)
|
|
|
+ convertPetCfg_Skill(data.Skill2, data.Skill2Rate, petData)
|
|
|
+ convertPetCfg_Skill(data.Skill3, data.Skill3Rate, petData)
|
|
|
+ convertPetCfg_Skill(data.Skill4, data.Skill4Rate, petData)
|
|
|
+
|
|
|
+ ConvertPet[petData.PetCfgId] = petData
|
|
|
+ }
|
|
|
+
|
|
|
+ //pet exp
|
|
|
+ var tmpList []*ConvertExpData
|
|
|
+ for _, data := range serverproto.PetExpCfgLoader {
|
|
|
+ expData := &ConvertExpData{
|
|
|
+ PetLevel: data.PetLevel,
|
|
|
+ NormalExp: data.Experience1,
|
|
|
+ NormalZeny: data.CostMoney1,
|
|
|
+ MiniExp: data.Experience2,
|
|
|
+ MiniZeny: data.CostMoney2,
|
|
|
+ MvpExp: data.Experience3,
|
|
|
+ MvpZeny: data.CostMoney3,
|
|
|
+ }
|
|
|
+ ConvertPetExp[expData.PetLevel] = expData
|
|
|
+ tmpList = append(tmpList, expData)
|
|
|
+ }
|
|
|
+ sort.Slice(tmpList, func(i, j int) bool {
|
|
|
+ return tmpList[i].PetLevel < tmpList[j].PetLevel
|
|
|
+ })
|
|
|
+ for idx := 0; idx < len(tmpList); idx++ {
|
|
|
+ tmpLevel := tmpList[idx].PetLevel
|
|
|
+ if tmpLevel > 1 {
|
|
|
+ tmpLevel := tmpList[idx].PetLevel
|
|
|
+ ConvertPetExp[tmpLevel].NormalAccuExp = ConvertPetExp[tmpLevel-1].NormalAccuExp + ConvertPetExp[tmpLevel].NormalExp
|
|
|
+ ConvertPetExp[tmpLevel].NormalAccuZeny = ConvertPetExp[tmpLevel-1].NormalAccuZeny + ConvertPetExp[tmpLevel].NormalZeny
|
|
|
+
|
|
|
+ ConvertPetExp[tmpLevel].MiniAccuExp = ConvertPetExp[tmpLevel-1].MiniAccuExp + ConvertPetExp[tmpLevel].MiniExp
|
|
|
+ ConvertPetExp[tmpLevel].MiniAccuZeny = ConvertPetExp[tmpLevel-1].MiniAccuZeny + ConvertPetExp[tmpLevel].MiniZeny
|
|
|
+
|
|
|
+ ConvertPetExp[tmpLevel].MvpAccuExp = ConvertPetExp[tmpLevel-1].MvpAccuExp + ConvertPetExp[tmpLevel].MvpExp
|
|
|
+ ConvertPetExp[tmpLevel].MvpAccuZeny = ConvertPetExp[tmpLevel-1].MvpAccuZeny + ConvertPetExp[tmpLevel].MvpZeny
|
|
|
+ } else {
|
|
|
+ ConvertPetExp[tmpLevel].NormalAccuExp = ConvertPetExp[tmpLevel].NormalExp
|
|
|
+ ConvertPetExp[tmpLevel].NormalAccuZeny = ConvertPetExp[tmpLevel].NormalZeny
|
|
|
+
|
|
|
+ ConvertPetExp[tmpLevel].MiniAccuExp = ConvertPetExp[tmpLevel].MiniExp
|
|
|
+ ConvertPetExp[tmpLevel].MiniAccuZeny = ConvertPetExp[tmpLevel].MiniZeny
|
|
|
+
|
|
|
+ ConvertPetExp[tmpLevel].MvpAccuExp = ConvertPetExp[tmpLevel].MvpExp
|
|
|
+ ConvertPetExp[tmpLevel].MvpAccuZeny = ConvertPetExp[tmpLevel].MvpZeny
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //pet partner
|
|
|
+ for _, data := range serverproto.PetpartnerCfgLoader {
|
|
|
+ bondData := &ConvertBondData{
|
|
|
+ BondId: data.Id,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.Condition1); idx++ {
|
|
|
+ key, val := Str2Res(data.Condition1[idx])
|
|
|
+ if key <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bondData.ConditionList1 = append(bondData.ConditionList1, &serverproto.KeyValueType{
|
|
|
+ Key: key, Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.Condition2); idx++ {
|
|
|
+ key, val := Str2Res(data.Condition2[idx])
|
|
|
+ if key <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bondData.ConditionList2 = append(bondData.ConditionList2, &serverproto.KeyValueType{
|
|
|
+ Key: key, Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.Condition3); idx++ {
|
|
|
+ key, val := Str2Res(data.Condition3[idx])
|
|
|
+ if key <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bondData.ConditionList3 = append(bondData.ConditionList3, &serverproto.KeyValueType{
|
|
|
+ Key: key, Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ConvertBond = append(ConvertBond, bondData)
|
|
|
+
|
|
|
+ //战斗力相关 key= {0,1,2,3,4,5}
|
|
|
+ bondFightData := &PetBondFightData{}
|
|
|
+ for idx := 0; idx < len(data.AddHeroCap1); idx++ {
|
|
|
+ key, val := Str2Res(data.AddHeroCap1[idx])
|
|
|
+ if key < 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bondFightData.FightPower1 = append(bondFightData.FightPower1, &serverproto.KeyValueType{
|
|
|
+ Key: key, Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.AddHeroCap2); idx++ {
|
|
|
+ key, val := Str2Res(data.AddHeroCap1[idx])
|
|
|
+ if key < 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bondFightData.FightPower2 = append(bondFightData.FightPower2, &serverproto.KeyValueType{
|
|
|
+ Key: key, Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.AddHeroCap3); idx++ {
|
|
|
+ key, val := Str2Res(data.AddHeroCap1[idx])
|
|
|
+ if key < 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bondFightData.FightPower3 = append(bondFightData.FightPower3, &serverproto.KeyValueType{
|
|
|
+ Key: key, Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ //attr
|
|
|
+ for idx := 0; idx < len(data.Attribute1); idx++ {
|
|
|
+ k, v := Str2Res(data.Attribute1[idx])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bondFightData.Attr1List = append(bondFightData.Attr1List, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.Attribute2); idx++ {
|
|
|
+ k, v := Str2Res(data.Attribute2[idx])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bondFightData.Attr2List = append(bondFightData.Attr2List, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(data.Attribute3); idx++ {
|
|
|
+ k, v := Str2Res(data.Attribute3[idx])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bondFightData.Attr3List = append(bondFightData.Attr3List, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertBondFight[data.Id] = bondFightData
|
|
|
+ }
|
|
|
+ sort.Slice(ConvertBond, func(i, j int) bool {
|
|
|
+ return ConvertBond[i].BondId < ConvertBond[j].BondId
|
|
|
+ })
|
|
|
+
|
|
|
+ //pet equip
|
|
|
+ //ConvertPetEquip
|
|
|
+ for _, data := range serverproto.PetEquipCfgLoader {
|
|
|
+ convertData := &ConvertPetEquipData{
|
|
|
+ CfgId: data.Id,
|
|
|
+ Quality: data.Quality,
|
|
|
+ Type: data.Type,
|
|
|
+ MaxLevel: data.MaxLevel,
|
|
|
+ AdvanceTargetEquip: data.Advance,
|
|
|
+ AdvanceCost: map[int32]int32{},
|
|
|
+ LevelUpList: map[int32]*ConvertPetEquipLevelUpData{},
|
|
|
+ }
|
|
|
+ Str2ResMapList(data.AdvanceCost, convertData.AdvanceCost)
|
|
|
+ ConvertPetEquip[convertData.CfgId] = convertData
|
|
|
+ }
|
|
|
+ for _, data := range serverproto.PetEquipExpCfgLoader {
|
|
|
+ convertData, ok := ConvertPetEquip[data.PetEquipID]
|
|
|
+ if !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ levelData := &ConvertPetEquipLevelUpData{
|
|
|
+ Level: data.PetEquipLevel,
|
|
|
+ CostList: map[int32]int32{},
|
|
|
+ AttrList: map[int32]int32{},
|
|
|
+ FightPower: uint64(data.FightPower),
|
|
|
+ }
|
|
|
+ Str2ResMapList(data.Cost, levelData.CostList)
|
|
|
+ Str2ResMapList(data.Nature, levelData.AttrList)
|
|
|
+
|
|
|
+ convertData.LevelUpList[data.PetEquipLevel] = levelData
|
|
|
+ }
|
|
|
+ for _, data := range serverproto.PetEquipSuitCfgLoader {
|
|
|
+ convertData := &ConvertPetEquipSuitData{
|
|
|
+ Id: data.Id,
|
|
|
+ AttrList: map[int32]int32{},
|
|
|
+ }
|
|
|
+ Str2ResMapList(data.Suit, convertData.AttrList)
|
|
|
+ convertData.ConditionList = append(convertData.ConditionList, Str2ResSliceList(data.Amount)...)
|
|
|
+
|
|
|
+ ConvertPteEquipSuit = append(ConvertPteEquipSuit, convertData)
|
|
|
+ }
|
|
|
+ sort.Slice(ConvertPteEquipSuit, func(i, j int) bool {
|
|
|
+ return ConvertPteEquipSuit[i].Id > ConvertPteEquipSuit[j].Id
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func convertPetCfg_ProgressCondition(conditionList1 []string, conditionList2 []string, detailData *ConvertPetProgressDataDetail) {
|
|
|
+ for idx := 0; idx < len(conditionList1); idx++ {
|
|
|
+ kvList := &serverproto.KeyValueType{}
|
|
|
+ v1, v2 := Str2Res(conditionList1[idx])
|
|
|
+ if v1 > 0 {
|
|
|
+ kvList.Key = v1
|
|
|
+ kvList.Value = v2
|
|
|
+ }
|
|
|
+ detailData.ConditionPet1 = append(detailData.ConditionPet1, kvList)
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := 0; idx < len(conditionList2); idx++ {
|
|
|
+ kvList := &serverproto.KeyValueType{}
|
|
|
+ v1, v2 := Str2Res(conditionList2[idx])
|
|
|
+ if v1 > 0 {
|
|
|
+ kvList.Key = v1
|
|
|
+ kvList.Value = v2
|
|
|
+ }
|
|
|
+ detailData.ConditionPet2 = append(detailData.ConditionPet2, kvList)
|
|
|
+ }
|
|
|
+}
|
|
|
+func convertPetCfg_ProgressAttr(attrList []string, rateList []string, detailData *ConvertPetProgressDataDetail) {
|
|
|
+ for idx := 0; idx < len(attrList); idx++ {
|
|
|
+ key, val := Str2Res(attrList[idx])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ detailData.AttrList = append(detailData.AttrList, &serverproto.KeyValueType{
|
|
|
+ Key: key, Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := 0; idx < len(rateList); idx++ {
|
|
|
+ key, val := Str2Res(rateList[idx])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ detailData.RateList = append(detailData.RateList, &serverproto.KeyValueType{
|
|
|
+ Key: key, Value: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+func convertPetCfg_Skill(skillId int32, skillRateList []string, petData *ConvertPetData) {
|
|
|
+ if skillId > 0 {
|
|
|
+ skill1 := &ConvertPetSkillData{
|
|
|
+ SkillId: skillId,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(skillRateList); idx++ {
|
|
|
+ val, _ := Str2Num(skillRateList[idx])
|
|
|
+ skill1.RateList = append(skill1.RateList, int32(val))
|
|
|
+ }
|
|
|
+ skill1.MaxSkillLevel = int32(len(skill1.RateList))
|
|
|
+ petData.SkillList = append(petData.SkillList, skill1)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type GuildBossReward struct {
|
|
|
+ RewardList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+type RankReward struct {
|
|
|
+ MaxDam int32
|
|
|
+ MinDam int32
|
|
|
+ RewardID int32
|
|
|
+ MasterReward int32
|
|
|
+}
|
|
|
+
|
|
|
+type GuildBossRank struct {
|
|
|
+ Reward []*RankReward
|
|
|
+ MaxDamage int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertGuildBossReward = map[int32]*GuildBossReward{}
|
|
|
+var ConvertGuildBossRewardRank = map[int32]*GuildBossRank{}
|
|
|
+
|
|
|
+func convertGuildBosRewardsCfg() {
|
|
|
+ for _, reward := range serverproto.GuildBossRewardCfgLoader {
|
|
|
+ convertReward := &GuildBossReward{
|
|
|
+ RewardList: map[int32]int32{},
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range reward.Reward {
|
|
|
+ strList := strings.Split(data, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ itemKey, _ := Str2Num(strList[0])
|
|
|
+ itemValue, _ := Str2Num(strList[1])
|
|
|
+ convertReward.RewardList[int32(itemKey)] = int32(itemValue)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertGuildBossReward[reward.Id] = convertReward
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, guildBoss := range serverproto.GuildBossCfgLoader {
|
|
|
+ convertGuildBossRank := &GuildBossRank{}
|
|
|
+
|
|
|
+ if len(guildBoss.RewardRange) != len(guildBoss.Reward) {
|
|
|
+ util.PanicF("[convertGuildBosRewardsCfg] reward config error:%v, %v, %v", guildBoss.Id, len(guildBoss.RewardRange), len(guildBoss.Reward))
|
|
|
+ }
|
|
|
+ if guildBoss.BossType == 1 { //1 普通boss 2 精英boss
|
|
|
+ if len(guildBoss.RewardRange) != len(guildBoss.MasterReward) {
|
|
|
+ util.PanicF("[convertGuildBosRewardsCfg] MasterReward config error:%v", guildBoss.Id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx, rank := range guildBoss.RewardRange {
|
|
|
+ strList := strings.Split(rank, ":")
|
|
|
+ minDam, _ := Str2Num(strList[0])
|
|
|
+ maxDam, _ := Str2Num(strList[1])
|
|
|
+
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ rankReward := &RankReward{}
|
|
|
+ rankReward.MinDam = int32(minDam)
|
|
|
+ rankReward.MaxDam = int32(maxDam)
|
|
|
+ rewardId, _ := Str2Num(guildBoss.Reward[idx])
|
|
|
+ rankReward.RewardID = int32(rewardId)
|
|
|
+ if guildBoss.BossType == 1 { //1 普通boss 2 精英boss
|
|
|
+ masterId, _ := Str2Num(guildBoss.MasterReward[idx])
|
|
|
+ rankReward.MasterReward = int32(masterId)
|
|
|
+ }
|
|
|
+
|
|
|
+ convertGuildBossRank.Reward = append(convertGuildBossRank.Reward, rankReward)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertGuildBossRewardRank[guildBoss.Id] = convertGuildBossRank
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertGuildBattleList = map[int32]int32{}
|
|
|
+
|
|
|
+func convertGuildBattleCfg() {
|
|
|
+ for _, cfgData := range serverproto.GuildWarDojoCfgLoader {
|
|
|
+ ConvertGuildBattleList[cfgData.Id] = cfgData.GuildWarPoint
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertExpedition struct {
|
|
|
+ ExpeditionType int32
|
|
|
+ LevelNum int32
|
|
|
+ LevelUnlockAddNum int32
|
|
|
+ //UnlockCondition []*serverproto.KeyValueType
|
|
|
+ LevelInfo map[int32]*ConvertExpeditionDetailInfo
|
|
|
+ LevelCoefficient float32
|
|
|
+ PassRewardList []*serverproto.KeyValueType //通关奖励(每日获取一次)
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertExpedition) GetLevelReward(levelIdx int32, addItemList map[int32]int32) {
|
|
|
+ levelData, ok := this.LevelInfo[levelIdx]
|
|
|
+ if !ok {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(levelData.RewardList); idx++ {
|
|
|
+ addItemList[levelData.RewardList[idx].Key] += levelData.RewardList[idx].Value
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertExpeditionBossInfo struct {
|
|
|
+ Weight int32
|
|
|
+ BossId int32
|
|
|
+ BossLevel int32
|
|
|
+ BossHP int32
|
|
|
+ BossSP int32
|
|
|
+}
|
|
|
+type ConvertExpeditionDetailInfo struct {
|
|
|
+ Id int32
|
|
|
+ LevelId int32
|
|
|
+ BossList []*ConvertExpeditionBossInfo
|
|
|
+ BuffList []*serverproto.KeyValueType //key:id val:weight
|
|
|
+ RewardList []*serverproto.KeyValueType
|
|
|
+ MaxFightingTime int32
|
|
|
+ WarriorScore int32 //勇士积分
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertExpeditionDetailInfo) RandBoss(tmpBossIdxList []int) (*ConvertExpeditionBossInfo, int) {
|
|
|
+ var totalWeight int32 = 0
|
|
|
+ var tmpList []*serverproto.KeyValueType
|
|
|
+
|
|
|
+ for idx := 0; idx < len(this.BossList); idx++ {
|
|
|
+ bFind := false
|
|
|
+ for k := 0; k < len(tmpBossIdxList); k++ {
|
|
|
+ if idx == tmpBossIdxList[k] {
|
|
|
+ bFind = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if bFind {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ totalWeight += this.BossList[idx].Weight
|
|
|
+ tmpList = append(tmpList, &serverproto.KeyValueType{Key: int32(idx), Value: totalWeight})
|
|
|
+ }
|
|
|
+
|
|
|
+ if totalWeight <= 0 {
|
|
|
+ return nil, 0
|
|
|
+ }
|
|
|
+ var retBossIdx = 0
|
|
|
+ randWeight := rand.Int31n(totalWeight) + 1
|
|
|
+ for idx := 0; idx < len(tmpList); idx++ {
|
|
|
+ retBossIdx = int(tmpList[idx].Key)
|
|
|
+ if tmpList[idx].Value >= randWeight {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this.BossList[retBossIdx], retBossIdx
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertExpeditionDetailInfo) RandBuff(hasBuffList set.Interface, tmpBuffList []int32, bossId uint64) int32 {
|
|
|
+ var retBuffId int32 = 0
|
|
|
+ var totalWeight int32 = 0
|
|
|
+ var tmpList []*serverproto.KeyValueType
|
|
|
+ bossBuffList, ok := ConvertExpeditionDropBuffList[bossId]
|
|
|
+ if !ok {
|
|
|
+ util.InfoF("Expedition bossid=%v randBuffList empty", bossId)
|
|
|
+ return retBuffId
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(bossBuffList.BuffList) <= 0 {
|
|
|
+ util.InfoF("Expedition bossid=%v randBuffList empty", bossId)
|
|
|
+ return retBuffId
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := 0; idx < len(bossBuffList.BuffList); idx++ {
|
|
|
+ if hasBuffList.Has(bossBuffList.BuffList[idx].Key) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bFind := false
|
|
|
+ for k := 0; k < len(tmpBuffList); k++ {
|
|
|
+ if tmpBuffList[k] == bossBuffList.BuffList[idx].Key {
|
|
|
+ bFind = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if bFind {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ totalWeight += bossBuffList.BuffList[idx].Value
|
|
|
+ tmpList = append(tmpList, &serverproto.KeyValueType{Key: bossBuffList.BuffList[idx].Key, Value: totalWeight})
|
|
|
+ }
|
|
|
+
|
|
|
+ if totalWeight <= 0 {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+
|
|
|
+ randWeight := rand.Int31n(totalWeight) + 1
|
|
|
+ for idx := 0; idx < len(tmpList); idx++ {
|
|
|
+ retBuffId = tmpList[idx].Key
|
|
|
+ if tmpList[idx].Value >= randWeight {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retBuffId
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertExpeditionBuffInfo struct {
|
|
|
+ Id uint64
|
|
|
+ BossId int32
|
|
|
+ LevelId int32 //关卡唯一ID
|
|
|
+ BuffList []*serverproto.KeyValueType //key:id val:weight
|
|
|
+ WarriorScore int32 //勇士积分
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertExpeditionDataList = map[int32]*ConvertExpedition{}
|
|
|
+var ConvertExpeditionDropBuffList = map[uint64]*ConvertExpeditionBuffInfo{}
|
|
|
+
|
|
|
+func convertExpeditionCfg() {
|
|
|
+ //ExpeditionCfg
|
|
|
+ for _, cfgData := range serverproto.ExpeditionCfgLoader {
|
|
|
+ convertData, ok := ConvertExpeditionDataList[cfgData.Type]
|
|
|
+ if !ok {
|
|
|
+ convertData = &ConvertExpedition{
|
|
|
+ ExpeditionType: cfgData.Type,
|
|
|
+ LevelNum: cfgData.LevelNum,
|
|
|
+ LevelInfo: map[int32]*ConvertExpeditionDetailInfo{},
|
|
|
+ }
|
|
|
+ ConvertExpeditionDataList[cfgData.Type] = convertData
|
|
|
+ }
|
|
|
+ if cfgData.Type > 0 {
|
|
|
+ convertData.ExpeditionType = cfgData.Type
|
|
|
+ }
|
|
|
+ if cfgData.LevelNum > 0 {
|
|
|
+ convertData.LevelNum = cfgData.LevelNum
|
|
|
+ }
|
|
|
+ if cfgData.ChallengeNum > 0 {
|
|
|
+ convertData.LevelUnlockAddNum = cfgData.ChallengeNum
|
|
|
+ }
|
|
|
+ if cfgData.LevelCoefficient > 0 {
|
|
|
+ convertData.LevelCoefficient = float32(cfgData.LevelCoefficient) / 100
|
|
|
+ }
|
|
|
+ if len(cfgData.DayReward) > 0 {
|
|
|
+ for idx := 0; idx < len(cfgData.DayReward); idx++ {
|
|
|
+ key, val := Str2Res(cfgData.DayReward[idx])
|
|
|
+ if key <= 0 || val <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ convertData.PassRewardList = append(convertData.PassRewardList,
|
|
|
+ &serverproto.KeyValueType{Key: key, Value: val})
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //level info
|
|
|
+ levelInfo := &ConvertExpeditionDetailInfo{
|
|
|
+ Id: cfgData.Id,
|
|
|
+ LevelId: cfgData.LevelId,
|
|
|
+ MaxFightingTime: cfgData.MaxFightingTime,
|
|
|
+ WarriorScore: cfgData.WarriorScore,
|
|
|
+ }
|
|
|
+ //level boss list
|
|
|
+ var totalWeight int32 = 0
|
|
|
+ for idx := 0; idx < len(cfgData.BossList); idx++ {
|
|
|
+ weight, bossId, level, hp, sp := Str2Res_5(cfgData.BossList[idx])
|
|
|
+ if bossId <= 0 || level <= 0 || hp <= 0 || sp <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ totalWeight = weight
|
|
|
+ bossInfo := &ConvertExpeditionBossInfo{
|
|
|
+ Weight: totalWeight,
|
|
|
+ BossId: bossId,
|
|
|
+ BossLevel: level,
|
|
|
+ BossHP: hp,
|
|
|
+ BossSP: sp,
|
|
|
+ }
|
|
|
+ levelInfo.BossList = append(levelInfo.BossList, bossInfo)
|
|
|
+ }
|
|
|
+ //level reward list
|
|
|
+ for idx := 0; idx < len(cfgData.Reward); idx++ {
|
|
|
+ key, val := Str2Res(cfgData.Reward[idx])
|
|
|
+ if key <= 0 || val <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ levelInfo.RewardList = append(levelInfo.RewardList, &serverproto.KeyValueType{Key: key, Value: val})
|
|
|
+ }
|
|
|
+
|
|
|
+ convertData.LevelInfo[levelInfo.LevelId] = levelInfo
|
|
|
+ }
|
|
|
+ //boss drop buff list
|
|
|
+ for _, cfgData := range serverproto.ExpeditionBuffDropCfgLoader {
|
|
|
+ bossBuffData := &ConvertExpeditionBuffInfo{
|
|
|
+ BossId: cfgData.BossID,
|
|
|
+ LevelId: cfgData.LevelId,
|
|
|
+ WarriorScore: cfgData.WarriorScore,
|
|
|
+ }
|
|
|
+ bossBuffData.Id = uint64(bossBuffData.BossId)*100000 + uint64(bossBuffData.LevelId)
|
|
|
+
|
|
|
+ for idx := 0; idx < len(cfgData.Buffs); idx++ {
|
|
|
+ weight, buffId := Str2Res(cfgData.Buffs[idx])
|
|
|
+ if buffId <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ bossBuffData.BuffList = append(bossBuffData.BuffList, &serverproto.KeyValueType{Key: buffId, Value: weight})
|
|
|
+ }
|
|
|
+ ConvertExpeditionDropBuffList[bossBuffData.Id] = bossBuffData
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查boss数据是否存在
|
|
|
+ for _, typeData := range ConvertExpeditionDataList {
|
|
|
+ for _, levelData := range typeData.LevelInfo {
|
|
|
+ for idx := 0; idx < len(levelData.BossList); idx++ {
|
|
|
+ //对应level boss是否存在掉落buff数据
|
|
|
+ tmpId := uint64(levelData.BossList[idx].BossId)*100000 + uint64(levelData.Id)
|
|
|
+ if _, ok := ConvertExpeditionDropBuffList[tmpId]; !ok {
|
|
|
+ //panic(errors.New("level boss not exist drop buff data:" + strconv.FormatUint(tmpId, 10)))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// /精彩活动
|
|
|
+type ConvertActivitiesData struct {
|
|
|
+ Id int32
|
|
|
+ ActivityType int32
|
|
|
+ StartTimeStr string
|
|
|
+ EndTimeStr string
|
|
|
+ TerminalOpenTimeStr string
|
|
|
+ OpenConditionList []*serverproto.KeyValueType
|
|
|
+ BG string
|
|
|
+ ServiceMark int32 //是否为合服活动
|
|
|
+
|
|
|
+ TimeType int //1绝对时间 2相对开服时间 3相对角色创建时间
|
|
|
+ StartTime time.Time
|
|
|
+ EndTime time.Time
|
|
|
+
|
|
|
+ StartDay int
|
|
|
+ EndDay int
|
|
|
+
|
|
|
+ CalStartTime time.Time
|
|
|
+ CalEndTime time.Time
|
|
|
+ CalEndTimeMs uint64
|
|
|
+
|
|
|
+ HDItemList set.Interface
|
|
|
+
|
|
|
+ //过期后的活动是否强制开启(之前没有开启过,只针对相对开服时间开启的活动类型)
|
|
|
+ ExpiredActivities bool
|
|
|
+ //活动开启最后截至时间(填写绝对时间)
|
|
|
+ TerminalOpenTime time.Time
|
|
|
+ TerminalOpenTimeMs uint64
|
|
|
+}
|
|
|
+type ConvertActivitiesTaskData struct {
|
|
|
+ TaskId int32
|
|
|
+ ConditionList map[int32][]int32
|
|
|
+ RewardList map[int32]int32
|
|
|
+ TaskScore int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertActivitiesList = map[int32]*ConvertActivitiesData{}
|
|
|
+var ConvertActivitiesTaskList = map[int32]*ConvertActivitiesTaskData{}
|
|
|
+
|
|
|
+// 14日连续登录活动
|
|
|
+// key=ActivitiesId * 1000 + Day
|
|
|
+var ConvertActivitiesFOList = map[int32]map[int32]int32{}
|
|
|
+
|
|
|
+// 14日阶段目标
|
|
|
+type ConvertActivitiesFortnightDaysData struct {
|
|
|
+ Days int32
|
|
|
+ TaskList []uint32
|
|
|
+ DailyTaskList []uint32
|
|
|
+}
|
|
|
+type ConvertActivitiesFortnightDaysScoreData struct {
|
|
|
+ RewardIdx int32
|
|
|
+ Score int32
|
|
|
+ RewardList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertActivitiesFortnightDaysList = map[int32]*ConvertActivitiesFortnightDaysData{}
|
|
|
+var ConvertActivitiesFortnightDaysScoreList = map[int32][]*ConvertActivitiesFortnightDaysScoreData{}
|
|
|
+
|
|
|
+// 首充/百元礼包
|
|
|
+type ConvertActFirstRechargeData struct {
|
|
|
+ OpenConditionList []*serverproto.KeyValueType
|
|
|
+ OpenConditionStrList []string
|
|
|
+ RechargeAmount float32 //达到该金额解锁首充奖励获取
|
|
|
+ Day1Reward []*serverproto.KeyValueType
|
|
|
+ Day2Reward []*serverproto.KeyValueType
|
|
|
+ Day3Reward []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertActFirstRecharge *ConvertActFirstRechargeData = nil
|
|
|
+var ConvertAct100Recharge *ConvertActFirstRechargeData = nil
|
|
|
+
|
|
|
+type StActTiredRecharge struct {
|
|
|
+ Day int32
|
|
|
+ Amount float32
|
|
|
+ Rewards []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+// 累计充值奖励
|
|
|
+var ConvertActTiredRecharge = map[int32]*StActTiredRecharge{}
|
|
|
+
|
|
|
+func GetActTiredRechargeDb(index, day int32) *StActTiredRecharge {
|
|
|
+ dbDay := int32(0)
|
|
|
+ for _, recharge := range ConvertActTiredRecharge {
|
|
|
+ if day >= recharge.Day {
|
|
|
+ if dbDay <= 0 || recharge.Day > dbDay {
|
|
|
+ dbDay = recharge.Day
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 左16位 当天领奖档次, 右16位活动天数
|
|
|
+ db := ConvertActTiredRecharge[index<<16|dbDay]
|
|
|
+ return db
|
|
|
+}
|
|
|
+
|
|
|
+// 超值礼包
|
|
|
+type ConvertActDiscountsRechargeData struct {
|
|
|
+ Id int32
|
|
|
+ ProductId int32
|
|
|
+ Name string
|
|
|
+ OpenCondition *serverproto.KeyValueTypeList
|
|
|
+ Amount float32 //购买价格
|
|
|
+ RewardList []*serverproto.KeyValueType
|
|
|
+ DurationTime uint64 //持续时间
|
|
|
+ UnlockCount int32 //触发次数
|
|
|
+ Recharge int32 //历史累计充值档位
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertActDiscountsRecharge = map[int32]*ConvertActDiscountsRechargeData{}
|
|
|
+
|
|
|
+// [type][id][data]
|
|
|
+var ConvertActDiscountsRechargeList = map[int32][]*ConvertActDiscountsRechargeData{}
|
|
|
+
|
|
|
+type ConvertActCollectionData struct {
|
|
|
+ Id int32
|
|
|
+ Name string
|
|
|
+ Order int32
|
|
|
+ ExchangeConditionList map[int32]int32
|
|
|
+ ServerRewardNum int32 //全服奖励数量
|
|
|
+ RewardNum int32 //兑换奖励次数上限
|
|
|
+ RewardList []*serverproto.KeyValueType
|
|
|
+ ActivitiesId int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertActCollection = map[int32]*ConvertActCollectionData{}
|
|
|
+
|
|
|
+type ConvertActLikabilityItemData struct {
|
|
|
+ ActivityId int32
|
|
|
+ LikabilityItemId int32 //道具id
|
|
|
+ LikabilityList []*serverproto.KeyValueTypeList
|
|
|
+}
|
|
|
+
|
|
|
+//var ConvertActLikabilityItem = map[int32]*ConvertActLikabilityItemData{}
|
|
|
+
|
|
|
+// [activityid][level][item...]
|
|
|
+var ConvertActLikabilityItemList = map[int32]map[int32]*ConvertActLikabilityItemData{}
|
|
|
+
|
|
|
+type ConvertActLikabilityData struct {
|
|
|
+ ActivityId int32
|
|
|
+ Level int32
|
|
|
+ LikeValMax int32
|
|
|
+ RewardList []*serverproto.KeyValueTypeList
|
|
|
+}
|
|
|
+
|
|
|
+// var ConvertActLikability = map[int32]*ConvertActLikabilityData{}
|
|
|
+var ConvertActLikabilityList = map[int32]map[int32]*ConvertActLikabilityData{}
|
|
|
+
|
|
|
+const (
|
|
|
+ Exchange_Type_Special = 1
|
|
|
+ Exchange_Type_Common = 2
|
|
|
+)
|
|
|
+
|
|
|
+const (
|
|
|
+ Exchange_Activity_Type_Pet = 0
|
|
|
+ Exchange_Activity_Type_Card = 1
|
|
|
+)
|
|
|
+
|
|
|
+type ExchangePetCondition struct {
|
|
|
+ CondType int32
|
|
|
+ ConditionId int32
|
|
|
+ Id int32
|
|
|
+ Level int32
|
|
|
+ SkillLevel int32
|
|
|
+ Count int32
|
|
|
+}
|
|
|
+
|
|
|
+type ExchangeCardCondition struct {
|
|
|
+ CondType int32
|
|
|
+ ConditionId int32
|
|
|
+ ItemType int32
|
|
|
+ ItemLevel int32
|
|
|
+ ItemId int32
|
|
|
+ ItemCount int32
|
|
|
+ ItemQuality int32
|
|
|
+ Scope map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertExchangeData struct {
|
|
|
+ Id int32
|
|
|
+ ActivitiesId int32
|
|
|
+ ActivitiesType int32
|
|
|
+ ConditionPet []*ExchangePetCondition
|
|
|
+ ConditionCard []*ExchangeCardCondition
|
|
|
+ Reward []*serverproto.KeyValueType
|
|
|
+ RewardNum int32 //兑换次数
|
|
|
+ ServerRewardNum int32
|
|
|
+ BroadCast int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertExchange = map[int32]*ConvertExchangeData{}
|
|
|
+
|
|
|
+type ResetIndexs struct {
|
|
|
+ Id []int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertExchangeReset = map[int32]*ResetIndexs{}
|
|
|
+
|
|
|
+const (
|
|
|
+ ActivitiesTime_Type_None = 0 //永久活动时间
|
|
|
+ ActivitiesTime_Type_Global = 1 //绝对时间
|
|
|
+ ActivitiesTime_Type_Server = 2 //相对开服时间 //根据开服时间endday-startday(持续时间)
|
|
|
+ ActivitiesTime_Type_Role = 3 //相对角色创建时间 //根据创建角色时间endday-startday + 1(持续时间)
|
|
|
+ ActivitiesTime_Type_System = 4 //根据玩家开启系统决定活动开启时间
|
|
|
+)
|
|
|
+
|
|
|
+func convertActivitiesCfg() {
|
|
|
+ //ActivitiesCfg
|
|
|
+ for _, cfgData := range serverproto.ActivitiesCfgLoader {
|
|
|
+ tmpData := &ConvertActivitiesData{
|
|
|
+ Id: cfgData.Id,
|
|
|
+ ActivityType: cfgData.Type,
|
|
|
+ BG: cfgData.BG,
|
|
|
+ HDItemList: set.New(set.NonThreadSafe),
|
|
|
+ ServiceMark: cfgData.ServiceMark,
|
|
|
+ }
|
|
|
+
|
|
|
+ for idx := 0; idx < len(cfgData.OpenCondition); idx++ {
|
|
|
+ key, val := Str2Res(cfgData.OpenCondition[idx])
|
|
|
+ if key > 0 {
|
|
|
+ tmpData.OpenConditionList = append(tmpData.OpenConditionList, &serverproto.KeyValueType{Key: key, Value: val})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ startDataList := strings.Split(cfgData.StartTime, ";")
|
|
|
+ endDataList := strings.Split(cfgData.EndTime, ";")
|
|
|
+ if len(startDataList) > 0 && len(endDataList) > 0 {
|
|
|
+ tmpData.TimeType, _ = Str2Num(startDataList[0])
|
|
|
+ switch tmpData.TimeType {
|
|
|
+ case ActivitiesTime_Type_Global: //绝对时间
|
|
|
+ loc := util.GetLoc()
|
|
|
+ tmpData.StartTime, _ = time.ParseInLocation(util.DATE_FORMAT, startDataList[1], loc)
|
|
|
+ tmpData.EndTime, _ = time.ParseInLocation(util.DATE_FORMAT, endDataList[1], loc)
|
|
|
+ tmpData.StartTimeStr = startDataList[1]
|
|
|
+ tmpData.EndTimeStr = endDataList[1]
|
|
|
+ case ActivitiesTime_Type_Server: //相对开服时间
|
|
|
+ fallthrough
|
|
|
+ case ActivitiesTime_Type_Role: //相对创建角色时间
|
|
|
+ tmpData.StartDay, _ = Str2Num(startDataList[1])
|
|
|
+ tmpData.EndDay, _ = Str2Num(endDataList[1])
|
|
|
+ tmpData.StartTimeStr = startDataList[2]
|
|
|
+ tmpData.EndTimeStr = endDataList[2]
|
|
|
+ if tmpData.EndDay < tmpData.StartDay {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ loc := util.GetLoc()
|
|
|
+ tmpData.StartTime, _ = time.ParseInLocation(util.DATE_FORMAT2, startDataList[2], loc)
|
|
|
+ tmpData.EndTime, _ = time.ParseInLocation(util.DATE_FORMAT2, endDataList[2], loc)
|
|
|
+
|
|
|
+ if len(startDataList) >= 4 {
|
|
|
+ tmpData.TerminalOpenTimeStr = startDataList[3]
|
|
|
+ tmpData.TerminalOpenTime = util.GetTimeByStr(tmpData.TerminalOpenTimeStr)
|
|
|
+ tmpData.TerminalOpenTimeMs = uint64(tmpData.TerminalOpenTime.UnixNano() / 1e6)
|
|
|
+ }
|
|
|
+ case ActivitiesTime_Type_System: //根据玩家开启系统决定活动开启时间
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //永久活动时间
|
|
|
+ tmpData.TimeType = 0
|
|
|
+ }
|
|
|
+
|
|
|
+ //过期后的活动是否强制开启(之前没有开启过,只针对相对开服时间开启的活动类型)
|
|
|
+ if cfgData.ExpiredActivities > 0 && tmpData.TimeType == ActivitiesTime_Type_Server {
|
|
|
+ tmpData.ExpiredActivities = true
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否有活动道具
|
|
|
+ for idx := 0; idx < len(cfgData.HdDrop); idx++ {
|
|
|
+ hdItemId, _ := Str2Num(cfgData.HdDrop[idx])
|
|
|
+ if hdItemId > 0 {
|
|
|
+ tmpData.HDItemList.Add(int32(hdItemId))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertActivitiesList[tmpData.Id] = tmpData
|
|
|
+ }
|
|
|
+ //ActivityTaskCfg
|
|
|
+ for _, cfgData := range serverproto.ActivitiesTaskCfgLoader {
|
|
|
+ tmpData := &ConvertActivitiesTaskData{
|
|
|
+ TaskId: cfgData.TaskId,
|
|
|
+ TaskScore: cfgData.Integral,
|
|
|
+ RewardList: map[int32]int32{},
|
|
|
+ ConditionList: map[int32][]int32{},
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.TaskCondition); idx++ {
|
|
|
+ valueList := strings.Split(cfgData.TaskCondition[idx], ":")
|
|
|
+ if len(valueList) >= 2 {
|
|
|
+ taskType, _ := Str2Num(valueList[0])
|
|
|
+ tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskType))
|
|
|
+ for i := 1; i < len(valueList); i++ {
|
|
|
+ taskValue, _ := Str2Num(valueList[i])
|
|
|
+ tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskValue))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Reward); idx++ {
|
|
|
+ key, val := Str2Res(cfgData.Reward[idx])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ tmpData.RewardList[key] += val
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertActivitiesTaskList[tmpData.TaskId] = tmpData
|
|
|
+ }
|
|
|
+ //ActivitiesFortnightOnlineCfg
|
|
|
+ for _, cfgData := range serverproto.ActivitiesFortnightOnlineCfgLoader {
|
|
|
+ tempId := cfgData.ActivitiesId*1000 + cfgData.Day
|
|
|
+ ConvertActivitiesFOList[tempId] = map[int32]int32{}
|
|
|
+ for idx := 0; idx < len(cfgData.Rewards); idx++ {
|
|
|
+ key, val := Str2Res(cfgData.Rewards[idx])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ ConvertActivitiesFOList[tempId][key] += val
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //ActivitiesFortnightDaysCfg
|
|
|
+ duplicateSet := set.New(set.NonThreadSafe)
|
|
|
+ for _, cfgData := range serverproto.ActivitiesFortnightDaysCfgLoader {
|
|
|
+ tmpData := &ConvertActivitiesFortnightDaysData{
|
|
|
+ Days: cfgData.Id,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.TaskIds); idx++ {
|
|
|
+ taskId, _ := Str2Num(cfgData.TaskIds[idx])
|
|
|
+ if duplicateSet.Has(taskId) {
|
|
|
+ panic("task id repeated")
|
|
|
+ }
|
|
|
+ duplicateSet.Add(taskId)
|
|
|
+ tmpData.TaskList = append(tmpData.TaskList, uint32(taskId))
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.DailyTaskIds); idx++ {
|
|
|
+ taskId, _ := Str2Num(cfgData.DailyTaskIds[idx])
|
|
|
+ if duplicateSet.Has(taskId) {
|
|
|
+ panic("task id repeated")
|
|
|
+ }
|
|
|
+ duplicateSet.Add(taskId)
|
|
|
+ tmpData.DailyTaskList = append(tmpData.DailyTaskList, uint32(taskId))
|
|
|
+ }
|
|
|
+ ConvertActivitiesFortnightDaysList[tmpData.Days] = tmpData
|
|
|
+ }
|
|
|
+
|
|
|
+ //ActivitiesRewardCfg
|
|
|
+ //task score reward
|
|
|
+ for _, cfgData := range serverproto.ActivitiesRewardCfgLoader {
|
|
|
+ scoreData := &ConvertActivitiesFortnightDaysScoreData{
|
|
|
+ RewardIdx: cfgData.Id,
|
|
|
+ Score: cfgData.Integral,
|
|
|
+ RewardList: map[int32]int32{},
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Rewards); idx++ {
|
|
|
+ key, val := Str2Res(cfgData.Rewards[idx])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ scoreData.RewardList[key] += val
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //Type 1第一周 2第二周
|
|
|
+ ConvertActivitiesFortnightDaysScoreList[cfgData.Type] = append(ConvertActivitiesFortnightDaysScoreList[cfgData.Type], scoreData)
|
|
|
+ }
|
|
|
+
|
|
|
+ //ActiviesFirstChargeCfg
|
|
|
+ for _, cfgData := range serverproto.ActivitiesFirstChargeCfgLoader {
|
|
|
+ tmpData := &ConvertActFirstRechargeData{
|
|
|
+ RechargeAmount: float32(cfgData.RechargeAmount),
|
|
|
+ }
|
|
|
+ tmpData.OpenConditionStrList = cfgData.OpenCondition
|
|
|
+ for idx := 0; idx < len(cfgData.OpenCondition); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.OpenCondition[idx])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ tmpData.OpenConditionList = append(tmpData.OpenConditionList, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Reward1); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.Reward1[idx])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ tmpData.Day1Reward = append(tmpData.Day1Reward, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Reward2); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.Reward2[idx])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ tmpData.Day2Reward = append(tmpData.Day2Reward, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Reward3); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.Reward3[idx])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ tmpData.Day3Reward = append(tmpData.Day3Reward, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //first recharge
|
|
|
+ if cfgData.Id == 1 {
|
|
|
+ ConvertActFirstRecharge = tmpData
|
|
|
+ } else if cfgData.Id == 2 {
|
|
|
+ //百元大礼包
|
|
|
+ ConvertAct100Recharge = tmpData
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //ActiviesTiredChargeCfg 累计充值奖励
|
|
|
+ for _, cfgData := range serverproto.ActivitiesTiredChargeCfgLoader {
|
|
|
+ dbData := &StActTiredRecharge{Amount: cfgData.RechargeAmount, Day: cfgData.Day}
|
|
|
+ for idx := 0; idx < len(cfgData.Reward); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.Reward[idx])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ dbData.Rewards = append(dbData.Rewards, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ // 左16位 当天领奖档次, 右16位活动天数
|
|
|
+ ConvertActTiredRecharge[cfgData.Index<<16|cfgData.Day] = dbData
|
|
|
+ }
|
|
|
+ //ActiviesDiscountsCfg //超值礼包
|
|
|
+ for _, cfgData := range serverproto.ActivitiesDiscountsCfgLoader {
|
|
|
+ tmpData := &ConvertActDiscountsRechargeData{
|
|
|
+ Id: cfgData.Id,
|
|
|
+ Amount: float32(cfgData.Money),
|
|
|
+ DurationTime: uint64(cfgData.Time) * 1000,
|
|
|
+ Name: cfgData.Name,
|
|
|
+ UnlockCount: cfgData.Popup,
|
|
|
+ Recharge: cfgData.Recharge,
|
|
|
+ ProductId: cfgData.ProductID,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Reward); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.Reward[idx])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmpData.RewardList = append(tmpData.RewardList, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.TriggeringCondition); idx++ {
|
|
|
+ valList := strings.Split(cfgData.TriggeringCondition[idx], ":")
|
|
|
+ key, _ := Str2Num(valList[0])
|
|
|
+ tmpData.OpenCondition = &serverproto.KeyValueTypeList{Key: int32(key)}
|
|
|
+ for k := 1; k < len(valList); k++ {
|
|
|
+ val, _ := Str2Num(valList[k])
|
|
|
+ tmpData.OpenCondition.ValueList = append(tmpData.OpenCondition.ValueList, int32(val))
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ ConvertActDiscountsRecharge[cfgData.Id] = tmpData
|
|
|
+
|
|
|
+ //分类优化性能
|
|
|
+ ConvertActDiscountsRechargeList[tmpData.OpenCondition.Key] = append(
|
|
|
+ ConvertActDiscountsRechargeList[tmpData.OpenCondition.Key], tmpData)
|
|
|
+ }
|
|
|
+ for key, _ := range ConvertActDiscountsRechargeList {
|
|
|
+ sort.Slice(ConvertActDiscountsRechargeList[key], func(i, j int) bool {
|
|
|
+ return ConvertActDiscountsRechargeList[key][i].OpenCondition.ValueList[0] < ConvertActDiscountsRechargeList[key][j].OpenCondition.ValueList[0]
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ //ActivitiesCollectionCfg 集字活动
|
|
|
+ //var ConvertActCollection = map[int32]*ConvertActCollectionData{}
|
|
|
+ for _, cfgData := range serverproto.ActivitiesCollectionCfgLoader {
|
|
|
+ tmpData := &ConvertActCollectionData{
|
|
|
+ Id: cfgData.Id,
|
|
|
+ ExchangeConditionList: map[int32]int32{},
|
|
|
+ ServerRewardNum: cfgData.ServersReward,
|
|
|
+ RewardNum: cfgData.Number,
|
|
|
+ ActivitiesId: cfgData.ActivitiesId,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.ExchangeCondition); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.ExchangeCondition[idx])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmpData.ExchangeConditionList[k] += v
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Reward); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.Reward[idx])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmpData.RewardList = append(tmpData.RewardList,
|
|
|
+ &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertActCollection[tmpData.Id] = tmpData
|
|
|
+ }
|
|
|
+
|
|
|
+ //ActivitieslikabilityCfg ActivitiesGiftCfg 好感度活动
|
|
|
+ for _, cfgData := range serverproto.ActivitiesGiftCfgLoader {
|
|
|
+ tmpData := &ConvertActLikabilityItemData{
|
|
|
+ ActivityId: cfgData.Activityid,
|
|
|
+ LikabilityItemId: cfgData.Classitemid,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Classcostaddlike); idx++ {
|
|
|
+ v1, v2, v3 := Str2Res_3(cfgData.Classcostaddlike[idx])
|
|
|
+ if v1 <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmpData.LikabilityList = append(tmpData.LikabilityList,
|
|
|
+ &serverproto.KeyValueTypeList{Key: cfgData.Classitemid, ValueList: []int32{v1, v2, v3}})
|
|
|
+ }
|
|
|
+ if _, ok := ConvertActLikabilityItemList[cfgData.Activityid]; !ok {
|
|
|
+ ConvertActLikabilityItemList[cfgData.Activityid] = map[int32]*ConvertActLikabilityItemData{}
|
|
|
+ }
|
|
|
+ ConvertActLikabilityItemList[cfgData.Activityid][cfgData.Classitemid] = tmpData
|
|
|
+ //ConvertActLikabilityItem[cfgData.Classitemid] = tmpData
|
|
|
+ }
|
|
|
+ for _, cfgData := range serverproto.ActivitieslikabilityCfgLoader {
|
|
|
+ tmpData := &ConvertActLikabilityData{
|
|
|
+ ActivityId: cfgData.Activityid,
|
|
|
+ Level: cfgData.Likelevel,
|
|
|
+ LikeValMax: cfgData.LikeMax,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Conditionrewards); idx++ {
|
|
|
+ k, v1, v2 := Str2Res_3(cfgData.Conditionrewards[idx])
|
|
|
+ if k <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmpData.RewardList = append(tmpData.RewardList, &serverproto.KeyValueTypeList{
|
|
|
+ Key: k,
|
|
|
+ ValueList: []int32{v1, v2},
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if _, ok := ConvertActLikabilityList[cfgData.Activityid]; !ok {
|
|
|
+ ConvertActLikabilityList[cfgData.Activityid] = map[int32]*ConvertActLikabilityData{}
|
|
|
+ }
|
|
|
+ ConvertActLikabilityList[cfgData.Activityid][cfgData.Likelevel] = tmpData
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, cfgData := range serverproto.ActivitiesPetExchangeCfgLoader {
|
|
|
+ tmpData := &ConvertExchangeData{
|
|
|
+ Id: cfgData.Id,
|
|
|
+ ActivitiesId: cfgData.ActivitiesId,
|
|
|
+ RewardNum: cfgData.Number,
|
|
|
+ ServerRewardNum: cfgData.ServersReward,
|
|
|
+ ActivitiesType: cfgData.Type,
|
|
|
+ BroadCast: cfgData.Broadcast,
|
|
|
+ }
|
|
|
+ if cfgData.ResetDay != 0 {
|
|
|
+ ResetData, resetOk := ConvertExchangeReset[cfgData.ActivitiesId]
|
|
|
+ if resetOk {
|
|
|
+ ResetData.Id = append(ResetData.Id, cfgData.Id)
|
|
|
+ } else {
|
|
|
+ convertResetData := &ResetIndexs{}
|
|
|
+ convertResetData.Id = append(convertResetData.Id, cfgData.Id)
|
|
|
+ ConvertExchangeReset[cfgData.ActivitiesId] = convertResetData
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if cfgData.Type == int32(Exchange_Activity_Type_Pet) {
|
|
|
+ for _, condition := range cfgData.ExchangeCondition1 {
|
|
|
+ strList := strings.Split(condition, ":")
|
|
|
+ if len(strList) >= 5 {
|
|
|
+ condId, _ := Str2Num(strList[0])
|
|
|
+ id, _ := Str2Num(strList[1])
|
|
|
+ level, _ := Str2Num(strList[2])
|
|
|
+ skillLevel, _ := Str2Num(strList[3])
|
|
|
+ count, _ := Str2Num(strList[4])
|
|
|
+
|
|
|
+ cond := &ExchangePetCondition{
|
|
|
+ CondType: Exchange_Type_Special,
|
|
|
+ ConditionId: int32(condId),
|
|
|
+ Id: int32(id),
|
|
|
+ Level: int32(level),
|
|
|
+ SkillLevel: int32(skillLevel),
|
|
|
+ Count: int32(count),
|
|
|
+ }
|
|
|
+ tmpData.ConditionPet = append(tmpData.ConditionPet, cond)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, condition := range cfgData.ExchangeCondition2 {
|
|
|
+ strList := strings.Split(condition, ":")
|
|
|
+ if len(strList) >= 5 {
|
|
|
+ condId, _ := Str2Num(strList[0])
|
|
|
+ id, _ := Str2Num(strList[1])
|
|
|
+ level, _ := Str2Num(strList[2])
|
|
|
+ skillLevel, _ := Str2Num(strList[3])
|
|
|
+ count, _ := Str2Num(strList[4])
|
|
|
+
|
|
|
+ cond := &ExchangePetCondition{
|
|
|
+ CondType: Exchange_Type_Common,
|
|
|
+ ConditionId: int32(condId),
|
|
|
+ Id: int32(id),
|
|
|
+ Level: int32(level),
|
|
|
+ SkillLevel: int32(skillLevel),
|
|
|
+ Count: int32(count),
|
|
|
+ }
|
|
|
+ tmpData.ConditionPet = append(tmpData.ConditionPet, cond)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if cfgData.Type == int32(Exchange_Activity_Type_Card) {
|
|
|
+ for _, condition := range cfgData.ExchangeCondition1 {
|
|
|
+ strList := strings.Split(condition, ":")
|
|
|
+ if len(strList) >= 4 {
|
|
|
+ condId, _ := Str2Num(strList[0])
|
|
|
+ itemType, _ := Str2Num(strList[1])
|
|
|
+ itemId, _ := Str2Num(strList[2])
|
|
|
+ itemNum, _ := Str2Num(strList[3])
|
|
|
+ cond := &ExchangeCardCondition{
|
|
|
+ CondType: Exchange_Type_Special,
|
|
|
+ ConditionId: int32(condId),
|
|
|
+ ItemType: int32(itemType),
|
|
|
+ ItemId: int32(itemId),
|
|
|
+ ItemCount: int32(itemNum),
|
|
|
+ }
|
|
|
+ tmpData.ConditionCard = append(tmpData.ConditionCard, cond)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(cfgData.Scope) == len(cfgData.ExchangeCondition2) {
|
|
|
+ for i := 0; i < len(cfgData.ExchangeCondition2); i++ {
|
|
|
+ strList := strings.Split(cfgData.ExchangeCondition2[i], ":")
|
|
|
+ if len(strList) >= 4 {
|
|
|
+ condId, _ := Str2Num(strList[0])
|
|
|
+ itemType, _ := Str2Num(strList[1])
|
|
|
+ itemLevel, _ := Str2Num(strList[2])
|
|
|
+ itemCount, _ := Str2Num(strList[3])
|
|
|
+ itemQuality, _ := Str2Num(strList[4])
|
|
|
+ cond := &ExchangeCardCondition{
|
|
|
+ CondType: Exchange_Type_Common,
|
|
|
+ ConditionId: int32(condId),
|
|
|
+ ItemType: int32(itemType),
|
|
|
+ ItemLevel: int32(itemLevel),
|
|
|
+ ItemCount: int32(itemCount),
|
|
|
+ ItemQuality: int32(itemQuality),
|
|
|
+ }
|
|
|
+ cond.Scope = map[int32]int32{}
|
|
|
+
|
|
|
+ scopeList := strings.Split(cfgData.Scope[i], ":")
|
|
|
+ for _, data := range scopeList {
|
|
|
+ cardCfgId, _ := Str2Num(data)
|
|
|
+ cond.Scope[int32(cardCfgId)] = 1
|
|
|
+ }
|
|
|
+ tmpData.ConditionCard = append(tmpData.ConditionCard, cond)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, reward := range cfgData.Reward {
|
|
|
+ strList := strings.Split(reward, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ petCfgId, _ := Str2Num(strList[0])
|
|
|
+ petCount, _ := Str2Num(strList[1])
|
|
|
+ tmpData.Reward = append(tmpData.Reward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(petCfgId),
|
|
|
+ Value: int32(petCount),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertExchange[cfgData.Id] = tmpData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type HeadFrameAttr struct {
|
|
|
+ AttrList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertHeadFrameAttr = map[int32]*HeadFrameAttr{}
|
|
|
+
|
|
|
+func convertHeadFrameCfg() {
|
|
|
+ for _, data := range serverproto.HeadFrameCfgLoader {
|
|
|
+ convert := &HeadFrameAttr{
|
|
|
+ AttrList: make(map[int32]int32),
|
|
|
+ }
|
|
|
+ for _, attr := range data.HeadFrameQuality {
|
|
|
+ strList := strings.Split(attr, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ attrId, _ := Str2Num(strList[0])
|
|
|
+ attrValue, _ := Str2Num(strList[1])
|
|
|
+ convert.AttrList[int32(attrId)] += int32(attrValue)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertHeadFrameAttr[data.HeadFrameId] = convert
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// invitation
|
|
|
+type ConvertInvitationTask struct {
|
|
|
+ TaskId uint32
|
|
|
+ RewardList map[int32]int32
|
|
|
+ ConditionList map[int32][]int32
|
|
|
+ CompleteNum int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertInvitationTaskList = map[uint32]*ConvertInvitationTask{}
|
|
|
+var ConvertInvitationTaskTypeList = map[int32][]*ConvertInvitationTask{}
|
|
|
+
|
|
|
+func convertInvitationCfg() {
|
|
|
+ for _, cfgData := range serverproto.InvitationTaskCfgLoader {
|
|
|
+ tmpData := &ConvertInvitationTask{
|
|
|
+ TaskId: uint32(cfgData.TaskId),
|
|
|
+ CompleteNum: cfgData.CompleteNum,
|
|
|
+ RewardList: map[int32]int32{},
|
|
|
+ ConditionList: map[int32][]int32{},
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.TaskCondition); idx++ {
|
|
|
+ valueList := strings.Split(cfgData.TaskCondition[idx], ":")
|
|
|
+ if len(valueList) >= 2 {
|
|
|
+ taskType, _ := Str2Num(valueList[0])
|
|
|
+ tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskType))
|
|
|
+ for i := 1; i < len(valueList); i++ {
|
|
|
+ taskValue, _ := Str2Num(valueList[i])
|
|
|
+ tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskValue))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Reward); idx++ {
|
|
|
+ key, val := Str2Res(cfgData.Reward[idx])
|
|
|
+ if key > 0 && val > 0 {
|
|
|
+ tmpData.RewardList[key] += val
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for key := range tmpData.ConditionList {
|
|
|
+ ConvertInvitationTaskTypeList[key] = append(ConvertInvitationTaskTypeList[key], tmpData)
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertInvitationTaskList[tmpData.TaskId] = tmpData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type VipData struct {
|
|
|
+ VipRight map[int32]int32
|
|
|
+ VipReward map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertVipRight = map[int32]*VipData{}
|
|
|
+
|
|
|
+const (
|
|
|
+ Vip_System_Levelup = 1 //vip升级需要经验
|
|
|
+ Vip_System_Evil = 2 //vip恶魔协会免费刷新次数(0开始恶魔协会刷新金色条目)
|
|
|
+ Vip_System_Online = 3 //vip上线提示
|
|
|
+ Vip_System_PetAdvance = 4 //宠物进阶消耗
|
|
|
+ Vip_System_CardReset = 5 //卡片重置
|
|
|
+ Vip_System_PetDesolve = 6 //宠物分解
|
|
|
+ Vip_System_SkillReset = 7 //技能重置
|
|
|
+ Vip_System_GuildHunt = 8 //公会狩猎次数
|
|
|
+ Vip_System_CardInsert = 9 //一键插卡
|
|
|
+ Vip_System_ShopWeight = 10 //商店权重
|
|
|
+ Vip_System_WorldBoss = 11 //世界boss
|
|
|
+ Vip_System_Arena = 12 //英灵殿
|
|
|
+ Vip_System_QuickBattle = 13 //快速战斗次数
|
|
|
+ Vip_System_HungSilver = 14 //挂机银币
|
|
|
+ Vip_System_HungExp = 15 //挂机经验
|
|
|
+ Vip_System_HungPartnerExp = 16 //挂机伙伴经验
|
|
|
+ Vip_System_HungSkillExp = 17 //技能经验
|
|
|
+ Vip_System_HungExtraTime = 18 //挂机额外时长
|
|
|
+ Vip_System_SignReward = 19 //签到翻倍
|
|
|
+ Vip_System_WorldBoss_Count = 20 //世界boss次数
|
|
|
+)
|
|
|
+
|
|
|
+func convertVipCfg() {
|
|
|
+ for _, data := range serverproto.VipCfgLoader {
|
|
|
+ convertVip := &VipData{
|
|
|
+ VipRight: make(map[int32]int32),
|
|
|
+ VipReward: make(map[int32]int32),
|
|
|
+ }
|
|
|
+ convertVip.VipRight[Vip_System_Levelup] = data.VipExp
|
|
|
+ convertVip.VipRight[Vip_System_Evil] = data.EvilFreeTimes
|
|
|
+ convertVip.VipRight[Vip_System_Online] = data.VipLogin
|
|
|
+ convertVip.VipRight[Vip_System_PetAdvance] = data.PetAdvance
|
|
|
+ convertVip.VipRight[Vip_System_CardReset] = data.CardReset
|
|
|
+ convertVip.VipRight[Vip_System_PetDesolve] = data.PetBreak
|
|
|
+ convertVip.VipRight[Vip_System_SkillReset] = data.SkillReset
|
|
|
+ convertVip.VipRight[Vip_System_GuildHunt] = data.GuildBossChallenge
|
|
|
+ convertVip.VipRight[Vip_System_CardInsert] = data.CardInsertion
|
|
|
+ convertVip.VipRight[Vip_System_ShopWeight] = data.ShopWeight
|
|
|
+ convertVip.VipRight[Vip_System_WorldBoss] = data.WorldBoss
|
|
|
+ convertVip.VipRight[Vip_System_Arena] = data.PvpReward
|
|
|
+ convertVip.VipRight[Vip_System_QuickBattle] = data.HangupTimes
|
|
|
+ convertVip.VipRight[Vip_System_HungSilver] = data.SilverUp
|
|
|
+ convertVip.VipRight[Vip_System_HungExp] = data.BaseExpUp
|
|
|
+ convertVip.VipRight[Vip_System_HungPartnerExp] = data.PartnerExpUp
|
|
|
+ convertVip.VipRight[Vip_System_HungSkillExp] = data.SkillExpUp
|
|
|
+ convertVip.VipRight[Vip_System_HungExtraTime] = data.HangupDuration
|
|
|
+ convertVip.VipRight[Vip_System_SignReward] = data.SignInRewardUp
|
|
|
+ convertVip.VipRight[Vip_System_WorldBoss_Count] = data.WorldBossCount
|
|
|
+
|
|
|
+ for _, data := range data.Reward {
|
|
|
+ strList := strings.Split(data, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ convertVip.VipReward[int32(key)] += int32(value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertVipRight[data.Lv] = convertVip
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type SummonCost struct {
|
|
|
+ ItemId int32
|
|
|
+ ItemNum int32
|
|
|
+ SourceId int32
|
|
|
+ SourceNum int32
|
|
|
+ DrawCount map[int32]int32
|
|
|
+ ActivitiesId int32 //是否属于活动召唤数据
|
|
|
+ SummonType int32 //召唤类型 1卡片 2宠物 3神器
|
|
|
+ Total int32
|
|
|
+ //根据开服时间获取不同掉落配置
|
|
|
+ ServerDataList []*SummonCostByServerTime
|
|
|
+}
|
|
|
+
|
|
|
+// 相对开服时间天数
|
|
|
+func (this *SummonCost) GetDataByDiffDay(diffDay int32) *SummonCostByServerTime {
|
|
|
+ for idx := 0; idx < len(this.ServerDataList); idx++ {
|
|
|
+ if diffDay <= this.ServerDataList[idx].ServerTime {
|
|
|
+ return this.ServerDataList[idx]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(this.ServerDataList) > 0 {
|
|
|
+ return this.ServerDataList[len(this.ServerDataList)-1]
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+type SummonCostByServerTime struct {
|
|
|
+ Id int32
|
|
|
+ ServerTime int32 //相对开服时间天数
|
|
|
+ SummonType int32 //召唤类型
|
|
|
+ SummonGroup int32 //召唤组
|
|
|
+ DropId int32
|
|
|
+ DropId2 int32
|
|
|
+ ExtDropId int32
|
|
|
+}
|
|
|
+
|
|
|
+type DrawTemplate struct {
|
|
|
+ ConfigId int32
|
|
|
+ WeightItem int32
|
|
|
+ WeightGold int32
|
|
|
+ ExtraPoint int32
|
|
|
+ DrawItem []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+type DrawPool struct {
|
|
|
+ TotalWeightItem int32
|
|
|
+ TotalWeightGold int32
|
|
|
+ DrawTemplate []*DrawTemplate
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertSummonList = map[int32]*SummonCost{}
|
|
|
+var ConvertDrawTemplate = map[int32]*DrawPool{}
|
|
|
+
|
|
|
+const (
|
|
|
+ Draw_ResType_Item = 1
|
|
|
+ Draw_ResType_Gold = 2
|
|
|
+)
|
|
|
+
|
|
|
+func convertSummonCfg() {
|
|
|
+ for _, data := range serverproto.SummonServerCfgLoader {
|
|
|
+ convertData := &SummonCost{
|
|
|
+ DrawCount: make(map[int32]int32),
|
|
|
+ ActivitiesId: data.ActivitiesId,
|
|
|
+ SummonType: data.Type,
|
|
|
+ Total: data.Total,
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(data.Cost) >= 1 {
|
|
|
+ itemId, itemCount := Str2Res(data.Cost[0])
|
|
|
+ convertData.ItemId = itemId
|
|
|
+ convertData.ItemNum = itemCount
|
|
|
+ }
|
|
|
+ if len(data.Cost) >= 2 {
|
|
|
+ sourceId, sourceCount := Str2Res(data.Cost[1])
|
|
|
+ convertData.SourceId = sourceId
|
|
|
+ convertData.SourceNum = sourceCount
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, count := range data.Method {
|
|
|
+ drawCount, _ := Str2Num(count)
|
|
|
+ convertData.DrawCount[int32(drawCount)] = 1
|
|
|
+ }
|
|
|
+
|
|
|
+ serverData := &SummonCostByServerTime{
|
|
|
+ Id: data.Id,
|
|
|
+ ServerTime: data.StartDay,
|
|
|
+ SummonType: data.Type,
|
|
|
+ SummonGroup: data.SummoType,
|
|
|
+ DropId: data.DropId,
|
|
|
+ DropId2: data.DropId2,
|
|
|
+ ExtDropId: data.ExtDropId,
|
|
|
+ }
|
|
|
+ //召唤组 只针对系统召唤(不包括活动)
|
|
|
+ if data.SummoType > 0 {
|
|
|
+ if summonData, ok := ConvertSummonList[data.SummoType]; ok {
|
|
|
+ summonData.ServerDataList = append(summonData.ServerDataList, serverData)
|
|
|
+ } else {
|
|
|
+ convertData.ServerDataList = append(convertData.ServerDataList, serverData)
|
|
|
+ ConvertSummonList[data.SummoType] = convertData
|
|
|
+ }
|
|
|
+ //无须读取导致之前没有赋值
|
|
|
+ if data.Total > 0 && len(data.Cost) > 0 {
|
|
|
+ ConvertSummonList[data.SummoType].Total = convertData.Total
|
|
|
+ ConvertSummonList[data.SummoType].SummonType = convertData.SummonType
|
|
|
+ ConvertSummonList[data.SummoType].ActivitiesId = convertData.ActivitiesId
|
|
|
+ ConvertSummonList[data.SummoType].DrawCount = convertData.DrawCount
|
|
|
+ ConvertSummonList[data.SummoType].ItemId = convertData.ItemId
|
|
|
+ ConvertSummonList[data.SummoType].ItemNum = convertData.ItemNum
|
|
|
+ ConvertSummonList[data.SummoType].SourceId = convertData.SourceId
|
|
|
+ ConvertSummonList[data.SummoType].SourceNum = convertData.SourceNum
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ convertData.ServerDataList = append(convertData.ServerDataList, serverData)
|
|
|
+ ConvertSummonList[data.Id] = convertData
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, v := range ConvertSummonList {
|
|
|
+ sort.Slice(v.ServerDataList, func(i, j int) bool {
|
|
|
+ return v.ServerDataList[i].ServerTime < v.ServerDataList[j].ServerTime
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.SummonTemplateCfgLoader {
|
|
|
+ drawPool, ok := ConvertDrawTemplate[data.CardType]
|
|
|
+ if !ok {
|
|
|
+ drawPool = &DrawPool{
|
|
|
+ TotalWeightItem: 0,
|
|
|
+ TotalWeightGold: 0,
|
|
|
+ }
|
|
|
+ ConvertDrawTemplate[data.CardType] = drawPool
|
|
|
+ }
|
|
|
+ if drawPool == nil {
|
|
|
+ // panic()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ drawPool.TotalWeightItem = drawPool.TotalWeightItem + data.Probability1
|
|
|
+ drawPool.TotalWeightGold = drawPool.TotalWeightGold + data.Probability2
|
|
|
+
|
|
|
+ //
|
|
|
+ drawTemplate := &DrawTemplate{
|
|
|
+ ConfigId: data.Id,
|
|
|
+ WeightItem: drawPool.TotalWeightItem,
|
|
|
+ WeightGold: drawPool.TotalWeightGold,
|
|
|
+ ExtraPoint: data.SecurityNum,
|
|
|
+ }
|
|
|
+ if len(data.BlueNum) >= 1 {
|
|
|
+ strList := strings.Split(data.BlueNum[0], ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ drawTemplate.DrawItem = append(drawTemplate.DrawItem, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(data.PurpleNum) >= 1 {
|
|
|
+ strList := strings.Split(data.PurpleNum[0], ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ drawTemplate.DrawItem = append(drawTemplate.DrawItem, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(data.GoldNum) >= 1 {
|
|
|
+ strList := strings.Split(data.GoldNum[0], ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ drawTemplate.DrawItem = append(drawTemplate.DrawItem, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ drawPool.DrawTemplate = append(drawPool.DrawTemplate, drawTemplate)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func GetDrawProbItem(drawType int32, resType int32) *DrawTemplate {
|
|
|
+ drawPool, ok := ConvertDrawTemplate[drawType]
|
|
|
+ if !ok {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ var totalWeight int32 = 0
|
|
|
+ if resType == Draw_ResType_Item {
|
|
|
+ totalWeight = drawPool.TotalWeightItem
|
|
|
+ } else if resType == Draw_ResType_Gold {
|
|
|
+ totalWeight = drawPool.TotalWeightGold
|
|
|
+ }
|
|
|
+ randWeight := rand.Int31n(totalWeight)
|
|
|
+ for _, data := range drawPool.DrawTemplate {
|
|
|
+ target := data.WeightItem
|
|
|
+ if resType == Draw_ResType_Gold {
|
|
|
+ target = data.WeightGold
|
|
|
+ }
|
|
|
+ if target >= randWeight {
|
|
|
+ return data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+type GiftBag struct {
|
|
|
+ GoodsId int32
|
|
|
+ BagType int32
|
|
|
+ Price float32
|
|
|
+ Name string
|
|
|
+ BuyReward []*serverproto.KeyValueType
|
|
|
+ FirstReward []*serverproto.KeyValueType
|
|
|
+ ExtraReward []*serverproto.KeyValueType
|
|
|
+ LimitCount int32
|
|
|
+ RmbTotalPay int32
|
|
|
+}
|
|
|
+
|
|
|
+type LimitBag struct {
|
|
|
+ GoodsId int32
|
|
|
+ Price float32
|
|
|
+ BeginTime int64
|
|
|
+ EndTime int64
|
|
|
+ LimitCount int32
|
|
|
+ Name string
|
|
|
+ StartDay int32
|
|
|
+ EndDay int32
|
|
|
+ LimitType int32
|
|
|
+ SeasonId int32
|
|
|
+ BuyReward []*serverproto.KeyValueType
|
|
|
+ ActivityId int32
|
|
|
+}
|
|
|
+
|
|
|
+type MonthCard struct {
|
|
|
+ GoodsId int32
|
|
|
+ Price float32
|
|
|
+ Duration int32
|
|
|
+ Name string
|
|
|
+ MailCfgId int32
|
|
|
+ BuyReward []*serverproto.KeyValueType
|
|
|
+ MailReward []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+// 冲榜商店
|
|
|
+type RushShop struct {
|
|
|
+ GoodsId int32
|
|
|
+ Activity int32
|
|
|
+ Price float32
|
|
|
+ Name string
|
|
|
+ LimitCount int32
|
|
|
+ WorthRate int32
|
|
|
+ BuyReward []*serverproto.KeyValueType
|
|
|
+ Score int32
|
|
|
+ Ticket int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertFreeBag = map[int32]*GiftBag{}
|
|
|
+var ConvertGiftBag = map[int32]*GiftBag{}
|
|
|
+var ConvertLimitGag = map[int32]*LimitBag{}
|
|
|
+var ConvertMonthCard = map[int32]*MonthCard{}
|
|
|
+
|
|
|
+var ConvertGuildBattle = map[int32]*RushShop{}
|
|
|
+
|
|
|
+// 卢恩冲榜商店
|
|
|
+var ConvertTowerShop = map[int32]*RushShop{}
|
|
|
+var ConvertArenaShop = map[int32]*RushShop{}
|
|
|
+var ConvertMapShop = map[int32]*RushShop{}
|
|
|
+var ConvertPetShop = map[int32]*RushShop{}
|
|
|
+var ConvertSkillShop = map[int32]*RushShop{}
|
|
|
+var ConvertIdolShop = map[int32]*RushShop{}
|
|
|
+
|
|
|
+func ConvertOldRedisRuneCfg() {
|
|
|
+ convertRuneCfg()
|
|
|
+}
|
|
|
+func convertRuneCfg() {
|
|
|
+ for _, data := range serverproto.RuneShopGiftsCfgLoader {
|
|
|
+ convertGift := &GiftBag{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ BagType: data.Type,
|
|
|
+ Price: data.RMB,
|
|
|
+ Name: data.Name,
|
|
|
+ LimitCount: data.RestrictedType,
|
|
|
+ RmbTotalPay: data.RmbTotalPay,
|
|
|
+ }
|
|
|
+ for _, reward := range data.Reward {
|
|
|
+ strList := strings.Split(reward, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ convertGift.BuyReward = append(convertGift.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, first := range data.FirstBuyReward {
|
|
|
+ strList := strings.Split(first, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ convertGift.FirstReward = append(convertGift.FirstReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, extra := range data.ExtraBuyReward {
|
|
|
+ strList := strings.Split(extra, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ convertGift.ExtraReward = append(convertGift.ExtraReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertGiftBag[data.Id] = convertGift
|
|
|
+ if data.RMB == 0 {
|
|
|
+ ConvertFreeBag[data.Id] = convertGift
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.RuneShopLimitCfgLoader {
|
|
|
+ convertLimitBag := &LimitBag{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ Price: data.RMB,
|
|
|
+ Name: data.Name,
|
|
|
+ StartDay: data.SellingBegin,
|
|
|
+ EndDay: data.SellingDuration,
|
|
|
+ LimitCount: data.RestrictedType,
|
|
|
+ LimitType: data.SellingType,
|
|
|
+ SeasonId: data.SeasonId,
|
|
|
+ ActivityId: data.ActiveId,
|
|
|
+ }
|
|
|
+ for _, extra := range data.BuyReward {
|
|
|
+ strList := strings.Split(extra, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ convertLimitBag.BuyReward = append(convertLimitBag.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ loc := util.GetLoc()
|
|
|
+ if data.BeginTime != "" {
|
|
|
+ sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.BeginTime, loc)
|
|
|
+ if err1 != nil {
|
|
|
+ util.PanicF("convertRune startTime err:%v", err1)
|
|
|
+ }
|
|
|
+ convertLimitBag.BeginTime = int64(sTime.Unix() * 1000)
|
|
|
+ }
|
|
|
+ if data.EndTime != "" {
|
|
|
+ cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.EndTime, loc)
|
|
|
+ if err2 != nil {
|
|
|
+ util.PanicF("convertRune endTime err:%v", err2)
|
|
|
+ }
|
|
|
+ convertLimitBag.EndTime = int64(cTime.Unix() * 1000)
|
|
|
+ }
|
|
|
+ ConvertLimitGag[data.Id] = convertLimitBag
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.RuneShopMonthCardCfgLoader {
|
|
|
+ monthCard := &MonthCard{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ Name: data.Name,
|
|
|
+ Duration: data.AddTime,
|
|
|
+ Price: data.RMB,
|
|
|
+ MailCfgId: data.RewardMail,
|
|
|
+ }
|
|
|
+ for _, buyReward := range data.BuyRewardServer {
|
|
|
+ strList := strings.Split(buyReward, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ monthCard.BuyReward = append(monthCard.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, dayReward := range data.DayReward {
|
|
|
+ strList := strings.Split(dayReward, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ monthCard.MailReward = append(monthCard.MailReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertMonthCard[data.Id] = monthCard
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.RuneShopRankTowerCfgLoader {
|
|
|
+ towerShop := &RushShop{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ Name: data.Name,
|
|
|
+ Price: data.RMB,
|
|
|
+ Activity: data.RankId,
|
|
|
+ LimitCount: data.RestrictedType,
|
|
|
+ }
|
|
|
+ for _, items := range data.Reward {
|
|
|
+ strList := strings.Split(items, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ towerShop.BuyReward = append(towerShop.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertTowerShop[data.Id] = towerShop
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.RuneShopRankArenaCfgLoader {
|
|
|
+ arenaShop := &RushShop{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ Name: data.Name,
|
|
|
+ Price: data.RMB,
|
|
|
+ Activity: data.RankId,
|
|
|
+ LimitCount: data.RestrictedType,
|
|
|
+ }
|
|
|
+ for _, items := range data.Reward {
|
|
|
+ strList := strings.Split(items, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ arenaShop.BuyReward = append(arenaShop.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertArenaShop[data.Id] = arenaShop
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.RuneShopRankMapCfgLoader {
|
|
|
+ mapShop := &RushShop{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ Name: data.Name,
|
|
|
+ Price: data.RMB,
|
|
|
+ Activity: data.RankId,
|
|
|
+ LimitCount: data.RestrictedType,
|
|
|
+ Score: data.RewardScore,
|
|
|
+ }
|
|
|
+ for _, items := range data.SeverReward {
|
|
|
+ strList := strings.Split(items, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ mapShop.BuyReward = append(mapShop.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertMapShop[data.Id] = mapShop
|
|
|
+ }
|
|
|
+
|
|
|
+ //公会战商店
|
|
|
+ for _, data := range serverproto.RuneShopGuildBattleCfgLoader {
|
|
|
+ convertGift := &RushShop{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ Price: data.RMB,
|
|
|
+ Name: data.Name,
|
|
|
+ LimitCount: data.RestrictedType,
|
|
|
+ }
|
|
|
+ for _, reward := range data.Reward {
|
|
|
+ strList := strings.Split(reward, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ convertGift.BuyReward = append(convertGift.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertGuildBattle[data.Id] = convertGift
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.RuneShopRankPetCfgLoader {
|
|
|
+ mapShop := &RushShop{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ Name: data.Name,
|
|
|
+ Price: data.RMB,
|
|
|
+ Activity: data.RankId,
|
|
|
+ LimitCount: data.RestrictedType,
|
|
|
+ // Score: data.RewardScore,
|
|
|
+ }
|
|
|
+ for _, items := range data.Reward {
|
|
|
+ strList := strings.Split(items, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ mapShop.BuyReward = append(mapShop.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertPetShop[data.Id] = mapShop
|
|
|
+ }
|
|
|
+ for _, data := range serverproto.RuneShopRankSkillCfgLoader {
|
|
|
+ mapShop := &RushShop{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ Name: data.Name,
|
|
|
+ Price: data.RMB,
|
|
|
+ Activity: data.RankId,
|
|
|
+ LimitCount: data.RestrictedType,
|
|
|
+ // Score: data.RewardScore,
|
|
|
+ }
|
|
|
+ for _, items := range data.Reward {
|
|
|
+ strList := strings.Split(items, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ mapShop.BuyReward = append(mapShop.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertSkillShop[data.Id] = mapShop
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.RuneShopRankAidouluCfgLoader {
|
|
|
+ convertIdol := &RushShop{
|
|
|
+ GoodsId: data.Id,
|
|
|
+ Name: data.Name,
|
|
|
+ Price: data.RMB,
|
|
|
+ Activity: data.RankId,
|
|
|
+ LimitCount: data.RestrictedType,
|
|
|
+ Score: data.IfRequite,
|
|
|
+ Ticket: data.RewardScore,
|
|
|
+ }
|
|
|
+ for _, items := range data.SeverReward {
|
|
|
+ strList := strings.Split(items, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ convertIdol.BuyReward = append(convertIdol.BuyReward, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertIdolShop[data.Id] = convertIdol
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const (
|
|
|
+ Rush_Type_Tower = 1
|
|
|
+ Rush_Type_Arena = 2
|
|
|
+ Rush_Type_Map = 3
|
|
|
+ Rush_Type_Pet = 4
|
|
|
+ Rush_Type_Skill = 5
|
|
|
+)
|
|
|
+
|
|
|
+const (
|
|
|
+ Rush_Reward_Type_FightCount = 1 //战斗次数,或者地图等级
|
|
|
+ Rush_Reward_Type_Rank = 2 //排行版奖励
|
|
|
+)
|
|
|
+
|
|
|
+type RewardRank struct {
|
|
|
+ RankBegin int32
|
|
|
+ RankEnd int32
|
|
|
+ RankLevel int32 //所在档位
|
|
|
+ RewardList []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+type RankList struct {
|
|
|
+ RankRound int32
|
|
|
+ StartDay int32
|
|
|
+ StartTime string
|
|
|
+ CloseDay int32
|
|
|
+ CloseTime string
|
|
|
+ RestDay int32
|
|
|
+ RestTime string
|
|
|
+ Reward []*RewardRank
|
|
|
+}
|
|
|
+
|
|
|
+type RewardBase struct {
|
|
|
+ RewardBegin int32
|
|
|
+ RewardEnd int32
|
|
|
+ RewardLevel int32 //所在档位
|
|
|
+ // RewardList []*serverproto.KeyValueType
|
|
|
+ RewardList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+type RushBaseReward struct {
|
|
|
+ Reward []*RewardBase
|
|
|
+}
|
|
|
+type RankActivity struct {
|
|
|
+ RushActivity map[int32]*RankList
|
|
|
+ BaseReward map[int32]*RushBaseReward
|
|
|
+}
|
|
|
+
|
|
|
+var DaySec int32 = 24 * 60 * 60
|
|
|
+var ConvertRushList = map[int32]*RankActivity{}
|
|
|
+
|
|
|
+func convertRushListCfg() {
|
|
|
+ for _, data := range serverproto.RushListCfgLoader {
|
|
|
+ _, ok := ConvertRushList[data.RankType]
|
|
|
+ if !ok {
|
|
|
+ rankActivity := &RankActivity{
|
|
|
+ RushActivity: map[int32]*RankList{},
|
|
|
+ BaseReward: map[int32]*RushBaseReward{},
|
|
|
+ }
|
|
|
+ ConvertRushList[data.RankType] = rankActivity
|
|
|
+ }
|
|
|
+ _, ok2 := ConvertRushList[data.RankType].RushActivity[data.RankId]
|
|
|
+ if !ok2 {
|
|
|
+ rankList := &RankList{}
|
|
|
+ rankList.RankRound = data.RankId
|
|
|
+
|
|
|
+ rankList.StartDay = data.StartDay
|
|
|
+ rankList.StartTime = data.StartTime
|
|
|
+ rankList.CloseDay = data.CloseDay
|
|
|
+ rankList.CloseTime = data.CloseTime
|
|
|
+ rankList.RestDay = data.RestDay
|
|
|
+ rankList.RestTime = data.RestTime
|
|
|
+
|
|
|
+ ConvertRushList[data.RankType].RushActivity[data.RankId] = rankList
|
|
|
+ }
|
|
|
+
|
|
|
+ rush, ok3 := ConvertRushList[data.RankType].RushActivity[data.RankId]
|
|
|
+ if ok3 {
|
|
|
+ rewardRank := &RewardRank{
|
|
|
+ RankLevel: data.RankGrade,
|
|
|
+ }
|
|
|
+ if len(data.Rank) >= 1 {
|
|
|
+ strList := strings.Split(data.Rank[0], ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ begin, _ := Str2Num(strList[0])
|
|
|
+ end, _ := Str2Num(strList[1])
|
|
|
+ rewardRank.RankBegin = int32(begin)
|
|
|
+ rewardRank.RankEnd = int32(end)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, reward := range data.Reward {
|
|
|
+ strList := strings.Split(reward, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ rewardRank.RewardList = append(rewardRank.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ rush.Reward = append(rush.Reward, rewardRank)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.RushListTargetCfgLoader {
|
|
|
+ _, ok := ConvertRushList[data.RankType]
|
|
|
+ if !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //没有这个活动。也不能加载这个活动对应的奖励
|
|
|
+ _, ok2 := ConvertRushList[data.RankType].RushActivity[data.RankId]
|
|
|
+ if !ok2 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ _, ok3 := ConvertRushList[data.RankType].BaseReward[data.RankId]
|
|
|
+ if !ok3 {
|
|
|
+ rushBaseReward := &RushBaseReward{}
|
|
|
+ ConvertRushList[data.RankType].BaseReward[data.RankId] = rushBaseReward
|
|
|
+ }
|
|
|
+ rushReward, ok4 := ConvertRushList[data.RankType].BaseReward[data.RankId]
|
|
|
+ if ok4 {
|
|
|
+ rewardRank := &RewardBase{
|
|
|
+ RewardLevel: data.TargetGrade,
|
|
|
+ RewardList: make(map[int32]int32),
|
|
|
+ }
|
|
|
+ if len(data.Rank) >= 1 {
|
|
|
+ strList := strings.Split(data.Rank[0], ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ begin, _ := Str2Num(strList[0])
|
|
|
+ end, _ := Str2Num(strList[1])
|
|
|
+ rewardRank.RewardBegin = int32(begin)
|
|
|
+ rewardRank.RewardEnd = int32(end)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, reward := range data.Reward {
|
|
|
+ strList := strings.Split(reward, ":")
|
|
|
+ if len(strList) >= 2 {
|
|
|
+ key, _ := Str2Num(strList[0])
|
|
|
+ value, _ := Str2Num(strList[1])
|
|
|
+ rewardRank.RewardList[int32(key)] = int32(value)
|
|
|
+ /*
|
|
|
+ rewardRank.RewardList = append(rewardRank.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: int32(key),
|
|
|
+ Value: int32(value),
|
|
|
+ })
|
|
|
+ */
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rushReward.Reward = append(rushReward.Reward, rewardRank)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func GetRushActivityTimeStamp(deltaDay int32, deltaTime string) uint64 {
|
|
|
+ loc := util.GetLoc()
|
|
|
+ startUpTime := service.GetServiceStartupTime()
|
|
|
+ if startUpTime < 0 {
|
|
|
+ util.ErrorF("[convertRushListCfg] data error:%v")
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ startServer := time.Unix(int64(startUpTime/1000), 0).In(loc).Format(util.DATE_FORMAT1)
|
|
|
+ startUpDayStr := util.GetDayByTimeStr1(startServer)
|
|
|
+
|
|
|
+ rushBegin := util.GetTimeByStr(startUpDayStr.Format(util.DATE_FORMAT1) + " " + deltaTime)
|
|
|
+ rushStart := time.Unix(rushBegin.Unix()+int64(deltaDay-1)*int64(DaySec), 0).In(loc)
|
|
|
+
|
|
|
+ return uint64(rushStart.UnixNano() / 1e6)
|
|
|
+}
|
|
|
+
|
|
|
+func GetCurrentRushActivity(RankType int32, RushRound int32) *RankList {
|
|
|
+ rushList, ok := ConvertRushList[RankType]
|
|
|
+ if !ok {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ nowTime := util.GetCurrentTime()
|
|
|
+ for _, data := range rushList.RushActivity {
|
|
|
+ if RushRound != 0 {
|
|
|
+ if data.RankRound != RushRound {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rushBegin := GetRushActivityTimeStamp(data.StartDay, data.StartTime)
|
|
|
+ rewardEnd := GetRushActivityTimeStamp(data.RestDay, data.RestTime)
|
|
|
+ if rushBegin <= nowTime && nowTime <= rewardEnd {
|
|
|
+ return data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func GetNextRushActivity(RankType int32, RushRound int32) *RankList {
|
|
|
+ rushList, ok := ConvertRushList[RankType]
|
|
|
+ if !ok {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ nowTime := util.GetCurrentTime()
|
|
|
+ for i := RushRound; i <= int32(len(rushList.RushActivity)); i++ {
|
|
|
+ data, ok := rushList.RushActivity[i]
|
|
|
+ if !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if nowTime < GetRushActivityTimeStamp(data.StartDay, data.StartTime) {
|
|
|
+ return data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+func GetRushActivityByRound(RankType int32, RushRound int32) *RankList {
|
|
|
+ rushList, ok := ConvertRushList[RankType]
|
|
|
+ if !ok {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ for _, data := range rushList.RushActivity {
|
|
|
+ if data.RankRound != RushRound {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ return data
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func GetRushActivityBaseReward(RushRound int32, RankType int32, score int32, addItemList map[int32]int32) int32 {
|
|
|
+ rushList, ok := ConvertRushList[RankType]
|
|
|
+ if !ok {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ rewards, ok2 := rushList.BaseReward[RushRound]
|
|
|
+ if !ok2 {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ for _, data := range rewards.Reward {
|
|
|
+ if data.RewardEnd != 0 && data.RewardBegin <= score && score <= data.RewardEnd ||
|
|
|
+ data.RewardEnd == 0 && data.RewardBegin <= score {
|
|
|
+ for key, value := range data.RewardList {
|
|
|
+ addItemList[key] += value
|
|
|
+ }
|
|
|
+ return data.RewardLevel
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0
|
|
|
+}
|
|
|
+
|
|
|
+type LevelUpMaterial struct {
|
|
|
+ Materials map[int32]int32
|
|
|
+ AddAttr map[int32]int32
|
|
|
+ Level int32
|
|
|
+}
|
|
|
+
|
|
|
+type KeepSakeData struct {
|
|
|
+ KeepSakeId int32
|
|
|
+ LevelData map[int32]*LevelUpMaterial
|
|
|
+ LevelDataList []*LevelUpMaterial
|
|
|
+ Job []int32
|
|
|
+ KeepLevel int32
|
|
|
+ MaxLevel int32
|
|
|
+ AllMaterials map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertMaterialToKeepSake = map[int32]int32{}
|
|
|
+var ConvertKeepSake = map[int32]*KeepSakeData{}
|
|
|
+
|
|
|
+func convertKeepSakeCfg() {
|
|
|
+ for _, data := range serverproto.KeepSakeCfgLoader {
|
|
|
+ convert := &KeepSakeData{
|
|
|
+ KeepSakeId: data.Id,
|
|
|
+ KeepLevel: data.CollectionLevel,
|
|
|
+ }
|
|
|
+ convert.LevelData = make(map[int32]*LevelUpMaterial)
|
|
|
+ convert.AllMaterials = make(map[int32]int32)
|
|
|
+
|
|
|
+ for _, jobs := range data.Job {
|
|
|
+ jobId, _ := Str2Num(jobs)
|
|
|
+ convert.Job = append(convert.Job, int32(jobId))
|
|
|
+ }
|
|
|
+ //等級1
|
|
|
+ levelUpMaterial1 := &LevelUpMaterial{}
|
|
|
+ levelUpMaterial1.Materials = make(map[int32]int32)
|
|
|
+ levelUpMaterial1.AddAttr = make(map[int32]int32)
|
|
|
+ for _, material1 := range data.MaterialLevel1 {
|
|
|
+ material := strings.Split(material1, ":")
|
|
|
+ if len(material) >= 2 {
|
|
|
+ itemId, _ := Str2Num(material[0])
|
|
|
+ itemCount, _ := Str2Num(material[1])
|
|
|
+ levelUpMaterial1.Materials[int32(itemId)] = int32(itemCount)
|
|
|
+ ConvertMaterialToKeepSake[int32(itemId)] = data.Id
|
|
|
+ convert.MaxLevel = 1
|
|
|
+ convert.AllMaterials[int32(itemId)] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, attr1 := range data.AddAttrLevel1 {
|
|
|
+ addAttr := strings.Split(attr1, ":")
|
|
|
+ if len(addAttr) >= 2 {
|
|
|
+ attrKey, _ := Str2Num(addAttr[0])
|
|
|
+ attrValue, _ := Str2Num(addAttr[1])
|
|
|
+ levelUpMaterial1.AddAttr[int32(attrKey)] = int32(attrValue)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ levelUpMaterial1.Level = 1
|
|
|
+ convert.LevelData[1] = levelUpMaterial1
|
|
|
+ convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial1)
|
|
|
+
|
|
|
+ //等級2
|
|
|
+ levelUpMaterial2 := &LevelUpMaterial{}
|
|
|
+ levelUpMaterial2.Materials = make(map[int32]int32)
|
|
|
+ levelUpMaterial2.AddAttr = make(map[int32]int32)
|
|
|
+ for _, material2 := range data.MaterialLevel2 {
|
|
|
+ material := strings.Split(material2, ":")
|
|
|
+ if len(material) >= 2 {
|
|
|
+ itemId, _ := Str2Num(material[0])
|
|
|
+ itemCount, _ := Str2Num(material[1])
|
|
|
+ levelUpMaterial2.Materials[int32(itemId)] = int32(itemCount)
|
|
|
+ ConvertMaterialToKeepSake[int32(itemId)] = data.Id
|
|
|
+ convert.MaxLevel = 2
|
|
|
+ convert.AllMaterials[int32(itemId)] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, attr2 := range data.AddAttrLevel2 {
|
|
|
+ addAttr := strings.Split(attr2, ":")
|
|
|
+ if len(addAttr) >= 2 {
|
|
|
+ attrKey, _ := Str2Num(addAttr[0])
|
|
|
+ attrValue, _ := Str2Num(addAttr[1])
|
|
|
+ levelUpMaterial2.AddAttr[int32(attrKey)] = int32(attrValue)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ levelUpMaterial2.Level = 2
|
|
|
+ convert.LevelData[2] = levelUpMaterial2
|
|
|
+ convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial2)
|
|
|
+
|
|
|
+ levelUpMaterial3 := &LevelUpMaterial{}
|
|
|
+ levelUpMaterial3.Materials = make(map[int32]int32)
|
|
|
+ levelUpMaterial3.AddAttr = make(map[int32]int32)
|
|
|
+ for _, material3 := range data.MaterialLevel3 {
|
|
|
+ material := strings.Split(material3, ":")
|
|
|
+ if len(material) >= 2 {
|
|
|
+ itemId, _ := Str2Num(material[0])
|
|
|
+ itemCount, _ := Str2Num(material[1])
|
|
|
+ levelUpMaterial3.Materials[int32(itemId)] = int32(itemCount)
|
|
|
+ ConvertMaterialToKeepSake[int32(itemId)] = data.Id
|
|
|
+ convert.MaxLevel = 3
|
|
|
+ convert.AllMaterials[int32(itemId)] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, attr3 := range data.AddAttrLevel3 {
|
|
|
+ attr := strings.Split(attr3, ":")
|
|
|
+ if len(attr) >= 2 {
|
|
|
+ attrKey, _ := Str2Num(attr[0])
|
|
|
+ attrValue, _ := Str2Num(attr[1])
|
|
|
+ levelUpMaterial3.AddAttr[int32(attrKey)] = int32(attrValue)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ levelUpMaterial3.Level = 3
|
|
|
+ convert.LevelData[3] = levelUpMaterial3
|
|
|
+ convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial3)
|
|
|
+
|
|
|
+ levelUpMaterial4 := &LevelUpMaterial{}
|
|
|
+ levelUpMaterial4.Materials = make(map[int32]int32)
|
|
|
+ levelUpMaterial4.AddAttr = make(map[int32]int32)
|
|
|
+ for _, material4 := range data.MaterialLevel4 {
|
|
|
+ material := strings.Split(material4, ":")
|
|
|
+ if len(material) >= 2 {
|
|
|
+ itemId, _ := Str2Num(material[0])
|
|
|
+ itemCount, _ := Str2Num(material[1])
|
|
|
+ levelUpMaterial4.Materials[int32(itemId)] = int32(itemCount)
|
|
|
+ ConvertMaterialToKeepSake[int32(itemId)] = data.Id
|
|
|
+ convert.MaxLevel = 4
|
|
|
+ convert.AllMaterials[int32(itemId)] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, attr4 := range data.AddAttrLevel4 {
|
|
|
+ attr := strings.Split(attr4, ":")
|
|
|
+ if len(attr) >= 2 {
|
|
|
+ attrKey, _ := Str2Num(attr[0])
|
|
|
+ attrValue, _ := Str2Num(attr[1])
|
|
|
+ levelUpMaterial4.AddAttr[int32(attrKey)] = int32(attrValue)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ levelUpMaterial4.Level = 4
|
|
|
+ convert.LevelData[4] = levelUpMaterial4
|
|
|
+ convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial4)
|
|
|
+
|
|
|
+ levelUpMaterial5 := &LevelUpMaterial{}
|
|
|
+ levelUpMaterial5.Materials = make(map[int32]int32)
|
|
|
+ levelUpMaterial5.AddAttr = make(map[int32]int32)
|
|
|
+ for _, material5 := range data.MaterialLevel5 {
|
|
|
+ material := strings.Split(material5, ":")
|
|
|
+ if len(material) >= 2 {
|
|
|
+ itemId, _ := Str2Num(material[0])
|
|
|
+ itemCount, _ := Str2Num(material[1])
|
|
|
+ levelUpMaterial5.Materials[int32(itemId)] = int32(itemCount)
|
|
|
+ ConvertMaterialToKeepSake[int32(itemId)] = data.Id
|
|
|
+ convert.MaxLevel = 5
|
|
|
+ convert.AllMaterials[int32(itemId)] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, attr5 := range data.AddAttrLevel5 {
|
|
|
+ attr := strings.Split(attr5, ":")
|
|
|
+ if len(attr) >= 2 {
|
|
|
+ attrKey, _ := Str2Num(attr[0])
|
|
|
+ attrValue, _ := Str2Num(attr[1])
|
|
|
+ levelUpMaterial5.AddAttr[int32(attrKey)] = int32(attrValue)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ levelUpMaterial5.Level = 5
|
|
|
+ convert.LevelData[5] = levelUpMaterial5
|
|
|
+ convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial5)
|
|
|
+
|
|
|
+ ConvertKeepSake[data.Id] = convert
|
|
|
+ }
|
|
|
+ for _, val := range ConvertKeepSake {
|
|
|
+ sort.Slice(val.LevelDataList, func(i, j int) bool {
|
|
|
+ return val.LevelDataList[i].Level < val.LevelDataList[j].Level
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func GetMaxKeepSakeLevel(keepSakeId int32) int32 {
|
|
|
+ data, ok := ConvertKeepSake[keepSakeId]
|
|
|
+ if !ok {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ return data.MaxLevel
|
|
|
+}
|
|
|
+
|
|
|
+type SuitCondition struct {
|
|
|
+ cardType int32
|
|
|
+ cardLvl int32
|
|
|
+ cardCnt int32
|
|
|
+}
|
|
|
+
|
|
|
+func (this SuitCondition) GetKey() int32 {
|
|
|
+ return this.cardType
|
|
|
+}
|
|
|
+
|
|
|
+func (this SuitCondition) GetLvl() int32 {
|
|
|
+ return this.cardLvl
|
|
|
+}
|
|
|
+
|
|
|
+func (this SuitCondition) GetCnt() int32 {
|
|
|
+ return this.cardCnt
|
|
|
+}
|
|
|
+
|
|
|
+type CardSuitData struct {
|
|
|
+ id int32
|
|
|
+ suits []*serverproto.KeyValueType
|
|
|
+ suitTerm []*SuitCondition
|
|
|
+ SuitTotalCardNum map[int32]int32 //需要同种类型卡片的数量
|
|
|
+}
|
|
|
+
|
|
|
+func (this CardSuitData) GetConditions() []*SuitCondition {
|
|
|
+ return this.suitTerm
|
|
|
+}
|
|
|
+
|
|
|
+func (this CardSuitData) GetSuits() []*serverproto.KeyValueType {
|
|
|
+ return this.suits
|
|
|
+}
|
|
|
+
|
|
|
+func (this CardSuitData) Id() int32 {
|
|
|
+ return this.id
|
|
|
+}
|
|
|
+
|
|
|
+var DbCardSuitData = map[int32]*CardSuitData{}
|
|
|
+var ConvertCardSuit []*CardSuitData
|
|
|
+
|
|
|
+func convertCardSuitNewCfg() {
|
|
|
+ for _, v := range serverproto.CardSuitNewCfgLoader {
|
|
|
+ data := &CardSuitData{
|
|
|
+ SuitTotalCardNum: map[int32]int32{},
|
|
|
+ }
|
|
|
+ data.id = v.Id
|
|
|
+ for _, v1 := range v.Suit1 {
|
|
|
+ k, val := Str2Res(v1)
|
|
|
+ data.suits = append(data.suits, &serverproto.KeyValueType{Key: k, Value: val})
|
|
|
+ }
|
|
|
+ for _, v2 := range v.TriggerConditions {
|
|
|
+ t, l, c := Str2Res_3(v2)
|
|
|
+ data.SuitTotalCardNum[t] += c
|
|
|
+ data.suitTerm = append(data.suitTerm, &SuitCondition{t, l, c})
|
|
|
+ }
|
|
|
+ DbCardSuitData[v.Id] = data
|
|
|
+
|
|
|
+ ConvertCardSuit = append(ConvertCardSuit, data)
|
|
|
+ }
|
|
|
+ sort.Slice(ConvertCardSuit, func(i, j int) bool {
|
|
|
+ return ConvertCardSuit[i].id > ConvertCardSuit[j].id
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+type TmapMaterial map[int32]int32
|
|
|
+type StFashionUp struct {
|
|
|
+ level int32
|
|
|
+ quality int32 // 品质 1:绿色 2:蓝色 3:紫色 4:金色 5:红色
|
|
|
+ upAttr int32
|
|
|
+ material TmapMaterial
|
|
|
+}
|
|
|
+
|
|
|
+func (this StFashionUp) Material() TmapMaterial {
|
|
|
+ return this.material
|
|
|
+}
|
|
|
+
|
|
|
+func (this StFashionUp) UpAttr() int32 {
|
|
|
+ return this.upAttr
|
|
|
+}
|
|
|
+
|
|
|
+func CreateKey16Offset(left, right int32) int32 {
|
|
|
+ // 偏移16位作为 左值
|
|
|
+ return left<<16 | right
|
|
|
+}
|
|
|
+
|
|
|
+var DbFashionLevelUp = make(map[int32]*StFashionUp)
|
|
|
+
|
|
|
+func CreateData(dbDate []string) *StFashionUp {
|
|
|
+ data := &StFashionUp{material: make(TmapMaterial)}
|
|
|
+ for _, v1 := range dbDate {
|
|
|
+ id, cnt := Str2Res(v1)
|
|
|
+ data.material[id] = cnt
|
|
|
+ }
|
|
|
+ return data
|
|
|
+}
|
|
|
+
|
|
|
+func covertFashionLevelUpCfg() {
|
|
|
+ for _, v := range serverproto.FashionLevelUpLoader {
|
|
|
+ data1 := CreateData(v.UpMaterial1)
|
|
|
+ data1.level = v.Level
|
|
|
+ data1.quality = 1
|
|
|
+ data1.upAttr = v.UpAttribute
|
|
|
+ DbFashionLevelUp[CreateKey16Offset(data1.level, data1.quality)] = data1
|
|
|
+
|
|
|
+ data2 := CreateData(v.UpMaterial2)
|
|
|
+ data2.level = v.Level
|
|
|
+ data2.quality = 2
|
|
|
+ data2.upAttr = v.UpAttribute
|
|
|
+ DbFashionLevelUp[CreateKey16Offset(data2.level, data2.quality)] = data2
|
|
|
+
|
|
|
+ data3 := CreateData(v.UpMaterial3)
|
|
|
+ data3.level = v.Level
|
|
|
+ data3.quality = 3
|
|
|
+ data3.upAttr = v.UpAttribute
|
|
|
+ DbFashionLevelUp[CreateKey16Offset(data3.level, data3.quality)] = data3
|
|
|
+
|
|
|
+ data4 := CreateData(v.UpMaterial4)
|
|
|
+ data4.level = v.Level
|
|
|
+ data4.quality = 4
|
|
|
+ data4.upAttr = v.UpAttribute
|
|
|
+ DbFashionLevelUp[CreateKey16Offset(data4.level, data4.quality)] = data4
|
|
|
+
|
|
|
+ data5 := CreateData(v.UpMaterial5)
|
|
|
+ data5.level = v.Level
|
|
|
+ data5.quality = 5
|
|
|
+ data5.upAttr = v.UpAttribute
|
|
|
+ DbFashionLevelUp[CreateKey16Offset(data5.level, data5.quality)] = data5
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type StFashionRandom struct {
|
|
|
+ id int32
|
|
|
+ roleid int32
|
|
|
+ atrid []int32
|
|
|
+ //refreshCost map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+func (this StFashionRandom) GetAtrid() []int32 {
|
|
|
+ return this.atrid[:]
|
|
|
+}
|
|
|
+
|
|
|
+func (this StFashionRandom) GetRoleid() int32 {
|
|
|
+ return this.roleid
|
|
|
+}
|
|
|
+
|
|
|
+var DbFashionResetAttrCost = []map[int32]int32{}
|
|
|
+var DbFashionRandom = []*StFashionRandom{} // make(map[int32]*StFashionRandom)
|
|
|
+func convertFashionRandomCfg() {
|
|
|
+ for _, v := range serverproto.FashionRandomLoader {
|
|
|
+ //id, cnt := Str2Res(v.RefreshCost)
|
|
|
+ data := &StFashionRandom{v.ID, int32(v.RoleId), []int32{}}
|
|
|
+ for _, jobs := range v.AtrId {
|
|
|
+ attrId, _ := Str2Num(jobs)
|
|
|
+ data.atrid = append(data.atrid, int32(attrId))
|
|
|
+ }
|
|
|
+ DbFashionRandom = append(DbFashionRandom, data)
|
|
|
+ //DbFashionRandom[data.roleid] = &data
|
|
|
+ }
|
|
|
+ var globalDb = serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Fashion_Attr)]
|
|
|
+ if globalDb == nil {
|
|
|
+ panic("299 全局配置错误")
|
|
|
+ }
|
|
|
+ items := strings.Split(globalDb.SVal, ";")
|
|
|
+ for _, i2 := range items {
|
|
|
+ id, cnt := Str2Res(i2)
|
|
|
+ DbFashionResetAttrCost = append(DbFashionResetAttrCost, map[int32]int32{id: cnt})
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+type StSuitLvlAttr struct {
|
|
|
+ lvl int32
|
|
|
+ attr *serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+// 套装表
|
|
|
+type StFashionSuit struct {
|
|
|
+ suitId int32
|
|
|
+ fashionIds []int32
|
|
|
+ mapAttr map[int32][]*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+func (this StFashionSuit) Id() int32 {
|
|
|
+ return this.suitId
|
|
|
+}
|
|
|
+
|
|
|
+func (this StFashionSuit) GetIds() []int32 {
|
|
|
+ return this.fashionIds[:]
|
|
|
+}
|
|
|
+
|
|
|
+func (this StFashionSuit) GetMapAttr() map[int32][]*serverproto.KeyValueType {
|
|
|
+ return this.mapAttr
|
|
|
+}
|
|
|
+
|
|
|
+var DbFashionSuit = make(map[int32]*StFashionSuit)
|
|
|
+var DbFashionSuitID = make(map[int32][]*StFashionSuit)
|
|
|
+
|
|
|
+func converFashionSuitCfg() {
|
|
|
+ for _, v := range serverproto.FashionSuitCfgLoader {
|
|
|
+ data := &StFashionSuit{mapAttr: make(map[int32][]*serverproto.KeyValueType)}
|
|
|
+ if len(v.LevelCondition) != len(v.Attribute) {
|
|
|
+ panic("FashionSuitCfg 属性配置和等级配置不对应")
|
|
|
+ }
|
|
|
+ for i, val := range v.LevelCondition {
|
|
|
+ lvl, _ := strconv.Atoi(val)
|
|
|
+ resList := strings.Split(v.Attribute[i], ":")
|
|
|
+ for _, i3 := range resList {
|
|
|
+ values := strings.Split(i3, "-")
|
|
|
+ if len(values) < 2 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ id, _ := Str2Num(values[0])
|
|
|
+ attrVar, _ := Str2Num(values[1])
|
|
|
+ data.mapAttr[int32(lvl)] = append(data.mapAttr[int32(lvl)], &serverproto.KeyValueType{Key: int32(id), Value: int32(attrVar)})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, i2 := range v.FashionId {
|
|
|
+ value, _ := Str2Num(i2)
|
|
|
+ data.fashionIds = append(data.fashionIds, int32(value))
|
|
|
+ }
|
|
|
+ data.suitId = v.SuitId
|
|
|
+ DbFashionSuit[v.SuitId] = data
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range serverproto.FashionSuitCfgLoader {
|
|
|
+ data := &StFashionSuit{mapAttr: make(map[int32][]*serverproto.KeyValueType)}
|
|
|
+ if len(v.LevelCondition) != len(v.Attribute) {
|
|
|
+ panic("FashionSuitCfg 属性配置和等级配置不对应")
|
|
|
+ }
|
|
|
+ for i, val := range v.LevelCondition {
|
|
|
+ lvl, _ := strconv.Atoi(val)
|
|
|
+ resList := strings.Split(v.Attribute[i], ":")
|
|
|
+ for _, i3 := range resList {
|
|
|
+ values := strings.Split(i3, "-")
|
|
|
+ if len(values) < 2 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ id, _ := Str2Num(values[0])
|
|
|
+ attrVar, _ := Str2Num(values[1])
|
|
|
+ data.mapAttr[int32(lvl)] = append(data.mapAttr[int32(lvl)], &serverproto.KeyValueType{Key: int32(id), Value: int32(attrVar)})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, i2 := range v.FashionId {
|
|
|
+ value, _ := Str2Num(i2)
|
|
|
+ data.fashionIds = append(data.fashionIds, int32(value))
|
|
|
+ }
|
|
|
+ data.suitId = v.SuitId
|
|
|
+ DbFashionSuit[v.SuitId] = data
|
|
|
+
|
|
|
+ for _, id := range data.fashionIds {
|
|
|
+ DbFashionSuitID[id] = append(DbFashionSuitID[id], data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// //////////////////////////////////卢恩战令////////////////////
|
|
|
+type StRuneShopExplore struct {
|
|
|
+ round int32
|
|
|
+ goldExp int32
|
|
|
+ missionExp int32
|
|
|
+ missonExpUp int32
|
|
|
+ rmb float32
|
|
|
+ sellingBegin int32
|
|
|
+ startTime string
|
|
|
+ sellingDuration int32
|
|
|
+ closeTime string
|
|
|
+ maxlvrewads map[int32]int32
|
|
|
+ expCost int32
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) StartTime() string {
|
|
|
+ return this.startTime
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) CloseTime() string {
|
|
|
+ return this.closeTime
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) SellingBegin() int32 {
|
|
|
+ return this.sellingBegin
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) SellingDuration() int32 {
|
|
|
+ return this.sellingDuration
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) GetRound() int32 {
|
|
|
+ return this.round
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) GetRMB() float32 {
|
|
|
+ return this.rmb
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) GoldScale() int32 {
|
|
|
+ return this.goldExp
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) MissionScale() int32 {
|
|
|
+ return this.missionExp
|
|
|
+}
|
|
|
+
|
|
|
+type GuildWarReward struct {
|
|
|
+ Rank int32
|
|
|
+ MemberRewardList []*serverproto.KeyValueType
|
|
|
+ LeaderRewardList []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+type GuildMvpReward struct {
|
|
|
+ Rank int32
|
|
|
+ RewardList []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+type GuildBattleBuff struct {
|
|
|
+ BuffId int32
|
|
|
+ BuyData map[int32]*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var GuildBattleRankReward = map[int32]*GuildWarReward{}
|
|
|
+var GuildBattleScoreMvpReward = map[int32]*GuildMvpReward{}
|
|
|
+var GuildBattleKillMvpReward = map[int32]*GuildMvpReward{}
|
|
|
+
|
|
|
+var GuildBattleBuffList = map[int32]*GuildBattleBuff{}
|
|
|
+
|
|
|
+func convertGuildWarCfg() {
|
|
|
+ for _, data := range serverproto.GuildWarAgainstCfgLoader {
|
|
|
+ rankReward := &GuildWarReward{
|
|
|
+ Rank: data.Ranking,
|
|
|
+ }
|
|
|
+ for _, deacon := range data.DeaconReword {
|
|
|
+ items := strings.Split(deacon, ":")
|
|
|
+ if len(items) >= 2 {
|
|
|
+ itemId, _ := Str2Num(items[0])
|
|
|
+ itemCount, _ := Str2Num(items[1])
|
|
|
+
|
|
|
+ rankReward.LeaderRewardList = append(rankReward.LeaderRewardList, &serverproto.KeyValueType{
|
|
|
+ Key: int32(itemId),
|
|
|
+ Value: int32(itemCount),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, member := range data.GuildsmenReword {
|
|
|
+ items := strings.Split(member, ":")
|
|
|
+ if len(items) >= 2 {
|
|
|
+ itemId, _ := Str2Num(items[0])
|
|
|
+ itemCount, _ := Str2Num(items[1])
|
|
|
+
|
|
|
+ rankReward.MemberRewardList = append(rankReward.MemberRewardList, &serverproto.KeyValueType{
|
|
|
+ Key: int32(itemId),
|
|
|
+ Value: int32(itemCount),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GuildBattleRankReward[data.Ranking] = rankReward
|
|
|
+
|
|
|
+ scoreMvpReward := &GuildMvpReward{
|
|
|
+ Rank: data.PointMvp,
|
|
|
+ }
|
|
|
+ for _, score := range data.PointMvpReword {
|
|
|
+ items := strings.Split(score, ":")
|
|
|
+ if len(items) >= 2 {
|
|
|
+ itemId, _ := Str2Num(items[0])
|
|
|
+ itemCount, _ := Str2Num(items[1])
|
|
|
+
|
|
|
+ scoreMvpReward.RewardList = append(scoreMvpReward.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: int32(itemId),
|
|
|
+ Value: int32(itemCount),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GuildBattleScoreMvpReward[data.PointMvp] = scoreMvpReward
|
|
|
+
|
|
|
+ killerMvpReward := &GuildMvpReward{
|
|
|
+ Rank: data.PointMvp,
|
|
|
+ }
|
|
|
+ for _, killer := range data.KillerMvpReword {
|
|
|
+ items := strings.Split(killer, ":")
|
|
|
+ if len(items) >= 2 {
|
|
|
+ itemId, _ := Str2Num(items[0])
|
|
|
+ itemCount, _ := Str2Num(items[1])
|
|
|
+
|
|
|
+ killerMvpReward.RewardList = append(killerMvpReward.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: int32(itemId),
|
|
|
+ Value: int32(itemCount),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GuildBattleKillMvpReward[data.KillerMvp] = killerMvpReward
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.GuildWarBuffCfgLoader {
|
|
|
+ convertData := &GuildBattleBuff{
|
|
|
+ BuffId: data.Id,
|
|
|
+ BuyData: map[int32]*serverproto.KeyValueType{},
|
|
|
+ }
|
|
|
+ for idx, buffData := range data.Price {
|
|
|
+ resType, count := Str2Res(buffData)
|
|
|
+ convertData.BuyData[int32(idx+1)] = &serverproto.KeyValueType{
|
|
|
+ Key: resType,
|
|
|
+ Value: count,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GuildBattleBuffList[data.Id] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const (
|
|
|
+ GuildBattle_Reward_GuildMember = 1
|
|
|
+ GuildBattle_Reward_GuildLeader = 2
|
|
|
+ GuildBattle_Reward_ScoreMvp = 3
|
|
|
+ GuildBattle_Reward_KillerMvp = 4
|
|
|
+)
|
|
|
+
|
|
|
+func GetGuildBattleReward(rewardType int32, rank int32, rewardList []*serverproto.KeyValueType) {
|
|
|
+ if rewardType == GuildBattle_Reward_GuildMember ||
|
|
|
+ rewardType == GuildBattle_Reward_GuildLeader {
|
|
|
+ data, ok := GuildBattleRankReward[rank]
|
|
|
+ if !ok {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if rewardType == GuildBattle_Reward_GuildMember {
|
|
|
+ for _, items := range data.MemberRewardList {
|
|
|
+ rewardList = append(rewardList, items)
|
|
|
+ }
|
|
|
+ } else if rewardType == GuildBattle_Reward_GuildLeader {
|
|
|
+ for _, items := range data.LeaderRewardList {
|
|
|
+ rewardList = append(rewardList, items)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if rewardType == GuildBattle_Reward_ScoreMvp {
|
|
|
+ data, ok := GuildBattleScoreMvpReward[rank]
|
|
|
+ if !ok {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, items := range data.RewardList {
|
|
|
+ rewardList = append(rewardList, items)
|
|
|
+ }
|
|
|
+ } else if rewardType == GuildBattle_Reward_KillerMvp {
|
|
|
+ data, ok := GuildBattleKillMvpReward[rank]
|
|
|
+ if !ok {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, items := range data.RewardList {
|
|
|
+ rewardList = append(rewardList, items)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) MissionUp() int32 {
|
|
|
+ return this.missonExpUp
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) ExpCost() int32 {
|
|
|
+ return this.expCost
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExplore) MaxAward() map[int32]int32 {
|
|
|
+ return this.maxlvrewads
|
|
|
+}
|
|
|
+
|
|
|
+// var DbRuneShopExplore = make(map[int32]*StRuneShopExplore)
|
|
|
+var DbRuneShopExplore = []*StRuneShopExplore{}
|
|
|
+
|
|
|
+func GetRuneExploreDataByRound(round int32) *StRuneShopExplore {
|
|
|
+ for _, explore := range DbRuneShopExplore {
|
|
|
+ if explore.GetRound() != round {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ return explore
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func convertRuneShopExploreCfg() {
|
|
|
+ for _, v := range serverproto.RuneShopExploreCfgLoader {
|
|
|
+ data := &StRuneShopExplore{round: v.Round, rmb: v.RMB, sellingBegin: v.SellingBegin,
|
|
|
+ sellingDuration: v.SellingDuration, expCost: v.ExpCost, maxlvrewads: make(map[int32]int32),
|
|
|
+ startTime: v.StartTime, closeTime: v.CloseTime}
|
|
|
+ _, val1 := Str2Res(v.GoldExp)
|
|
|
+ data.goldExp = val1
|
|
|
+ _, val2 := Str2Res(v.MissionExp)
|
|
|
+ data.missionExp = val2
|
|
|
+ up, _ := Str2Num(v.MissonExpUp)
|
|
|
+ data.missonExpUp = data.missionExp * int32(up) / 100
|
|
|
+ for _, i2 := range v.MaxLvRewad {
|
|
|
+ id, cnt := Str2Res(i2)
|
|
|
+ data.maxlvrewads[id] = cnt
|
|
|
+ //data.maxlvrewads = append(data.maxlvrewads, &serverproto.KeyValueType{Key: id,Value: cnt})
|
|
|
+ }
|
|
|
+ DbRuneShopExplore = append(DbRuneShopExplore, data)
|
|
|
+ //DbRuneShopExplore[data.round] = data
|
|
|
+ }
|
|
|
+ sort.Slice(DbRuneShopExplore, func(i, j int) bool {
|
|
|
+ return DbRuneShopExplore[i].GetRound() < DbRuneShopExplore[j].GetRound()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+type StRuneShopExploreReward struct {
|
|
|
+ lv int32
|
|
|
+ round int32
|
|
|
+ exp int32
|
|
|
+ rewards map[int32]int32
|
|
|
+ cashRewards map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExploreReward) Exp() int32 {
|
|
|
+ return this.exp
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExploreReward) Lvl() int32 {
|
|
|
+ return this.lv
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExploreReward) GetAward() map[int32]int32 {
|
|
|
+ return this.rewards
|
|
|
+}
|
|
|
+
|
|
|
+func (this StRuneShopExploreReward) GetCashAward() map[int32]int32 {
|
|
|
+ return this.cashRewards
|
|
|
+}
|
|
|
+
|
|
|
+type StMaxData struct {
|
|
|
+ MaxLvl int32
|
|
|
+ MaxExp int32
|
|
|
+}
|
|
|
+
|
|
|
+var DbRuneShopExploreMax = make(map[int32]*StMaxData)
|
|
|
+var DbRuneShopExploreReward = make(map[int32]*StRuneShopExploreReward)
|
|
|
+
|
|
|
+func convertRuneShopExploreRewardCfg() {
|
|
|
+ for _, v := range serverproto.RuneShopExploreRewardCfgLoader {
|
|
|
+ data := &StRuneShopExploreReward{lv: v.Lv, round: v.ActiveRound, exp: v.Exp,
|
|
|
+ rewards: make(map[int32]int32), cashRewards: make(map[int32]int32)}
|
|
|
+ for _, i2 := range v.Reward {
|
|
|
+ id, cnt := Str2Res(i2)
|
|
|
+ data.rewards[id] = cnt
|
|
|
+ //data.rewards = append(data.rewards, &serverproto.KeyValueType{Key: id,Value: cnt})
|
|
|
+ }
|
|
|
+ for _, i3 := range v.CashReward {
|
|
|
+ id, cnt := Str2Res(i3)
|
|
|
+ data.cashRewards[id] = cnt
|
|
|
+ //data.cashRewards = append(data.cashRewards, &serverproto.KeyValueType{Key: id,Value: cnt})
|
|
|
+ }
|
|
|
+ DbRuneShopExploreReward[data.round<<16|data.lv] = data
|
|
|
+ max, ok := DbRuneShopExploreMax[data.round]
|
|
|
+ if !ok {
|
|
|
+ max = &StMaxData{}
|
|
|
+ }
|
|
|
+ max.MaxExp += v.Exp
|
|
|
+ if v.Lv > max.MaxLvl {
|
|
|
+ max.MaxLvl = v.Lv
|
|
|
+ }
|
|
|
+ DbRuneShopExploreMax[data.round] = max
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 在线累计时间奖励处理
|
|
|
+type OnlineRewardDayInfoST struct {
|
|
|
+ Day int32
|
|
|
+ Id int32
|
|
|
+ RewardToTalTime int32 //累计时间 s
|
|
|
+ RewardList []*serverproto.KeyValueType //奖励列表
|
|
|
+ RewardCostCoin int32 //直接获取奖励消耗金币
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertOnlineRewardList = map[int32][]*OnlineRewardDayInfoST{} //[Day,DayInfo]
|
|
|
+var ConvertOnlineRewardMaxDay int32 = 0
|
|
|
+
|
|
|
+func convertOnlineTimeRewardCfg() {
|
|
|
+ ConvertOnlineRewardList = map[int32][]*OnlineRewardDayInfoST{}
|
|
|
+ for _, cfgData := range serverproto.OnlineRewardsCfgLoader {
|
|
|
+ rewardInfo := &OnlineRewardDayInfoST{
|
|
|
+ Id: cfgData.Id,
|
|
|
+ Day: cfgData.Day,
|
|
|
+ RewardToTalTime: cfgData.Time,
|
|
|
+ RewardCostCoin: cfgData.SpeedUp,
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(cfgData.Rewards); idx++ {
|
|
|
+ k, v := Str2Res(cfgData.Rewards[idx])
|
|
|
+ if k <= 0 || v <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ rewardInfo.RewardList = append(rewardInfo.RewardList, &serverproto.KeyValueType{
|
|
|
+ Key: k,
|
|
|
+ Value: v,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ConvertOnlineRewardList[cfgData.Day] = append(ConvertOnlineRewardList[cfgData.Day], rewardInfo)
|
|
|
+ if ConvertOnlineRewardMaxDay < cfgData.Day {
|
|
|
+ ConvertOnlineRewardMaxDay = cfgData.Day
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //sort
|
|
|
+ for key := range ConvertOnlineRewardList {
|
|
|
+ sort.Slice(ConvertOnlineRewardList[key], func(i, j int) bool {
|
|
|
+ return ConvertOnlineRewardList[key][i].Id <
|
|
|
+ ConvertOnlineRewardList[key][j].Id
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type StQualityData struct {
|
|
|
+ ItemId int32
|
|
|
+ QualityPoint int32
|
|
|
+ MaxUse int32
|
|
|
+}
|
|
|
+
|
|
|
+var DBQualityFruit = map[int32]*StQualityData{}
|
|
|
+
|
|
|
+func convertQualityFruitCfg() {
|
|
|
+ gload, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Quality_Fruit_Item)]
|
|
|
+ if !ok {
|
|
|
+ panic("GlobalCfg quality Fruit error")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ lis := strings.Split(gload.SVal, ";")
|
|
|
+ for _, li := range lis {
|
|
|
+ id, value, maxCnt := Str2Res_3(li)
|
|
|
+ DBQualityFruit[id] = &StQualityData{id, value, maxCnt}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type StJobChangeData struct {
|
|
|
+ Id int32
|
|
|
+ JobType int32
|
|
|
+ JobStage int32 //职业阶数
|
|
|
+ BeforeJobId int32
|
|
|
+ JobBranch int32
|
|
|
+ AfterJobIds []int32 // 下一阶职业
|
|
|
+ ChangeCond []string // 转职条件
|
|
|
+ ItemCosts map[int32]int32
|
|
|
+ Skills []int32 // 默认装备技能
|
|
|
+ NewSkills []int32
|
|
|
+}
|
|
|
+
|
|
|
+func (this *StJobChangeData) HasNextJob(jobId int32) bool {
|
|
|
+ for _, v := range this.AfterJobIds {
|
|
|
+ if jobId != v {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+func (this *StJobChangeData) converRoleData(data *serverproto.JobCfg) *StJobChangeData {
|
|
|
+ this.ItemCosts = make(map[int32]int32)
|
|
|
+ this.Id = data.Id
|
|
|
+ this.JobType = data.JobType
|
|
|
+ this.JobStage = data.JobStage
|
|
|
+ //this.ChangeCond = data.ChangeCond
|
|
|
+ this.BeforeJobId = data.BeforeJobId
|
|
|
+ this.JobBranch = data.JobBranch
|
|
|
+ for _, v := range data.AfterJobId {
|
|
|
+ num, err := Str2Num(v)
|
|
|
+ if err != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ this.AfterJobIds = append(this.AfterJobIds, int32(num))
|
|
|
+ }
|
|
|
+ for _, v := range data.ItemCost {
|
|
|
+ id, cnt := Str2Res(v)
|
|
|
+ if id <= 0 || cnt <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ this.ItemCosts[id] = cnt //append(this.ItemCosts, &serverproto.KeyValueType{Key:id,Value: cnt})
|
|
|
+ }
|
|
|
+ for _, id := range data.SkillIds {
|
|
|
+ skillId, _ := Str2Num(id)
|
|
|
+ this.Skills = append(this.Skills, int32(skillId))
|
|
|
+ }
|
|
|
+ for _, s := range data.ChangeCond {
|
|
|
+ if len(s) <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ this.ChangeCond = append(this.ChangeCond, s)
|
|
|
+ }
|
|
|
+ return this
|
|
|
+}
|
|
|
+
|
|
|
+func (this *StJobChangeData) converParterData(data *serverproto.ParterCfg) *StJobChangeData {
|
|
|
+ this.ItemCosts = make(map[int32]int32)
|
|
|
+ this.Id = data.ParterId
|
|
|
+ this.JobType = data.JobType
|
|
|
+ this.JobStage = data.JobStage
|
|
|
+ //this.ChangeCond = data.ChangeCond
|
|
|
+ this.BeforeJobId = data.BeforeJobId
|
|
|
+ this.JobBranch = data.JobBranch
|
|
|
+ for _, v := range data.AfterJobId {
|
|
|
+ num, err := Str2Num(v)
|
|
|
+ if err != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ this.AfterJobIds = append(this.AfterJobIds, int32(num))
|
|
|
+ }
|
|
|
+ for _, v := range data.ItemCost {
|
|
|
+ id, cnt := Str2Res(v)
|
|
|
+ if id <= 0 || cnt <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ this.ItemCosts[id] = cnt //append(this.ItemCosts, &serverproto.KeyValueType{Key:id,Value: cnt})
|
|
|
+ }
|
|
|
+ for _, id := range data.SkillIds {
|
|
|
+ skillId, _ := Str2Res(id)
|
|
|
+ this.Skills = append(this.Skills, int32(skillId))
|
|
|
+ }
|
|
|
+ for _, s := range data.ChangeCond {
|
|
|
+ if len(s) <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ this.ChangeCond = append(this.ChangeCond, s)
|
|
|
+ }
|
|
|
+ return this
|
|
|
+}
|
|
|
+
|
|
|
+var DBJobChange = map[int32]*StJobChangeData{}
|
|
|
+
|
|
|
+// 生成职业表Id
|
|
|
+func GetJobChangeKey(isRoleMain bool, jobId int32) int32 {
|
|
|
+ key := jobId
|
|
|
+ // 伙伴职业Id与主角职业id相同, 伙伴Id增加10倍区分主角职业Id
|
|
|
+ if !isRoleMain {
|
|
|
+ key *= 10
|
|
|
+ }
|
|
|
+ return key
|
|
|
+}
|
|
|
+
|
|
|
+func convertJobChangeCfg() {
|
|
|
+ // 临时记录, key值对应技能表中数据,根据组合参数索引出技能Id,保存到DBJobChange结构中
|
|
|
+ var tmp = map[int32]*StJobChangeData{}
|
|
|
+ var tmpky = map[int32][]*serverproto.KeyValueType{}
|
|
|
+ // 生成技能表位移key值 偏移24位:是否主角数据, 偏移16位:职业类型 偏移8位:技能阶数 后八位:分支值
|
|
|
+ calcKey := func(jobtype, jobstate, JobBranch int32, roleMain bool) int32 {
|
|
|
+ first := int32(1) // 是否是主角表
|
|
|
+ if roleMain == true {
|
|
|
+ first = 0
|
|
|
+ }
|
|
|
+ return first<<24 | jobtype<<16 | jobstate<<8 | JobBranch
|
|
|
+ }
|
|
|
+ //----------------------------------------------------------------------
|
|
|
+ for i, cfg := range serverproto.JobCfgLoader {
|
|
|
+ db := new(StJobChangeData).converRoleData(cfg)
|
|
|
+ DBJobChange[GetJobChangeKey(true, i)] = db
|
|
|
+ tmp[calcKey(db.JobType, db.JobStage, db.JobBranch, true)] = db
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, cfg := range serverproto.ParterCfgLoader {
|
|
|
+ db := new(StJobChangeData).converParterData(cfg)
|
|
|
+ DBJobChange[GetJobChangeKey(false, i)] = db
|
|
|
+ tmp[calcKey(db.JobType, db.JobStage, db.JobBranch, false)] = db
|
|
|
+ }
|
|
|
+ // 从主角技能表解析出 对应的职业
|
|
|
+ for _, skilldb := range serverproto.SkillTreeCfgLoader {
|
|
|
+ key := calcKey(skilldb.JobType, skilldb.JobStage, skilldb.JobBranch, true) // 位移生成 key值
|
|
|
+ if _, ok := tmp[key]; ok {
|
|
|
+ tmpky[key] = append(tmpky[key], &serverproto.KeyValueType{Key: skilldb.SkillId, Value: skilldb.OpenLevel})
|
|
|
+ sort.Slice(tmpky[key], func(i, j int) bool { return tmpky[key][i].Value < tmpky[key][j].Value })
|
|
|
+ } else {
|
|
|
+ panic("技能解析出错")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 从伙伴技能表解析出 对应的职业
|
|
|
+ for _, skilldb := range serverproto.ParterSkillTreeCfgLoader {
|
|
|
+ key := calcKey(skilldb.JobType, skilldb.JobStage, skilldb.JobBranch, false)
|
|
|
+ if _, ok := tmp[key]; ok {
|
|
|
+ tmpky[key] = append(tmpky[key], &serverproto.KeyValueType{Key: skilldb.SkillId, Value: skilldb.OpenLevel})
|
|
|
+ sort.Slice(tmpky[key], func(i, j int) bool { return tmpky[key][i].Value < tmpky[key][j].Value })
|
|
|
+ } else {
|
|
|
+ panic("伙伴技能解析出错")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 根据等级排序写入对应职业
|
|
|
+ for i, types := range tmpky {
|
|
|
+ data, _ := tmp[i]
|
|
|
+ for _, valueType := range types {
|
|
|
+ data.NewSkills = append(data.NewSkills, valueType.Key)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type ConvertSysRewardData struct {
|
|
|
+ TowerLevel int32
|
|
|
+ RewardList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertSysRewardList []*ConvertSysRewardData
|
|
|
+
|
|
|
+func convertSysRewardCfg() {
|
|
|
+ for key, val := range serverproto.SysRewardLoader {
|
|
|
+ convertData := &ConvertSysRewardData{
|
|
|
+ TowerLevel: key,
|
|
|
+ RewardList: map[int32]int32{},
|
|
|
+ }
|
|
|
+ for idx := 0; idx < len(val.Reward); idx++ {
|
|
|
+ rewardId, _ := Str2Num(val.Reward[idx])
|
|
|
+ if rewardId > 0 {
|
|
|
+ convertData.RewardList[int32(rewardId)]++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ConvertSysRewardList = append(ConvertSysRewardList, convertData)
|
|
|
+ }
|
|
|
+ sort.Slice(ConvertSysRewardList, func(i, j int) bool {
|
|
|
+ return ConvertSysRewardList[i].TowerLevel < ConvertSysRewardList[j].TowerLevel
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 占星
|
|
|
+type ConvertDevine struct {
|
|
|
+ StarCount int32
|
|
|
+ NormalRate int32
|
|
|
+ SpecialRate int32
|
|
|
+ ItemCost map[int32]int32
|
|
|
+ GoldCost map[int32]int32
|
|
|
+ RewardList map[int32]int32
|
|
|
+ LuckyTicket int32
|
|
|
+ TicketCount int32
|
|
|
+ ScoreId int32
|
|
|
+ ScorePoint int32
|
|
|
+ BroadCast int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertCompetitionDevine = map[int32]*ConvertDevine{}
|
|
|
+
|
|
|
+func convertCompetitionDevineCfg() {
|
|
|
+ for _, data := range serverproto.CompetitionDevineCfgLoader {
|
|
|
+ convertData := &ConvertDevine{
|
|
|
+ StarCount: data.NowLightNum,
|
|
|
+ NormalRate: data.Probability,
|
|
|
+ SpecialRate: data.PledgeProbability,
|
|
|
+ }
|
|
|
+ convertData.ItemCost = make(map[int32]int32)
|
|
|
+ convertData.GoldCost = make(map[int32]int32)
|
|
|
+ convertData.RewardList = make(map[int32]int32)
|
|
|
+
|
|
|
+ for _, item := range data.ItemPrice {
|
|
|
+ itemId, itemNum := Str2Res(item)
|
|
|
+ if itemId != 0 && itemNum != 0 {
|
|
|
+ convertData.ItemCost[itemId] += itemNum
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, item := range data.GoldPrice {
|
|
|
+ itemId, itemNum := Str2Res(item)
|
|
|
+ if itemId != 0 && itemNum != 0 {
|
|
|
+ convertData.GoldCost[itemId] += itemNum
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, item := range data.Rewards {
|
|
|
+ itemId, itemNum := Str2Res(item)
|
|
|
+ if itemId != 0 && itemNum != 0 {
|
|
|
+ convertData.RewardList[itemId] += itemNum
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(data.LuckyPrice) > 0 {
|
|
|
+ luckId, luckyNum := Str2Res(data.LuckyPrice[0])
|
|
|
+ convertData.LuckyTicket = luckId
|
|
|
+ convertData.TicketCount = luckyNum
|
|
|
+ }
|
|
|
+ if len(data.Point) > 0 {
|
|
|
+ scoreId, scoreNum := Str2Res(data.Point[0])
|
|
|
+ convertData.ScoreId = scoreId
|
|
|
+ convertData.ScorePoint = scoreNum
|
|
|
+ }
|
|
|
+ convertData.BroadCast = data.IfBroadcast
|
|
|
+ ConvertCompetitionDevine[data.NowLightNum] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertYuanHangTrail = map[int32]*ConvertYuanHangTrialData{}
|
|
|
+var ConvertYuanHangMaxShipLevel int32 = 0
|
|
|
+
|
|
|
+type ConvertYuanHangTrialData struct {
|
|
|
+ ShipLevel int32 //type id
|
|
|
+ Duration int32 //s
|
|
|
+ ConsumeSpecialItemList map[int32]int32 //特殊道具消耗
|
|
|
+ ConsumeNormalList map[int32]int32 //普通金币消耗
|
|
|
+ ShipRefreshSuccessRate int //100 rate
|
|
|
+ ShipRefreshTopLevelCost []*serverproto.KeyValueType //直接升级到顶级消耗(根据列表优先级消耗)
|
|
|
+ ShipRewardList map[int32]int32
|
|
|
+ BeAttackNum int32 //被攻击丢失奖励次数
|
|
|
+ BeAttackScore int32
|
|
|
+ BeAttackRewardList map[int32]int32
|
|
|
+ BeAttackRewardListSlice []*serverproto.KeyValueType
|
|
|
+ BeAttackLoseItemList map[int32]int32 //被打劫损失奖励
|
|
|
+ BeAttackLoseItemListSlice []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ConvertYuanHangTrialData) RefreshShip(force bool) (int32, serverproto.ErrorCode) {
|
|
|
+ if force {
|
|
|
+ return ConvertYuanHangMaxShipLevel, serverproto.ErrorCode_ERROR_OK
|
|
|
+ }
|
|
|
+ if this.ShipRefreshSuccessRate <= 0 {
|
|
|
+ return this.ShipLevel, serverproto.ErrorCode_ERROR_CROSS_YUANHANGTRIAL_TOP_SHIPLEVEL
|
|
|
+ }
|
|
|
+
|
|
|
+ randNum := rand.Intn(100) + 1
|
|
|
+ if randNum <= this.ShipRefreshSuccessRate {
|
|
|
+ return this.ShipLevel + 1, serverproto.ErrorCode_ERROR_OK
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.ShipLevel, serverproto.ErrorCode_ERROR_CROSS_YUANHANGTRIAL_REFRESH_FAILED
|
|
|
+}
|
|
|
+
|
|
|
+func convertYuanHangTrailCfg() {
|
|
|
+ for _, data := range serverproto.TransportCfgLoader {
|
|
|
+ trailItem := &ConvertYuanHangTrialData{
|
|
|
+ ShipLevel: data.ShipLevel,
|
|
|
+ Duration: data.Duration * 60,
|
|
|
+ ShipRefreshSuccessRate: int(data.Probability),
|
|
|
+ BeAttackNum: data.RobberyTimes,
|
|
|
+ BeAttackScore: data.RobberyFraction,
|
|
|
+
|
|
|
+ ConsumeSpecialItemList: map[int32]int32{},
|
|
|
+ ConsumeNormalList: map[int32]int32{},
|
|
|
+ ShipRewardList: map[int32]int32{},
|
|
|
+ BeAttackRewardList: map[int32]int32{},
|
|
|
+ BeAttackLoseItemList: map[int32]int32{},
|
|
|
+ }
|
|
|
+ if len(data.Consume) >= 1 {
|
|
|
+ k, v := Str2Res(data.Consume[0])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ trailItem.ConsumeSpecialItemList[k] += v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(data.Consume) >= 2 {
|
|
|
+ k, v := Str2Res(data.Consume[1])
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ trailItem.ConsumeNormalList[k] += v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ trailItem.ShipRefreshTopLevelCost = Str2ResSliceList(data.TopLevel)
|
|
|
+ Str2ResMapList(data.TranspoertReward, trailItem.ShipRewardList)
|
|
|
+ Str2ResMapList(data.RobberyReward, trailItem.BeAttackRewardList)
|
|
|
+ for _, str := range data.RobberyReward {
|
|
|
+ k, v := Str2Res(str)
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ trailItem.BeAttackRewardListSlice = append(trailItem.BeAttackRewardListSlice,
|
|
|
+ &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Str2ResMapList(data.RobberyLose, trailItem.BeAttackLoseItemList)
|
|
|
+ for _, str := range data.RobberyLose {
|
|
|
+ k, v := Str2Res(str)
|
|
|
+ if k > 0 && v > 0 {
|
|
|
+ trailItem.BeAttackLoseItemListSlice = append(trailItem.BeAttackLoseItemListSlice,
|
|
|
+ &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertYuanHangTrail[trailItem.ShipLevel] = trailItem
|
|
|
+
|
|
|
+ if data.ShipLevel > ConvertYuanHangMaxShipLevel {
|
|
|
+ ConvertYuanHangMaxShipLevel = data.ShipLevel
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type StDbKingTaskData struct {
|
|
|
+ TaskIds []int32 `csv:"TaskIds"` //成长任务
|
|
|
+ DailyTaskIds []int32 `csv:"DailyTaskIds"` //今日挑战
|
|
|
+ ActivitiesId int32 `csv:"ActivitiesId"` //活动Id
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertKingTask = map[int32]map[int32]*StDbKingTaskData{}
|
|
|
+
|
|
|
+func GetKingTaskData(AvtivitiesId, day int32) *StDbKingTaskData {
|
|
|
+ avt, ok := ConvertKingTask[AvtivitiesId]
|
|
|
+ if !ok {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ data, ok := avt[day]
|
|
|
+ if !ok {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return data
|
|
|
+}
|
|
|
+func convertActivitiesKingTaskCfg() {
|
|
|
+ for _, data := range serverproto.ActivitiesKingTaskCfgLoader {
|
|
|
+ taskItem := &StDbKingTaskData{ActivitiesId: data.ActivitiesId}
|
|
|
+ for _, id := range data.TaskIds {
|
|
|
+ taskId, err := Str2Num(id)
|
|
|
+ if err != nil {
|
|
|
+ panic("convertActivitiesKingTask TaskIds err")
|
|
|
+ }
|
|
|
+ taskItem.TaskIds = append(taskItem.TaskIds, int32(taskId))
|
|
|
+ }
|
|
|
+ for _, id := range data.DailyTaskIds {
|
|
|
+ taskId, err := Str2Num(id)
|
|
|
+ if err != nil {
|
|
|
+ panic("convertActivitiesKingTask DailyTaskIds err")
|
|
|
+ }
|
|
|
+ taskItem.DailyTaskIds = append(taskItem.DailyTaskIds, int32(taskId))
|
|
|
+ }
|
|
|
+ maptmp, ok := ConvertKingTask[data.ActivitiesId]
|
|
|
+ if !ok {
|
|
|
+ maptmp = make(map[int32]*StDbKingTaskData)
|
|
|
+ ConvertKingTask[data.ActivitiesId] = maptmp
|
|
|
+ }
|
|
|
+ maptmp[data.Day] = taskItem
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type MatchSection struct {
|
|
|
+ LevelRank int32
|
|
|
+ LeftSection int32
|
|
|
+ RightSection int32
|
|
|
+}
|
|
|
+
|
|
|
+func (this *MatchSection) InSection(val int32) bool {
|
|
|
+ if this.LeftSection <= val &&
|
|
|
+ this.RightSection >= val {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+type TopTowerData struct {
|
|
|
+ SelfRankSection *MatchSection
|
|
|
+ MatchSection []*MatchSection
|
|
|
+}
|
|
|
+type TopTowerRewardData struct {
|
|
|
+ ForceWinCostList map[int32]int32
|
|
|
+ Idx int32
|
|
|
+ WinRewardList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertTopTowerDataList []*TopTowerData
|
|
|
+var ConvertTopTowerRewardList []*TopTowerRewardData
|
|
|
+
|
|
|
+func convertTopTowerCfg() {
|
|
|
+ for _, data := range serverproto.TopTowerCfgLevelLoader {
|
|
|
+ rankInfo := &TopTowerData{}
|
|
|
+ rankInfo.SelfRankSection = convertTopTowerSectionCfg(data.RankId, 0)
|
|
|
+
|
|
|
+ rankInfo.MatchSection = append(rankInfo.MatchSection,
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank1, 1),
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank2, 2),
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank3, 3),
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank4, 4),
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank5, 5),
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank6, 6),
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank7, 7),
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank8, 8),
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank9, 9),
|
|
|
+ convertTopTowerSectionCfg(data.LevelRank10, 10))
|
|
|
+
|
|
|
+ ConvertTopTowerDataList = append(ConvertTopTowerDataList, rankInfo)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, data := range serverproto.TopTowerCfgRewardLoader {
|
|
|
+ rewardData := &TopTowerRewardData{
|
|
|
+ Idx: data.LevelId,
|
|
|
+ ForceWinCostList: map[int32]int32{},
|
|
|
+ WinRewardList: map[int32]int32{},
|
|
|
+ }
|
|
|
+ Str2ResMapList(data.BuyRoadCost, rewardData.ForceWinCostList)
|
|
|
+ Str2ResMapList(data.RewardItems, rewardData.WinRewardList)
|
|
|
+ ConvertTopTowerRewardList = append(ConvertTopTowerRewardList, rewardData)
|
|
|
+ }
|
|
|
+}
|
|
|
+func convertTopTowerSectionCfg(sectionStr []string, idx int32) *MatchSection {
|
|
|
+ tmpMatchSection := &MatchSection{}
|
|
|
+ v1, _ := Str2Num(sectionStr[0])
|
|
|
+ v2, _ := Str2Num(sectionStr[1])
|
|
|
+ tmpMatchSection.LeftSection = int32(v1)
|
|
|
+ tmpMatchSection.RightSection = int32(v2)
|
|
|
+ tmpMatchSection.LevelRank = idx
|
|
|
+ return tmpMatchSection
|
|
|
+}
|
|
|
+
|
|
|
+type StDbHeadData struct {
|
|
|
+ HeadId int32
|
|
|
+ HeadType int32
|
|
|
+ ContinueTime int32 // 时长 (小时)
|
|
|
+ BRestTask bool // 每日重置任务
|
|
|
+ Attr []*serverproto.KeyValueType
|
|
|
+ Condition map[int32][]int32 // 任务条件
|
|
|
+ ActivateItem map[int32]int32 // 激活消耗
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+var DbHeadData = map[int32]*StDbHeadData{}
|
|
|
+
|
|
|
+func convertHeadDataCfg() {
|
|
|
+ for _, cfg := range serverproto.DesignationCfgLoader {
|
|
|
+ taskItem := &StDbHeadData{HeadId: cfg.ID, HeadType: cfg.Type, Condition: map[int32][]int32{}, ActivateItem: map[int32]int32{}, ContinueTime: cfg.Time}
|
|
|
+ if cfg.RefreshDaily > 0 {
|
|
|
+ taskItem.BRestTask = true
|
|
|
+ } else {
|
|
|
+ taskItem.BRestTask = false
|
|
|
+ }
|
|
|
+ for _, s := range cfg.Attribute {
|
|
|
+ k, v := Str2Res(s)
|
|
|
+ taskItem.Attr = append(taskItem.Attr, &serverproto.KeyValueType{Key: k, Value: v})
|
|
|
+ }
|
|
|
+ for _, v := range cfg.TaskCondition {
|
|
|
+ valueList := strings.Split(v, ":")
|
|
|
+ if len(valueList) >= 2 {
|
|
|
+ taskType, _ := Str2Num(valueList[0])
|
|
|
+ taskItem.Condition[int32(taskType)] = append(taskItem.Condition[int32(taskType)], int32(taskType))
|
|
|
+ for i := 1; i < len(valueList); i++ {
|
|
|
+ taskValue, _ := Str2Num(valueList[i])
|
|
|
+ taskItem.Condition[int32(taskType)] = append(taskItem.Condition[int32(taskType)], int32(taskValue))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, s := range cfg.TaskConditionItem {
|
|
|
+ if len(s) <= 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ k, v := Str2Res(s)
|
|
|
+ taskItem.ActivateItem[k] = v
|
|
|
+ }
|
|
|
+ DbHeadData[taskItem.HeadId] = taskItem
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type DemonRewardData struct {
|
|
|
+ Level int32
|
|
|
+ StageMax uint64
|
|
|
+ StageMin uint64
|
|
|
+ Reward []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+type GuildDemonData struct {
|
|
|
+ ConfigId int32
|
|
|
+ DemonId int32
|
|
|
+ DemonLevel int32
|
|
|
+ StartDay int32
|
|
|
+ EndDay int32
|
|
|
+ WeekDay int32
|
|
|
+ ChallengeCount int32 //免费战斗次数
|
|
|
+ BuyChallengeCount int32 //最大购买次数
|
|
|
+ ChallengePrice map[int32]*serverproto.KeyValueType
|
|
|
+ StartTime string
|
|
|
+ RewardStage []*DemonRewardData
|
|
|
+ BaseReward map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+type GuildWeekDemonData struct {
|
|
|
+ DemonData []*GuildDemonData
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertGuildDemon = map[int32]*GuildWeekDemonData{}
|
|
|
+
|
|
|
+func convertGuildDemonCfg() {
|
|
|
+ for _, data := range serverproto.GuildDemonCfgLoader {
|
|
|
+ if data.Id == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ _, ok := ConvertGuildDemon[data.WeekDay]
|
|
|
+ if !ok {
|
|
|
+ ConvertGuildDemon[data.WeekDay] = &GuildWeekDemonData{}
|
|
|
+ }
|
|
|
+
|
|
|
+ convertData := &GuildDemonData{
|
|
|
+ ConfigId: data.Id,
|
|
|
+ DemonId: data.Id,
|
|
|
+ WeekDay: data.WeekDay,
|
|
|
+ ChallengeCount: data.FreeChallenge,
|
|
|
+ BuyChallengeCount: data.ChallengeTimes,
|
|
|
+ StartTime: data.SummonTime,
|
|
|
+ DemonLevel: data.BossLevel,
|
|
|
+ BaseReward: map[int32]int32{},
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(data.BossLvCycle) >= 1 {
|
|
|
+ start, end := Str2Res(data.BossLvCycle[0])
|
|
|
+ convertData.StartDay = int32(start)
|
|
|
+ convertData.EndDay = int32(end)
|
|
|
+ }
|
|
|
+
|
|
|
+ damageList := strings.Split(data.DamageSegment, ";")
|
|
|
+ if len(damageList) != len(data.DamageReward)+1 {
|
|
|
+ util.InfoF("convertGuildDemonCfg boss config reward bossId:%v error: %v %v", data.Id, len(damageList), len(data.DamageReward))
|
|
|
+ panic("convertGuildDemonCfg boss config reward error")
|
|
|
+ }
|
|
|
+
|
|
|
+ for i := 0; i < len(data.DamageReward); i++ {
|
|
|
+ convertReward := &DemonRewardData{}
|
|
|
+
|
|
|
+ damage := strings.Split(damageList[i+1], ":")
|
|
|
+ if len(damage) >= 2 {
|
|
|
+ level, _ := Str2Num(damage[0])
|
|
|
+ minDamage, _ := Str2NumU64(damage[1])
|
|
|
+ maxDamage, _ := Str2NumU64(damage[2])
|
|
|
+ convertReward.StageMax = maxDamage
|
|
|
+ convertReward.StageMin = minDamage
|
|
|
+ convertReward.Level = int32(level)
|
|
|
+ }
|
|
|
+
|
|
|
+ //todo 解析伤害区间
|
|
|
+ //解析奖励
|
|
|
+ reward := strings.Split(data.DamageReward[i], ":")
|
|
|
+ if len(reward) >= 2 {
|
|
|
+ itemId, itemNum := Str2Res(data.DamageReward[i])
|
|
|
+ convertReward.Reward = append(convertReward.Reward, &serverproto.KeyValueType{
|
|
|
+ Key: itemId,
|
|
|
+ Value: itemNum,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ convertData.RewardStage = append(convertData.RewardStage, convertReward)
|
|
|
+ }
|
|
|
+ convertData.ChallengePrice = make(map[int32]*serverproto.KeyValueType)
|
|
|
+
|
|
|
+ for _, baseReward := range data.ChallengeReward {
|
|
|
+ itemId, itemNum := Str2Res(baseReward)
|
|
|
+ convertData.BaseReward[itemId] += itemNum
|
|
|
+ }
|
|
|
+
|
|
|
+ startIndex := int32(1)
|
|
|
+ for _, priceData := range data.ChallengePrice {
|
|
|
+ itemId, itemNum := Str2Res(priceData)
|
|
|
+ convertData.ChallengePrice[startIndex] = &serverproto.KeyValueType{
|
|
|
+ Key: itemId,
|
|
|
+ Value: itemNum,
|
|
|
+ }
|
|
|
+ startIndex++
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertGuildDemon[data.WeekDay].DemonData = append(ConvertGuildDemon[data.WeekDay].DemonData, convertData)
|
|
|
+ //util.InfoF("[GetDemonInfo] get guildDemon config [%v] data:%v", int32(data.Id), convertData)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func GetDemonDataByConfigId(configId int32) *GuildDemonData {
|
|
|
+ for _, weekDemon := range ConvertGuildDemon {
|
|
|
+ for _, demon := range weekDemon.DemonData {
|
|
|
+ if configId == demon.DemonId {
|
|
|
+ return demon
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// (int32, int32):(bossId, bossLevel)
|
|
|
+func GetDemonInfo(weekDay int32, curTime time.Time) (*GuildDemonData, int32) {
|
|
|
+ curWeekDay := weekDay
|
|
|
+ // curTime := util.GetCurrentTimeNow()
|
|
|
+ if curTime.Hour() <= 4 {
|
|
|
+ curWeekDay--
|
|
|
+ if curWeekDay == 0 {
|
|
|
+ curWeekDay = 7
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ startUpTime := service.GetServiceStartupTime()
|
|
|
+ curServerDay := util.GetDurationDay2(startUpTime, uint64(util.GetTimeMilliseconds()))
|
|
|
+
|
|
|
+ guildDemon, ok := ConvertGuildDemon[int32(curWeekDay)]
|
|
|
+ if !ok {
|
|
|
+ util.InfoF("[GetDemonInfo] get guildDemon config [%v] ", int32(curWeekDay))
|
|
|
+ return nil, 0
|
|
|
+ }
|
|
|
+ demonData := &GuildDemonData{}
|
|
|
+ maxStartDay := int32(0)
|
|
|
+ for _, data := range guildDemon.DemonData {
|
|
|
+ if data.StartDay <= curServerDay && curServerDay <= data.EndDay {
|
|
|
+ return data, curServerDay
|
|
|
+ }
|
|
|
+ if maxStartDay <= data.StartDay {
|
|
|
+ maxStartDay = data.StartDay
|
|
|
+ demonData = data
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return demonData, curServerDay
|
|
|
+}
|
|
|
+
|
|
|
+// nextRefreshTime下次刷新的时间戳,取前一天的相关数据
|
|
|
+func GetDemonInfoByTimeStamp(nextRefreshTime uint64) *GuildDemonData {
|
|
|
+ nowTime := util.GetTimeByUint64(nextRefreshTime - 24*3600*1000)
|
|
|
+ curWeekDay := nowTime.Weekday()
|
|
|
+ if curWeekDay == 0 {
|
|
|
+ curWeekDay = 7
|
|
|
+ }
|
|
|
+
|
|
|
+ if nowTime.Hour() <= 4 {
|
|
|
+ curWeekDay--
|
|
|
+ if curWeekDay == 0 {
|
|
|
+ curWeekDay = 7
|
|
|
+ }
|
|
|
+ }
|
|
|
+ startUpTime := service.GetServiceStartupTime()
|
|
|
+ curServerDay := util.GetDurationDay1(startUpTime, nextRefreshTime)
|
|
|
+
|
|
|
+ guildDemon, ok := ConvertGuildDemon[int32(curWeekDay)]
|
|
|
+ if !ok {
|
|
|
+ util.InfoF("[GetDemonInfo] get guildDemon config [%v] ", int32(curWeekDay))
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ demonData := &GuildDemonData{}
|
|
|
+ maxStartDay := int32(0)
|
|
|
+ for _, data := range guildDemon.DemonData {
|
|
|
+ if data.StartDay <= curServerDay && curServerDay <= data.EndDay {
|
|
|
+ return data
|
|
|
+ }
|
|
|
+ if maxStartDay <= data.StartDay {
|
|
|
+ maxStartDay = data.StartDay
|
|
|
+ demonData = data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return demonData
|
|
|
+}
|
|
|
+
|
|
|
+type ActivitySignInData struct {
|
|
|
+ SignDay int32
|
|
|
+ IsDouble int32
|
|
|
+ VipLevel int32
|
|
|
+ ActivityId int32
|
|
|
+ RewardList map[int32]int32
|
|
|
+}
|
|
|
+
|
|
|
+type ActivitySignIn struct {
|
|
|
+ SignData map[int32]*ActivitySignInData
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertActivitySignIn = map[int32]*ActivitySignIn{}
|
|
|
+
|
|
|
+func convertActivitySignInCfg() {
|
|
|
+ for _, data := range serverproto.ActivitiesSignInCfgLoader {
|
|
|
+ _, ok := ConvertActivitySignIn[data.ActivitiesId]
|
|
|
+ if !ok {
|
|
|
+ convertData := &ActivitySignIn{
|
|
|
+ SignData: map[int32]*ActivitySignInData{},
|
|
|
+ }
|
|
|
+ ConvertActivitySignIn[data.ActivitiesId] = convertData
|
|
|
+ }
|
|
|
+
|
|
|
+ signData := &ActivitySignInData{
|
|
|
+ RewardList: map[int32]int32{},
|
|
|
+ }
|
|
|
+ signData.VipLevel = data.VipLevel
|
|
|
+ signData.IsDouble = data.SignInType
|
|
|
+ signData.SignDay = data.Day
|
|
|
+ signData.ActivityId = data.ActivitiesId
|
|
|
+
|
|
|
+ for _, reward := range data.SignInReward {
|
|
|
+ itemId, itemCount := Str2Res(reward)
|
|
|
+ signData.RewardList[itemId] += itemCount
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertActivitySignIn[data.ActivitiesId].SignData[data.Day] = signData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type IdolBoxData struct {
|
|
|
+ Level int32
|
|
|
+ BoxCount int32
|
|
|
+ TicketCount int32
|
|
|
+ Reward []*serverproto.KeyValueType
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertIdolBoxData = map[int32]*IdolBoxData{}
|
|
|
+
|
|
|
+func convertIdolSeasonCfg() {
|
|
|
+ //解析馈赠宝箱
|
|
|
+ for _, data := range serverproto.CompetitionAidouluCfgLoader {
|
|
|
+ convertData := &IdolBoxData{
|
|
|
+ Level: data.BoxId,
|
|
|
+ BoxCount: data.GoodNum,
|
|
|
+ TicketCount: data.ConditionHot,
|
|
|
+ }
|
|
|
+ for _, reward := range data.Rewards {
|
|
|
+ itemId, itemNum := Str2Res(reward)
|
|
|
+ if itemNum > 0 {
|
|
|
+ convertData.Reward = append(convertData.Reward, &serverproto.KeyValueType{
|
|
|
+ Key: itemId,
|
|
|
+ Value: itemNum,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertIdolBoxData[data.BoxId] = convertData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type StProbRewardData struct {
|
|
|
+ Weight int32
|
|
|
+ ItemId int32
|
|
|
+ ItemCnt int32
|
|
|
+ WaitTime int32
|
|
|
+}
|
|
|
+
|
|
|
+type StDbWishBox struct {
|
|
|
+ IsRand bool
|
|
|
+ ItemId int32
|
|
|
+ BoxType int32 // 类型
|
|
|
+ WaitTime int32 // 倒计时
|
|
|
+ LuckyProb int32 // 暴击概率
|
|
|
+ SpeedCost serverproto.KeyValueType // 加速消耗
|
|
|
+ RewardList []*StProbRewardData // 许愿奖励
|
|
|
+ LuckyReward []*StProbRewardData // 暴击奖励
|
|
|
+}
|
|
|
+
|
|
|
+func (this StDbWishBox) GetRewardItem(itemId int32) (ret *StProbRewardData) {
|
|
|
+ for _, i2 := range this.RewardList {
|
|
|
+ if i2.ItemId != itemId {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ ret = i2
|
|
|
+ break
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (this StDbWishBox) GetRandRewardItem() (ret *StProbRewardData) {
|
|
|
+ total := this.RewardList[len(this.RewardList)-1].Weight
|
|
|
+ value := rand.Int31n(total)
|
|
|
+ for _, i2 := range this.RewardList {
|
|
|
+ if value > i2.Weight {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ ret = i2
|
|
|
+ break
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertWishBoxData = map[int32]*StDbWishBox{}
|
|
|
+
|
|
|
+func convertWishCfg() {
|
|
|
+ for _, data := range serverproto.WishCfgLoader {
|
|
|
+ dbData := &StDbWishBox{ItemId: data.Id, BoxType: data.BoxType, WaitTime: data.WishCountdown, LuckyProb: data.LuckyProbability}
|
|
|
+ initWeight := int32(0)
|
|
|
+ for _, i2 := range data.WishReward {
|
|
|
+ rewardItem := strings.Split(i2, ":")
|
|
|
+ if len(rewardItem) < 3 {
|
|
|
+ panic("许愿表配置奖励错误")
|
|
|
+ }
|
|
|
+ weight, itemId, itemcnt := Str2Res_3(i2)
|
|
|
+ initWeight += weight
|
|
|
+ dbData.RewardList = append(dbData.RewardList, &StProbRewardData{Weight: int32(initWeight), ItemId: int32(itemId), ItemCnt: int32(itemcnt), WaitTime: data.WishCountdown})
|
|
|
+ }
|
|
|
+ sort.Slice(dbData.RewardList, func(i, j int) bool {
|
|
|
+ return dbData.RewardList[i].Weight < dbData.RewardList[j].Weight
|
|
|
+ })
|
|
|
+ if initWeight > 0 {
|
|
|
+ dbData.IsRand = true
|
|
|
+ }
|
|
|
+ initWeight = 0
|
|
|
+ for _, i2 := range data.LuckyReward {
|
|
|
+ rewardItem := strings.Split(i2, ":")
|
|
|
+ if len(rewardItem) < 3 {
|
|
|
+ panic("许愿表配置暴击奖励错误")
|
|
|
+ }
|
|
|
+ weight, itemId, itemcnt := Str2Res_3(i2)
|
|
|
+ initWeight += weight
|
|
|
+ dbData.LuckyReward = append(dbData.LuckyReward, &StProbRewardData{Weight: int32(initWeight), ItemId: int32(itemId), ItemCnt: int32(itemcnt), WaitTime: data.WishCountdown})
|
|
|
+ }
|
|
|
+ sort.Slice(dbData.LuckyReward, func(i, j int) bool {
|
|
|
+ return dbData.LuckyReward[i].Weight < dbData.LuckyReward[j].Weight
|
|
|
+ })
|
|
|
+
|
|
|
+ for _, i2 := range data.AccelerateCost {
|
|
|
+ dbData.SpeedCost.Key, dbData.SpeedCost.Value = Str2Res(i2)
|
|
|
+ }
|
|
|
+ ConvertWishBoxData[data.Id] = dbData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type CombineServer struct {
|
|
|
+ Id int32
|
|
|
+ ServerList []*serverproto.KeyValueType
|
|
|
+ CombineTime uint64
|
|
|
+ Notice string
|
|
|
+}
|
|
|
+
|
|
|
+var ConvertCombineServerData = map[int32]*CombineServer{}
|
|
|
+
|
|
|
+func ConvertCombinedServer() {
|
|
|
+ //热跟新的时候需要重新处理
|
|
|
+ ConvertCombineServerData = make(map[int32]*CombineServer)
|
|
|
+
|
|
|
+ for _, data := range serverproto.CombinedServiceCfgLoader {
|
|
|
+ combineData := &CombineServer{}
|
|
|
+ combineData.Id = data.Id
|
|
|
+
|
|
|
+ loc := util.GetLoc()
|
|
|
+
|
|
|
+ if data.Time != "" {
|
|
|
+ sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.Time, loc)
|
|
|
+ if err1 != nil {
|
|
|
+ util.PanicF("combineData endTime err:%v", err1)
|
|
|
+ }
|
|
|
+ combineData.CombineTime = uint64(sTime.UnixNano() / 1e6)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, servers := range data.Number {
|
|
|
+ start, end := Str2Res(servers)
|
|
|
+ combineData.ServerList = append(combineData.ServerList, &serverproto.KeyValueType{
|
|
|
+ Key: start,
|
|
|
+ Value: end,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ combineData.Notice = data.Tips
|
|
|
+ ConvertCombineServerData[data.Id] = combineData
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func CheckInCombined(zoneId int32) (bool, uint64) {
|
|
|
+ data, ok := ConvertCombineServerData[1]
|
|
|
+ if !ok {
|
|
|
+ return false, 0
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ nowTime := util.GetCurrentTime()
|
|
|
+ if data.CombineTime > nowTime {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ for _, server := range data.ServerList {
|
|
|
+ if server.Key <= zoneId && zoneId <= server.Value {
|
|
|
+ return true, data.CombineTime
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false, 0
|
|
|
+}
|