diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 6235b7c..a04533b 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -820,26 +820,44 @@ function _M.drawHeroRpc(agent, data) end end - for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do - local pool_str = "pool_" .. poolId - if oneData[pool_str] and oneData[pool_str] ~= "" then - local itemData = csvdb["itemCsv"][itemId] - while itemData do - if itemData.type ~= ItemType.Hero then break end - local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] - if not heroData then break end - local ok = true - -- 保底是全随机,不用比较类型 - if not isFloorBack then - for idx, field in ipairs(condition) do - if heroData[field] ~= values[idx] then ok = false break end + local weight = 0 + local up_pool = nil + local rand_v = math.randomInt(1, 100) + if values[1] == HeroQuality.SR then + weight = unitPool["up_sr_weight"] + up_pool = unitPool["up_sr_id"] + elseif values[1] == HeroQuality.SSR then + weight = unitPool["up_ssr_weight"] + up_pool = unitPool["up_ssr_id"] + end + --print(poolId, rand_v, weight, up_pool, values[1]) + if rand_v < weight and up_pool then + up_pool = up_pool:toArray(true, "=") + for k, v in ipairs(up_pool) do + resultPool[v] = {1} + end + else + for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do + local pool_str = "pool_" .. poolId + if oneData[pool_str] and oneData[pool_str] ~= "" then + local itemData = csvdb["itemCsv"][itemId] + while itemData do + if itemData.type ~= ItemType.Hero then break end + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] + if not heroData then break end + local ok = true + -- 保底是全随机,不用比较类型 + if not isFloorBack then + for idx, field in ipairs(condition) do + if heroData[field] ~= values[idx] then ok = false break end + end end + if not ok then break end + if oneData[pool_str] > 0 then + resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 + end + break end - if not ok then break end - if oneData[pool_str] > 0 then - resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 - end - break end end end @@ -874,7 +892,7 @@ function _M.drawHeroRpc(agent, data) if itemData.quality == HeroQuality.SSR then ssrCount = ssrCount + 1 if not guideHero then - -- STODO 广播获得ssr英雄 + -- 广播获得ssr英雄 local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) end diff --git a/src/csvdata b/src/csvdata index a79b329..bc48fe0 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit a79b3296ccaa4f24e2263de83dc8dc581f1eb75a +Subproject commit bc48fe0471d09c4c81e4cdde286209b5df9eab75 diff --git a/src/utils/StringUtil.lua b/src/utils/StringUtil.lua index 6f4d1e7..c4c7373 100644 --- a/src/utils/StringUtil.lua +++ b/src/utils/StringUtil.lua @@ -347,4 +347,20 @@ function string.toMap(str, tonum, sep) end end return tab +end + +--[[ +from: 1=2=3=4 +to: {1,2,3,4} +]] +function string.toMap(str, tonum, sep) + local str_vec = string.split(str, " ") + local tab = {} + for _, v in pairs(str_vec) do + local vec = string.split(v, sep) + if #vec == 2 then + tab[vec[1]] = tonum and tonumber(vec[2]) or vec[2] + end + end + return tab end \ No newline at end of file -- libgit2 0.21.2