Преглед на файлове

怎该获取所有已经激活的英雄图鉴协议

gitxsm преди 6 месеца
родител
ревизия
10c8bc2d43
променени са 4 файла, в които са добавени 63 реда и са изтрити 1 реда
  1. 3 0
      script/common/ProtoID.lua
  2. 7 1
      script/module/hero/Handler.lua
  3. 46 0
      script/module/hero/HeroBook.lua
  4. 7 0
      script/module/hero/Proto.lua

+ 3 - 0
script/common/ProtoID.lua

@@ -1747,3 +1747,6 @@ _ENV[1775]="CG_ZHUANPAN_ONCE_REWARD_QUERY"
 _ENV[1776]="GC_ZHUANPAN_ONCE_REWARD_QUERY"
 _ENV[1777]="CG_ZHUANPAN_ONCE_REWARD_GET"
 
+
+_ENV[1778]="CG_ALL_HERO_BOOK_QUERY"
+_ENV[1779]="GC_ALL_HERO_BOOK_QUERY"

+ 7 - 1
script/module/hero/Handler.lua

@@ -72,7 +72,13 @@ end
 function CG_HERO_BOOK_QUERY_CS(human, msg)
     HeroBook.querySimple_CS(human, msg.camp)
 end
-	
+
+-- 查询所有激活的英雄图鉴
+function CG_ALL_HERO_BOOK_QUERY(human, msg)
+    HeroBook.HeroBook_AllHeroTujian_Query(human)
+end
+
+
 -- 英雄图鉴列传
 function CG_HERO_BOOK_LIEZHUAN_QUERY(human, msg)
 	HeroBook.CG_HERO_BOOK_LIEZHUAN_QUERY(human,msg.id)

+ 46 - 0
script/module/hero/HeroBook.lua

@@ -334,4 +334,50 @@ function queryHeroBookById(human,heroID,star)
     heroGrid.star = star
     HeroGrid.makeHeroSimple(msgRet.hero, heroGrid, nil, human, nil, true)
     Msg.send(msgRet, human.fd)
+end
+
+-- 查询所有激活的图鉴英雄
+function HeroBook_AllHeroTujian_Query(human)
+    local msgRet = Msg.gc.GC_ALL_HERO_BOOK_QUERY
+    msgRet.list[0] = 0
+    msgRet.isEnd = 0
+
+    if not human.db.heroBook then
+        msgRet.isEnd = 1
+        return Msg.send(msgRet, human.fd)
+    end
+
+    local heroIdArr = {}
+    for heroId in pairs(human.db.heroBook) do
+        heroIdArr[#heroIdArr+1] = heroId
+    end
+
+    local len = 0
+    local msgMaxLen = 20
+    local heroNum = #heroIdArr
+
+    for _, heroId in ipairs(heroIdArr) do
+        len = len + 1
+        msgRet.list[0] = len
+        local showStar = getTuJianStar(human, heroId)
+        local heroGrid = HeroGrid.getCacheHeroGridTujian(heroId)
+        heroGrid.star = showStar
+        HeroGrid.makeHeroSimple(msgRet.list[len], heroGrid, nil, human, nil, true)
+
+        if len >= msgMaxLen 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
+        end
+    end
+
+    if len > 0 then
+        msgRet.isEnd = 1
+        Msg.send(msgRet, human.fd)
+    end
 end

+ 7 - 0
script/module/hero/Proto.lua

@@ -417,6 +417,13 @@ GC_HERO_BOOK_QUERY_CS = {    --长沙这边特珠需求 同一father只取一个
     {"dot",			    10,		"byte"}, 
 }
 
+-- 查询所有激活的图鉴英雄
+CG_ALL_HERO_BOOK_QUERY = {}
+GC_ALL_HERO_BOOK_QUERY = {
+	{"list",			20,		HeroSimple},
+	{"isEnd",			1,		"byte"},	-- 发完标识, 0-否, 1-是
+}
+
 -- 图鉴英雄列传
 CG_HERO_BOOK_LIEZHUAN_QUERY = {
 	{"id",				1,		"int"},   -- 英雄id