Commit 08575c686e42858a2e2e00477348687f061751d6

Authored by jiyue
2 parents e08b052f e66080dd

Merge branch 'cn/develop' into cn/player

robot/robot.lua
... ... @@ -136,6 +136,18 @@ function CMD.task()
136 136 startUnit()
137 137 end
138 138  
  139 +function randomName()
  140 + local str = "1234567890abcdefghijklmnopqrstuvwxyz"
  141 + local len = #str
  142 + local result = ""
  143 + for i=1,10 do
  144 + local idx = math.random(1, len)
  145 + result = result .. string.sub(str, idx, idx)
  146 + end
  147 +
  148 + return result
  149 +end
  150 +
139 151 -- 开始登录
140 152 function CMD.start(fd, id)
141 153 client.fd = fd
... ...
src/GlobalVar.lua
... ... @@ -133,7 +133,7 @@ ItemStartId = {
133 133 --常用的物品id的枚举
134 134 ItemId = {
135 135 Gold = 1, -- 金币
136   - Exp = 2, -- 经验
  136 + Exp = 2, -- 能量饮料
137 137 Jade = 3, -- 虹光玉
138 138 PlayerExp = 4, -- 突破材料
139 139 FriendPoint = 5, -- 友情点
... ... @@ -371,6 +371,8 @@ MailId = {
371 371 CBBackAward2 = 244,
372 372 ActivityPoolRet = 280,
373 373 MyCardBuy = 300,
  374 +
  375 + RechargeBack = 3001,
374 376 }
375 377  
376 378 TriggerEventType = {
... ... @@ -383,6 +385,13 @@ TriggerEventType = {
383 385 AfterTs = 7, -- 某时间以后
384 386 DrawHeroCnt = 8, -- 每日抽卡次数
385 387 Appoint = 0, -- 触发指定id礼包
  388 + SignIn = 9, -- 签到
  389 + DrawHero = 10, -- 循环抽卡
  390 + FoodSell = 11, -- 循环卖菜
  391 + RuneUp = 12, -- 循环强化符文
  392 + CostDiamond = 13, -- 循环消耗钻石
  393 + BuyLimitPack = 14, --购买指定id礼包 触发
  394 + HeroTalent = 15, --英雄精进 触发礼包
386 395 }
387 396  
388 397 DrawCardType = {
... ... @@ -424,6 +433,8 @@ SystemBnousType = {
424 433 UpSpeedNum = 15, -- 加速次数上限增加 15=1探索加速or 2齿轮加速or 3餐厅加速=增加次数
425 434 ChangeBaseCount = 16, -- 每日奖励关卡挑战卡基础数量增加
426 435 ChangeBuyCount = 17, -- 每日奖励关卡挑战卡可购买次数增加,
  436 + ExtraProp = 18, -- 每次探索加速额外获得道具
  437 + AccountLevel = 19, -- 账号等级提升角色等级上限
427 438 }
428 439  
429 440 -- 开箱物品类型
... ... @@ -435,4 +446,12 @@ ItemOccupy = {
435 446 Spark = 5, --火花
436 447 Other = 6,
437 448 CanUsed = 7, --可使用
  449 +}
  450 +
  451 +-- 世界变动积分
  452 +ItemWorldLine = {
  453 + RouletteCount = 1, --抽轮盘次数
  454 + Points = 2, --积分
  455 + CostDiamond = 3, --消耗钻石
  456 + CostJade = 4, --消耗红光玉
438 457 }
439 458 \ No newline at end of file
... ...
src/ProtocolCode.lua
... ... @@ -13,6 +13,8 @@ actionCodes = {
13 13 Gm_clientRequest = 20,
14 14 Gm_receiveResponse = 21,
15 15 Gm_helpRpc = 22,
  16 + Gm_clientLuaCommandNtf = 23,
  17 + Gm_clientUploadLuaResult = 24,
16 18  
17 19 Role_notifyNewEvent = 100,
18 20 Role_queryLoginRpc = 101,
... ... @@ -59,7 +61,9 @@ actionCodes = {
59 61 Role_runeBuyRpc = 142, -- 铭文购买
60 62 Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍
61 63 Role_setBgRpc = 144, -- 设置看板娘
62   - Role_itemConvertMonthCardRpc = 145, -- 兑换月卡道具
  64 + Role_itemConvertSpecialRpc = 145, -- 兑换月卡/战令探索指令等 特殊道具
  65 + Role_worldLineRoulette = 146, --世界线抽轮盘
  66 + Role_worldLineReward = 147, -- 世界线一键领取奖励
63 67  
64 68 Adv_startAdvRpc = 151,
65 69 Adv_startHangRpc = 152,
... ... @@ -225,6 +229,7 @@ actionCodes = {
225 229 Store_getExploreCommandRewardRpc = 563, --探索指令
226 230 Store_getTotalRechargeAwardRpc = 564, -- 累计充值
227 231 Store_monthCardRewardRpc = 565, --每日月卡+特刊奖励
  232 + Store_dyhxAndroidRechargeRpc = 566, -- 东银河充值
228 233  
229 234 Store_biliCloudRechargeRpc = 596,
230 235 Store_biliAndroidRechargeRpc = 597,
... ... @@ -245,7 +250,7 @@ actionCodes = {
245 250 Activity_actCalendaTaskRpc = 655,
246 251 Activity_actPaySignRpc = 656,
247 252 Activity_exchangeRpc = 657,
248   - Activity_gachakonRpc = 658,
  253 + Activity_gachakonRpc = 658, --狩猎祭 抽扭蛋机
249 254 Activity_hangDropRpc = 659,
250 255 Activity_startBattleRpc = 660,
251 256 Activity_endBattleRpc = 661,
... ... @@ -263,6 +268,7 @@ actionCodes = {
263 268 Activity_returnerTaskRpc = 673,
264 269 Activity_actNewUserTaskRpc = 674,
265 270 Activity_buyBattleTicketRpc = 675,
  271 + Activity_resetGachakonRpc = 676, --狩猎祭,重制扭蛋机
266 272  
267 273 Radio_startQuestRpc = 700,
268 274 Radio_finishQuestRpc = 701,
... ... @@ -281,10 +287,12 @@ actionCodes = {
281 287 Capsule_drawRpc = 854, --抽扭蛋机
282 288 --Capsule_switchRoomRpc = 855, --切换扭蛋机房间
283 289 Capsule_notifyChange = 856, -- 通知信息变动
284   - Capsule_payReward = 857, -- 特殊赏 奖励通知
  290 + Capsule_specialRewardRpc = 857, -- 获取 未领取特殊赏通知 主动
285 291 Capsule_exitRpc = 858, -- 退出
286 292 Capsule_getDataRpc = 859, --获取扭蛋机信息
287   - Capsule_convertCapsuleRpc = 890, --兑换消耗票
  293 + Capsule_convertCapsuleRpc = 860, --兑换消耗票
  294 + Capsule_pageRecordRpc = 861, --抽奖记录分页查询
  295 + Capsule_clearSpecialNtyRpc = 862, --消除特殊赏通知
288 296 }
289 297  
290 298 rpcResponseBegin = 10000
... ...
src/actions/ActivityAction.lua
... ... @@ -315,7 +315,27 @@ function _M.actBattleCommandTaskRpc(agent, data)
315 315  
316 316 role:updateProperty({field = "bcTask", value = calTask})
317 317  
318   - local reward, change = role:award(taskCfg.reward, {log = {desc = "battleCommandTask"}})
  318 + local rechargeRecord = role.storeData:getProperty("payR") or {}
  319 + local recordFlag = false
  320 + for _, id in ipairs(taskCfg.battlepass_id:toArray(true, "=")) do
  321 + if rechargeRecord[id] then
  322 + local cfg = csvdb["shop_rechargeCsv"][id]
  323 + if cfg and cfg.shop == 2 and cfg.type == CardType.ActBattleCommandCard then
  324 + recordFlag = true
  325 + break
  326 + end
  327 + end
  328 + end
  329 +
  330 + local taskReward = {}
  331 + if recordFlag then
  332 + for k, v in pairs(taskCfg.reward:toNumMap()) do
  333 + taskReward[k] = (taskReward[k] or 0) + v + taskCfg.battlepass_reward
  334 + break
  335 + end
  336 + end
  337 +
  338 + local reward, change = role:award(taskReward, {log = {desc = "battleCommandTask"}})
319 339  
320 340 role:log("activity", {
321 341 activity_id = taskId, -- 活动ID(或活动指定任务的ID)
... ... @@ -479,6 +499,20 @@ function _M.gachakonRpc(agent, data)
479 499 return true
480 500 end
481 501  
  502 +function _M.resetGachakonRpc(agent, data)
  503 + local role = agent.role
  504 + local msg = MsgPack.unpack(data)
  505 + local actid = msg.actid
  506 +
  507 + if not role.activity:isOpenById(actid, "Gachakon") then return 1 end
  508 +
  509 + if role.activity:isResetById(actid, "Gachakon") then return 2 end
  510 + role.activity:resetActDataById(actid)
  511 +
  512 + SendPacket(actionCodes.Activity_resetGachakonRpc, MsgPack.pack({}))
  513 + return true
  514 +end
  515 +
482 516 function _M.hangDropRpc(agent, data)
483 517 local role = agent.role
484 518 local msg = MsgPack.unpack(data)
... ... @@ -605,6 +639,8 @@ function _M.startBattleRpc(agent, data)
605 639 end
606 640 end
607 641 num = num * count
  642 + else
  643 + num = 0
608 644 end
609 645 if ticket < num then
610 646 return 6
... ... @@ -643,7 +679,7 @@ function _M.startBattleRpc(agent, data)
643 679 award[k] = v * count
644 680 end
645 681 local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}})
646   - SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change)))
  682 +
647 683 changeFlag = true
648 684 actData["ticket"] = ticket - num
649 685  
... ... @@ -663,11 +699,15 @@ function _M.startBattleRpc(agent, data)
663 699 end
664 700 role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal)
665 701 end
  702 + role.activity:updateActData("ChallengeLevel", actData)
666 703  
  704 + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change)))
  705 +
  706 + return true
667 707 end
668   - if changeFlag then
669   - role.activity:updateActData("ChallengeLevel", actData)
670   - end
  708 + --if changeFlag then
  709 + -- role.activity:updateActData("ChallengeLevel", actData)
  710 + --end
671 711  
672 712 return true
673 713 end
... ... @@ -801,10 +841,12 @@ function _M.endBattleRpc(agent, data)
801 841 end
802 842  
803 843 if battleCfg.rank ~= 0 and isWin then
804   - -- 消耗门票
805   - role.activity:getBattleTicket(actid)
806   - local num = battleCfg.type:toArray(true, "=")[3]
807   - actData["ticket"] = math.max(actData["ticket"] - num, 0)
  844 + if battleCfg.type ~= "" then
  845 + -- 消耗门票
  846 + role.activity:getBattleTicket(actid)
  847 + local num = battleCfg.type:toArray(true, "=")[3]
  848 + actData["ticket"] = math.max(actData["ticket"] - num, 0)
  849 + end
808 850  
809 851 -- 更新排行榜 最高伤害
810 852 battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg)
... ... @@ -1337,8 +1379,8 @@ function _M.buyBattleCommandLvlRpc(agent, data)
1337 1379 end
1338 1380 if cost == 0 then return 5 end
1339 1381  
1340   - if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 6 end
1341   - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}})
  1382 + if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 6 end
  1383 + role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}})
1342 1384 actData["lvl"] = nextLvl
1343 1385 role.activity:updateActData("BattleCommand", actData)
1344 1386 role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl})
... ... @@ -1486,7 +1528,7 @@ function _M.buyBattleTicketRpc(agent, data)
1486 1528 end
1487 1529 local cost = globalCsv.activity_scrofa_tickets[curCount + 1]
1488 1530 if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end
1489   - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyActivityBattleTicket", int1 = actid, int2 = count, cint1 = curCount}})
  1531 + role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyActivityBattleTicket", int1 = actid, int2 = count, long1 = curCount}})
1490 1532 actData["ticket"] = (actData["ticket"] or 0) + 1
1491 1533 actData["buyC"] = curCount + count
1492 1534  
... ...
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
... ... @@ -96,7 +96,7 @@ function _M.drawRpc(agent, data)
96 96 local full = msg.full or 0-- 0=单次,1=十连抽 2=全收
97 97 local cares = msg.cares
98 98  
99   - local ret, token, reward, change, rewardByGoods, capsule
  99 + local ret, token, change, drawReward, capsule
100 100  
101 101 --检查库存
102 102 if typ == 1 then
... ... @@ -127,26 +127,23 @@ function _M.drawRpc(agent, data)
127 127  
128 128 --开始抽奖
129 129 if typ == 1 then
130   - 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)
131 131 else
132   - ret, reward, rewardByGoods, capsule= role:drawCapsule(capsuleId, full, cares)
  132 + ret, drawReward, capsule = role:drawCapsule(capsuleId, full, cares)
133 133 end
134 134 if ret < 5 then
135 135 return ret
136 136 end
137 137  
138   - --dump(rewardByGoods)
139   - --dump(capsule)
140   -
141 138 if ret == 5 then
142   - SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({change = reward, capsule = capsule}))
  139 + SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({change = drawReward, capsule = capsule}))
