Commit eb7ce1e794e6feb40f9cbc5142e9943a991ed73e

Authored by jiyue
2 parents 8546aa8f e8dce82e

Merge branch 'cn/develop' into cn/publish/preview

src/ProtocolCode.lua
... ... @@ -59,7 +59,7 @@ actionCodes = {
59 59 Role_runeBuyRpc = 142, -- 铭文购买
60 60 Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍
61 61 Role_setBgRpc = 144, -- 设置看板娘
62   - Role_itemExchangeRpc = 145, -- 道具兑换
  62 + Role_itemConvertMonthCardRpc = 145, -- 兑换月卡道具
63 63  
64 64 Adv_startAdvRpc = 151,
65 65 Adv_startHangRpc = 152,
... ... @@ -279,10 +279,14 @@ actionCodes = {
279 279 Capsule_joinRpc = 851, --扭蛋机详情
280 280 Capsule_registerRpc = 853, --报名扭蛋机 "报名"后,抽取按钮才会开放,未报名的玩家分在围观玩家中
281 281 Capsule_drawRpc = 854, --抽扭蛋机
282   - Capsule_switchRoomRpc = 855, --切换扭蛋机房间
  282 + --Capsule_switchRoomRpc = 855, --切换扭蛋机房间
283 283 Capsule_notifyChange = 856, -- 通知信息变动
284   - Capsule_payReward = 857, -- 特殊赏 奖励通知
  284 + Capsule_specialRewardRpc = 857, -- 获取 未领取特殊赏通知 主动
285 285 Capsule_exitRpc = 858, -- 退出
  286 + Capsule_getDataRpc = 859, --获取扭蛋机信息
  287 + Capsule_convertCapsuleRpc = 860, --兑换消耗票
  288 + Capsule_pageRecordRpc = 861, --抽奖记录分页查询
  289 + Capsule_clearSpecialNtyRpc = 862, --消除特殊赏通知
286 290 }
287 291  
288 292 rpcResponseBegin = 10000
... ...
src/actions/AdvAction.lua
... ... @@ -459,11 +459,12 @@ function _M.endHangRpc(agent, data)
459 459 heroCnt = heroCnt + 1
460 460 end
461 461  
462   - local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2
463   -
464   - local idleReward = totalReward:toNumMap()
465   - for itemId, count in pairs(idleReward) do
466   - idleReward[itemId] = count * adv_idle_reward_coef
  462 + local idleReward = {}
  463 + for k, v in pairs(campSiteData.idleReward_1:toNumMap()) do
  464 + idleReward[k] = (idleReward[k] or 0) + v * adv_idle_reward_coef
  465 + end
  466 + for k, v in pairs(campSiteData.idleReward_2:toNumMap()) do
  467 + idleReward[k] = (idleReward[k] or 0) + v * adv_idle_reward_coef
467 468 end
468 469  
469 470 local bnousReward = role:getBnousAdv()
... ...
src/actions/CapsuleAction.lua
... ... @@ -17,18 +17,18 @@ function _M.listRpc(agent, data)
17 17 local role = agent.role
18 18 local msg = MsgPack.unpack(data)
19 19 local typ = msg.typ
20   - local coin = msg.coin
  20 + local id = msg.id
21 21  
22 22 local capsules = {}
23 23 if typ == 1 then
24   - local ret = skynet.call(agent.capsule_serv, "lua", "list", coin)
  24 + local ret = skynet.call(agent.capsule_serv, "lua", "list", id)
25 25 if next(ret) then
26 26 for k, v in pairs(ret) do
27 27 capsules[k] = v
28 28 end
29 29 end
30 30 elseif typ == 0 then
31   - local ret = role:getCapsuleList(coin)
  31 + local ret = role:getCapsuleList(id)
32 32 if next(ret) then
33 33 for k, v in pairs(ret) do
34 34 capsules[k] = v
... ... @@ -51,7 +51,7 @@ function _M.joinRpc(agent, data)
51 51 if typ == 1 then
52 52 ret = skynet.call(agent.capsule_serv, "lua", "join", roleId, capsuleId)
53 53 elseif typ == 0 then
54   - ret = role:joinCapsule()
  54 + ret = role:joinCapsule(roleId, capsuleId)
55 55 end
56 56 SendPacket(actionCodes.Capsule_joinRpc, MsgPack.pack(ret))
57 57 return true
... ... @@ -93,39 +93,160 @@ function _M.drawRpc(agent, data)
93 93 local roleId = role:getProperty("id")
94 94 local capsuleId = msg.capsule_id
95 95 local typ = msg.typ --0=独享,1= 公开
96   - local full = msg.full -- 0=单次,1=十连抽 2=全收
  96 + local full = msg.full or 0-- 0=单次,1=十连抽 2=全收
97 97 local cares = msg.cares
98 98  
99   - local ret, reward, change, rewardByGoods, capsule
  99 + local ret, token, change, drawReward, capsule
  100 +
  101 + --检查库存
  102 + if typ == 1 then
  103 + ret, token = skynet.call(agent.capsule_serv, "lua", "goods_stock", capsuleId)
  104 + else
  105 + ret, token = role:goodStock(capsuleId)
  106 + end
  107 + if ret == 0 then skynet.error("零库存 " .. capsuleId) return 0 end
  108 +
  109 + --检查余额
  110 + if not next(token) then skynet.error("代币未配置 " .. capsuleId) return 1 end
  111 + local cost, drawsNum = {}, 0
  112 + if full == 0 then
  113 + drawsNum = 1
  114 + elseif full == 1 then
  115 + if ret < 10 then
  116 + drawsNum = ret
  117 + else
  118 + drawsNum = 10
  119 + end
  120 + elseif full == 2 then
  121 + drawsNum = ret
  122 + end
  123 + cost[token[1]] = drawsNum * token[2]
  124 +
  125 + if not role:checkItemEnough(cost) then return 2 end
  126 + role:costItems(cost, {log = {desc = "CapsuleCoinCost", int1 = token[1], int2 = cost[token[1]]}})
  127 +
  128 + --开始抽奖
100 129 if typ == 1 then
101   - ret, reward, rewardByGoods, capsule = skynet.call(agent.capsule_serv, "lua", "draw_capsule", roleId, capsuleId, full, cares)
  130 + ret, drawReward, capsule = skynet.call(agent.capsule_serv, "lua", "draw_capsule", roleId, capsuleId, full, cares)
102 131 else
103   - ret, reward, rewardByGoods, capsule= role:drawCapsule(capsuleId, full, cares)
  132 + ret, drawReward, capsule = role:drawCapsule(capsuleId, full, cares)
  133 + end
  134 + if ret < 5 then
  135 + return ret
  136 + end
  137 +
  138 + if ret == 5 then
  139 + SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({change = drawReward, capsule = capsule}))
  140 + return true
104 141 end
105   - if ret < 4 then
  142 +
  143 + if drawReward["reward"] and next(drawReward["reward"]) then
  144 + _, change = role:award(drawReward["reward"], {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}})
  145 + drawReward["capsule"] = capsule
  146 + SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack(drawReward))
  147 + else
106 148 return ret
107 149 end
  150 + return true
  151 +end
  152 +
  153 +function _M.getDataRpc(agent, data)
  154 + local role = agent.role
  155 + local msg = MsgPack.unpack(data)
  156 + local capsuleId = msg.capsule_id
  157 + local typ = msg.typ --0=独享,1= 公开
  158 + local roleId = role:getProperty("id")
  159 +
  160 + local capsule
  161 + if typ == 1 then
  162 + capsule = skynet.call(agent.capsule_serv, "lua", "capsule_data", roleId, capsuleId)
  163 + else
  164 + capsule = role:getCapsuleData(roleId, capsuleId)
  165 + end
  166 + if not capsule then return 1 end
  167 +
  168 + SendPacket(actionCodes.Capsule_getDataRpc, MsgPack.pack({capsule = capsule}))
  169 + return true
  170 +
  171 +end
  172 +
  173 +function _M.convertCapsuleRpc(agent, data)
  174 + local role = agent.role
  175 + local msg = MsgPack.unpack(data)
  176 + local coin = msg.coin
  177 + local count = msg.count or 1
  178 +
  179 + local cost, convert = {}
  180 + for k, v in pairs(globalCsv.ichibankuji_buy_cost)do
  181 + if k == coin then
  182 + convert = v:toArray(true, "=")
  183 + break
  184 + end
  185 + end
  186 + cost[convert[1]] = convert[2] * count
  187 + if not role:checkItemEnough(cost) then return 1 end
  188 + role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}})
  189 +
  190 +
  191 + local reward, change = role:award({[coin]= count}, {log = {desc = "CapsuleConvert"}})
  192 + SendPacket(actionCodes.Capsule_convertCapsuleRpc, MsgPack.pack(role:packReward(reward, change)))
  193 + return true
  194 +end
  195 +
  196 +function _M.pageRecordRpc(agent, data)
  197 + local role = agent.role
  198 + local msg = MsgPack.unpack(data)
  199 + local idx = msg.idx
  200 + local up = msg.up or 0
  201 + local capsuleId = msg.capsule_id
  202 + local typ = msg.typ --0=独享,1= 公开
