Commit 5dfc497874aa081fff5f73e3a2d30d32178dbb9f
1 parent
c384626d
好友完善
Showing
2 changed files
with
33 additions
and
27 deletions
Show diff stats
src/actions/FriendAction.lua
| @@ -136,6 +136,7 @@ function _M.applyRpc(agent, data) | @@ -136,6 +136,7 @@ function _M.applyRpc(agent, data) | ||
| 136 | red:hlen(FRIEND_KEY:format(roleId)) | 136 | red:hlen(FRIEND_KEY:format(roleId)) |
| 137 | red:hlen(FRIEND_KEY:format(objectId)) | 137 | red:hlen(FRIEND_KEY:format(objectId)) |
| 138 | end) | 138 | end) |
| 139 | + | ||
| 139 | -- 玩家id不存在 | 140 | -- 玩家id不存在 |
| 140 | if not result and redret[1] ~= 1 then | 141 | if not result and redret[1] ~= 1 then |
| 141 | result = 1 | 142 | result = 1 |
| @@ -155,7 +156,7 @@ function _M.applyRpc(agent, data) | @@ -155,7 +156,7 @@ function _M.applyRpc(agent, data) | ||
| 155 | end | 156 | end |
| 156 | 157 | ||
| 157 | -- 你把对方拉黑了 | 158 | -- 你把对方拉黑了 |
| 158 | - if not result and redret[4] == 1 then | 159 | + if not result and redret[5] == 1 then |
| 159 | result = 5 | 160 | result = 5 |
| 160 | end | 161 | end |
| 161 | 162 | ||
| @@ -280,7 +281,7 @@ function _M.handleApplyRpc(agent, data) | @@ -280,7 +281,7 @@ function _M.handleApplyRpc(agent, data) | ||
| 280 | redisproxy:del(FRIEND_APPLY_KEY:format(roleId)) | 281 | redisproxy:del(FRIEND_APPLY_KEY:format(roleId)) |
| 281 | elseif cmd == 3 then -- 一键同意 | 282 | elseif cmd == 3 then -- 一键同意 |
| 282 | local redret = redisproxy:pipelining(function(red) | 283 | local redret = redisproxy:pipelining(function(red) |
| 283 | - red:zrange(FRIEND_APPLY_KEY:format(roleId)) | 284 | + red:zrange(FRIEND_APPLY_KEY:format(roleId), 0, -1) |
| 284 | red:SMEMBERS(FRIEND_POINT:format(roleId)) | 285 | red:SMEMBERS(FRIEND_POINT:format(roleId)) |
| 285 | end) | 286 | end) |
| 286 | local allIds = redret[1] | 287 | local allIds = redret[1] |
| @@ -429,6 +430,8 @@ function _M.blockRpc(agent, data) | @@ -429,6 +430,8 @@ function _M.blockRpc(agent, data) | ||
| 429 | red:hdel(FRIEND_KEY:format(objectId), roleId) | 430 | red:hdel(FRIEND_KEY:format(objectId), roleId) |
| 430 | red:sadd(FRIEND_BLACK_KEY:format(roleId), objectId) | 431 | red:sadd(FRIEND_BLACK_KEY:format(roleId), objectId) |
| 431 | end) | 432 | end) |
| 433 | + rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId})) | ||
| 434 | + | ||
| 432 | end | 435 | end |
| 433 | elseif cmd == 2 then | 436 | elseif cmd == 2 then |
| 434 | redisproxy:SREM(FRIEND_BLACK_KEY:format(roleId), objectId) | 437 | redisproxy:SREM(FRIEND_BLACK_KEY:format(roleId), objectId) |
| @@ -456,6 +459,7 @@ function _M.blockListRpc(agent, data) | @@ -456,6 +459,7 @@ function _M.blockListRpc(agent, data) | ||
| 456 | 459 | ||
| 457 | })) | 460 | })) |
| 458 | end | 461 | end |
| 462 | + | ||
| 459 | SendPacket(actionCodes.Friend_blockListRpc, MsgPack.pack({list = blockList})) | 463 | SendPacket(actionCodes.Friend_blockListRpc, MsgPack.pack({list = blockList})) |
| 460 | return true | 464 | return true |
| 461 | end | 465 | end |
| @@ -588,38 +592,44 @@ function _M.randomRpc(agent, data) | @@ -588,38 +592,44 @@ function _M.randomRpc(agent, data) | ||
| 588 | 592 | ||
| 589 | local redret = redisproxy:pipelining(function (red) | 593 | local redret = redisproxy:pipelining(function (red) |
| 590 | red:hgetall(FRIEND_KEY:format(roleId)) | 594 | red:hgetall(FRIEND_KEY:format(roleId)) |
| 591 | - red:zrevrange(FRIEND_RECOMMEND, 0, globalCsv.friendRecommendLimit + globalCsv.friendListLimit) | 595 | + red:zrevrange(FRIEND_RECOMMEND, 0, globalCsv.friendRecommendLimit + globalCsv.friendListLimit + 10) --扩充10个 |
| 596 | + red:SMEMBERS(FRIEND_BLACK_KEY:format(roleId)) | ||
| 592 | end) | 597 | end) |
| 593 | - | ||
| 594 | - local friends = redret[1] | 598 | + local friends = {} |
| 599 | + for i = 1, #redret[1], 2 do | ||
| 600 | + friends[tonumber(redret[1][i])] = redret[1][i + 1] | ||
| 601 | + end | ||
| 602 | + | ||
| 595 | local newList = redret[2] | 603 | local newList = redret[2] |
| 604 | + local hadBlack = formatArray(redret[3]) | ||
| 605 | + | ||
| 596 | local needRoleIds = {} | 606 | local needRoleIds = {} |
| 597 | for _, newId in pairs(newList) do | 607 | for _, newId in pairs(newList) do |
| 598 | local numNewId = tonumber(newId) | 608 | local numNewId = tonumber(newId) |
| 599 | - if numNewId ~= roleId and not friends[newId] then | 609 | + if numNewId ~= roleId and not friends[numNewId] and not hadBlack[numNewId] then |
| 600 | table.insert(needRoleIds, numNewId) | 610 | table.insert(needRoleIds, numNewId) |
| 601 | end | 611 | end |
| 602 | end | 612 | end |
| 603 | 613 | ||
| 604 | local randomRoles = {} | 614 | local randomRoles = {} |
| 605 | - for _, objId in ipairs(needRoleIds) do | ||
| 606 | - local online, info = getRoleInfo(objId) | ||
| 607 | - local redret = redisproxy:pipelining(function (red) | 615 | + local redret = redisproxy:pipelining(function (red) |
| 616 | + for _, objId in ipairs(needRoleIds) do | ||
| 608 | red:zscore(FRIEND_APPLY_KEY:format(objId), roleId) | 617 | red:zscore(FRIEND_APPLY_KEY:format(objId), roleId) |
| 609 | - red:sismember(FRIEND_BLACK_KEY:format(roleId), objId) | ||
| 610 | - end) | ||
| 611 | - local hadApply = redret[1] and 1 or nil | ||
| 612 | - local inBlack = redret[2] == 1 and 1 or nil | ||
| 613 | - | ||
| 614 | - table.insert(randomRoles, table_merge({ | ||
| 615 | - roleId = objId, | ||
| 616 | - online = online, | ||
| 617 | - hadApply = hadApply, | ||
| 618 | - inBlack = inBlack, | ||
| 619 | - }, info, { | ||
| 620 | - | ||
| 621 | - })) | ||
| 622 | - if #randomRoles >= globalCsv.friendRecommendLimit then break end | 618 | + end |
| 619 | + end) | ||
| 620 | + for idx, objId in ipairs(needRoleIds) do | ||
| 621 | + if not redret[idx] then | ||
| 622 | + local online, info = getRoleInfo(objId) | ||
| 623 | + table.insert(randomRoles, table_merge({ | ||
| 624 | + roleId = objId, | ||
| 625 | + online = online, | ||
| 626 | + hadApply = hadApply, | ||
| 627 | + inBlack = inBlack, | ||
| 628 | + }, info, { | ||
| 629 | + | ||
| 630 | + })) | ||
| 631 | + if #randomRoles >= globalCsv.friendRecommendLimit then break end | ||
| 632 | + end | ||
| 623 | end | 633 | end |
| 624 | 634 | ||
| 625 | SendPacket(actionCodes.Friend_randomRpc, MsgPack.pack({list = randomRoles})) | 635 | SendPacket(actionCodes.Friend_randomRpc, MsgPack.pack({list = randomRoles})) |
src/models/RoleTask.lua
| @@ -394,10 +394,6 @@ function RoleTask.bind(Role) | @@ -394,10 +394,6 @@ function RoleTask.bind(Role) | ||
| 394 | end | 394 | end |
| 395 | nStatus = math.max(nStatus, n) | 395 | nStatus = math.max(nStatus, n) |
| 396 | end | 396 | end |
| 397 | - if achiveData.id == 35 then | ||
| 398 | - print(nStatus) | ||
| 399 | - end | ||
| 400 | - | ||
| 401 | if nStatus > curStatus then | 397 | if nStatus > curStatus then |
| 402 | table.insert(change, {type = "achiveT", field = tId, value = nStatus}) | 398 | table.insert(change, {type = "achiveT", field = tId, value = nStatus}) |
| 403 | end | 399 | end |