143 140 return true
144 141 end
145 142  
146   - -- rewardByGoods是抽到的扭蛋信息,reward是抽扭蛋后获得的所有奖励信息。
147   - if rewardByGoods and next(rewardByGoods) then
148   - reward, change = role:award(reward, {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}})
149   - SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({reward = rewardByGoods, capsule = capsule}))
  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))
150 147 else
151 148 return ret
152 149 end
... ... @@ -164,7 +161,7 @@ function _M.getDataRpc(agent, data)
164 161 if typ == 1 then
165 162 capsule = skynet.call(agent.capsule_serv, "lua", "capsule_data", roleId, capsuleId)
166 163 else
167   - capsule = role:getCapsuleData(capsuleId)
  164 + capsule = role:getCapsuleData(roleId, capsuleId)
168 165 end
169 166 if not capsule then return 1 end
170 167  
... ... @@ -190,9 +187,67 @@ function _M.convertCapsuleRpc(agent, data)
190 187 if not role:checkItemEnough(cost) then return 1 end
191 188 role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}})
192 189  
193   - local reward, change = role:award({coin = count}, {log = {desc = "CapsuleConvert"}})
  190 +
  191 + local reward, change = role:award({[coin]= count}, {log = {desc = "CapsuleConvert"}})
194 192 SendPacket(actionCodes.Capsule_convertCapsuleRpc, MsgPack.pack(role:packReward(reward, change)))
195 193 return true
196 194 end
197 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= 公开
  203 +
  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)
  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")
  222 +
  223 + local ret
  224 + if typ == 1 then
  225 + ret = skynet.call(agent.capsule_serv, "lua", "get_special_nty", roleId, capsuleId)
  226 + else
  227 + ret = role:getSpecialNotify(roleId, capsuleId)
  228 + end
  229 + if not ret or not next(ret) then return 1 end
  230 +
  231 + SendPacket(actionCodes.Capsule_specialRewardRpc, MsgPack.pack({special= ret}))
  232 + return true
  233 +end
  234 +
  235 +function _M.clearSpecialNtyRpc(agent, data)
  236 + local role = agent.role
  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
  241 + local roleId = role:getProperty("id")
  242 +
  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({}))
  250 + return true
  251 +end
  252 +
198 253 return _M
199 254 \ No newline at end of file
... ...
src/actions/GmAction.lua
... ... @@ -675,6 +675,13 @@ function _M.helpRpc(agent, data)
675 675 return true
676 676 end
677 677  
  678 +function _M.clientUploadLuaResult(agent, data)
  679 + local role = agent.role
  680 + local msg = MsgPack.unpack(data)
  681 + role:mylog("gm_action", {desc = "upload_lua", int1 = id, key1 = msg.result})
  682 + return true
  683 +end
  684 +
678 685 function _M.test(role, pms)
679 686 local id = tonum(pms.pm1, 0)
680 687 local actid = nil
... ... @@ -722,6 +729,8 @@ function _M.cz(role, pms)
722 729 pay_time = skynet.timex(),
723 730 sid = sid == 1 and IOS_SID or 0,
724 731 })
  732 + -- 补发邮件
  733 + role:sendMail(MailId.RechargeBack)
725 734 role:mylog("gm_action", {desc = "recharge", int1 = id, key1 = pms.sender})
726 735 return "指令成功"
727 736 end
... ... @@ -1086,4 +1095,10 @@ function _M.reset_capsule(role, pms, capsule_serv)
1086 1095 return "成功"
1087 1096 end
1088 1097  
  1098 +function _M.do_lua(role, pms)
  1099 + local luaStr = pms.pm1
  1100 + SendPacket(actionCodes.Gm_clientLuaCommandNtf, MsgPack.pack({lua = luaStr}))
  1101 + return "成功"
  1102 +end
  1103 +
1089 1104 return _M
1090 1105 \ No newline at end of file
... ...
src/actions/HangAction.lua
... ... @@ -528,16 +528,20 @@ function _M.quickRpc(agent , data)
528 528 end
529 529  
530 530 --宝藏加速
531   - local treasureList= role.dailyData:quickTreasureList(hangInfo.carbonId, time) or {}
532   - if next(treasureList) then
533   - for id, val in pairs(treasureList) do
534   - local award = val.award:toNumMap()
535   - for k,v in pairs(award) do
536   - reward[k] = (reward[k] or 0) + v
537   - end
  531 + local treasureList = role.dailyData:quickTreasureList(hangInfo.carbonId, time) or {}
  532 + for id, val in pairs(treasureList) do
  533 + local award = val.award:toNumMap()
  534 + for k,v in pairs(award) do
  535 + reward[k] = (reward[k] or 0) + v
538 536 end
539 537 end
540 538  
  539 + --等级 额外奖励
  540 + local levelReward = role:getExtraProp()
  541 + for k, v in pairs(levelReward or {}) do
  542 + reward[k] = (reward[k] or 0) + v
  543 + end
  544 +
541 545 local change
542 546 reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
543 547 if reward[ItemId.Gold] then
... ...
src/actions/HeroAction.lua
... ... @@ -42,10 +42,14 @@ function _M.levelUpRpc( agent, data )
42 42 if not role:checkItemEnough(cost) then return 3 end
43 43  
44 44 -- 通过指定关卡后才能升级英雄等级
45   - local pass = globalCsv.unit_exp_level_pass[level + 1]
46   - if pass then
47   - if not role:checkHangPass(pass) then return 4 end
48   - end
  45 + --local pass = globalCsv.unit_exp_level_pass[level + 1]
  46 + --if pass then
  47 + -- if not role:checkHangPass(pass) then return 4 end
  48 + --end
  49 +
  50 + --账号等级提升角色等级上限
  51 + local accountLevel = role:getAccountLevel()
  52 + if level >= accountLevel then return 4 end
49 53  
50 54 role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}})
51 55  
... ... @@ -86,10 +90,10 @@ function _M.breakRpc( agent, data )
86 90 if not role:checkItemEnough(cost) then return 4 end
87 91  
88 92 -- 通过指定关卡后才能突破英雄
89   - local pass = globalCsv.unit_break_level_pass[breakL + 1]
90   - if pass then
91   - if not role:checkHangPass(pass) then return 4 end
92   - end
  93 + --local pass = globalCsv.unit_break_level_pass[breakL + 1]
  94 + --if pass then
  95 + -- if not role:checkHangPass(pass) then return 4 end
  96 + --end
93 97  
94 98 role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}})
95 99 local oldAttr = hero:getTotalAttrs()
... ... @@ -147,9 +151,11 @@ function _M.wakeRpc(agent, data)
147 151 local oldBattleV = hero:getProperty("battleV")
148 152 hero:updateProperty({field = "wakeL", delta = 1})
149 153  
150   - role:checkTaskEnter("Wake", {heroType = typ, wakeL = curLevel + 1})
  154 + curLevel = curLevel + 1
  155 + role:checkTaskEnter("Wake", {heroType = typ, wakeL = curLevel})
151 156 if curLevel == 3 then -- 解锁cg
152 157 role:checkTaskEnter("WakeCG", {heroType = typ})
  158 + role:checkTaskEnter("WakeCGSum", {count = 1})
153 159 end
154 160  
155 161 if curLevel >= 4 then --自动觉醒技能
... ... @@ -173,6 +179,7 @@ function _M.wakeRpc(agent, data)
173 179 SendPacket(actionCodes.Hero_wakeRpc, '')
174 180  
175 181 role:checkTaskEnter("HeroStarCollect", {})
  182 + role:checkTaskEnter("HeroStartSum", {})
176 183 return true
177 184 end
178 185  
... ... @@ -212,7 +219,7 @@ function _M.talentRpc(agent, data)
212 219 talent = talent:setv(1, curLevel + 1)
213 220 end
214 221 curStage = talent:getv(0, 1)
215   - role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = curStage})
  222 + role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = curStage, count = 1})
216 223  
217 224 hero:updateProperty({field = "talent", value = talent})
218 225  
... ...
src/actions/HttpAction.lua
... ... @@ -143,7 +143,7 @@ function _M.gm_action(query)
143 143 role:startActionUcode()
144 144 local status = gmFuncs[query.cmd](role, query)
145 145 role:endActionUcode()
146   - role:update()
  146 + role:saveRoleData()
147 147  
148 148 return status
149 149 end
... ... @@ -174,6 +174,7 @@ function _M.pay_action(query)
174 174 role:startActionUcode()
175 175 local status = gmFuncs[query.cmd](role, query)
176 176 role:endActionUcode()
  177 + role:saveRoleData()
177 178  
178 179 return status
179 180 end
... ...
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,36 +1712,112 @@ function _M.setBgRpc(agent, data)
1710 1712 return true
1711 1713 end
1712 1714  
1713   -function _M.itemConvertMonthCardRpc(agent, data)
  1715 +function _M.itemConvertSpecialRpc(agent, data)
1714 1716 local role = agent.role
1715 1717 local msg = MsgPack.unpack(data)
1716 1718 local itemId = msg.item_id
1717   - local typ = msg.typ
1718   - local count = msg.count
1719   - local exchangeId = msg.change_id
1720   -
1721   - if not ItemId[itemId] then return 1 end
  1719 + local exchangeId = tonumber(msg.exchange_id)
1722 1720  
1723   - if not role:checkItemEnough({[itemId] = count}) then return 2 end
1724   - role:costItems({[itemId] = count}, {log = {desc = "itemConvertmonthCard", int1 = count, int2 = count}})
  1721 + local itemData = csvdb["itemCsv"][itemId]
  1722 + if not itemData then return 1 end
1725 1723  
1726 1724 local rechargeData = csvdb["shop_rechargeCsv"][exchangeId]
1727 1725 if not rechargeData then
1728 1726 skynet.error("[recharge] recharge id not exist", exchangeId)
1729   - return 3
  1727 + return 2
1730 1728 end
1731   - local reward = {}
1732   - for i = 1, count do
1733   - local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.id , rechargeData.activity_id)
  1729 +
  1730 + if not role:checkItemEnough({[itemId] = 1}) then return 3 end
  1731 +
  1732 + local reward = {}
  1733 +
  1734 + if not role.storeData:checkRechargeRecord(rechargeData.limit, exchangeId)then
  1735 + return 5
  1736 + end
  1737 +
  1738 + if rechargeData.type == CardType.ActBattleCommandCard then
  1739 + if role.activity:isOpenById(rechargeData.activity_id, "ActShopGoods") then
  1740 + local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id)
  1741 + if tmpreward then
  1742 + table.rewardMerge(reward, tmpreward)
  1743 + end
  1744 + else
  1745 + skynet.error("not open id: ".. rechargeData.id .. "; actid: " .. rechargeData.activity_id)
  1746 + SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack({result = 4}))
  1747 + return true
  1748 + end
  1749 + else
  1750 + local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id)
1734 1751 if tmpreward then
1735 1752 table.rewardMerge(reward, tmpreward)
1736   - else
1737   - return
1738 1753 end
1739 1754 end
1740 1755  
1741   - SendPacket(actionCodes.Role_itemConvertMonthCardRpc, MsgPack.pack(role:packReward(reward)))
1742   - return status
  1756 + role:costItems({[itemId] = 1}, {log = {desc = "itemConvertSpecial", int1 = itemId, int2 = itemData.type}})
  1757 +
  1758 + SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack(role:packReward(reward)))
  1759 + return true
  1760 +end
  1761 +
  1762 +function _M.worldLineRoulette(agent, data)
  1763 + local role = agent.role
  1764 +
  1765 + local worldChangePoints = role:getProperty("worldChangePoints") or {}
  1766 + local rouletteCount = worldChangePoints[ItemWorldLine.RouletteCount] or 0
  1767 + if rouletteCount == 0 then return 1 end
  1768 +
  1769 + local worldline_gift_base_10, worldline_gift_base_1, worldline_gift_magnification_1, worldline_gift_magnification_0 = {}, {}, {}, {}
  1770 + for k, v in pairs(globalCsv.worldline_gift_base_10) do
  1771 + worldline_gift_base_10[k] = {v}
  1772 + end
  1773 + for k, v in pairs(globalCsv.worldline_gift_base_1) do
  1774 + worldline_gift_base_1[k] = {v}
  1775 + end
  1776 + for k, v in pairs(globalCsv.worldline_gift_magnification_1) do
  1777 + worldline_gift_magnification_1[k] = {v}
  1778 + end
  1779 + for k, v in pairs(globalCsv.worldline_gift_magnification_0) do
  1780 + worldline_gift_magnification_0[k] = {v}
  1781 + end
  1782 +
  1783 + local gift_base_10 = (math.randWeight(worldline_gift_base_10, 1) or 0) * 10
  1784 + local gift_base_1 = math.randWeight(worldline_gift_base_1, 1) or 0
  1785 +
  1786 + local gift_magnification_1 = math.randWeight(worldline_gift_magnification_1, 1) or 0
  1787 + local gift_magnification_0 = (math.randWeight(worldline_gift_magnification_0, 1) or 0) * (0.1)
  1788 +
  1789 + local points = math.floor((gift_base_10 + gift_base_1) * (gift_magnification_1 + gift_magnification_0))
  1790 + worldChangePoints[ItemWorldLine.RouletteCount] = worldChangePoints[ItemWorldLine.RouletteCount] - 1
  1791 + worldChangePoints[ItemWorldLine.Points] = worldChangePoints[ItemWorldLine.Points] + points
  1792 + role:updateProperty({field = "worldChangePoints", value = worldChangePoints})
  1793 +
  1794 + SendPacket(actionCodes.Role_worldLineRoulette, MsgPack.pack(worldChangePoints))
  1795 + return true
  1796 +end
  1797 +
  1798 +function _M.worldLineReward(agent, data)
  1799 + local role = agent.role
  1800 + local worldLineReward = role:getProperty("worldLineReward") or {}
  1801 + local worldChangePoints = role:getProperty("worldChangePoints") or {}
  1802 + local points = worldChangePoints[ItemWorldLine.Points] or 0
  1803 +
  1804 + local reward, change = {}
  1805 + for key, val in pairs(csvdb["worldline_rewardCsv"]) do
  1806 + if points >= key and not worldLineReward[key] then
  1807 + for k, v in pairs(val.award:toNumMap()) do
  1808 + reward[k] = (reward[k] or 0) + v
  1809 + end
  1810 + worldLineReward[key] = 1
  1811 + end
  1812 + end
  1813 +
  1814 + role:updateProperty({field = "worldLineReward", value = worldLineReward})
  1815 +
  1816 + if next(reward) then
  1817 + reward, change = role:award(reward, {log = {desc = "worldLine", int1 = role:getProperty("id")}})
  1818 + end
  1819 + SendPacket(actionCodes.Role_worldLineReward, MsgPack.pack(role:packReward(reward, change)))
  1820 + return true
