Commit 5404ee7d8e233ab6dcba8ed5af167e66519b195b
1 parent
f60fc764
冒险挂机加速
Showing
2 changed files
with
28 additions
and
0 deletions
Show diff stats
src/ProtocolCode.lua
@@ -62,6 +62,7 @@ actionCodes = { | @@ -62,6 +62,7 @@ actionCodes = { | ||
62 | Adv_upArtifactRpc = 167, | 62 | Adv_upArtifactRpc = 167, |
63 | Adv_repayWheelSurfRpc = 168, | 63 | Adv_repayWheelSurfRpc = 168, |
64 | Adv_rankRpc = 169, | 64 | Adv_rankRpc = 169, |
65 | + Adv_quickHangRpc = 170, | ||
65 | 66 | ||
66 | Hero_loadInfos = 201, | 67 | Hero_loadInfos = 201, |
67 | Hero_updateProperty = 202, | 68 | Hero_updateProperty = 202, |
src/actions/AdvAction.lua
@@ -194,6 +194,33 @@ function _M.startHangRpc(agent, data) | @@ -194,6 +194,33 @@ function _M.startHangRpc(agent, data) | ||
194 | return true | 194 | return true |
195 | end | 195 | end |
196 | 196 | ||
197 | +function _M.quickHangRpc(agent, data) | ||
198 | + local role = agent.role | ||
199 | + local msg = MsgPack.unpack(data) | ||
200 | + | ||
201 | + local chapterId = msg.chapterId --关卡id | ||
202 | + | ||
203 | + local advHang = role:getProperty("advHang") | ||
204 | + local info = advHang[chapterId] | ||
205 | + if not info then return end | ||
206 | + | ||
207 | + local chapterData = csvdb["adv_chapterCsv"][chapterId] | ||
208 | + if not chapterData then return end | ||
209 | + | ||
210 | + local reward, isFull | ||
211 | + if skynet.timex() >= info.time then return end -- 已经完成了 | ||
212 | + | ||
213 | + local cost = math.ceil((info.time - skynet.timex()) / chapterData.idleTime * chapterData.accelerate) | ||
214 | + | ||
215 | + if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return end | ||
216 | + role:costItems({[ItemId.Diamond] = cost}) | ||
217 | + info.time = 0 | ||
218 | + role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) | ||
219 | + | ||
220 | + SendPacket(actionCodes.Adv_quickHangRpc, '') | ||
221 | + return true | ||
222 | +end | ||
223 | + | ||
197 | function _M.endHangRpc(agent, data) | 224 | function _M.endHangRpc(agent, data) |
198 | local role = agent.role | 225 | local role = agent.role |
199 | local msg = MsgPack.unpack(data) | 226 | local msg = MsgPack.unpack(data) |