gitxsm 3 месяцев назад
Родитель
Сommit
f3976aa7e4
2 измененных файлов с 78 добавлено и 10 удалено
  1. 10 2
      script/module/zhanbu/Proto.lua
  2. 68 8
      script/module/zhanbu/ZhanbuLogic.lua

+ 10 - 2
script/module/zhanbu/Proto.lua

@@ -56,9 +56,17 @@ GC_ZHANBU_LVUP = {
 CG_ZHANBU_HEART_HERO_QUERY = {
 }
 
+ZHANBU_HERO_INFO = {
+    {"heroId",    1,   "int"},      -- 英雄头像及id
+    {"heroCamp",  1,   "byte"},      -- 英雄种族
+    {"heroName",  1,   "string"},   -- 英雄名字
+}
+
 GC_ZHANBU_HEART_HERO_QUERY = {
-    {"heroInfo",3,"int"},      -- 英雄头像及id
-    {"heroList",100,"int"},      -- 图鉴SSR英雄列表
+    {"heroInfo",    3,      ZHANBU_HERO_INFO},      -- 英雄头像及id
+    {"heroList",    20,    ZHANBU_HERO_INFO},      -- 图鉴SSR英雄列表
+    {"isEnd",       1,     "byte"},            -- 是否发完数据, 0-没有, 1-发完
+    {"isStart",     1,     "byte"},            -- 是否是第一段数据, 0-不是,1-是
 }
 
 CG_ZHANBU_HEART_HERO = {

+ 68 - 8
script/module/zhanbu/ZhanbuLogic.lua

@@ -517,6 +517,19 @@ function refreshCardPool(human)
     YunYingLogic.onCallBack(human, "onZhanBuBuyCard", CARD_POOL_REFRESH)
 end
 
+
+local function populateHeroMsg(net, heroId)
+    net.heroId = heroId or 0
+    net.heroCamp = 0
+    net.heroName = ""
+    local heroConfig = HeroExcel.hero[heroId]
+    if heroConfig then
+        net.heroCamp = heroConfig.camp
+        net.heroName = heroConfig.name
+    end
+end
+
+
 -- ����Ӣ��
 function zhanbuHeartHeroQuery(human)
     -- �������ݶ�û�У��Ҹ�
@@ -525,21 +538,68 @@ function zhanbuHeartHeroQuery(human)
     end
     
     local msgRet = Msg.gc.GC_ZHANBU_HEART_HERO_QUERY
+    -- for i = 1,3 do
+    --     local heroID = human.db.zhanbu.heartHero[i]
+    --     msgRet.heroInfo[i] = heroID or 0
+    -- end
+    -- msgRet.heroInfo[0] = 3
+    -- local len = 0
+    -- for heroID,v in pairs(human.db.heroBook) do
+    --     local heroConfig = HeroExcel.hero[heroID]
+    --     if heroConfig and heroConfig.grade >= 4 then
+    --         len = len + 1
+    --         msgRet.heroList[len] = heroID
+    --     end
+    -- end
+    -- msgRet.heroList[0] = len
+    -- Msg.send(msgRet,human.fd)
+
+
+
+    msgRet.isEnd = 0
+    msgRet.isStart = 1
+    msgRet.heroInfo[0] = 3
+    msgRet.heroList[0] = 0
+
     for i = 1,3 do
         local heroID = human.db.zhanbu.heartHero[i]
-        msgRet.heroInfo[i] = heroID or 0
+        populateHeroMsg(msgRet.heroInfo[i], heroID)
     end
-    msgRet.heroInfo[0] = 3
-    local len = 0
-    for heroID,v in pairs(human.db.heroBook) do
+
+    local heroIdArr = {}
+    for heroID in pairs(human.db.heroBook) do
         local heroConfig = HeroExcel.hero[heroID]
         if heroConfig and heroConfig.grade >= 4 then
-            len = len + 1
-            msgRet.heroList[len] = heroID
+            heroIdArr[#heroIdArr+1] = heroID
         end
     end
-    msgRet.heroList[0] = len
-    Msg.send(msgRet,human.fd)
+
+    local heroNum = #heroIdArr
+    local len, msgOnceLen = 0, 20
+
+    for _, heroId in ipairs(heroIdArr) do
+        len = len + 1
+        msgRet.heroList[0] = len
+        populateHeroMsg(msgRet.heroList[len], heroId)
+
+        if len >= msgOnceLen then
+            heroNum = heroNum - len
+            if heroNum <= 0 then
+                msgRet.isEnd = 1
+                return Msg.send(msgRet,human.fd)
+            end
+
+            Msg.send(msgRet,human.fd)
+            len = 0
+            msgRet.isStart = 0
+        end
+    end
+
+    if len > 0 then
+        msgRet.isEnd = 1
+        Msg.send(msgRet,human.fd)
+    end
+
 end
 
 -- ��������Ӣ��