1743 1821 end
1744 1822  
1745 1823 return _M
1746 1824 \ No newline at end of file
... ...
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/actions/StoreAction.lua
... ... @@ -52,6 +52,19 @@ local function signPms(params, secret_key)
52 52 return md5.sumhexa(urlCode .. secret_key):lower()
53 53 end
54 54  
  55 +local function signDyhPms(params, secret_key)
  56 + local keys = table_keys(params)
  57 + table.sort(keys)
  58 + local str2Sign = ""
  59 + for index, key in ipairs(keys) do
  60 + if str2Sign ~= "" then
  61 + str2Sign = str2Sign .. '&'
  62 + end
  63 + str2Sign = str2Sign .. string.format("%s=%s", key, params[key])
  64 + end
  65 + return md5.sumhexa(str2Sign .. secret_key):lower()
  66 +end
  67 +
55 68 -- bili android 充值 入口
56 69 function _M.biliAndroidRechargeRpc(agent, data)
57 70 local role = agent.role
... ... @@ -226,7 +239,7 @@ function _M.iosRechargeRpc(agent, data)
226 239 --创建订单号
227 240 local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
228 241 -- 签名
229   - local secret_key = "1916d62251dd4a8aa5e452121eefc9a1"
  242 + local secret_key = "2b2036e1f44640a59168c92462714870"
230 243 local need = {
231 244 out_trade_no = partnerOrderId,
232 245 money = dataSet.rmb * 100,
... ... @@ -234,12 +247,40 @@ function _M.iosRechargeRpc(agent, data)
234 247 product_id = dataSet.iap_product_id,
235 248 notify_url = msg.notifyUrl
236 249 }
237   - local sign = signPms(need, secret_key)
  250 + local sign = signDyhPms(need, secret_key)
238 251  
239 252 SendPacket(actionCodes.Store_iosRechargeRpc, MsgPack.pack({ order = partnerOrderId, sign = sign}))
240 253 return true
241 254 end
242 255  
  256 +-- dyh android 充值 入口
  257 +function _M.dyhxAndroidRechargeRpc(agent, data)
  258 + local role = agent.role
  259 + local msg = MsgPack.unpack(data)
  260 + local id = msg.id
  261 + local choose = msg.choose or ""
  262 + local dataSet = csvdb["shop_rechargeCsv"][id]
  263 + if not dataSet then return end
  264 + local roleId = role:getProperty("id")
  265 +
  266 + role.ignoreHeartbeat = true
  267 + --创建订单号
  268 + local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
  269 + -- 签名
  270 + local secret_key = "51ba4398c69d4d229d5402295dc38b50"
  271 + local need = {
  272 + out_trade_no = partnerOrderId,
  273 + money = dataSet.rmb * 100,
  274 + game_money = dataSet.diamond,
  275 + notify_url = msg.notifyUrl
  276 + }
  277 + local sign = signDyhPms(need, secret_key)
  278 +
  279 + SendPacket(actionCodes.Store_dyhxAndroidRechargeRpc, MsgPack.pack({ order = partnerOrderId, sign = sign}))
  280 + return true
  281 +end
  282 +
  283 +
243 284 function _M.purchaseOrderResult(agent, data)
244 285 local role = agent.role
245 286  
... ... @@ -315,7 +356,7 @@ function _M.shopBuyRpc(agent , data)
315 356 role.storeData:updateProperty({field = "buyR", value = buyRecord})
316 357 limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit)
317 358 end
318   - role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, cint1= dataSet.shop}})
  359 + role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}})
319 360  
320 361 local gift = {}
321 362 for _id, _count in pairs(dataSet.gift:toNumMap()) do
... ...
src/agent.lua
... ... @@ -35,10 +35,17 @@ local function handle_timeout()
35 35 skynet.timeout(100, handle_timeout)
36 36 end
37 37  
  38 +local function handle_gc()
  39 + if not agentInfo.open_timer then return end
  40 + collectgarbage("collect")
  41 + skynet.timeout(6000, handle_gc)
  42 +end
  43 +
38 44 function start_agent_timer()
39 45 if agentInfo.open_timer then return end
40 46 agentInfo.open_timer = true
41 47 skynet.timeout(150, handle_timeout)
  48 + skynet.timeout(6000, handle_gc)
42 49 end
43 50  
44 51 function cancel_agent_timer()
... ...
1   -Subproject commit 4d894270d4aeb6352a29dfd3a8686cbaea5b427c
  1 +Subproject commit 45264603ff07db4cd2eaf8822c17f453bf5f00de
... ...
src/models/Activity.lua
... ... @@ -93,6 +93,8 @@ Activity.schema = {
93 93  
94 94 act34 = {"table", {}}, -- 战令记录{unlock = 1, freeR = "", payR = "", lvl = 10, sum = 100}
95 95 act36 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1}
  96 +
  97 + reset20 = {"number", 1}, -- 重置扭蛋机
96 98 }
97 99  
98 100 function Activity:data()
... ... @@ -121,6 +123,8 @@ function Activity:data()
121 123  
122 124 act34 = self:getProperty("act34"),
123 125 act36 = self:getProperty("act36"),
  126 +
  127 + reset20 = self:getProperty("reset20")
124 128 }
125 129 end
126 130  
... ... @@ -207,6 +211,24 @@ function Activity:isOpenById(id, activityType)
207 211 return self._isOpen[id]
208 212 end
209 213  
  214 +function Activity:isResetById(id, activityType)
  215 + activityType = checkActivityType(activityType)
  216 + local cfg = csvdb["activity_ctrlCsv"][id]
  217 + if not cfg then return false end
  218 + if activityType ~= 0 and cfg.showType ~= activityType then return false end
  219 + return self:getResetData(activityType) == 0
  220 +end
  221 +
  222 +function Activity:getResetData(actType)
  223 + actType = checkActivityType(actType)
  224 + return self:getProperty("reset" .. actType)
  225 +end
  226 +
  227 +function Activity:updateResetData(actType, reset)
  228 + actType = checkActivityType(actType)
  229 + self:updateProperty({field = "reset" .. actType, value = reset})
  230 +end
  231 +
210 232 function Activity:getActData(actType)
211 233 actType = checkActivityType(actType)
212 234 return self:getProperty("act" .. actType)
... ... @@ -497,6 +519,7 @@ activityFunc[Activity.ActivityType.CalendaTask] = {
497 519 --role:checkTaskEnter("HangPass", {id = 0})
498 520 role:checkCalendaTask(true, 15, 3)
499 521 role:checkTaskEnter("HeroStarCollect", {})
  522 + role:checkTaskEnter("HeroStartSum", {})
500 523 role:checkTaskEnter("RuneQualityCollect", {})
501 524  
502 525 end,
... ... @@ -565,6 +588,7 @@ activityFunc[Activity.ActivityType.BattleCommandTask] = {
565 588 --role:checkTaskEnter("HangPass", {id = 0})
566 589 role:checkCalendaTask(true, 15, 3)
567 590 role:checkTaskEnter("HeroStarCollect", {})
  591 + role:checkTaskEnter("HeroStartSum", {})
568 592 role:checkTaskEnter("RuneQualityCollect", {})
569 593  
570 594 end,
... ... @@ -669,6 +693,7 @@ activityFunc[Activity.ActivityType.NewUserTask] = {
669 693 --role:checkTaskEnter("HangPass", {id = 0})
670 694 role:checkCalendaTask(true, 15, 3)
671 695 role:checkTaskEnter("HeroStarCollect", {})
  696 + role:checkTaskEnter("HeroStartSum", {})
672 697 role:checkTaskEnter("RuneQualityCollect", {})
673 698  
674 699 end,
... ... @@ -753,8 +778,14 @@ activityFunc[Activity.ActivityType.Gachakon] = {
753 778 self:updateActData(actType, {}, not notify)
754 779 end,
755 780 ["crossDay"] = function(self, actType, notify)
756   - self:updateActData(actType, {}, not notify)
  781 + self:updateResetData(actType, 1)
  782 + --self:updateActData(actType, {}, not notify)
757 783 end,
  784 + ["reset"] = function(self, actType)
  785 + if self:getResetData(actType) == 0 then return end
  786 + self:updateResetData(actType, 0)
  787 + self:updateActData(actType, {})
  788 + end
758 789 }
759 790  
760 791 -- 活动卡池
... ... @@ -862,6 +893,15 @@ function Activity:refreshWeekData(notify)
862 893 end
863 894 end
864 895  
  896 +function Activity:resetActDataById(actId)
  897 + local actData = csvdb["activity_ctrlCsv"][actId]
  898 + if not actData then return end
  899 + local actType = actData.showType
  900 + if activityFunc[actType] and activityFunc[actType]['reset'] then
  901 + activityFunc[actType]["reset"](self, actType)
  902 + end
  903 +end
  904 +
865 905 function Activity:checkActivity(notNotify, activityType, ...)
866 906 if not activityType then return end
867 907 if not self:isOpen(activityType) then return end
... ...
src/models/Capsule.lua
... ... @@ -44,8 +44,8 @@ Capsule.schema = {
44 44 goods = {"table", {}}, --奖励池
45 45 specials = {"table", {}}, --特殊赏
46 46 incentive = {"table", {}}, --激励奖
47   - incentiveRecord = {"table", {}}, --激励奖记录
48   - specialsRecord= {"table", {}}, --特殊赏领取记录
  47 + incentiveRecord = {"table", {}}, --激励奖记录 {roleId = {}, roleId={}}
  48 + specialsRecord= {"table", {}}, --特殊赏领取记录 {1={},2={}} key=触发特殊赏的 抽奖次数, v=特殊赏商品 table
49 49 resetTimes = {"number", 0}, --每日一次手动重置的机会
50 50 hideTime = {"number", 0} , --隐藏时间
51 51 drawEndTime = {"number", 0}, --抽完时间
... ... @@ -145,6 +145,80 @@ function Capsule:isShow()
145 145 return true
146 146 end
147 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 +
148 222 function Capsule:refreshing(now)
149 223 local id = self:getProperty("id")
150 224 local room = self:getProperty("room")
... ... @@ -154,30 +228,13 @@ function Capsule:refreshing(now)
154 228 if reset == "0" then
155 229 return false
156 230 elseif reset == "1" then
157   - if self:getProperty("resetTimes") == 1 then
  231 + if self:getProperty("resetTimes") == 0 then
  232 + self:setProperty("resetTime", 1)
158 233 return true
159 234 end
160 235 return false
161 236 else
162   - local resetArr = reset:toArray(true, "=")
163   - if not next(resetArr) then return false end
164   -
165   - if resetArr[1] == "2" then
166   - if self:getGoodsAmount() > 0 then return false end
167   -
168   - local drawEndTime = self:getProperty("drawEndTime") or 0
169   - if drawEndTime == 0 then return false end
170   -
171   - if now - drawEndTime >= resetArr[2] then
172   - return true
173   - end
174   - return false
175   -
176   - elseif resetArr[1] == "3" then
177   -
178   - elseif resetArr[1] == "4" then
179   - if now >= resetArr[2] then return true end
180   - end
  237 + return self:checkTime(reset, now)
181 238 end
182 239  
183 240 return false
... ... @@ -274,7 +331,7 @@ function Capsule:checkSpecialFlag(typ)
274 331 return spKey, special
275 332 end
276 333  
277   -local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now)
  334 +local function getSpecialReward(rewardRecord, count, award, spKey, typ, now)
278 335 local rewardByRole = {}
279 336 while(count > 0 and next(rewardRecord)) do
280 337 local roleId = math.randWeight(rewardRecord, "amount")
... ... @@ -285,19 +342,9 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now)
285 342  
286 343 if tmp["amount"] <= 0 then rewardRecord[roleId] = nil end
287 344  
288   - tmp = rewardByRole[roleId] or {}
289   - if not next(tmp) then
290   - local name = getNameByRoleId(roleId)
291   - tmp[spKey] = {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = award, amount = 1, quality = typ, create_time= now}
292   - else
293   - if not tmp[spKey] then
294   - local name = getNameByRoleId(roleId)
295   - tmp[spKey] = {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = award, amount = 1, quality = typ, create_time= now}
296   - else
297   - tmp[spKey].amount = tmp[spKey].amount + 1
298   - end
299   - end
300   - 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)
301 348  
302 349 count = count - 1
303 350 end
... ... @@ -306,20 +353,11 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now)
306 353 end
307 354  
308 355  
309   -local rewardToNtyFunc = function(notify, tmpReward)
310   - for key, val in pairs(tmpReward or {}) do
311   - if not notify[key] then
312   - notify[key] = clone(val)
313   - else
314   - for k, v in pairs(val) do
315   - if not notify[key][k] then
316   - notify[key][k] = v
317   - else
318   - notify[key][k] = notify[key][k].amount + v.amount
319   - end
320   - end
321   -
322   - end
  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)
