Bladeren bron

修改收纳箱功能

gitxsm 2 weken geleden
bovenliggende
commit
13c6434272
4 gewijzigde bestanden met toevoegingen van 106 en 29 verwijderingen
  1. 2 0
      script/common/ProtoID.lua
  2. 4 0
      script/module/bag/Handler.lua
  3. 9 3
      script/module/bag/Proto.lua
  4. 91 26
      script/module/bag/RecycleItem.lua

+ 2 - 0
script/common/ProtoID.lua

@@ -1818,6 +1818,8 @@ _ENV[1854]="GC_POWERRANK_TOPONE_LOGIN"
 _ENV[1855]="CG_RECYCLE_QUERY"
 _ENV[1856]="GC_RECYCLE_QUERY"
 _ENV[1857]="CG_RECYCLE_RECYCLEITEM"
+_ENV[1858]="CG_RECYCLE_GET_RECYCLE_LIST"
+_ENV[1859]="GC_RECYCLE_GET_RECYCLE_LIST"
 
 _ENV[1896]="CG_ZHUANPAN_SUBSCRIBE_REWARD_QUERY"
 _ENV[1897]="GC_ZHUANPAN_SUBSCRIBE_REWARD_QUERY"

+ 4 - 0
script/module/bag/Handler.lua

@@ -101,4 +101,8 @@ end
 
 function CG_RECYCLE_RECYCLEITEM(human, msg)
 	RecycleItem.RecycleItem_Recycle_Do(human, msg.recycleItemStr)
+end
+
+function CG_RECYCLE_GET_RECYCLE_LIST(human, msg)
+	RecycleItem.RecycleItem_RecycleItemListQuery(human)
 end

+ 9 - 3
script/module/bag/Proto.lua

@@ -381,9 +381,15 @@ GC_RECYCLE_QUERY = {
 	{"maxLevel",		1,		"short"},		-- 最高等级
 	{"currentExp",		1,		"int"},			-- 当前经验值
 	{"nextLvExp",		1,		"int"},			-- 升到下一级所需经验
-	{"currentLvAttrs",	4,		Attr},			-- 当前等级加成属性
-	{"nextLvAttrs",		4,		Attr},			-- 下一级加成属性
-	{"recycleList",		30,		RECYCLE_ITEM},	-- 可回收道具列表
+	{"currentLvAttrs",	6,		Attr},			-- 当前等级加成属性
+	{"nextLvAttrs",		6,		Attr},			-- 下一级加成属性
+}
+
+CG_RECYCLE_GET_RECYCLE_LIST = {}
+GC_RECYCLE_GET_RECYCLE_LIST = {
+	{"recycleList",		50,		RECYCLE_ITEM},	-- 可回收道具列表
+	{"isStart",			1,		"byte"},      	-- 0-否,1-是
+	{"isEnd",			1,		"byte"},      	-- 0-否,1-是
 }
 
 

+ 91 - 26
script/module/bag/RecycleItem.lua

@@ -58,8 +58,8 @@ local function calcCurrentLvAttrs(currentLevel)
     local attrs = {}
     for i=1, currentLevel do
         local cfg = RecycleConfig[i]
-        if cfg and cfg.atttrs then
-            for _,v in ipairs(cfg.atttrs) do
+        if cfg and cfg.attrs then
+            for _,v in ipairs(cfg.attrs) do
                 local attrId = v[1]
                 local attrVal = v[2]
                 attrs[attrId] = (attrs[attrId] or 0) + attrVal
@@ -132,9 +132,10 @@ local function populateNextLvAttrs(net, nextLv)
 
     net[0] = 0
     local cfg = RecycleConfig[nextLv]
-    if cfg and cfg.atttrs then
-        net[0] = #cfg.atttrs
-        for k,v in ipairs(cfg.atttrs) do
+
+    if cfg and cfg.attrs then
+        net[0] = #cfg.attrs
+        for k,v in ipairs(cfg.attrs) do
             net[k].key = v[1]
             net[k].value = isMax and 0 or v[2]
         end
@@ -142,30 +143,34 @@ local function populateNextLvAttrs(net, nextLv)
 
 end
 
-local function populateRecycleItem(net, human)
-    net[0] = 0
+-- local function populateRecycleItem(net, human)
+--     net[0] = 0
 
