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 | 897 | local result, award |
| 898 | 898 | |
| 899 | 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 | 902 | local actCsv = csvdb["activity_ctrlCsv"][actid] |
| 903 | 903 | local getLimit = actCsv.condition |
| ... | ... | @@ -915,17 +915,7 @@ function _M.friendHelpRpc(agent, data) |
| 915 | 915 | return ids |
| 916 | 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 | 919 | local objId = msg.roleId |
| 930 | 920 | local gift = gifts[1] |
| 931 | 921 | local ids = {} |
| ... | ... | @@ -947,6 +937,7 @@ function _M.friendHelpRpc(agent, data) |
| 947 | 937 | giveFE[friendId] = 1 |
| 948 | 938 | award[gift[1]] = (award[gift[1]] or 0) + gift[2] |
| 949 | 939 | red:sadd(FRIEND_ENERGY:format(friendId), roleId) |
| 940 | + rpcRole(friendId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({actFriendGive = 1, roleId = roleId})) | |
| 950 | 941 | end |
| 951 | 942 | end |
| 952 | 943 | end) |
| ... | ... | @@ -1002,6 +993,7 @@ function _M.friendHelpRpc(agent, data) |
| 1002 | 993 | giveFE[friendId] = 1 |
| 1003 | 994 | award[gift1[1]] = (award[gift1[1]] or 0) + gift1[2] |
| 1004 | 995 | red:sadd(FRIEND_ENERGY:format(friendId), roleId) |
| 996 | + rpcRole(friendId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({actFriendGive = 1, roleId = roleId})) | |
| 1005 | 997 | end |
| 1006 | 998 | |
| 1007 | 999 | if not getFE[friendId] and limit <= getLimit then |
| ... | ... | @@ -1049,8 +1041,21 @@ function _M.friendHelpRpc(agent, data) |
| 1049 | 1041 | rewards[level] = 1 |
| 1050 | 1042 | actData.reward = rewards |
| 1051 | 1043 | actData.magic = level |
| 1044 | + else | |
| 1045 | + return 5 | |
| 1052 | 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 | 1059 | local reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) |
| 1055 | 1060 | role.activity:updateActData("FriendEnergy", actData) |
| 1056 | 1061 | SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = result, reward = reward})) | ... | ... |
src/models/Activity.lua
| ... | ... | @@ -751,9 +751,14 @@ activityFunc[Activity.ActivityType.ActShopGoods] = { |
| 751 | 751 | |
| 752 | 752 | activityFunc[Activity.ActivityType.FriendEnergy] = { |
| 753 | 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 | 755 | self:updateActData(actType, data, not notify) |
| 756 | 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 | 762 | ["crossDay"] = function(self, actType, notify) |
| 758 | 763 | local actData = self:getActData(actType) |
| 759 | 764 | actData.limit = 0 |
| ... | ... | @@ -766,6 +771,26 @@ activityFunc[Activity.ActivityType.FriendEnergy] = { |
| 766 | 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 | 794 | activityFunc[Activity.ActivityType.Crisis] = { |
| 770 | 795 | ["check"] = function(self, actType, notify, atype, count) -- 检查 |
| 771 | 796 | count = count or 1 | ... | ... |
src/models/RolePlugin.lua
| ... | ... | @@ -1515,7 +1515,6 @@ function RolePlugin.bind(Role) |
| 1515 | 1515 | local breathes = { |
| 1516 | 1516 | ["email"] = breath(120, "email"), -- email |
| 1517 | 1517 | ["pvphg"] = breath(300, "pvphg"), -- 高级竞技场 奖励满的红点 |
| 1518 | - ["actfriend"] = breath(180, "actfriend"), -- 好友能量助力活动 | |
| 1519 | 1518 | } |
| 1520 | 1519 | function Role:checkNewEvent(now) |
| 1521 | 1520 | if now - self:getProperty("ltime") < 5 then |
| ... | ... | @@ -1578,21 +1577,6 @@ function RolePlugin.bind(Role) |
| 1578 | 1577 | return true |
| 1579 | 1578 | end |
| 1580 | 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 | 1581 | local events = {} |
| 1598 | 1582 | for name, breath in pairs(breathes) do | ... | ... |