108 203  
109   - if ret == 4 then
110   - SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack(reward))
  204 + local record
  205 + if typ == 1 then
  206 + record = skynet.call(agent.capsule_serv, "lua", "page_record", capsuleId, up, idx)
  207 + else
  208 + record = role:pageRecord(capsuleId, up, idx)
111 209 end
  210 + if not record then return 1 end
  211 +
  212 + SendPacket(actionCodes.Capsule_pageRecordRpc, MsgPack.pack({record = record}))
  213 + return true
  214 +end
  215 +
  216 +function _M.specialRewardRpc(agent, data)
  217 + local role = agent.role
  218 + local msg = MsgPack.unpack(data)
  219 + local capsuleId = msg.capsule_id
  220 + local typ = msg.typ or 1 --0=独享,1= 公开
  221 + local roleId = role:getProperty("id")
112 222  
113   - if rewardByGoods and next(rewardByGoods) then
114   - reward, change = role:award(reward, {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}})
115   - SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({reward = rewardByGoods, capsule = capsule}))
  223 + local ret
  224 + if typ == 1 then
  225 + ret = skynet.call(agent.capsule_serv, "lua", "get_special_nty", roleId, capsuleId)
116 226 else
117   - return 5
  227 + ret = role:getSpecialNotify(roleId, capsuleId)
118 228 end
  229 + if not ret or not next(ret) then return 1 end
  230 +
  231 + SendPacket(actionCodes.Capsule_specialRewardRpc, MsgPack.pack({special= ret}))
119 232 return true
120 233 end
121 234  
122   -function _M.switchRoomRpc(agent, data)
  235 +function _M.clearSpecialNtyRpc(agent, data)
123 236 local role = agent.role
124 237 local msg = MsgPack.unpack(data)
  238 + local capsuleId = msg.capsule_id
  239 + local typ = msg.typ --0=独享,1= 公开
  240 + local good_ids = msg.good_ids
125 241 local roleId = role:getProperty("id")
126 242  
127   - local ret = skynet.call(agent.capsule_serv, "lua", "switch_room", roleId)
128   - SendPacket(actionCodes.Capsule_switchRoomRpc, MsgPack.pack(ret))
  243 + local ret
  244 + if typ == 1 then
  245 + ret = skynet.call(agent.capsule_serv, "lua", "clear_special_nty", roleId, capsuleId, good_ids)
  246 + end
  247 + if not ret or not next(ret) then return 1 end
  248 +
  249 + SendPacket(actionCodes.Capsule_clearSpecialNtyRpc, MsgPack.pack({}))
129 250 return true
130 251 end
131 252  
... ...
src/actions/GmAction.lua
... ... @@ -9,7 +9,7 @@ function _M.clientRequest(agent, data)
9 9 SendPacket(actionCodes.Gm_receiveResponse, bin)
10 10 return true
11 11 end
12   - local ret = action(role, msg)
  12 + local ret = action(role, msg, agent.capsule_serv)
13 13 bin = MsgPack.pack({ cmd = ret })
14 14 SendPacket(actionCodes.Gm_receiveResponse, bin)
15 15 return true
... ... @@ -1075,4 +1075,15 @@ function _M.clear_sea(role, pms)
1075 1075 return "成功"
1076 1076 end
1077 1077  
  1078 +table.insert(helpDes, {"重置扭蛋机", "reset_capsule", "typ"})
  1079 +function _M.reset_capsule(role, pms, capsule_serv)
  1080 + local typ = tonumber(pms.pm1)
  1081 + if typ == 1 then
  1082 + skynet.call(capsule_serv, "lua", "reset")
  1083 + else
  1084 + role:resetCapsule()
  1085 + end
  1086 + return "成功"
  1087 +end
  1088 +
1078 1089 return _M
1079 1090 \ No newline at end of file
... ...
src/actions/RoleAction.lua
... ... @@ -288,7 +288,9 @@ function _M.loginRpc( agent, data )
288 288  
289 289 -- 注册全服广播
290 290 if not role._channelIdx then
291   - local channel = math.randomInt(1, 1)
  291 + local online = datacenter.get("onlineCount") or 0
  292 + local channel = math.floor(online / 500) + 1
  293 + --local channel = math.randomInt(1, 1)
292 294 role._channelIdx = channel
293 295 end
294 296 if not mcast_util.channel_world() then
... ... @@ -1710,7 +1712,7 @@ function _M.setBgRpc(agent, data)
1710 1712 return true
1711 1713 end
1712 1714  
1713   -function _M.itemExchangeRpc(agent, data)
  1715 +function _M.itemConvertMonthCardRpc(agent, data)
1714 1716 local role = agent.role
1715 1717 local msg = MsgPack.unpack(data)
1716 1718 local itemId = msg.item_id
... ... @@ -1738,7 +1740,7 @@ function _M.itemExchangeRpc(agent, data)
1738 1740 end
1739 1741 end
1740 1742  
1741   - SendPacket(actionCodes.Role_itemExchangeRpc, MsgPack.pack(role:packReward(reward)))
  1743 + SendPacket(actionCodes.Role_itemConvertMonthCardRpc, MsgPack.pack(role:packReward(reward)))
1742 1744 return status
1743 1745 end
1744 1746  
... ...
src/actions/SeaportAction.lua
... ... @@ -267,7 +267,7 @@ function _M.shopRpc(agent, data)
267 267 local shopCsv = {}
268 268 local dataSet = csvdb["shop_normalCsv"]
269 269 for _, datat in pairs(dataSet) do
270   - if datat.shop == 5 then
  270 + if datat.shop == 4 then
271 271 shopCsv[datat.id] = datat
272 272 end
273 273 end
... ...
src/agent.lua
... ... @@ -284,7 +284,7 @@ function CMD.close()
284 284 local role = agentInfo.role
285 285 if not role then return end
286 286  
287   - skynet.call(agent.capsule_serv, "lua", "exit", role:getProperty("id"))
  287 + skynet.call(agentInfo.capsule_serv, "lua", "exit", role:getProperty("id"))
