Commit 4839b94dff9c63c1a2e47098bb942e566fbd0515
1 parent
1af7ada5
增加抽卡英雄up
Showing
3 changed files
with
54 additions
and
20 deletions
Show diff stats
src/actions/HeroAction.lua
| @@ -820,26 +820,44 @@ function _M.drawHeroRpc(agent, data) | @@ -820,26 +820,44 @@ function _M.drawHeroRpc(agent, data) | ||
| 820 | end | 820 | end |
| 821 | end | 821 | end |
| 822 | 822 | ||
| 823 | - for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do | ||
| 824 | - local pool_str = "pool_" .. poolId | ||
| 825 | - if oneData[pool_str] and oneData[pool_str] ~= "" then | ||
| 826 | - local itemData = csvdb["itemCsv"][itemId] | ||
| 827 | - while itemData do | ||
| 828 | - if itemData.type ~= ItemType.Hero then break end | ||
| 829 | - local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | ||
| 830 | - if not heroData then break end | ||
| 831 | - local ok = true | ||
| 832 | - -- 保底是全随机,不用比较类型 | ||
| 833 | - if not isFloorBack then | ||
| 834 | - for idx, field in ipairs(condition) do | ||
| 835 | - if heroData[field] ~= values[idx] then ok = false break end | 823 | + local weight = 0 |
| 824 | + local up_pool = nil | ||
| 825 | + local rand_v = math.randomInt(1, 100) | ||
| 826 | + if values[1] == HeroQuality.SR then | ||
| 827 | + weight = unitPool["up_sr_weight"] | ||
| 828 | + up_pool = unitPool["up_sr_id"] | ||
| 829 | + elseif values[1] == HeroQuality.SSR then | ||
| 830 | + weight = unitPool["up_ssr_weight"] | ||
| 831 | + up_pool = unitPool["up_ssr_id"] | ||
| 832 | + end | ||
| 833 | + --print(poolId, rand_v, weight, up_pool, values[1]) | ||
| 834 | + if rand_v < weight and up_pool then | ||
| 835 | + up_pool = up_pool:toArray(true, "=") | ||
| 836 | + for k, v in ipairs(up_pool) do | ||
| 837 | + resultPool[v] = {1} | ||
| 838 | + end | ||
| 839 | + else | ||
| 840 | + for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do | ||
| 841 | + local pool_str = "pool_" .. poolId | ||
| 842 | + if oneData[pool_str] and oneData[pool_str] ~= "" then | ||
| 843 | + local itemData = csvdb["itemCsv"][itemId] | ||
| 844 | + while itemData do | ||
| 845 | + if itemData.type ~= ItemType.Hero then break end | ||
| 846 | + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | ||
| 847 | + if not heroData then break end | ||
| 848 | + local ok = true | ||
| 849 | + -- 保底是全随机,不用比较类型 | ||
| 850 | + if not isFloorBack then | ||
| 851 | + for idx, field in ipairs(condition) do | ||
| 852 | + if heroData[field] ~= values[idx] then ok = false break end | ||
| 853 | + end | ||
| 836 | end | 854 | end |
| 855 | + if not ok then break end | ||
| 856 | + if oneData[pool_str] > 0 then | ||
| 857 | + resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 | ||
| 858 | + end | ||
| 859 | + break | ||
| 837 | end | 860 | end |
| 838 | - if not ok then break end | ||
| 839 | - if oneData[pool_str] > 0 then | ||
| 840 | - resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 | ||
| 841 | - end | ||
| 842 | - break | ||
| 843 | end | 861 | end |
| 844 | end | 862 | end |
| 845 | end | 863 | end |
| @@ -874,7 +892,7 @@ function _M.drawHeroRpc(agent, data) | @@ -874,7 +892,7 @@ function _M.drawHeroRpc(agent, data) | ||
| 874 | if itemData.quality == HeroQuality.SSR then | 892 | if itemData.quality == HeroQuality.SSR then |
| 875 | ssrCount = ssrCount + 1 | 893 | ssrCount = ssrCount + 1 |
| 876 | if not guideHero then | 894 | if not guideHero then |
| 877 | - -- STODO 广播获得ssr英雄 | 895 | + -- 广播获得ssr英雄 |
| 878 | local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} | 896 | local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} |
| 879 | mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) | 897 | mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) |
| 880 | end | 898 | end |
src/utils/StringUtil.lua
| @@ -347,4 +347,20 @@ function string.toMap(str, tonum, sep) | @@ -347,4 +347,20 @@ function string.toMap(str, tonum, sep) | ||
| 347 | end | 347 | end |
| 348 | end | 348 | end |
| 349 | return tab | 349 | return tab |
| 350 | +end | ||
| 351 | + | ||
| 352 | +--[[ | ||
| 353 | +from: 1=2=3=4 | ||
| 354 | +to: {1,2,3,4} | ||
| 355 | +]] | ||
| 356 | +function string.toMap(str, tonum, sep) | ||
| 357 | + local str_vec = string.split(str, " ") | ||
| 358 | + local tab = {} | ||
| 359 | + for _, v in pairs(str_vec) do | ||
| 360 | + local vec = string.split(v, sep) | ||
| 361 | + if #vec == 2 then | ||
| 362 | + tab[vec[1]] = tonum and tonumber(vec[2]) or vec[2] | ||
| 363 | + end | ||
| 364 | + end | ||
| 365 | + return tab | ||
| 350 | end | 366 | end |
| 351 | \ No newline at end of file | 367 | \ No newline at end of file |