Commit 0886d05ad5f6662261eeef2d6a717ee9961aa99f
1 parent
091912ed
修改联动好友赠送获得的红点记录和通知
Showing
3 changed files
with
43 additions
and
29 deletions
Show diff stats
src/actions/ActivityAction.lua
@@ -897,7 +897,7 @@ function _M.friendHelpRpc(agent, data) | @@ -897,7 +897,7 @@ function _M.friendHelpRpc(agent, data) | ||
897 | local result, award | 897 | local result, award |
898 | 898 | ||
899 | if not role.activity:isOpenById(actid, "FriendEnergy") then return 1 end | 899 | if not role.activity:isOpenById(actid, "FriendEnergy") then return 1 end |
900 | - if oper < 0 or oper > 3 then return 2 end | 900 | + if oper < 1 or oper > 3 then return 2 end |
901 | 901 | ||
902 | local actCsv = csvdb["activity_ctrlCsv"][actid] | 902 | local actCsv = csvdb["activity_ctrlCsv"][actid] |
903 | local getLimit = actCsv.condition | 903 | local getLimit = actCsv.condition |
@@ -915,17 +915,7 @@ function _M.friendHelpRpc(agent, data) | @@ -915,17 +915,7 @@ function _M.friendHelpRpc(agent, data) | ||
915 | return ids | 915 | return ids |
916 | end | 916 | end |
917 | 917 | ||
918 | - if oper == 0 then | ||
919 | - local ids = {} | ||
920 | - local friendIds = getIds() | ||
921 | - for id, _ in pairs(friendIds) do | ||
922 | - if redisproxy:sismember(FRIEND_ENERGY:format(roleId), id) then | ||
923 | - ids[id] = 1 | ||
924 | - end | ||
925 | - end | ||
926 | - SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = 1, ids = ids})) | ||
927 | - return true | ||
928 | - elseif oper == 1 then -- 赠送好友能量 | 918 | + if oper == 1 then -- 赠送好友能量 |
929 | local objId = msg.roleId | 919 | local objId = msg.roleId |
930 | local gift = gifts[1] | 920 | local gift = gifts[1] |
931 | local ids = {} | 921 | local ids = {} |
@@ -947,6 +937,7 @@ function _M.friendHelpRpc(agent, data) | @@ -947,6 +937,7 @@ function _M.friendHelpRpc(agent, data) | ||
947 | giveFE[friendId] = 1 | 937 | giveFE[friendId] = 1 |
948 | award[gift[1]] = (award[gift[1]] or 0) + gift[2] | 938 | award[gift[1]] = (award[gift[1]] or 0) + gift[2] |
949 | red:sadd(FRIEND_ENERGY:format(friendId), roleId) | 939 | red:sadd(FRIEND_ENERGY:format(friendId), roleId) |
940 | + rpcRole(friendId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({actFriendGive = 1, roleId = roleId})) | ||
950 | end | 941 | end |
951 | end | 942 | end |
952 | end) | 943 | end) |
@@ -1002,6 +993,7 @@ function _M.friendHelpRpc(agent, data) | @@ -1002,6 +993,7 @@ function _M.friendHelpRpc(agent, data) | ||
1002 | giveFE[friendId] = 1 | 993 | giveFE[friendId] = 1 |
1003 | award[gift1[1]] = (award[gift1[1]] or 0) + gift1[2] | 994 | award[gift1[1]] = (award[gift1[1]] or 0) + gift1[2] |
1004 | red:sadd(FRIEND_ENERGY:format(friendId), roleId) | 995 | red:sadd(FRIEND_ENERGY:format(friendId), roleId) |
996 | + rpcRole(friendId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({actFriendGive = 1, roleId = roleId})) | ||
1005 | end | 997 | end |
1006 | 998 | ||
1007 | if not getFE[friendId] and limit <= getLimit then | 999 | if not getFE[friendId] and limit <= getLimit then |
@@ -1049,8 +1041,21 @@ function _M.friendHelpRpc(agent, data) | @@ -1049,8 +1041,21 @@ function _M.friendHelpRpc(agent, data) | ||
1049 | rewards[level] = 1 | 1041 | rewards[level] = 1 |
1050 | actData.reward = rewards | 1042 | actData.reward = rewards |
1051 | actData.magic = level | 1043 | actData.magic = level |
1044 | + else | ||
1045 | + return 5 | ||
1052 | end | 1046 | end |
1053 | 1047 | ||
1048 | + local ids = {} | ||
1049 | + local friendIds = getIds() | ||
1050 | + redisproxy:pipelining(function(red) | ||
1051 | + for id, _ in pairs(friendIds) do | ||
1052 | + if red:sismember(FRIEND_ENERGY:format(roleId), id) then | ||
1053 | + ids[id] = 1 | ||
1054 | + end | ||
1055 | + end | ||
1056 | + end) | ||
1057 | + actData.new = ids | ||
1058 | + | ||
1054 | local reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) | 1059 | local reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) |
1055 | role.activity:updateActData("FriendEnergy", actData) | 1060 | role.activity:updateActData("FriendEnergy", actData) |
1056 | SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = result, reward = reward})) | 1061 | SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = result, reward = reward})) |
src/models/Activity.lua
@@ -751,9 +751,14 @@ activityFunc[Activity.ActivityType.ActShopGoods] = { | @@ -751,9 +751,14 @@ activityFunc[Activity.ActivityType.ActShopGoods] = { | ||
751 | 751 | ||
752 | activityFunc[Activity.ActivityType.FriendEnergy] = { | 752 | activityFunc[Activity.ActivityType.FriendEnergy] = { |
753 | ["init"] = function (self, actType, isCrossDay, notify, actId) | 753 | ["init"] = function (self, actType, isCrossDay, notify, actId) |
754 | - local data = {magic = 0, limit = 0, reward = {}, giveAE = {}, getAE = {}} | 754 | + local data = {magic = 0, limit = 0, reward = {}, giveAE = {}, getAE = {}, new = self:getActFriendNew() |
755 | self:updateActData(actType, data, not notify) | 755 | self:updateActData(actType, data, not notify) |
756 | end, | 756 | end, |
757 | + ["login"] = function (self, actType) | ||
758 | + local curData = self:getActData(actType) or {} | ||
759 | + actData.new = self:getActFriendNew() | ||
760 | + self:updateActData(actType, actData, not notify) | ||
761 | + end, | ||
757 | ["crossDay"] = function(self, actType, notify) | 762 | ["crossDay"] = function(self, actType, notify) |
758 | local actData = self:getActData(actType) | 763 | local actData = self:getActData(actType) |
759 | actData.limit = 0 | 764 | actData.limit = 0 |
@@ -766,6 +771,26 @@ activityFunc[Activity.ActivityType.FriendEnergy] = { | @@ -766,6 +771,26 @@ activityFunc[Activity.ActivityType.FriendEnergy] = { | ||
766 | end | 771 | end |
767 | } | 772 | } |
768 | 773 | ||
774 | +function activity:getActFriendNew() | ||
775 | + local roleId = self.owner:getProperty("id") | ||
776 | + local friendIds = {} | ||
777 | + local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId)) | ||
778 | + for i = 1, #friends , 2 do | ||
779 | + local objId = tonumber(friends[i]) | ||
780 | + friendIds[objId] = 1 | ||
781 | + end | ||
782 | + | ||
783 | + local ids = {} | ||
784 | + redisproxy:pipelining(function(red) | ||
785 | + for id, _ in pairs(friendIds) do | ||
786 | + if red:sismember(FRIEND_ENERGY:format(roleId), id) then | ||
787 | + ids[id] = 1 | ||
788 | + end | ||
789 | + end | ||
790 | + end) | ||
791 | + return ids | ||
792 | +end | ||
793 | + | ||
769 | activityFunc[Activity.ActivityType.Crisis] = { | 794 | activityFunc[Activity.ActivityType.Crisis] = { |
770 | ["check"] = function(self, actType, notify, atype, count) -- 检查 | 795 | ["check"] = function(self, actType, notify, atype, count) -- 检查 |
771 | count = count or 1 | 796 | count = count or 1 |
src/models/RolePlugin.lua
@@ -1515,7 +1515,6 @@ function RolePlugin.bind(Role) | @@ -1515,7 +1515,6 @@ function RolePlugin.bind(Role) | ||
1515 | local breathes = { | 1515 | local breathes = { |
1516 | ["email"] = breath(120, "email"), -- email | 1516 | ["email"] = breath(120, "email"), -- email |
1517 | ["pvphg"] = breath(300, "pvphg"), -- 高级竞技场 奖励满的红点 | 1517 | ["pvphg"] = breath(300, "pvphg"), -- 高级竞技场 奖励满的红点 |
1518 | - ["actfriend"] = breath(180, "actfriend"), -- 好友能量助力活动 | ||
1519 | } | 1518 | } |
1520 | function Role:checkNewEvent(now) | 1519 | function Role:checkNewEvent(now) |
1521 | if now - self:getProperty("ltime") < 5 then | 1520 | if now - self:getProperty("ltime") < 5 then |
@@ -1578,21 +1577,6 @@ function RolePlugin.bind(Role) | @@ -1578,21 +1577,6 @@ function RolePlugin.bind(Role) | ||
1578 | return true | 1577 | return true |
1579 | end | 1578 | end |
1580 | end | 1579 | end |
1581 | - | ||
1582 | - checks["actfriend"] = function () | ||
1583 | - local ids = {} | ||
1584 | - local roleId = self:getProperty("id") | ||
1585 | - local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId)) | ||
1586 | - for i = 1, #friends , 2 do | ||
1587 | - local objId = tonumber(friends[i]) | ||
1588 | - ids[objId] = 1 | ||
1589 | - end | ||
1590 | - for friendId, _ in pairs(ids) do | ||
1591 | - if redisproxy:sismember(FRIEND_ENERGY:format(roleId), friendId) then | ||
1592 | - return true | ||
1593 | - end | ||
1594 | - end | ||
1595 | - end | ||
1596 | 1580 | ||
1597 | local events = {} | 1581 | local events = {} |
1598 | for name, breath in pairs(breathes) do | 1582 | for name, breath in pairs(breathes) do |