288 288 role:log("onLogout", {logtime = skynet.timex()-role:getProperty("ltime")})
289 289 role:mylog("logout", {int1 = skynet.timex()-role:getProperty("ltime")})
290 290 role:onOfflineEvent()
... ...
src/models/Capsule.lua
... ... @@ -36,6 +36,7 @@ Capsule.schema = {
36 36 name = {"string"},
37 37 typ = {"number", 1}, -- 1=共享,2=独享
38 38 coin = {"number", 0}, --货币代号
  39 + token = {"table", {}}, --抽一次,货币=消耗
39 40 register = {"table", {}}, --人数 {["id"]=0}, 0 围观, 1 已报名
40 41 record = {"table", {}}, --抽取记录 列表
41 42 recordByRole = {"table", {}}, -- 抽取记录,hash, {roleid=record}
... ... @@ -43,8 +44,8 @@ Capsule.schema = {
43 44 goods = {"table", {}}, --奖励池
44 45 specials = {"table", {}}, --特殊赏
45 46 incentive = {"table", {}}, --激励奖
46   - incentiveRecord = {"table", {}}, --激励奖记录
47   - specialsRecord= {"table", {}}, --特殊赏领取记录
  47 + incentiveRecord = {"table", {}}, --激励奖记录 {roleId = {}, roleId={}}
  48 + specialsRecord= {"table", {}}, --特殊赏领取记录 {1={},2={}} key=触发特殊赏的 抽奖次数, v=特殊赏商品 table
48 49 resetTimes = {"number", 0}, --每日一次手动重置的机会
49 50 hideTime = {"number", 0} , --隐藏时间
50 51 drawEndTime = {"number", 0}, --抽完时间
... ... @@ -56,6 +57,7 @@ function Capsule:getResetFields()
56 57 room = self:getProperty("room"),
57 58 typ = self:getProperty("typ"),
58 59 coin = 0,
  60 + token = {},
59 61 register = {},
60 62 record = {},
61 63 recordByRole = {},
... ... @@ -132,7 +134,8 @@ function Capsule:init()
132 134 end
133 135 --货币类型
134 136 local coin = ichibankuji["token"]:toArray(true, "=")
135   - self:setProperties({coin = coin[1] or 0, hideTime = ichibankuji.hide_time, goods = goods, specials = specials, incentive = incentive})
  137 + self:setProperties({coin = coin[1] or 0, token = coin, hideTime = ichibankuji.hide_time, goods = goods, specials = specials, incentive = incentive})
  138 +
136 139 end
137 140  
138 141 function Capsule:isShow()
... ... @@ -142,6 +145,80 @@ function Capsule:isShow()
142 145 return true
143 146 end
144 147  
  148 +function Capsule:reset2TimeOut(curTime, now)
  149 + now = now or skynet.timex()
  150 + local interval
  151 + if now >= curTime then
  152 + self:init()
  153 + self:create()
  154 + else
  155 + interval = curTime - now
  156 + end
  157 + interval = (interval)* 100
  158 + skynet.timeout(interval, handler(self,self.reset3TimeOut)(curTime))
  159 +end
  160 +
  161 +function Capsule:reset3TimeOut(curTime, now)
  162 + now = now or skynet.timex()
  163 + local cur4Time = curTime or (specTime({hour = 4},now))
  164 +
  165 + local interval
  166 + if cur4Time > now then
  167 + interval = cur4Time - now
  168 + elseif cur4Time < now then
  169 + local nextTime = dayLater(now)
  170 + interval = nextTime - now
  171 + elseif cur4Time == now then
  172 + self:init()
  173 + self:create()
  174 +
  175 + local nextTime = dayLater(now)
  176 + interval = nextTime - now
  177 + end
  178 + interval = (interval)* 100
  179 + skynet.timeout(interval, handler(self,self.reset3TimeOut))
  180 +end
  181 +
  182 +function Capsule:reset4TimeOut(curTime, now)
  183 + now = now or skynet.timex()
  184 + local interval
  185 + if curTime > now then
  186 + interval = curTime - now
  187 + elseif curTime < now then
  188 + local nextTime = dayLater(now)
  189 + interval = nextTime - now
  190 + elseif curTime == now then
  191 + self:init()
  192 + self:create()
  193 +
  194 + return false
  195 + end
  196 + interval = (interval)* 100
  197 + skynet.timeout(interval, handler(self,self.reset4TimeOut))
  198 +end
  199 +
  200 +function Capsule:checkTime(reset, now)
  201 + local resetArr = reset:toArray(true, "=")
  202 + if not next(resetArr) then return false end
  203 +
  204 + if resetArr[1] == 2 then
  205 + if self:getGoodsAmount() > 0 then return false end
  206 + local drawEndTime = self:getProperty("drawEndTime") or 0
  207 + if drawEndTime == 0 then return false end
  208 + if now - drawEndTime >= resetArr[2] then return true end
  209 + --self:reset2TimeOut(drawEndTime + resetArr[2], now)
  210 + elseif resetArr[1] == 3 then
  211 + local cur4Time = specTime({hour = 4},now)
  212 + if now == cur4Time then return true end
  213 + --self:reset3TimeOut(cur4Time, now)
  214 + elseif resetArr[1] == 4 then
  215 + if now == resetArr[2] then return true end
  216 + --self:reset4TimeOut(resetArr[2], now)
  217 + end
  218 +
  219 + return false
  220 +end
  221 +
145 222 function Capsule:refreshing(now)
146 223 local id = self:getProperty("id")
147 224 local room = self:getProperty("room")
... ... @@ -151,30 +228,13 @@ function Capsule:refreshing(now)
151 228 if reset == "0" then
152 229 return false
153 230 elseif reset == "1" then
154   - if self:getProperty("resetTimes") == 1 then
  231 + if self:getProperty("resetTimes") == 0 then
  232 + self:setProperty("resetTime", 1)
155 233 return true
156 234 end
157 235 return false
158 236 else
159   - local resetArr = reset:toArray(true, "=")
160   - if not next(resetArr) then return false end
161   -
162   - if resetArr[1] == "2" then
163   - if self:getGoodsAmount() > 0 then return false end
164   -
165   - local drawEndTime = self:getProperty("drawEndTime") or 0
166   - if drawEndTime == 0 then return false end
167   -
168   - if now - drawEndTime >= resetArr[2] then
169   - return true
170   - end
171   - return false
172   -
173   - elseif resetArr[1] == "3" then
174   -
175   - elseif resetArr[1] == "4" then
176   - if now >= resetArr[2] then return true end
177   - end
  237 + return self:checkTime(reset, now)
178 238 end
179 239  
180 240 return false
... ... @@ -233,11 +293,11 @@ function Capsule:confirmed(cares)
233 293 for k, v in pairs(cares) do
234 294 if v.typ == 1 then
235 295 if goods[k] and goods[k].amount ~= v.count then
236   - change[k] = goods[k].amount
  296 + change[k] = {typ=1, count = goods[k].amount}
237 297 end
238 298 else
239 299 if specials[k] and specials[k].amount ~= v.count then
240   - change[k] = specials[k].amount
  300 + change[k] = {typ=1, count = specials[k].amount}
241 301 end
242 302 end
243 303 end
... ... @@ -271,7 +331,7 @@ function Capsule:checkSpecialFlag(typ)
271 331 return spKey, special
272 332 end
273 333  
274   -local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now)
  334 +local function getSpecialReward(rewardRecord, count, award, spKey, typ, now)
275 335 local rewardByRole = {}
276 336 while(count > 0 and next(rewardRecord)) do
277 337 local roleId = math.randWeight(rewardRecord, "amount")
... ... @@ -282,19 +342,9 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now)
282 342  
283 343 if tmp["amount"] <= 0 then rewardRecord[roleId] = nil end
284 344  
285   - tmp = rewardByRole[roleId]
286   - if not tmp then
287   - local name = getNameByRoleId(roleId)
288   - tmp[spKey] = {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = award, amount = 1, quality = typ, create_time= now}
289   - else
290   - if not tmp[spKey] then
291   - local name = getNameByRoleId(roleId)
292   - tmp[spKey] = {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = award, amount = 1, quality = typ, create_time= now}
293   - else
294   - tmp[spKey].amount = tmp[spKey].amount + 1
295   - end
296   - end
297   - rewardByRole[roleId] = tmp
  345 + local name = getNameByRoleId(roleId)
  346 + tmp = {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = award, amount = 1, quality = typ, create_time= now}
  347 + table.insert(rewardByRole, tmp)
298 348  
299 349 count = count - 1
300 350 end
... ... @@ -302,13 +352,28 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now)
302 352 return rewardByRole, count
303 353 end
304 354  
305   -function Capsule:getTop(record)
  355 +
  356 +local rewardToRecordFunc = function(specialsRecord, recordAmount, rewardByRole)
  357 + if not specialsRecord[recordAmount] then
  358 + specialsRecord[recordAmount] = rewardByRole
  359 + else
  360 + table.insert(specialsRecord[recordAmount], rewardByRole)
  361 + end
  362 +end
  363 +
  364 +local function getRecordAmount(record)
  365 + return #record
  366 +end
  367 +
  368 +
  369 +function Capsule:getTop(record, recordAmount,now)
306 370 local spKey, special = self:checkSpecialFlag(SpecialType.TOP)
307 371 if not special then return nil end
308 372 local specials = self:getProperty("specials") or {}
309 373 local specialsRecord = self:getProperty("specialsRecord") or {}
310 374  
311   - if #record < special["np"] then return nil end
  375 + if recordAmount < special["np"] then return nil end
  376 +
312 377 local topRecord = {}
313 378 local count = special["np"]
314 379 for _, v in ipairs(record) do
... ... @@ -330,32 +395,33 @@ function Capsule:getTop(record)
330 395 end
331 396 end
332 397  
333   - local rewardByRole, count = getSpecialRoleNotify(topRecord, special["amount"], special["award"], spKey, SpecialType.TOP)
  398 + local rewardByRole, count = getSpecialReward(topRecord, special["amount"], special["award"], spKey, SpecialType.TOP,now)
334 399  
335 400 special["amount"] = count
336 401 specials[spKey] = special
337   - specialsRecord[SpecialType.TOP] = rewardByRole
  402 +
  403 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
  404 +
338 405 self:setProperties({specialsRecord = specialsRecord, specials = specials})
339 406 return rewardByRole
340 407  
341 408 end
342 409  
343 410 --TODO
344   -function Capsule:getCore(record)
  411 +function Capsule:getCore(record, recordAmount,now)
345 412 local spKey, special = self:checkSpecialFlag(SpecialType.CORE)
346 413 if not special then return nil end
347 414  
348 415 local specials = self:getProperty("specials") or {}
349 416 local specialsRecord = self:getProperty("specialsRecord") or {}
350 417  
351   - if self:getGoodsAmount() > 0 then return nil end
352 418  
353   - local np = special["np"]
354   - if np > #record then return nil end
  419 +
  420 + local count = special["np"]
  421 + if count > recordAmount then return nil end
355 422  
356 423  
357   - local left = math.ceil((np - #record)/2) or 0
358   - local count = np
  424 + local left = math.ceil((count - recordAmount)/2) or 0
359 425 local roleRecord = {}
360 426 for i, v in ipairs(record) do
361 427 if count <= 0 then break end
... ... @@ -372,34 +438,32 @@ function Capsule:getCore(record)
372 438 if not roleRecord[v.roleId]then
373 439 roleRecord[v.roleId] = {amount = v.amount }
374 440 else
375   - roleRecord[v.roleId] = {amount = (roleRecord[v.rol_id]["amount"] or 0) + tmpCount}
  441 + roleRecord[v.roleId] = {amount = (roleRecord[v.roleId]["amount"] or 0) + tmpCount}
376 442 end
377 443 end
378 444  
379 445 end
380 446  
381   - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], SpecialType.CORE)
  447 + local rewardByRole, count = getSpecialReward(roleRecord, special["amount"], special["award"], spKey, SpecialType.CORE,now)
382 448  
383 449 special["amount"] = count
384 450 specials[spKey] = special
385   - specialsRecord[SpecialType.CORE] = rewardByRole
  451 +
  452 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
