Commit 8c4a6f4c5d566fd171aaeafdd2f3afc158b1cdf1
1 parent
127a5787
冒险增加错误返回
Showing
2 changed files
with
11 additions
and
11 deletions
Show diff stats
src/actions/AdvAction.lua
@@ -272,8 +272,8 @@ function _M.clickBlockRpc(agent, data) | @@ -272,8 +272,8 @@ function _M.clickBlockRpc(agent, data) | ||
272 | 272 | ||
273 | local adv = role:getAdvData() | 273 | local adv = role:getAdvData() |
274 | if adv:isWaitChooseArtifact() then return end | 274 | if adv:isWaitChooseArtifact() then return end |
275 | - local status = adv:clickBlock(msg.roomId, msg.blockId, msg) | ||
276 | - if not status then return end | 275 | + local status, errorCode = adv:clickBlock(msg.roomId, msg.blockId, msg) |
276 | + if not status then return errorCode end | ||
277 | SendPacket(actionCodes.Adv_clickBlockRpc, MsgPack.pack({events = adv:popBackEvents()})) | 277 | SendPacket(actionCodes.Adv_clickBlockRpc, MsgPack.pack({events = adv:popBackEvents()})) |
278 | return true | 278 | return true |
279 | end | 279 | end |
src/adv/Adv.lua
@@ -793,19 +793,19 @@ end | @@ -793,19 +793,19 @@ end | ||
793 | local function clickTrader(self, room, block, params) | 793 | local function clickTrader(self, room, block, params) |
794 | local buyId = params.id | 794 | local buyId = params.id |
795 | local traderData = csvdb["event_traderCsv"][block.event.id] | 795 | local traderData = csvdb["event_traderCsv"][block.event.id] |
796 | - if not traderData then return end -- 偷偷改表了 | 796 | + if not traderData then return false, 1 end -- 偷偷改表了 |
797 | 797 | ||
798 | - if not block.event.shop or not block.event.shop[buyId] then return end | ||
799 | - if (block.event.status or ""):getv(buyId, 0) == 1 then return end -- 买过了 | 798 | + if not block.event.shop or not block.event.shop[buyId] then return false, 2 end |
799 | + if (block.event.status or ""):getv(buyId, 0) == 1 then return false, 3 end -- 买过了 | ||
800 | 800 | ||
801 | local buyCount = #((block.event.status or ""):toArray()) | 801 | local buyCount = #((block.event.status or ""):toArray()) |
802 | - if traderData.purchasetime <= buyCount then return end | 802 | + if traderData.purchasetime <= buyCount then return false, 4 end |
803 | 803 | ||
804 | local goodsData = csvdb["event_trader_goodsCsv"][block.event.shop[buyId][1]] | 804 | local goodsData = csvdb["event_trader_goodsCsv"][block.event.shop[buyId][1]] |
805 | - if not goodsData then return end | 805 | + if not goodsData then return false, 5 end |
806 | 806 | ||
807 | local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) | 807 | local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) |
808 | - if not self:cost({[goodsData.currency] = costCount}, {}) then return end --不够 | 808 | + if not self:cost({[goodsData.currency] = costCount}, {}) then return false, 6 end --不够 |
809 | self:backCost({[goodsData.currency] = costCount}) | 809 | self:backCost({[goodsData.currency] = costCount}) |
810 | local reward = self:award({[goodsData.item] = goodsData.num}) | 810 | local reward = self:award({[goodsData.item] = goodsData.num}) |
811 | if goodsData.restrict == 1 then | 811 | if goodsData.restrict == 1 then |
@@ -917,7 +917,7 @@ function Adv:clickBlock(roomId, blockId, params) | @@ -917,7 +917,7 @@ function Adv:clickBlock(roomId, blockId, params) | ||
917 | local block = self:getBlock(roomId, blockId) | 917 | local block = self:getBlock(roomId, blockId) |
918 | if not block then return end | 918 | if not block then return end |
919 | 919 | ||
920 | - local status = false | 920 | + local status, errorCode = false, nil |
921 | local clickEvent = false | 921 | local clickEvent = false |
922 | if not block.isOpen then | 922 | if not block.isOpen then |
923 | local canOpen = false --如果未开放是否可以开放 | 923 | local canOpen = false --如果未开放是否可以开放 |
@@ -945,7 +945,7 @@ function Adv:clickBlock(roomId, blockId, params) | @@ -945,7 +945,7 @@ function Adv:clickBlock(roomId, blockId, params) | ||
945 | --可点击的事件 | 945 | --可点击的事件 |
946 | if not room.isBossRoom or block:isBoss() then | 946 | if not room.isBossRoom or block:isBoss() then |
947 | if eventCallFunc[block.event.etype] then | 947 | if eventCallFunc[block.event.etype] then |
948 | - status = eventCallFunc[block:getEventType()](self, room, block, params) | 948 | + status, errorCode = eventCallFunc[block:getEventType()](self, room, block, params) |
949 | end | 949 | end |
950 | end | 950 | end |
951 | end | 951 | end |
@@ -960,7 +960,7 @@ function Adv:clickBlock(roomId, blockId, params) | @@ -960,7 +960,7 @@ function Adv:clickBlock(roomId, blockId, params) | ||
960 | self:afterRound() | 960 | self:afterRound() |
961 | end | 961 | end |
962 | self:saveDB() | 962 | self:saveDB() |
963 | - return status | 963 | + return status, errorCode |
964 | end | 964 | end |
965 | 965 | ||
966 | 966 |