Browse Source

修改巅峰战场解锁英雄逻辑

gitxsm 4 tháng trước cách đây
mục cha
commit
41544ed6f4

+ 18 - 4
script/module/serverCommerce/ServerCommerceActBattleGroundNS.lua

@@ -242,18 +242,24 @@ local function unlockHero(human, unlockHeroInfo, isInit)
         return
     end
 
-    local heroList = {}
+    -- local heroList = {}
+    local heroArr = {}
     for heroId, heroCfg in pairs(HeroConfig) do
         if heroCfg.grade >= HeroDefine.HERO_SSR_GRADE and not findVal(heroBagData, heroId) then
-            heroList[heroId] = heroCfg
+            -- heroList[heroId] = heroCfg
+            heroArr[#heroArr+1] = {heroId, heroCfg}
         end
     end
 
+    table.shuffle(heroArr)
+
     for _, heroCond in ipairs(unlockHeroInfo) do
         local campCond = heroCond[1] or 0
         local numCond = heroCond[2] or 0
         for i=1, numCond do
-            for heroId, heroCfg in pairs(heroList) do
+            for _, heroData in ipairs(heroArr) do
+                local heroId =  heroData[1]
+                local heroCfg = heroData[2]
                 if heroCfg.camp == campCond and not findVal(heroBagData, heroId) then
                     heroBagData[#heroBagData+1] = genHeroGrid(heroId)
                     break
@@ -385,6 +391,10 @@ function getHeroGridByUuid(human, heroUuid)
         return
     end
 
+    if not human.db.ServerCommerce then
+        return
+    end
+
     local battleGroundData = human.db.ServerCommerce.battleGround
     if not battleGroundData.heroBag then
         return
@@ -414,6 +424,10 @@ function getHeroGridByheroId(human, heroId)
         return
     end
 
+    if not human.db.ServerCommerce then
+        return
+    end
+
     local battleGroundData = human.db.ServerCommerce.battleGround
     if not battleGroundData.heroBag then
         return
@@ -443,7 +457,7 @@ end
 -- 阵容有更新
 function onUpdatePos(human)
     BattleGround_Lineup_Update(human)
-end 
+end
 
 
 -- 推送主界面信息