Commit 81a00cac4be0105278104ca7605542372860e80a
1 parent
12f7b52c
爬塔买满次数
Showing
2 changed files
with
25 additions
and
0 deletions
Show diff stats
src/ProtocolCode.lua
src/actions/TowerAction.lua
... | ... | @@ -55,6 +55,9 @@ function _M.startBattleRpc(agent, data) |
55 | 55 | |
56 | 56 | --搞起来 |
57 | 57 | towerInfo.c = curCount - 1 |
58 | + if curCount == globalCsv.tower_count_limit then --满的情况下的消耗了 恢复时间从当下开始 | |
59 | + nextTime = skynet.timex() | |
60 | + end | |
58 | 61 | towerInfo.t = nextTime |
59 | 62 | local key = tostring(math.random()) |
60 | 63 | towerInfo.k = key |
... | ... | @@ -95,6 +98,27 @@ function _M.endBattleRpc(agent, data) |
95 | 98 | return true |
96 | 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 | 123 | function _M.rankRpc(agent , data) |
100 | 124 | local role = agent.role | ... | ... |