323 361 end
324 362 end
325 363  
... ... @@ -357,12 +395,12 @@ function Capsule:getTop(record, recordAmount,now)
357 395 end
358 396 end
359 397  
360   - local rewardByRole, count = getSpecialRoleNotify(topRecord, special["amount"], special["award"], spKey, SpecialType.TOP,now)
  398 + local rewardByRole, count = getSpecialReward(topRecord, special["amount"], special["award"], spKey, SpecialType.TOP,now)
361 399  
362 400 special["amount"] = count
363 401 specials[spKey] = special
364 402  
365   - rewardToNtyFunc(specialsRecord, rewardByRole)
  403 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
366 404  
367 405 self:setProperties({specialsRecord = specialsRecord, specials = specials})
368 406 return rewardByRole
... ... @@ -379,12 +417,11 @@ function Capsule:getCore(record, recordAmount,now)
379 417  
380 418  
381 419  
382   - local np = special["np"]
383   - if np > recordAmount then return nil end
  420 + local count = special["np"]
  421 + if count > recordAmount then return nil end
384 422  
385 423  
386   - local left = math.ceil((np - recordAmount)/2) or 0
387   - local count = np
  424 + local left = math.ceil((count - recordAmount)/2) or 0
388 425 local roleRecord = {}
389 426 for i, v in ipairs(record) do
390 427 if count <= 0 then break end
... ... @@ -407,17 +444,17 @@ function Capsule:getCore(record, recordAmount,now)
407 444  
408 445 end
409 446  
410   - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], spKey, SpecialType.CORE,now)
  447 + local rewardByRole, count = getSpecialReward(roleRecord, special["amount"], special["award"], spKey, SpecialType.CORE,now)
411 448  
412 449 special["amount"] = count
413 450 specials[spKey] = special
414 451  
415   - rewardToNtyFunc(specialsRecord, rewardByRole)
  452 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
416 453 self:setProperties({specialsRecord = specialsRecord, specials = specials})
417 454 return rewardByRole
418 455 end
419 456  
420   -function Capsule:getLast(record,now)
  457 +function Capsule:getLast(record, recordAmount, now)
421 458 local spKey, special = self:checkSpecialFlag(SpecialType.LAST)
422 459 if not special then return nil end
423 460  
... ... @@ -426,8 +463,7 @@ function Capsule:getLast(record,now)
426 463  
427 464 table.sort(record, function(a, b) return a.create_time > b.create_time end)
428 465  
429   - local np = special["np"]
430   - local count = np
  466 + local count = special["np"]
431 467 local roleRecord = {}
432 468 for _, v in ipairs(record) do
433 469 if count <= 0 then break end
... ... @@ -448,17 +484,17 @@ function Capsule:getLast(record,now)
448 484 end
449 485 end
450 486  
451   - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], spKey, SpecialType.LAST,now)
  487 + local rewardByRole, count = getSpecialReward(roleRecord, special["amount"], special["award"], spKey, SpecialType.LAST,now)
452 488  
453 489 special["amount"] = count
454 490 specials[spKey] = special
455 491  
456   - rewardToNtyFunc(specialsRecord, rewardByRole)
  492 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
457 493 self:setProperties({specialsRecord = specialsRecord, specials = specials})
458 494 return rewardByRole
459 495 end
460 496  
461   -function Capsule:getJoker(record,now)
  497 +function Capsule:getJoker(record, recordAmount, now)
462 498 local spKey, special = self:checkSpecialFlag(SpecialType.JOKER)
463 499 if not special then return nil end
464 500  
... ... @@ -474,37 +510,50 @@ function Capsule:getJoker(record,now)
474 510 end
475 511 end
476 512  
477   - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], spKey, SpecialType.JOKER,now)
  513 + local rewardByRole, count = getSpecialReward(roleRecord, special["amount"], special["award"], spKey, SpecialType.JOKER,now)
478 514  
479 515 special["amount"] = count
480 516 specials[spKey] = special
481 517  
482   - rewardToNtyFunc(specialsRecord, rewardByRole)
  518 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
483 519 self:setProperties({specialsRecord = specialsRecord, specials = specials})
484 520 return rewardByRole
485 521 end
486 522  
487   -function Capsule:getKing(record,now)
  523 +function Capsule:getKing(record, recordAmount, now)
488 524 local spKey, special = self:checkSpecialFlag(SpecialType.KING)
489 525 if not special then return nil end
490 526  
491 527 local specials = self:getProperty("specials") or {}
492 528 local specialsRecord = self:getProperty("specialsRecord") or {}
  529 + local rank = self:getProperty("rank") or {}
  530 + if not next(rank) then return nil end
493 531  
494 532 local roleRecord = {}
495   - for _, v in ipairs(record) do
496   - if not roleRecord[v.roleId]then
497   - roleRecord[v.roleId] = {amount = v.amount }
498   - else
499   - roleRecord[v.roleId] = {amount = (roleRecord[v.roleId]["amount"] or 0) + v.amount}
500   - 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})
501 551 end
502 552  
503   - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], spKey, SpecialType.KING,now)
504 553 special["amount"] = count
505 554 specials[spKey] = special
506 555  
507   - rewardToNtyFunc(specialsRecord, rewardByRole)
  556 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
508 557 self:setProperties({specialsRecord = specialsRecord, specials = specials})
509 558 return rewardByRole
510 559 end
... ... @@ -523,16 +572,16 @@ function Capsule:checkSpecialReward(now, goodsAmount)
523 572  
524 573 if goodsAmount == 0 then
525 574 local coreReward = self:getCore(record, recordAmount, now)
526   - rewardToNtyFunc(notify, coreReward)
  575 + rewardToRecordFunc(notify, recordAmount, coreReward)
527 576  
528   - local lastReward = self:getLast(record, now)
529   - rewardToNtyFunc(notify, lastReward)
  577 + local lastReward = self:getLast(record, recordAmount, now)
  578 + rewardToRecordFunc(notify, recordAmount, lastReward)
530 579  
531   - local jokerReward = self:getJoker(record, now)
532   - rewardToNtyFunc(notify, jokerReward)
  580 + local jokerReward = self:getJoker(record, recordAmount, now)
  581 + rewardToRecordFunc(notify, recordAmount, jokerReward)
533 582  
534   - local kingReward = self:getKing(record, now)
535   - rewardToNtyFunc(notify, kingReward)
  583 + local kingReward = self:getKing(record, recordAmount, now)
  584 + rewardToRecordFunc(notify, recordAmount, kingReward)
536 585 end
537 586  
538 587 return notify
... ... @@ -572,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now)
572 621 end
573 622  
574 623 local count = math.floor(amount / incentive["amount"]["np"])
575   - local tmpCount = count * incentive["amount"]["np"]
576   - notify["amount"] = {name = name, roleId= roleId, good_id = "amount", typ = RewardType.INCENTIVE, award = incentive["amount"]["award"], amount = count, quality = 2, create_time= now}
577   -
578   - --填充v.calculated 字段,标识已经用于每x抽的计算中。
579   - for _, v in pairs(roleRecord) do
580   - if tmpCount <= 0 then break end
581   -
582   - v.calculated = v.calculated or 0
583   - if v.calculated ~= v.amount then
584   - if tmpCount <= v.amount then
585   - v.calculated = tmpCount
586   - tmpCount = 0
587   - else
588   - v.calculated = v.amount
589   - 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
590 641 end
591 642 end
592   -
593 643 end
594 644 end
595 645  
... ... @@ -601,12 +651,44 @@ function Capsule:checkIncentive(roleId, name, now)
601 651  
602 652 end
603 653 end
604   - 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
605 661 incentiveRecord[roleId] = incentiveByRole
606 662 self:setProperty("incentiveRecord", incentiveRecord)
607 663  
608   - --TODO 先屏蔽
609   - return {}
  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
610 692 end
611 693  
612 694 function Capsule:drawByCount(roleId, count)
... ... @@ -614,6 +696,8 @@ function Capsule:drawByCount(roleId, count)
614 696  
615 697 local goods = self:getProperty("goods") or {}
616 698 local record = self:getProperty("record") or {}
  699 + local rank = self:getProperty("rank") or {}
  700 + local rankRole = rank[roleId] or 0
617 701 local recordByRole = self:getProperty("recordByRole") or {}
618 702 local roleRecord = recordByRole[roleId] or {}
619 703  
... ... @@ -623,9 +707,8 @@ function Capsule:drawByCount(roleId, count)
623 707 local goods_id = ichibankuji["goods_id"]
624 708 local now = skynet.timex()
625 709  
626   - --奖励, 通知信息
627   - local notify= {}
628   - notify[roleId] = {}
  710 + --奖励,普通奖品信息
  711 + local goodsByUsual= {}
629 712  
630 713 local name = getNameByRoleId(roleId)
631 714 while (goods and next(goods) and count > 0) do
... ... @@ -636,15 +719,18 @@ function Capsule:drawByCount(roleId, count)
636 719 if good and good.amount > 0 then
637 720 good.amount = good.amount - 1
638 721  
  722 + --插入rank
  723 + rankRole = rankRole + 1
  724 +
639 725 --插入记录
640 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}
641 727 table.insert(record, tmpNotify)
642 728  
643 729 --作为奖励记录+通知
644   - if not notify[roleId][good_id] then
645   - notify[roleId][good_id] = tmpNotify
  730 + if not goodsByUsual[good_id] then
  731 + goodsByUsual[good_id] = tmpNotify
646 732 else
647   - notify[roleId][good_id].amount = notify[roleId][good_id].amount + 1
  733 + goodsByUsual[good_id].amount = goodsByUsual[good_id].amount + 1
648 734 end
649 735  
650 736 --记录角色的抽奖记录 计算激励奖需要用到
... ... @@ -659,48 +745,52 @@ function Capsule:drawByCount(roleId, count)
659 745 end
660 746  
661 747 end
662   - recordByRole[roleId] = roleRecord
663   - self:setProperties({recordByRole = recordByRole, record = record, goods = goods})
664 748  
665   - local tmpNotify = self:checkIncentive(roleId, name, now)
666   - for k, v in pairs(tmpNotify) do
667   - if not notify[roleId][k] then
668   - notify[roleId][k] = v
669   - else
670   - notify[roleId][k].amount = notify[roleId][k].amount + v.amount
671   - end
672   - end
  749 + --奖励池重新赋值
  750 + rank[roleId] = rankRole
  751 + recordByRole[roleId] = roleRecord
  752 + self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank})
673 753  
674   - local speciNotify = self:checkSpecialReward(now)
675   - rewardToNtyFunc(notify, speciNotify)
  754 + --奖励收集
  755 + local reward = {}
  756 + rewardCollect(reward, goodsByUsual)
676 757  
677   - local reward, rewardByGoods = {}, {}
678   - for key, val in pairs(notify) do
679   - if key == roleId then
680   - for k, v in pairs(val) do
681   - for id, count in pairs(v.award:toNumMap()) do
682   - reward[id] = (reward[id] or 0) + count
683   - end
684   - rewardByGoods[k] = v
685   - end
686   - end
  758 + local goodsByIncentive = self:checkIncentive(roleId, name, now)
  759 + rewardCollect(reward, goodsByIncentive)
687 760  
  761 + local goodsAmount = self:getGoodsAmount()
  762 + if goodsAmount == 0 then
  763 + self:setProperty("drawEndTime", now)
688 764 end
689   - 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
690 776 end
691 777  
692 778 function Capsule:drawAll(roleId)
693 779 local goods = self:getProperty("goods") or {}
694 780 local record = self:getProperty("record") or {}
  781 + local rank = self:getProperty("rank") or {}
  782 + local rankRole = rank[roleId] or 0
