diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index f30be68..c52b298 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -897,7 +897,7 @@ function _M.friendHelpRpc(agent, data) local result, award if not role.activity:isOpenById(actid, "FriendEnergy") then return 1 end - if oper < 0 or oper > 3 then return 2 end + if oper < 1 or oper > 3 then return 2 end local actCsv = csvdb["activity_ctrlCsv"][actid] local getLimit = actCsv.condition @@ -915,17 +915,7 @@ function _M.friendHelpRpc(agent, data) return ids end - if oper == 0 then - local ids = {} - local friendIds = getIds() - for id, _ in pairs(friendIds) do - if redisproxy:sismember(FRIEND_ENERGY:format(roleId), id) then - ids[id] = 1 - end - end - SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = 1, ids = ids})) - return true - elseif oper == 1 then -- 赠送好友能量 + if oper == 1 then -- 赠送好友能量 local objId = msg.roleId local gift = gifts[1] local ids = {} @@ -947,6 +937,7 @@ function _M.friendHelpRpc(agent, data) giveFE[friendId] = 1 award[gift[1]] = (award[gift[1]] or 0) + gift[2] red:sadd(FRIEND_ENERGY:format(friendId), roleId) + rpcRole(friendId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({actFriendGive = 1, roleId = roleId})) end end end) @@ -1002,6 +993,7 @@ function _M.friendHelpRpc(agent, data) giveFE[friendId] = 1 award[gift1[1]] = (award[gift1[1]] or 0) + gift1[2] red:sadd(FRIEND_ENERGY:format(friendId), roleId) + rpcRole(friendId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({actFriendGive = 1, roleId = roleId})) end if not getFE[friendId] and limit <= getLimit then @@ -1049,8 +1041,21 @@ function _M.friendHelpRpc(agent, data) rewards[level] = 1 actData.reward = rewards actData.magic = level + else + return 5 end + local ids = {} + local friendIds = getIds() + redisproxy:pipelining(function(red) + for id, _ in pairs(friendIds) do + if red:sismember(FRIEND_ENERGY:format(roleId), id) then + ids[id] = 1 + end + end + end) + actData.new = ids + local reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) role.activity:updateActData("FriendEnergy", actData) SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = result, reward = reward})) diff --git a/src/models/Activity.lua b/src/models/Activity.lua index a368e55..a3c15e3 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -751,9 +751,14 @@ activityFunc[Activity.ActivityType.ActShopGoods] = { activityFunc[Activity.ActivityType.FriendEnergy] = { ["init"] = function (self, actType, isCrossDay, notify, actId) - local data = {magic = 0, limit = 0, reward = {}, giveAE = {}, getAE = {}} + local data = {magic = 0, limit = 0, reward = {}, giveAE = {}, getAE = {}, new = self:getActFriendNew() self:updateActData(actType, data, not notify) end, + ["login"] = function (self, actType) + local curData = self:getActData(actType) or {} + actData.new = self:getActFriendNew() + self:updateActData(actType, actData, not notify) + end, ["crossDay"] = function(self, actType, notify) local actData = self:getActData(actType) actData.limit = 0 @@ -766,6 +771,26 @@ activityFunc[Activity.ActivityType.FriendEnergy] = { end } +function activity:getActFriendNew() + local roleId = self.owner:getProperty("id") + local friendIds = {} + local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId)) + for i = 1, #friends , 2 do + local objId = tonumber(friends[i]) + friendIds[objId] = 1 + end + + local ids = {} + redisproxy:pipelining(function(red) + for id, _ in pairs(friendIds) do + if red:sismember(FRIEND_ENERGY:format(roleId), id) then + ids[id] = 1 + end + end + end) + return ids +end + activityFunc[Activity.ActivityType.Crisis] = { ["check"] = function(self, actType, notify, atype, count) -- 检查 count = count or 1 diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index cc5e69b..daae0c0 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1515,7 +1515,6 @@ function RolePlugin.bind(Role) local breathes = { ["email"] = breath(120, "email"), -- email ["pvphg"] = breath(300, "pvphg"), -- 高级竞技场 奖励满的红点 - ["actfriend"] = breath(180, "actfriend"), -- 好友能量助力活动 } function Role:checkNewEvent(now) if now - self:getProperty("ltime") < 5 then @@ -1578,21 +1577,6 @@ function RolePlugin.bind(Role) return true end end - - checks["actfriend"] = function () - local ids = {} - local roleId = self:getProperty("id") - local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId)) - for i = 1, #friends , 2 do - local objId = tonumber(friends[i]) - ids[objId] = 1 - end - for friendId, _ in pairs(ids) do - if redisproxy:sismember(FRIEND_ENERGY:format(roleId), friendId) then - return true - end - end - end local events = {} for name, breath in pairs(breathes) do -- libgit2 0.21.2