战斗力

This commit is contained in:
puxuan 2025-08-13 20:54:58 +08:00
parent ab824968e0
commit 667d76fcde
6 changed files with 145 additions and 87 deletions

View File

@ -2,392 +2,392 @@ local attr = {
[1]={ [1]={
["id"]=1, ["id"]=1,
["name"]="hp", ["name"]="hp",
["fight"]=100 ["power"]=100
}, },
[2]={ [2]={
["id"]=2, ["id"]=2,
["name"]="atk_red", ["name"]="atk_red",
["fight"]=200 ["power"]=200
}, },
[3]={ [3]={
["id"]=3, ["id"]=3,
["name"]="atk_yellow", ["name"]="atk_yellow",
["fight"]=200 ["power"]=200
}, },
[4]={ [4]={
["id"]=4, ["id"]=4,
["name"]="atk_green", ["name"]="atk_green",
["fight"]=200 ["power"]=200
}, },
[5]={ [5]={
["id"]=5, ["id"]=5,
["name"]="atk_blue", ["name"]="atk_blue",
["fight"]=200 ["power"]=200
}, },
[6]={ [6]={
["id"]=6, ["id"]=6,
["name"]="atk_purple", ["name"]="atk_purple",
["fight"]=200 ["power"]=200
}, },
[7]={ [7]={
["id"]=7, ["id"]=7,
["name"]="attr_crit_red", ["name"]="attr_crit_red",
["fight"]=500 ["power"]=500
}, },
[8]={ [8]={
["id"]=8, ["id"]=8,
["name"]="attr_crit_yellow", ["name"]="attr_crit_yellow",
["fight"]=500 ["power"]=500
}, },
[9]={ [9]={
["id"]=9, ["id"]=9,
["name"]="attr_crit_green", ["name"]="attr_crit_green",
["fight"]=500 ["power"]=500
}, },
[10]={ [10]={
["id"]=10, ["id"]=10,
["name"]="attr_crit_blue", ["name"]="attr_crit_blue",
["fight"]=500 ["power"]=500
}, },
[11]={ [11]={
["id"]=11, ["id"]=11,
["name"]="attr_crit_purple", ["name"]="attr_crit_purple",
["fight"]=500 ["power"]=500
}, },
[12]={ [12]={
["id"]=12, ["id"]=12,
["name"]="attr_crit_time_red", ["name"]="attr_crit_time_red",
["fight"]=500 ["power"]=500
}, },
[13]={ [13]={
["id"]=13, ["id"]=13,
["name"]="attr_crit_time_yellow", ["name"]="attr_crit_time_yellow",
["fight"]=500 ["power"]=500
}, },
[14]={ [14]={
["id"]=14, ["id"]=14,
["name"]="attr_crit_time_green", ["name"]="attr_crit_time_green",
["fight"]=500 ["power"]=500
}, },
[15]={ [15]={
["id"]=15, ["id"]=15,
["name"]="attr_crit_time_blue", ["name"]="attr_crit_time_blue",
["fight"]=500 ["power"]=500
}, },
[16]={ [16]={
["id"]=16, ["id"]=16,
["name"]="attr_crit_time_purple", ["name"]="attr_crit_time_purple",
["fight"]=500 ["power"]=500
}, },
[17]={ [17]={
["id"]=17, ["id"]=17,
["name"]="attr_cured_red", ["name"]="attr_cured_red",
["fight"]=100 ["power"]=100
}, },
[18]={ [18]={
["id"]=18, ["id"]=18,
["name"]="attr_cured_yellow", ["name"]="attr_cured_yellow",
["fight"]=100 ["power"]=100
}, },
[19]={ [19]={
["id"]=19, ["id"]=19,
["name"]="attr_cured_green", ["name"]="attr_cured_green",
["fight"]=100 ["power"]=100
}, },
[20]={ [20]={
["id"]=20, ["id"]=20,
["name"]="attr_cured_blue", ["name"]="attr_cured_blue",
["fight"]=100 ["power"]=100
}, },
[21]={ [21]={
["id"]=21, ["id"]=21,
["name"]="attr_cured_purple", ["name"]="attr_cured_purple",
["fight"]=100 ["power"]=100
}, },
[22]={ [22]={
["id"]=22, ["id"]=22,
["name"]="attr_atkp_red", ["name"]="attr_atkp_red",
["fight"]=100 ["power"]=100
}, },
[23]={ [23]={
["id"]=23, ["id"]=23,
["name"]="attr_atkp_yellow", ["name"]="attr_atkp_yellow",
["fight"]=100 ["power"]=100
}, },
[24]={ [24]={
["id"]=24, ["id"]=24,
["name"]="attr_atkp_green", ["name"]="attr_atkp_green",
["fight"]=100 ["power"]=100
}, },
[25]={ [25]={
["id"]=25, ["id"]=25,
["name"]="attr_atkp_blue", ["name"]="attr_atkp_blue",
["fight"]=100 ["power"]=100
}, },
[26]={ [26]={
["id"]=26, ["id"]=26,
["name"]="attr_atkp_purple", ["name"]="attr_atkp_purple",
["fight"]=100 ["power"]=100
}, },
[27]={ [27]={
["id"]=27, ["id"]=27,
["name"]="attr_hpp_red", ["name"]="attr_hpp_red",
["fight"]=100 ["power"]=100
}, },
[28]={ [28]={
["id"]=28, ["id"]=28,
["name"]="attr_hpp_yellow", ["name"]="attr_hpp_yellow",
["fight"]=100 ["power"]=100
}, },
[29]={ [29]={
["id"]=29, ["id"]=29,
["name"]="attr_hpp_green", ["name"]="attr_hpp_green",
["fight"]=100 ["power"]=100
}, },
[30]={ [30]={
["id"]=30, ["id"]=30,
["name"]="attr_hpp_blue", ["name"]="attr_hpp_blue",
["fight"]=100 ["power"]=100
}, },
[31]={ [31]={
["id"]=31, ["id"]=31,
["name"]="attr_hpp_purple", ["name"]="attr_hpp_purple",
["fight"]=100 ["power"]=100
}, },
[32]={ [32]={
["id"]=32, ["id"]=32,
["name"]="attr_normal_hurt_red", ["name"]="attr_normal_hurt_red",
["fight"]=50 ["power"]=50
}, },
[33]={ [33]={
["id"]=33, ["id"]=33,
["name"]="attr_normal_hurt_yellow", ["name"]="attr_normal_hurt_yellow",
["fight"]=50 ["power"]=50
}, },
[34]={ [34]={
["id"]=34, ["id"]=34,
["name"]="attr_normal_hurt_green", ["name"]="attr_normal_hurt_green",
["fight"]=50 ["power"]=50
}, },
[35]={ [35]={
["id"]=35, ["id"]=35,
["name"]="attr_normal_hurt_blue", ["name"]="attr_normal_hurt_blue",
["fight"]=50 ["power"]=50
}, },
[36]={ [36]={
["id"]=36, ["id"]=36,
["name"]="attr_normal_hurt_purple", ["name"]="attr_normal_hurt_purple",
["fight"]=50 ["power"]=50
}, },
[37]={ [37]={
["id"]=37, ["id"]=37,
["name"]="attr_skill_hurt_red", ["name"]="attr_skill_hurt_red",
["fight"]=50 ["power"]=50
}, },
[38]={ [38]={
["id"]=38, ["id"]=38,
["name"]="attr_skill_hurt_yellow", ["name"]="attr_skill_hurt_yellow",
["fight"]=50 ["power"]=50
}, },
[39]={ [39]={
["id"]=39, ["id"]=39,
["name"]="attr_skill_hurt_green", ["name"]="attr_skill_hurt_green",
["fight"]=50 ["power"]=50
}, },
[40]={ [40]={
["id"]=40, ["id"]=40,
["name"]="attr_skill_hurt_blue", ["name"]="attr_skill_hurt_blue",
["fight"]=50 ["power"]=50
}, },
[41]={ [41]={
["id"]=41, ["id"]=41,
["name"]="attr_skill_hurt_purple", ["name"]="attr_skill_hurt_purple",
["fight"]=50 ["power"]=50
}, },
[42]={ [42]={
["id"]=42, ["id"]=42,
["name"]="attr_normal_hurtp_red", ["name"]="attr_normal_hurtp_red",
["fight"]=50 ["power"]=50
}, },
[43]={ [43]={
["id"]=43, ["id"]=43,
["name"]="attr_normal_hurtp_yellow", ["name"]="attr_normal_hurtp_yellow",
["fight"]=50 ["power"]=50
}, },
[44]={ [44]={
["id"]=44, ["id"]=44,
["name"]="attr_normal_hurtp_green", ["name"]="attr_normal_hurtp_green",
["fight"]=50 ["power"]=50
}, },
[45]={ [45]={
["id"]=45, ["id"]=45,
["name"]="attr_normal_hurtp_blue", ["name"]="attr_normal_hurtp_blue",
["fight"]=50 ["power"]=50
}, },
[46]={ [46]={
["id"]=46, ["id"]=46,
["name"]="attr_normal_hurtp_purple", ["name"]="attr_normal_hurtp_purple",
["fight"]=50 ["power"]=50
}, },
[47]={ [47]={
["id"]=47, ["id"]=47,
["name"]="attr_skill_hurtp_red", ["name"]="attr_skill_hurtp_red",
["fight"]=50 ["power"]=50
}, },
[48]={ [48]={
["id"]=48, ["id"]=48,
["name"]="attr_skill_hurtp_yellow", ["name"]="attr_skill_hurtp_yellow",
["fight"]=50 ["power"]=50
}, },
[49]={ [49]={
["id"]=49, ["id"]=49,
["name"]="attr_skill_hurtp_green", ["name"]="attr_skill_hurtp_green",
["fight"]=50 ["power"]=50
}, },
[50]={ [50]={
["id"]=50, ["id"]=50,
["name"]="attr_skill_hurtp_blue", ["name"]="attr_skill_hurtp_blue",
["fight"]=50 ["power"]=50
}, },
[51]={ [51]={
["id"]=51, ["id"]=51,
["name"]="attr_skill_hurtp_purple", ["name"]="attr_skill_hurtp_purple",
["fight"]=50 ["power"]=50
}, },
[52]={ [52]={
["id"]=52, ["id"]=52,
["name"]="attr_hp_red", ["name"]="attr_hp_red",
["fight"]=50 ["power"]=50
}, },
[53]={ [53]={
["id"]=53, ["id"]=53,
["name"]="attr_hp_yellow", ["name"]="attr_hp_yellow",
["fight"]=50 ["power"]=50
}, },
[54]={ [54]={
["id"]=54, ["id"]=54,
["name"]="attr_hp_green", ["name"]="attr_hp_green",
["fight"]=50 ["power"]=50
}, },
[55]={ [55]={
["id"]=55, ["id"]=55,
["name"]="attr_hp_blue", ["name"]="attr_hp_blue",
["fight"]=50 ["power"]=50
}, },
[56]={ [56]={
["id"]=56, ["id"]=56,
["name"]="attr_hp_purple", ["name"]="attr_hp_purple",
["fight"]=50 ["power"]=50
}, },
[57]={ [57]={
["id"]=57, ["id"]=57,
["name"]="attr_all_hurtp_red", ["name"]="attr_all_hurtp_red",
["fight"]=50 ["power"]=50
}, },
[58]={ [58]={
["id"]=58, ["id"]=58,
["name"]="attr_all_hurtp_yellow", ["name"]="attr_all_hurtp_yellow",
["fight"]=50 ["power"]=50
}, },
[59]={ [59]={
["id"]=59, ["id"]=59,
["name"]="attr_all_hurtp_green", ["name"]="attr_all_hurtp_green",
["fight"]=50 ["power"]=50
}, },
[60]={ [60]={
["id"]=60, ["id"]=60,
["name"]="attr_all_hurtp_blue", ["name"]="attr_all_hurtp_blue",
["fight"]=50 ["power"]=50
}, },
[61]={ [61]={
["id"]=61, ["id"]=61,
["name"]="attr_all_hurtp_purple", ["name"]="attr_all_hurtp_purple",
["fight"]=50 ["power"]=50
}, },
[62]={ [62]={
["id"]=62, ["id"]=62,
["name"]="attr_atkp_red_all", ["name"]="attr_atkp_red_all",
["fight"]=50 ["power"]=50
}, },
[63]={ [63]={
["id"]=63, ["id"]=63,
["name"]="attr_atkp_yellow_all", ["name"]="attr_atkp_yellow_all",
["fight"]=50 ["power"]=50
}, },
[64]={ [64]={
["id"]=64, ["id"]=64,
["name"]="attr_atkp_green_all", ["name"]="attr_atkp_green_all",
["fight"]=50 ["power"]=50
}, },
[65]={ [65]={
["id"]=65, ["id"]=65,
["name"]="attr_atkp_blue_all", ["name"]="attr_atkp_blue_all",
["fight"]=50 ["power"]=50
}, },
[66]={ [66]={
["id"]=66, ["id"]=66,
["name"]="attr_atkp_purple_all", ["name"]="attr_atkp_purple_all",
["fight"]=50 ["power"]=50
}, },
[67]={ [67]={
["id"]=67, ["id"]=67,
["name"]="atk_all", ["name"]="atk_all",
["fight"]=50 ["power"]=50
}, },
[68]={ [68]={
["id"]=68, ["id"]=68,
["name"]="attr_hp_all", ["name"]="attr_hp_all",
["fight"]=50 ["power"]=50
}, },
[69]={ [69]={
["id"]=69, ["id"]=69,
["name"]="attr_dmgdec_all", ["name"]="attr_dmgdec_all",
["fight"]=50 ["power"]=50
}, },
[70]={ [70]={
["id"]=70, ["id"]=70,
["name"]="attr_crit_all", ["name"]="attr_crit_all",
["fight"]=50 ["power"]=50
}, },
[71]={ [71]={
["id"]=71, ["id"]=71,
["name"]="attr_crit_time_all", ["name"]="attr_crit_time_all",
["fight"]=50 ["power"]=50
}, },
[72]={ [72]={
["id"]=72, ["id"]=72,
["name"]="attr_normal_hurtp_all", ["name"]="attr_normal_hurtp_all",
["fight"]=50 ["power"]=50
}, },
[73]={ [73]={
["id"]=73, ["id"]=73,
["name"]="attr_skill_hurtp_all", ["name"]="attr_skill_hurtp_all",
["fight"]=50 ["power"]=50
}, },
[74]={ [74]={
["id"]=74, ["id"]=74,
["name"]="attr_atkp_all", ["name"]="attr_atkp_all",
["fight"]=50 ["power"]=50
}, },
[75]={ [75]={
["id"]=75, ["id"]=75,
["name"]="attr_atk", ["name"]="attr_atk",
["fight"]=50 ["power"]=50
}, },
[76]={ [76]={
["id"]=76, ["id"]=76,
["name"]="attr_hp", ["name"]="attr_hp",
["fight"]=50 ["power"]=50
}, },
[77]={ [77]={
["id"]=77, ["id"]=77,
["name"]="attr_normal_hurt", ["name"]="attr_normal_hurt",
["fight"]=50 ["power"]=50
}, },
[78]={ [78]={
["id"]=78, ["id"]=78,
["name"]="attr_skill_hurt", ["name"]="attr_skill_hurt",
["fight"]=50 ["power"]=50
} }
} }
local keys = { local keys = {

View File

@ -2033,4 +2033,9 @@ function GFunc.getUnevenSliderValue(list, value, defaultValue)
return per return per
end end
function GFunc.getAttrNameCfg()
local AttrNameCfg = ConfigManager:getConfigWithOtherKey("attr", "name")
return AttrNameCfg
end
return GFunc return GFunc

View File

@ -54,6 +54,7 @@ function HeroComp:init()
-- self.uiMap["hero_ui.bottom_bg.filter_bg.btn_0.desc_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.COLLECTION_DESC_10)) -- self.uiMap["hero_ui.bottom_bg.filter_bg.btn_0.desc_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.COLLECTION_DESC_10))
self.uiMap["hero_ui.bottom_bg.filter_bg.btn_0.desc_tx"]:setText("ALL") self.uiMap["hero_ui.bottom_bg.filter_bg.btn_0.desc_tx"]:setText("ALL")
self.powerTx = self.uiMap["hero_ui.power_img.power_tx"]
local attrTx = self.uiMap["hero_ui.bottom_bg.attr_bg.attr_tx"] local attrTx = self.uiMap["hero_ui.bottom_bg.attr_bg.attr_tx"]
local infoBtn = self.uiMap["hero_ui.bottom_bg.attr_bg.info_btn"] local infoBtn = self.uiMap["hero_ui.bottom_bg.attr_bg.info_btn"]
self.elementType = 0 self.elementType = 0
@ -225,10 +226,13 @@ end
function HeroComp:refreshScrollRect() function HeroComp:refreshScrollRect()
self.heroList = DataManager.HeroData:getAllHeroesSort(self.battleType, self.elementType) -- 每次都重新算一次 self.heroList = DataManager.HeroData:getAllHeroesSort(self.battleType, self.elementType) -- 每次都重新算一次
local power = 0
for i = 1, 5 do for i = 1, 5 do
local heroId = self.curFormation[i] local heroId = self.curFormation[i]
local hero = DataManager.HeroData:getHeroById(heroId) local hero = DataManager.HeroData:getHeroById(heroId)
if hero and hero:getLv() > 0 then if hero and hero:getLv() > 0 then
power = power + hero:getPower()
self.heroAddImgList[i]:setVisible(false) self.heroAddImgList[i]:setVisible(false)
if self.heroSpineList[i] and self.heroSpineList[i]:getModelId() == hero:getModelId() then if self.heroSpineList[i] and self.heroSpineList[i]:getModelId() == hero:getModelId() then
self.heroSpineList[i]:setActive(true) self.heroSpineList[i]:setActive(true)
@ -254,6 +258,7 @@ function HeroComp:refreshScrollRect()
end end
end end
end end
self.powerTx:setText(GFunc.num2Str2(power, 2))
self.allHeroCount = #self.heroList self.allHeroCount = #self.heroList
self.unlockCount = DataManager.HeroData:getUnlockHeroCount(self.elementType) self.unlockCount = DataManager.HeroData:getUnlockHeroCount(self.elementType)

View File

@ -100,7 +100,7 @@ function HeroDetailUI:onLoadRootComplete()
-- self.txStar2:setText("升星") -- self.txStar2:setText("升星")
-- self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN)) -- self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN))
-- self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN)) -- self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN))
self.powerTx:setText(1313213) -- self.powerTx:setText(self.heroEntity:getPower())
-- if not DataManager.HeroData:isStarOpen() then -- if not DataManager.HeroData:isStarOpen() then
-- self.lockStar:setVisible(true) -- self.lockStar:setVisible(true)
-- GFunc.centerImgAndTx(self.lockStar, self.txStar1, 5) -- GFunc.centerImgAndTx(self.lockStar, self.txStar1, 5)
@ -272,6 +272,8 @@ function HeroDetailUI:showHeroInfo()
-- self.selectSkin:setActive(false) -- self.selectSkin:setActive(false)
self.bg:setActive(true) self.bg:setActive(true)
local power = self.heroEntity:getPower()
self.powerTx:setText(GFunc.num2Str2(power, 2))
if not self.compHero then if not self.compHero then
self.heroInfo:initPrefabHelper() self.heroInfo:initPrefabHelper()
self.heroInfo:genAllChildren() self.heroInfo:genAllChildren()

