From 85083dba9b046b99c5406e9172ded2ca8ee2d621 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Wed, 27 Nov 2019 20:50:30 +0800 Subject: [PATCH] 拉黑从申请列表移除 --- src/actions/FriendAction.lua | 2 ++ src/actions/PvpAction.lua | 57 +++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/actions/FriendAction.lua b/src/actions/FriendAction.lua index d884636..5e1a79e 100644 --- a/src/actions/FriendAction.lua +++ b/src/actions/FriendAction.lua @@ -428,6 +428,8 @@ function _M.blockRpc(agent, data) redisproxy:pipelining(function (red) red:hdel(FRIEND_KEY:format(roleId), objectId) red:hdel(FRIEND_KEY:format(objectId), roleId) + red:ZREM(FRIEND_APPLY_KEY:format(roleId), objectId) + red:ZREM(FRIEND_APPLY_KEY:format(objectId), roleId) red:sadd(FRIEND_BLACK_KEY:format(roleId), objectId) end) rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId})) diff --git a/src/actions/PvpAction.lua b/src/actions/PvpAction.lua index 2281960..8ff1b62 100644 --- a/src/actions/PvpAction.lua +++ b/src/actions/PvpAction.lua @@ -13,6 +13,9 @@ local _pvpStartBattleCache = nil -- local _pvpRecordInfoCache = {} -- 记录缓存 local _pvpRecordBattleInfoCache = {} -- 记录战斗数据缓存 +local _responseRecord = {} -- 复仇对单人1分钟间隔 + +local ResponseWaitTime = 60 function _M.formatCommonRpc(agent , data) local role = agent.role @@ -148,14 +151,21 @@ function _M.startBattleRpc(agent, data) local idx = msg.idx local revenge = msg.revenge - local matchInfo - + local matchInfo, result, key, wait + local now = skynet.timex() if revenge then --复仇 - if not _pvpRecordInfoCache[idx] then return end - if _pvpRecordInfoCache[idx].t == 1 then - matchInfo = _pvpRecordBattleInfoCache[_pvpRecordInfoCache[idx].id] - elseif _pvpRecordInfoCache[idx].t == 2 then - matchInfo = {robot = _pvpRecordInfoCache[idx].id} + local temp = _pvpRecordInfoCache[idx] + if not temp then return end + + if not _responseRecord[temp.id] or now >= _responseRecord[temp.id] then + if temp.t == 1 then + matchInfo = _pvpRecordBattleInfoCache[temp.id] + elseif temp.t == 2 then + matchInfo = {robot = temp.id} + end + else + result = 1 + wait = _responseRecord[temp.id] - now end else --打正常 local pvpMC = role:getProperty("pvpMC") @@ -167,22 +177,24 @@ function _M.startBattleRpc(agent, data) end end - if not matchInfo then return end + if not result and not matchInfo then return end + + if not result then + -- 次数扣一波 + local pvpFree = role.dailyData:getProperty("pvpFree") + if pvpFree >= globalCsv.pvp_battle_free_count then + local cost = {[ItemId.PvpKey] = 1} + if not role:checkItemEnough(cost) then return end + role:costItems(cost) + else + role.dailyData:updateProperty({field = "pvpFree", delta = 1}) + end - -- 次数扣一波 - local pvpFree = role.dailyData:getProperty("pvpFree") - if pvpFree >= globalCsv.pvp_battle_free_count then - local cost = {[ItemId.PvpKey] = 1} - if not role:checkItemEnough(cost) then return end - role:costItems(cost) - else - role.dailyData:updateProperty({field = "pvpFree", delta = 1}) + key = tostring(math.random()) + _pvpStartBattleCache = {idx = idx, key = key, revenge = revenge} end - local key = tostring(math.random()) - _pvpStartBattleCache = {idx = idx, key = key, revenge = revenge} - - SendPacket(actionCodes.Pvp_startBattleRpc, MsgPack.pack({matchInfo = matchInfo, key = key})) + SendPacket(actionCodes.Pvp_startBattleRpc, MsgPack.pack({matchInfo = matchInfo, key = key, result = result, wait = wait})) return true end @@ -199,11 +211,13 @@ function _M.endBattleRpc(agent, data) end local isWin = msg.starNum and msg.starNum > 0 + local now = skynet.timex() local revenge = _pvpStartBattleCache.revenge local match if revenge then match = _pvpRecordInfoCache[msg.idx] + _responseRecord[match.id] = now + ResponseWaitTime -- 1分钟内不能再打 else local pvpMC = role:getProperty("pvpMC") match = pvpMC[msg.idx] @@ -221,7 +235,6 @@ function _M.endBattleRpc(agent, data) _pvpStartBattleCache = nil -- 请求上传录像 - local now = skynet.timex() local params = { ["roleid"] = roleId, ["key"] = "zhaolugame20191016", @@ -326,7 +339,7 @@ function _M.recordListRpc(agent, data) local tempList = {} for _, temp in ipairs(rlist) do local one = MsgPack.unpack(temp) - if now - one.time <= 24 * 3600 then -- 大于一天的弃之 + if now - one.time <= globalCsv.pvp_record_keep_time then -- 大于一天的弃之 table.insert(tempList, one) end end -- libgit2 0.21.2