显示优化

This commit is contained in:
xiekaidong 2023-05-26 16:32:13 +08:00
parent eb2e858213
commit cff917cac8
2 changed files with 25 additions and 19 deletions

View File

@ -650,23 +650,21 @@ function GFunc.addCosts(costs, itemGetType)
end end
-- 奖励排序 结构为后端结构 -- 奖励排序 结构为后端结构
-- function GFunc.sortRewards(rewards) function GFunc.sortRewards(rewards)
-- rewards = rewards or {} rewards = rewards or {}
-- local maxType = 10 local maxType = 10
-- for i,v in ipairs(rewards) do for i,v in ipairs(rewards) do
-- if v.type == GConst.REWARD_TYPE.ITEM then if v.type == GConst.REWARD_TYPE.ITEM then
-- rewards[i].sort = (maxType - v.type) * 1000000000 + (1000000000 - v.item.cfg_id) rewards[i].sort = (maxType - v.type) * 1000000000 + v.item.id
-- elseif v.type == GConst.REWARD_TYPE.EQUIP then elseif v.type == GConst.REWARD_TYPE.EQUIP then
-- local cfg = ConfigManager:getConfig("equip")[v.equip.id] local cfg = ConfigManager:getConfig("equip")[v.equip.id]
-- rewards[i].sort = (maxType - v.type) * 1000000000 + cfg.qlt*100000000 + v.equip.id rewards[i].sort = (maxType - v.type) * 1000000000 + cfg.qlt*100000000 + v.equip.id
-- elseif v.type == GConst.REWARD_TYPE.JEWELRY then end
-- rewards[i].sort = (maxType - v.type) * 1000000000 + (1000000000 - v.jewelry.cfg_id) end
-- end table.sort(rewards, function (a, b)
-- end return a.sort > b.sort
-- table.sort(rewards, function (a, b) end)
-- return a.sort > b.sort end
-- end)
-- end
---- 奖励展示接口 ---- 奖励展示接口
function GFunc.showRewardBox(rewards, extParams, callback) function GFunc.showRewardBox(rewards, extParams, callback)
@ -683,7 +681,7 @@ function GFunc.showRewardBox(rewards, extParams, callback)
ModuleManager.TipsManager:showRewardsBox(params) ModuleManager.TipsManager:showRewardsBox(params)
end end
function GFunc.mergeRewards2(rewards, newRewards) function GFunc.mergeRewards2(rewards, newRewards, needSort)
local items = {} local items = {}
for i,v in ipairs(rewards) do for i,v in ipairs(rewards) do
if v.type == GConst.REWARD_TYPE.ITEM then if v.type == GConst.REWARD_TYPE.ITEM then
@ -695,6 +693,9 @@ function GFunc.mergeRewards2(rewards, newRewards)
for k,v in pairs(items) do for k,v in pairs(items) do
table.insert(newRewards, {type = GConst.REWARD_TYPE.ITEM, item = {id = k, count = v}}) table.insert(newRewards, {type = GConst.REWARD_TYPE.ITEM, item = {id = k, count = v}})
end end
if needSort then
GFunc.sortRewards(newRewards)
end
end end
-- reward 结构为 type id num 配置中结构 -- reward 结构为 type id num 配置中结构

View File

@ -86,8 +86,13 @@ function ChapterManager:endFightFinish(result)
end end
if rewards then if rewards then
GFunc.mergeRewards2(rewards, newRewards) local mergeRewards = {}
GFunc.mergeRewards2(rewards, mergeRewards, true)
for _, unit in ipairs(mergeRewards) do
table.insert(newRewards, unit)
end
end end
ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport, mysteryBoxIdx) ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport, mysteryBoxIdx)
DataManager.ChapterData:fightChapter(reqData.chapter_id, result.max_chapter_id, result.max_wave, reqData.mystery_box_idx) DataManager.ChapterData:fightChapter(reqData.chapter_id, result.max_chapter_id, result.max_wave, reqData.mystery_box_idx)
-- 处理金猪,要在章节更新之后 -- 处理金猪,要在章节更新之后