695 783 local recordByRole = self:getProperty("recordByRole") or {}
696 784 local roleRecord = recordByRole[roleId] or {}
697 785 local now = skynet.timex()
698 786  
699 787 local name = getNameByRoleId(roleId)
700   - local notify = {}
701   - notify[roleId] = {}
  788 + local goodsByUsual = {}
702 789 for good_id, good in pairs(goods) do
703 790 if good.amount > 0 then
  791 + --插入rank
  792 + rankRole = rankRole + good.amount
  793 +
704 794 --插入记录
705 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}
706 796 for i = 1, good.amount do
... ... @@ -708,10 +798,10 @@ function Capsule:drawAll(roleId)
708 798 end
709 799  
710 800 --作为奖励记录+通知
711   - if not notify[roleId][good_id] then
712   - notify[roleId][good_id] = tmpNotify
  801 + if not goodsByUsual[good_id] then
  802 + goodsByUsual[good_id] = tmpNotify
713 803 else
714   - notify[roleId][good_id].amount = notify[roleId][good_id].amount + good.award
  804 + goodsByUsual[good_id].amount = goodsByUsual[good_id].amount + good.award
715 805 end
716 806  
717 807 --记录角色的抽奖记录
... ... @@ -725,40 +815,32 @@ function Capsule:drawAll(roleId)
725 815 end
726 816  
727 817 end
  818 + rank[roleId] = rankRole
728 819 recordByRole[roleId] = roleRecord
729   - self:setProperties({recordByRole = recordByRole, record = record, goods = goods})
730   -
731   - local tmpNotify = self:checkIncentive(roleId, name, now)
732   - for k, v in pairs(tmpNotify) do
733   - if not notify[roleId][k] then
734   - notify[roleId][k] = v
735   - else
736   - notify[roleId][k].amount = notify[roleId][k].amount + v.amount
737   - end
738   - end
  820 + self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank})
739 821  
740   - local goodsAmount = self:getGoodsAmount()
741   - local speciNotify = self:checkSpecialReward(now, goodsAmount)
742   - rewardToNtyFunc(notify, speciNotify)
743   -
744   - local reward, rewardByGoods = {}, {}
745   - for key, val in pairs(notify) do
746   - if key == roleId then
747   - for k, v in pairs(val) do
748   - for id, count in pairs(v.award:toNumMap()) do
749   - reward[id] = (reward[id] or 0) + count
750   - end
751   - rewardByGoods[k] = v
752   - end
753   - end
  822 + --奖励收集
  823 + local reward = {}
  824 + rewardCollect(reward, goodsByUsual)
754 825  
755   - end
  826 + local goodsByIncentive = self:checkIncentive(roleId, name, now)
  827 + rewardCollect(reward, goodsByIncentive)
756 828  
  829 + local goodsAmount = self:getGoodsAmount()
757 830 if goodsAmount == 0 then
758 831 self:setProperty("drawEndTime", now)
759 832 end
760 833  
761   - return reward, rewardByGoods, notify
  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
762 844 end
763 845  
764 846 --@param
... ... @@ -789,6 +871,77 @@ function Capsule:draw(roleId, full, cares)
789 871 end
790 872 end
791 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
792 945  
793 946 function Capsule:data(roleId)
794 947 return {
... ... @@ -799,12 +952,13 @@ function Capsule:data(roleId)
799 952 coin = self:getProperty("coin"),
800 953 onlineCount = self:getOnlineCount(),
801 954 playerStatus = self:getRegisterByRoleId(roleId),
802   - record = self:getProperty("record"),
  955 + record = self:pageRecord() or {},
803 956 rank = self:getProperty("rank"),
804 957 goods = self:getProperty("goods"),
805 958 specials = self:getProperty("specials"),
806 959 incentive = self:getProperty("incentive"),
807 960 specialsRecord= self:getProperty("specialsRecord"),
  961 + roleProgress = self:getRoleProgress(roleId),
808 962 }
809 963 end
810 964  
... ...
src/models/Role.lua
... ... @@ -214,6 +214,9 @@ Role.schema = {
214 214 heroCnt = {"number", 0}, -- 英雄数量
215 215 friendTeam = {"table", {}}, -- 好友切磋队伍信息 {bInfo = {}, team = {}, v = 0}
216 216 bgId = {"number", 0}, -- 看板娘id
  217 +
  218 + worldChangePoints = {"table", {}}, -- 世界变动积分 {[1]= 转盘抽取次数, [2]= 获得的积分, [3]=魔导石消耗, [4]= 虹光玉消耗}
  219 + worldLineReward = {"table", {}}, -- 世界积分 领取记录 {[id] = 1}
217 220 }
218 221  
219 222  
... ... @@ -457,6 +460,8 @@ function Role:data()
457 460 unlockChap = self:getProperty("unlockChap"), -- 解锁的章节
458 461 friendTeam = self:getProperty("friendTeam"),
459 462 bgId = self:getProperty("bgId"),
  463 + worldChangePoints = self:getProperty("worldChangePoints"),
  464 + worldLineReward = self:getProperty("worldLineReward"),
460 465 }
461 466 end
462 467  
... ...
src/models/RoleCross.lua
... ... @@ -168,6 +168,9 @@ RoleCross.bind = function (Role)
168 168 self:checkTaskEnter("Wake", {heroType = heroId, wakeL = initData.heros.wakeL})
169 169 self:checkTaskEnter("WakeCG", {heroType = heroId})
170 170 self:checkTaskEnter("HeroTalent", {heroType = heroId, alv = aheadLevel})
  171 + if initData.heros.wakeL == 3 then
  172 + self:checkTaskEnter("WakeCGSum", {count = 1})
  173 + end
171 174  
172 175 end
173 176 end
... ... @@ -211,7 +214,6 @@ RoleCross.bind = function (Role)
211 214 end
212 215  
213 216 function Role:paySpecialReward(roleId, notify)
214   - dump(notify)
215 217 if notify and next(notify) then
216 218 local reward = {}
217 219 for key, val in pairs(notify) do
... ... @@ -221,6 +223,7 @@ RoleCross.bind = function (Role)
221 223  
222 224 end
223 225 self:award(reward, {log = {desc = "CapsuleReward", int1=roleId}})
  226 + SendPacket(actionCodes.Capsule_notifyChange, MsgPack.pack({special = notify}))
224 227 end
225 228 end
226 229  
... ... @@ -385,7 +388,6 @@ function CMD.redPTag(roleId, tag, pms)
385 388 end
386 389  
387 390 function CMD.paySpecialReward(roleId, notify)
388   - dump(notify)
389 391 if notify and next(notify) then
390 392 local reward = {}
391 393 for key, val in pairs(notify) do
... ...
src/models/RoleLog.lua
... ... @@ -66,8 +66,10 @@ local ItemReason = {
66 66 shopBuy = 150, -- 商店购买
67 67 monthCardReward = 151, --月卡奖励
68 68 smonthCardReward = 152, --特刊奖励
69   - itemConvertmonthCard = 153, --兑换月卡
70   - itemConvertsmonthCard = 154, --兑换特刊
  69 + itemConvertSpecial = 153, --兑换月卡/战令/探索指令 特殊道具
  70 + buyDiamondCardReward = 154, --购买钻石额外赠送奖励
  71 + firstMonthCardReward = 155, --首次订阅月卡奖励
  72 + firstSMonthCardReward = 156, --首次订阅特刊奖励
71 73  
72 74 advHang = 301, -- 拾荒挂机
73 75 hangBattle = 302, -- 挂机战斗
... ... @@ -163,6 +165,8 @@ local ItemReason = {
163 165 CapsuleReward = 1411, --扭蛋机奖励
164 166 CapsuleConvert = 1412, --扭蛋机 消耗票 兑换
165 167 CapsuleCoinCost = 1413, --抽扭蛋机消耗
  168 +
  169 + worldLine = 1500, --世界线积分
166 170 }
167 171  
168 172  
... ...
src/models/RolePlugin.lua
... ... @@ -32,6 +32,8 @@ function RolePlugin.bind(Role)
32 32 function Role:onOfflineEvent()
33 33 -- 设置最新的登录时间
34 34 self:setProperty("ltime", skynet.timex())
  35 +
  36 + self:saveRoleData()
35 37 end
36 38  
37 39 local function checkItemCount(self, itemId, count)
... ... @@ -212,6 +214,8 @@ function RolePlugin.bind(Role)
212 214 end
213 215 end
214 216 if not next(allChange) then allChange = nil end
  217 + -- 加道具及时刷新数据
  218 + self:update()
215 219 return reward, allChange --实际获得的奖励 和 最高级奖励转化过程
216 220 end
217 221  
... ... @@ -426,8 +430,15 @@ function RolePlugin.bind(Role)
426 430 return
427 431 end
428 432 end
  433 +
  434 + if itemCountT[ItemId.Jade] then --扣除
  435 + pms.itemId = ItemId.Jade
  436 + pms.count = - itemCountT[ItemId.Jade]
  437 + self:costJade(pms)
  438 + end
  439 +
429 440 for itemId, count in pairs(itemCountT) do
430   - if itemId ~= ItemId.Diamond then
  441 + if itemId ~= ItemId.Diamond and itemId ~= ItemId.Jade then
431 442 pms.itemId = itemId
432 443 pms.count = - count
433 444 self:addItem(pms)
... ... @@ -563,9 +574,16 @@ function RolePlugin.bind(Role)
563 574 self:notifyUpdateProperty("diamond", self:getAllDiamond())
564 575  
565 576 self:checkTaskEnter("CostDiamond", {count = count})
  577 + self:checkWorldChangePoints({[ItemWorldLine.CostDiamond]=count})
566 578 return true
567 579 end
568 580  
  581 + function Role:costJade(param)
  582 + self:addItem(param)
  583 + self:checkTaskEnter("CostJade", {count = - param.count})
  584 + self:checkWorldChangePoints({[ItemWorldLine.CostJade]= -param.count})
  585 + end
  586 +
569 587 function Role:increBy(field, val)
570 588 local roleIncre = self:getProperty("roleIncre")
571 589 local curId = roleIncre[field] or 0
... ... @@ -592,6 +610,7 @@ function RolePlugin.bind(Role)
592 610 }
593 611 if heroInfo.wakeL == 3 then
594 612 self:checkTaskEnter("WakeCG", {heroType = heroType})
  613 + self:checkTaskEnter("WakeCGSum", {count = 1})
595 614 end
596 615 local newHero = require("models.Hero").new(heroInfo)
597 616 newHero:create()
... ... @@ -604,6 +623,8 @@ function RolePlugin.bind(Role)
604 623 end
605 624 self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job, ssrCount = ssrCount}, params.notNotify)
606 625 self:checkTaskEnter("HeroQualityCollect", {})
  626 + self:checkTaskEnter("HeroStartSum", {})
  627 +
607 628 if not params.notNotify then
608 629 local heroResponse = {}
609 630 table.insert(heroResponse, newHero:data())
... ... @@ -2037,10 +2058,10 @@ function RolePlugin.bind(Role)
2037 2058  
2038 2059 local SAVE_DATA_INTERVAL = 3
2039 2060 function Role:saveRoleData(now)
2040   - if now - self._lastSaveTs < SAVE_DATA_INTERVAL then
  2061 + if now and (now - self._lastSaveTs < SAVE_DATA_INTERVAL) then
2041 2062 return
2042 2063 end
2043   - self._lastSaveTs = now
  2064 + self._lastSaveTs = now or skynet.timex()
2044 2065 self:update()
2045 2066 local objs = {self.activity, self.dailyData, self.dinerData, self.storeData, self.roleIncre}
2046 2067 for _, info in ipairs(objs) do
... ... @@ -2090,7 +2111,7 @@ function RolePlugin.bind(Role)
2090 2111 local emailSync = math.max(emailSync + 1, globalEmail - EMAIL_LIMIT + 1)
2091 2112 local redret = redisproxy:pipelining(function (red)
2092 2113 for id = emailSync, globalEmail do
2093   - red:hgetall(string.format("globalEmail:%s", id))
  2114 + red:hgetall(string.format("globalEmail:%s", id))
2094 2115 end
2095 2116 end)
2096 2117 for _, data in ipairs(redret) do
... ... @@ -2414,7 +2435,7 @@ function RolePlugin.bind(Role)
2414 2435 return 1
2415 2436 end
2416 2437  
2417   - if not self.storeData:checkRechargeRecord(rechargeData.limit, id) and rechargeData.shop ~= 2 then
  2438 + if not self.storeData:checkRechargeRecord(rechargeData.limit, id)then
2418 2439 return 2
2419 2440 end
2420 2441  
... ... @@ -2429,6 +2450,12 @@ function RolePlugin.bind(Role)
2429 2450 self:updateProperty({field = "rechargeF", value = rechargeF})
2430 2451 end
2431 2452 self:gainDiamond({count = diamondCount, isRecharge = true, sid = params.sid, log = {desc = "recharge", int1 = id}})
  2453 +
  2454 + --已购月卡 购买魔导石 赠送cardReward
  2455 + if not self.storeData:isMonthCardExpire() then
  2456 + reward, _ = self:award(rechargeData.cardReward, {isRecharge = true, log = {desc = "buyDiamondCardReward", int1 = id}})
  2457 + end
  2458 +
