From 8c4a6f4c5d566fd171aaeafdd2f3afc158b1cdf1 Mon Sep 17 00:00:00 2001 From: zhouhaihai <781184096@qq.com> Date: Thu, 20 Feb 2020 20:16:24 +0800 Subject: [PATCH] 冒险增加错误返回 --- src/actions/AdvAction.lua | 4 ++-- src/adv/Adv.lua | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index ecacd3e..543f8a7 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -272,8 +272,8 @@ function _M.clickBlockRpc(agent, data) local adv = role:getAdvData() if adv:isWaitChooseArtifact() then return end - local status = adv:clickBlock(msg.roomId, msg.blockId, msg) - if not status then return end + local status, errorCode = adv:clickBlock(msg.roomId, msg.blockId, msg) + if not status then return errorCode end SendPacket(actionCodes.Adv_clickBlockRpc, MsgPack.pack({events = adv:popBackEvents()})) return true end diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 9a75536..4f14254 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -793,19 +793,19 @@ end local function clickTrader(self, room, block, params) local buyId = params.id local traderData = csvdb["event_traderCsv"][block.event.id] - if not traderData then return end -- 偷偷改表了 + if not traderData then return false, 1 end -- 偷偷改表了 - if not block.event.shop or not block.event.shop[buyId] then return end - if (block.event.status or ""):getv(buyId, 0) == 1 then return end -- 买过了 + if not block.event.shop or not block.event.shop[buyId] then return false, 2 end + if (block.event.status or ""):getv(buyId, 0) == 1 then return false, 3 end -- 买过了 local buyCount = #((block.event.status or ""):toArray()) - if traderData.purchasetime <= buyCount then return end + if traderData.purchasetime <= buyCount then return false, 4 end local goodsData = csvdb["event_trader_goodsCsv"][block.event.shop[buyId][1]] - if not goodsData then return end + if not goodsData then return false, 5 end local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) - if not self:cost({[goodsData.currency] = costCount}, {}) then return end --不够 + if not self:cost({[goodsData.currency] = costCount}, {}) then return false, 6 end --不够 self:backCost({[goodsData.currency] = costCount}) local reward = self:award({[goodsData.item] = goodsData.num}) if goodsData.restrict == 1 then @@ -917,7 +917,7 @@ function Adv:clickBlock(roomId, blockId, params) local block = self:getBlock(roomId, blockId) if not block then return end - local status = false + local status, errorCode = false, nil local clickEvent = false if not block.isOpen then local canOpen = false --如果未开放是否可以开放 @@ -945,7 +945,7 @@ function Adv:clickBlock(roomId, blockId, params) --可点击的事件 if not room.isBossRoom or block:isBoss() then if eventCallFunc[block.event.etype] then - status = eventCallFunc[block:getEventType()](self, room, block, params) + status, errorCode = eventCallFunc[block:getEventType()](self, room, block, params) end end end @@ -960,7 +960,7 @@ function Adv:clickBlock(roomId, blockId, params) self:afterRound() end self:saveDB() - return status + return status, errorCode end -- libgit2 0.21.2