Commit da20e3846eeb494e3b599ba8dde71fa5bd7e4996
1 parent
01ff9b4b
feat: 一番赏 特殊赏 通知
1. 服务器主动通知 Capsule_notifyChange = 856 2. 客户端主动获获取 Capsule_specialRewardRpc = 857 3. 客户端消除特殊赏通知指令 Capsule_clearSpecialNtyRpc = 862 备注:客户端收到特殊赏的奖励后,都需要消除特殊赏通知。不然特殊赏通知会一直存在。
Showing
6 changed files
with
106 additions
and
15 deletions
Show diff stats
src/ProtocolCode.lua
| @@ -281,11 +281,12 @@ actionCodes = { | @@ -281,11 +281,12 @@ actionCodes = { | ||
| 281 | Capsule_drawRpc = 854, --抽扭蛋机 | 281 | Capsule_drawRpc = 854, --抽扭蛋机 |
| 282 | --Capsule_switchRoomRpc = 855, --切换扭蛋机房间 | 282 | --Capsule_switchRoomRpc = 855, --切换扭蛋机房间 |
| 283 | Capsule_notifyChange = 856, -- 通知信息变动 | 283 | Capsule_notifyChange = 856, -- 通知信息变动 |
| 284 | - Capsule_payReward = 857, -- 特殊赏 奖励通知 | 284 | + Capsule_specialRewardRpc = 857, -- 获取 未领取特殊赏通知 主动 |
| 285 | Capsule_exitRpc = 858, -- 退出 | 285 | Capsule_exitRpc = 858, -- 退出 |
| 286 | Capsule_getDataRpc = 859, --获取扭蛋机信息 | 286 | Capsule_getDataRpc = 859, --获取扭蛋机信息 |
| 287 | - Capsule_convertCapsuleRpc = 890, --兑换消耗票 | ||
| 288 | - Capsule_pageRecordRpc = 891, --抽奖记录分页查询 | 287 | + Capsule_convertCapsuleRpc = 860, --兑换消耗票 |
| 288 | + Capsule_pageRecordRpc = 861, --抽奖记录分页查询 | ||
| 289 | + Capsule_clearSpecialNtyRpc = 862, --消除特殊赏通知 | ||
| 289 | } | 290 | } |
| 290 | 291 | ||
| 291 | rpcResponseBegin = 10000 | 292 | rpcResponseBegin = 10000 |
src/actions/CapsuleAction.lua
| @@ -51,7 +51,7 @@ function _M.joinRpc(agent, data) | @@ -51,7 +51,7 @@ function _M.joinRpc(agent, data) | ||
| 51 | if typ == 1 then | 51 | if typ == 1 then |
| 52 | ret = skynet.call(agent.capsule_serv, "lua", "join", roleId, capsuleId) | 52 | ret = skynet.call(agent.capsule_serv, "lua", "join", roleId, capsuleId) |
| 53 | elseif typ == 0 then | 53 | elseif typ == 0 then |
| 54 | - ret = role:joinCapsule() | 54 | + ret = role:joinCapsule(roleId, capsuleId) |
| 55 | end | 55 | end |
| 56 | SendPacket(actionCodes.Capsule_joinRpc, MsgPack.pack(ret)) | 56 | SendPacket(actionCodes.Capsule_joinRpc, MsgPack.pack(ret)) |
| 57 | return true | 57 | return true |
| @@ -143,7 +143,6 @@ function _M.drawRpc(agent, data) | @@ -143,7 +143,6 @@ function _M.drawRpc(agent, data) | ||
| 143 | if drawReward["reward"] and next(drawReward["reward"]) then | 143 | if drawReward["reward"] and next(drawReward["reward"]) then |
| 144 | _, change = role:award(drawReward["reward"], {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}}) | 144 | _, change = role:award(drawReward["reward"], {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}}) |
| 145 | drawReward["capsule"] = capsule | 145 | drawReward["capsule"] = capsule |
| 146 | - dump(drawReward) | ||
| 147 | SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack(drawReward)) | 146 | SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack(drawReward)) |
| 148 | else | 147 | else |
| 149 | return ret | 148 | return ret |
| @@ -162,7 +161,7 @@ function _M.getDataRpc(agent, data) | @@ -162,7 +161,7 @@ function _M.getDataRpc(agent, data) | ||
| 162 | if typ == 1 then | 161 | if typ == 1 then |
| 163 | capsule = skynet.call(agent.capsule_serv, "lua", "capsule_data", roleId, capsuleId) | 162 | capsule = skynet.call(agent.capsule_serv, "lua", "capsule_data", roleId, capsuleId) |
| 164 | else | 163 | else |
| 165 | - capsule = role:getCapsuleData(capsuleId) | 164 | + capsule = role:getCapsuleData(roleId, capsuleId) |
| 166 | end | 165 | end |
| 167 | if not capsule then return 1 end | 166 | if not capsule then return 1 end |
| 168 | 167 | ||
| @@ -213,4 +212,41 @@ function _M.pageRecordRpc(agent, data) | @@ -213,4 +212,41 @@ function _M.pageRecordRpc(agent, data) | ||
| 213 | return true | 212 | return true |
| 214 | end | 213 | end |
| 215 | 214 | ||
| 215 | +function _M.specialRewardRpc(agent, data) | ||
| 216 | + local role = agent.role | ||
| 217 | + local msg = MsgPack.unpack(data) | ||
| 218 | + local capsuleId = msg.capsule_id | ||
| 219 | + local typ = msg.typ --0=独享,1= 公开 | ||
| 220 | + local roleId = role:getProperty("id") | ||
| 221 | + | ||
| 222 | + local ret | ||
| 223 | + if typ == 1 then | ||
| 224 | + ret = skynet.call(agent.capsule_serv, "lua", "get_special_nty", roleId, capsuleId) | ||
| 225 | + else | ||
| 226 | + ret = role:getSpecialNotify(roleId, capsuleId) | ||
| 227 | + end | ||
| 228 | + if not ret or not next(ret) then return 1 end | ||
| 229 | + | ||
| 230 | + SendPacket(actionCodes.Capsule_specialRewardRpc, MsgPack.pack({special= ret})) | ||
| 231 | + return true | ||
| 232 | +end | ||
| 233 | + | ||
| 234 | +function _M.clearSpecialNtyRpc(agent, data) | ||
| 235 | + local role = agent.role | ||
| 236 | + local msg = MsgPack.unpack(data) | ||
| 237 | + local capsuleId = msg.capsule_id | ||
| 238 | + local typ = msg.typ --0=独享,1= 公开 | ||
| 239 | + local good_ids = msg.good_ids | ||
| 240 | + local roleId = role:getProperty("id") | ||
| 241 | + | ||
| 242 | + local ret | ||
| 243 | + if typ == 1 then | ||
| 244 | + ret = skynet.call(agent.capsule_serv, "lua", "clear_special_nty", roleId, capsuleId, good_ids) | ||
| 245 | + end | ||
| 246 | + if not ret or not next(ret) then return 1 end | ||
| 247 | + | ||
| 248 | + SendPacket(actionCodes.Capsule_clearSpecialNtyRpc, MsgPack.pack({})) | ||
| 249 | + return true | ||
| 250 | +end | ||
| 251 | + | ||
| 216 | return _M | 252 | return _M |
| 217 | \ No newline at end of file | 253 | \ No newline at end of file |
src/models/Capsule.lua
| @@ -669,8 +669,7 @@ function Capsule:checkIncentive(roleId, name, now) | @@ -669,8 +669,7 @@ function Capsule:checkIncentive(roleId, name, now) | ||
| 669 | incentiveRecord[roleId] = incentiveByRole | 669 | incentiveRecord[roleId] = incentiveByRole |
| 670 | self:setProperty("incentiveRecord", incentiveRecord) | 670 | self:setProperty("incentiveRecord", incentiveRecord) |
| 671 | 671 | ||
| 672 | - --TODO 先屏蔽 | ||
| 673 | - return {} | 672 | + return incentiveByRole |
| 674 | end | 673 | end |
| 675 | 674 | ||
| 676 | local rewardCollect = function(reward, goods) | 675 | local rewardCollect = function(reward, goods) |
| @@ -892,6 +891,40 @@ function Capsule:pageRecord(up, idx) | @@ -892,6 +891,40 @@ function Capsule:pageRecord(up, idx) | ||
| 892 | return tmpRecord | 891 | return tmpRecord |
| 893 | end | 892 | end |
| 894 | 893 | ||
| 894 | +--检查是否有未领取奖励的通知 | ||
| 895 | +function Capsule:getSpecialNotify(roleId) | ||
| 896 | + local specialsRecord = self:getProperty("specialsRecord") or {} | ||
| 897 | + local specialsRecordByRole = specialsRecord[roleId] | ||
| 898 | + if not specialsRecordByRole then return nil end | ||
| 899 | + | ||
| 900 | + local tmp = {} | ||
| 901 | + for good_id, good in pairs(specialsRecordByRole) do | ||
| 902 | + if not good.nty or good.nty == 0 then | ||
| 903 | + tmp[good_id] = good | ||
| 904 | + end | ||
| 905 | + end | ||
| 906 | + | ||
| 907 | + specialsRecord[roleId] = specialsRecordByRole | ||
| 908 | + self:setProperty("specialsRecord", specialsRecord) | ||
| 909 | + | ||
| 910 | + return tmp | ||
| 911 | +end | ||
| 912 | + | ||
| 913 | +function Capsule:clearSpecialNty(roleId, good_ids) | ||
| 914 | + local specialsRecord = self:getProperty("specialsRecord") or {} | ||
| 915 | + local specialsRecordByRole = specialsRecord[roleId] | ||
| 916 | + if not specialsRecordByRole then return nil end | ||
| 917 | + | ||
| 918 | + for _, good_id in ipairs(good_ids) do | ||
| 919 | + if specialsRecordByRole[good_id] then | ||
| 920 | + specialsRecordByRole[good_id].nty = 1 | ||
| 921 | + end | ||
| 922 | + end | ||
| 923 | + | ||
| 924 | + specialsRecord[roleId] = specialsRecordByRole | ||
| 925 | + self:setProperty("specialsRecord", specialsRecord) | ||
| 926 | +end | ||
| 927 | + | ||
| 895 | 928 | ||
| 896 | function Capsule:data(roleId) | 929 | function Capsule:data(roleId) |
| 897 | return { | 930 | return { |
src/models/RoleCross.lua
| @@ -211,7 +211,6 @@ RoleCross.bind = function (Role) | @@ -211,7 +211,6 @@ RoleCross.bind = function (Role) | ||
| 211 | end | 211 | end |
| 212 | 212 | ||
| 213 | function Role:paySpecialReward(roleId, notify) | 213 | function Role:paySpecialReward(roleId, notify) |
| 214 | - dump(notify) | ||
| 215 | if notify and next(notify) then | 214 | if notify and next(notify) then |
| 216 | local reward = {} | 215 | local reward = {} |
| 217 | for key, val in pairs(notify) do | 216 | for key, val in pairs(notify) do |
| @@ -221,6 +220,7 @@ RoleCross.bind = function (Role) | @@ -221,6 +220,7 @@ RoleCross.bind = function (Role) | ||
| 221 | 220 | ||
| 222 | end | 221 | end |
| 223 | self:award(reward, {log = {desc = "CapsuleReward", int1=roleId}}) | 222 | self:award(reward, {log = {desc = "CapsuleReward", int1=roleId}}) |
| 223 | + SendPacket(actionCodes.Capsule_notifyChange, MsgPack.pack({special = notify})) | ||
| 224 | end | 224 | end |
| 225 | end | 225 | end |
| 226 | 226 |
src/models/RolePlugin.lua
| @@ -2090,7 +2090,7 @@ function RolePlugin.bind(Role) | @@ -2090,7 +2090,7 @@ function RolePlugin.bind(Role) | ||
| 2090 | local emailSync = math.max(emailSync + 1, globalEmail - EMAIL_LIMIT + 1) | 2090 | local emailSync = math.max(emailSync + 1, globalEmail - EMAIL_LIMIT + 1) |
| 2091 | local redret = redisproxy:pipelining(function (red) | 2091 | local redret = redisproxy:pipelining(function (red) |
| 2092 | for id = emailSync, globalEmail do | 2092 | for id = emailSync, globalEmail do |
| 2093 | - red:hgetall(string.format("globalEmail:%s", id)) | 2093 | + red:hgetall(string.format("globalEmail:%s", id)) |
| 2094 | end | 2094 | end |
| 2095 | end) | 2095 | end) |
| 2096 | for _, data in ipairs(redret) do | 2096 | for _, data in ipairs(redret) do |
| @@ -3174,11 +3174,11 @@ function RolePlugin.bind(Role) | @@ -3174,11 +3174,11 @@ function RolePlugin.bind(Role) | ||
| 3174 | return ret, drawReward, capsule:data(roleId) | 3174 | return ret, drawReward, capsule:data(roleId) |
| 3175 | end | 3175 | end |
| 3176 | 3176 | ||
| 3177 | - function Role:joinCapsule(capsuleId) | 3177 | + function Role:joinCapsule(roleId, capsuleId) |
| 3178 | local capsule = self.capsules[capsuleId] | 3178 | local capsule = self.capsules[capsuleId] |
| 3179 | if not capsule then return nil end | 3179 | if not capsule then return nil end |
| 3180 | 3180 | ||
| 3181 | - return capsule:data() | 3181 | + return capsule:data(roleId) |
| 3182 | end | 3182 | end |
| 3183 | 3183 | ||
| 3184 | function Role:checkCapsule(now) | 3184 | function Role:checkCapsule(now) |
| @@ -3197,11 +3197,11 @@ function RolePlugin.bind(Role) | @@ -3197,11 +3197,11 @@ function RolePlugin.bind(Role) | ||
| 3197 | return capsule:getGoodsAmount(), capsule:getProperty("token") | 3197 | return capsule:getGoodsAmount(), capsule:getProperty("token") |
| 3198 | end | 3198 | end |
| 3199 | 3199 | ||
| 3200 | - function Role:getCapsuleData(capsuleId) | 3200 | + function Role:getCapsuleData(roleId, capsuleId) |
| 3201 | local capsule = self.capsules[capsuleId] | 3201 | local capsule = self.capsules[capsuleId] |
| 3202 | if not capsule then return nil end | 3202 | if not capsule then return nil end |
| 3203 | 3203 | ||
| 3204 | - return capsule:data() | 3204 | + return capsule:data(roleId) |
| 3205 | end | 3205 | end |
| 3206 | 3206 | ||
| 3207 | function Role:resetCapsule() | 3207 | function Role:resetCapsule() |
| @@ -3234,6 +3234,13 @@ function RolePlugin.bind(Role) | @@ -3234,6 +3234,13 @@ function RolePlugin.bind(Role) | ||
| 3234 | 3234 | ||
| 3235 | return capsule:pageRecord(up, idx) | 3235 | return capsule:pageRecord(up, idx) |
| 3236 | end | 3236 | end |
| 3237 | + | ||
| 3238 | + function Role:getSpecialNotify(roleId, capsuleId) | ||
| 3239 | + local capsule = self.capsules[capsuleId] | ||
| 3240 | + if not capsule then return nil end | ||
| 3241 | + | ||
| 3242 | + return capsule:getSpecialNotify(roleId) | ||
| 3243 | + end | ||
| 3237 | end | 3244 | end |
| 3238 | 3245 | ||
| 3239 | return RolePlugin | 3246 | return RolePlugin |
| 3240 | \ No newline at end of file | 3247 | \ No newline at end of file |
src/services/capsuled.lua
| @@ -73,7 +73,7 @@ function broadCastSpecial(roleId, capsuleId, broadInfo) | @@ -73,7 +73,7 @@ function broadCastSpecial(roleId, capsuleId, broadInfo) | ||
| 73 | for id, _ in pairs(register) do | 73 | for id, _ in pairs(register) do |
| 74 | if id ~= roleId then | 74 | if id ~= roleId then |
| 75 | if broadInfo[id] then | 75 | if broadInfo[id] then |
| 76 | - rpcRole(id, "paySpecialReward", id, broadInfo[id]) | 76 | + rpcRole(id, "paySpecialReward", id, broadInfo[id]) |
| 77 | end | 77 | end |
| 78 | end | 78 | end |
| 79 | end | 79 | end |
| @@ -243,6 +243,20 @@ function CMD.page_record(capsuleId, up, idx) | @@ -243,6 +243,20 @@ function CMD.page_record(capsuleId, up, idx) | ||
| 243 | return capsule:pageRecord(up, idx) | 243 | return capsule:pageRecord(up, idx) |
| 244 | end | 244 | end |
| 245 | 245 | ||
| 246 | +function CMD.get_special_nty(roleId, capsuleId) | ||
| 247 | + local capsule = capsules[capsuleId] | ||
| 248 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end | ||
| 249 | + | ||
| 250 | + return capsule:getSpecialNotify(roleId) | ||
| 251 | +end | ||
| 252 | + | ||
| 253 | +function CMD.clear_special_nty(roleId, capsuleId, good_ids) | ||
| 254 | + local capsule = capsules[capsuleId] | ||
| 255 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end | ||
| 256 | + | ||
| 257 | + return capsule:clearSpecialNty(roleId, good_ids) | ||
| 258 | +end | ||
| 259 | + | ||
| 246 | skynet.start(function() | 260 | skynet.start(function() |
| 247 | skynet.dispatch("lua", function(session, address, cmd, ...) | 261 | skynet.dispatch("lua", function(session, address, cmd, ...) |
| 248 | local f = CMD[string.lower(cmd)] | 262 | local f = CMD[string.lower(cmd)] |