2432 2459 elseif rechargeData.shop == 2 then --通行证商店
2433 2460 --签收 + 订阅奖励
2434 2461 local tmpreward, _ = self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id)
... ... @@ -2437,6 +2464,8 @@ function RolePlugin.bind(Role)
2437 2464 end
2438 2465 elseif rechargeData.shop == 3 then -- 礼包商店
2439 2466 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
  2467 +
  2468 + self:checkTaskEnter("BuyLimitPack", {id = id})
2440 2469 else
2441 2470 skynet.error("[recharge] invalid recharge shop type " .. id)
2442 2471 return 3
... ... @@ -2991,6 +3020,22 @@ function RolePlugin.bind(Role)
2991 3020 return levelBnous[SystemBnousType.ChangeBuyCount] or 0
2992 3021 end
2993 3022  
  3023 + function Role:getExtraProp()
  3024 + local levelBnous = self:getLevelBnous()
  3025 + local extraPropReward = levelBnous[SystemBnousType.ExtraProp] or {}
  3026 + local reward = {}
  3027 + for k, v in pairs(extraPropReward) do
  3028 + reward[k] = (reward[k] or 0) + v
  3029 + end
  3030 + return reward
  3031 + end
  3032 +
  3033 + function Role:getAccountLevel()
  3034 + local levelBnous = self:getLevelBnous()
  3035 + dump(levelBnous)
  3036 + return levelBnous[SystemBnousType.AccountLevel] or 0
  3037 + end
  3038 +
2994 3039 function Role:getLevelBnous()
2995 3040 local levelBnous = {}
2996 3041 local curLevel = self:getProperty("level")
... ... @@ -3019,6 +3064,11 @@ function RolePlugin.bind(Role)
3019 3064 levelBnous[pm1] = 0
3020 3065 end
3021 3066 levelBnous[pm1] = levelBnous[pm1] + pm2
  3067 + elseif pm1 == SystemBnousType.AccountLevel then
  3068 + if type(levelBnous[pm1]) == "table" then
  3069 + levelBnous[pm1] = 0
  3070 + end
  3071 + levelBnous[pm1] = math.max(levelBnous[pm1], pm2)
3022 3072 else
3023 3073 levelBnous[pm1][pm2] = (levelBnous[pm1][pm2] or 0) + pm3
3024 3074 end
... ... @@ -3153,10 +3203,10 @@ function RolePlugin.bind(Role)
3153 3203 return itemRandomOccupy
3154 3204 end
3155 3205  
3156   - function Role:getCapsuleList(coin)
  3206 + function Role:getCapsuleList(id)
3157 3207 local capsules = {}
3158 3208 for k, v in pairs(self.capsules) do
3159   - if v:getProperty("coin") == coin then
  3209 + if v:getProperty("id") == id then
3160 3210 local onlineCount= v:getOnlineCount()
3161 3211 capsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")}
3162 3212 end
... ... @@ -3165,17 +3215,20 @@ function RolePlugin.bind(Role)
3165 3215 end
3166 3216  
3167 3217 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 3
  3218 + local capsule = self.capsules[capsuleId]
  3219 + if not capsule then return nil end
  3220 +
  3221 + local roleId = self:getProperty("id")
  3222 + local ret, drawReward = capsule:draw(roleId, full, cares)
  3223 + drawReward["specials"] = nil
  3224 + return ret, drawReward, capsule:data(roleId)
3174 3225 end
3175 3226  
3176   - function Role:joinCapsule(capsuleId)
3177   - local capsule = self.capsules[capsuleId] or {}
3178   - return capsule:data()
  3227 + function Role:joinCapsule(roleId, capsuleId)
  3228 + local capsule = self.capsules[capsuleId]
  3229 + if not capsule then return nil end
  3230 +
  3231 + return capsule:data(roleId)
3179 3232 end
3180 3233  
3181 3234 function Role:checkCapsule(now)
... ... @@ -3188,13 +3241,17 @@ function RolePlugin.bind(Role)
3188 3241 end
3189 3242  
3190 3243 function Role:goodStock(capsuleId)
3191   - local capsule = self.capsules[capsuleId] or {}
  3244 + local capsule = self.capsules[capsuleId]
  3245 + if not capsule then return 0 end
  3246 +
3192 3247 return capsule:getGoodsAmount(), capsule:getProperty("token")
3193 3248 end
3194 3249  
3195   - function Role:getCapsuleData(capsuleId)
3196   - local capsule = self.capsules[capsuleId] or {}
3197   - return capsule:data()
  3250 + function Role:getCapsuleData(roleId, capsuleId)
  3251 + local capsule = self.capsules[capsuleId]
  3252 + if not capsule then return nil end
  3253 +
  3254 + return capsule:data(roleId)
3198 3255 end
3199 3256  
3200 3257 function Role:resetCapsule()
... ... @@ -3220,6 +3277,38 @@ function RolePlugin.bind(Role)
3220 3277 end
3221 3278 end
3222 3279 end
  3280 +
  3281 + function Role:pageRecord(capsuleId, up, idx)
  3282 + local capsule = self.capsules[capsuleId]
  3283 + if not capsule then return nil end
  3284 +
  3285 + return capsule:pageRecord(up, idx)
  3286 + end
  3287 +
  3288 + function Role:getSpecialNotify(roleId, capsuleId)
  3289 + local capsule = self.capsules[capsuleId]
  3290 + if not capsule then return nil end
  3291 +
  3292 + return capsule:getSpecialNotify(roleId)
  3293 + end
  3294 +
  3295 + function Role:checkWorldChangePoints(param)
  3296 + local worldChangePoints = self:getProperty("worldChangePoints") or {}
  3297 + if param[ItemWorldLine.CostJade] then
  3298 + worldChangePoints[ItemWorldLine.CostJade] = (worldChangePoints[ItemWorldLine.CostJade] or 0) + param[ItemWorldLine.CostJade]
  3299 + local cost = math.floor(worldChangePoints[ItemWorldLine.CostJade] / globalCsv.worldline_gift)
  3300 + worldChangePoints[ItemWorldLine.CostJade] = worldChangePoints[ItemWorldLine.CostJade] - cost * globalCsv.worldline_gift
  3301 + worldChangePoints[ItemWorldLine.RouletteCount] = (worldChangePoints[ItemWorldLine.RouletteCount] or 0) + cost
  3302 + end
  3303 +
  3304 + if param[ItemWorldLine.CostDiamond] then
  3305 + worldChangePoints[ItemWorldLine.CostDiamond] = (worldChangePoints[ItemWorldLine.CostDiamond] or 0) + param[ItemWorldLine.CostDiamond]
  3306 + local cost = math.floor(worldChangePoints[ItemWorldLine.CostDiamond] / globalCsv.worldline_count_currency)
  3307 + worldChangePoints[ItemWorldLine.CostDiamond] = worldChangePoints[ItemWorldLine.CostDiamond] - cost * globalCsv.worldline_count_currency
  3308 + worldChangePoints[ItemWorldLine.Points] = (worldChangePoints[ItemWorldLine.Points] or 0) + cost
  3309 + end
  3310 + self:setProperty("worldChangePoints", worldChangePoints)
  3311 + end
3223 3312 end
3224 3313  
3225 3314 return RolePlugin
3226 3315 \ No newline at end of file
... ...
src/models/RoleTask.lua
... ... @@ -17,6 +17,9 @@ local TaskType = {
17 17 HeroStarCollect = 12, -- 英雄星级收集进度
18 18 DrawHeroNotFriend = 13, -- 非友情招募 -- count
19 19 DrawHeroLimitPack = 14, -- 抽卡限时礼貌 -- count
  20 + HeroStartSum = 15, -- 英雄星级总数
  21 + WakeCGSum = 16, -- 累计解锁xx张CG
  22 +
20 23  
21 24 --装备相关
22 25 AddEquip = 101, -- 获得装备 - equipId rarity
... ... @@ -112,6 +115,8 @@ local TaskType = {
112 115 ActBattlePass = 911, -- 活动关卡通关 -- chapterId
113 116 Appoint = 912, -- 触发限时礼包,指定id
114 117 Rename = 913, -- 重命名
  118 + CostJade = 914, -- 消耗虹光玉
  119 + BuyLimitPack = 915, -- 购买指定id礼包触发
115 120  
116 121 --功能未实现 todo
117 122 AdvShop = 1002, -- 冒险商城
... ... @@ -271,6 +276,13 @@ local StoreListener = {
271 276 [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}},
272 277 [TaskType.DrawHeroLimitPack] = {{TriggerEventType.DrawHeroCnt, f("count")}},
273 278 [TaskType.Appoint] = {{TriggerEventType.Appoint, f("id")}},
  279 + [TaskType.SignIn] = {{TriggerEventType.SignIn, 1}},
  280 + [TaskType.DrawHero] = {{TriggerEventType.DrawHero, f("count")}},
  281 + [TaskType.FoodSell]= {{TriggerEventType.FoodSell, f("count")}},
  282 + [TaskType.RuneUp] = {{TriggerEventType.RuneUp, 1}},
  283 + [TaskType.CostDiamond] = {{TriggerEventType.CostDiamond, f("count")}},
  284 + [TaskType.BuyLimitPack] = {{TriggerEventType.BuyLimitPack, f("id")}},
  285 + [TaskType.HeroTalent] = {{TriggerEventType.HeroTalent, f("count")}},
274 286 }
275 287 }
276 288  
... ... @@ -318,6 +330,9 @@ local CalendaTaskListener = {
318 330 [TaskType.AdvKill] = {{39, 1, f("chapterId")}},
319 331 [TaskType.ActBattlePass] = {{40, 3, f("chapterId")}},
320 332 [TaskType.AdvPass] = {{41, 3, f("id")}},
  333 + [TaskType.CostJade] = {{43, 1, f("count")}},
  334 + [TaskType.HeroStartSum] = {{44, 3}},
  335 + [TaskType.WakeCGSum] = {{45, 1, f("count")}},
321 336 }
322 337 }
323 338  
... ... @@ -738,7 +753,7 @@ function RoleTask.bind(Role)
738 753 for _,uid in pairs(hero:getRunes()) do
739 754 if uid > 0 then
740 755 local runeData = self.runeBag[uid]
741   - if runeData then
  756 + if runeData then
742 757 local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")]
743 758  
744 759 if csvData and cfg.condition2 <= csvData.rarity then
... ... @@ -758,9 +773,9 @@ function RoleTask.bind(Role)
758 773 end
759 774 elseif cfg.type == 15 then -- 通关关卡
760 775 if (calTask[id] or 0) == 0 then
761   - if self:checkHangPass(cfg.condition2) then
  776 + if self:checkHangPass(cfg.condition2) then
762 777 calTask[id] = 1
763   - end
  778 + end
764 779 --local hangPass = self:getProperty("hangPass")
765 780 --local diff = math.floor(cfg.condition2 / 10000)
766 781 --if (hangPass[diff] or 0) >= cfg.condition2 then
... ... @@ -791,7 +806,7 @@ function RoleTask.bind(Role)
791 806 elseif cfg.type == 37 then -- 拾荒使用道具
792 807 if cfg.condition2 == param1 then
793 808 calTask[id] = (calTask[id] or 0) + (param2 or 0)
794   - end
  809 + end
795 810 elseif cfg.type == 38 then -- 和指定建筑交互
796 811 local condArr = cfg.condition3:toArray(true, "=")
797 812 for i = 0, #condArr do
... ... @@ -820,6 +835,14 @@ function RoleTask.bind(Role)
820 835 if cfg.condition2 <= param1 and param2 == 1 then
821 836 calTask[id] = (calTask[id] or 0) + 1
822 837 end
  838 + elseif cfg.type == 44 then --玩家拥有拾荒者总星级达到xxx
  839 + local count = 0
  840 + for _, hero in pairs(self.heros) do
  841 + count = count + hero:getProperty("wakeL")
  842 + end
  843 + if (calTask[id] or 0) < count then
  844 + calTask[id] = count
  845 + end
