Commit 85083dba9b046b99c5406e9172ded2ca8ee2d621
1 parent
4cf74232
拉黑从申请列表移除
Showing
2 changed files
with
37 additions
and
22 deletions
Show diff stats
src/actions/FriendAction.lua
| @@ -428,6 +428,8 @@ function _M.blockRpc(agent, data) | @@ -428,6 +428,8 @@ function _M.blockRpc(agent, data) | ||
| 428 | redisproxy:pipelining(function (red) | 428 | redisproxy:pipelining(function (red) |
| 429 | red:hdel(FRIEND_KEY:format(roleId), objectId) | 429 | red:hdel(FRIEND_KEY:format(roleId), objectId) |
| 430 | red:hdel(FRIEND_KEY:format(objectId), roleId) | 430 | red:hdel(FRIEND_KEY:format(objectId), roleId) |
| 431 | + red:ZREM(FRIEND_APPLY_KEY:format(roleId), objectId) | ||
| 432 | + red:ZREM(FRIEND_APPLY_KEY:format(objectId), roleId) | ||
| 431 | red:sadd(FRIEND_BLACK_KEY:format(roleId), objectId) | 433 | red:sadd(FRIEND_BLACK_KEY:format(roleId), objectId) |
| 432 | end) | 434 | end) |
| 433 | rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId})) | 435 | rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId})) |
src/actions/PvpAction.lua
| @@ -13,6 +13,9 @@ local _pvpStartBattleCache = nil -- | @@ -13,6 +13,9 @@ local _pvpStartBattleCache = nil -- | ||
| 13 | 13 | ||
| 14 | local _pvpRecordInfoCache = {} -- 记录缓存 | 14 | local _pvpRecordInfoCache = {} -- 记录缓存 |
| 15 | local _pvpRecordBattleInfoCache = {} -- 记录战斗数据缓存 | 15 | local _pvpRecordBattleInfoCache = {} -- 记录战斗数据缓存 |
| 16 | +local _responseRecord = {} -- 复仇对单人1分钟间隔 | ||
| 17 | + | ||
| 18 | +local ResponseWaitTime = 60 | ||
| 16 | 19 | ||
| 17 | function _M.formatCommonRpc(agent , data) | 20 | function _M.formatCommonRpc(agent , data) |
| 18 | local role = agent.role | 21 | local role = agent.role |
| @@ -148,14 +151,21 @@ function _M.startBattleRpc(agent, data) | @@ -148,14 +151,21 @@ function _M.startBattleRpc(agent, data) | ||
| 148 | local idx = msg.idx | 151 | local idx = msg.idx |
| 149 | local revenge = msg.revenge | 152 | local revenge = msg.revenge |
| 150 | 153 | ||
| 151 | - local matchInfo | ||
| 152 | - | 154 | + local matchInfo, result, key, wait |
| 155 | + local now = skynet.timex() | ||
| 153 | if revenge then --复仇 | 156 | if revenge then --复仇 |
| 154 | - if not _pvpRecordInfoCache[idx] then return end | ||
| 155 | - if _pvpRecordInfoCache[idx].t == 1 then | ||
| 156 | - matchInfo = _pvpRecordBattleInfoCache[_pvpRecordInfoCache[idx].id] | ||
| 157 | - elseif _pvpRecordInfoCache[idx].t == 2 then | ||
| 158 | - matchInfo = {robot = _pvpRecordInfoCache[idx].id} | 157 | + local temp = _pvpRecordInfoCache[idx] |
| 158 | + if not temp then return end | ||
| 159 | + | ||
| 160 | + if not _responseRecord[temp.id] or now >= _responseRecord[temp.id] then | ||
| 161 | + if temp.t == 1 then | ||
| 162 | + matchInfo = _pvpRecordBattleInfoCache[temp.id] | ||
| 163 | + elseif temp.t == 2 then | ||
| 164 | + matchInfo = {robot = temp.id} | ||
| 165 | + end | ||
| 166 | + else | ||
| 167 | + result = 1 | ||
| 168 | + wait = _responseRecord[temp.id] - now | ||
| 159 | end | 169 | end |
| 160 | else --打正常 | 170 | else --打正常 |
| 161 | local pvpMC = role:getProperty("pvpMC") | 171 | local pvpMC = role:getProperty("pvpMC") |
| @@ -167,22 +177,24 @@ function _M.startBattleRpc(agent, data) | @@ -167,22 +177,24 @@ function _M.startBattleRpc(agent, data) | ||
| 167 | end | 177 | end |
| 168 | end | 178 | end |
| 169 | 179 | ||
| 170 | - if not matchInfo then return end | 180 | + if not result and not matchInfo then return end |
| 181 | + | ||
| 182 | + if not result then | ||
| 183 | + -- 次数扣一波 | ||
| 184 | + local pvpFree = role.dailyData:getProperty("pvpFree") | ||
| 185 | + if pvpFree >= globalCsv.pvp_battle_free_count then | ||
| 186 | + local cost = {[ItemId.PvpKey] = 1} | ||
| 187 | + if not role:checkItemEnough(cost) then return end | ||
| 188 | + role:costItems(cost) | ||
| 189 | + else | ||
| 190 | + role.dailyData:updateProperty({field = "pvpFree", delta = 1}) | ||
| 191 | + end | ||
| 171 | 192 | ||
| 172 | - -- 次数扣一波 | ||
| 173 | - local pvpFree = role.dailyData:getProperty("pvpFree") | ||
| 174 | - if pvpFree >= globalCsv.pvp_battle_free_count then | ||
| 175 | - local cost = {[ItemId.PvpKey] = 1} | ||
| 176 | - if not role:checkItemEnough(cost) then return end | ||
| 177 | - role:costItems(cost) | ||
| 178 | - else | ||
| 179 | - role.dailyData:updateProperty({field = "pvpFree", delta = 1}) | 193 | + key = tostring(math.random()) |
| 194 | + _pvpStartBattleCache = {idx = idx, key = key, revenge = revenge} | ||
| 180 | end | 195 | end |
| 181 | 196 | ||
| 182 | - local key = tostring(math.random()) | ||
| 183 | - _pvpStartBattleCache = {idx = idx, key = key, revenge = revenge} | ||
| 184 | - | ||
| 185 | - SendPacket(actionCodes.Pvp_startBattleRpc, MsgPack.pack({matchInfo = matchInfo, key = key})) | 197 | + SendPacket(actionCodes.Pvp_startBattleRpc, MsgPack.pack({matchInfo = matchInfo, key = key, result = result, wait = wait})) |
| 186 | return true | 198 | return true |
| 187 | end | 199 | end |
| 188 | 200 | ||
| @@ -199,11 +211,13 @@ function _M.endBattleRpc(agent, data) | @@ -199,11 +211,13 @@ function _M.endBattleRpc(agent, data) | ||
| 199 | end | 211 | end |
| 200 | 212 | ||
| 201 | local isWin = msg.starNum and msg.starNum > 0 | 213 | local isWin = msg.starNum and msg.starNum > 0 |
| 214 | + local now = skynet.timex() | ||
| 202 | 215 | ||
| 203 | local revenge = _pvpStartBattleCache.revenge | 216 | local revenge = _pvpStartBattleCache.revenge |
| 204 | local match | 217 | local match |
| 205 | if revenge then | 218 | if revenge then |
| 206 | match = _pvpRecordInfoCache[msg.idx] | 219 | match = _pvpRecordInfoCache[msg.idx] |
| 220 | + _responseRecord[match.id] = now + ResponseWaitTime -- 1分钟内不能再打 | ||
| 207 | else | 221 | else |
| 208 | local pvpMC = role:getProperty("pvpMC") | 222 | local pvpMC = role:getProperty("pvpMC") |
| 209 | match = pvpMC[msg.idx] | 223 | match = pvpMC[msg.idx] |
| @@ -221,7 +235,6 @@ function _M.endBattleRpc(agent, data) | @@ -221,7 +235,6 @@ function _M.endBattleRpc(agent, data) | ||
| 221 | _pvpStartBattleCache = nil | 235 | _pvpStartBattleCache = nil |
| 222 | 236 | ||
| 223 | -- 请求上传录像 | 237 | -- 请求上传录像 |
| 224 | - local now = skynet.timex() | ||
| 225 | local params = { | 238 | local params = { |
| 226 | ["roleid"] = roleId, | 239 | ["roleid"] = roleId, |
| 227 | ["key"] = "zhaolugame20191016", | 240 | ["key"] = "zhaolugame20191016", |
| @@ -326,7 +339,7 @@ function _M.recordListRpc(agent, data) | @@ -326,7 +339,7 @@ function _M.recordListRpc(agent, data) | ||
| 326 | local tempList = {} | 339 | local tempList = {} |
| 327 | for _, temp in ipairs(rlist) do | 340 | for _, temp in ipairs(rlist) do |
| 328 | local one = MsgPack.unpack(temp) | 341 | local one = MsgPack.unpack(temp) |
| 329 | - if now - one.time <= 24 * 3600 then -- 大于一天的弃之 | 342 | + if now - one.time <= globalCsv.pvp_record_keep_time then -- 大于一天的弃之 |
| 330 | table.insert(tempList, one) | 343 | table.insert(tempList, one) |
| 331 | end | 344 | end |
| 332 | end | 345 | end |