Commit db8e475e64a8fbd53aa8ffd5989eb0d353b48b74
1 parent
216fb30d
抽奖
Showing
1 changed file
with
18 additions
and
18 deletions
Show diff stats
src/actions/HeroAction.lua
| @@ -726,7 +726,6 @@ function _M.drawHeroRpc(agent, data) | @@ -726,7 +726,6 @@ function _M.drawHeroRpc(agent, data) | ||
| 726 | for _, rateType in ipairs(rateTypes) do | 726 | for _, rateType in ipairs(rateTypes) do |
| 727 | table.insert(typePool, {buildTypeData[rateType]}) | 727 | table.insert(typePool, {buildTypeData[rateType]}) |
| 728 | end | 728 | end |
| 729 | - local rateType = math.randWeight(typePool, 1) | ||
| 730 | 729 | ||
| 731 | local resultPool = {} | 730 | local resultPool = {} |
| 732 | 731 | ||
| @@ -771,23 +770,24 @@ function _M.drawHeroRpc(agent, data) | @@ -771,23 +770,24 @@ function _M.drawHeroRpc(agent, data) | ||
| 771 | for i = 1, drawCount[drawType] do | 770 | for i = 1, drawCount[drawType] do |
| 772 | 771 | ||
| 773 | resultPool = {} | 772 | resultPool = {} |
| 774 | - if not fillPoolFunc[rateTypes[rateType]] then return 4 end | ||
| 775 | - fillPoolFunc[rateTypes[rateType]]() | ||
| 776 | - | ||
| 777 | - if next(resultPool) then | ||
| 778 | - local idx = math.randWeight(resultPool, 3) | ||
| 779 | - local temp = resultPool[idx] | ||
| 780 | - local itemData = csvdb["itemCsv"][temp[1]] | ||
| 781 | - if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then | ||
| 782 | - local fragId = itemData.id - ItemStartId.Hero | ||
| 783 | - local heroData = csvdb["unitCsv"][fragId] | ||
| 784 | - local count = globalCsv.draw_unit_tofragment[heroData.rare] * temp[2] | ||
| 785 | - role:award({[fragId] = count}) | ||
| 786 | - table.insert(reward, {id = fragId, count = count, from = temp[1], fcount = temp[2]}) | ||
| 787 | - else | ||
| 788 | - role:award({[temp[1]] = temp[2]}) | ||
| 789 | - table.insert(reward, {id = temp[1], count = temp[2]}) | ||
| 790 | - end | 773 | + while not next(resultPool) do |
| 774 | + local rateType = math.randWeight(typePool, 1) | ||
| 775 | + if not fillPoolFunc[rateTypes[rateType]] then return 4 end | ||
| 776 | + fillPoolFunc[rateTypes[rateType]]() | ||
| 777 | + end | ||
| 778 | + | ||
| 779 | + local idx = math.randWeight(resultPool, 3) | ||
| 780 | + local temp = resultPool[idx] | ||
| 781 | + local itemData = csvdb["itemCsv"][temp[1]] | ||
| 782 | + if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then | ||
| 783 | + local fragId = itemData.id - ItemStartId.Hero | ||
| 784 | + local heroData = csvdb["unitCsv"][fragId] | ||
| 785 | + local count = globalCsv.draw_unit_tofragment[heroData.rare] * temp[2] | ||
| 786 | + role:award({[fragId] = count}) | ||
| 787 | + table.insert(reward, {id = fragId, count = count, from = temp[1], fcount = temp[2]}) | ||
| 788 | + else | ||
| 789 | + role:award({[temp[1]] = temp[2]}) | ||
| 790 | + table.insert(reward, {id = temp[1], count = temp[2]}) | ||
| 791 | end | 791 | end |
| 792 | end | 792 | end |
| 793 | 793 |