823 846 end
824 847 end
825 848 end
... ...
src/models/Store.lua
... ... @@ -30,11 +30,12 @@ Store.schema = {
30 30  
31 31 monthCardEx = {"number", 0}, -- 期数
32 32 monthCardId = {"number", 0}, -- 月卡id
33   - firstMonthCard = {"number", 1}, -- 首次订阅月卡
  33 + firstMonthCard = {"number", 0}, -- 首次订阅月卡
34 34 monthCardReceive = {"number", 0}, -- 月卡奖励领取记录 当天 0-未领取, 1-已经领取
35 35  
36 36 smonthCards = {"table", {}}, --特刊信息 {[id]={["buyCount"]=0, ["periods"]=0}} buyCount: 购买次数,periods: 剩余期数,
37 37 smonthCardReceive = {"number", 0}, -- 特刊奖励领取记录 当天 0-未领取, 1-已经领取
  38 + firstSMonthCard = {"table", {}}, -- 首次订阅当期特刊
38 39  
39 40 battleCard = {"number", 0}, -- 赛季卡
40 41 battleFR = {"string", ""}, -- 免费赛季卡领取记录
... ... @@ -55,6 +56,7 @@ Store.schema = {
55 56  
56 57 dailyShop = {"table", {}},
57 58 weekShop = {"table", {}},
  59 + dayLimitInfo = {"table", {}}, -- {[id]={count=0, trigger=0}}
58 60 }
59 61  
60 62 function Store:updateProperty(params)
... ... @@ -80,6 +82,7 @@ function Store:onCrossDay()
80 82 --self:sendMonthCardEmail()
81 83 self:deleteExpireLimitGoods()
82 84 --self:checkPaySignReward()
  85 + self:resetDayLimitPackTriggerCount()
83 86  
84 87 --刷新商店
85 88 self:flushDailyShop()
... ... @@ -93,100 +96,15 @@ function Store:refreshWeekData(notify)
93 96 self:flushWeekShop()
94 97 end
95 98  
96   -local SuperMonthCard = {}
97 99  
98   -SuperMonthCard["buy"] = function(self, id)
99   - local smonthCards = self:getProperty("smonthCards") or {}
100   -
101   - local buyLimitFunc = function(buylimit)
102   - for k, v in pairs(buylimit) do
103   - if k == 1 then
104   - if v == 101 then
105   - if self:isMonthCardExpire() then
106   - skynet.error("月卡过期")
107   - return false
108   - end
109   - else
110   - if smonthCards[v] == nil then
111   - skynet.error("没有购买增刊里的条件, %d", v)
112   - return false
113   - end
114   - end
115   - elseif k == 2 then
116   - if smonthCards[v] == nil and v ~= 101 then
117   - skynet.error("没有购买增刊里的条件, %d", v)
118   - return false
119   - end
120   - if SuperMonthCard["isExpired"](self, v) == false and v ~= 101 then
121   - skynet.error("上期特刊奖励没有领取完")
122   - return false
123   - end
124   - end
125   - end
126   - return true
127   - end
128   -
129   - local BuyMonthCard = {}
130   - BuyMonthCard["renewal"]= function()
131   - --续刊
132   - local card = csvdb["shop_cardCsv"][id] or {}
133   - if card["buyLimit"] and card["buyLimit"] ~= "" then
134   - if buyLimitFunc(card["buyLimit"]:toNumMap()) == false then
135   - skynet.error("不满足购买条件")
136   - return false
137   - end
138   - end
139   -
140   - local smonthCard = smonthCards[id] or {}
141   - if next(smonthCard) then
142   - smonthCard["buyCount"] = (smonthCard["buyCount"] or 0) + 1
143   - local periods = SuperMonthCard["periods"](self, id) + (card["amount"] or 30)
144   - smonthCard["periods"] = periods
145   -
146   - self:updateProperty({field = "smonthCards", value = smonthCards})
147   - return true
148   - end
149   - end
150   - BuyMonthCard["order"] = function()
151   - --增刊条件
152   - local card = csvdb["shop_cardCsv"][id] or {}
153   - if card["buyLimit"] and card["buyLimit"] ~= "" then
154   - if buyLimitFunc(card["buyLimit"]:toNumMap()) == false then
155   - skynet.error("不满足增刊条件")
156   - return false
157   - end
158   - end
159   - smonthCards[id] = {["periods"] = (card["amount"] or 30), ["buyCount"] = 1}
160   -
161   - self:updateProperty({field= "smonthCards", value = smonthCards})
162   - return true
163   - end
164   -
165   - if SuperMonthCard["isExpired"](self, id) then
166   - local smonthCard = smonthCards[id] or {}
167   - if next(smonthCard) then
168   - return BuyMonthCard["renewal"]()
169   - else
170   - return BuyMonthCard["order"]()
171   - end
172   - else
173   - return BuyMonthCard["renewal"]()
174   - end
175   -end
176   -
177   -SuperMonthCard["periods"] = function(self, id)
  100 +local function getSMonthCardPeriods(self, id)
178 101 local smonthCards = self:getProperty("smonthCards") or {}
179 102 local smonthCard = smonthCards[id] or {}
180 103 return smonthCard["periods"] or 0
181 104 end
182 105  
183   -SuperMonthCard["isExpired"] = function (self, id)
184   - local periods = SuperMonthCard["periods"](self, id)
185   - return periods == 0
186   -end
187   -
188   -SuperMonthCard["itemDaily"] = function(self, id)
189   - local cur_ex = SuperMonthCard["periods"](self, id)
  106 +local function getCardItemDailyReward(self, id)
  107 + local cur_ex = getSMonthCardPeriods(self, id)
190 108 if cur_ex == 0 then return nil, nil end
191 109 cur_ex = cur_ex - 1
192 110  
... ... @@ -201,7 +119,7 @@ SuperMonthCard[&quot;itemDaily&quot;] = function(self, id)
201 119 return reward, change, cur_ex
202 120 end
203 121  
204   -SuperMonthCard["itemFirst"] = function(self, id)
  122 +local function getCardItemFirstReward(self, id)
205 123 local card = csvdb["shop_cardCsv"][id] or {}
206 124 local reward, _ = self.owner:award(card["itemFirst"], {isRecharge = true, log = {desc = "recharge", int1 = id}})
207 125 return reward
... ... @@ -219,6 +137,15 @@ function Store:deleteExpireLimitGoods()
219 137 self:updateProperty({field = "limitTPack", value = limitGoodsList, notNotify = true})
220 138 end
221 139  
  140 +-- 每日充值循环限时礼包的触发次数
  141 +function Store:resetDayLimitPackTriggerCount()
  142 + local dayLimitInfo = self:getProperty("dayLimitInfo")
  143 + for k, v in pairs(dayLimitInfo) do
  144 + v['trigger'] = nil
  145 + end
  146 + self:updateProperty({field = "dayLimitInfo", value = dayLimitInfo, notNotify = true})
  147 +end
  148 +
222 149 -- 发送月卡邮件
223 150 function Store:sendMonthCardEmail()
224 151 local timeNow = skynet.timex()
... ... @@ -373,8 +300,8 @@ end
373 300 function Store:getSMonthCardDailyReward(id)
374 301 if not id then return nil end
375 302  
376   - local before_ex = SuperMonthCard["periods"](self, id)
377   - local reward, change, cur_ex= SuperMonthCard["itemDaily"](self, id)
  303 + local before_ex = getSMonthCardPeriods(self, id)
  304 + local reward, change, cur_ex= getCardItemDailyReward(self, id)
378 305  
379 306 --今日特刊奖励已经领取
380 307 self:updateProperty({field = "smonthCardReceive", value = 1})
... ... @@ -391,14 +318,110 @@ function Store:getSMonthCardDailyReward(id)
391 318 end
392 319  
393 320 function Store:firstBuyMonthCard(id)
394   - if self:getProperty("firstMonthCard") == 1 then
395   - self:updateProperty({field = "firstMonthCard", value = 0})
  321 + if self:getProperty("firstMonthCard") == 0 then
  322 + self:updateProperty({field = "firstMonthCard", value = 1})
  323 + local card = csvdb["shop_cardCsv"][id] or {}
  324 + return self.owner:award(card["itemOnce"], {log = {desc = "firstMonthCardReward", int1 = id}})
  325 + end
  326 + return nil
  327 +end
  328 +
  329 +function Store:firstBuySMonthCard(id)
  330 + local firstSMonthCard = self:getProperty("firstSMonthCard") or {}
  331 + if not firstSMonthCard[id] or firstSMonthCard[id] == 0 then
  332 + firstSMonthCard[id] = 1
  333 + self:updateProperty({field = "firstSMonthCard", value = firstSMonthCard})
396 334 local card = csvdb["shop_cardCsv"][id] or {}
397   - return self.owner:award(card["itemOnce"], {log = {desc = "monthCardReward", int1 = id, int2 = 30}})
  335 + return self.owner:award(card["itemOnce"], {log = {desc = "firstSMonthCardReward", int1 = id}})
398 336 end
399 337 return nil
400 338 end
401 339  
  340 +function Store:isSMonthCardExpired(id)
  341 + return getSMonthCardPeriods(self, id) == 0
  342 +end
  343 +
  344 +function Store:buySMonthCardLimit(buylimit)
  345 + local smonthCards = self:getProperty("smonthCards") or {}
  346 + for k, v in pairs(buylimit) do
  347 + if k == 1 then
  348 + if v == 101 then
  349 + if self:isMonthCardExpire() then
  350 + skynet.error("月卡过期")
  351 + return false
  352 + end
  353 + else
  354 + if smonthCards[v] == nil then
  355 + skynet.error("没有购买增刊里的条件, %d", v)
  356 + return false
  357 + end
  358 + end
  359 + elseif k == 2 then
  360 + if smonthCards[v] == nil and v ~= 101 then
  361 + skynet.error("没有购买增刊条件里的特刊, %d", v)
  362 + return false
  363 + end
  364 + if self:isSMonthCardExpired(v) == false and v ~= 101 then
  365 + skynet.error("上期特刊奖励没领完") --策划yc+hbw 没领完上期特刊,新一期特刊不展示,不允许购买
  366 + return false
  367 + end
  368 + end
  369 + end
  370 + return true
  371 +end
  372 +
  373 +function Store:buySMonthCard(id)
  374 + local smonthCards = self:getProperty("smonthCards") or {}
  375 +
  376 + local BuyMonthCard = {}
  377 + BuyMonthCard["renewal"]= function()
  378 + --续刊
  379 + local card = csvdb["shop_cardCsv"][id] or {}
  380 + if card["buyLimit"] and card["buyLimit"] ~= "" then
  381 + if self:buySMonthCardLimit(card["buyLimit"]:toNumMap()) == false then
  382 + skynet.error("不满足购买条件")
  383 + return false
  384 + end
  385 + end
  386 +
  387 + local smonthCard = smonthCards[id] or {}
  388 + if next(smonthCard) then
  389 + smonthCard["buyCount"] = (smonthCard["buyCount"] or 0) + 1
  390 + local periods = (smonthCard["periods"] or 0) + (card["amount"] or 30)
  391 + smonthCard["periods"] = periods
  392 +
  393 + self:updateProperty({field = "smonthCards", value = smonthCards})
  394 + return true
  395 + end
  396 + end
  397 +
  398 + BuyMonthCard["order"] = function()
  399 + --增刊
  400 + local card = csvdb["shop_cardCsv"][id] or {}
  401 + if card["buyLimit"] and card["buyLimit"] ~= "" then
  402 + if self:buySMonthCardLimit(card["buyLimit"]:toNumMap()) == false then
  403 + skynet.error("不满足增刊条件")
  404 + return false
  405 + end
  406 + end
  407 +
  408 + smonthCards[id] = {["periods"] = (card["amount"] or 30), ["buyCount"] = 1}
  409 + self:updateProperty({field= "smonthCards", value = smonthCards})
  410 + return true
  411 + end
  412 +
  413 + if self:isSMonthCardExpired(id) then
  414 + local smonthCard = smonthCards[id] or {}
  415 + if next(smonthCard) then
  416 + return BuyMonthCard["renewal"]()
  417 + else
  418 + return BuyMonthCard["order"]()
  419 + end
  420 + else
  421 + return BuyMonthCard["renewal"]()
  422 + end
  423 +end
  424 +
402 425 -- 购买通行证
403 426 function Store:onBuyCard(type, duration, id, actid)
404 427 local timeNow = skynet.timex()
... ... @@ -409,20 +432,23 @@ function Store:onBuyCard(type, duration, id, actid)
409 432 self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + 30})
410 433  
411 434 local reward = {}
412   - --初回特典 仅首次购买月卡时赠送SSR级角色"拉塔托娅"
413   - local tmpreward, _ = self:firstBuyMonthCard(id)
  435 + local tmpreward, _ = self:firstBuyMonthCard(id) --初回特典 仅首次购买月卡
414 436 if tmpreward then table.rewardMerge(reward, tmpreward) end
415 437  
416   - --订阅奖励
417   - tmpreward = SuperMonthCard["itemFirst"](self, id)
  438 + tmpreward = getCardItemFirstReward(self, id) --订阅奖励
418 439 if next(tmpreward) then table.rewardMerge(reward, tmpreward) end
419 440  
420 441 return reward
421 442 elseif type == CardType.SuperMonthCard then
422   - if SuperMonthCard["buy"](self, id) then
423   - skynet.error("特刊购买成功:"..id)
424   - return SuperMonthCard["itemFirst"](self, id)
  443 + if self:buySMonthCard(id) then
  444 + local reward = getCardItemFirstReward(self, id) or {}
  445 + local tmpreward, _ = self:firstBuySMonthCard(id)
  446 + if tmpreward then table.rewardMerge(reward, tmpreward) end
  447 +
  448 + return reward
425 449 end
  450 +
  451 + skynet.error("特刊购买失败:"..id)
426 452 return nil
427 453 elseif type == CardType.NormalMonthCardLevelUp then
428 454 if self:isMonthCardExpire() then
... ... @@ -474,7 +500,7 @@ function Store:onBuyCard(type, duration, id, actid)
474 500 self:updateProperty({field = "bpInfo", value = bpInfo})
475 501 elseif type == CardType.ActBattleCommandCard then
476 502 if not self.owner.activity:isOpenById(actid, "ActShopGoods") then
477   - return
  503 + return nil
