diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 7c3c533..f0503f6 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -765,25 +765,29 @@ function _M.drawHeroRpc(agent, data) end, } - if not fillPoolFunc[rateTypes[rateType]] then return 4 end - fillPoolFunc[rateTypes[rateType]]() - if not next(resultPool) then return 5 end role:costItems(cost) local reward = {} for i = 1, drawCount[drawType] do - local idx = math.randWeight(resultPool, 3) - local temp = resultPool[idx] - local itemData = csvdb["itemCsv"][temp[1]] - if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then - local fragId = itemData.id - ItemStartId.Hero - local heroData = csvdb["unitCsv"][fragId] - local count = globalCsv.draw_unit_tofragment[heroData.rare] * temp[2] - role:award({[fragId] = count}) - table.insert(reward, {id = fragId, count = count, from = temp[1], fcount = temp[2]}) - else - role:award({[temp[1]] = temp[2]}) - table.insert(reward, {id = temp[1], count = temp[2]}) + + resultPool = {} + if not fillPoolFunc[rateTypes[rateType]] then return 4 end + fillPoolFunc[rateTypes[rateType]]() + + if next(resultPool) then + local idx = math.randWeight(resultPool, 3) + local temp = resultPool[idx] + local itemData = csvdb["itemCsv"][temp[1]] + if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then + local fragId = itemData.id - ItemStartId.Hero + local heroData = csvdb["unitCsv"][fragId] + local count = globalCsv.draw_unit_tofragment[heroData.rare] * temp[2] + role:award({[fragId] = count}) + table.insert(reward, {id = fragId, count = count, from = temp[1], fcount = temp[2]}) + else + role:award({[temp[1]] = temp[2]}) + table.insert(reward, {id = temp[1], count = temp[2]}) + end end end -- libgit2 0.21.2