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

526 lines
25 KiB
Lua
Raw Normal View History

2021-01-22 16:53:50 +08:00
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
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 passiveSkillLogicConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig)
Hero_Prop_Type = {
Base = 0, -- 基础属性,自身成长
Equip = 1, -- 装备
EquipTreasure = 2, -- 宝物
PassiveSkill = 4, -- 被动,天赋
Talisman = 5, -- 法宝
SoulPrint = 6, -- 魂印
SkinAdd = 7, -- 皮肤
2021-09-26 09:54:58 +08:00
LikeAbility = 8, -- 好感度
2021-10-18 10:36:32 +08:00
GodSoul = 9, -- 神魂
2021-11-16 15:24:17 +08:00
TailsManSou = 10, -- 法宝之魂
2021-01-22 16:53:50 +08:00
}
local BattlePropToConfig = {}
local TargetPropToConfig = {}
-- 将战斗中的被动属性转为ui用的属性
local function BattlePropToUIProp(id, v, ct)
if not BattlePropToConfig[id] then
BattlePropToConfig[id] = ConfigManager.GetConfigDataByKey(ConfigName.PropertyConfig, "PropertyIdInBattle", id)
end
local config = BattlePropToConfig[id]
if not config then
return id, v
end
local propId = config.PropertyId
local style = config.Style
local value = style == 1 and v or v * 10000
if ct == 1 then
return propId, value
elseif ct == 2 then
-- 对固定值的百分比加成转换成 对应的属性
if style == 1 then
if not TargetPropToConfig[propId] then
TargetPropToConfig[propId] = ConfigManager.TryGetConfigDataByKey(ConfigName.PropertyConfig, "TargetPropertyId", propId)
end
if TargetPropToConfig[propId] then
local propId2 = TargetPropToConfig[propId].PropertyId
local value = TargetPropToConfig[propId].Style == 1 and v or v * 10000
if propId2 then
return propId2, value
end
end
end
return propId, value
elseif ct == 3 then
return propId, -value
elseif ct == 4 then
return propId, value
end
end
-- 被动技能转换为属性列表
local function PassiveListToPropList(skillids)
local propList = {} -- 自身属性
local conPropList = {} -- 条件属性
local teamPropList = {} -- 团队属性
local conTeamPropList = {} -- 团队条件属性
local dePropList = {} -- 百分比减益属性(特殊计算)
for i = 1, #skillids do
local skillid = skillids[i]
if passiveSkillLogicConfig[skillid] then
local curSkillData = passiveSkillLogicConfig[skillid]
if curSkillData.EffectiveRange > 1 then
local args = curSkillData.Value
-- 计算
local pId, v, ct
if curSkillData.Type == 90 then -- [a]增加[b][c]改变 || a[属性]b[float]c[改变类型]
pId, v, ct = args[1], args[2], args[3]
elseif curSkillData.Type == 94 then -- 全体上阵武将增加[a]%[b],[c]改变 || a[float]b[属性]c[改变类型]
pId, v, ct = args[2], args[1], args[3]
elseif curSkillData.Type == 171 then -- 武将100级后每升一级[a]额外增加[b][c]改变(战斗外实现) || a[属性]b[float]c[改变类型]
pId, v, ct = args[1], args[2], args[3]
elseif curSkillData.Type == 129 then -- 全体上阵[a]元素角色增加[b]%[c][d]改变 || a[元素]b[float]c[属性]d[改变类型]
pId, v, ct = args[3], args[2], args[4]
end
-- 获取UI属性
LogRed_Prop(string.format("args = %s|%s|%s", pId, v, ct))
local propId, value = BattlePropToUIProp(pId, v, ct)
LogRed_Prop(string.format("prop = %s|%s", propId, value))
if curSkillData.EffectiveRange == 2 then --战前个人
if ct == 4 then -- 减益效果
table.insert(dePropList, {propId = propId ,value = value})
elseif curSkillData.Type == 171 then -- 100级才开始加成(个人条件属性)
local propList = {}
propList[propId] = value
table.insert(conPropList, {type = Condition_Prop_Type.LV_100, propList = propList, args = args})
else
if not propList[propId] then
propList[propId] = 0
end
propList[propId] = propList[propId] + value
end
else
-- 条件
if curSkillData.Type == 129 then -- (团队条件属性)
local propList = {}
propList[propId] = value
table.insert(conTeamPropList, {type = Condition_Prop_Type.ELE_TEAM_ADD, propList = propList, args = args})
else
if not teamPropList[propId] then
teamPropList[propId] = 0
end
teamPropList[propId] = teamPropList[propId] + value
end
end
end
end
end
return propList, conPropList, teamPropList, conTeamPropList, dePropList
end
Hero_Prop_Func = {
-- 基础属性计算
[Hero_Prop_Type.Base] = function(_heroData)
local allAddProVal = {}
local tData = heroConfig[_heroData.tId]
local curLvNum = _heroData.lv
local breakId = _heroData.breakId
local upStarId = _heroData.upStarId
allAddProVal[HeroProType.Attack] = HeroManager.CalculateProVal( tData.Attack, curLvNum,breakId, upStarId, HeroProType.Attack)
allAddProVal[HeroProType.Hp] = HeroManager.CalculateProVal(tData.Hp, curLvNum, breakId, upStarId, HeroProType.Hp)
allAddProVal[HeroProType.PhysicalDefence] = HeroManager.CalculateProVal(tData.PhysicalDefence, curLvNum, breakId, upStarId, HeroProType.PhysicalDefence)
allAddProVal[HeroProType.MagicDefence] = HeroManager.CalculateProVal(tData.MagicDefence, curLvNum, breakId, upStarId, HeroProType.MagicDefence)
local subProp = tData.SecondaryFactor
if subProp then
for i = 1, #subProp do
local propType = subProp[i][1]
local propValue = subProp[i][2]
if not allAddProVal[propType] then
allAddProVal[propType] = 0
end
allAddProVal[propType] = allAddProVal[propType] + propValue
end
end
return allAddProVal
end,
-- 普通装备
[Hero_Prop_Type.Equip] = function(_heroData)
2021-01-25 21:02:35 +08:00
local equipIdList = {}
2021-01-22 16:53:50 +08:00
local addAllProVal = {}
for i, v in ConfigPairs(propertyConfig) do
addAllProVal[i] = 0
end
2021-01-25 21:02:35 +08:00
local curHeroData = _heroData
if curHeroData then
for i = 1, #curHeroData.equipList do
table.insert(equipIdList,curHeroData.equipList[i].id)
end
local equipSuit = HeroManager.GetCurHeroEquipSuitPros(equipIdList)
--[id] = 件数
for i = 1, #equipIdList do
local curEquip = _heroData.equipList[i]
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
2021-01-22 16:53:50 +08:00
end
end
end
2021-01-25 21:02:35 +08:00
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]
if addAllProVal[curProId] then
addAllProVal[curProId] = addAllProVal[curProId] + curProVal
else
addAllProVal[curProId] = curProVal
2021-01-22 16:53:50 +08:00
end
end
end
end
return addAllProVal
end,
--英雄身上宝器属性计算
[Hero_Prop_Type.EquipTreasure] = function(_heroData)
local addAllProVal = {}
local minLv
local mainRefineLv
for i = 1, #_heroData.treasureList do
local curEuipTreaSureData = _heroData.treasureList[i]
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
--神应属性
if
configInfo.PoolID == curEuipTreaSureConfig.GodHoodPool and configInfo.Type == 3 and
configInfo.Level == curEuipTreaSureData.treeLv
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
2021-01-22 16:53:50 +08:00
end
if #_heroData.treasureList > 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
--math.min()
--取 强化 精炼 共鸣属性
if #_heroData.treasureList > 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
return addAllProVal
end,
-- 计算所有英雄被动技能的属性值
[Hero_Prop_Type.PassiveSkill] = function(_heroData)
local allOpenPassiveSkillIds = HeroManager.GetAllPassiveSkillIds(heroConfig[_heroData.tId], _heroData.breakId, _heroData.upStarId)
--单体加成 --团体加成 --单体等级限制加成 --减乘
local propList, conPropList, teamPropList, conTeamPropList, dePropList = PassiveListToPropList(allOpenPassiveSkillIds)
return propList, conPropList, teamPropList, conTeamPropList, dePropList
end,
-- 法宝
[Hero_Prop_Type.Talisman] = function(_heroData)
local addAllProVal = {}
local propList, conPropList, teamPropList, conTeamPropList, dePropList
local star = _heroData.star
local profession = heroConfig[_heroData.tId].Profession
local curTalisman = heroConfig[_heroData.tId].EquipTalismana
if curTalisman and star >= curTalisman[1] then
local talismanConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "TalismanaId", curTalisman[2], "Level", _heroData.talismanLv)
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] == 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 _heroData.talismanLv >= dowerAllData[i].Level then
for k = 1, #dowerAllData[i].OpenSkillRules do
table.insert(skillIds, dowerAllData[i].OpenSkillRules[k])
end
end
end
--被动技能计算
if skillIds and #skillIds > 0 then --talismanConFig.OpenSkillRules and #talismanConFig.OpenSkillRules > 0 then
--单体加成 --单体等级限制加成 --团体加成 --减乘
propList, conPropList, teamPropList, conTeamPropList, dePropList = PassiveListToPropList(skillIds)
end
end
end
if propList and LengthOfTable(propList) > 0 then
for i, v in pairs(propList) do
if addAllProVal[i] then
addAllProVal[i] = addAllProVal[i] + v
else
addAllProVal[i] = v
end
end
end
return addAllProVal, conPropList, teamPropList, conTeamPropList, dePropList
end,
-- 魂印
[Hero_Prop_Type.SoulPrint] = function(_heroData)
local allSoulPrintAddWarPowerVal = 0
if (table.nums(_heroData.soulPrintList) >= 1) then
for i = 1, #_heroData.soulPrintList do
local cursoulPrintConfig = equipConfig[_heroData.soulPrintList[i].equipId]
if cursoulPrintConfig then
allSoulPrintAddWarPowerVal = allSoulPrintAddWarPowerVal + cursoulPrintConfig.Score
end
end
end
-- local allAddProVal = {}
-- allAddProVal[HeroProType.WarPower] = allSoulPrintAddWarPowerVal
-- return allAddProVal
local addAllProVal = {}
local propList, conPropList, teamPropList, conTeamPropList, dePropList
local allPassiveSkill = {}
local curHeroData =_heroData
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 and #cursoulPrintConfig.PassiveSkill > 0 then
for j = 1, #cursoulPrintConfig.PassiveSkill do
table.insert(allPassiveSkill,cursoulPrintConfig.PassiveSkill[j])
end
end
end
end
end
end
--被动技能计算
if allPassiveSkill and #allPassiveSkill > 0 then --talismanConFig.OpenSkillRules and #talismanConFig.OpenSkillRules > 0 then
--单体加成 --单体等级限制加成 --团体加成 --减乘
propList, conPropList, teamPropList, conTeamPropList, dePropList = PassiveListToPropList(allPassiveSkill)
end
if propList and LengthOfTable(propList) > 0 then
for i,v in pairs(propList) do
if addAllProVal[i] then
addAllProVal[i] = addAllProVal[i] + v
else
addAllProVal[i] = v
end
end
end
addAllProVal[HeroProType.WarPower] = allSoulPrintAddWarPowerVal
return addAllProVal, conPropList, teamPropList, conTeamPropList, dePropList
2021-01-22 16:53:50 +08:00
end,
-- 皮肤
[Hero_Prop_Type.SkinAdd] = function(_heroData)
local propList, conPropList, teamPropList, conTeamPropList, dePropList
local heroSkinSingleProVal = {}
local heroSkinAllHeroProVal = {}
if _heroData.skinId ~= 0 then
if HeroSkinManager.skinDatas[_heroData.skinId] and HeroSkinManager.skinDatas[_heroData.skinId].MonomerProperty and #HeroSkinManager.skinDatas[_heroData.skinId].MonomerProperty > 0 then
for _,v in ipairs(HeroSkinManager.skinDatas[_heroData.skinId].MonomerProperty) do
if not heroSkinSingleProVal[v[1]] then
heroSkinSingleProVal[v[1]] = 0
end
heroSkinSingleProVal[v[1]] = heroSkinSingleProVal[v[1]] + v[2]
end
end
end
for _,v in pairs(HeroSkinManager.skinDatas) do
if _heroData.skinId ~= v.id then
if HeroSkinManager.skinDatas[v.id] and HeroSkinManager.skinDatas[v.id].UnlockProperty and #HeroSkinManager.skinDatas[v.id].UnlockProperty > 0 then
for _,n in ipairs(HeroSkinManager.skinDatas[v.id].UnlockProperty) do
if not heroSkinAllHeroProVal[n[1]] then
heroSkinAllHeroProVal[n[1]] = 0
end
heroSkinAllHeroProVal[n[1]] = heroSkinAllHeroProVal[n[1]] + n[2]
end
end
end
end
2021-01-22 16:53:50 +08:00
propList = heroSkinSingleProVal
teamPropList = heroSkinAllHeroProVal
return propList, conPropList, teamPropList, conTeamPropList, dePropList
end,
2021-09-26 09:54:58 +08:00
-- 好感度
[Hero_Prop_Type.LikeAbility] = function(_heroData)
local SingleProVal, AllHeroProVal = LikabilityManager.GetTotalForce(_heroData)
return SingleProVal
end,
2021-10-26 16:00:31 +08:00
[Hero_Prop_Type.GodSoul] = function(_heroData)
local propList, conPropList, teamPropList, conTeamPropList, dePropList
local SingleProVal = GodSoulManager.GetHeroGodSoulDatas(_heroData.dId,_heroData.tId, _heroData.godSoulLv)
2021-10-26 16:00:31 +08:00
if SingleProVal and #SingleProVal > 0 then --talismanConFig.OpenSkillRules and #talismanConFig.OpenSkillRules > 0 then
--单体加成 --单体等级限制加成 --团体加成 --减乘
propList, conPropList, teamPropList, conTeamPropList, dePropList = PassiveListToPropList(SingleProVal)
end
return propList, conPropList, teamPropList, conTeamPropList, dePropList
end,
2021-11-16 15:24:17 +08:00
[Hero_Prop_Type.TailsManSou] = function(_heroData)
local propList, conPropList, teamPropList, conTeamPropList, dePropList
local SingleProVal = TailsManSoulManager.GetTailsmanPassivePower()
if SingleProVal and #SingleProVal > 0 then --talismanConFig.OpenSkillRules and #talismanConFig.OpenSkillRules > 0 then
--单体加成 --单体等级限制加成 --团体加成 --减乘
propList, conPropList, teamPropList, conTeamPropList, dePropList = PassiveListToPropList(SingleProVal)
end
return propList, conPropList, teamPropList, conTeamPropList, dePropList
end,
2021-01-22 16:53:50 +08:00
}