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

415 lines
19 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.

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,
}
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
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属性
local propId, value = BattlePropToUIProp(pId, v, ct)
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 = curHeroData.heroConfig.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
-- local curProConfig = propertyConfig[propType]
-- if curProConfig.Style == 2 then
-- allAddProVal[propType] = allAddProVal[propType] + propValue/100
-- else
-- allAddProVal[propType] = allAddProVal[propType] + propValue
-- end
-- end
-- end
return allAddProVal
end,
-- 普通装备
[Hero_Prop_Type.Equip] = function(_heroData)
local addAllProVal = {}
for i, v in ConfigPairs(propertyConfig) do
addAllProVal[i] = 0
end
local tData = heroConfig[_heroData.tId]
local equipSuit = {}
--[id] = 件数
LogBlue("装备件数".. #_heroData.equipList)
for i = 1, #_heroData.equipList 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
end
--套装加成
if equipSuit[curEquip.equipConfig.SuiteID] then
equipSuit[curEquip.equipConfig.SuiteID] = equipSuit[curEquip.equipConfig.SuiteID] + 1
else
equipSuit[curEquip.equipConfig.SuiteID] = 1
end
end
end
if equipSuit and LengthOfTable(equipSuit) > 0 then
for i, v in pairs(equipSuit) do
local curSuitConfig = equipsuite[i]
if v > 1 then
if curSuitConfig and curSuitConfig.SuiteValue then
for j = 1, #curSuitConfig.SuiteValue do
if v >= curSuitConfig.SuiteValue[j][1] then
local curProId = curSuitConfig.SuiteValue[j][2]
local curProVal = curSuitConfig.SuiteValue[j][3]
--LogError("套装激活 "..i .." "..v.." curProId "..curProId .." "..curProVal)
if addAllProVal[curProId] then
addAllProVal[curProId] = addAllProVal[curProId] + curProVal
else
addAllProVal[curProId] = curProVal
end
end
end
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
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
end,
}