Commit 81a00cac4be0105278104ca7605542372860e80a
1 parent
12f7b52c
爬塔买满次数
Showing
2 changed files
with
25 additions
and
0 deletions
Show diff stats
src/ProtocolCode.lua
@@ -85,6 +85,7 @@ actionCodes = { | @@ -85,6 +85,7 @@ actionCodes = { | ||
85 | Tower_startBattleRpc = 351, | 85 | Tower_startBattleRpc = 351, |
86 | Tower_endBattleRpc = 352, | 86 | Tower_endBattleRpc = 352, |
87 | Tower_rankRpc = 353, | 87 | Tower_rankRpc = 353, |
88 | + Tower_bugCountRpc = 354, | ||
88 | 89 | ||
89 | Car_makePotionRpc = 400, | 90 | Car_makePotionRpc = 400, |
90 | Car_equipUpRpc = 401, | 91 | Car_equipUpRpc = 401, |
src/actions/TowerAction.lua
@@ -55,6 +55,9 @@ function _M.startBattleRpc(agent, data) | @@ -55,6 +55,9 @@ function _M.startBattleRpc(agent, data) | ||
55 | 55 | ||
56 | --搞起来 | 56 | --搞起来 |
57 | towerInfo.c = curCount - 1 | 57 | towerInfo.c = curCount - 1 |
58 | + if curCount == globalCsv.tower_count_limit then --满的情况下的消耗了 恢复时间从当下开始 | ||
59 | + nextTime = skynet.timex() | ||
60 | + end | ||
58 | towerInfo.t = nextTime | 61 | towerInfo.t = nextTime |
59 | local key = tostring(math.random()) | 62 | local key = tostring(math.random()) |
60 | towerInfo.k = key | 63 | towerInfo.k = key |
@@ -95,6 +98,27 @@ function _M.endBattleRpc(agent, data) | @@ -95,6 +98,27 @@ function _M.endBattleRpc(agent, data) | ||
95 | return true | 98 | return true |
96 | end | 99 | end |
97 | 100 | ||
101 | +function _M.bugCountRpc(agent, data) | ||
102 | + local role = agent.role | ||
103 | + | ||
104 | + local towerInfo = role:getProperty("towerInfo") | ||
105 | + local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) | ||
106 | + local needCount = globalCsv.tower_count_limit - curCount | ||
107 | + if needCount > 0 then -- 补充 | ||
108 | + local cost = globalCsv.tower_chance_item:toNumMap() | ||
109 | + for k , v in pairs(cost) do | ||
110 | + cost[k] = v * needCount | ||
111 | + end | ||
112 | + if not role:checkItemEnough(cost) then return end | ||
113 | + role:costItems(cost) | ||
114 | + curCount = globalCsv.tower_count_limit | ||
115 | + end | ||
116 | + towerInfo.c = curCount | ||
117 | + towerInfo.t = nextTime | ||
118 | + role:updateProperty({field = "towerInfo", value = towerInfo}) | ||
119 | + SendPacket(actionCodes.Tower_bugCountRpc, '') | ||
120 | + return true | ||
121 | +end | ||
98 | 122 | ||
99 | function _M.rankRpc(agent , data) | 123 | function _M.rankRpc(agent , data) |
100 | local role = agent.role | 124 | local role = agent.role |