386 453 self:setProperties({specialsRecord = specialsRecord, specials = specials})
387 454 return rewardByRole
388 455 end
389 456  
390   -function Capsule:getLast(record)
  457 +function Capsule:getLast(record, recordAmount, now)
391 458 local spKey, special = self:checkSpecialFlag(SpecialType.LAST)
392 459 if not special then return nil end
393 460  
394 461 local specials = self:getProperty("specials") or {}
395 462 local specialsRecord = self:getProperty("specialsRecord") or {}
396 463  
397   - if self:getGoodsAmount() > 0 then return nil end
398   -
399 464 table.sort(record, function(a, b) return a.create_time > b.create_time end)
400 465  
401   - local np = special["np"]
402   - local count = np
  466 + local count = special["np"]
403 467 local roleRecord = {}
404 468 for _, v in ipairs(record) do
405 469 if count <= 0 then break end
... ... @@ -416,90 +480,85 @@ function Capsule:getLast(record)
416 480 if not roleRecord[v.roleId]then
417 481 roleRecord[v.roleId] = {amount = v.amount }
418 482 else
419   - roleRecord[v.roleId] = {amount = (roleRecord[v.rol_id]["amount"] or 0) + tmpCount}
  483 + roleRecord[v.roleId] = {amount = (roleRecord[v.roleId]["amount"] or 0) + tmpCount}
420 484 end
421 485 end
422 486  
423   - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], SpecialType.LAST)
  487 + local rewardByRole, count = getSpecialReward(roleRecord, special["amount"], special["award"], spKey, SpecialType.LAST,now)
424 488  
425 489 special["amount"] = count
426 490 specials[spKey] = special
427   - specialsRecord[SpecialType.LAST] = rewardByRole
  491 +
  492 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
428 493 self:setProperties({specialsRecord = specialsRecord, specials = specials})
429 494 return rewardByRole
430 495 end
431 496  
432   -function Capsule:getJoker(record)
  497 +function Capsule:getJoker(record, recordAmount, now)
433 498 local spKey, special = self:checkSpecialFlag(SpecialType.JOKER)
434 499 if not special then return nil end
435 500  
436 501 local specials = self:getProperty("specials") or {}
437 502 local specialsRecord = self:getProperty("specialsRecord") or {}
438 503  
439   - if self:getGoodsAmount() > 0 then return nil end
440   -
441 504 local roleRecord = {}
442 505 for _, v in ipairs(record) do
443 506 if not roleRecord[v.roleId]then
444 507 roleRecord[v.roleId] = {amount = v.amount }
445 508 else
446   - roleRecord[v.roleId] = {amount = (roleRecord[v.rol_id]["amount"] or 0) + v.amount}
  509 + roleRecord[v.roleId] = {amount = (roleRecord[v.roleId]["amount"] or 0) + v.amount}
447 510 end
448 511 end
449 512  
450   - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], SpecialType.JOKER)
  513 + local rewardByRole, count = getSpecialReward(roleRecord, special["amount"], special["award"], spKey, SpecialType.JOKER,now)
451 514  
452 515 special["amount"] = count
453 516 specials[spKey] = special
454   - specialsRecord[SpecialType.JOKER] = rewardByRole
  517 +
  518 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
455 519 self:setProperties({specialsRecord = specialsRecord, specials = specials})
456 520 return rewardByRole
457 521 end
458 522  
459   -function Capsule:getKing(record)
  523 +function Capsule:getKing(record, recordAmount, now)
460 524 local spKey, special = self:checkSpecialFlag(SpecialType.KING)
461 525 if not special then return nil end
462 526  
463 527 local specials = self:getProperty("specials") or {}
464 528 local specialsRecord = self:getProperty("specialsRecord") or {}
465   -
466   - if self:getGoodsAmount() > 0 then return nil end
  529 + local rank = self:getProperty("rank") or {}
  530 + if not next(rank) then return nil end
467 531  
468 532 local roleRecord = {}
469   - for _, v in ipairs(record) do
470   - if not roleRecord[v.roleId]then
471   - roleRecord[v.roleId] = {amount = v.amount }
472   - else
473   - roleRecord[v.roleId] = {amount = (roleRecord[v.rol_id]["amount"] or 0) + v.amount}
474   - end
  533 +
  534 + for roleId, count in pairs(rank) do
  535 + table.insert(roleRecord, {roleId = roleId, count = count})
  536 + end
  537 + table.sort(roleRecord, function(a, b) return a.count > b.count end)
  538 +
  539 + local count = math.min(special["amount"], #roleRecord)
  540 +
  541 + local rewardByRole = {}
  542 + local index = 1
  543 + while (count > 0 ) do
  544 + count = count - 1
  545 + local tmp = roleRecord[index]
  546 + if not tmp then break end
  547 + index = index + 1
  548 +
  549 + local name = getNameByRoleId(tmp.roleId)
  550 + table.insert(rewardByRole, {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = special["award"], amount = 1, SpecialType.KING, create_time= now})
475 551 end
476 552  
477   - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], SpecialType.KING)
478 553 special["amount"] = count
479 554 specials[spKey] = special
480   - specialsRecord[SpecialType.KING] = rewardByRole
  555 +
  556 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
481 557 self:setProperties({specialsRecord = specialsRecord, specials = specials})
482 558 return rewardByRole
483 559 end
484 560  
485   -local rewardToNtyFunc = function(notify, tmpReward)
486   - for key, val in pairs(tmpReward or {}) do
487   - if not notify[key] then
488   - notify[key] = val
489   - else
490   - for k, v in pairs(val) do
491   - if not notify[key][k] then
492   - notify[key][k] = v
493   - else
494   - notify[key][k] = notify[key][k].amount + v.amount
495   - end
496   - end
497   -
498   - end
499   - end
500   -end
501   -
502   -function Capsule:checkSpecialReward( now)
  561 +function Capsule:checkSpecialReward(now, goodsAmount)
503 562 local specials = self:getProperty("specials") or {}
504 563 if not next(specials) then return nil end
505 564 local record = self:getProperty("record") or {}
... ... @@ -507,23 +566,24 @@ function Capsule:checkSpecialReward( now)
507 566 if not next(record) then return nil end
508 567 table.sort(record, function(a, b) return a.create_time < b.create_time end )
509 568  
  569 + local recordAmount = getRecordAmount(record)
510 570  
511   - local notify = self:getTop(record) or {}
  571 + local notify = self:getTop(record, recordAmount,now) or {}
512 572  
513   - local coreReward = self:getCore(record)
514   - rewardToNtyFunc(notify, coreReward)
  573 + if goodsAmount == 0 then
  574 + local coreReward = self:getCore(record, recordAmount, now)
  575 + rewardToRecordFunc(notify, recordAmount, coreReward)
515 576  
516   - local lastReward = self:getLast(record)
517   - rewardToNtyFunc(notify, lastReward)
  577 + local lastReward = self:getLast(record, recordAmount, now)
  578 + rewardToRecordFunc(notify, recordAmount, lastReward)
518 579  
519   - local jokerReward = self:getJoker(record)
520   - rewardToNtyFunc(notify, jokerReward)
  580 + local jokerReward = self:getJoker(record, recordAmount, now)
  581 + rewardToRecordFunc(notify, recordAmount, jokerReward)
521 582  
522   - local kingReward = self:getKing(record)
523   - rewardToNtyFunc(notify, kingReward)
  583 + local kingReward = self:getKing(record, recordAmount, now)
  584 + rewardToRecordFunc(notify, recordAmount, kingReward)
  585 + end
524 586  
525   - --广播出去TODO
526   - --rpcRole(roleId, "paySpecialReward", RewardTYpe.JOKER, jokerReward.award)
527 587 return notify
528 588 end
529 589  
... ... @@ -561,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now)
561 621 end
562 622  
563 623 local count = math.floor(amount / incentive["amount"]["np"])
564   - local tmpCount = count * incentive["amount"]["np"]
565   - notify["amount"] = {name = name, good_id = "amount", typ = RewardType.INCENTIVE, award = incentive["amount"]["award"], amount = count, quality = 2, create_time= now}
566   -
567   - --填充v.calculated 字段,标识已经用于每x抽的计算中。
568   - for _, v in pairs(roleRecord) do
569   - if tmpCount <= 0 then break end
570   -
571   - v.calculated = v.calculated or 0
572   - if v.calculated ~= v.amount then
573   - if tmpCount <= v.amount then
574   - v.calculated = tmpCount
575   - tmpCount = 0
576   - else
577   - v.calculated = v.amount
578   - tmpCount = tmpCount - v.amount
  624 + if count > 0 then
  625 + local tmpCount = count * incentive["amount"]["np"]
  626 + notify["amount"] = {name = name, roleId= roleId, good_id = "amount", typ = RewardType.INCENTIVE, award = incentive["amount"]["award"], amount = count, quality = 2, create_time= now}
  627 +
  628 + --填充v.calculated 字段,标识已经用于每x抽的计算中。
  629 + for _, v in pairs(roleRecord) do
  630 + if tmpCount <= 0 then break end
  631 +
  632 + v.calculated = v.calculated or 0
  633 + if v.calculated ~= v.amount then
  634 + if tmpCount <= v.amount then
  635 + v.calculated = tmpCount
  636 + tmpCount = 0
  637 + else
  638 + v.calculated = v.amount
  639 + tmpCount = tmpCount - v.amount
  640 + end
