miduo_client/Assets/ManagedResources/~Lua/Modules/Hero/HeroManager.lua

3922 lines
166 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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()
this.GetSingleProScoreVal()
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()
--赋值英雄战力
-- 计算所有人的战斗力
HeroPowerManager.InitAllPower()
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.." _msgHeroData.starBreakId:".._msgHeroData.starBreakId)
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 --法宝等级
heroData.sealIdList = _msgHeroData.sealIdList --紫府神印list
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 GetHeroPosStr(_configData.Profession) then
heroData.professionIcon = GetHeroPosStr(_configData.Profession)--GetJobSpriteStrByJobNum(_configData.Profession)
else
heroData.professionIcon = GetHeroPosStr(1)--GetJobSpriteStrByJobNum(1)
end
heroData.name = GetLanguageStrById(_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)
isFindHandBook = isFindHandBook or true
if isFindHandBook then --图鉴
PlayerManager.SetHeroHandBookListData(heroData.id, heroData.star)
CheckRedPointStatus(RedPointType.wujinBianDui)
CheckRedPointStatus(RedPointType.LikeabilityRed)
CheckRedPointStatus(RedPointType.EndlessPanel)
end
heroData.warPower = 0--HeroPowerManager.GetHeroPower(heroData.dynamicId)
--远征初始化血量
--ExpeditionManager.InitHeroHpValue(heroData)
end
-- 获取所有英雄数据
function this.GetAllHeroList()
return heroDatas
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
--设置战斗力脏数据
HeroPropManager.SetDirtyByType(heroId, Hero_Prop_Type.SkinAdd)
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 then-- 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[11097]
elseif teamId == FormationTypeDef.FORMATION_ARENA_DEFEND then
-- 101
return Language[11098]
elseif teamId == FormationTypeDef.FORMATION_ARENA_ATTACK then
-- 201
return Language[11099]
elseif teamId == FormationTypeDef.FORMATION_ENDLESS_MAP then
-- 401
return Language[11100]
elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_DEFEND then
-- 501
return Language[11101]
elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_ATTACK then
-- 502
-- elseif teamId == FormationTypeDef.MONSTER_CAMP_ATTACK then
-- return "该猎妖师在锁妖阵容中已上阵"-- 601
return Language[11102]
elseif teamId == FormationTypeDef.BLOODY_BATTLE_ATTACK then
-- 701
return Language[11103]
elseif teamId == FormationTypeDef.EXPEDITION then
return Language[10410]
-- 1001
elseif teamId == FormationTypeDef.ARENA_TOM_MATCH then
return Language[11104]
elseif teamId == FormationTypeDef.JUMPSERVER_HIGHTLADDER then
return"该神将在罗浮争锋阵容中已上阵"
end
end
return ""
end
function this.GetHeroFormationStr2(teamId)
if this.heroResolveLicence[teamId] then
if teamId < FormationTypeDef.FORMATION_ARENA_DEFEND then
return Language[11106], FormationTypeDef.FORMATION_NORMAL
elseif teamId == FormationTypeDef.FORMATION_ARENA_DEFEND then
return Language[11107], FormationTypeDef.FORMATION_ARENA_DEFEND
elseif teamId == FormationTypeDef.FORMATION_ARENA_ATTACK then
return Language[11108], FormationTypeDef.FORMATION_ARENA_ATTACK
elseif teamId == FormationTypeDef.FORMATION_ENDLESS_MAP then
return Language[10692], FormationTypeDef.FORMATION_ENDLESS_MAP
-- elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_DEFEND then
-- return Language[10682], FormationTypeDef.FORMATION_GUILD_FIGHT_DEFEND
-- elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_ATTACK then
-- return Language[10683], FormationTypeDef.FORMATION_GUILD_FIGHT_ATTACK
elseif teamId == FormationTypeDef.BLOODY_BATTLE_ATTACK then
return Language[11109], FormationTypeDef.BLOODY_BATTLE_ATTACK
elseif teamId == FormationTypeDef.EXPEDITION then
return Language[10697], FormationTypeDef.EXPEDITION
elseif teamId == FormationTypeDef.ARENA_TOM_MATCH then
return Language[11110], FormationTypeDef.ARENA_TOM_MATCH
elseif teamId == FormationTypeDef.JUMPSERVER_HIGHTLADDER then
return "罗浮争锋", FormationTypeDef.JUMPSERVER_HIGHTLADDER
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
-- 清除佩戴的魂印
local soulPrintList = heroDatas[heroDIds[i]].soulPrintList
for j = 1, #soulPrintList do
if soulPrintList[j] then
SoulPrintManager.DelSoulPrintUpHeroDynamicId(soulPrintList[j].equipId, heroDIds[i])
end
end
--清楚编队上的英雄
FormationManager.AllFormationDeleCurHeroId(heroDIds[i])
--清除英雄魂印上挂载的英雄did
SoulPrintManager.hasEquipSoulPrintId[heroDIds[i]] = nil
--删除远征英雄数据
ExpeditionManager.DelHeroHpValue(heroDatas[heroDIds[i]])
--删除英雄
heroDatas[heroDIds[i]] = nil
end
end
CheckRedPointStatus(RedPointType.Huaxutan_CompoundHero)
end
--更新本地单个英雄基本信息
function this.UpdateSingleHeroDatas(heroDId, heroLv, heroStar, breakId, upStarId, isCallBackChangeWar)
if heroDatas[heroDId] then
if heroLv then--鸿蒙阵上阵的等级是虚等级 升星不必赋值传nil 即可
heroDatas[heroDId].lv = heroLv
end
heroDatas[heroDId].star = heroStar
if breakId then--鸿蒙阵上阵的突破等级是虚等级 升星不必赋值传nil 即可
heroDatas[heroDId].breakId = breakId
end
heroDatas[heroDId].upStarId = upStarId
local actionPowerRormula = gameSetting[1].ActionPowerRormula
heroDatas[heroDId].actionPower =
heroDatas[heroDId].heroConfig.ActionPower +
math.floor(
(actionPowerRormula[1] * math.pow(heroDatas[heroDId].lv, 3) + actionPowerRormula[2] * math.pow(heroDatas[heroDId].lv, 2) +
actionPowerRormula[3] * heroDatas[heroDId].lv +
actionPowerRormula[4])
)
PlayerManager.SetHeroHandBookListData(heroDatas[heroDId].id, heroDatas[heroDId].star)
end
--设置战斗力脏数据
-- 英雄基础数据变化
HeroPropManager.SetDirtyByType(heroDId, Hero_Prop_Type.Base)
HeroPropManager.SetDirtyByType(heroDId, Hero_Prop_Type.PassiveSkill)
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 = HeroPowerManager.GetHeroPower(heroDId)
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.CompareWarPower1(heroDId,oldWarPowerValue)
local newWarPowerValue = HeroPowerManager.GetHeroPower(heroDId)
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)
--LogGreen("heroDId"..tostring(heroDId))
if heroDatas[heroDId] then
return heroDatas[heroDId]
elseif ExpeditionManager.GetSingleHeroData(heroDId) then
return ExpeditionManager.GetSingleHeroData(heroDId)
elseif MonsterCampManager.GetSingleHeroData(heroDId) then
return MonsterCampManager.GetSingleHeroData(heroDId)
elseif EndLessMapManager.GetSingleHeroData(heroDId) then
return EndLessMapManager.GetSingleHeroData(heroDId)
else
return nil
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 = {}
--0 没有 1 有满足条件单位英雄
needHeroListData = {}
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, v)
end
else
table.insert(needHeroListData, v)
end
end
else
if heroRankUpGroup.IsId > 0 then
if v.id == heroRankUpGroup.IsId then
table.insert(needHeroListData, v)
end
else
table.insert(needHeroListData, 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, v)
end
else
table.insert(needHeroListData, v)
end
end
else
if heroRankUpGroup.IsId > 0 then
if v.id == heroRankUpGroup.IsId then
table.insert(needHeroListData, v)
end
else
table.insert(needHeroListData, v)
end
end
end
end
end
end
--删除编队上的英雄
if needHeroListData and LengthOfTable(needHeroListData) > 0 then
for i, v in pairs(needHeroListData) 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
table.sort(needHeroListData,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
)
--前边以前添加英雄代码不动
local canSeleItemIds = {}
if heroRankUpGroup.ItemCamp and #heroRankUpGroup.ItemCamp > 0 then
for i = 1, #heroRankUpGroup.ItemCamp do
if heroData.heroConfig.PropertyName == heroRankUpGroup.ItemCamp[i][1] then
local itemId = heroRankUpGroup.ItemCamp[i][2]
local haveNum = BagManager.GetItemCountById(itemId)
if haveNum > 0 then
for i = 1, haveNum do
local v = {}
v.id = itemId
table.insert(canSeleItemIds,itemId)
end
end
end
end
end
if heroRankUpGroup.Items and #heroRankUpGroup.Items > 0 then
for i = 1, #heroRankUpGroup.Items do
local itemId = heroRankUpGroup.Items[i]
local haveNum = BagManager.GetItemCountById(itemId)
if haveNum > 0 then
for i = 1, haveNum do
local v = {}
v.id = itemId
table.insert(canSeleItemIds,itemId)
end
end
end
end
local needHeroListData2 = {}
needHeroListData2.state = 0
--0 没有 1 有满足条件单位英雄
needHeroListData2.heroList = {}
if #needHeroListData > 0 or #canSeleItemIds > 0 then
needHeroListData2.state = 1
end
--道具靠前
if #canSeleItemIds > 0 then
for i, v in ipairs(canSeleItemIds) do
local vData = {}
vData.id = v
vData.type = RoleUpStarMatType.item--1道具 2 英雄 需要传给后端
vData.index = i--用于祭品选择界面 查看是否选中
table.insert(needHeroListData2.heroList, vData)
end
end
--英雄靠后
if #needHeroListData > 0 then
for i, v in ipairs(needHeroListData) do
v.type = RoleUpStarMatType.hero--1道具 2 英雄 需要传给后端
table.insert(needHeroListData2.heroList, v)
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]<v.RankupPara then
-- this.heroLvBreakNum[threeStarLvEnd]=v.RankupPara
-- end
-- elseif v.Star==fourStarLvEnd then
-- if v.Type==1 and this.heroLvBreakNum[fourStarLvEnd]<v.RankupPara then
-- this.heroLvBreakNum[fourStarLvEnd]=v.RankupPara
-- end
-- elseif v.Star==fiveStarLvEnd then
-- if v.Type==1 and this.heroLvBreakNum[fiveStarLvEnd]<v.RankupPara then
-- this.heroLvBreakNum[fiveStarLvEnd]=v.RankupPara
-- end
-- end
--end
end
--计算英雄当前星级的等级上限
function this.GetCurHeroStarLvEnd(getValType, curHeroData, _breakId, _upStarId)
local breakId = 0
local upStarId = 0
if getValType == 1 then
breakId = curHeroData.breakId
upStarId = curHeroData.upStarId
else
breakId = _breakId
upStarId = _upStarId
end
if breakId == 0 then --从没突破过 显示当前初始星级的等级上限
for i, v in ConfigPairs(heroRankUpConfig) do
if v.Star == curHeroData.heroConfig.Star then
return v.LimitLevel
end
end
elseif breakId > 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 = HeroPowerManager.GetHeroPower(v.dynamicId)
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 = HeroPowerManager.GetHeroPower(v.dynamicId)
--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 GetLanguageStrById(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
local curAllPassiveSkillIds = {}
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 and #cursoulPrintConfig.PassiveSkill > 0 then
for i = 1, #cursoulPrintConfig.PassiveSkill do
table.insert(curAllPassiveSkillIds,cursoulPrintConfig.PassiveSkill[i])
end
end
end
end
singleHeroProVal,lvProVal,allHeroProVal,specialProVal = this.CalculatePassiveSkillsValList(WarPowerType.SoulPrint,curAllPassiveSkillIds)
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) or
MonsterCampManager.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
--神应属性
local tLv = curEuipTreaSureData.treeLv
if
configInfo.PoolID == curEuipTreaSureConfig.GodHoodPool and configInfo.Type == 3 and
configInfo.Level == tLv
then
for j = 1, SacredTreeManager.CulAttri(curEuipTreaSureData) 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("属性ID " .. _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("被动技能在被动技能表PassiveSkillLogicConfig没有找到 " .. 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 heroFetterAddPro = TianShuMiJuanManger.GetAllFetterAddProsBy(1)
this.DoubleTableCompound(teamProVal, heroFetterAddPro)
--魂印羁绊加成
local hunyinFetterAddPro = TianShuMiJuanManger.GetAllFetterAddProsBy(2)
this.DoubleTableCompound(teamProVal, hunyinFetterAddPro)
--光环加成
local aureoleProAdd = FormationManager.GetCurFormationElementAdd(teamHeroInfos)
this.DoubleTableCompound(teamProVal, aureoleProAdd)
--修行加成
local practiceAddPro = PracticeManager.GetCurAllGetAdd()
this.DoubleTableCompound(teamProVal, practiceAddPro)
return teamProVal
end
--计算英雄身上所有属性加成(包括装备就、异妖的加成)
--_type==1 计算当前英雄的所有属性 _type==2 根据_heroDid之后_breakId传过来的值进行计算 _isAllHeroProVal==true 团体加成综合 用字段_allHeroProVal
function this.CalculateHeroAllProValList(_type, _heroDid, isWar, _breakId, _upStarId, _isAllHeroProVal, _allHeroProVal,formationHeroNum, formationId)
-- LogRed(" ------- ------------ 原战斗计算方式不应调用 ----------- -------")
local curHeroData = this.GetSingleHeroData(_heroDid) or _heroDid
local curLvNum = curHeroData.lv
--添加该英雄装备的属性
local allEquipScore = PlayerManager.GetSingHeroAllEquipSkillListScore(curHeroData)
--获取单个英雄装备被动技能累计评分
local allAddProVal = {}
--单体所有属性加成
local lvProVal = {}
--100等级所有属性加成 升一级 加一次
local allHeroProVal = _allHeroProVal or {}
--团体所有属性加成
local specialProVal = {}
--4公式特殊减乘所有属性加成
allAddProVal = CalculateHeroUpEquipsProAddVal(curHeroData.dynamicId)
LogRed_Prop("装备加成")
LogRedTable_Prop(allAddProVal)
--异妖配件的加成
local allPokemonPeiJianAddPro = DiffMonsterManager.CalculateAllPokemonPeiJiAllProAddVal(curHeroData.heroConfig.Profession)
LogRed_Prop("异妖配件的加成")
LogRedTable_Prop(allPokemonPeiJianAddPro)
--科技树加成
local treeAllProAdd = WorkShopManager.HeroCalculateTreeWarForce(curHeroData.heroConfig.Profession)
LogRed_Prop("科技树加成")
LogRedTable_Prop(treeAllProAdd)
--公会技能加成
local guildSkillAllProAdd = GuildSkillManager.HeroCalculateGuildSkillWarForce(curHeroData.heroConfig.Profession)
LogRed_Prop("公会技能加成")
LogRedTable_Prop(guildSkillAllProAdd)
--四象心法加成
local fourQuaderAllProAdd = PracticeManager.HeroCalculateFourQuaWarForce(curHeroData.heroConfig.Profession)
LogRed_Prop("四象心法加成")
LogRedTable_Prop(fourQuaderAllProAdd)
--英雄被动技能属性加成
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
LogRed_Prop("英雄被动技的单体属性加成")
LogRedTable_Prop(heroSkillSingleHeroProVal)
LogRed_Prop("英雄被动技的等极限值属性加成")
LogRedTable_Prop(heroSkillLvProVal)
LogRed_Prop("英雄被动技的团体属性加成")
LogRedTable_Prop(heroSkillAllHeroProVal)
--法宝的属性加成 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
LogRed_Prop("法宝的单体属性加成")
LogRedTable_Prop(falismanSingleHeroProVal)
LogRed_Prop("法宝的等极限值属性加成")
LogRedTable_Prop(falismanLvProVal)
LogRed_Prop("法宝的团体属性加成")
LogRedTable_Prop(falismanAllHeroProVal)
--魂印的属性加成
local singleHeroSoulPrintProVal,lvSoulPrintProVal,allHeroSoulPrintProVal,specialSoulPrintProVal = CalculateSoulPrintAddVal(curHeroData.dynamicId)
LogRed_Prop("魂印单体加成")
LogRedTable_Prop(singleHeroSoulPrintProVal)
LogRed_Prop("魂印100+加成")
LogRedTable_Prop(lvSoulPrintProVal)
LogRed_Prop("魂印团体加成")
LogRedTable_Prop(allHeroSoulPrintProVal)
LogRed_Prop("魂印特殊加成")
LogRedTable_Prop(specialSoulPrintProVal)
local allSoulPrintAddWarPowerVal = CalculateSoulPrintAddVal2(curHeroData.dynamicId)
LogRed_Prop("魂印战斗力加成 "..allSoulPrintAddWarPowerVal)
--宝器加成 宝器本身属性 + 宝器激活的强化共鸣 和 精炼共鸣
local equipTreasureAddPro = CalculateEquipTreaSureAddVal(curHeroData.dynamicId)
LogRed_Prop("宝器加成")
LogRedTable_Prop(equipTreasureAddPro)
--玩家称号 皮肤 坐骑属性加成
local playerDcorateAdd = PlayerManager.CalculatePlayerDcorateProAddVal()
LogRed_Prop("玩家称号 皮肤 坐骑属性加成")
LogRedTable_Prop(playerDcorateAdd)
--编队光环加成
local teamAddPro = FormationManager.GetCurFormationElementAddByType(FormationTypeDef.FORMATION_NORMAL, curHeroData.dynamicId)
LogRed_Prop("编队光环加成")
LogRedTable_Prop(teamAddPro)
-- Vip加成 暂时注释
local vipAddPro = VipManager.GetAddPro()
LogRed_Prop("Vip加成")
LogRedTable_Prop(vipAddPro)
local heroSkinSingleProVal, heroSkinAllHeroProVal = HeroSkinManager.CaculateSkinProVal(curHeroData)
this.DoubleTableCompound(allAddProVal, heroSkinSingleProVal)
this.DoubleTableCompound(allAddProVal, heroSkinAllHeroProVal)
--灵兽 现在只在编队战力中计算 因为单个英雄可以上多个编队
local pokemonFormationAllHeroProVal = {}
if formationId then
local formation = FormationManager.GetFormationByID(formationId)
local formationHeroNum = #formation.teamHeroInfos
if formationHeroNum and formationHeroNum > 0 then
pokemonFormationAllHeroProVal = PokemonManager.GetPokemonFormationTeamAddPro(formationHeroNum)
end
end
LogRed_Prop("灵兽加成")
LogRedTable_Prop(pokemonFormationAllHeroProVal)
--灵兽羁绊
local pokemonFetterAddPro = PokemonManager.GetAllPokemonFetterAddPros()
LogRed_Prop("灵兽羁绊 最终 加成 ")
LogRedTable_Prop(pokemonFetterAddPro)
--神将羁绊
local heroFetterAddPro = TianShuMiJuanManger.GetAllFetterAddProsBy(1)
LogRed_Prop("神将羁绊 最终 加成 ")
LogRedTable_Prop(heroFetterAddPro)
--魂印羁绊
local hunyinFetterAddPro = TianShuMiJuanManger.GetAllFetterAddProsBy(2)
LogRed_Prop("魂印羁绊 最终 加成 ")
LogRedTable_Prop(hunyinFetterAddPro)
--灵兽羁绊单加战力 暂时去掉
-- 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
--修行加成
local practiceAddPro = PracticeManager.GetCurAllGetAdd()
LogRed_Prop("修行加成")
LogRedTable_Prop(practiceAddPro)
--单体所有属性合并
this.DoubleTableCompound(allAddProVal, allPokemonPeiJianAddPro)
this.DoubleTableCompound(allAddProVal, guildSkillAllProAdd)
this.DoubleTableCompound(allAddProVal, fourQuaderAllProAdd)
this.DoubleTableCompound(allAddProVal, falismanSingleHeroProVal)
this.DoubleTableCompound(allAddProVal,singleHeroSoulPrintProVal)
this.DoubleTableCompound(allAddProVal, playerDcorateAdd)
this.DoubleTableCompound(allAddProVal, heroSkillSingleHeroProVal)
this.DoubleTableCompound(allAddProVal, equipTreasureAddPro)
this.DoubleTableCompound(allAddProVal, vipAddPro)
this.DoubleTableCompound(allAddProVal, heroSkinSingleProVal)
this.DoubleTableCompound(allAddProVal, heroSkinAllHeroProVal)
--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, heroFetterAddPro)
this.DoubleTableCompound(allHeroProVal, hunyinFetterAddPro)
this.DoubleTableCompound(allHeroProVal, pokemonFormationAllHeroProVal)
this.DoubleTableCompound(allHeroProVal, practiceAddPro)
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公式特殊
--Log("proValue * (1 + upStarRankupPara/10000) * lvNum+proValue*breakRankupPara/10000")
local GrowProVal = {}
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])
GrowProVal[HeroProType.Attack] =
this.CalculateProVal(
curHeroData.attack,
curLvNum,
curHeroData.breakId,
curHeroData.upStarId,
HeroProType.Attack
)
GrowProVal[HeroProType.Hp] =
this.CalculateProVal(curHeroData.hp, curLvNum, curHeroData.breakId, curHeroData.upStarId, HeroProType.Hp)
GrowProVal[HeroProType.PhysicalDefence] =
this.CalculateProVal(
curHeroData.pDef,
curLvNum,
curHeroData.breakId,
curHeroData.upStarId,
HeroProType.PhysicalDefence
)
GrowProVal[HeroProType.MagicDefence] =
this.CalculateProVal(
curHeroData.mDef,
curLvNum,
curHeroData.breakId,
curHeroData.upStarId,
HeroProType.MagicDefence
)
elseif _type == 2 then
GrowProVal[HeroProType.Attack] =
this.CalculateProVal(curHeroData.attack, curLvNum, _breakId, _upStarId, HeroProType.Attack)
GrowProVal[HeroProType.Hp] =
this.CalculateProVal(curHeroData.hp, curLvNum, _breakId, _upStarId, HeroProType.Hp)
GrowProVal[HeroProType.PhysicalDefence] =
this.CalculateProVal(curHeroData.pDef, curLvNum, _breakId, _upStarId, HeroProType.PhysicalDefence)
GrowProVal[HeroProType.MagicDefence] =
this.CalculateProVal(curHeroData.mDef, curLvNum, _breakId, _upStarId, 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
LogRed_Prop("成长属性")
LogRedTable_Prop(GrowProVal)
this.DoubleTableCompound(allAddProVal, GrowProVal)
LogRed_Prop("所有属性综合1")
LogRedTable_Prop(allAddProVal)
--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
else
allAddProVal[curProConfig.TargetPropertyId] = allAddProVal[curProConfig.TargetPropertyId] + allAddProVal[k]/100
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
LogRed_Prop("所有属性综合2")
LogRedTable_Prop(allAddProVal)
--目前没有 王振兴加 最后计算个属性的乘减算
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
-- LogGreenTable(allAddProVal)
-- LogRed("原方式:"..allAddProVal[HeroProType.WarPower])
-- local power = HeroPowerManager.GetHeroPower(_heroDid, formationId)
-- LogRed("新方式:"..power)
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 = HeroPropManager.GetHeroProp(heroDid)--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 then
heros[index] = v
index = index + 1
end
end
end
return heros
end
--通过职业,阵营筛选英雄
function this.GetHeroDataByPropertyAndProfession(_property, _profession,_star)
local heros = {}
local index = 1
for i, v in pairs(heroDatas) do
if (v.profession == _profession or _profession == 0) and (v.PropertyName == _property or _property == 0) and (v.star >= _star) then --0 全职业
heros[index] = v
index = index + 1
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)
--设置战斗力脏数据
HeroPropManager.SetDirtyByType(heroDid, Hero_Prop_Type.SoulPrint)
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)
--设置战斗力脏数据
HeroPropManager.SetDirtyByType(heroDid, Hero_Prop_Type.SoulPrint)
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)
local isCanUpEquipTreasure
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig,40)
if config then
local limits = string.split(config.Value, "|")
if limits then
local heroConfig = curHeroData.heroConfig
local lvs = string.split(limits[1], "#")
local stars = string.split(limits[2], "#")
if PlayerManager.level >= tonumber(lvs[2]) and heroConfig ~= nil and heroConfig.MaxRank >= tonumber(stars[2]) then
isCanUpEquipTreasure = true
else
isCanUpEquipTreasure = false
end
else
isCanUpEquipTreasure = false
end
else
isCanUpEquipTreasure = false
end
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) or
(isCanUpEquipTreasure and #HeroManager.GetHeroIsUpTreasure(curHeroData.dynamicId,0) > 0) or
HeroManager.CheckIsUpTreasure(curHeroData.jewels[1],0) or
HeroManager.CheckIsUpTreasure(curHeroData.jewels[2],0)
then
return true
end
end
return SacredTreeManager.CheckRedPoint()
end
--化虚坛红点判断
function this.GetAllHeroCompoundRedPoint()
if ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.COMPOUND_HERO) then
for i, v in pairs(heroDatas) do
if v.star == 4 or v.star == 5 then
if this.IsShowUpStarRedPoint(v,true) then
return true
end
end
end
end
return false
end
--单个英雄所有红点判断
function this.GetCurHeroIsShowRedPoint(curHeroData)
local isCanUpEquipTreasure
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig,40)
if config then
local limits = string.split(config.Value, "|")
if limits then
local heroConfig = curHeroData.heroConfig
local lvs = string.split(limits[1], "#")
local stars = string.split(limits[2], "#")
if PlayerManager.level >= tonumber(lvs[2]) and heroConfig ~= nil and heroConfig.MaxRank >= tonumber(stars[2]) then
isCanUpEquipTreasure = true
else
isCanUpEquipTreasure = false
end
else
isCanUpEquipTreasure = false
end
else
isCanUpEquipTreasure = false
end
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) or
(#this.GetHeroIsUpTreasure(curHeroData.dynamicId,0) > 0 and isCanUpEquipTreasure) or
HeroManager.CheckIsUpTreasure(curHeroData.jewels[1],0) or
HeroManager.CheckIsUpTreasure(curHeroData.jewels[2],0)
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)
--是否为最大等级
--print( curHeroData.lv.." 最大:"..HeroManager.heroLvEnd[curHeroData.heroConfig.Id])
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 and (not HarmonyManager.IsChangeColor(curHeroData.dynamicId)) then
return true
else
return false
end
end
else --从未进阶过处理
return false
end
else
if isUpLvMaterials and (not HarmonyManager.IsChangeColor(curHeroData.dynamicId)) then
return true
else
return false
end
end
return false
end
--单个英雄升星红点
function this.IsShowUpStarRedPoint(curHeroData,isNoDeleFormation)--isNoDeleFormation 可选传参数 材料筛选是否去除上阵英雄
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 == "" or isNoDeleFormation) and
#curSelectHeroList < curSelectUpStarData.upStarData[4] and
not upStarConsumeMaterial[upStarHeroListData.heroList[j].dynamicId] and
not HarmonyManager.IsChangeColor(upStarHeroListData.heroList[j].dynamicId) and
not (HarmonyManager:IsEnvoy(upStarHeroListData.heroList[j].dynamicId) and HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv) and HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).heroTid == 0)
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 > 0 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
--宝物
function this.GetHeroIsUpTreasure(heroDid,pos)
if heroDatas[heroDid] then
local heroData = heroDatas[heroDid]
local lackEquips = {}
for i = 1, 2 do
local equipIdAndWarPower = {}
equipIdAndWarPower.pos = i
equipIdAndWarPower.id = "0"
equipIdAndWarPower.warPower = 0
lackEquips[i] = equipIdAndWarPower
end
-- 有装备的位置赋值装备id及战力
if heroData.jewels and #heroData.jewels > 0 then
for i = 1, #heroData.jewels do
if not heroData.jewels[i] then
else
local curEquipConFigData =
EquipTreasureManager.GetSingleTreasureByIdDyn(heroData.jewels[i])
if not curEquipConFigData then
LogBlue("-------------------------"..heroData.jewels[i] .. " " .. heroDid)
else
lackEquips[curEquipConFigData.equipType].id = heroData.jewels[i]
lackEquips[curEquipConFigData.equipType].warPower =
EquipTreasureManager.CalculateWarForce(heroData.jewels[i])
end
end
end
end
local allEquipTreasures = EquipTreasureManager.GetAllTreasuresByLocation(pos, heroData.heroConfig.PropertyName)
for k, v in ipairs(allEquipTreasures) do
--比较战力 高战力的装备add
if lackEquips[v.equipType].id == "0" then
lackEquips[v.equipType].id = v.idDyn
lackEquips[v.equipType].warPower = EquipTreasureManager.CalculateWarForce(v.idDyn)
else
local nextEquipWarPower = EquipTreasureManager.CalculateWarForce(v.idDyn)
if nextEquipWarPower > lackEquips[v.equipType].warPower then
lackEquips[v.equipType].id = v.idDyn
lackEquips[v.equipType].warPower = EquipTreasureManager.CalculateWarForce(v.idDyn)
end
end
end
--去掉与自己本身自带的重合装备
local allUpEquipDidTabs = {}
for k,v in pairs(lackEquips) do
if v.id ~= "0" then
local isAdd = true
for j = 1, #heroData.jewels do
if heroData.jewels[j] == v.id then
isAdd = false
end
end
if isAdd then
table.insert(allUpEquipDidTabs, v.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 HarmonyManager.IsChangeColor(curHeroData.dynamicId) then
-- body
return false
end
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 = HeroPowerManager.GetHeroPower(heroDatas[dynamicloadId].dynamicId)
--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.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)
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
local configInfo = equipSuiteConfig[curEquipLists[i].equipConfig.Star]
if configInfo and num > 1 then
-- LogPink("curEquipLists[i].equipConfig.Star "..curEquipLists[i].equipConfig.Star.." "..num)
local curequipSuit = {configInfo.Id, configInfo.SuiteValue[num - 1]}
table.insert(equipSuit, 1, curequipSuit)
end
num = num - 1
end
-- for i = 1, #equipSuit do
-- LogPink(equipSuit[i][1].. " " ..equipSuit[i][2][1])
-- end
return equipSuit
end
-- 获取白金套装属性
function this.GetCurHeroBaiJinEquipSuitPros(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)
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
local configInfo = equipSuiteConfig[curEquipLists[i].equipConfig.Star]
if configInfo and configInfo.SuiteSkill then
local len = #configInfo.SuiteSkill
for x = len , 1, -1 do
local skill = configInfo.SuiteSkill[x]
if skill[1] == num then
-- LogPink("curEquipLists[i].equipConfig.Star "..configInfo.Id.." "..num)
local curequipSuit = {configInfo.Id, skill}
table.insert(equipSuit, 1, curequipSuit)
break
end
end
end
num = num - 1
end
-- for i = 1, #equipSuit do
-- LogPink(equipSuit[i][1].. " " ..equipSuit[i][2][1])
-- end
return equipSuit
end
--设置英雄皮肤脏数据
function this.SetHerosSkinWarPowerState()
for i, v in pairs(heroDatas) do
if v.skinId ~= 0 then
--设置战斗力脏数据
HeroPropManager.SetDirtyByType(i, Hero_Prop_Type.SkinAdd)
end
end
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.LimitLevel] = key
else
curAllStarBreakIdData[configInfo.Star] = {}
curAllStarBreakIdData[configInfo.Star][configInfo.LimitLevel] = 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
function this.UpdateSingleHeroWarPower(dynamicId)
if dynamicId and heroDatas[dynamicId] then
HeroPropManager.SetHeroDirty(dynamicId)--SetDirtyByType(dynamicId, Hero_Prop_Type.Base)
-- heroDatas[dynamicId].warPower = this.CalculateHeroAllProValList(1, dynamicId, false)[HeroProType.WarPower]
-- LogGreen(heroDatas[dynamicId].heroConfig.ReadingName.." "..heroDatas[dynamicId].lv.." warPower ".. heroDatas[dynamicId].warPower)
end
end
--查找英雄身上的装备List
function this.GetEquipedEquipList()
local EquipedEquipList = {}
for _, heroData in ipairs(this.heroDataLists) do
for i = 1, #heroData.equipIdList do
local data = heroData.equipIdList[i]
table.insert(EquipedEquipList,data)
end
end
return EquipedEquipList
end
--通过装备id找英雄id
function this.GetHeroIdByEquipId(_id)
for _, heroData in ipairs(this.heroDataLists) do
for i = 1, #heroData.equipIdList do
if _id == tonumber(heroData.equipIdList[i]) then
return heroData.name
end
end
end
end
function this.CheckIsUpTreasure(Did,index)
if not Did then
return false
end
local curEquipData = EquipTreasureManager.GetSingleEquipTreasreData(Did) or MonsterCampManager.GetSingleTreasureByIdDyn(Did) or ExpeditionManager.GetSingleTreasureByIdDyn(Did) or GoodFriendManager.GetSingleTreasureByIdDyn(Did)
local isMax,isMatEnough,items
local indexType = curEquipData.equipType == 1 and HarmonyAddType.HunSoulPrint or HarmonyAddType.LingSoulPrint
if index == 1 then
isMax = curEquipData.lv == curEquipData.maxLv
items,isMatEnough = this.GetCostItems(curEquipData,curEquipData.strongConfig)
isMatEnough = isMatEnough and
--not (HarmonyManager.IsInfo(curEquipData.upHeroDid) and HarmonyManager.GetSingleAdditions(indexType) ~= -1)
not (HarmonyManager.IsInfo(curEquipData.upHeroDid))
elseif index == 2 then
isMax = curEquipData.refineLv == curEquipData.maxRefineLv
items,isMatEnough = this.GetCostItems(curEquipData,curEquipData.refineConfig)
else
isMax = (curEquipData.lv == curEquipData.maxLv) and (curEquipData.refineLv==curEquipData.maxRefineLv)
items,isMatEnough = this.GetCostItems(curEquipData,curEquipData.refineConfig)
if not isMatEnough then
items,isMatEnough = this.GetCostItems(curEquipData,curEquipData.strongConfig)
isMatEnough = isMatEnough and
--not (HarmonyManager.IsInfo(curEquipData.upHeroDid) and HarmonyManager.GetSingleAdditions(indexType) ~= -1)
not (HarmonyManager.IsInfo(curEquipData.upHeroDid))
end
end
local teamHero=FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.FORMATION_NORMAL)
if not isMax and isMatEnough and teamHero[curEquipData.upHeroDid] then
return true
end
return false
end
--获取消耗物品数据
function this.GetCostItems(curEquipData,_config)
if _config==nil then
return
end
local config = _config
local exps = config.UpExpend
if exps == nil then
return
end
local items={}
for i = 1,#exps do
local id=exps[i][1]
if itemConfig[id] then
local item={}
item.id=id
item.icon=GetResourcePath(itemConfig[id].ResourceID)
item.frame=GetQuantityImageByquality(itemConfig[id].Quantity)
item.haveNum=BagManager.GetItemCountById(id)
item.needNum=exps[i][2]
item.isEnough=item.haveNum>=item.needNum
items[i]=item
end
end
if config.JewelExpend then
for i = 1, #config.JewelExpend do
local id=config.JewelExpend[i]
local item={}
--同类型宝物
local type=id[1]
if type==1 then
item.id=curEquipData.id
item.icon=curEquipData.icon
item.frame=curEquipData.frame
local equips,num=EquipTreasureManager.GetEnoughRefineTreasure(curEquipData.id,curEquipData.idDyn)
if equips then
item.haveNum= num
else
item.haveNum=0
end
item.needNum=id[2]
if item.haveNum>=item.needNum then
item.isEnough=true
else
item.isEnough=false
end
items[#items+1]=item
else
item.id=type
local config=itemConfig[type]
if config then
item.icon=GetResourcePath(config.ResourceID)
item.frame=GetQuantityImageByquality(config.Quantity)
local equips,num=EquipTreasureManager.GetEnoughRefineTreasure(type,curEquipData.idDyn)
if equips then
item.haveNum= num
else
item.haveNum=0
end
item.needNum=id[2]
if item.haveNum>=item.needNum then
item.isEnough=true
else
item.isEnough=false
end
items[#items+1]=item
end
end
end
end
local isEnough = true
for k,v in pairs(items) do
if not v.isEnough then
isEnough = false
break
end
end
return items,isEnough
end
function this.CalculatePvpBonusForShow(data)
--因为后端无法区分是否为PVP所以前端处理把PVP伤害加成和减免从伤害加成和减免中去除
if data[51] and data[69] then
data[51] = data[51] - data[69] or 0
end
if data[52] and data[70] then
data[52] = data[52] - data[70] or 0
end
return data
end
return this