From 81a00cac4be0105278104ca7605542372860e80a Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Thu, 15 Aug 2019 14:26:58 +0800 Subject: [PATCH] 爬塔买满次数 --- src/ProtocolCode.lua | 1 + src/actions/TowerAction.lua | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index af5d6b2..862c96d 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -85,6 +85,7 @@ actionCodes = { Tower_startBattleRpc = 351, Tower_endBattleRpc = 352, Tower_rankRpc = 353, + Tower_bugCountRpc = 354, Car_makePotionRpc = 400, Car_equipUpRpc = 401, diff --git a/src/actions/TowerAction.lua b/src/actions/TowerAction.lua index 184c89f..9bf448c 100644 --- a/src/actions/TowerAction.lua +++ b/src/actions/TowerAction.lua @@ -55,6 +55,9 @@ function _M.startBattleRpc(agent, data) --搞起来 towerInfo.c = curCount - 1 + if curCount == globalCsv.tower_count_limit then --满的情况下的消耗了 恢复时间从当下开始 + nextTime = skynet.timex() + end towerInfo.t = nextTime local key = tostring(math.random()) towerInfo.k = key @@ -95,6 +98,27 @@ function _M.endBattleRpc(agent, data) return true end +function _M.bugCountRpc(agent, data) + local role = agent.role + + local towerInfo = role:getProperty("towerInfo") + local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) + local needCount = globalCsv.tower_count_limit - curCount + if needCount > 0 then -- 补充 + local cost = globalCsv.tower_chance_item:toNumMap() + for k , v in pairs(cost) do + cost[k] = v * needCount + end + if not role:checkItemEnough(cost) then return end + role:costItems(cost) + curCount = globalCsv.tower_count_limit + end + towerInfo.c = curCount + towerInfo.t = nextTime + role:updateProperty({field = "towerInfo", value = towerInfo}) + SendPacket(actionCodes.Tower_bugCountRpc, '') + return true +end function _M.rankRpc(agent , data) local role = agent.role -- libgit2 0.21.2