579 641 end
580 642 end
581   -
582 643 end
583 644 end
584 645  
... ... @@ -590,11 +651,44 @@ function Capsule:checkIncentive(roleId, name, now)
590 651  
591 652 end
592 653 end
593   - table.insert(incentiveByRole, notify)
  654 + for k, v in pairs(notify) do
  655 + if not incentiveByRole[k] then
  656 + incentiveByRole[k] = v
  657 + else
  658 + incentiveByRole[k].amount = incentiveByRole[k].amount + v.amount
  659 + end
  660 + end
594 661 incentiveRecord[roleId] = incentiveByRole
595 662 self:setProperty("incentiveRecord", incentiveRecord)
596 663  
597   - return notify
  664 + return incentiveByRole
  665 +end
  666 +
  667 +local rewardCollect = function(reward, goods)
  668 + for _, v in pairs(goods) do
  669 + for id, count in pairs(v.award:toNumMap()) do
  670 + reward[id] = (reward[id] or 0) + count * v.amount
  671 + end
  672 + end
  673 +end
  674 +
  675 +local rewardCollectByRoleId = function(roleId, reward, goods)
  676 + local tmp = {}
  677 + for _, val in pairs(goods) do
  678 + for _, v in ipairs(val) do
  679 + if v.roleId == roleId then
  680 + for id, count in pairs(v.award:toNumMap()) do
  681 + reward[id] = (reward[id] or 0) + count * v.amount
  682 + end
  683 + if not tmp[v.good_id] then
  684 + tmp[v.good_id] = v
  685 + else
  686 + tmp[v.good_id].amount = tmp[v.good_id].amount + v.amount
  687 + end
  688 + end
  689 + end
  690 + end
  691 + return tmp
598 692 end
599 693  
600 694 function Capsule:drawByCount(roleId, count)
... ... @@ -602,6 +696,8 @@ function Capsule:drawByCount(roleId, count)
602 696  
603 697 local goods = self:getProperty("goods") or {}
604 698 local record = self:getProperty("record") or {}
  699 + local rank = self:getProperty("rank") or {}
  700 + local rankRole = rank[roleId] or 0
605 701 local recordByRole = self:getProperty("recordByRole") or {}
606 702 local roleRecord = recordByRole[roleId] or {}
607 703  
... ... @@ -611,98 +707,106 @@ function Capsule:drawByCount(roleId, count)
611 707 local goods_id = ichibankuji["goods_id"]
612 708 local now = skynet.timex()
613 709  
614   - --奖励, 通知信息
615   - local notify= {}
616   - notify[roleId] = {}
  710 + --奖励,普通奖品信息
  711 + local goodsByUsual= {}
617 712  
618 713 local name = getNameByRoleId(roleId)
619 714 while (goods and next(goods) and count > 0) do
620 715 local good_id = math.randWeight(goods, "weight")
621   - if good_id then
622   - local good = goods[good_id] or {}
623   - if good and good.amount > 0 then
624   - good.amount = good.amount - 1
625   -
626   - --插入记录
627   - local tmpNotify = {name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = 1, quality = good.quality, create_time= now}
628   - table.insert(record, tmpNotify)
629   -
630   - --作为奖励记录+通知
631   - if not notify[roleId][good_id] then
632   - notify[roleId][good_id] = tmpNotify
633   - else
634   - notify[roleId][good_id].amount = notify[roleId][good_id].amount + 1
635   - end
  716 + if not good_id then break end
636 717  
637   - --记录角色的抽奖记录 计算激励奖需要用到
638   - if not roleRecord[good_id] then
639   - roleRecord[good_id] = tmpNotify
640   - else
641   - roleRecord[good_id].amount = roleRecord[good_id].amount + 1
642   - end
  718 + local good = goods[good_id] or {}
  719 + if good and good.amount > 0 then
  720 + good.amount = good.amount - 1
  721 +
  722 + --插入rank
  723 + rankRole = rankRole + 1
643 724  
644   - good.weight = good.weight - csvdb["ichibankuji_goodsCsv"][goods_id][good.id].weight
645   - count = count - 1
  725 + --插入记录
  726 + local tmpNotify = {roleId = roleId, name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = 1, quality = good.quality, create_time= now}
  727 + table.insert(record, tmpNotify)
  728 +
  729 + --作为奖励记录+通知
  730 + if not goodsByUsual[good_id] then
  731 + goodsByUsual[good_id] = tmpNotify
  732 + else
  733 + goodsByUsual[good_id].amount = goodsByUsual[good_id].amount + 1
646 734 end
647   - end
648 735  
649   - end
650   - recordByRole[roleId] = roleRecord
651   - self:setProperties({recordByRole = recordByRole, record = record, goods = goods})
  736 + --记录角色的抽奖记录 计算激励奖需要用到
  737 + if not roleRecord[good_id] then
  738 + roleRecord[good_id] = tmpNotify
  739 + else
  740 + roleRecord[good_id].amount = roleRecord[good_id].amount + 1
  741 + end
652 742  
653   - local tmpNotify = self:checkIncentive(roleId, name, now)
654   - for k, v in pairs(tmpNotify) do
655   - if not notify[roleId][k] then
656   - notify[roleId][k] = v
657   - else
658   - notify[roleId][k].amount = notify[roleId][k].amount + v.amount
  743 + good.weight = good.weight - csvdb["ichibankuji_goodsCsv"][goods_id][good.id].weight
  744 + count = count - 1
659 745 end
  746 +
660 747 end
661 748  
662   - local speciNotify = self:checkSpecialReward(now)
663   - rewardToNtyFunc(notify, speciNotify)
  749 + --奖励池重新赋值
  750 + rank[roleId] = rankRole
  751 + recordByRole[roleId] = roleRecord
  752 + self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank})
664 753  
665   - local reward, rewardByGoods = {}, {}
666   - for key, val in pairs(notify) do
667   - if key == roleId then
668   - for k, v in pairs(val) do
669   - for id, count in pairs(v.award:toNumMap()) do
670   - reward[id] = (reward[id] or 0) + count
671   - end
672   - rewardByGoods[k] = v
673   - end
674   - end
  754 + --奖励收集
  755 + local reward = {}
  756 + rewardCollect(reward, goodsByUsual)
675 757  
  758 + local goodsByIncentive = self:checkIncentive(roleId, name, now)
  759 + rewardCollect(reward, goodsByIncentive)
  760 +
  761 + local goodsAmount = self:getGoodsAmount()
  762 + if goodsAmount == 0 then
  763 + self:setProperty("drawEndTime", now)
676 764 end
677   - return reward, rewardByGoods, notify
  765 +
  766 + local goodsBySpecial = self:checkSpecialReward(now, goodsAmount)
  767 + local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial)
  768 +
  769 + local drawReward = {}
  770 + drawReward["reward"] = reward
  771 + drawReward["usual"] = goodsByUsual
  772 + drawReward["specials"] = goodsBySpecial
  773 + if next(goodsByIncentive) then drawReward["incentive"] = goodsByIncentive end
  774 + if next(specialByRole) then drawReward["special"] = specialByRole end
  775 + return drawReward
678 776 end
679 777  
680 778 function Capsule:drawAll(roleId)
681 779 local goods = self:getProperty("goods") or {}
682 780 local record = self:getProperty("record") or {}
  781 + local rank = self:getProperty("rank") or {}
  782 + local rankRole = rank[roleId] or 0
683 783 local recordByRole = self:getProperty("recordByRole") or {}
684 784 local roleRecord = recordByRole[roleId] or {}
685 785 local now = skynet.timex()
686 786  
687 787 local name = getNameByRoleId(roleId)
688   - local notify = {}
689   - notify[roleId] = {}
  788 + local goodsByUsual = {}
690 789 for good_id, good in pairs(goods) do
691 790 if good.amount > 0 then
  791 + --插入rank
  792 + rankRole = rankRole + good.amount
  793 +
692 794 --插入记录
693   - local tmpNotify = {name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = good.amount, quality = good.quality, create_time = now}
694   - table.insert(record, notify)
  795 + local tmpNotify = {roleId = roleId, name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = good.amount, quality = good.quality, create_time = now}
  796 + for i = 1, good.amount do
  797 + table.insert(record, {roleId = roleId, name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = 1, quality = good.quality, create_time = now})
  798 + end
695 799  
696 800 --作为奖励记录+通知
697   - if not notify[roleId][good_id] then
698   - notify[roleId][good_id] = tmpNotify
  801 + if not goodsByUsual[good_id] then
  802 + goodsByUsual[good_id] = tmpNotify
699 803 else
700   - notify[roleId][good_id].amount = notify[roleId][good_id].amount + good.award
  804 + goodsByUsual[good_id].amount = goodsByUsual[good_id].amount + good.award
701 805 end
702 806  
703 807 --记录角色的抽奖记录
704 808 if not roleRecord[good_id] then
705   - roleRecord[good_id] = notify
  809 + roleRecord[good_id] = tmpNotify
