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

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

View File

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