-    local bagData = BagLogic.GetBagData(human)
-    if not bagData then
-        return
-    end
+--     local bagData = BagLogic.GetBagData(human)
+--     if not bagData then
+--         return
+--     end
 
-    local len = 0
-    for itemId in pairs(bagData) do
-        local itemCfg = ItemConfig[itemId]
-        if itemCfg and itemCfg.val and itemCfg.val > 0 then
-            len = len + 1
-            net[0] = len
-            net[len].id = itemId
-            net[len].recycleVal = itemCfg.val
-        end
-    end
-end
+--     local len = 0
+--     for itemId in pairs(bagData) do
+--         local itemCfg = ItemConfig[itemId]
+--         if itemCfg and itemCfg.val and itemCfg.val > 0 then
+--             len = len + 1
+--             net[0] = len
+--             net[len].id = itemId
+--             net[len].recycleVal = itemCfg.val
+--         end
+--     end
+-- end
 
 
 
 -- 外部调用, 统计收纳箱加成属性
 function doCalcHero(human, addAttrs)
+    if not human then
+        return
+    end
+
     local recycleData = getRecycleData(human)
     if not recycleData then
         return
@@ -184,7 +189,7 @@ end
 
 
 
--- 查询
+-- 查询部分信息
 function RecycleItem_Query(human)
     if not isOpen(human) then
         return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
@@ -198,7 +203,7 @@ function RecycleItem_Query(human)
 
     if currentLevel < maxLevel then
         local nextLvCfg = RecycleConfig[currentLevel + 1]
-        nextLvExp = nextLvCfg.exp - currentExp
+        nextLvExp = nextLvCfg.exp
     end
 
     local msgRet = Msg.gc.GC_RECYCLE_QUERY
@@ -209,11 +214,70 @@ function RecycleItem_Query(human)
 
     populateCurrentLvAttrs(msgRet.currentLvAttrs, currentLevel)
     populateNextLvAttrs(msgRet.nextLvAttrs, currentLevel+1)
-    populateRecycleItem(msgRet.recycleList, human)
+    -- populateRecycleItem(msgRet.recycleList, human)
 
     Msg.send(msgRet, human.fd)
 end
 
+-- 查询可回收道具列表
+function RecycleItem_RecycleItemListQuery(human)
+    if not isOpen(human) then
+        return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
+    end
+
+    local msgRet = Msg.gc.GC_RECYCLE_GET_RECYCLE_LIST
+    msgRet.recycleList[0] = 0
+    msgRet.isStart = 1
+    msgRet.isEnd = 0
+
+    local bagData = BagLogic.GetBagData(human)
+    if not bagData then
+        msgRet.isEnd = 1
+        return Msg.send(msgRet, human.fd)
+    end
+
+    local itemArr = {}
+    for itemId in pairs(bagData) do
+        local itemCfg = ItemConfig[itemId]
+        if itemCfg and itemCfg.val and itemCfg.val > 0 then
+            itemArr[#itemArr+1] = {itemId, itemCfg.val}
+        end
+    end
+
+    local itemNum = #itemArr
+    if itemNum == 0 then
+        msgRet.isEnd = 1
+        return Msg.send(msgRet, human.fd)
+    end
+
+    local len = 0
+    local onceMsgLen = 50
+
+    for _, itemInfo in ipairs(itemArr) do
+        len = len + 1
+        msgRet.recycleList[0] = len
+        msgRet.recycleList[len].id = itemInfo[1]
+        msgRet.recycleList[len].recycleVal = itemInfo[2]
+
+        if len >= onceMsgLen then
+            itemNum = itemNum - len
+            if itemNum <= 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
+
 -- 回收道具
 function RecycleItem_Recycle_Do(human, recycleItemStr)
     if not isOpen(human) then
@@ -243,7 +307,7 @@ function RecycleItem_Recycle_Do(human, recycleItemStr)
             return Broadcast.sendErr(human, Lang.COMMON_ITEM_NOT_ENOUGH)
         end
 
-        totalExp = totalExp + itemCfg.val
+        totalExp = totalExp + itemCfg.val * itemCnt
     end
 
     for itemId, itemCnt in pairs(itemList) do
@@ -262,4 +326,5 @@ function RecycleItem_Recycle_Do(human, recycleItemStr)
 
     -- 更新UI界面数据
     RecycleItem_Query(human)
+    RecycleItem_RecycleItemListQuery(human)
 end