|
@@ -58,8 +58,8 @@ local function calcCurrentLvAttrs(currentLevel)
|
|
|
local attrs = {}
|
|
local attrs = {}
|
|
|
for i=1, currentLevel do
|
|
for i=1, currentLevel do
|
|
|
local cfg = RecycleConfig[i]
|
|
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 attrId = v[1]
|
|
|
local attrVal = v[2]
|
|
local attrVal = v[2]
|
|
|
attrs[attrId] = (attrs[attrId] or 0) + attrVal
|
|
attrs[attrId] = (attrs[attrId] or 0) + attrVal
|
|
@@ -132,9 +132,10 @@ local function populateNextLvAttrs(net, nextLv)
|
|
|
|
|
|
|
|
net[0] = 0
|
|
net[0] = 0
|
|
|
local cfg = RecycleConfig[nextLv]
|
|
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].key = v[1]
|
|
|
net[k].value = isMax and 0 or v[2]
|
|
net[k].value = isMax and 0 or v[2]
|
|
|
end
|
|
end
|
|
@@ -142,30 +143,34 @@ local function populateNextLvAttrs(net, nextLv)
|
|
|
|
|
|
|
|
end
|
|
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)
|
|
function doCalcHero(human, addAttrs)
|
|
|
|
|
+ if not human then
|
|
|
|
|
+ return
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
local recycleData = getRecycleData(human)
|
|
local recycleData = getRecycleData(human)
|
|
|
if not recycleData then
|
|
if not recycleData then
|
|
|
return
|
|
return
|
|
@@ -184,7 +189,7 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- 查询
|
|
|
|
|
|
|
+-- 查询部分信息
|
|
|
function RecycleItem_Query(human)
|
|
function RecycleItem_Query(human)
|
|
|
if not isOpen(human) then
|
|
if not isOpen(human) then
|
|
|
return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
|
|
return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
|
|
@@ -198,7 +203,7 @@ function RecycleItem_Query(human)
|
|
|
|
|
|
|
|
if currentLevel < maxLevel then
|
|
if currentLevel < maxLevel then
|
|
|
local nextLvCfg = RecycleConfig[currentLevel + 1]
|
|
local nextLvCfg = RecycleConfig[currentLevel + 1]
|
|
|
- nextLvExp = nextLvCfg.exp - currentExp
|
|
|
|
|
|
|
+ nextLvExp = nextLvCfg.exp
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
local msgRet = Msg.gc.GC_RECYCLE_QUERY
|
|
local msgRet = Msg.gc.GC_RECYCLE_QUERY
|
|
@@ -209,11 +214,70 @@ function RecycleItem_Query(human)
|
|
|
|
|
|
|
|
populateCurrentLvAttrs(msgRet.currentLvAttrs, currentLevel)
|
|
populateCurrentLvAttrs(msgRet.currentLvAttrs, currentLevel)
|
|
|
populateNextLvAttrs(msgRet.nextLvAttrs, currentLevel+1)
|
|
populateNextLvAttrs(msgRet.nextLvAttrs, currentLevel+1)
|
|
|
- populateRecycleItem(msgRet.recycleList, human)
|
|
|
|
|
|
|
+ -- populateRecycleItem(msgRet.recycleList, human)
|
|
|
|
|
|
|
|
Msg.send(msgRet, human.fd)
|
|
Msg.send(msgRet, human.fd)
|
|
|
end
|
|
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)
|
|
function RecycleItem_Recycle_Do(human, recycleItemStr)
|
|
|
if not isOpen(human) then
|
|
if not isOpen(human) then
|
|
@@ -243,7 +307,7 @@ function RecycleItem_Recycle_Do(human, recycleItemStr)
|
|
|
return Broadcast.sendErr(human, Lang.COMMON_ITEM_NOT_ENOUGH)
|
|
return Broadcast.sendErr(human, Lang.COMMON_ITEM_NOT_ENOUGH)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- totalExp = totalExp + itemCfg.val
|
|
|
|
|
|
|
+ totalExp = totalExp + itemCfg.val * itemCnt
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
for itemId, itemCnt in pairs(itemList) do
|
|
for itemId, itemCnt in pairs(itemList) do
|
|
@@ -262,4 +326,5 @@ function RecycleItem_Recycle_Do(human, recycleItemStr)
|
|
|
|
|
|
|
|
-- 更新UI界面数据
|
|
-- 更新UI界面数据
|
|
|
RecycleItem_Query(human)
|
|
RecycleItem_Query(human)
|
|
|
|
|
+ RecycleItem_RecycleItemListQuery(human)
|
|
|
end
|
|
end
|