Commit 5404ee7d8e233ab6dcba8ed5af167e66519b195b
1 parent
f60fc764
冒险挂机加速
Showing
2 changed files
with
28 additions
and
0 deletions
Show diff stats
src/ProtocolCode.lua
src/actions/AdvAction.lua
| ... | ... | @@ -194,6 +194,33 @@ function _M.startHangRpc(agent, data) |
| 194 | 194 | return true |
| 195 | 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 | 224 | function _M.endHangRpc(agent, data) |
| 198 | 225 | local role = agent.role |
| 199 | 226 | local msg = MsgPack.unpack(data) | ... | ... |