706 810 else
707 811 roleRecord[good_id].amount = roleRecord[good_id].amount + good.amount
708 812 end
... ... @@ -711,34 +815,32 @@ function Capsule:drawAll(roleId)
711 815 end
712 816  
713 817 end
  818 + rank[roleId] = rankRole
714 819 recordByRole[roleId] = roleRecord
715   - self:setProperties({recordByRole = recordByRole, record = record, goods = goods})
716   -
717   - local tmpNotify = self:checkIncentive(roleId, name, now)
718   - for k, v in pairs(tmpNotify) do
719   - if not notify[roleId][k] then
720   - notify[roleId][k] = v
721   - else
722   - notify[roleId][k].amount = notify[roleId][k].amount + v.amount
723   - end
724   - end
  820 + self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank})
725 821  
726   - local speciNotify = self:checkSpecialReward(now)
727   - rewardToNtyFunc(notify, speciNotify)
  822 + --奖励收集
  823 + local reward = {}
  824 + rewardCollect(reward, goodsByUsual)
728 825  
729   - local reward, rewardByGoods = {}, {}
730   - for key, val in pairs(notify) do
731   - if key == roleId then
732   - for k, v in pairs(val) do
733   - for id, count in pairs(v.award:toNumMap()) do
734   - reward[id] = (reward[id] or 0) + count
735   - end
736   - rewardByGoods[k] = v
737   - end
738   - end
  826 + local goodsByIncentive = self:checkIncentive(roleId, name, now)
  827 + rewardCollect(reward, goodsByIncentive)
739 828  
  829 + local goodsAmount = self:getGoodsAmount()
  830 + if goodsAmount == 0 then
  831 + self:setProperty("drawEndTime", now)
740 832 end
741   - return reward, rewardByGoods, notify
  833 +
  834 + local goodsBySpecial = self:checkSpecialReward(now, goodsAmount)
  835 + local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial)
  836 +
  837 + local drawReward = {}
  838 + drawReward["reward"] = reward
  839 + drawReward["usual"] = goodsByUsual
  840 + drawReward["specials"] = goodsBySpecial
  841 + if next(goodsByIncentive) then drawReward["incentive"] = goodsByIncentive end
  842 + if next(specialByRole) then drawReward["special"] = specialByRole end
  843 + return drawReward
742 844 end
743 845  
744 846 --@param
... ... @@ -749,27 +851,97 @@ end
749 851 ]]--
750 852  
751 853 function Capsule:draw(roleId, full, cares)
752   - if self:getGoodsAmount() == 0 then return 2 end
753 854 if self:getProperty("typ") == 1 then
754 855 --是否报名
755   - if self:isRegister(roleId) == false then return 3 end
  856 + if self:isRegister(roleId) == false then return 4 end
756 857  
757 858 --关注的奖品的数量发生了变化
758 859 if cares then
759 860 local change = self:confirmed(cares)
760   - if next(change) then return 4, change end
  861 + if next(change) then return 5, change end
761 862 end
762 863 end
763 864  
764 865 if full == 0 then
765   - return 5, self:drawByCount(roleId, 1)
  866 + return 6, self:drawByCount(roleId, 1)
766 867 elseif full == 1 then
767   - return 5, self:drawByCount(roleId, 10)
  868 + return 6, self:drawByCount(roleId, 10)
768 869 elseif full == 2 then
769   - return 5, self:drawAll(roleId)
  870 + return 6, self:drawAll(roleId)
