装备数值显示与计算分开处理

This commit is contained in:
Fang 2023-07-25 17:18:32 +08:00
parent 03c6bdd523
commit 27affc743b
2 changed files with 17 additions and 16 deletions

View File

@ -1,5 +1,6 @@
local AttrCell = class("AttrCell", BaseCell) local AttrCell = class("AttrCell", BaseCell)
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
local PERCENT_FACTOR = 100
function AttrCell:init() function AttrCell:init()
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
@ -144,10 +145,10 @@ function AttrCell:showCrit()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end end
self.txValue:setText(value) self.txValue:setText(value // PERCENT_FACTOR)
end end
-- 显示暴击伤害 -- 显示暴击伤害百分比
function AttrCell:showCritAtk() function AttrCell:showCritAtk()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_6") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_6")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT_TIME)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT_TIME))
@ -162,7 +163,7 @@ function AttrCell:showCritAtk()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end end
self.txValue:setText(value) self.txValue:setText(value // PERCENT_FACTOR)
end end
-- 显示普攻增伤百分比 -- 显示普攻增伤百分比
@ -183,7 +184,7 @@ function AttrCell:showNormalHurtp()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end end
self.txValue:setText(value // DEFAULT_FACTOR) self.txValue:setText(value // PERCENT_FACTOR)
end end
-- 显示技能增伤百分比 -- 显示技能增伤百分比
@ -204,7 +205,7 @@ function AttrCell:showSkillHurtp()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end end
self.txValue:setText(value // DEFAULT_FACTOR) self.txValue:setText(value // PERCENT_FACTOR)
end end
-- 显示治疗效果提升百分比 -- 显示治疗效果提升百分比
@ -222,7 +223,7 @@ function AttrCell:showCured()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end end
self.txValue:setText(value) self.txValue:setText(value // PERCENT_FACTOR)
end end
return AttrCell return AttrCell

View File

@ -1,5 +1,5 @@
local EquipEntity = class("EquipEntity", BaseData) local EquipEntity = class("EquipEntity", BaseData)
local ATTR_FACTOR = 100 local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
function EquipEntity:ctor(heroId, part, level) function EquipEntity:ctor(heroId, part, level)
self.level = level or 0 self.level = level or 0
@ -40,7 +40,7 @@ end
-- 获取部位加成后生命值 -- 获取部位加成后生命值
function EquipEntity:getHp() function EquipEntity:getHp()
local result = self:getBaseHp() local result = self:getBaseHp()
result = result + self:getHeroEntity():getTotalBaseHp() * self:getHpPercent() // ATTR_FACTOR result = result + self:getHeroEntity():getTotalBaseHp() * self:getHpPercent() // DEFAULT_FACTOR
return result return result
end end
@ -55,7 +55,7 @@ end
-- 获取部位加成后攻击力 -- 获取部位加成后攻击力
function EquipEntity:getAttack() function EquipEntity:getAttack()
local result = self:getBaseAttack() local result = self:getBaseAttack()
result = result + self:getHeroEntity():getTotalBaseAtk() * self:getAtkPercent() // ATTR_FACTOR result = result + self:getHeroEntity():getTotalBaseAtk() * self:getAtkPercent() // DEFAULT_FACTOR
return result return result
end end
@ -83,7 +83,7 @@ function EquipEntity:getAtkPercent()
end end
for index, attr in ipairs(attrs) do for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_ATTACK_ADD_NAME, attr.type) then if table.containValue(GConst.MATCH_ATTACK_ADD_NAME, attr.type) then
return attr.num // ATTR_FACTOR return attr.num
end end
end end
return 0 return 0
@ -97,7 +97,7 @@ function EquipEntity:getHpPercent()
end end
for index, attr in ipairs(attrs) do for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_HP_ADD_NAME, attr.type) then if table.containValue(GConst.MATCH_HP_ADD_NAME, attr.type) then
return attr.num // ATTR_FACTOR return attr.num
end end
end end
return 0 return 0
@ -111,7 +111,7 @@ function EquipEntity:getCritPercent()
end end
for index, attr in ipairs(attrs) do for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_CRIT_NAME, attr.type) then if table.containValue(GConst.MATCH_CRIT_NAME, attr.type) then
return attr.num // ATTR_FACTOR return attr.num
end end
end end
return 0 return 0
@ -125,7 +125,7 @@ function EquipEntity:getCritHurtPercent()
end end
for index, attr in ipairs(attrs) do for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_CRIT_TIME_NAME, attr.type) then if table.containValue(GConst.MATCH_CRIT_TIME_NAME, attr.type) then
return attr.num // ATTR_FACTOR return attr.num
end end
end end
return 0 return 0
@ -139,7 +139,7 @@ function EquipEntity:getHealPercent()
end end
for index, attr in ipairs(attrs) do for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_CURED_NAME, attr.type) then if table.containValue(GConst.MATCH_CURED_NAME, attr.type) then
return attr.num // ATTR_FACTOR return attr.num
end end
end end
return 0 return 0
@ -153,7 +153,7 @@ function EquipEntity:getNormalHurtPercent()
end end
for index, attr in ipairs(attrs) do for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_NORMAL_HURTP_NAME, attr.type) then if table.containValue(GConst.MATCH_NORMAL_HURTP_NAME, attr.type) then
return attr.num // ATTR_FACTOR return attr.num
end end
end end
return 0 return 0
@ -167,7 +167,7 @@ function EquipEntity:getSkillHurtPercent()
end end
for index, attr in ipairs(attrs) do for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_SKILL_HURTP_NAME, attr.type) then if table.containValue(GConst.MATCH_SKILL_HURTP_NAME, attr.type) then
return attr.num // ATTR_FACTOR return attr.num
end end
end end
return 0 return 0