Merge branch 'dev_20230815' of http://git.juzugame.com/b6-client/b6-lua into dev_20230815

This commit is contained in:
xiekaidong 2023-08-15 14:59:18 +08:00
commit 2aff8266ac
6 changed files with 105 additions and 79 deletions

View File

@ -1797,7 +1797,7 @@ function GFunc.formatPlayerName(name)
return name
end
-- info = {array_heroes, heroes_equips} -- 服务器返回的数据
-- info = {array_heroes, heroes_equips, skins} -- 服务器返回的数据
function GFunc.formatPlayerFormationInfo(info)
local formation = {}
if not info.array_heroes then
@ -1810,13 +1810,17 @@ function GFunc.formatPlayerFormationInfo(info)
end
end
-- 处理装备
if not info.heroes_equips then
info.heroes_equips = {}
end
if not info.skins then
info.skins = {}
end
for matchType, heroEntity in pairs(formation) do
local heroId = heroEntity:getCfgId()
-- 处理装备
local equipInfo = info.heroes_equips[heroId]
local equips = {}
if not equipInfo then
@ -1829,6 +1833,17 @@ function GFunc.formatPlayerFormationInfo(info)
equipEntity:setHeroEntity(heroEntity)
end
heroEntity:setEquips(equips)
-- 处理皮肤
local skinIds = {}
for idx, skinId in pairs(info.skins) do
if DataManager.SkinData:getOriginSkinId(heroId) ~= skinId and DataManager.SkinData:getHeroIdBySkinId(skinId) == heroId then
table.insert(skinIds, skinId)
end
end
if #skinIds > 0 then
heroEntity:setSkins(skinIds)
end
end
return formation

View File