770 871 end
771 872 end
772 873  
  874 +function Capsule:pageRecord(up, idx)
  875 + local record = self:getProperty("record") or {}
  876 + if not next(record) then return nil end
  877 +
  878 + --默认取20条
  879 + idx = idx or #record
  880 + up = up or 0
  881 +
  882 + local count = 0
  883 + local tmpRecord = {}
  884 + if up == 1 then
  885 + --向上获取索引更大的 从上往下拉
  886 + count = math.min(#record - idx, 20)
  887 + for i = idx, count do
  888 + tmpRecord[i] = record[i]
  889 + end
  890 + else
  891 + --向下获取索引更小的 从下往上拉
  892 + count = math.max(idx - 20, 0)
  893 + for i = count, idx do
  894 + tmpRecord[i] = record[i]
  895 + end
  896 + end
  897 +
  898 + return tmpRecord
  899 +end
  900 +
  901 +--检查是否有未领取奖励的通知
  902 +function Capsule:getSpecialNotify(roleId)
  903 + local specialsRecord = self:getProperty("specialsRecord") or {}
  904 + local tmp = {}
  905 + for _, goods in pairs(specialsRecord) do
  906 + for _, good in ipairs(goods) do
  907 + if good.roleId == roleId then
  908 + if not good.nty or good.nty == 0 then
  909 + tmp[good.good_id] = good
  910 + end
  911 + end
  912 + end
  913 + end
  914 + self:setProperty("specialsRecord", specialsRecord)
  915 +
  916 + return tmp
  917 +end
  918 +
  919 +function Capsule:clearSpecialNty(roleId, good_ids)
  920 + local specialsRecord = self:getProperty("specialsRecord") or {}
  921 + for _, goods in pairs(specialsRecord) do
  922 + for _, good in ipairs(goods) do
  923 + for _, good_id in ipairs(good_ids) do
  924 + if good_id == good.good_id and good.roleId == roleId then
  925 + good.nty = 1
  926 + end
  927 + end
  928 + end
  929 + end
  930 + self:setProperty("specialsRecord", specialsRecord)
  931 +end
  932 +
  933 +function Capsule:getRoleProgress(roleId)
  934 + local recordByRole = self:getProperty("recordByRole") or {}
  935 + local roleRecord = recordByRole[roleId] or {}
  936 + local amount = 0
  937 + for _, v in pairs(roleRecord) do
  938 + v.calculated = v.calculated or 0
  939 + if v.calculated ~= v.amount then
  940 + amount = amount + (v.amount - v.calculated)
  941 + end
  942 + end
  943 + return amount
  944 +end
773 945  
774 946 function Capsule:data(roleId)
775 947 return {
... ... @@ -780,12 +952,13 @@ function Capsule:data(roleId)
780 952 coin = self:getProperty("coin"),
781 953 onlineCount = self:getOnlineCount(),
782 954 playerStatus = self:getRegisterByRoleId(roleId),
783   - record = self:getProperty("record"),
  955 + record = self:pageRecord() or {},
784 956 rank = self:getProperty("rank"),
785 957 goods = self:getProperty("goods"),
786 958 specials = self:getProperty("specials"),
787 959 incentive = self:getProperty("incentive"),
788 960 specialsRecord= self:getProperty("specialsRecord"),
  961 + roleProgress = self:getRoleProgress(roleId),
789 962 }
790 963 end
791 964  
... ...
src/models/RoleCross.lua
... ... @@ -210,10 +210,18 @@ RoleCross.bind = function (Role)
210 210 return "成功"
211 211 end
212 212  
213   - function Role:paySpecialReward(typ, reward)
214   - local tmpReward, _= self:award(reward, {log = {desc = "specialsReward", int1=self:getKey(), int2 = typ}})
215   - SendPacket(actionCodes.Capsule_payReward, MsgPack.pack({reward=tmpReward}))
216   - return "reward"
  213 + function Role:paySpecialReward(roleId, notify)
  214 + if notify and next(notify) then
  215 + local reward = {}
  216 + for key, val in pairs(notify) do
  217 + for id, count in pairs(val.award:toNumMap()) do
  218 + reward[id] = (reward[id] or 0) + count
  219 + end
  220 +
  221 + end
  222 + self:award(reward, {log = {desc = "CapsuleReward", int1=roleId}})
  223 + SendPacket(actionCodes.Capsule_notifyChange, MsgPack.pack({special = notify}))
  224 + end
217 225 end
218 226  
219 227 end
... ... @@ -376,9 +384,19 @@ function CMD.redPTag(roleId, tag, pms)
376 384 end
377 385 end
378 386  
379   -function CMD.paySpecialReward(roleId, typ, reward)
380   - local role = require("models.Role").new({key = string.format("%s",roleId), id = roleId})
381   - role:award(reward, {log = {desc = "specialsReward", int1=self:getKey(), int2 = typ}})
  387 +function CMD.paySpecialReward(roleId, notify)
  388 + if notify and next(notify) then
  389 + local reward = {}
  390 + for key, val in pairs(notify) do
  391 + for id, count in pairs(val.award:toNumMap()) do
  392 + reward[id] = (reward[id] or 0) + count
  393 + end
  394 +
  395 + end
  396 + local role = require("models.Role").new({key = string.format("%s",roleId), id = roleId})
  397 + role:award(reward, {log = {desc = "CapsuleReward", int1=roleId}})
  398 + end
  399 +
382 400 end
383 401  
384 402 RoleCross.handle = function(cmd, roleId, ...)
... ...
src/models/RoleLog.lua
... ... @@ -161,7 +161,8 @@ local ItemReason = {
161 161 returner = 1410, -- 回归者奖励
162 162  
163 163 CapsuleReward = 1411, --扭蛋机奖励
164   - specialsReward = 1412, --特殊赏
  164 + CapsuleConvert = 1412, --扭蛋机 消耗票 兑换
  165 + CapsuleCoinCost = 1413, --抽扭蛋机消耗
165 166 }
166 167  
167 168  
... ...
src/models/RolePlugin.lua
... ... @@ -2090,7 +2090,7 @@ function RolePlugin.bind(Role)
2090 2090 local emailSync = math.max(emailSync + 1, globalEmail - EMAIL_LIMIT + 1)
2091 2091 local redret = redisproxy:pipelining(function (red)
2092 2092 for id = emailSync, globalEmail do
2093   - red:hgetall(string.format("globalEmail:%s", id))
  2093 + red:hgetall(string.format("globalEmail:%s", id))
2094 2094 end
2095 2095 end)
2096 2096 for _, data in ipairs(redret) do
... ... @@ -2437,6 +2437,11 @@ function RolePlugin.bind(Role)
2437 2437 end
2438 2438 elseif rechargeData.shop == 3 then -- 礼包商店
2439 2439 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
  2440 +
  2441 + --增加购买记录
  2442 + local buyRecord = self.storeData:getProperty("buyR") or {}
  2443 + buyRecord[id] = (buyRecord[id] or 0) + 1
  2444 + self.storeData:updateProperty({field = "buyR", value = buyRecord})
2440 2445 else
2441 2446 skynet.error("[recharge] invalid recharge shop type " .. id)
2442 2447 return 3
... ... @@ -3153,10 +3158,10 @@ function RolePlugin.bind(Role)
3153 3158 return itemRandomOccupy
3154 3159 end
3155 3160  
3156   - function Role:getCapsuleList(coin)
  3161 + function Role:getCapsuleList(id)
3157 3162 local capsules = {}
3158 3163 for k, v in pairs(self.capsules) do
3159   - if v:getProperty("coin") == coin then
  3164 + if v:getProperty("id") == id then
3160 3165 local onlineCount= v:getOnlineCount()
3161 3166 capsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")}
3162 3167 end
... ... @@ -3165,17 +3170,20 @@ function RolePlugin.bind(Role)
3165 3170 end
3166 3171  
3167 3172 function Role:drawCapsule(capsuleId, full, cares)
3168   - local capsule = self.capsules[capsuleId] or {}
3169   - if next(capsule) then
3170   - local roleId = self:getProperty("id")
3171   - return capsule:draw(roleId, full, cares)
3172   - end
3173   - return 1
  3173 + local capsule = self.capsules[capsuleId]
  3174 + if not capsule then return nil end
  3175 +
  3176 + local roleId = self:getProperty("id")
  3177 + local ret, drawReward = capsule:draw(roleId, full, cares)
  3178 + drawReward["specials"] = nil
  3179 + return ret, drawReward, capsule:data(roleId)
3174 3180 end
3175 3181  
3176   - function Role:joinCapsule(capsuleId)
3177   - local capsule = self.capsules[capsuleId] or {}
3178   - return capsule:data()
  3182 + function Role:joinCapsule(roleId, capsuleId)
  3183 + local capsule = self.capsules[capsuleId]
  3184 + if not capsule then return nil end
  3185 +
  3186 + return capsule:data(roleId)
3179 3187 end
3180 3188  
3181 3189 function Role:checkCapsule(now)
... ... @@ -3186,6 +3194,58 @@ function RolePlugin.bind(Role)
3186 3194 end
3187 3195 end
3188 3196 end
  3197 +
  3198 + function Role:goodStock(capsuleId)
  3199 + local capsule = self.capsules[capsuleId]
  3200 + if not capsule then return 0 end
  3201 +
  3202 + return capsule:getGoodsAmount(), capsule:getProperty("token")
  3203 + end
  3204 +
  3205 + function Role:getCapsuleData(roleId, capsuleId)
  3206 + local capsule = self.capsules[capsuleId]
  3207 + if not capsule then return nil end
  3208 +
  3209 + return capsule:data(roleId)
  3210 + end
  3211 +
  3212 + function Role:resetCapsule()
  3213 + local roleId = self:getProperty("id")
  3214 + local res = redisproxy:smembers(CAPSULE_ID_ROLE:format(roleId)) or {}
  3215 + for _, key in pairs(res) do
  3216 + redisproxy:del(CAPSULE_ROLE:format(roleId, tonumber(key)))
  3217 + redisproxy:srem(CAPSULE_ID_ROLE, key)
  3218 + end
  3219 +
  3220 + for _, data in pairs(csvdb["ichibankuji_mainCsv"]) do
  3221 + for _, val in pairs(data) do
  3222 + if val.typ == 0 then
  3223 + local key = val.id..val.room
  3224 + if not self.capsules[key] then
  3225 + local capsule = require("models.Capsule").new({ key = CAPSULE_ROLE:format(roleId, tonumber(key)), id= val.id, room = val.room, typ = 0, name=val.name})
  3226 + capsule:init()
  3227 + capsule:create()
  3228 + self.capsules[key] = capsule
  3229 + redisproxy.sadd(CAPSULE_ID_ROLE:format(roleId), key)
  3230 + end
  3231 + end
  3232 + end
  3233 + end
  3234 + end
  3235 +
  3236 + function Role:pageRecord(capsuleId, up, idx)
  3237 + local capsule = self.capsules[capsuleId]
  3238 + if not capsule then return nil end
  3239 +
  3240 + return capsule:pageRecord(up, idx)
  3241 + end
  3242 +
  3243 + function Role:getSpecialNotify(roleId, capsuleId)
  3244 + local capsule = self.capsules[capsuleId]
  3245 + if not capsule then return nil end
  3246 +
  3247 + return capsule:getSpecialNotify(roleId)
  3248 + end
3189 3249 end
3190 3250  
3191 3251 return RolePlugin
3192 3252 \ No newline at end of file
... ...
src/models/Store.lua
... ... @@ -474,7 +474,7 @@ function Store:onBuyCard(type, duration, id, actid)
474 474 self:updateProperty({field = "bpInfo", value = bpInfo})
475 475 elseif type == CardType.ActBattleCommandCard then
476 476 if not self.owner.activity:isOpenById(actid, "ActShopGoods") then
477   - return
  477 + return nil
478 478 end
479 479 local actCfg = csvdb["activity_ctrlCsv"][actid]
480 480 if not actCfg then return end
... ... @@ -486,6 +486,10 @@ function Store:onBuyCard(type, duration, id, actid)
486 486 end
487 487 self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0})
488 488 self.owner.activity:updateActData("BattleCommand", actData)
  489 + local rechargeData = csvdb["shop_rechargeCsv"][id]
  490 + if rechargeData then
  491 + return self.owner:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
  492 + end
489 493 end
490 494 return nil, nil
491 495 end
... ...
src/services/agent_ctrl.lua
... ... @@ -141,10 +141,11 @@ function _M:check_agent_status()
141 141 end
142 142 end
143 143  
  144 + local count = table_nums(self.u2f)
  145 + datacenter.set("onlineCount", count)
144 146 if now >= next_log_time and now % 60 == 0 then
145 147 next_log_time = now + 60
146   - local count = table_nums(self.u2f)
147   - datacenter.set("onlineCount", count)
  148 + --datacenter.set("onlineCount", count)
148 149 logproxy:log({["@type"] = "online", count = count}, "log")
149 150 end
150 151 end
... ...
src/services/capsuled.lua
... ... @@ -16,27 +16,44 @@ NotifyChangeType = {
16 16 EXIT = 2,
17 17 DRAW = 3,
18 18 SPECIAL = 4,
19   - INCENTIVE = 5,
  19 +}
  20 +
  21 +skynet.register_protocol {
  22 + name = "role",
  23 + id = 101,
  24 + pack = skynet.pack,
  25 + unpack = skynet.unpack,
20 26 }
21 27  
22 28 local function rpcRole(roleId, funcName, ...)
23 29 local fields = ...
24 30 local agent = datacenter.get("agent", roleId)
25   - local roleCross = require("models.RoleCross")
26   - if funcName == "getProperties" then
27   - return roleCross.handle(funcName, roleId, fields)
  31 + if agent and agent.serv then
  32 + if funcName == "getProperties" then
  33 + return true, skynet.call(agent.serv, "role", funcName, fields)
  34 + else
  35 + return true, skynet.call(agent.serv, "role", funcName, ...)
  36 + end
28 37 else
29   - return roleCross.handle(funcName, roleId, ...)
  38 + local roleCross = require("models.RoleCross")
  39 + if funcName == "getProperties" then
  40 + return false, roleCross.handle(funcName, roleId, fields)
  41 + else
  42 + return false, roleCross.handle(funcName, roleId, ...)
  43 + end
30 44 end
31 45 end
32 46  
33 47 function getNameByRoleId(roleId)
34   - return rpcRole(roleId, "getProperty", "name")
  48 + local status, name = rpcRole(roleId, "getProperty", "name")
  49 + return name