View File

@ -1,7 +1,5 @@
local EquipEntity = class("EquipEntity", BaseData) local EquipEntity = class("EquipEntity", BaseData)
local AttrNameCfg = ConfigManager:getConfigWithOtherKey("attr", "name")
function EquipEntity:setDirty() function EquipEntity:setDirty()
self.allAttrs = nil self.allAttrs = nil
end end
@ -161,7 +159,7 @@ function EquipEntity:_getAttrPower()
local power = 0 local power = 0
for attrName, attrNum in pairs(self:getAllAttr()) do for attrName, attrNum in pairs(self:getAllAttr()) do
local cfg = AttrNameCfg[attrName] local cfg = GFunc.getAttrNameCfg()[attrName]
if cfg then if cfg then
local realValue = attrNum local realValue = attrNum
-- 特殊处理,玩家基础暴击伤害不算 -- 特殊处理,玩家基础暴击伤害不算
@ -169,7 +167,7 @@ function EquipEntity:_getAttrPower()
realValue = attrNum - 15000 realValue = attrNum - 15000
end end
power = power + math.floor(realValue * cfg.power / GConst.DEFAULT_FACTOR) power = power + math.floor(realValue * cfg.power / GConst.DEFAULT_FACTOR / GConst.DEFAULT_FACTOR + 0.0000001)
end end
end end