@ -62,7 +62,7 @@ function AttrCell:showHp()
value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getHp()
value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getHp()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getHp(self.heroEntity:getCfgId())
value = value + DataManager.SkinData:getHp(self.heroEntity)
end
self.txValue:setText(value // DEFAULT_FACTOR)
@ -94,7 +94,7 @@ function AttrCell:showAtk()
value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getAttack()
value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getAttack()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getAttack(self.heroEntity:getCfgId())
value = value + DataManager.SkinData:getAttack(self.heroEntity)
end
self.txValue:setText(value // DEFAULT_FACTOR)
@ -116,7 +116,7 @@ function AttrCell:showNormalHurt()
value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getNormalHurt()
value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getNormalHurt()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getNormalHurt(self.heroEntity:getCfgId())
value = value + DataManager.SkinData:getNormalHurt(self.heroEntity)
end
self.txValue:setText(value // DEFAULT_FACTOR)
@ -138,7 +138,7 @@ function AttrCell:showSkillHurt()
value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getSkillHurt()
value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getSkillHurt()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getSkillHurt(self.heroEntity:getCfgId())
value = value + DataManager.SkinData:getSkillHurt(self.heroEntity)
end
self.txValue:setText(value // DEFAULT_FACTOR)
@ -157,7 +157,7 @@ function AttrCell:showCrit()
value = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON):getCritPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getCritPercent(self.heroEntity:getCfgId())
value = value + DataManager.SkinData:getCritPercent(self.heroEntity)
end
self.txValue:setText(value // PERCENT_FACTOR .. "%")
@ -176,7 +176,7 @@ function AttrCell:showCritAtk()
value = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON):getCritHurtPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getCritHurtPercent(self.heroEntity:getCfgId())
value = value + DataManager.SkinData:getCritHurtPercent(self.heroEntity)
end
self.txValue:setText(value // PERCENT_FACTOR .. "%")
@ -199,7 +199,7 @@ function AttrCell:showNormalHurtp()
-- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getNormalHurtPercent()
-- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getNormalHurtPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getNormalHurtPercent(self.heroEntity:getCfgId())
value = value + DataManager.SkinData:getNormalHurtPercent(self.heroEntity)
end
self.txValue:setText(value // PERCENT_FACTOR .. "%")
@ -222,7 +222,7 @@ function AttrCell:showSkillHurtp()
-- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getSkillHurtPercent()
-- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getSkillHurtPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getSkillHurtPercent(self.heroEntity:getCfgId())
value = value + DataManager.SkinData:getSkillHurtPercent(self.heroEntity)
end
self.txValue:setText(value // PERCENT_FACTOR .. "%")
@ -241,7 +241,7 @@ function AttrCell:showCured()
value = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON):getHealPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getHealPercent(self.heroEntity:getCfgId())
value = value + DataManager.SkinData:getHealPercent(self.heroEntity)
end
self.txValue:setText(value // PERCENT_FACTOR .. "%")

View File

@ -24,7 +24,7 @@ function AttrNodeCell:refresh(heroEntity, node)
self.attrCount = 0
for index, attr in ipairs(node) do
if node ~= GConst.HeroConst.ATTR_SHOW_SKIN or DataManager.SkinData:hasAttr(heroEntity:getCfgId(), attr[heroEntity:getMatchType()]) then
if node ~= GConst.HeroConst.ATTR_SHOW_SKIN or DataManager.SkinData:hasAttr(heroEntity, attr[heroEntity:getMatchType()]) then
self.attrCount = self.attrCount + 1
CellManager:loadCellAsync(ATTR_CELL_PATH, ATTR_CELL, self.itemsRoot, function(cell)
cell:refresh(heroEntity, node, attr)

View File

@ -44,7 +44,7 @@ function HeroAttrUI:onRefresh()
local totalHeight = 0
for index, node in ipairs(GConst.HeroConst.SHOW_NODE) do
-- 有皮肤属性时才显示皮肤
if node ~= GConst.HeroConst.ATTR_SHOW_SKIN or #DataManager.SkinData:getOwnAllAttr(self.heroEntity:getCfgId()) > 0 then
if node ~= GConst.HeroConst.ATTR_SHOW_SKIN or #DataManager.SkinData:getOwnAllAttr(self.heroEntity) > 0 then
CellManager:loadCellAsync(ATTR_NODE_CELL_PATH, ATTR_NODE_CELL, self.rootNodes, function(cell)
cell:refresh(self.heroEntity, node)

View File

@ -124,20 +124,20 @@ function HeroEntity:updateEquipAttr()
self:addEquipAttrValue(GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()], skillHurtPer)
self:addEquipAttrValue(GConst.MATCH_CURED_NAME[self:getMatchType()], healPer)
if EDITOR_MODE then
local printStr = ""
printStr = printStr .. "更新装备数值:"..self:getCfgId().."-".. partName .. "-" .. equipEntity:getLevel() .. "\n"
printStr = printStr .. "生命:".. hp .. "\n"
printStr = printStr .. "攻击力:".. atk .. "\n"
printStr = printStr .. "普攻增伤:".. normalHurt .. "\n"
printStr = printStr .. "技能增伤:".. skillHurt .. "\n"
printStr = printStr .. "暴击率:".. critPer .. "\n"
printStr = printStr .. "暴击伤害百分比:".. critHurtPer .. "\n"
printStr = printStr .. "普攻增伤百分比:".. normalHurtPer .. "\n"
printStr = printStr .. "技能增伤百分比:".. skillHurtPer .. "\n"
printStr = printStr .. "治疗加成百分比:".. healPer .. "\n"
Logger.logHighlight(printStr)
end
-- if EDITOR_MODE then
-- local printStr = ""
-- printStr = printStr .. "更新装备数值:"..self:getCfgId().."-".. partName .. "-" .. equipEntity:getLevel() .. "\n"
-- printStr = printStr .. "生命:".. hp .. "\n"
-- printStr = printStr .. "攻击力:".. atk .. "\n"
-- printStr = printStr .. "普攻增伤:".. normalHurt .. "\n"
-- printStr = printStr .. "技能增伤:".. skillHurt .. "\n"
-- printStr = printStr .. "暴击率:".. critPer .. "\n"
-- printStr = printStr .. "暴击伤害百分比:".. critHurtPer .. "\n"
-- printStr = printStr .. "普攻增伤百分比:".. normalHurtPer .. "\n"
-- printStr = printStr .. "技能增伤百分比:".. skillHurtPer .. "\n"
-- printStr = printStr .. "治疗加成百分比:".. healPer .. "\n"
-- Logger.logHighlight(printStr)
-- end
end
end
end
@ -156,19 +156,16 @@ end
-- 更新皮肤属性
function HeroEntity:updateSkinAttr()
self.skinAttr = {}
if #DataManager.SkinData:getOwnAllAttr(self:getCfgId()) <= 0 then
return
end
local hp = DataManager.SkinData:getHp(self:getCfgId())
local atk = DataManager.SkinData:getAttack(self:getCfgId())
local normalHurt = DataManager.SkinData:getNormalHurt(self:getCfgId())
local skillHurt = DataManager.SkinData:getSkillHurt(self:getCfgId())
local critPer = DataManager.SkinData:getCritPercent(self:getCfgId())
local critHurtPer = DataManager.SkinData:getCritHurtPercent(self:getCfgId())
local normalHurtPer = DataManager.SkinData:getNormalHurtPercent(self:getCfgId())
local skillHurtPer = DataManager.SkinData:getSkillHurtPercent(self:getCfgId())
local healPer = DataManager.SkinData:getHealPercent(self:getCfgId())
local hp = DataManager.SkinData:getHp(self)
local atk = DataManager.SkinData:getAttack(self)
local normalHurt = DataManager.SkinData:getNormalHurt(self)
local skillHurt = DataManager.SkinData:getSkillHurt(self)
local critPer = DataManager.SkinData:getCritPercent(self)
local critHurtPer = DataManager.SkinData:getCritHurtPercent(self)
local normalHurtPer = DataManager.SkinData:getNormalHurtPercent(self)
local skillHurtPer = DataManager.SkinData:getSkillHurtPercent(self)
local healPer = DataManager.SkinData:getHealPercent(self)
self.skinAttr[GConst.MATCH_HP_NAME[self:getMatchType()]] = hp
self.skinAttr[GConst.MATCH_ATTACK_NAME[self:getMatchType()]] = atk
@ -495,7 +492,7 @@ function HeroEntity:getTotalBaseHp()
result = result + equipEntity:getBaseHp()
end
end
result = result + DataManager.SkinData:getBaseHp(self:getCfgId())
result = result + DataManager.SkinData:getBaseHp(self)
return result
end
@ -512,7 +509,7 @@ function HeroEntity:getTotalBaseAtk()
end
end
-- Logger.logHighlight(logStr)
result = result + DataManager.SkinData:getBaseAttack(self:getCfgId())
result = result + DataManager.SkinData:getBaseAttack(self)
return result
end
@ -531,4 +528,14 @@ function HeroEntity:getEquips(partType)
return DataManager.EquipData:getEquip(self:getCfgId(), partType)
end
function HeroEntity:setSkins(skinIds)
self.unlockSkins = skinIds
self:getTotalAttrValue() -- 防止报错
self:onSkinAttrChange()
end
function HeroEntity:getSkins()
return self.unlockSkins
end
return HeroEntity

View File

@ -30,6 +30,11 @@ function SkinData:isOpen(showToast)
return true
end
-- 获取英雄已解锁的id
function SkinData:getUnlockList()
return table.keys(self.unlockList)
end
-- 是否解锁
function SkinData:isUnlock(skinId)
return self.unlockList[skinId] or self:getSkinCfg(skinId).qlt == DEFAULT_SKIN_QLT
@ -141,25 +146,26 @@ end
-- 皮肤属性相关接口start------------------------------------------------------------------------------------
-- 英雄是否拥有某属性
function SkinData:hasAttr(heroId, attrType)
function SkinData:hasAttr(heroEntity, attrType)
if table.containValue(GConst.MATCH_HP_FIX_NAME, attrType) then
return self:getHp(heroId) > 0
return self:getHp(heroEntity) > 0
end
if table.containValue(GConst.MATCH_ATTACK_NAME, attrType) then
return self:getAttack(heroId) > 0
return self:getAttack(heroEntity) > 0
end
return table.find(self:getOwnAllAttr(heroId), function(value)
return table.find(self:getOwnAllAttr(heroEntity), function(value)
return value.type == attrType
end) ~= nil
end
-- 获取英雄已拥有的所有皮肤属性(未计算,仅配置的属性数据)
function SkinData:getOwnAllAttr(heroId)
-- 获取英雄已拥有的所有皮肤属性(未经过计算,仅配置的属性数据)
function SkinData:getOwnAllAttr(heroEntity)
local result = {}
for skinId, value in pairs(self.unlockList) do
local unlockList = heroEntity:getSkins() or self:getUnlockList()
for idx, skinId in pairs(unlockList) do
local hero = self:getHeroIdBySkinId(skinId)
local attrs = self:getAttr(skinId)
if attrs and hero == heroId then
if attrs and hero == heroEntity:getCfgId() then
for index, attr in ipairs(attrs) do
local temp = table.find(result, function(value)
return value.type == attr.type
@ -177,104 +183,102 @@ function SkinData:getOwnAllAttr(heroId)
end
-- 获取基础生命值
function SkinData:getBaseHp(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getBaseHp(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_HP_FIX_NAME, value.type)
end)
return result and result.num or 0
end
-- 获取加成后生命值
function SkinData:getHp(heroId)
local result = self:getBaseHp(heroId)
local heroEntity = DataManager.HeroData:getHeroById(heroId)
result = result + heroEntity:getTotalBaseHp() * self:getHpPercent(heroId) // DEFAULT_FACTOR
function SkinData:getHp(heroEntity)
local result = self:getBaseHp(heroEntity)
result = result + heroEntity:getTotalBaseHp() * self:getHpPercent(heroEntity) // DEFAULT_FACTOR
return result
end
-- 获取基础攻击力
function SkinData:getBaseAttack(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getBaseAttack(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_ATTACK_NAME, value.type)
end)
return result and result.num or 0
end
-- 获取加成后攻击力
function SkinData:getAttack(heroId)
local result = self:getBaseAttack(heroId)
local heroEntity = DataManager.HeroData:getHeroById(heroId)
result = result + heroEntity:getTotalBaseAtk() * self:getAtkPercent(heroId) // DEFAULT_FACTOR
function SkinData:getAttack(heroEntity)
local result = self:getBaseAttack(heroEntity)
result = result + heroEntity:getTotalBaseAtk() * self:getAtkPercent(heroEntity) // DEFAULT_FACTOR
return result
end
-- 获取攻击加成百分比
function SkinData:getAtkPercent(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getAtkPercent(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_ATTACK_ADD_NAME, value.type)
end)
return result and result.num or 0
end
-- 获取生命值加成百分比
function SkinData:getHpPercent(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getHpPercent(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_HP_ADD_NAME, value.type)
end)
return result and result.num or 0
end
-- 获取普攻伤害
function SkinData:getNormalHurt(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getNormalHurt(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_NORMAL_HURT_NAME, value.type)
end)
return result and result.num or 0
end
-- 获取皮肤技能伤害
function SkinData:getSkillHurt(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getSkillHurt(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_SKILL_HURT_NAME, value.type)
end)
return result and result.num or 0
end
-- 获取暴击率百分比
function SkinData:getCritPercent(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getCritPercent(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_CRIT_NAME, value.type)
end)
return result and result.num or 0
end
--获取暴击伤害百分比
function SkinData:getCritHurtPercent(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getCritHurtPercent(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_CRIT_TIME_NAME, value.type)
end)
return result and result.num or 0
end
-- 获取治疗百分比
function SkinData:getHealPercent(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getHealPercent(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_CURED_NAME, value.type)
end)
return result and result.num or 0
end
-- 获取普攻增伤百分比
function SkinData:getNormalHurtPercent(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getNormalHurtPercent(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_NORMAL_HURTP_NAME, value.type)
end)
return result and result.num or 0
end
-- 获取技能增伤百分比
function SkinData:getSkillHurtPercent(heroId)
local result = table.find(self:getOwnAllAttr(heroId), function(value)
function SkinData:getSkillHurtPercent(heroEntity)
local result = table.find(self:getOwnAllAttr(heroEntity), function(value)
return table.containValue(GConst.MATCH_SKILL_HURTP_NAME, value.type)
end)
return result and result.num or 0