35 50  
36 51 end
37 52  
38 53 function broadCastCapsule(roleId, capsuleId, broadInfo)
39   - local capsule = capsules[capsuleId] or {}
  54 + local capsule = capsules[capsuleId]
  55 + if not capsule then print("not capsule :" .. capsuleId) return end
  56 +
40 57 local register = capsule:getProperty("register") or {}
41 58 if next(capsule) then
42 59 for id, _ in pairs(register) do
... ... @@ -47,25 +64,39 @@ function broadCastCapsule(roleId, capsuleId, broadInfo)
47 64 end
48 65 end
49 66  
50   -local function getCapsuleId(id, room)
51   - return string.format("%d%d", id, room)
52   -end
  67 +function broadCastSpecial(roleId, capsuleId, broadInfo)
  68 + if not broadInfo or not next(broadInfo) then return end
  69 + local capsule = capsules[capsuleId]
  70 + if not capsule then skynet.error("not capsule: " .. capsuleId) return end
53 71  
  72 + local register = capsule:getProperty("register") or {}
  73 + for id, _ in pairs(register) do
  74 + if id ~= roleId then
  75 + if broadInfo[id] then
  76 + rpcRole(id, "paySpecialReward", id, broadInfo[id])
  77 + end
  78 + end
  79 + end
  80 +end
54 81  
55 82 local function add(roleId, capsuleId)
56   - local capsule = capsules[capsuleId] or {}
  83 + local capsule = capsules[capsuleId]
  84 + if not capsule then skynet.error("add not capsule: " .. capsuleId) return end
57 85 if next(capsule) then
58 86 capsule:join(roleId)
59   - broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.JOIN, roleId = roleId})
  87 + broadCastCapsule(roleId, capsuleId, {notifyType= NotifyChangeType.JOIN, roleId = roleId})
60 88 return capsule:data(roleId)
61 89 end
62 90 print("id 不存在: ".. capsuleId)
63 91 return nil
64 92 end
65 93  
66   -local function capsuleRefreshing()
  94 +local function capsuleRefreshing(now)
67 95 for _, v in pairs(capsules) do
68   - if v:refreshing() then
  96 + if v:refreshing(now) then
  97 + print("刷新机器looooook....")
  98 + print(v:getProperty("id"))
  99 + print(v:getProperty("room"))
69 100 v:init()
70 101 v:create()
71 102 end
... ... @@ -74,8 +105,31 @@ end
74 105  
75 106 --扭蛋机刷新
76 107 local function check_capsules()
77   - pcall(capsuleRefreshing)
78   - skynet.timeout(60, check_capsules)
  108 + local now = skynet.timex()
  109 + pcall(capsuleRefreshing, now)
  110 + skynet.timeout(100, check_capsules)
  111 +end
  112 +
  113 +function CMD.reset()
  114 + local now = skynet.timex()
  115 + local res = redisproxy:smembers(CAPSULE_INFO) or {}
  116 + for _, key in pairs(res) do
  117 + redisproxy:del(CAPSULE_PUBLIC:format(key))
  118 + redisproxy:srem(CAPSULE_INFO, key)
  119 + end
  120 +
  121 + for _, data in pairs(csvdb["ichibankuji_mainCsv"]) do
  122 + for _, val in ipairs(data) do
  123 + if val.type == 1 then
  124 + local key = val.id..val.room
  125 + local capsule = require("models.Capsule").new({ key = CAPSULE_PUBLIC:format(key), id= val.id, room = val.room, typ = 1, name=val.name})
  126 + capsule:init()
  127 + capsule:create()
  128 + capsules[key] = capsule
  129 + redisproxy:sadd(CAPSULE_INFO, key)
  130 + end
  131 + end
  132 + end
79 133 end
80 134  
81 135 function CMD.start()
... ... @@ -101,11 +155,14 @@ function CMD.start()
101 155 if val.type == 1 then
102 156 local key = val.id..val.room
103 157 if not capsules[key] then
104   - local capsule = require("models.Capsule").new({ key = CAPSULE_PUBLIC:format(key), id= val.id, room = val.room, typ = 1, name=val.name})
105   - capsule:init()
106   - capsule:create()
107   - capsules[key] = capsule
108   - redisproxy:sadd(CAPSULE_INFO, key)
  158 + if now < val.hide_time then
  159 + local capsule = require("models.Capsule").new({ key = CAPSULE_PUBLIC:format(key), id= val.id, room = val.room, typ = 1, name=val.name})
  160 + capsule:init()
  161 + capsule:create()
  162 +
  163 + capsules[key] = capsule
  164 + redisproxy:sadd(CAPSULE_INFO, key)
  165 + end
109 166 end
110 167 end
111 168 end
... ... @@ -114,10 +171,10 @@ function CMD.start()
114 171 check_capsules()
115 172 end
116 173  
117   -function CMD.list(coin)
  174 +function CMD.list(id)
118 175 local tmpCapsules = {}
119 176 for k, v in pairs(capsules) do
120   - if v:getProperty("coin") == coin then
  177 + if v:getProperty("id") == id then
121 178 local onlineCount= v:getOnlineCount()
122 179 tmpCapsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")}
123 180 end
... ... @@ -135,39 +192,74 @@ end
135 192  
136 193 function CMD.exit(roleId, capsuleId)
137 194 if capsuleId then
138   - local capsule = capsules[capsuleId] or {}
139   - if next(capsule) then
140   - capsule:exit(roleId)
141   - broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.EXIT, roleId = roleId})
142   - end
  195 + local capsule = capsules[capsuleId]
  196 + if not capsule then skynet.error("not capsule: " .. capsuleId) return end
  197 +
  198 + capsule:exit(roleId)
  199 + broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.EXIT, roleId = roleId})
143 200 else
144   - for _, capsule in pairs(capsules) do
  201 + for id, capsule in pairs(capsules) do
145 202 if next(capsule) then
146 203 capsule:exit(roleId)
147   - broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.EXIT, roleId = roleId})
  204 + broadCastCapsule(roleId, id, {notifyType = NotifyChangeType.EXIT, roleId = roleId})
148 205 end
149 206 end
150 207 end
151 208 end
152 209  
153   -function CMD.draw_capsule(roleId, capsuleId, full, cares)
154   - local capsule = capsules[capsuleId] or {}
155   - if next(capsule) then
156   - local ret, reward, rewardByGoods, notify = capsule:draw(roleId, full, cares)
157   - --if ret > 4 then
158   - -- broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.DRAW, roleId = roleId, notify = notify})
159   - --end
160   - return ret, reward, rewardByGoods, capsule:data(roleId)
  210 +function CMD.draw_capsule(roleId, capsuleId, full, drawsNum, cares)
  211 + local capsule = capsules[capsuleId]
  212 + if not capsule then skynet.error("not capsule: " .. capsuleId) return 2 end
  213 +
  214 + local ret, drawReward = capsule:draw(roleId, full, drawsNum, cares)
  215 + if ret > 5 then
  216 + --broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.DRAW, notify = notify})
  217 + broadCastSpecial(roleId, capsuleId, drawReward["specials"])
161 218 end
162   - return 1
  219 + drawReward["specials"] = nil
  220 + return ret, drawReward, capsule:data(roleId)
163 221 end
164 222  
165 223 function CMD.register(roleId, capsuleId)
166   - local capsule = capsules[capsuleId] or {}
167   - if next(capsule) then
168   - return capsule:register(roleId)
169   - end
170   - return nil
  224 + local capsule = capsules[capsuleId]
  225 + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end
  226 +
  227 + return capsule:register(roleId)
  228 +end
  229 +
  230 +function CMD.goods_stock(capsuleId)
  231 + local capsule = capsules[capsuleId]
  232 + if not capsule then skynet.error("not capsule: " .. capsuleId) return 0 end
  233 +
  234 + return capsule:getGoodsAmount(), capsule:getProperty("token")
  235 +end
  236 +
  237 +function CMD.capsule_data(roleId, capsuleId)
  238 + local capsule = capsules[capsuleId]
  239 + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end
  240 +
  241 + return capsule:data(roleId)
  242 +end
  243 +
  244 +function CMD.page_record(capsuleId, up, idx)
  245 + local capsule = capsules[capsuleId]
  246 + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end
  247 +
  248 + return capsule:pageRecord(up, idx)
  249 +end
  250 +
  251 +function CMD.get_special_nty(roleId, capsuleId)
  252 + local capsule = capsules[capsuleId]
  253 + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end
  254 +
  255 + return capsule:getSpecialNotify(roleId)
  256 +end
  257 +
  258 +function CMD.clear_special_nty(roleId, capsuleId, good_ids)
  259 + local capsule = capsules[capsuleId]
  260 + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end
  261 +
  262 + return capsule:clearSpecialNty(roleId, good_ids)
171 263 end
172 264  
173 265 skynet.start(function()
... ...
src/services/watchdog.lua
... ... @@ -56,7 +56,7 @@ end
56 56  
57 57 -- 创建world以及union channel 用于广播
58 58 function create_mutilcast()
59   - for i = 1, 10 do
  59 + for i = 1, 50 do
60 60 local chan_w = mc:new()
61 61 datacenter.set("MC_W_CHANNEL" .. i, chan_w.channel)
62 62 end
... ...