478 504 end
479 505 local actCfg = csvdb["activity_ctrlCsv"][actid]
480 506 if not actCfg then return end
... ... @@ -486,6 +512,10 @@ function Store:onBuyCard(type, duration, id, actid)
486 512 end
487 513 self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0})
488 514 self.owner.activity:updateActData("BattleCommand", actData)
  515 + local rechargeData = csvdb["shop_rechargeCsv"][id]
  516 + if rechargeData then
  517 + return self.owner:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
  518 + end
489 519 end
490 520 return nil, nil
491 521 end
... ... @@ -587,58 +617,64 @@ function Store:OnTriggerLimitTimePack(eventType, param)
587 617 local limitPack = self:getProperty("limitTPack")
588 618 --local payRecord = self:getProperty("payR")
589 619 local timeNow = skynet.timex()
590   - --local find = false
591   - -- 有未过期的限时礼包不再推送
592   - --for k, v in pairs(limitPack) do
593   - -- if v > timeNow and not payRecord[k] then
594   - -- find = true
595   - -- break
596   - -- end
597   - --end
598   - --if find == true then
599   - -- return
600   - --end
601   - --local hangPass = self.owner:getProperty("hangPass")
602   - --local triggerRecord = self:getProperty("packTrigger")
603   - --local result = {}
604   - --local maxDiff = 0
605   - -- 取满足限时礼包关卡要求的对应数据
606   - --for diff, maxCarbonId in pairs(hangPass) do
607   - -- for id, cfg in pairs(csvdb["shop_packCsv"]) do
608   - -- local range = cfg.showRange:toArray(true, "=")
609   - -- local beginRange = range[1] or 0
610   - -- local endRange = range[2] or 0
611   - -- if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then
612   - -- result[diff] = cfg
613   - -- maxDiff = math.max(maxDiff, diff)
614   - -- break
615   - -- end
616   - -- end
617   - --end
  620 +
618 621 local config = nil
619 622 for id, cfg in pairs(csvdb["shop_packCsv"]) do
620   - if cfg.type == eventType and cfg.condition == param then
  623 + if cfg.type == eventType and (cfg.condition == param or cfg.isLoop ~= 0) then
621 624 config = cfg
  625 + break
622 626 end
623 627 end
624   - if config ~= nil then
625   - local rechargeCfg = csvdb["shop_normalCsv"][config.packId]
626   - if rechargeCfg then
627   - limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id}
628   - self.owner:log("push_gift", {
629   - gift_id = rechargeCfg.id, --礼包ID
630   - gift_name = rechargeCfg.descId, --礼包名称
631   - })
632   - -- 每日抽卡限时礼包 触发重置
633   - if eventType == TriggerEventType.DrawHeroCnt then
634   - local payR = self:getProperty("buyR")
635   - if payR[rechargeCfg.id] then
636   - payR[rechargeCfg.id] = nil
637   - self:updateProperty({field = "buyR", value = payR})
638   - end
  628 + if not config then return end
  629 +
  630 + -- 每日循环弹窗
  631 + local typeMap = {[TriggerEventType.DrawHero] = 1, [TriggerEventType.FoodSell] = 1, [TriggerEventType.RuneUp] = 1, [TriggerEventType.CostDiamond] = 1, [TriggerEventType.HeroTalent] = 1}
  632 + if typeMap[eventType] then
  633 + local dayInfo = self:getProperty("dayLimitInfo")
  634 + local info = dayInfo[eventType] or {}
  635 + local count = (info["count"] or 0) + param
  636 + local triggerCount = info["trigger"] or 0
  637 + local flag = nil
  638 + if count >= config.condition then
  639 + if triggerCount < config.triggerLimit then
  640 + info["trigger"] = triggerCount + 1
  641 + info["count"] = 0
  642 + flag = true
  643 + else
  644 + info["count"] = config.condition - 1
  645 + end
  646 + else
  647 + info["count"] = count
  648 + end
  649 + dayInfo[eventType] = info
  650 + self:updateProperty({field = "dayLimitInfo", value = dayInfo})
  651 + if not flag then
  652 + return
  653 + end
  654 + end
  655 + local rechargeCfg = csvdb["shop_rechargeCsv"][config.packId]
  656 + if rechargeCfg then
  657 + limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id}
  658 + self.owner:log("push_gift", {
  659 + gift_id = rechargeCfg.id, --礼包ID
  660 + gift_name = rechargeCfg.descId, --礼包名称
  661 + })
  662 + if config.isLoop ~= 0 then
  663 + local payR = self:getProperty("payR")
  664 + if payR[rechargeCfg.id] then
  665 + payR[rechargeCfg.id] = nil
  666 + self:updateProperty({field = "payR", value = payR})
639 667 end
640   - self:updateProperty({field = "limitTPack", value = limitPack})
641 668 end
  669 + -- 每日抽卡限时礼包 触发重置
  670 + --if eventType == TriggerEventType.DrawHeroCnt then
  671 + -- local payR = self:getProperty("buyR")
  672 + -- if payR[rechargeCfg.id] then
  673 + -- payR[rechargeCfg.id] = nil
  674 + -- self:updateProperty({field = "buyR", value = payR})
  675 + -- end
  676 + --end
  677 + self:updateProperty({field = "limitTPack", value = limitPack})
642 678 end
643 679 --if next(result) then
644 680 -- self:updateProperty({field = "packTrigger", value = triggerRecord})
... ... @@ -831,6 +867,7 @@ function Store:data()
831 867 totalRR = self:getProperty("totalRR"),
832 868 monthCardId = self:getProperty("monthCardId"),
833 869 firstMonthCard = self:getProperty("firstMonthCard"),
  870 + firstsMonthCard = self:getProperty("firstsMonthCard"),
834 871 monthCardReceive = self:getProperty("monthCardReceive"),
835 872 smonthCards = self:getProperty("smonthCards"),
836 873 smonthCardReceive = self:getProperty("smonthCardReceive"),
... ...
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
... ... @@ -51,7 +51,9 @@ function getNameByRoleId(roleId)
51 51 end
52 52  
53 53 function broadCastCapsule(roleId, capsuleId, broadInfo)
54   - local capsule = capsules[capsuleId] or {}
  54 + local capsule = capsules[capsuleId]
  55 + if not capsule then print("not capsule :" .. capsuleId) return end
  56 +
55 57 local register = capsule:getProperty("register") or {}
56 58 if next(capsule) then
57 59 for id, _ in pairs(register) do
... ... @@ -63,21 +65,23 @@ function broadCastCapsule(roleId, capsuleId, broadInfo)
63 65 end
64 66  
65 67 function broadCastSpecial(roleId, capsuleId, broadInfo)
66   - local capsule = capsules[capsuleId] or {}
  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
  71 +
67 72 local register = capsule:getProperty("register") or {}
68   - if next(capsule) then
69   - for id, _ in pairs(register) do
70   - if id ~= roleId then
71   - if broadInfo[id] then
72   - rpcRole(id, "paySpecialReward", id, broadInfo[id])
73   - end
  73 + for id, _ in pairs(register) do
  74 + if id ~= roleId then
  75 + if broadInfo[id] then
  76 + rpcRole(id, "paySpecialReward", id, broadInfo[id])
74 77 end
75 78 end
76 79 end
77 80 end
78 81  
79 82 local function add(roleId, capsuleId)
80   - local capsule = capsules[capsuleId] or {}
  83 + local capsule = capsules[capsuleId]
  84 + if not capsule then skynet.error("add not capsule: " .. capsuleId) return end
81 85 if next(capsule) then
82 86 capsule:join(roleId)
83 87 broadCastCapsule(roleId, capsuleId, {notifyType= NotifyChangeType.JOIN, roleId = roleId})
... ... @@ -87,9 +91,12 @@ local function add(roleId, capsuleId)
87 91 return nil
88 92 end
89 93  
90   -local function capsuleRefreshing()
  94 +local function capsuleRefreshing(now)
91 95 for _, v in pairs(capsules) do
92   - if v:refreshing() then
  96 + if v:refreshing(now) then
  97 + print("刷新机器looooook....")
  98 + print(v:getProperty("id"))
  99 + print(v:getProperty("room"))
93 100 v:init()
94 101 v:create()
95 102 end
... ... @@ -98,8 +105,9 @@ end
98 105  
99 106 --扭蛋机刷新
100 107 local function check_capsules()
101   - pcall(capsuleRefreshing)
102   - skynet.timeout(60, check_capsules)
  108 + local now = skynet.timex()
  109 + pcall(capsuleRefreshing, now)
  110 + skynet.timeout(100, check_capsules)
103 111 end
104 112  
105 113 function CMD.reset()
... ... @@ -114,13 +122,11 @@ function CMD.reset()
114 122 for _, val in ipairs(data) do
115 123 if val.type == 1 then
116 124 local key = val.id..val.room
117   - if not capsules[key] then
118   - local capsule = require("models.Capsule").new({ key = CAPSULE_PUBLIC:format(key), id= val.id, room = val.room, typ = 1, name=val.name})
119   - capsule:init()
120   - capsule:create()
121   - capsules[key] = capsule
122   - redisproxy:sadd(CAPSULE_INFO, key)
123   - end
  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)
124 130 end
125 131 end
126 132 end
... ... @@ -149,11 +155,14 @@ function CMD.start()
149 155 if val.type == 1 then
150 156 local key = val.id..val.room
151 157 if not capsules[key] then
152   - local capsule = require("models.Capsule").new({ key = CAPSULE_PUBLIC:format(key), id= val.id, room = val.room, typ = 1, name=val.name})
153   - capsule:init()
154   - capsule:create()
155   - capsules[key] = capsule
156   - 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
157 166 end
158 167 end
159 168 end
... ... @@ -162,10 +171,10 @@ function CMD.start()
162 171 check_capsules()
163 172 end
164 173  
165   -function CMD.list(coin)
  174 +function CMD.list(id)
166 175 local tmpCapsules = {}
167 176 for k, v in pairs(capsules) do
168   - if v:getProperty("coin") == coin then
  177 + if v:getProperty("id") == id then
169 178 local onlineCount= v:getOnlineCount()
170 179 tmpCapsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")}
171 180 end
... ... @@ -183,49 +192,76 @@ end
183 192  
184 193 function CMD.exit(roleId, capsuleId)
185 194 if capsuleId then
186   - local capsule = capsules[capsuleId] or {}
187   - if next(capsule) then
188   - capsule:exit(roleId)
189   - broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.EXIT, roleId = roleId})
190   - 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})
191 200 else
192   - for _, capsule in pairs(capsules) do
  201 + for id, capsule in pairs(capsules) do
193 202 if next(capsule) then
194 203 capsule:exit(roleId)
195   - broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.EXIT, roleId = roleId})
  204 + broadCastCapsule(roleId, id, {notifyType = NotifyChangeType.EXIT, roleId = roleId})
196 205 end
197 206 end
198 207 end
199 208 end
200 209  
201 210 function CMD.draw_capsule(roleId, capsuleId, full, drawsNum, cares)
202   - local capsule = capsules[capsuleId] or {}
203   - if next(capsule) then
204   - local ret, reward, rewardByGoods, notify = capsule:draw(roleId, full, drawsNum, cares)
205   - if ret > 5 then
206   - --broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.DRAW, notify = notify})
207   - broadCastSpecial(roleId, capsuleId, notify)
208   - end
209   - return ret, reward, rewardByGoods, capsule:data(roleId)
  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"])
210 218 end
211   - return 2
  219 + drawReward["specials"] = nil
  220 + return ret, drawReward, capsule:data(roleId)
212 221 end
213 222  
214 223 function CMD.register(roleId, capsuleId)
215   - local capsule = capsules[capsuleId] or {}
  224 + local capsule = capsules[capsuleId]
  225 + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end
  226 +
216 227 return capsule:register(roleId)
217 228 end
218 229  
219 230 function CMD.goods_stock(capsuleId)
220   - local capsule = capsules[capsuleId] or {}
  231 + local capsule = capsules[capsuleId]
  232 + if not capsule then skynet.error("not capsule: " .. capsuleId) return 0 end
  233 +
221 234 return capsule:getGoodsAmount(), capsule:getProperty("token")
222 235 end
223 236  
224 237 function CMD.capsule_data(roleId, capsuleId)
225   - local capsule = capsules[capsuleId] or {}
  238 + local capsule = capsules[capsuleId]
  239 + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end
  240 +
226 241 return capsule:data(roleId)
227 242 end
228 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)
  263 +end
  264 +
229 265 skynet.start(function()
230 266 skynet.dispatch("lua", function(session, address, cmd, ...)
231 267 local f = CMD[string.lower(cmd)]
... ...
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
... ...
src/shared/ModelBaseMysql.lua
... ... @@ -510,6 +510,11 @@ function ModelBaseMysql:updateFields(fields)
510 510 skynet.error("error sql:"..sql)
511 511 skynet.error("error str:"..res["err"])
512 512 return false
  513 + else
  514 + if (res["affected_rows"] or -1) == 0 then
  515 + skynet.error("affected row = 0")
  516 + skynet.error("error sql:"..sql)
  517 + end
513 518 end
514 519 end
515 520 return true
... ...