Commit 8c4a6f4c5d566fd171aaeafdd2f3afc158b1cdf1

Authored by zhouhaihai
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 272  
273 273 local adv = role:getAdvData()
274 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 277 SendPacket(actionCodes.Adv_clickBlockRpc, MsgPack.pack({events = adv:popBackEvents()}))
278 278 return true
279 279 end
... ...
src/adv/Adv.lua
... ... @@ -793,19 +793,19 @@ end
793 793 local function clickTrader(self, room, block, params)
794 794 local buyId = params.id
795 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 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 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 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 809 self:backCost({[goodsData.currency] = costCount})
810 810 local reward = self:award({[goodsData.item] = goodsData.num})
811 811 if goodsData.restrict == 1 then
... ... @@ -917,7 +917,7 @@ function Adv:clickBlock(roomId, blockId, params)
917 917 local block = self:getBlock(roomId, blockId)
918 918 if not block then return end
919 919  
920   - local status = false
  920 + local status, errorCode = false, nil
921 921 local clickEvent = false
922 922 if not block.isOpen then
923 923 local canOpen = false --如果未开放是否可以开放
... ... @@ -945,7 +945,7 @@ function Adv:clickBlock(roomId, blockId, params)
945 945 --可点击的事件
946 946 if not room.isBossRoom or block:isBoss() then
947 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 949 end
950 950 end
951 951 end
... ... @@ -960,7 +960,7 @@ function Adv:clickBlock(roomId, blockId, params)
960 960 self:afterRound()
961 961 end
962 962 self:saveDB()
963   - return status
  963 + return status, errorCode
964 964 end
965 965  
966 966  
... ...