HeroManager = {} local this = HeroManager local HeroData = require("Modules.Hero.HeroData") local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig) local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local heroLevelConfig = ConfigManager.GetConfig(ConfigName.HeroLevelConfig) local heroRankUpConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig) local heroRankUpGroup = ConfigManager.GetConfig(ConfigName.HeroRankupGroup) local skillConfig = ConfigManager.GetConfig(ConfigName.SkillConfig) local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig) local passiveSkillLogicConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig) local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting) local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig) local equipConfig = ConfigManager.GetConfig(ConfigName.EquipConfig) local equipsuite = ConfigManager.GetConfig(ConfigName.EquipSuiteConfig) local jewelConfig = ConfigManager.GetConfig(ConfigName.JewelConfig) local jewelRankupConfig = ConfigManager.GetConfig(ConfigName.JewelRankupConfig) local jewelResonanceConfig = ConfigManager.GetConfig(ConfigName.JewelResonanceConfig) local heroDatas = {} this.heroSortedDatas={}--排序后的英雄数据 this.heroDataLists = {} this.heroLvEnd = {} --3星=60,4=200,5=250 星级对应等级上限 --this.heroLvBreakNum={}--3星=9000,4=60000,5=60000 星级对应突破系数 this.heroPropertyScore = {} --每个属性评分 this.heroPosCount = 5 this.heroQuantityCount = 6 this.heroProCount = 6 --成员界面排序索引 this.heroListPanelSortID = 1 this.heroListPanelProID = 0 --穿脱装备界面临时数据 this.roleEquipPanelCurHeroData = nil this.roleEquipPanelHeroListData = nil this.allProVal = {} --临时计算英雄战力加成 this.heroResolveLicence = {} --this.singleHeroProVal = {}--单体加成 --this.lvProVal = {}--单体等级限制加成 --this.allHeroProVal = {}--团体加成 --this.specialProVal = {}--减乘 this.awakeStarIndex = 10-- 前端写死觉醒星级标志 this.awakeNextStarIndex = 11-- 前端写死觉醒星级标志 --存储英雄身上对应的星级 local curAllStarBreakIdData = { -- [1] = {[40]= 24}, -- [2] = {[40]= 22,[50]= 23} } function this.Initialize() for i = 1, WarPowerTypeAllNum do this.allProVal[i] = { singleHeroProVal = {}, --单体加成 lvProVal = {}, --单体等级限制加成 allHeroProVal = {}, --团体加成 specialProVal = {} --减乘 } end this.SetAllStarBreakIdData() end --初始化英雄数据 function this.InitHeroData(_msgHeroList) local hero_resolve_licence = string.split(ConfigManager.GetConfigData(ConfigName.SpecialConfig, 36).Value, "#") for i = 1, #hero_resolve_licence do this.heroResolveLicence[tonumber(hero_resolve_licence[i])] = tonumber(hero_resolve_licence[i]) end this.UpdateHeroLvEnd() --Log("服务端推送英雄数量:" .. #_msgHeroList) for i = 1, #_msgHeroList do this.UpdateHeroDatas(_msgHeroList[i], true) end --赋值每个星级的英雄等级上限 -- this.UpdateHeroPower() --赋值英雄战力 end --刷新本地数据 function this.UpdateHeroDatas(_msgHeroData, isFindHandBook) local heroData = HeroData.new(_msgHeroData, isFindHandBook) heroData.soulPrintList = {} --乘减属性集合 heroData.MLSproList={} heroData.heroBackData = _msgHeroData heroData.dynamicId = _msgHeroData.id local _id = _msgHeroData.heroId heroData.id = _id heroData.star = _msgHeroData.star heroData.lv = _msgHeroData.level heroData.breakId = _msgHeroData.breakId -- LogGreen("heroData.id:"..heroData.id.." heroData.breakId:"..heroData.breakId) heroData.upStarId = _msgHeroData.starBreakId heroData.skinId = _msgHeroData.skinId heroData.createTime = _msgHeroData.createTimelocal heroData.lockState = _msgHeroData.lockState heroData.createtype = _msgHeroData.createtype heroData.changeId = _msgHeroData.changeId--置换id heroData.formationList = {}--所在编队list --本地 or 援助 local _configData = heroConfig[_id] heroData.heroConfig = heroConfig[_id] heroData.maxStar = _configData.MaxRank --Log(heroData.heroConfig.ReadingName.." _msgHeroData.starBreakId ".._msgHeroData.starBreakId) local actionPowerRormula = gameSetting[1].ActionPowerRormula heroData.actionPower = heroData.heroConfig.ActionPower + math.floor( (actionPowerRormula[1] * math.pow(heroData.lv, 3) + actionPowerRormula[2] * math.pow(heroData.lv, 2) + actionPowerRormula[3] * heroData.lv + actionPowerRormula[4]) ) --_msgHeroData.actionPower --英雄穿戴的装备 -- LogPink("_msgHeroData.equipIdList "..#_msgHeroData.equipIdList..heroData.heroConfig.ReadingName) heroData.equipIdList = _msgHeroData.equipIdList heroData.jewels = _msgHeroData.jewels heroData.talismanList = _msgHeroData.especialEquipLevel --法宝等级 if (#_msgHeroData.soulPos >= 1) then local soulPrintList = {} for i, v in ipairs(_msgHeroData.soulPos) do local soulPrint = {equipId = v.equipId, position = v.position} SoulPrintManager.AddSoulPrintUpHeroDynamicId(v.equipId, heroData.dynamicId) table.insert(soulPrintList, soulPrint) end heroData.soulPrintList = soulPrintList end heroData.skillIdList = {} --主动技 this.UpdateSkillIdList(heroData) heroData.passiveSkillList = {} --被动技 this.UpdatePassiveHeroSkill(heroData) heroData.hp = _configData.Hp heroData.attack = _configData.Attack heroData.pDef = _configData.PhysicalDefence heroData.mDef = _configData.MagicDefence heroData.speed = _configData.Speed if heroData.skinId == 0 then heroData.skinConfig = _configData heroData.live = GetResourcePath(_configData.Live) heroData.painting = GetResourcePath(_configData.Painting) heroData.icon = GetResourcePath(_configData.Icon) heroData.scale = _configData.Scale heroData.position = _configData.Position else heroData.skinConfig = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",heroData.skinId) heroData.live = GetResourcePath(heroData.skinConfig.Live) heroData.painting = GetResourcePath(heroData.skinConfig.Painting) heroData.icon = GetResourcePath(heroData.skinConfig.Icon) heroData.scale = heroData.skinConfig.Scale heroData.position = heroData.skinConfig.Position end heroData.profession = _configData.Profession heroData.ProfessionResourceId = _configData.ProfessionResourceId if GetJobSpriteStrByJobNum(_configData.Profession) then heroData.professionIcon = GetJobSpriteStrByJobNum(_configData.Profession) else heroData.professionIcon = GetJobSpriteStrByJobNum(1) end heroData.name = _configData.ReadingName heroData.property = _configData.PropertyName heroData.sortId = #heroDatas + 1 heroData.harmonyGongMing = _msgHeroData.createtype table.insert(this.heroDataLists, heroData) heroDatas[heroData.dynamicId] = heroData this.SetEquipUpHeroDid(heroData.equipIdList, heroData.dynamicId) this.SetEquipTreasureUpHeroDid(heroData.jewels, heroData.dynamicId) this.SetTalismanLv(heroData.dynamicId, heroData.talismanList) --this.SetSoulPrintUpHeroDid(heroData.soulPrintList,heroData.dynamicId) this.GetSingleProScoreVal() isFindHandBook = isFindHandBook or true if isFindHandBook then --图鉴 PlayerManager.SetHeroHandBookListData(heroData.id, heroData.star) end heroData.warPower = this.CalculateHeroAllProValList(1, heroData.dynamicId, false)[HeroProType.WarPower] --远征初始化血量 --ExpeditionManager.InitHeroHpValue(heroData) end function this.ChangeSkinId(heroId,skinId) heroDatas[heroId].skinId = skinId if skinId == 0 then heroDatas[heroId].skinConfig = heroConfig[heroDatas[heroId].id] else heroDatas[heroId].skinConfig = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",heroDatas[heroId].skinId) end heroDatas[heroId].live = GetResourcePath(heroDatas[heroId].skinConfig.Live) heroDatas[heroId].painting = GetResourcePath(heroDatas[heroId].skinConfig.Painting) heroDatas[heroId].icon = GetResourcePath(heroDatas[heroId].skinConfig.Icon) heroDatas[heroId].scale = heroDatas[heroId].skinConfig.Scale heroDatas[heroId].position = heroDatas[heroId].skinConfig.Position end function this.SetHeroFormationList(heroDid,teamId,isAddOrDel) if heroDatas[heroDid] then -- LogRed("this.heroResolveLicence[teamId]:"..tostring(this.heroResolveLicence[teamId])) if isAddOrDel and this.heroResolveLicence[teamId] then -- LogRed("添加了") heroDatas[heroDid].formationList[teamId] = teamId else heroDatas[heroDid].formationList[teamId] = nil end end end function this.GetHeroEquipIdList(heroDid) return heroDatas[heroDid].equipIdList end function this.GetHeroEquipIdList1(heroDid, id) for i = 1, #heroDatas[heroDid].equipIdList do if equipConfig[tonumber(heroDatas[heroDid].equipIdList[i])].Position == equipConfig[tonumber(id)].Position then heroDatas[heroDid].equipIdList[i] = id end end end function this.SetHeroEquipIdList(heroDid, equipIdList) heroDatas[heroDid].equipIdList = equipIdList end function this.SetEquipUpHeroDid(_equipids, _heroDid) if _equipids then EquipManager.UpdateEquipData(_equipids, _heroDid) end end function this.SetEquipTreasureUpHeroDid(_equipTreasureDids, _heroDid) for i = 1, #_equipTreasureDids do EquipTreasureManager.SetEquipTreasureUpHeroDid(_equipTreasureDids[i], _heroDid) end end --设置法宝等级 function this.SetTalismanLv(did, lv) heroDatas[did].talismanList = lv end function this.GetTalismanLv(did) if heroDatas[did] then return heroDatas[did].talismanList end end --设置已穿戴魂印数据 function this.SetSoulPrintUpHeroDid(soulPos, _heroDid) if (soulPos) then SoulPrintManager.SetSoulPrintUpHeroDid(soulPos, _heroDid) end end --获取所有英雄信息 function this.GetAllHeroDatas(_lvLimit) local lvLimit = 0 local allUpZhenHeroList = FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.FORMATION_ENDLESS_MAP) if _lvLimit then lvLimit = _lvLimit end local heros = {} for i, v in pairs(heroDatas) do if v.lv >= lvLimit or allUpZhenHeroList[v.dynamicId] then table.insert(heros, v) end end table.sort( heros, function(a, b) return a.sortId < b.sortId end ) return heros end --获取该静态id sortid最小的英雄信息 function this.GetHeroDataByHeroSIdAndMinSortId(_heroSId) local heroData = {} local formationList = FormationManager.GetAllFormationHeroId() for i, v in pairs(formationList) do if heroDatas[i] then local curData = heroDatas[i] if curData.id == _heroSId then if heroData and heroData.id then if curData.sortId < heroData.sortId then heroData = curData end else heroData = curData end end end end if heroData and heroData.id then return heroData end for i, v in pairs(heroDatas) do if v.id == _heroSId then if heroData and heroData.id then if v.sortId < heroData.sortId then heroData = v end else heroData = v end end end return heroData end --获取该静态id 没有穿皮肤的 sortid最小的英雄信息 function this.GetHeroDataByHeroSIdAndMinSortIdAndSkinId(_heroSId,_skinId) local heroData = {} local formationList = FormationManager.GetAllFormationHeroId() for i, v in pairs(formationList) do if heroDatas[i] then local curData = heroDatas[i] if curData.id == _heroSId and curData.skinId ~= _skinId then if heroData and heroData.id then if curData.sortId < heroData.sortId then heroData = curData end else heroData = curData end end end end if heroData and heroData.id then return heroData end for i, v in pairs(heroDatas) do if v.id == _heroSId and v.skinId ~= _skinId then if heroData and heroData.id then if v.sortId < heroData.sortId then heroData = v end else heroData = v end end end LogPink("heroData.dynamicId:"..heroData.dynamicId) return heroData end --获取所有英雄信息(分解 回溯用 ) function this.GetAllHeroDataMsinusUpWar(_sortTypeId,type) --0全部 1-6属性 7-9 3、4、5星 local heros = {} local heros2 = {} for i, v in pairs(heroDatas) do --队伍名称 以、 连接 v.isFormation = "" table.insert(heros, v) end --标记编队上的英雄 if heros and LengthOfTable(heros) > 0 then for i, v in pairs(heros) do local isFormations = {} for n, w in pairs(FormationManager.formationList) do for m = 1, #w.teamHeroInfos do if w.teamHeroInfos[m] and v.dynamicId == w.teamHeroInfos[m].heroId then --队伍名称 队伍id local isFormationStr = "" local curFormationId = 0 local temp = this.GetHeroFormationStr2(n) if temp and temp ~= "" then if heros[i].isFormation and heros[i].isFormation == "" then isFormationStr, curFormationId = this.GetHeroFormationStr2(n) table.insert(isFormations, curFormationId) else isFormationStr, curFormationId = "、" .. this.GetHeroFormationStr2(n) table.insert(isFormations, curFormationId) end heros[i].isFormation = heros[i].isFormation .. isFormationStr end end heros[i].isHarmonyGongMing = 0 if HarmonyManager.IsChangeColor(v.dynamicId) then heros[i].isHarmonyGongMing = 1 end if HarmonyManager:IsEnvoy(v.dynamicId) then heros[i].isHarmonyGongMing = 2 end end end --所有的所在队伍id, heros[i].isFormations = isFormations end end --筛选 if heros and LengthOfTable(heros) > 0 then for i, v in pairs(heros) do if (v.lv > 1 and type == 1) or (v.lv > 0 and type == 2) or (v.talismanList > 1 and type == 3) then if _sortTypeId == 0 then table.insert(heros2, v) -- elseif _sortTypeId >= 7 then -- if v.star == _sortTypeId - 4 then -- table.insert(heros2, v) -- end else if v.property == _sortTypeId then table.insert(heros2, v) end end end end end return heros2 end function this.GetHeroFormationStr(teamId) if this.heroResolveLicence[teamId] then if teamId < FormationTypeDef.FORMATION_ARENA_DEFEND then return Language[11101] elseif teamId == FormationTypeDef.FORMATION_ARENA_DEFEND then -- 101 return Language[11102] elseif teamId == FormationTypeDef.FORMATION_ARENA_ATTACK then -- 201 return Language[11103] elseif teamId == FormationTypeDef.FORMATION_ENDLESS_MAP then -- 401 return Language[11104] elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_DEFEND then -- 501 return Language[11105] elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_ATTACK then -- 502 -- elseif teamId == FormationTypeDef.MONSTER_CAMP_ATTACK then -- return "该猎妖师在锁妖阵容中已上阵"-- 601 return Language[11106] elseif teamId == FormationTypeDef.BLOODY_BATTLE_ATTACK then -- 701 return Language[11107] elseif teamId == FormationTypeDef.EXPEDITION then return Language[11108] -- 1001 elseif teamId == FormationTypeDef.ARENA_TOM_MATCH then return Language[12388] end end return "" end function this.GetHeroFormationStr2(teamId) if this.heroResolveLicence[teamId] then if teamId < FormationTypeDef.FORMATION_ARENA_DEFEND then return Language[11109], FormationTypeDef.FORMATION_NORMAL elseif teamId == FormationTypeDef.FORMATION_ARENA_DEFEND then return Language[11110], FormationTypeDef.FORMATION_ARENA_DEFEND elseif teamId == FormationTypeDef.FORMATION_ARENA_ATTACK then return Language[11111], FormationTypeDef.FORMATION_ARENA_ATTACK elseif teamId == FormationTypeDef.FORMATION_ENDLESS_MAP then return Language[10694], FormationTypeDef.FORMATION_ENDLESS_MAP elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_DEFEND then return Language[10680], FormationTypeDef.FORMATION_GUILD_FIGHT_DEFEND elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_ATTACK then return Language[10681], FormationTypeDef.FORMATION_GUILD_FIGHT_ATTACK elseif teamId == FormationTypeDef.BLOODY_BATTLE_ATTACK then return Language[11112], FormationTypeDef.BLOODY_BATTLE_ATTACK elseif teamId == FormationTypeDef.EXPEDITION then return Language[10699], FormationTypeDef.EXPEDITION elseif teamId == FormationTypeDef.ARENA_TOM_MATCH then return Language[12280], FormationTypeDef.ARENA_TOM_MATCH end end return "" end --删除本地英雄信息 function this.DeleteHeroDatas(heroDIds) for i = 1, #heroDIds do if heroDatas[heroDIds[i]] then --清除英雄装备上挂载的英雄id local equips = heroDatas[heroDIds[i]].equipIdList if equips and LengthOfTable(equips) > 0 then for j = 1, LengthOfTable(equips) do EquipManager.DeleteSingleEquip(equips[j], heroDIds[i]) end end if (heroDatas[heroDIds[i]].jewels and #heroDatas[heroDIds[i]].jewels > 0) then for j = 1, #heroDatas[heroDIds[i]].jewels do EquipTreasureManager.SetTreasureUpOrDown(heroDatas[heroDIds[i]].jewels[j], "") end end --清除英雄法宝上挂载的英雄did --local talismanList=heroDatas[heroDIds[i]].talismanList --if talismanList and LengthOfTable(talismanList)>0 then -- for i = 1, LengthOfTable(talismanList) do -- if TalismanManager.talismanTabs[talismanList[i]] then -- TalismanManager.talismanTabs[talismanList[i]].upHeroDid="0" -- end -- end --end --清楚编队上的英雄 FormationManager.AllFormationDeleCurHeroId(heroDIds[i]) --清除英雄魂印上挂载的英雄did SoulPrintManager.hasEquipSoulPrintId[heroDIds[i]] = nil --删除远征英雄数据 ExpeditionManager.DelHeroHpValue(heroDatas[heroDIds[i]]) --删除英雄 heroDatas[heroDIds[i]] = nil end end end --更新本地单个英雄基本信息 function this.UpdateSingleHeroDatas(heroDId, heroLv, heroStar, breakId, upStarId, isCallBackChangeWar) if heroDatas[heroDId] then heroDatas[heroDId].lv = heroLv heroDatas[heroDId].star = heroStar heroDatas[heroDId].breakId = breakId heroDatas[heroDId].upStarId = upStarId local actionPowerRormula = gameSetting[1].ActionPowerRormula heroDatas[heroDId].actionPower = heroDatas[heroDId].heroConfig.ActionPower + math.floor( (actionPowerRormula[1] * math.pow(heroLv, 3) + actionPowerRormula[2] * math.pow(heroLv, 2) + actionPowerRormula[3] * heroLv + actionPowerRormula[4]) ) PlayerManager.SetHeroHandBookListData(heroDatas[heroDId].id, heroDatas[heroDId].star) end if isCallBackChangeWar then this.CompareWarPower(heroDId) end end --更新本地单个英雄上锁 function this.UpdateSingleHeroLockState(heroDId, lockState) if heroDatas[heroDId] then heroDatas[heroDId].lockState = lockState end end --对比战力并更新战力值 function this.CompareWarPower(heroDId) local oldWarPowerValue = heroDatas[heroDId].warPower local newWarPowerValue = this.CalculateHeroAllProValList(1, heroDId, false)[HeroProType.WarPower] heroDatas[heroDId].warPower = newWarPowerValue if oldWarPowerValue and newWarPowerValue then if oldWarPowerValue ~= newWarPowerValue then if not UIManager.IsOpen(UIName.RoleUpStarSuccessPanel) and not UIManager.IsOpen(UIName.RoleUpLvBreakSuccessPanel) then UIManager.OpenPanel( UIName.WarPowerChangeNotifyPanelV2, {oldValue = oldWarPowerValue, newValue = newWarPowerValue} ) end end end FormationManager.CheckHeroIdExist(heroDId) end --更新本地单个英雄技能信息 function this.UpdateSingleHeroSkillData(_heroDId) if heroDatas[_heroDId] then --local herodata=heroDatas[_heroDId] --local skillIdList={} --for i = 1, #herodata.heroConfig.OpenSkillRules do -- if herodata.heroConfig.OpenSkillRules[i][1]==herodata.star then -- --skillIdList[i]=herodata.heroConfig.OpenSkillRules[i][2] -- table.insert(skillIdList,herodata.heroConfig.OpenSkillRules[i][2]) -- end --end --herodata.skillIdList={} --for i = 1, #skillIdList do -- local heroSkill={} -- heroSkill.skillId=skillIdList[i] -- heroSkill.skillConfig=skillConfig[skillIdList[i]] -- table.insert( herodata.skillIdList,heroSkill) --end --heroDatas[_heroDId]=herodata local heroData = heroDatas[_heroDId] heroData.skillIdList = {} --主动技 if heroData.heroConfig.OpenSkillRules then for i = 1, #heroData.heroConfig.OpenSkillRules do if heroData.heroConfig.OpenSkillRules[i][1] == heroData.star then local heroSkill = {} heroSkill.skillId = heroData.heroConfig.OpenSkillRules[i][2] heroSkill.skillConfig = skillConfig[heroSkill.skillId] table.insert(heroData.skillIdList, heroSkill) end end end heroData.passiveSkillList = {} --被动技 local OpenPassiveSkillRules = heroData.star == this.awakeNextStarIndex and heroData.heroConfig.Awaken or heroData.heroConfig.OpenPassiveSkillRules if OpenPassiveSkillRules then for i = 1, #OpenPassiveSkillRules do if OpenPassiveSkillRules[i][1] == heroData.star then local heroSkill = {} heroSkill.skillId = OpenPassiveSkillRules[i][2] heroSkill.skillConfig = passiveSkillConfig[heroSkill.skillId] table.insert(heroData.passiveSkillList, heroSkill) end end end end end --更新本地单个英雄法宝信息 function this.UpdateHeroSingleTalismanData(heroDId, heroTalismanDatas, type) --type--1 穿单件法宝 2 卸单件法宝 if heroDatas[heroDId] then if type == 1 then heroDatas[heroDId].talismanList = {} for i = 1, #heroTalismanDatas do table.insert(heroDatas[heroDId].talismanList, heroTalismanDatas[i]) end elseif type == 2 then for i = 1, #heroDatas[heroDId].talismanList do for j = 1, #heroTalismanDatas do if heroDatas[heroDId].talismanList[i] == heroTalismanDatas[j] then heroDatas[heroDId].talismanList[i] = nil end end end end end this.CompareWarPower(heroDId) end --更新本地单个英雄魂印信息 function this.UpdateHeroSingleSoulPrint(heroDId, hasEquipSoulPrintId) local soulEquipPrintList = {} for i, v in pairs(hasEquipSoulPrintId[heroDId]) do local soulPrint = {did = v.did, pos = v.pos} table.insert(soulEquipPrintList, soulPrint) end heroDatas[heroDId].soulPrintList = soulEquipPrintList this.CompareWarPower(heroDId) end --获取单个英雄数据 function this.GetSingleHeroData(heroDId) if heroDatas[heroDId] then return heroDatas[heroDId] else return ExpeditionManager.GetSingleHeroData(heroDId) end end function this.IsHaveHero(heroDId) if heroDatas[heroDId] then return true end return false end --获取当前升星信息 function this.GetHeroCurUpStarInfo(heroDId) local indexStar = 0 local RankupConsumeMaterial = {} for i, v in pairs(heroDatas) do if v.dynamicId == heroDId then if v.heroConfig.RankupConsumeMaterial then for j = 1, #v.heroConfig.RankupConsumeMaterial do if #v.heroConfig.RankupConsumeMaterial[j] > 1 then if v.heroConfig.RankupConsumeMaterial[j][1] > v.star then if indexStar == 0 then indexStar = v.heroConfig.RankupConsumeMaterial[j][1] end if v.heroConfig.RankupConsumeMaterial[j][1] == indexStar then local heroUpStarMaterialsData = {} heroUpStarMaterialsData.upStarData = v.heroConfig.RankupConsumeMaterial[j] heroUpStarMaterialsData.upStarMaterialsData = heroRankUpGroup[v.heroConfig.RankupConsumeMaterial[j][3]] table.insert(RankupConsumeMaterial, heroUpStarMaterialsData) end end else return nil end end end end end return RankupConsumeMaterial end --检测卡库中的英雄是否有满足当前升星条件 function this.GetUpStarHeroListData(heroRankUpGroupId, heroData) local needHeroListData = {} needHeroListData.state = 0 --0 没有 1 有满足条件单位英雄 needHeroListData.heroList = {} local heroRankUpGroup = heroRankUpGroup[heroRankUpGroupId] for i, v in pairs(heroDatas) do if v.dynamicId == heroData.dynamicId then --自己筛掉 else v.isFormation = "" if heroRankUpGroup.Issame == 1 then --需要同名卡 if v.id == heroData.id then if v.star == heroRankUpGroup.StarLimit then if heroRankUpGroup.IsSameClan == 1 then if v.property == heroData.property then if heroRankUpGroup.IsId > 0 then if v.id == heroRankUpGroup.IsId then table.insert(needHeroListData.heroList, v) end else table.insert(needHeroListData.heroList, v) end end else if heroRankUpGroup.IsId > 0 then if v.id == heroRankUpGroup.IsId then table.insert(needHeroListData.heroList, v) end else table.insert(needHeroListData.heroList, v) end end end end else if v.star == heroRankUpGroup.StarLimit then if heroRankUpGroup.IsSameClan == 1 then if v.property == heroData.property then if heroRankUpGroup.IsId > 0 then if v.id == heroRankUpGroup.IsId then table.insert(needHeroListData.heroList, v) end else table.insert(needHeroListData.heroList, v) end end else if heroRankUpGroup.IsId > 0 then if v.id == heroRankUpGroup.IsId then table.insert(needHeroListData.heroList, v) end else table.insert(needHeroListData.heroList, v) end end end end end end --删除编队上的英雄 if needHeroListData.heroList and LengthOfTable(needHeroListData.heroList) > 0 then for i, v in pairs(needHeroListData.heroList) do for n, w in pairs(FormationManager.formationList) do if this.heroResolveLicence[n] then for m = 1, #w.teamHeroInfos do if w.teamHeroInfos[m] and v.dynamicId == w.teamHeroInfos[m].heroId then local isFormationStr = this.GetHeroFormationStr(n) v.isFormation = isFormationStr end end end end end end --删除冒险上的英雄 --if needHeroListData.heroList and LengthOfTable(needHeroListData.heroList)>0 then -- for i, v in pairs(needHeroListData.heroList) do -- for n,w in pairs(AdventureManager.heroList) do -- for m = 1, #w do -- if v.dynamicId==w[m] then -- needHeroListData.heroList[i] = nil -- end -- end -- end -- end --end local needHeroListData2 = {} needHeroListData2.state = 0 --0 没有 1 有满足条件单位英雄 needHeroListData2.heroList = {} for i, v in pairs(needHeroListData.heroList) do table.insert(needHeroListData2.heroList, v) end if #needHeroListData2.heroList > 0 then needHeroListData2.state = 1 end table.sort( needHeroListData2, function(a, b) if a.id == b.id then if a.lv == b.lv then return a.id > b.id else return a.lv < b.lv end else return a.id > b.id end end ) return needHeroListData2 end --计算每个星级的英雄等级最终上限 function this.UpdateHeroLvEnd() --计算每个最终等级上限 this.heroLvEnd = {} for i, v in ConfigPairs(heroConfig) do local heroEndStar = v.Star if v.RankupConsumeMaterial then local curRankupConsumeMaterial = v.RankupConsumeMaterial[#v.RankupConsumeMaterial] if curRankupConsumeMaterial then heroEndStar = curRankupConsumeMaterial[1] end end if heroEndStar == nil then heroEndStar = v.Star end for i, v2 in ConfigPairs(heroRankUpConfig) do if v2.Star == v.Star then if v2.OpenStar == heroEndStar then this.heroLvEnd[v.Id] = v2.OpenLevel end end end end --local threeStarLvEnd=3 --local fourStarLvEnd=4 --local fiveStarLvEnd=5 --this.heroLvBreakNum[threeStarLvEnd]=0 --this.heroLvBreakNum[fourStarLvEnd]=0 --this.heroLvBreakNum[fiveStarLvEnd]=0 -- --for i,v in ConfigPairs(heroRankUpConfig) do -- if v.Star==threeStarLvEnd then -- if v.Type==1 and this.heroLvBreakNum[threeStarLvEnd] 0 and heroRankUpConfig[breakId].JudgeClass ~= 1 then --没突破完毕 显示当前突破的等级上限 return heroRankUpConfig[breakId].OpenLevel elseif breakId > 0 and heroRankUpConfig[breakId].JudgeClass == 1 then --突破完毕 显示当前进阶的等级上限 if upStarId > 0 then return heroRankUpConfig[upStarId].OpenLevel else return heroRankUpConfig[breakId].OpenLevel end end end function this.UpdateHeroPower() for _, v in pairs(heroDatas) do v.warPower = this.CalculateHeroAllProValList(1, v.dynamicId, false)[HeroProType.WarPower] end end function this.UpdateHeroPowerProfession() for _, v in pairs(heroDatas) do if GuildSkillManager.UpdataHeroProList[v.heroConfig.Profession] then LogGreen("v.dynamicId "..v.dynamicId) v.warPower = this.CalculateHeroAllProValList(1, v.dynamicId, false)[HeroProType.WarPower] end end end --获取同一类型的技能 function this.GetTypeAllSkillData(_skillName) local allTypeSkillData = {} for i, v in ConfigPairs(skillConfig) do if v.Name == _skillName then table.insert(allTypeSkillData, v) end end return allTypeSkillData end --获得英雄属性计算战斗力属性评分 function this.GetSingleProScoreVal() this.heroPropertyScore = {} for i, v in ConfigPairs(propertyConfig) do this.heroPropertyScore[i] = v.Score end end --计算所有装备加成的属性值 local function CalculateHeroUpEquipsProAddVal(_heroId) local addAllProVal = {} for i, v in ConfigPairs(propertyConfig) do addAllProVal[i] = 0 end local curHeroData = HeroManager.GetSingleHeroData(_heroId) if curHeroData then --Log("#curHeroData.equipIdList "..#curHeroData.equipIdList) local equipSuit = this.GetCurHeroEquipSuitPros(curHeroData.equipIdList) --[id] = 件数 for i = 1, #curHeroData.equipIdList do local curEquip = EquipManager.GetSingleHeroSingleEquipData(curHeroData.equipIdList[i], _heroId) if curEquip then for index, prop in ipairs(curEquip.mainAttribute) do local id = prop.propertyId local value = prop.propertyValue if addAllProVal[id] then addAllProVal[id] = addAllProVal[id] + value else addAllProVal[id] = value end end end end if equipSuit and #equipSuit > 0 then for i, v in ipairs(equipSuit) do local curSuitConfig = equipsuite[i] local curProId = equipSuit[i][2][2] local curProVal = equipSuit[i][2][3] -- LogError("套装激活 curProId "..curProId .." "..curProVal) if addAllProVal[curProId] then addAllProVal[curProId] = addAllProVal[curProId] + curProVal else addAllProVal[curProId] = curProVal end end end end return addAllProVal end --计算所有法宝加成的属性值 local function CalculateHeroUpTalismanProAddVal(_heroId, _breakId, _upStarId,teamCurPropertyName) local addAllProVal = {} local singleHeroProVal, lvProVal, allHeroProVal, specialProVal local curHeroData = HeroManager.GetSingleHeroData(_heroId) if curHeroData and curHeroData.heroConfig.EquipTalismana then local star = curHeroData.star if heroRankUpConfig[_upStarId] then star = heroRankUpConfig[_upStarId].OpenStar end if star >= curHeroData.heroConfig.EquipTalismana[1] then local curTalisman = ConfigManager.GetConfigData(ConfigName.HeroConfig, curHeroData.id).EquipTalismana if curTalisman and curTalisman[2] then local talismanConFig = ConfigManager.GetConfigDataByDoubleKey( ConfigName.EquipTalismana, "TalismanaId", curTalisman[2], "Level", curHeroData.talismanList ) if talismanConFig then --主属性 for j = 1, #talismanConFig.Property do if addAllProVal[talismanConFig.Property[j][1]] then addAllProVal[talismanConFig.Property[j][1]] = addAllProVal[talismanConFig.Property[j][1]] + talismanConFig.Property[j][2] else addAllProVal[talismanConFig.Property[j][1]] = talismanConFig.Property[j][2] end end --副属性 if talismanConFig.SpecialProperty and #talismanConFig.SpecialProperty > 0 then for k = 1, #talismanConFig.SpecialProperty do if talismanConFig.SpecialProperty[k][1] == curHeroData.profession then if addAllProVal[talismanConFig.SpecialProperty[k][2]] then addAllProVal[talismanConFig.SpecialProperty[k][2]] = addAllProVal[talismanConFig.SpecialProperty[k][2]] + talismanConFig.SpecialProperty[k][3] else addAllProVal[talismanConFig.SpecialProperty[k][2]] = talismanConFig.SpecialProperty[k][3] end end end end --当前法宝全部天赋数据(天赋可能为空) local dowerAllData = ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipTalismana, "TalismanaId", curTalisman[2]) local skillIds = {} --LogError("当前法宝全部天赋数据 "..curTalisman[2].." "..#dowerAllData.." "..curHeroData.talismanList) for i = 1, #dowerAllData do if dowerAllData[i].OpenSkillRules and curHeroData.talismanList >= dowerAllData[i].Level then for k = 1, #dowerAllData[i].OpenSkillRules do --LogError("dowerAllData[i].OpenSkillRules[k] "..dowerAllData[i].OpenSkillRules[k]) table.insert(skillIds, dowerAllData[i].OpenSkillRules[k]) end end end --被动技能计算 if skillIds and #skillIds > 0 then --talismanConFig.OpenSkillRules and #talismanConFig.OpenSkillRules > 0 then --单体加成 --单体等级限制加成 --团体加成 --减乘 curHeroData.MLSproList = {} singleHeroProVal, lvProVal, allHeroProVal, specialProVal = this.CalculatePassiveSkillsValList(WarPowerType.Talisman, skillIds,teamCurPropertyName,curHeroData) end end end end end if singleHeroProVal and LengthOfTable(singleHeroProVal) > 0 then for i, v in pairs(singleHeroProVal) do if addAllProVal[i] then addAllProVal[i] = addAllProVal[i] + v else addAllProVal[i] = v end end end return addAllProVal, lvProVal, allHeroProVal, specialProVal end --英雄身上魂印属性计算 local function CalculateSoulPrintAddVal(_heroId) -- local allSoulPrintAddWarPowerVal = 0 -- local curHeroData = HeroManager.GetSingleHeroData(_heroId) -- if curHeroData then -- if (table.nums(curHeroData.soulPrintList) >= 1) then -- for i = 1, #curHeroData.soulPrintList do -- -- LogError(_heroId) -- local cursoulPrintConfig = equipConfig[curHeroData.soulPrintList[i].equipId] -- if cursoulPrintConfig then -- allSoulPrintAddWarPowerVal = allSoulPrintAddWarPowerVal + cursoulPrintConfig.Score -- end -- end -- end -- end -- return allSoulPrintAddWarPowerVal local addAllProVal = {} local singleHeroProVal,lvProVal,allHeroProVal,specialProVal local curHeroData = HeroManager.GetSingleHeroData(_heroId) if curHeroData then if(table.nums(curHeroData.soulPrintList) >= 1) then for i = 1, #curHeroData.soulPrintList do local cursoulPrintConfig = equipConfig[curHeroData.soulPrintList[i].equipId] if cursoulPrintConfig then --基础属性计算 local soulPrintPropertyList = cursoulPrintConfig.Property if soulPrintPropertyList and #soulPrintPropertyList > 0 then for i,v in pairs(soulPrintPropertyList) do if(addAllProVal[v[1]]) then addAllProVal[v[1]]=v[2]+addAllProVal[v[1]] else addAllProVal[v[1]]=v[2] end end end --被动技能计算 if cursoulPrintConfig.PassiveSkill then --单体加成 --单体等级限制加成 --团体加成 --减乘 singleHeroProVal,lvProVal,allHeroProVal,specialProVal = this.CalculatePassiveSkillsValList(WarPowerType.SoulPrint,cursoulPrintConfig.PassiveSkill) end end end end end if singleHeroProVal and LengthOfTable(singleHeroProVal) > 0 then for i,v in pairs(singleHeroProVal) do if addAllProVal[i] then addAllProVal[i] = addAllProVal[i] + v else addAllProVal[i] = v end end end return addAllProVal,lvProVal,allHeroProVal,specialProVal end --英雄身上魂印属性计算 local function CalculateSoulPrintAddVal2(_heroId) local allSoulPrintAddWarPowerVal = 0 local curHeroData = HeroManager.GetSingleHeroData(_heroId) if curHeroData then if (table.nums(curHeroData.soulPrintList) >= 1) then for i = 1, #curHeroData.soulPrintList do -- LogError(_heroId) local cursoulPrintConfig = equipConfig[curHeroData.soulPrintList[i].equipId] if cursoulPrintConfig then allSoulPrintAddWarPowerVal = allSoulPrintAddWarPowerVal + cursoulPrintConfig.Score end end end end return allSoulPrintAddWarPowerVal -- local addAllProVal = {} -- local singleHeroProVal,lvProVal,allHeroProVal,specialProVal -- local curHeroData = HeroManager.GetSingleHeroData(_heroId) -- if curHeroData then -- if(table.nums(curHeroData.soulPrintList) >= 1) then -- for i = 1, #curHeroData.soulPrintList do -- local cursoulPrintConfig = equipConfig[curHeroData.soulPrintList[i].equipId] -- if cursoulPrintConfig then -- --基础属性计算 -- local soulPrintPropertyList = cursoulPrintConfig.Property -- if soulPrintPropertyList and #soulPrintPropertyList > 0 then -- for i,v in pairs(soulPrintPropertyList) do -- if(addAllProVal[v[1]]) then -- addAllProVal[v[1]]=v[2]+addAllProVal[v[1]] -- else -- addAllProVal[v[1]]=v[2] -- end -- end -- end -- --被动技能计算 -- if cursoulPrintConfig.PassiveSkill then -- --单体加成 --单体等级限制加成 --团体加成 --减乘 -- singleHeroProVal,lvProVal,allHeroProVal,specialProVal = this.CalculatePassiveSkillsValList(WarPowerType.SoulPrint,cursoulPrintConfig.PassiveSkill) -- end -- end -- end -- end -- end -- if singleHeroProVal and LengthOfTable(singleHeroProVal) > 0 then -- for i,v in pairs(singleHeroProVal) do -- if addAllProVal[i] then -- addAllProVal[i] = addAllProVal[i] + v -- else -- addAllProVal[i] = v -- end -- end -- end -- return addAllProVal,lvProVal,allHeroProVal,specialProVal end --英雄身上宝器属性计算 local function CalculateEquipTreaSureAddVal(_heroId) local addAllProVal = {} local minLv local mainRefineLv local curHeroData = HeroManager.GetSingleHeroData(_heroId) if curHeroData then if #curHeroData.jewels > 0 then for i = 1, #curHeroData.jewels do local did = curHeroData.jewels[i] local curEuipTreaSureData = EquipTreasureManager.GetSingleTreasureByIdDyn(did) or ExpeditionManager.GetSingleTreasureByIdDyn(did) if curEuipTreaSureData then local curEuipTreaSureConfig = jewelConfig[curEuipTreaSureData.id] for _, configInfo in ConfigPairs(jewelRankupConfig) do --强化的属性 if configInfo.PoolID == curEuipTreaSureConfig.LevelupPool and configInfo.Type == 1 and configInfo.Level == curEuipTreaSureData.lv then for j = 1, #configInfo.Property do if addAllProVal[configInfo.Property[j][1]] then addAllProVal[configInfo.Property[j][1]] = addAllProVal[configInfo.Property[j][1]] + configInfo.Property[j][2] else addAllProVal[configInfo.Property[j][1]] = configInfo.Property[j][2] end end end --精炼的属性 if configInfo.PoolID == curEuipTreaSureConfig.RankupPool and configInfo.Type == 2 and configInfo.Level == curEuipTreaSureData.refineLv then for j = 1, #configInfo.Property do if addAllProVal[configInfo.Property[j][1]] then addAllProVal[configInfo.Property[j][1]] = addAllProVal[configInfo.Property[j][1]] + configInfo.Property[j][2] else addAllProVal[configInfo.Property[j][1]] = configInfo.Property[j][2] end end end end if #curHeroData.jewels > 1 then --取 强化 精炼 最小值 if minLv then if curEuipTreaSureData.lv < minLv then minLv = curEuipTreaSureData.lv end else minLv = curEuipTreaSureData.lv end if mainRefineLv then if curEuipTreaSureData.refineLv < mainRefineLv then mainRefineLv = curEuipTreaSureData.refineLv end else mainRefineLv = curEuipTreaSureData.refineLv end end end end --math.min() --取 强化 精炼 共鸣属性 if #curHeroData.jewels > 1 then local lvjewelResonanceConfig local refineLvjewelResonanceConfig for _, curjewelResonanceConfig in ConfigPairs(jewelResonanceConfig) do if lvjewelResonanceConfig then if curjewelResonanceConfig.Type == 1 and curjewelResonanceConfig.Level <= minLv and curjewelResonanceConfig.Id > lvjewelResonanceConfig.Id then lvjewelResonanceConfig = curjewelResonanceConfig end else if curjewelResonanceConfig.Type == 1 and curjewelResonanceConfig.Level <= minLv then lvjewelResonanceConfig = curjewelResonanceConfig end end if refineLvjewelResonanceConfig then if curjewelResonanceConfig.Type == 2 and curjewelResonanceConfig.Level <= mainRefineLv and curjewelResonanceConfig.Id > refineLvjewelResonanceConfig.Id then refineLvjewelResonanceConfig = curjewelResonanceConfig end else if curjewelResonanceConfig.Type == 2 and curjewelResonanceConfig.Level <= mainRefineLv then refineLvjewelResonanceConfig = curjewelResonanceConfig end end end -- if lvjewelResonanceConfig then for j = 1, #lvjewelResonanceConfig.Property do if addAllProVal[lvjewelResonanceConfig.Property[j][1]] then addAllProVal[lvjewelResonanceConfig.Property[j][1]] = addAllProVal[lvjewelResonanceConfig.Property[j][1]] + lvjewelResonanceConfig.Property[j][2] else addAllProVal[lvjewelResonanceConfig.Property[j][1]] = lvjewelResonanceConfig.Property[j][2] end end end if refineLvjewelResonanceConfig then for j = 1, #refineLvjewelResonanceConfig.Property do if addAllProVal[refineLvjewelResonanceConfig.Property[j][1]] then addAllProVal[refineLvjewelResonanceConfig.Property[j][1]] = addAllProVal[refineLvjewelResonanceConfig.Property[j][1]] + refineLvjewelResonanceConfig.Property[j][2] else addAllProVal[refineLvjewelResonanceConfig.Property[j][1]] = refineLvjewelResonanceConfig.Property[j][2] end end end end end end return addAllProVal end --计算所有英雄被动技能的属性值 local function CalculateHeroPassiveSkillProAddVal(_type, _heroId, _breakId, _upStarId,teamCurPropertyName) local singleHeroProVal, lvProVal, allHeroProVal, specialProVal local curHeroData = HeroManager.GetSingleHeroData(_heroId) if curHeroData then local allOpenPassiveSkillIds = {} if _type == 1 then allOpenPassiveSkillIds = this.GetAllPassiveSkillIds(curHeroData.heroConfig, curHeroData.breakId, curHeroData.upStarId) else allOpenPassiveSkillIds = this.GetAllPassiveSkillIds(curHeroData.heroConfig, _breakId, _upStarId) end --单体加成 --单体等级限制加成 --团体加成 --减乘 singleHeroProVal, lvProVal, allHeroProVal, specialProVal = this.CalculatePassiveSkillsValList(WarPowerType.Hero, allOpenPassiveSkillIds,teamCurPropertyName,curHeroData) end return singleHeroProVal, lvProVal, allHeroProVal, specialProVal end --计算其他属性值 (角色基础属性+角色升级属性)* 星级系数+升星变量+进阶总属性 --proValue 初始属性 rebirth=0 化境增长 lvNum 对应属性等级 breakNum 突破系数 function this.CalculateProVal(proValue, lvNum, breakId, upStarId, proId) --LogError("breakId upStarId "..breakId.." "..upStarId.." "..lvNum) local curProLvNum = 0 if heroLevelConfig[lvNum] then for i = 1, #heroLevelConfig[lvNum].CharacterLevelPara do if heroLevelConfig[lvNum].CharacterLevelPara[i][1] == proId then curProLvNum = heroLevelConfig[lvNum].CharacterLevelPara[i][2] end end end local breakRankupPara = {0, 0, 0} local upStarRankupPara = {0, 0, 0} if heroRankUpConfig[breakId] then for i = 1, #heroRankUpConfig[breakId].RankupPara do if heroRankUpConfig[breakId].RankupPara[i][1] == proId then breakRankupPara = heroRankUpConfig[breakId].RankupPara[i] end end end if heroRankUpConfig[upStarId] then for i = 1, #heroRankUpConfig[upStarId].RankupPara do if heroRankUpConfig[upStarId].RankupPara[i][1] == proId then upStarRankupPara = heroRankUpConfig[upStarId].RankupPara[i] end end end if upStarRankupPara[3] == 0 then --星级系数 ==0 让其 == 10000 万分比 upStarRankupPara[3] = 10000 end --LogError("proValue "..proValue.." curProLvNum "..curProLvNum.." upStarRankupPara[3]/10000 "..upStarRankupPara[3]/10000 .." upStarRankupPara[2] "..upStarRankupPara[2].." breakRankupPara[2] "..breakRankupPara[2]) return math.floor((proValue + curProLvNum) * upStarRankupPara[3] / 10000 + upStarRankupPara[2] + breakRankupPara[2]) end --计算其他属性值 角色面板属性*(1+升星增加值/10000)*等级系数+角色面板属性*突破系数/10000 --proValue 初始属性 rebirth=0 化境增长 lvNum 等级系数 breakNum 突破系数 --local function CalculateProVal2(proValue, lvNum, breakId,upStarId) -- local breakRankupPara = 0 -- local upStarRankupPara = 0 -- if heroRankUpConfig[breakId] then -- breakRankupPara = heroRankUpConfig[breakId].RankupPara -- end -- if heroRankUpConfig[upStarId] then -- upStarRankupPara = heroRankUpConfig[upStarId].RankupPara -- end -- --Log("proValue "..proValue.." upStarRankupPara "..upStarRankupPara.." lvNum "..lvNum.." breakRankupPara "..breakRankupPara) -- -- return math.floor(proValue * (1 + upStarRankupPara/10000) * lvNum+proValue*breakRankupPara/10000) --end --计算speed属性值 0#0#10#1 abcd公式 x=breakId 刚才公式算出的数据 + 速度升级参数 * speed基础属性 --proValue速度基础属性 lv等级 local function CalculateSpeedProVal(proValue, breakId, speedNum) --local SpeedFormulaData = ConfigManager.GetConfig(ConfigName.GameSetting) --local curSpeedFormulaData = SpeedFormulaData[1].SpeedFormula --breakId = breakId % 100 --local val = math.floor(((curSpeedFormulaData[1] * math.pow(breakId, 3) + curSpeedFormulaData[2] * math.pow(breakId, 2) + curSpeedFormulaData[3] * breakId + curSpeedFormulaData[4]) + proValue * speedNum)) return 0 --val end --计算其他属性值 初始属性*(1+化境增长)*等级系数 + 初始属性*突破系数 --proValue 初始属性 rebirth 化境增长 lvNum 等级系数 breakNum 突破系数 function this.CalculateProValMap(_heroDid, _proType) Log(Language[11113] .. _proType) --proValue,rebirth,lvNum,breakId local curheroData = {} if heroDatas[_heroDid] then curheroData = heroDatas[_heroDid] end --local speedNum=heroLevelConfig[curheroData.lv].SpeedLevelPara local allEquipAddProVal = {} allEquipAddProVal = CalculateHeroUpEquipsProAddVal(curheroData.dynamicId) local allPokemonPeiJianAddPro = DiffMonsterManager.CalculateAllPokemonPeiJiAllProAddVal(curheroData.heroConfig.Profession) --添加所有异妖配件的属性 for k, v in pairs(allPokemonPeiJianAddPro) do if allEquipAddProVal[k] then allEquipAddProVal[k] = allEquipAddProVal[k] + v end end local proValue = 0 if _proType == HeroProType.Attack then proValue = curheroData.attack elseif _proType == HeroProType.Hp then proValue = curheroData.hp elseif _proType == HeroProType.PhysicalDefence then proValue = curheroData.pDef elseif _proType == HeroProType.MagicDefence then proValue = curheroData.mDef elseif _proType == HeroProType.Speed then proValue = curheroData.speed end if _proType == HeroProType.Speed then --return CalculateSpeedProVal(proValue,curheroData.breakId,speedNum)+allEquipAddProVal[_proType] else return this.CalculateProVal(proValue, curheroData.lv, curheroData.breakId, curheroData.upStarId, _proType) + allEquipAddProVal[_proType] end end --计算战斗力 local function CalculateWarForce(powerVal) local powerEndVal = 0 for i, v in pairs(powerVal) do if v > 0 then powerEndVal = powerEndVal + v * HeroManager.heroPropertyScore[i] end end return math.floor(powerEndVal) end --计算战斗力 local function CalculateSingleModuleWarForce(powerVal) local powerEndVal = 0 for i, v in pairs(powerVal) do if v > 0 then local curProConfig = propertyConfig[i] if curProConfig and curProConfig.TargetPropertyId > 0 then powerVal[curProConfig.TargetPropertyId] = math.floor( powerVal[curProConfig.TargetPropertyId] + powerVal[curProConfig.TargetPropertyId] * powerVal[i] / 10000 ) end if curProConfig and curProConfig.Style == 2 then powerVal[i] = powerVal[i] / 10000 end end end for i, v in pairs(powerVal) do if v > 0 then powerEndVal = powerEndVal + v * HeroManager.heroPropertyScore[i] end end return math.floor(powerEndVal) end ---PassiveSkillLogicConfig 表里EffectiveRange 2 3 为战前生效直接加成属性 2 为个体 3 为团体 ---PassiveSkillLogicConfig 表里Type 90 个体加成 94 全体加成 171 对多少级英雄加成 加成公式1加算 2乘算 3减算 4乘减算 ---90 例子 5#0.05#2 第一位对应PropertyConfig表PropertyIdInBattle 第二位 加成具体数值是百分百或者绝对值看PropertyConfig表 第三位 公式 ---94 例子 0.05#17#2 百分比 PropertyConfig表PropertyIdInBattle属性 公式 ---171 例子 3#9 100后每增加一级加 PropertyConfig表PropertyIdInBattle属性3 9值 ---129 例子 3#0.1#5#1 第一位英雄元素 第二位 加成具体数值是百分百或者绝对值看PropertyConfig表 第三位对应PropertyConfig表PropertyIdInBattle 第四位 公式 ---前端计算逻辑 先把所有被动技团体加成 和 被动技个人加成都提出来 然后计算英雄身上所有绝对值 + 所有被动技团体绝对值 + 所有被动技个人加成绝对值 --- * (1 + 英雄身上万分比加成 + 普通团体被动技百分比 + 普通个人被动技百分比 + 个体等级百分比加成 ) * (1 - 4乘减算 百分比) --- --- --- function this.CalculatePassiveSkillsValList(index, skillids,teamCurPropertyName,curHeroData) for k, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.PropertyConfig)) do this.allProVal[index].singleHeroProVal[k] = 0 this.allProVal[index].lvProVal[k] = 0 this.allProVal[index].allHeroProVal[k] = 0 this.allProVal[index].specialProVal[k] = 0 end for i = 1, #skillids do local skillid = skillids[i] if passiveSkillLogicConfig[skillid] then local curSkillData = passiveSkillLogicConfig[skillid] --LogError("skillid "..skillid) if curSkillData.EffectiveRange == 2 then --战前个人 if curSkillData.Type == 90 then this.GetProAndValByFormula( this.allProVal[index].singleHeroProVal, this.allProVal[index].specialProVal, curSkillData.Value[1], curSkillData.Value[2], curSkillData.Value[3], curHeroData ) elseif curSkillData.Type == 94 then this.GetProAndValByFormula( this.allProVal[index].singleHeroProVal, this.allProVal[index].specialProVal, curSkillData.Value[2], curSkillData.Value[1], curSkillData.Value[3] ) elseif curSkillData.Type == 171 then this.GetProAndValByFormula( this.allProVal[index].lvProVal, this.allProVal[index].specialProVal, curSkillData.Value[1], curSkillData.Value[2] ) end elseif curSkillData.EffectiveRange == 3 then --战前团体 if curSkillData.Type == 90 then this.GetProAndValByFormula( this.allProVal[index].allHeroProVal, this.allProVal[index].specialProVal, curSkillData.Value[1], curSkillData.Value[2], curSkillData.Value[3] ) elseif curSkillData.Type == 94 then this.GetProAndValByFormula( this.allProVal[index].allHeroProVal, this.allProVal[index].specialProVal, curSkillData.Value[2], curSkillData.Value[1], curSkillData.Value[3] ) elseif curSkillData.Type == 129 then if teamCurPropertyName and teamCurPropertyName == curSkillData.Value[1] then -- LogGreen("teamCurPropertyName "..teamCurPropertyName .." "..curSkillData.Value[1]) this.GetProAndValByFormula( this.allProVal[index].allHeroProVal, this.allProVal[index].specialProVal, curSkillData.Value[3], curSkillData.Value[2], curSkillData.Value[4], curSkillData.Value[1] ) elseif not teamCurPropertyName then -- LogGreen("not teamCurPropertyName") this.GetProAndValByFormula( this.allProVal[index].allHeroProVal, this.allProVal[index].specialProVal, curSkillData.Value[3], curSkillData.Value[2], curSkillData.Value[4], curSkillData.Value[1] ) end elseif curSkillData.Type == 171 then --目前没有 --this.GetProAndValByFormula(lvProVal,curSkillData,specialProVal) end end else LogError(Language[11114] .. skillid) end end return this.allProVal[index].singleHeroProVal, this.allProVal[index].lvProVal, this.allProVal[index].allHeroProVal, this.allProVal[ index ].specialProVal end function this.GetProAndValByFormula(proTable, specialProVal, curProId, curProVal, curProlGs,heroPro) if curProlGs == 1 then --公式 (绝对值加a+b) local curProConfig = ConfigManager.GetConfigDataByKey(ConfigName.PropertyConfig, "PropertyIdInBattle", curProId) if propertyConfig[curProConfig.PropertyId].Style == 1 then if proTable[curProConfig.PropertyId] then proTable[curProConfig.PropertyId] = proTable[curProConfig.PropertyId] + curProVal else proTable[curProConfig.PropertyId] = curProVal end else if proTable[curProConfig.PropertyId] then proTable[curProConfig.PropertyId] = proTable[curProConfig.PropertyId] + curProVal * 10000 else proTable[curProConfig.PropertyId] = curProVal * 10000 end end elseif curProlGs == 2 then --公式 (百分比加a+oa*b) local curProConfig1 = ConfigManager.GetConfigDataByKey(ConfigName.PropertyConfig, "PropertyIdInBattle", curProId) local curProConfig2 = ConfigManager.TryGetConfigDataByKey(ConfigName.PropertyConfig, "TargetPropertyId", curProConfig1.PropertyId) if curProConfig2 then if proTable[curProConfig2.PropertyId] then proTable[curProConfig2.PropertyId] = proTable[curProConfig2.PropertyId] + curProVal * 10000 else proTable[curProConfig2.PropertyId] = curProVal * 10000 end else if proTable[curProConfig1.PropertyId] then proTable[curProConfig1.PropertyId] = proTable[curProConfig1.PropertyId] + curProVal * 10000 else proTable[curProConfig1.PropertyId] = curProVal * 10000 end end elseif curProlGs == 3 then --公式 (绝对值减a-b) local curProConfig = ConfigManager.GetConfigDataByKey(ConfigName.PropertyConfig, "PropertyIdInBattle", curProId) if propertyConfig[curProConfig.PropertyId].Style == 1 then if proTable[curProConfig.PropertyId] then proTable[curProConfig.PropertyId] = proTable[curProConfig.PropertyId] - curProVal else proTable[curProConfig.PropertyId] = curProVal end else if proTable[curProConfig.PropertyId] then proTable[curProConfig.PropertyId] = proTable[curProConfig.PropertyId] - curProVal * 10000 else proTable[curProConfig.PropertyId] = curProVal * 10000 end end elseif curProlGs == 4 then --公式 (百分比减a*(1-b)) --目前没有 --specialProVal local curProConfig = ConfigManager.GetConfigDataByKey(ConfigName.PropertyConfig, "PropertyIdInBattle", curProId) local singleProInfo = {proId =curProConfig.PropertyId ,value = curProVal} if heroPro.MLSproList then table.insert(heroPro.MLSproList,singleProInfo) end else --171 无公式 local curProConfig = ConfigManager.GetConfigDataByKey(ConfigName.PropertyConfig, "PropertyIdInBattle", curProId) if propertyConfig[curProConfig.PropertyId].Style == 1 then if proTable[curProConfig.PropertyId] then proTable[curProConfig.PropertyId] = proTable[curProConfig.PropertyId] + curProVal else proTable[curProConfig.PropertyId] = curProVal end else if proTable[curProConfig.PropertyId] then proTable[curProConfig.PropertyId] = proTable[curProConfig.PropertyId] + curProVal * 10000 else proTable[curProConfig.PropertyId] = curProVal * 10000 end end end end --团队加成 function this.GetAllHeroTeamAddProVal(teamHeroInfos,curteamHeroDid) local teamProVal = {} --英雄 法宝 魂印 被动技能 local heroAllNum = 0 for i = 1, 6 do if teamHeroInfos[i] then heroAllNum = heroAllNum + 1 local heroSkillSingleHeroProVal, heroSkillLvProVal, heroSkillAllHeroProVal, heroSkillSpecialProVal = CalculateHeroPassiveSkillProAddVal(1, teamHeroInfos[i].heroId,nil,nil, curteamHeroDid and HeroManager.GetSingleHeroData(curteamHeroDid).heroConfig.PropertyName or nil) local falismanSingleHeroProVal, falismanLvProVal, falismanAllHeroProVal, falismanSpecialProVal = CalculateHeroUpTalismanProAddVal(teamHeroInfos[i].heroId,nil,nil, curteamHeroDid and HeroManager.GetSingleHeroData(curteamHeroDid).heroConfig.PropertyName or nil) local soulPrinSingleHeroProVal,soulPrinLvProVal,soulPrinAllHeroProVal,soulPrinSpecialProVal = CalculateSoulPrintAddVal(teamHeroInfos[i].heroId) local heroSkinSingleProVal, heroSkinAllHeroProVal = HeroSkinManager.CaculateSkinProVal(teamHeroInfos[i].heroId) this.DoubleTableCompound(teamProVal, heroSkillAllHeroProVal) this.DoubleTableCompound(teamProVal, falismanAllHeroProVal) this.DoubleTableCompound(teamProVal, soulPrinAllHeroProVal) this.DoubleTableCompound(teamProVal, heroSkinAllHeroProVal) end end --灵兽编队加成 local pokemonFormationAllHeroProVal = PokemonManager.GetPokemonFormationTeamAddPro(heroAllNum) this.DoubleTableCompound(teamProVal, pokemonFormationAllHeroProVal) --灵兽羁绊加成 local pokemonFetterAddPro = PokemonManager.GetAllPokemonFetterAddPros() this.DoubleTableCompound(teamProVal, pokemonFetterAddPro) --光环加成 local aureoleProAdd = FormationManager.GetCurFormationElementAdd(teamHeroInfos) this.DoubleTableCompound(teamProVal, aureoleProAdd) return teamProVal end --计算英雄身上所有属性加成(包括装备就、异妖的加成) --_type==1 计算当前英雄的所有属性 _type==2 根据_heroDid之后_breakId传过来的值进行计算 _isAllHeroProVal==true 团体加成综合 用字段_allHeroProVal function this.CalculateHeroAllProValList(_type, _heroDid, isWar, _breakId, _upStarId, _isAllHeroProVal, _allHeroProVal,formationHeroNum) local curHeroData = this.GetSingleHeroData(_heroDid) or _heroDid local curLvNum = curHeroData.lv -- heroLevelConfig[curHeroData.lv].CharacterLevelPara --local speedNum = heroLevelConfig[curHeroData.lv].SpeedLevelPara --if _type == 1 then -- LogError("计算战力英雄数据打印1 lv _breakId _upStarId "..curHeroData.lv.." "..curHeroData.breakId.." "..curHeroData.upStarId) --else -- LogError("计算战力英雄数据打印2 lv _breakId _upStarId "..curHeroData.lv.." ".._breakId.." ".._upStarId) --end --添加该英雄装备的属性 local allEquipScore = PlayerManager.GetSingHeroAllEquipSkillListScore(curHeroData) --获取单个英雄装备被动技能累计评分 local allAddProVal = {} --单体所有属性加成 local lvProVal = {} --100等级所有属性加成 升一级 加一次 local allHeroProVal = _allHeroProVal or {} --团体所有属性加成 local specialProVal = {} --4公式特殊(减乘)所有属性加成 allAddProVal = CalculateHeroUpEquipsProAddVal(curHeroData.dynamicId) --for i, v in pairs(allAddProVal) do -- if v > 0 then -- LogError("装备加成 "..i.." "..v) -- end --end --异妖配件的加成 local allPokemonPeiJianAddPro = DiffMonsterManager.CalculateAllPokemonPeiJiAllProAddVal(curHeroData.heroConfig.Profession) --for i, v in pairs(allPokemonPeiJianAddPro) do -- if v > 0 then -- LogError("异妖配件的加成 "..i.." "..v) -- end --end --科技树加成 local treeAllProAdd = WorkShopManager.HeroCalculateTreeWarForce(curHeroData.heroConfig.Profession) --for i, v in pairs(treeAllProAdd) do -- if v > 0 then -- LogError("科技树加成 "..i.." "..v) -- end --end --公会技能加成 local guildSkillAllProAdd = GuildSkillManager.HeroCalculateGuildSkillWarForce(curHeroData.heroConfig.Profession) --for i, v in pairs(guildSkillAllProAdd) do -- if v > 0 then -- LogError("公会技能加成 "..i.." "..v) -- end --end --英雄被动技能属性加成 local heroSkillSingleHeroProVal, heroSkillLvProVal, heroSkillAllHeroProVal, heroSkillSpecialProVal = {}, {}, {}, {} if _type == 1 then heroSkillSingleHeroProVal, heroSkillLvProVal, heroSkillAllHeroProVal, heroSkillSpecialProVal = CalculateHeroPassiveSkillProAddVal(_type, curHeroData.dynamicId) elseif _type == 2 then heroSkillSingleHeroProVal, heroSkillLvProVal, heroSkillAllHeroProVal, heroSkillSpecialProVal = CalculateHeroPassiveSkillProAddVal(_type, curHeroData.dynamicId, _breakId, _upStarId) end -- if heroSkillSingleHeroProVal and LengthOfTable(heroSkillSingleHeroProVal) > 0 then -- for i, v in pairs(heroSkillSingleHeroProVal) do -- if v > 0 then -- LogError("英雄被动技的单体属性加成 "..i.." "..v) -- end -- end -- end -- if heroSkillLvProVal and LengthOfTable(heroSkillLvProVal) > 0 then -- for i, v in pairs(heroSkillLvProVal) do -- if v > 0 then -- LogError("英雄被动技的等极限值属性加成 "..i.." "..v) -- end -- end -- end -- if heroSkillAllHeroProVal and LengthOfTable(heroSkillAllHeroProVal) > 0 then -- for i, v in pairs(heroSkillAllHeroProVal) do -- if v > 0 then -- LogError("英雄被动技的团体属性加成 "..i.." "..v) -- end -- end -- end --法宝的属性加成 falismanProAdd local falismanSingleHeroProVal, falismanLvProVal, falismanAllHeroProVal, falismanSpecialProVal = {}, {}, {}, {} if _type == 1 then falismanSingleHeroProVal, falismanLvProVal, falismanAllHeroProVal, falismanSpecialProVal = CalculateHeroUpTalismanProAddVal(curHeroData.dynamicId) elseif _type == 2 then falismanSingleHeroProVal, falismanLvProVal, falismanAllHeroProVal, falismanSpecialProVal = CalculateHeroUpTalismanProAddVal(curHeroData.dynamicId, _breakId, _upStarId) end --if falismanSingleHeroProVal and LengthOfTable(falismanSingleHeroProVal) > 0 then -- for i, v in pairs(falismanSingleHeroProVal) do -- if v > 0 then -- LogError("法宝的单体属性加成 "..i.." "..v) -- end -- end --end --if falismanLvProVal and LengthOfTable(falismanLvProVal) > 0 then -- for i, v in pairs(falismanLvProVal) do -- if v > 0 then -- LogError("法宝的等极限值属性加成 "..i.." "..v) -- end -- end --end --if falismanAllHeroProVal and LengthOfTable(falismanAllHeroProVal) > 0 then -- for i, v in pairs(falismanAllHeroProVal) do -- if v > 0 then -- LogError("法宝的团体属性加成 "..i.." "..v) -- end -- end --end --魂印的属性加成 local singleHeroSoulPrintProVal,lvSoulPrintProVal,allHeroSoulPrintProVal,specialSoulPrintProVal = CalculateSoulPrintAddVal(curHeroData.dynamicId) local allSoulPrintAddWarPowerVal = CalculateSoulPrintAddVal2(curHeroData.dynamicId) -- LogError("魂印的单体属性加成 "..allSoulPrintAddWarPowerVal) --宝器加成 宝器本身属性 + 宝器激活的强化共鸣 和 精炼共鸣 local equipTreasureAddPro = CalculateEquipTreaSureAddVal(curHeroData.dynamicId) --if equipTreasureAddPro and LengthOfTable(equipTreasureAddPro) > 0 then -- for i, v in pairs(equipTreasureAddPro) do -- if v > 0 then -- LogError("宝器加成 "..i.." "..v) -- end -- end --end --玩家称号 皮肤 坐骑属性加成 local playerDcorateAdd = PlayerManager.CalculatePlayerDcorateProAddVal() --if playerDcorateAdd and LengthOfTable(playerDcorateAdd) > 0 then -- for i, v in pairs(playerDcorateAdd) do -- if v > 0 then -- LogError("玩家称号 皮肤 坐骑属性加成 "..i.." "..v) -- end -- end --end --编队光环加成 local teamAddPro = FormationManager.GetCurFormationElementAddByType(FormationTypeDef.FORMATION_NORMAL, curHeroData.dynamicId) --if teamAddPro and LengthOfTable(teamAddPro) > 0 then -- for i, v in pairs(teamAddPro) do -- if v > 0 then -- LogError("编队光环加成 "..i.." "..v) -- end -- end --end -- Vip加成 暂时注释 local vipAddPro = VipManager.GetAddPro() --if vipAddPro and LengthOfTable(vipAddPro) > 0 then -- for i, v in pairs(vipAddPro) do -- if v > 0 then -- LogError("Vip加成 "..i.." "..v) -- end -- end --end local heroSkinSingleProVal, heroSkinAllHeroProVal = HeroSkinManager.CaculateSkinProVal(curHeroData.dynamicId) this.DoubleTableCompound(allAddProVal, heroSkinSingleProVal) this.DoubleTableCompound(allAddProVal, heroSkinAllHeroProVal) --灵兽 现在只在编队战力中计算 因为单个英雄可以上多个编队 local pokemonFormationAllHeroProVal = {} if formationHeroNum and formationHeroNum > 0 then pokemonFormationAllHeroProVal = PokemonManager.GetPokemonFormationTeamAddPro(formationHeroNum) end --if pokemonFormationAllHeroProVal and LengthOfTable(pokemonFormationAllHeroProVal) > 0 then -- for i, v in pairs(pokemonFormationAllHeroProVal) do -- if v > 0 then -- LogError("灵兽加成 "..i.." "..v) -- end -- end --end --灵兽羁绊 local pokemonFetterAddPro = PokemonManager.GetAllPokemonFetterAddPros() --灵兽羁绊单加战力 暂时去掉 -- local allPokemonFetterAddWarPowerVal = PokemonManager.GetAllPokemonFetterAddProsSWarPower()--allSoulPrintAddWarPowerVal-- -- LogError("灵兽羁绊加成静态战力 "..allPokemonFetterAddWarPowerVal) -- if pokemonFetterAddPro and LengthOfTable(pokemonFetterAddPro) > 0 then -- for i, v in pairs(pokemonFetterAddPro) do -- if v > 0 then -- LogError("灵兽羁绊加成 "..i.." "..v) -- end -- end -- end --单体所有属性合并 this.DoubleTableCompound(allAddProVal, allPokemonPeiJianAddPro) this.DoubleTableCompound(allAddProVal, guildSkillAllProAdd) this.DoubleTableCompound(allAddProVal, falismanSingleHeroProVal) this.DoubleTableCompound(allAddProVal,singleHeroSoulPrintProVal) this.DoubleTableCompound(allAddProVal, playerDcorateAdd) this.DoubleTableCompound(allAddProVal, heroSkillSingleHeroProVal) this.DoubleTableCompound(allAddProVal, equipTreasureAddPro) this.DoubleTableCompound(allAddProVal, vipAddPro) --100等级所有属性合并 this.DoubleTableCompound(lvProVal, falismanLvProVal) this.DoubleTableCompound(lvProVal,lvSoulPrintProVal) this.DoubleTableCompound(lvProVal, heroSkillLvProVal) --团体所有属性合并 if not _isAllHeroProVal then this.DoubleTableCompound(allHeroProVal, falismanAllHeroProVal) this.DoubleTableCompound(allHeroProVal,allHeroSoulPrintProVal) this.DoubleTableCompound(allHeroProVal, heroSkillAllHeroProVal) this.DoubleTableCompound(allHeroProVal, teamAddPro) this.DoubleTableCompound(allHeroProVal, pokemonFetterAddPro) this.DoubleTableCompound(allHeroProVal, pokemonFormationAllHeroProVal) end -- for index, value in pairs(allHeroProVal) do -- if value > 0 then -- LogError("allHeroProVal 最终 加成 "..index.." "..value) -- end -- end --4公式特殊(减乘)所有属性加成 this.DoubleTableCompound(specialProVal, falismanSpecialProVal) this.DoubleTableCompound(specialProVal,specialSoulPrintProVal) this.DoubleTableCompound(specialProVal, heroSkillSpecialProVal) --100等级所有属性合并 local forNum = curLvNum - 100 if forNum > 0 then for k = 1, forNum do this.DoubleTableCompound(allAddProVal, lvProVal) end end --团体所有属性合并 this.DoubleTableCompound(allAddProVal, allHeroProVal) --4公式特殊 --for i, v in pairs(allAddProVal) do -- if v > 0 then -- LogError("所有属性综合完allAddProVal 1 "..i.." "..v) -- end --end --Log("proValue * (1 + upStarRankupPara/10000) * lvNum+proValue*breakRankupPara/10000") if _type == 1 then --allAddProVal[HeroProType.Speed]=CalculateSpeedProVal(curHeroData.speed,curHeroData.breakId,speedNum)+allAddProVal[HeroProType.Speed] --allAddProVal[HeroProType.WarPower]=allEquipScore+CalculateWarForce( allAddProVal[HeroProType.Hp], allAddProVal[HeroProType.PhysicalDefence],allAddProVal[HeroProType.MagicDefence],allAddProVal[HeroProType.Attack],allAddProVal[HeroProType.CritFactor],allAddProVal[HeroProType.Hit],allAddProVal[HeroProType.Dodge],allAddProVal[HeroProType.DamageBocusFactor],allAddProVal[HeroProType.DamageReduceFactor],allAddProVal[HeroProType.Speed]) allAddProVal[HeroProType.Attack] = this.CalculateProVal( curHeroData.attack, curLvNum, curHeroData.breakId, curHeroData.upStarId, HeroProType.Attack ) + allAddProVal[HeroProType.Attack] allAddProVal[HeroProType.Hp] = this.CalculateProVal(curHeroData.hp, curLvNum, curHeroData.breakId, curHeroData.upStarId, HeroProType.Hp) + allAddProVal[HeroProType.Hp] allAddProVal[HeroProType.PhysicalDefence] = this.CalculateProVal( curHeroData.pDef, curLvNum, curHeroData.breakId, curHeroData.upStarId, HeroProType.PhysicalDefence ) + allAddProVal[HeroProType.PhysicalDefence] allAddProVal[HeroProType.MagicDefence] = this.CalculateProVal( curHeroData.mDef, curLvNum, curHeroData.breakId, curHeroData.upStarId, HeroProType.MagicDefence ) + allAddProVal[HeroProType.MagicDefence] elseif _type == 2 then allAddProVal[HeroProType.Attack] = this.CalculateProVal(curHeroData.attack, curLvNum, _breakId, _upStarId, HeroProType.Attack) + allAddProVal[HeroProType.Attack] allAddProVal[HeroProType.Hp] = this.CalculateProVal(curHeroData.hp, curLvNum, _breakId, _upStarId, HeroProType.Hp) + allAddProVal[HeroProType.Hp] allAddProVal[HeroProType.PhysicalDefence] = this.CalculateProVal(curHeroData.pDef, curLvNum, _breakId, _upStarId, HeroProType.PhysicalDefence) + allAddProVal[HeroProType.PhysicalDefence] allAddProVal[HeroProType.MagicDefence] = this.CalculateProVal(curHeroData.mDef, curLvNum, _breakId, _upStarId, HeroProType.MagicDefence) + allAddProVal[HeroProType.MagicDefence] --allAddProVal[HeroProType.Speed]=CalculateSpeedProVal(curHeroData.speed,_breakId,speedNum)+allAddProVal[HeroProType.Speed] --allAddProVal[HeroProType.WarPower]=allEquipScore+CalculateWarForce( allAddProVal[HeroProType.Hp], allAddProVal[HeroProType.PhysicalDefence],allAddProVal[HeroProType.MagicDefence],allAddProVal[HeroProType.Attack],allAddProVal[HeroProType.CritFactor],allAddProVal[HeroProType.Hit],allAddProVal[HeroProType.Dodge],allAddProVal[HeroProType.DamageBocusFactor],allAddProVal[HeroProType.DamageReduceFactor],allAddProVal[HeroProType.Speed]) end --for i, v in pairs(allAddProVal) do -- if v > 0 then -- LogError("基础属性综合前端算allAddProVal 2 "..i.." "..v) -- end --end for k, v in pairs(allAddProVal) do local curProConfig = propertyConfig[k] if curHeroData.heroConfig.SecondaryFactor and isWar then for i = 1, #curHeroData.heroConfig.SecondaryFactor do if k == curHeroData.heroConfig.SecondaryFactor[i][1] then allAddProVal[k] = allAddProVal[k] + curHeroData.heroConfig.SecondaryFactor[i][2] end end end --计算装备异妖 特殊百分比加成 (在英雄自身、装备、异妖 绝对值属性算完之后 最后计算百分比加成) if curProConfig and allAddProVal[k] > 0 and curProConfig.TargetPropertyId > 0 then if k ~= 69 and k ~= 70 then allAddProVal[curProConfig.TargetPropertyId] = propertyConfig[curProConfig.TargetPropertyId].Style == 1 and math.floor(allAddProVal[curProConfig.TargetPropertyId] + allAddProVal[curProConfig.TargetPropertyId] * allAddProVal[k] / 10000) or allAddProVal[curProConfig.TargetPropertyId] + allAddProVal[curProConfig.TargetPropertyId] * allAddProVal[k] / 10000 end end --战斗里面 PropertyConfig里Style字段,2类型的统一需要除以100在战斗里面 if curProConfig and allAddProVal[k] > 0 and isWar and curProConfig.Style == 2 then allAddProVal[k] = allAddProVal[k] / 10000 elseif curProConfig and allAddProVal[k] > 0 and isWar == false and curProConfig.Style == 2 then allAddProVal[k] = allAddProVal[k] / 100 end --战斗里面 PropertyConfig里面 IfFormula==1,策划投放的是属性绝对值,转化为战斗里面的是属性系数,转化公式为: 属性系数=属性绝对值*0.1/(等级+10)/100 if curProConfig and allAddProVal[k] > 0 and isWar and curProConfig.IfFormula == 1 then allAddProVal[k] = math.floor(allAddProVal[k] * 0.1 / (curHeroData.lv + 10) / 10000) elseif curProConfig and allAddProVal[k] > 0 and isWar == false and curProConfig.IfFormula == 1 then --allAddProVal[k]=math.floor(allAddProVal[k]*0.1/(curHeroData.lv+10)/100) end end --目前没有 王振兴加 最后计算个属性的乘减算 if curHeroData.MLSproList and LengthOfTable(curHeroData.MLSproList)>0 then for k, v in pairs(curHeroData.MLSproList) do local mlsPro=curHeroData.MLSproList[k] if allAddProVal[mlsPro.proId] then local aaa=1-mlsPro.value local value=math.floor(allAddProVal[mlsPro.proId] * (1-mlsPro.value)) allAddProVal[mlsPro.proId]=value end end end curHeroData.MLSproList={} --Log("allEquipScore "..allEquipScore) --最后计算英雄战斗力 if _type == 1 then --最后加魂印战力 加灵兽羁绊静态战力 allAddProVal[HeroProType.WarPower] = allEquipScore + CalculateWarForce(allAddProVal) + allSoulPrintAddWarPowerVal-- + allPokemonFetterAddWarPowerVal elseif _type == 2 then allAddProVal[HeroProType.WarPower] = allEquipScore + CalculateWarForce(allAddProVal) + allSoulPrintAddWarPowerVal-- + allPokemonFetterAddWarPowerVal --最后加魂印战力 end --for i, v in pairs(allAddProVal) do -- if v > 0 then -- LogError("最后allAddProVal 3 "..i.." "..v) -- end --end return allAddProVal end function this.DoubleTableCompound(allProVal, addProVal) if addProVal and LengthOfTable(addProVal) > 0 then for k, v in pairs(addProVal) do if v > 0 then if allProVal[k] then allProVal[k] = allProVal[k] + v else allProVal[k] = v end end end end end --计算英雄身上单个模块战斗力 --1 装备 2 异妖 3 戒灵 4 天赋树 5 魂印 6 法宝 7 英雄自身 function this.CalculateSingleModuleProPower(_type, _heroDid) local curHeroData = heroDatas[_heroDid] local curLvNum = curHeroData.lv -- heroLevelConfig[curHeroData.lv].CharacterLevelPara --local speedNum = heroLevelConfig[curHeroData.lv].SpeedLevelPara if _type == 1 then local allEquipScore = PlayerManager.GetSingHeroAllEquipSkillListScore(curHeroData) --获取单个英雄装备被动技能累计评分 local allAddEquipProVal = CalculateHeroUpEquipsProAddVal(curHeroData.dynamicId) --添加该英雄装备的属性 return allEquipScore + CalculateSingleModuleWarForce(allAddEquipProVal) elseif _type == 2 then --elseif _type == 3 then -- local allTalentProVal=TalentManager.GetAllTypeTalentProVal()--添加所有戒灵的属性 -- return CalculateSingleModuleWarForce( allTalentProVal) local allPokemonPeiJianAddPro = DiffMonsterManager.CalculateAllPokemonPeiJiAllProAddVal(curHeroData.heroConfig.Profession) --添加所有异妖配件的属性 return CalculateSingleModuleWarForce(allPokemonPeiJianAddPro) elseif _type == 4 then local treeAllProAdd = WorkShopManager.HeroCalculateTreeWarForce(curHeroData.heroConfig.Profession) --计算所有科技树属性 return CalculateSingleModuleWarForce(treeAllProAdd) elseif _type == 5 then return 0 elseif _type == 6 then return 0 elseif _type == 7 then local allAddProVal = {} allAddProVal[HeroProType.Attack] = this.CalculateProVal( curHeroData.attack, curLvNum, curHeroData.breakId, curHeroData.upStarId, HeroProType.Attack ) allAddProVal[HeroProType.Hp] = this.CalculateProVal(curHeroData.hp, curLvNum, curHeroData.breakId, curHeroData.upStarId, HeroProType.Hp) allAddProVal[HeroProType.PhysicalDefence] = this.CalculateProVal( curHeroData.pDef, curLvNum, curHeroData.breakId, curHeroData.upStarId, HeroProType.PhysicalDefence ) allAddProVal[HeroProType.MagicDefence] = this.CalculateProVal( curHeroData.mDef, curLvNum, curHeroData.breakId, curHeroData.upStarId, HeroProType.MagicDefence ) --allAddProVal[HeroProType.Speed]=CalculateSpeedProVal(curHeroData.speed,curHeroData.breakId,speedNum) --if curHeroData.heroConfig.SecondaryFactor then -- for i = 1, #curHeroData.heroConfig.SecondaryFactor do -- if allAddProVal[curHeroData.heroConfig.SecondaryFactor[i][1]] then -- allAddProVal[curHeroData.heroConfig.SecondaryFactor[i][1]] = allAddProVal[curHeroData.heroConfig.SecondaryFactor[i][1]] + -- curHeroData.heroConfig.SecondaryFactor[i][2] -- else -- allAddProVal[curHeroData.heroConfig.SecondaryFactor[i][1]] = curHeroData.heroConfig.SecondaryFactor[i][2] -- end -- end --end return CalculateSingleModuleWarForce(allAddProVal) end return 0 end --计算英雄战斗属性 --目前一次顺序 >等级>生命>最大生命>攻击力>护甲>魔抗>速度>伤害加成系数(%)>伤害减免系数(%)>命中率(%)>闪避率(%)>暴击率(%)>暴击伤害系数(%)>治疗加成系数(%) -- >火系伤害加成系数(%)>火系伤害减免系数(%)>冰系伤害加成系数(%)>冰系伤害减免系数(%)>雷系伤害加成系数(%)>雷系伤害减免系数(%)>风系伤害加成系数(%) -- >风系伤害减免系数(%)>地系伤害加成系数(%)>地系伤害减免系数(%)>暗系伤害加成系数(%)>暗系伤害减免系数(%) function this.CalculateWarAllProVal(heroDid) local allEquipAddProVal = HeroManager.CalculateHeroAllProValList(1, heroDid, true) local allProVal = {} table.insert(allProVal, 1, HeroManager.GetSingleHeroData(heroDid).lv) --等级 table.insert(allProVal, 2, allEquipAddProVal[HeroProType.Hp]) --生命 table.insert(allProVal, 3, allEquipAddProVal[HeroProType.Hp]) --最大生命 table.insert(allProVal, 4, allEquipAddProVal[HeroProType.Attack]) --攻击力 table.insert(allProVal, 5, allEquipAddProVal[HeroProType.PhysicalDefence]) --护甲 table.insert(allProVal, 6, allEquipAddProVal[HeroProType.MagicDefence]) --魔抗 table.insert(allProVal, 7, allEquipAddProVal[HeroProType.Speed]) --速度 table.insert(allProVal, 8, allEquipAddProVal[HeroProType.DamageBocusFactor]) --伤害加成系数(%) table.insert(allProVal, 9, allEquipAddProVal[HeroProType.DamageReduceFactor]) --伤害减免系数(%) table.insert(allProVal, 10, allEquipAddProVal[HeroProType.Hit]) --命中率(%) table.insert(allProVal, 11, allEquipAddProVal[HeroProType.Dodge]) --闪避率(%) table.insert(allProVal, 12, allEquipAddProVal[HeroProType.CritFactor]) --暴击率(%) table.insert(allProVal, 13, allEquipAddProVal[HeroProType.CritDamageFactor]) --暴击伤害系数(%) table.insert(allProVal, 14, allEquipAddProVal[HeroProType.AntiCritDamageFactor]) --抗暴率(%) table.insert(allProVal, 15, allEquipAddProVal[HeroProType.TreatFacter]) --治疗加成系数(%) table.insert(allProVal, 16, allEquipAddProVal[HeroProType.CureFacter]) --受到治疗系数(%) table.insert(allProVal, 17, allEquipAddProVal[HeroProType.DifferDemonsBocusFactor]) --异妖伤害加成系数(%) table.insert(allProVal, 18, allEquipAddProVal[HeroProType.DifferDemonsReduceFactor]) --异妖减伤率(%) table.insert(allProVal, 19, allEquipAddProVal[HeroProType.FireDamageReduceFactor]) --火系伤害减免系数(%) table.insert(allProVal, 20, allEquipAddProVal[HeroProType.WindDamageReduceFactor]) --风系伤害减免系数(%) table.insert(allProVal, 21, allEquipAddProVal[HeroProType.WaterDamageReduceFactor]) --冰系伤害减免系数(%) table.insert(allProVal, 22, allEquipAddProVal[HeroProType.LandDamageReduceFactor]) --地系伤害减免系数(%) table.insert(allProVal, 23, allEquipAddProVal[HeroProType.LightDamageReduceFactor]) --光系伤害减免系数(%) table.insert(allProVal, 24, allEquipAddProVal[HeroProType.DarkDamageReduceFactor]) --暗系伤害减免系数(%) table.insert(allProVal, 25, 0) --属性伤害加成系数(%) return allProVal end --地图临时背包数据 this.mapShotTimeItemData = {} --地图临时英雄数据存储 function this.InitMapShotTimeHeroBagData(_mapHero) this.mapShotTimeItemData[#this.mapShotTimeItemData + 1] = _mapHero end --通过职业筛选英雄 function this.GetHeroDataByProfession(_profession) local heros = {} local index = 1 for i, v in pairs(heroDatas) do if v.profession == _profession or _profession == 0 then --0 全职业 heros[index] = v index = index + 1 end end return heros end --通过属性,等级筛选英雄 function this.GetHeroDataByProperty(_property, _lvLimit) local heros = {} local lvLimit = 0 local allUpZhenHeroList = FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.FORMATION_ENDLESS_MAP) if _lvLimit then lvLimit = _lvLimit end local index = 1 for i, v in pairs(heroDatas) do if v.property == _property then if v.lv >= lvLimit or allUpZhenHeroList[v.dynamicId] then heros[index] = v index = index + 1 end end end return heros end --通过品阶筛选英雄 function this.GetHeroDataByNatural(_natural) local heros = {} for _, heroInfo in pairs(heroDatas) do if heroInfo.heroConfig.Natural == _natural then table.insert(heros, heroInfo) end end return heros end --检测单个英雄是否有可穿的法宝 function this.GetHeroIsUpTalisman(heroDid) if heroDatas[heroDid] then local heroData = heroDatas[heroDid] local isOpenTalisman = TalismanManager.GetCurHeroIsOpenTalisman(heroData.star) if isOpenTalisman == false then --法宝是否开启 return {} end local curTalismanData if heroData.talismanList and #heroData.talismanList > 0 then curTalismanData = TalismanManager.GetSingleTalismanData(heroData.talismanList[1]) end local GetAllTalismanData = TalismanManager.GetAllTalismanData(false, "0") table.sort( GetAllTalismanData, function(a, b) return a.power > b.power end ) if curTalismanData then if GetAllTalismanData and #GetAllTalismanData > 0 then for i = 1, #GetAllTalismanData do if GetAllTalismanData[i].power > curTalismanData.power then return {GetAllTalismanData[i]} end end end return {} else if GetAllTalismanData and #GetAllTalismanData > 0 then return {GetAllTalismanData[1]} else return {} end end end return {} end --获取妖灵师技能最大等级 function this.GetHeroSkillMaxLevel(heroTId, type) local curHeroData = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroTId) local maxSkillLv if type == 1 then if #curHeroData.OpenSkillRules - 1 == 0 then maxSkillLv = curHeroData.OpenSkillRules[1][2] % 10 else maxSkillLv = curHeroData.OpenSkillRules[#curHeroData.OpenSkillRules][2] % 10 end elseif type == 2 then maxSkillLv = curHeroData.OpenSkillRules[#curHeroData.OpenSkillRules][2] % 10 elseif type == 3 then maxSkillLv = curHeroData.OpenPassiveSkillRules[#curHeroData.OpenPassiveSkillRules][2] % 10 end return maxSkillLv end --获取所有英雄信息(回溯功能) function this.GetReturnHeroDatas(_star) local heros = {} local heros2 = {} for i, v in pairs(heroDatas) do v.isFormation = "" table.insert(heros, v) end --标记编队上的英雄 if heros and LengthOfTable(heros) > 0 then for i, v in pairs(heros) do for n, w in pairs(FormationManager.formationList) do for m = 1, #w.teamHeroInfos do if v.dynamicId == w.teamHeroInfos[m].heroId then local isFormationStr = this.GetHeroFormationStr(n) heros[i].isFormation = isFormationStr end end end if v.star >= _star then table.insert(heros2, v) end end end return heros2 end function this.GetCurHeroSidAndCurStarAllSkillDatas(sid, star) local allSkillDatas = {} local skillIndex = 1 local curHeroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, sid) if curHeroConfig.OpenSkillRules then for i = 1, #curHeroConfig.OpenSkillRules do if curHeroConfig.OpenSkillRules[i][1] == star then local heroSkill = {} heroSkill.skillId = curHeroConfig.OpenSkillRules[i][2] heroSkill.skillConfig = skillConfig[heroSkill.skillId] allSkillDatas[skillIndex] = heroSkill skillIndex = skillIndex + 1 end end end local OpenPassiveSkillRules = star == this.awakeNextStarIndex and curHeroConfig.Awaken or curHeroConfig.OpenPassiveSkillRules if OpenPassiveSkillRules then for i = 1, #OpenPassiveSkillRules do if OpenPassiveSkillRules[i][1] == star then local heroSkill = {} heroSkill.skillId = OpenPassiveSkillRules[i][2] heroSkill.skillConfig = passiveSkillConfig[heroSkill.skillId] allSkillDatas[skillIndex] = heroSkill skillIndex = skillIndex + 1 end end end return allSkillDatas end function this.DetectionOpenFiveStarActivity(starUpGiftNum) Log(" ---- GameEvent.PatFace.PatFaceSend,14 ") PlayerManager.IsGetFiveStarHero = true end -- 判断英雄是否有魂印功能 function this.IsHeroHaveSoulPrintFunc(heroId) local unlock = ConfigManager.GetConfigData(ConfigName.GameSetting, 1).EquipSignUnlock if unlock[1] == 1 then -- 根据英雄判断等级 return elseif unlock[1] == 2 then local MaxStar = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroId).MaxRank return MaxStar >= unlock[2] end return false end -- 判断英雄是否有法宝功能 function this.IsHeroHaveTalismanFunc(heroId) local unlock = ConfigManager.GetConfigData(ConfigName.GameSetting, 1).EquipTalismanaUnlock if unlock[1] == 1 then -- 根据英雄判断等级 return elseif unlock[1] == 2 then local MaxStar = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroId).MaxRank return MaxStar >= unlock[2] end return false end --获取迷宫寻宝所有英雄信息 function this.GetFingTreasureAllHeroDatas() local allUpZhenHeroList = FindTreasureManager.GetAllUpHeros() local heros = {} for i, v in pairs(heroDatas) do if not allUpZhenHeroList[v.dynamicId] then table.insert(heros, v) end end return heros end --回溯 和 献祭 返回item信息 local rewardGroup = ConfigManager.GetConfig(ConfigName.RewardGroup) function this.GetHeroReturnItems(selectHeroData, type) local allRewardData = {} if type == GENERAL_POPUP_TYPE.ResolveRecall then local specificValue = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig, 34).Value) / 10000 local ShowItemlist = {} --HeroReturn 的 ReturnHero + RankupReturn * specificValue + HeroLevelConfig 的 Consume * specificValue --先把回溯英雄放进去 for i, v in pairs(selectHeroData) do local curHeroData = heroDatas[i] if not curHeroData then return end local pId if curHeroData.breakId == 0 then pId=0 else pId= heroRankUpConfig[curHeroData.breakId].Phase[2] end local heroReturnConfig = ConfigManager.TryGetConfigDataByDoubleKey( ConfigName.HeroReturn, "HeroId", curHeroData.id, "Star", pId ) local rewardShowStr1 = {} if not heroReturnConfig then LogRed("pId:"..pId.." curHeroData.breakId:"..curHeroData.breakId.." curHeroData.id:"..curHeroData.id) else ShowItemlist[heroReturnConfig.HeroId] = {heroReturnConfig.HeroId,1,curHeroData.star} rewardShowStr1 = heroReturnConfig.RankupReturn if rewardShowStr1 then for k,v in ipairs(rewardShowStr1) do if v[1] and v[2] then if not ShowItemlist[v[1]] then ShowItemlist[v[1]] = {v[1], v[2] * specificValue} else ShowItemlist[v[1]] = {v[1],ShowItemlist[v[1]][2] + v[2] * specificValue} end end end end end rewardShowStr1 = ConfigManager.GetConfigData(ConfigName.HeroLevelConfig, v.lv).SumConsume if rewardShowStr1 then for k,v in ipairs(rewardShowStr1) do if not ShowItemlist[v[1]] then ShowItemlist[v[1]] = {v[1], v[2] * specificValue} else ShowItemlist[v[1]] = {v[1],ShowItemlist[v[1]][2] + v[2] * specificValue} end end end --this.GetHeroReturnItems2(ShowItemlist,allRewardData) end local dropList = {} for n,m in pairs(ShowItemlist) do local curReward = {} curReward.id = m[1] curReward.num = math.floor(m[2]) curReward.itemConfig = itemConfig[curReward.id] curReward.star = m[3] or nil table.insert(dropList, curReward) end return dropList elseif type == GENERAL_POPUP_TYPE.ResolveDismantle then --献祭 local specificValue = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig, 35).Value) / 10000 for i, v in pairs(selectHeroData) do --当英雄一次都未突破和进阶时 --val=itemConfig.ResolveReward+heroLevelConfig.SumConsume else val=HeroRankupConfig.SumConsume+heroLevelConfig.SumConsume --1裸角色卡(没有突破过的角色卡)熔炼后返还的材料=当前等级返还升级材料+item表返还材料 --2有过突破的卡 =当前等级返还升级材料+突破表返还材料+升星返还材料 local curHeroData = heroDatas[i] if not curHeroData then return end local ShowItemlist = {} local pId if curHeroData.breakId == 0 then pId=0 else pId= heroRankUpConfig[curHeroData.breakId].Phase[2] end if pId == 0 and curHeroData.upStarId == 0 then local rewardGroupId = tonumber(itemConfig[curHeroData.id].ResolveReward) if rewardGroupId and rewardGroup[rewardGroupId] then local showItem = rewardGroup[rewardGroupId].ShowItem if showItem and LengthOfTable(showItem) > 0 then for i = 1, #showItem do table.insert(ShowItemlist, {showItem[i][1], showItem[i][2]}) end end end else if pId > 0 then local heroRankUpConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.HeroSacrifice,"Type",2,"Key",pId) if heroRankUpConfig then local sumConsume = heroRankUpConfig.Value for i = 1, #sumConsume do table.insert(ShowItemlist, {sumConsume[i][1], sumConsume[i][2] * specificValue}) end else LogRed("pId:"..pId.." curHeroData.breakId:"..curHeroData.breakId.." curHeroData.id:"..curHeroData.id) end end if curHeroData.star > 1 then local heroRankUpConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.HeroSacrifice,"Type",1,"Key",curHeroData.star) if heroRankUpConfig then local sumConsume = heroRankUpConfig.Value for i = 1, #sumConsume do table.insert(ShowItemlist, {sumConsume[i][1], sumConsume[i][2] * specificValue}) end end else LogRed("curHeroData.star :"..curHeroData.star) end end local temp = {} if curHeroData.talismanList > 1 then local temp1 =tonumber(ConfigManager.GetConfigData(ConfigName.HeroConfig, curHeroData.id).EquipTalismana[2]) LogRed(temp1) for i = 1, curHeroData.talismanList - 1 do temp = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",temp1,"Level",i).RankupBasicMaterial for i = 1,#temp do table.insert(ShowItemlist, {temp[i][1], temp[i][2] * specificValue}) end end end if curHeroData.lv > 1 then local rewardShowStr2 = {} rewardShowStr2 = ConfigManager.GetConfigData(ConfigName.HeroLevelConfig, curHeroData.lv).SumConsume if rewardShowStr2 then for i = 1, #rewardShowStr2 do if rewardShowStr2[i] and rewardShowStr2[i][1] then table.insert(ShowItemlist, {rewardShowStr2[i][1], rewardShowStr2[i][2] * specificValue}) end end end end this.GetHeroReturnItems2(ShowItemlist, allRewardData) end local dropList = {} for k, v in pairs(allRewardData) do v.num = math.floor(v.num) table.insert(dropList, v) end table.sort( dropList, function(a, b) return itemConfig[a.id].Quantity > itemConfig[b.id].Quantity end ) return dropList elseif type == GENERAL_POPUP_TYPE.TalismanResolve then --法宝回归 local specificValue = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig, 35).Value) / 10000 local ShowItemlist = {} for i, v in pairs(selectHeroData) do local curHeroData = heroDatas[i] local temp = {} if curHeroData.talismanList > 1 then local temp1 =tonumber(ConfigManager.GetConfigData(ConfigName.HeroConfig, curHeroData.id).EquipTalismana[2]) for i = 1, curHeroData.talismanList - 1 do temp = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",temp1,"Level",i).RankupBasicMaterial for i = 1,#temp do if not ShowItemlist[temp[i][1]] then ShowItemlist[temp[i][1]] = {temp[i][1], temp[i][2] * specificValue} else ShowItemlist[temp[i][1]] = {temp[i][1],ShowItemlist[temp[i][1]][2] + temp[i][2] * specificValue} end end end end end local dropList = {} for k, v in pairs(ShowItemlist) do local curReward = {} curReward.id = v[1] curReward.num = math.floor(v[2]) table.insert(dropList, curReward) end table.sort( dropList, function(a, b) return itemConfig[a.id].Quantity > itemConfig[b.id].Quantity end ) return dropList end end function this.GetHeroReturnItems2(ShowItemlist, allRewardData) for i = 1, #ShowItemlist do local curReward = {} curReward.id = ShowItemlist[i][1] curReward.num = ShowItemlist[i][2] LogBlue("curReward.id:"..curReward.id.." curReward.num"..curReward.num) curReward.itemConfig = itemConfig[curReward.id] if allRewardData[curReward.id] == nil then allRewardData[curReward.id] = curReward else allRewardData[curReward.id].num = allRewardData[curReward.id].num + curReward.num end end end --更新英雄主动技能 function this.UpdateSkillIdList(heroData) heroData.skillIdList = {} --主动技 if heroData.heroConfig.OpenSkillRules then for i = 1, #heroData.heroConfig.OpenSkillRules do if heroData.heroConfig.OpenSkillRules[i][1] == heroData.star then local heroSkill = {} heroSkill.skillId = heroData.heroConfig.OpenSkillRules[i][2] heroSkill.skillConfig = skillConfig[heroSkill.skillId] table.insert(heroData.skillIdList, heroSkill) end end end end --更新英雄被动技能 function this.UpdatePassiveHeroSkill(heroData) heroData.passiveSkillList = {} --被动技 local OpenPassiveSkillRules = heroData.star == this.awakeNextStarIndex and heroData.heroConfig.Awaken or heroData.heroConfig.OpenPassiveSkillRules if OpenPassiveSkillRules then for i = 1, #OpenPassiveSkillRules do if OpenPassiveSkillRules[i][1] == 1 then --突破 if heroData.breakId >= OpenPassiveSkillRules[i][2] then local heroSkill = {} heroSkill.skillId = OpenPassiveSkillRules[i][3] heroSkill.skillConfig = passiveSkillConfig[heroSkill.skillId] table.insert(heroData.passiveSkillList, heroSkill) end else --升星 if heroData.upStarId >= OpenPassiveSkillRules[i][2] then local heroSkill = {} heroSkill.skillId = OpenPassiveSkillRules[i][3] heroSkill.skillConfig = passiveSkillConfig[heroSkill.skillId] table.insert(heroData.passiveSkillList, heroSkill) end end end end end -----------新魂印开始 --增加魂印装备的英雄did function this.AddSoulPrintUpHeroDynamicId(heroDid, soulPrintSid, soulPrintPos) if heroDatas[heroDid] then local singleSoulPrint = {equipId = soulPrintSid, position = soulPrintPos} table.insert(heroDatas[heroDid].soulPrintList, singleSoulPrint) SoulPrintManager.AddSoulPrintUpHeroDynamicId(soulPrintSid, heroDid) end end --删除魂印装备的英雄did function this.DelSoulPrintUpHeroDynamicId(heroDid, soulPrintSid) if heroDatas[heroDid] then for i = 1, #heroDatas[heroDid].soulPrintList do if heroDatas[heroDid].soulPrintList[i] and heroDatas[heroDid].soulPrintList[i].equipId == soulPrintSid then table.remove(heroDatas[heroDid].soulPrintList, i) SoulPrintManager.DelSoulPrintUpHeroDynamicId(soulPrintSid, heroDid) end end end end ------------新魂印结束 --天赋技能(被动技能) function this.GetAllPassiveSkillIds(heroConfig, breakId, upStarId) local allPassiveSkillIds = {} local allPassiveSkillIdcompound = {} local allOpenPassiveSkillIdcompound = {} local allUpStarOpenData = {} --只用于界面升星开放技能提示显示用 local compoundNum = 0 local compoundOPenNum = 0 local OpenPassiveSkillRules = (upStarId and upStarId ~=0 and heroRankUpConfig[upStarId].OpenStar == this.awakeNextStarIndex) and heroConfig.Awaken or heroConfig.OpenPassiveSkillRules if OpenPassiveSkillRules then for i = 1, #OpenPassiveSkillRules do if OpenPassiveSkillRules[i][1] == 1 then --突破 if breakId >= OpenPassiveSkillRules[i][2] then -- local openPassiveSkillRules = allPassiveSkillIds,OpenPassiveSkillRules table.insert(allPassiveSkillIds, OpenPassiveSkillRules[i][3]) if allOpenPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] then allOpenPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] = allOpenPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] + 1 else allOpenPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] = 1 end end else --升星 allUpStarOpenData[heroRankUpConfig[OpenPassiveSkillRules[i][2]].Phase[2]] = OpenPassiveSkillRules[i] if upStarId >= OpenPassiveSkillRules[i][2] then table.insert(allPassiveSkillIds, OpenPassiveSkillRules[i][3]) if allOpenPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] then allOpenPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] = allOpenPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] + 1 else allOpenPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] = 1 end end end if allPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] then allPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] = allPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] + 1 else allPassiveSkillIdcompound[OpenPassiveSkillRules[i][2]] = 1 end end end for i, v in pairs(allPassiveSkillIdcompound) do if v > 1 then compoundNum = compoundNum + v - 1 end end for i, v in pairs(allOpenPassiveSkillIdcompound) do if v > 1 then compoundOPenNum = compoundOPenNum + v - 1 end end return allPassiveSkillIds, compoundOPenNum, compoundNum, allUpStarOpenData end --战中英雄被动技获取 function this.GetHeroAllPassiveSkillIds(curHeroData) local allPassiveSkillIds = {} if not curHeroData then return allPassiveSkillIds end --英雄天赋被动技 if curHeroData.heroConfig.OpenPassiveSkillRules then local openPassiveSkillRules = curHeroData.star == this.awakeNextStarIndex and curHeroData.heroConfig.Awaken or curHeroData.heroConfig.OpenPassiveSkillRules for i = 1, #openPassiveSkillRules do local skillType = openPassiveSkillRules[i][1] local skillRanUpId = openPassiveSkillRules[i][2] local skillId = openPassiveSkillRules[i][3] if skillType == 1 then --突破 if curHeroData.breakId >= skillRanUpId and passiveSkillLogicConfig[skillId].EffectiveRange == 1 then table.insert(allPassiveSkillIds, skillId) end else --升星 if curHeroData.upStarId >= skillRanUpId and passiveSkillLogicConfig[skillId].EffectiveRange == 1 then table.insert(allPassiveSkillIds, skillId) end end end end --法宝被动技 if curHeroData.heroConfig.EquipTalismana and curHeroData.star >= curHeroData.heroConfig.EquipTalismana[1] then local curTalisman = ConfigManager.GetConfigData(ConfigName.HeroConfig, curHeroData.id).EquipTalismana if curTalisman and curTalisman[2] then local talismanConFig = ConfigManager.GetConfigDataByDoubleKey( ConfigName.EquipTalismana, "TalismanaId", curTalisman[2], "Level", curHeroData.talismanList ) if talismanConFig then --当前法宝全部天赋数据(天赋可能为空) local dowerAllData = ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipTalismana, "TalismanaId", curTalisman[2]) for i = 1, #dowerAllData do if dowerAllData[i].OpenSkillRules and curHeroData.talismanList >= dowerAllData[i].Level then for k = 1, #dowerAllData[i].OpenSkillRules do if passiveSkillLogicConfig[dowerAllData[i].OpenSkillRules[k]].EffectiveRange == 1 then table.insert(allPassiveSkillIds, dowerAllData[i].OpenSkillRules[k]) end end end end end end end --魂印被动技 if (table.nums(curHeroData.soulPrintList) >= 1) then for i = 1, #curHeroData.soulPrintList do local cursoulPrintConfig = equipConfig[curHeroData.soulPrintList[i].equipId] if cursoulPrintConfig and cursoulPrintConfig.PassiveSkill then for _, pId in ipairs(cursoulPrintConfig.PassiveSkill) do if passiveSkillLogicConfig[pId] and passiveSkillLogicConfig[pId].EffectiveRange == 1 then table.insert(allPassiveSkillIds, pId) end end end end end for i = 1, #allPassiveSkillIds do LogError("allPassiveSkillIds " .. allPassiveSkillIds[i]) end return allPassiveSkillIds end --获取当前类型英雄是否存在 function this.GetCurHeroIsHaveBySid(heroSId) for i, v in pairs(heroDatas) do if v.id == heroSId then return true end end return false end -- 角色定位相关 -- 判断该角色是否开启定位 sid 英雄静态ID function this.IsHeroPosOpen(did) return this.GetSingleHeroData(did).heroConfig.RecommendTeamId[1] ~= 0 end --单个红点判断 local isHeroUpTuPo = false local isHeroUpStar = false local upTuPoRankUpConfig = {} local upStarRankUpConfig = {} local heroRankupConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig) --编队所有英雄判断 function this.GetFormationHeroRedPoint() local teamHero = FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.FORMATION_NORMAL) for i, v in pairs(teamHero) do local curHeroData = HeroManager.GetSingleHeroData(i) if this.GetCurHeroUpLvOrUpStarSData(curHeroData) or this.LvUpBtnRedPoint(curHeroData) or this.IsShowUpStarRedPoint(curHeroData) or #this.GetHeroIsUpEquip(curHeroData.dynamicId) > 0 or this.GetIsShowSoulPrintRedPoint(curHeroData) or this.GetIsShowTalismanRedPoint(curHeroData) then return true end end return false end --单个英雄所有红点判断 function this.GetCurHeroIsShowRedPoint(curHeroData) return this.GetCurHeroUpLvOrUpStarSData(curHeroData) or this.LvUpBtnRedPoint(curHeroData) or this.IsShowUpStarRedPoint(curHeroData) or #this.GetHeroIsUpEquip(curHeroData.dynamicId) > 0 or this.GetIsShowSoulPrintRedPoint(curHeroData) or this.GetIsShowTalismanRedPoint(curHeroData) end --获取当前英雄的下一突破 和 升星 静态数据 function this.GetCurHeroUpLvOrUpStarSData(curHeroData) isHeroUpTuPo = false isHeroUpStar = false upTuPoRankUpConfig = {} upStarRankUpConfig = {} for i, v in ConfigPairs(heroRankUpConfig) do if v.Star == curHeroData.heroConfig.Star then --初始星级相等 if v.Show == 1 then -- 1 突破 if v.Id ~= curHeroData.breakId and curHeroData.lv == v.LimitLevel then --and curHeroData.star == v.LimitStar --Log("突破 "..v.Id) isHeroUpTuPo = true upTuPoRankUpConfig = v end end if v.Show == 2 then -- 2 升星 if v.Id ~= curHeroData.upStarId and curHeroData.star == v.LimitStar then --Log("升星 "..v.Id) upStarRankUpConfig = v isHeroUpStar = true end end end end end --单个英雄升级红点 function this.LvUpBtnRedPoint(curHeroData) HeroManager.GetCurHeroUpLvOrUpStarSData(curHeroData) --是否为最大等级 if curHeroData.lv >= HeroManager.heroLvEnd[curHeroData.heroConfig.Id] then return false end local curTuPoRankUpConfig = heroRankupConfig[curHeroData.breakId] local curStarRankUpConfig = heroRankupConfig[curHeroData.upStarId] local isUpLvMaterials = true local costItemList = {} if isHeroUpTuPo and upTuPoRankUpConfig and curHeroData.lv == upTuPoRankUpConfig.LimitLevel then costItemList = upTuPoRankUpConfig.ConsumeMaterial else costItemList = ConfigManager.GetConfigData(ConfigName.HeroLevelConfig, curHeroData.lv).Consume end for i = 1, #costItemList do if BagManager.GetItemCountById(costItemList[i][1]) < costItemList[i][2] then isUpLvMaterials = false end end --如果此时需要进阶 每次都要跳转 if isHeroUpStar and upStarRankUpConfig and curTuPoRankUpConfig and curTuPoRankUpConfig.JudgeClass == 1 and curHeroData.lv >= curTuPoRankUpConfig.OpenLevel then --当前突破全部完成 if curStarRankUpConfig then --进阶过处理 if curHeroData.lv == curStarRankUpConfig.OpenLevel then return false else if isUpLvMaterials then return true else return false end end else --从未进阶过处理 return false end else if isUpLvMaterials then return true else return false end end return false end --单个英雄升星红点 function this.IsShowUpStarRedPoint(curHeroData) HeroManager.GetCurHeroUpLvOrUpStarSData(curHeroData) -- if curHeroData.lv >= HeroManager.heroLvEnd[curHeroData.heroConfig.Id] then -- return false -- --培养已满 -- end local curUpStarData= HeroManager.GetHeroCurUpStarInfo(curHeroData.dynamicId) if curUpStarData and #curUpStarData>0 then else --培养已满 return false end if upStarRankUpConfig and upStarRankUpConfig.LimitLevel then if curHeroData.lv < upStarRankUpConfig.LimitLevel then return false --等级不够 end else --不能升星 return false end if upStarRankUpConfig then local ConsumeMaterial = upStarRankUpConfig.ConsumeMaterial for i = 1, #ConsumeMaterial do if ConsumeMaterial[i][2] > 0 then if BagManager.GetItemCountById(ConsumeMaterial[i][1]) < ConsumeMaterial[i][2] then return false --材料不足 end end end end local upStarConsumeMaterial = {} local upStarMaterialIsAll = {} local curUpStarData = HeroManager.GetHeroCurUpStarInfo(curHeroData.dynamicId) if curUpStarData and #curUpStarData > 0 then for i = 1, #curUpStarData do local curSelectUpStarData = curUpStarData[i] local upStarHeroListData = HeroManager.GetUpStarHeroListData(curSelectUpStarData.upStarMaterialsData.Id, curHeroData) local curSelectHeroList = {} --if curSelectUpStarData.upStarMaterialsData.Issame ==1 or curSelectUpStarData.upStarMaterialsData.IsId > 0 then upStarMaterialIsAll[curSelectUpStarData.upStarData[2]] = 2 if #upStarHeroListData.heroList >= curSelectUpStarData.upStarData[4] then for j = 1, #upStarHeroListData.heroList do if upStarHeroListData.heroList[j].lockState == 0 and upStarHeroListData.heroList[j].isFormation == "" and #curSelectHeroList < curSelectUpStarData.upStarData[4] and not upStarConsumeMaterial[upStarHeroListData.heroList[j].dynamicId] then table.insert(curSelectHeroList, upStarHeroListData.heroList[j]) end end if LengthOfTable(curSelectHeroList) >= curSelectUpStarData.upStarData[4] then upStarMaterialIsAll[curSelectUpStarData.upStarData[2]] = 1 end for _i, v in pairs(curSelectHeroList) do upStarConsumeMaterial[v.dynamicId] = v.dynamicId end end --end end end -- 消耗位置材料状态 for i = 1, #upStarMaterialIsAll do if upStarMaterialIsAll[i] == 2 then return false end end return true end --单个英雄装备红点 --检测单个英雄是否有可穿的装备 function this.GetHeroIsUpEquip(heroDid) if heroDatas[heroDid] then local heroData = heroDatas[heroDid] local lackEquips = {} --六个装备位 for i = 1, 6 do local equipIdAndWarPower = {} equipIdAndWarPower.pos = i equipIdAndWarPower.id = 0 equipIdAndWarPower.warPower = 0 lackEquips[i] = equipIdAndWarPower end -- 有装备的位置赋值装备id及战力 if heroData.equipIdList and #heroData.equipIdList > 1 then for i = 1, #heroData.equipIdList do if not heroData.equipIdList[i] then else local curEquipConFigData = EquipManager.GetSingleHeroSingleEquipData(heroData.equipIdList[i], heroDid) if not curEquipConFigData then LogBlue("-------------------------"..heroData.equipIdList[i] .. " " .. heroDid) else lackEquips[curEquipConFigData.equipConfig.Position].id = heroData.equipIdList[i] lackEquips[curEquipConFigData.equipConfig.Position].warPower = EquipManager.CalculateWarForce(heroData.equipIdList[i]) end end end end --有同系 且未在英雄身上的装备 local equips = BagManager.GetEquipDataByEquipPosition(heroData.heroConfig.Profession) for _, v in ipairs(equips) do if EquipManager.GetSingleHeroSingleEquipData(v.id, heroDid) then --英雄已经装备了这个装备 else local equipConfigData = equipConfig[v.id] local pos = equipConfigData.Position --比较战力 高战力的装备add if lackEquips[pos].pos == equipConfigData.Position then if lackEquips[pos].id == 0 then lackEquips[pos].id = v.id lackEquips[pos].warPower = EquipManager.CalculateWarForce(v.id) else local nextEquipWarPower = EquipManager.CalculateWarForce(v.id) if nextEquipWarPower > lackEquips[pos].warPower then lackEquips[pos].id = v.id lackEquips[pos].warPower = EquipManager.CalculateWarForce(v.id) end end end end end --去掉与自己本身自带的重合装备 local allUpEquipDidTabs = {} for i = 1, #lackEquips do if lackEquips[i].id ~= 0 then local isAdd = true for j = 1, #heroData.equipIdList do if tonumber(heroData.equipIdList[j]) == tonumber(lackEquips[i].id) then isAdd = false end end if isAdd then table.insert(allUpEquipDidTabs, lackEquips[i].id) end end end if #allUpEquipDidTabs > 0 then return allUpEquipDidTabs end return {} end return {} end --单个英雄魂印红点 --获取魂印环形布局数据 didMaxLen最大槽位数量 didLen可装备槽位数量 didLv最大动态等级 maxLv配置最大等级 function this.GetSoulPrintLoopUIMaxData() local d = string.split(ConfigManager.GetConfigData(ConfigName.SpecialConfig, 37).Value, "#") local _d = {} for n = 1, #d do local v = d[n] if PlayerManager.level >= tonumber(v) then table.insert(_d, v) end end --当前动态最大等级 local didLv = 0 --最大槽位数量 local didMaxLen = 0 --可装备槽位数量(与是否装备英雄无关) local didLen = 0 if #_d < #d then --未达到最大等级 +1显示锁定 didMaxLen = #_d + 1 else didMaxLen = #_d end didLv = tonumber(d[didMaxLen]) didLen = #_d local maxLv = tonumber(d[#d]) return didMaxLen, didLen, didLv, maxLv end function this.GetIsShowSoulPrintRedPoint(curHeroData) local soulPrintIsOpen = SoulPrintManager.GetSoulPrintIsOpen(curHeroData) if not soulPrintIsOpen then return false end local didMaxLen, didLen, didLv, maxLv = this.GetSoulPrintLoopUIMaxData() if curHeroData.soulPrintList and #curHeroData.soulPrintList >= didLen then return false --空位置 已装满 end local allUpSoulPrint = {} if curHeroData.soulPrintList then for i = 1, #curHeroData.soulPrintList do allUpSoulPrint[curHeroData.soulPrintList[i].equipId] = curHeroData.soulPrintList[i] end end local allBagSoulPrintData = BagManager.GetBagItemDataByItemType(ItemBaseType.SoulPrint) for i = 1, #allBagSoulPrintData do if not allUpSoulPrint[allBagSoulPrintData[i].id] and equipConfig[allBagSoulPrintData[i].id].Range[1] == 0 then return true --有空位可以穿戴 end local isHaveCurHeroid = false for j = 1, #equipConfig[allBagSoulPrintData[i].id].Range do local heroId = equipConfig[allBagSoulPrintData[i].id].Range[j] if curHeroData.id == heroId then isHaveCurHeroid = true end end if not allUpSoulPrint[allBagSoulPrintData[i].id] and isHaveCurHeroid then return true --有空位可以穿戴 end end return false end --单个英雄法宝红点 function this.GetIsShowTalismanRedPoint(curHeroData) local isOpen = TalismanManager.GetCurHeroIsOpenTalisman(curHeroData) if not isOpen then return false --功能未开启 end local equipTalismana = ConfigManager.GetConfigData(ConfigName.HeroConfig, curHeroData.id).EquipTalismana --当前法宝数据 data[1]星级 data[2]法宝ID if not equipTalismana then return false end --获取最大等级 TalismanManager.GetStartAndEndStar() local maxLv = TalismanManager.AllTalismanEndStar[equipTalismana[2]] --获取当前法宝等级 local curLv = HeroManager.GetTalismanLv(curHeroData.dynamicId) --获取当前等级与下一等级表数据 local nextLv = 0 if (curLv + 1) <= maxLv then nextLv = curLv + 1 end local isMaxStar = curLv >= maxLv if isMaxStar then return false --已满级 end local curTalismanConFig = ConfigManager.GetConfigDataByDoubleKey( ConfigName.EquipTalismana, "Level", curLv, "TalismanaId", equipTalismana[2] ) --local nextTalismanConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "TalismanaId", equipTalismana[2], "Level", nextLv) --需要判断材料够不够 for i = 1, #curTalismanConFig.RankupBasicMaterial do local needNum = curTalismanConFig.RankupBasicMaterial[i][2] --需要物品数量 local haveNum = BagManager.GetItemCountById(curTalismanConFig.RankupBasicMaterial[i][1]) --已有物品数量 if haveNum < needNum then return false --材料不足 end end return true end function this.ResetHero(dynamicloadId) if heroDatas[dynamicloadId] then heroDatas[dynamicloadId].lv = 1 heroDatas[dynamicloadId].breakId = 0 heroDatas[dynamicloadId].warPower = this.CalculateHeroAllProValList(1, heroDatas[dynamicloadId].dynamicId, false)[HeroProType.WarPower] end FormationManager.ResolvDownBattleCurHeroId(dynamicloadId) end --神将合成 function this.ByCompoundHeroGetAllHeros() local upSortHeroList = {} local downSoryHeroList = {} local text = "" for i, v in pairs(heroDatas) do text = "" if v.star == 4 or v.star == 5 or v.star == 3 then--四星 五星 才能加 3星 是狗粮 for n, w in pairs(FormationManager.formationList) do for m = 1, #w.teamHeroInfos do if v.dynamicId == w.teamHeroInfos[m].heroId then local isFormationStr = this.GetHeroFormationStr2(n) if isFormationStr ~= "" then if not text or text == "" then text = isFormationStr else text = text .. "、"..isFormationStr end end end end end v.isFormation = text table.insert(upSortHeroList,v) table.insert(downSoryHeroList,v) end end table.sort(downSoryHeroList, function(a,b) if a.star == b.star then if a.lv == b.lv then return a.heroConfig.Id < b.heroConfig.Id else return a.lv > b.lv end else return a.star > b.star end end) table.sort(upSortHeroList, function(a,b) if a.star == b.star then if a.lv == b.lv then return a.heroConfig.Id > b.heroConfig.Id else return a.lv < b.lv end else return a.star < b.star end end) return upSortHeroList,downSoryHeroList end --神将置换 function this.ByReplaceHeroGetAllHeros() local sortHeroList = {} for i, v in pairs(heroDatas) do if v.star == 4 or v.star == 5 then--四星 五星 v.isFormation = "" table.insert(sortHeroList,v) end end table.sort(sortHeroList, function(a,b) if a.star == b.star then if a.lv == b.lv then return a.heroConfig.Id > b.heroConfig.Id else return a.lv < b.lv end else return a.star > b.star end end) return sortHeroList end --修改神将changeId (1是增加/修改 0是恢复默认值0) function this.ResetHeroChangeId(dynamicloadId,changeId) if heroDatas[dynamicloadId] then if changeId then heroDatas[dynamicloadId].changeId = changeId else heroDatas[dynamicloadId].changeId = 0 end end end -- 检测所有重复穿戴的宝器并卸下 function this.CheckRepeatTreasure(func) this._TreasureToTarget = {} this._WearCount = {} this._NoTreasure = {} this._CheckIndex = 0 for _, heroData in ipairs(this.heroDataLists) do if heroData and heroData.jewels and #heroData.jewels > 0 then for _, jId in ipairs(heroData.jewels) do local jewel = EquipTreasureManager.GetSingleTreasureByIdDyn(jId) if jewel then -- 重复穿戴 if not this._WearCount[jId] then this._WearCount[jId] = 0 end this._WearCount[jId] = this._WearCount[jId] + 1 -- 判断最终穿戴的人(根据战斗力判断) if not this._TreasureToTarget[jId] then this._TreasureToTarget[jId] = {id = heroData.dynamicId, power = heroData.warPower} end if this._TreasureToTarget[jId].power < heroData.warPower then this._TreasureToTarget[jId] = {id = heroData.dynamicId, power = heroData.warPower} end else -- 没有这件装备 this._NoTreasure[jId] = 1 end end end end -- 开始卸下 this.UnloadRepeatTreasure(function() -- 开始装备 this.EquipRepeatTreasure(func) end) end -- 卸下重复和没有的装备 function this.UnloadRepeatTreasure(func) this._CheckIndex = this._CheckIndex + 1 if this._CheckIndex > #this.heroDataLists then if func then func() end return end -- 计算需要卸载的装备 local unloadList = {} local heroData = this.heroDataLists[this._CheckIndex] if heroData and heroData.jewels and #heroData.jewels > 0 then for _, jId in ipairs(heroData.jewels) do if this._NoTreasure[jId] == 1 -- 没有这件装备 or this._WearCount[jId] > 1 then-- 重复 table.insert(unloadList, jId) end end end -- 卸载 if #unloadList > 0 then NetManager.EquipUnLoadOptRequest(heroData.dynamicId, unloadList, 2, function () for i = 1, #unloadList do EquipTreasureManager.SetTreasureUpOrDown(unloadList[i], "") this.RemoveTreasure(heroData.dynamicId, unloadList[i]) end this.UnloadRepeatTreasure(func) end) else this.UnloadRepeatTreasure(func) end end -- 重复穿戴的装备应该不会太多,所以这里直接同步穿上 function this.EquipRepeatTreasure(func) local _EquipIndex = 0 local _MaxIndex = 0 for jId, heroData in pairs(this._TreasureToTarget) do if this._WearCount[jId] > 1 then -- 重复 _MaxIndex = _MaxIndex + 1 NetManager.EquipWearRequest(heroData.id, {jId}, 2, function () _EquipIndex = _EquipIndex + 1 EquipTreasureManager.SetTreasureUpOrDown(jId, heroData.id) this.WearTreasure(heroData.id, jId) --对比战力并更新战力值 播放战力变更动画 HeroManager.CompareWarPower(heroData.id) if _EquipIndex >= _MaxIndex then if func then func() end end end) end end -- 没有直接结束 if _MaxIndex == 0 then if func then func() end end end function this.WearTreasure(dId, jId, index) if index and index >= 1 and index <= 2 then table.remove(heroDatas[dId].jewels, index) table.insert(heroDatas[dId].jewels, index, jId) return end if #heroDatas[dId].jewels < 2 then table.insert(heroDatas[dId].jewels, jId) end end function this.RemoveTreasure(dId, jId) local removeIndex for i = 1, #heroDatas[dId].jewels do if heroDatas[dId].jewels[i] == jId then removeIndex = i end end if removeIndex then table.remove(heroDatas[dId].jewels, removeIndex) end end --根据界面数据加载动态立绘 function this.LoadHerolive(_heroData, _objPoint) --TODO:动态加载立绘 local testLive = poolManager:LoadLive(_heroData.live, _objPoint.transform, Vector3.one * _heroData.scale, Vector3.New(_heroData.position[1], _heroData.position[2], 0)) local SkeletonGraphic = testLive:GetComponent("SkeletonGraphic") local idle = function() SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true) end SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete + idle poolManager:SetLiveClearCall(_heroData.live, testLive, function () SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete - idle end) return testLive end --根据界面数据加载动态立绘 function this.LoadHerolive1(data, _objPoint) --TODO:动态加载立绘 local testLive = poolManager:LoadLive(GetResourcePath(data.Live), _objPoint.transform, Vector3.one * data.Scale, Vector3.New(data.Position[1], data.Position[2], 0)) local SkeletonGraphic = testLive:GetComponent("SkeletonGraphic") local idle = function() SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true) end SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete + idle poolManager:SetLiveClearCall(GetResourcePath(data.Live), testLive, function () SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete - idle end) return testLive end function this.GetHongMengData(dynamicId) return heroDatas[dynamicId] end function this.SortHeroDatas(_heroDatas) local teamHero = FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.FORMATION_NORMAL) --上阵最优先,星级优先,同星级等级优先,同星级同等级按sortId排序。排序时降序排序。 table.sort(_heroDatas, function(a, b) if (teamHero[a.dynamicId] and teamHero[b.dynamicId]) or (not teamHero[a.dynamicId] and not teamHero[b.dynamicId]) then if a.heroConfig.Natural ==b.heroConfig.Natural then if a.star == b.star then if a.lv == b.lv then return a.heroConfig.Id < b.heroConfig.Id else return a.lv > b.lv end else return a.star > b.star end else return a.heroConfig.Natural > b.heroConfig.Natural end else return teamHero[a.dynamicId] and not teamHero[b.dynamicId] end end) end --脱下皮肤 function this.ChangeDownSkinId(heroSId,skinId) for k,v in pairs(heroDatas) do if v.id == heroSId and v.skinId == skinId then NetManager.ChangeHeroSkin(v.dynamicId,0,function() end) v.skinId = 0 v.skinConfig = heroConfig[v.id] v.live = GetResourcePath(v.skinConfig.Live) v.painting = GetResourcePath(v.skinConfig.Painting) v.icon = GetResourcePath(v.skinConfig.Icon) v.scale = v.skinConfig.Scale v.position = v.skinConfig.Position end end Game.GlobalEvent:DispatchEvent(GameEvent.Role.UpdateSkin) end function this.GetAllHerosByStar(curStar) local heros = {} for i, v in pairs(heroDatas) do if v.star == curStar then table.insert(heros,v) end end return heros end --判断是否是十一星神将 function this.IsElevenStar(v) -- body if v == this.awakeNextStarIndex then return true else return false end end --判断是否是十天赋神将 IsTenTalent function this.IsTenTalent(v) -- body --print(v," ")--,heroConfig[v].MaxRank) if heroConfig[v].MaxRank == this.awakeNextStarIndex or heroConfig[v].MaxRank == this.awakeStarIndex then return true else return false end end --套装新属性计算 --{{Star,{4#61#100}},{},{} local equipSuiteConfig = ConfigManager.GetConfig(ConfigName.EquipSuiteConfig) function this.GetCurHeroEquipSuitPros(equipIdList) local equipSuit = {} local curEquipLists = {} for i = 1, #equipIdList do --套装加成 local curEquip = EquipManager.GetSingleEquipData(equipIdList[i]) if equipSuiteConfig[curEquip.equipConfig.Star] then--有套装 table.insert(curEquipLists,curEquip) if #curEquipLists > 1 then end end end table.sort(curEquipLists, function(a, b) return a.equipConfig.Star < b.equipConfig.Star end) local num = #curEquipLists -- LogPink("num "..num) for i = 1, #curEquipLists do for _, configInfo in ConfigPairs(ConfigManager.GetConfig(ConfigName.EquipSuiteConfig)) do if configInfo.Id == curEquipLists[i].equipConfig.Star then if num > 1 then -- LogPink("curEquipLists[i].equipConfig.Star "..curEquipLists[i].equipConfig.Star.." "..num) local curequipSuit = {curEquipLists[i].equipConfig.Star,configInfo.SuiteValue[num - 1]} table.insert(equipSuit,curequipSuit) end num = num - 1 end end end -- for i = 1, #equipSuit do -- LogPink(equipSuit[i][1].. " " ..equipSuit[i][2][1]) -- end return equipSuit end function this.SetAllStarBreakIdData() for key, configInfo in ConfigPairs(ConfigManager.GetConfig(ConfigName.HeroRankupConfig)) do if configInfo.Type == 1 then if curAllStarBreakIdData[configInfo.Star] then curAllStarBreakIdData[configInfo.Star][configInfo.OpenLevel] = key else curAllStarBreakIdData[configInfo.Star] = {} curAllStarBreakIdData[configInfo.Star][configInfo.OpenLevel] = key end end end end function this.GetAllStarBreakIdData(sid,lv) local curHeroConFig = heroConfig[sid] local endBreakId = 0 for key, value in pairs(curAllStarBreakIdData[curHeroConFig.Star]) do if lv >= key and endBreakId < value then endBreakId = value end end return endBreakId end return this