View File

@ -85,6 +85,8 @@ function HeroEntity:_updateAllAttr()
if factorValue > 0 then if factorValue > 0 then
self.allAttr[atkType] = math.floor(self.allAttr[atkType] * (1 + factorValue / GConst.DEFAULT_FACTOR) + 0.0000001) self.allAttr[atkType] = math.floor(self.allAttr[atkType] * (1 + factorValue / GConst.DEFAULT_FACTOR) + 0.0000001)
end end
self:calcPower()
end end
function HeroEntity:_getAllBaseAttr() function HeroEntity:_getAllBaseAttr()
@ -223,10 +225,10 @@ function HeroEntity:getTotalBaseAtk()
-- local logStr = self:getCfgId() .. "总基础攻击值:\n英雄" .. result -- local logStr = self:getCfgId() .. "总基础攻击值:\n英雄" .. result
-- 武器 + 防具 -- 武器 + 防具
-- for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do -- for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do
-- local equipEntity = self:getEquips(partType) -- local HeroEntity = self:getEquips(partType)
-- if equipEntity then -- if HeroEntity then
-- -- logStr = logStr .. "\n" .. partName .. "" .. equipEntity:getBaseAttack() -- -- logStr = logStr .. "\n" .. partName .. "" .. HeroEntity:getBaseAttack()
-- result = result + equipEntity:getBaseAttack() -- result = result + HeroEntity:getBaseAttack()
-- end -- end
-- end -- end
-- logStr = logStr .. "\nSKIN" .. DataManager.SkinData:getBaseAttack(self) -- logStr = logStr .. "\nSKIN" .. DataManager.SkinData:getBaseAttack(self)
@ -666,4 +668,50 @@ function HeroEntity:setSkins(skinIds)
end end
-- endregion -- endregion
--@region 战力
function HeroEntity:setPowerDirty()
self.data.isPowerDirty = not self.data.isPowerDirty
end
function HeroEntity:getPower()
if not self.curPower then
self:getAllAttr()
end
return self.curPower
end
-- 计算战斗力
function HeroEntity:calcPower()
if self.lastPower then
self.lastPower = self.curPower
end
self.curPower = math.floor(self:_getAttrPower())
if not self.lastPower then
self.lastPower = self.curPower
end
if self.lastPower ~= self.curPower then
self:setPowerDirty()
end
end
function HeroEntity:_getAttrPower()
local power = 0
for attrName, attrNum in pairs(self:getAllAttr()) do
local cfg = GFunc.getAttrNameCfg()[attrName]
if cfg then
local realValue = attrNum
-- 特殊处理,玩家基础暴击伤害不算
if attrName == GConst.BattleConst.ATTR_NAME.CRIT_TIME then
realValue = attrNum - 15000
end
power = power + math.floor(realValue * cfg.power / GConst.DEFAULT_FACTOR / GConst.DEFAULT_FACTOR + 0.0000001)
end
end
return power
end
--@endregion
return HeroEntity return HeroEntity