Commit 08575c686e42858a2e2e00477348687f061751d6

Authored by jiyue
2 parents e08b052f e66080dd

Merge branch 'cn/develop' into cn/player

@@ -136,6 +136,18 @@ function CMD.task() @@ -136,6 +136,18 @@ function CMD.task()
136 startUnit() 136 startUnit()
137 end 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 function CMD.start(fd, id) 152 function CMD.start(fd, id)
141 client.fd = fd 153 client.fd = fd
@@ -133,7 +133,7 @@ ItemStartId = { @@ -133,7 +133,7 @@ ItemStartId = {
133 --常用的物品id的枚举 133 --常用的物品id的枚举
134 ItemId = { 134 ItemId = {
135 Gold = 1, -- 金币 135 Gold = 1, -- 金币
136 - Exp = 2, -- 经验 136 + Exp = 2, -- 能量饮料
137 Jade = 3, -- 虹光玉 137 Jade = 3, -- 虹光玉
138 PlayerExp = 4, -- 突破材料 138 PlayerExp = 4, -- 突破材料
139 FriendPoint = 5, -- 友情点 139 FriendPoint = 5, -- 友情点
@@ -371,6 +371,8 @@ MailId = { @@ -371,6 +371,8 @@ MailId = {
371 CBBackAward2 = 244, 371 CBBackAward2 = 244,
372 ActivityPoolRet = 280, 372 ActivityPoolRet = 280,
373 MyCardBuy = 300, 373 MyCardBuy = 300,
  374 +
  375 + RechargeBack = 3001,
374 } 376 }
375 377
376 TriggerEventType = { 378 TriggerEventType = {
@@ -383,6 +385,13 @@ TriggerEventType = { @@ -383,6 +385,13 @@ TriggerEventType = {
383 AfterTs = 7, -- 某时间以后 385 AfterTs = 7, -- 某时间以后
384 DrawHeroCnt = 8, -- 每日抽卡次数 386 DrawHeroCnt = 8, -- 每日抽卡次数
385 Appoint = 0, -- 触发指定id礼包 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 DrawCardType = { 397 DrawCardType = {
@@ -424,6 +433,8 @@ SystemBnousType = { @@ -424,6 +433,8 @@ SystemBnousType = {
424 UpSpeedNum = 15, -- 加速次数上限增加 15=1探索加速or 2齿轮加速or 3餐厅加速=增加次数 433 UpSpeedNum = 15, -- 加速次数上限增加 15=1探索加速or 2齿轮加速or 3餐厅加速=增加次数
425 ChangeBaseCount = 16, -- 每日奖励关卡挑战卡基础数量增加 434 ChangeBaseCount = 16, -- 每日奖励关卡挑战卡基础数量增加
426 ChangeBuyCount = 17, -- 每日奖励关卡挑战卡可购买次数增加, 435 ChangeBuyCount = 17, -- 每日奖励关卡挑战卡可购买次数增加,
  436 + ExtraProp = 18, -- 每次探索加速额外获得道具
  437 + AccountLevel = 19, -- 账号等级提升角色等级上限
427 } 438 }
428 439
429 -- 开箱物品类型 440 -- 开箱物品类型
@@ -435,4 +446,12 @@ ItemOccupy = { @@ -435,4 +446,12 @@ ItemOccupy = {
435 Spark = 5, --火花 446 Spark = 5, --火花
436 Other = 6, 447 Other = 6,
437 CanUsed = 7, --可使用 448 CanUsed = 7, --可使用
  449 +}
  450 +
  451 +-- 世界变动积分
  452 +ItemWorldLine = {
  453 + RouletteCount = 1, --抽轮盘次数
  454 + Points = 2, --积分
  455 + CostDiamond = 3, --消耗钻石
  456 + CostJade = 4, --消耗红光玉
438 } 457 }
439 \ No newline at end of file 458 \ No newline at end of file
src/ProtocolCode.lua
@@ -13,6 +13,8 @@ actionCodes = { @@ -13,6 +13,8 @@ actionCodes = {
13 Gm_clientRequest = 20, 13 Gm_clientRequest = 20,
14 Gm_receiveResponse = 21, 14 Gm_receiveResponse = 21,
15 Gm_helpRpc = 22, 15 Gm_helpRpc = 22,
  16 + Gm_clientLuaCommandNtf = 23,
  17 + Gm_clientUploadLuaResult = 24,
16 18
17 Role_notifyNewEvent = 100, 19 Role_notifyNewEvent = 100,
18 Role_queryLoginRpc = 101, 20 Role_queryLoginRpc = 101,
@@ -59,7 +61,9 @@ actionCodes = { @@ -59,7 +61,9 @@ actionCodes = {
59 Role_runeBuyRpc = 142, -- 铭文购买 61 Role_runeBuyRpc = 142, -- 铭文购买
60 Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍 62 Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍
61 Role_setBgRpc = 144, -- 设置看板娘 63 Role_setBgRpc = 144, -- 设置看板娘
62 - Role_itemConvertMonthCardRpc = 145, -- 兑换月卡道具 64 + Role_itemConvertSpecialRpc = 145, -- 兑换月卡/战令探索指令等 特殊道具
  65 + Role_worldLineRoulette = 146, --世界线抽轮盘
  66 + Role_worldLineReward = 147, -- 世界线一键领取奖励
63 67
64 Adv_startAdvRpc = 151, 68 Adv_startAdvRpc = 151,
65 Adv_startHangRpc = 152, 69 Adv_startHangRpc = 152,
@@ -225,6 +229,7 @@ actionCodes = { @@ -225,6 +229,7 @@ actionCodes = {
225 Store_getExploreCommandRewardRpc = 563, --探索指令 229 Store_getExploreCommandRewardRpc = 563, --探索指令
226 Store_getTotalRechargeAwardRpc = 564, -- 累计充值 230 Store_getTotalRechargeAwardRpc = 564, -- 累计充值
227 Store_monthCardRewardRpc = 565, --每日月卡+特刊奖励 231 Store_monthCardRewardRpc = 565, --每日月卡+特刊奖励
  232 + Store_dyhxAndroidRechargeRpc = 566, -- 东银河充值
228 233
229 Store_biliCloudRechargeRpc = 596, 234 Store_biliCloudRechargeRpc = 596,
230 Store_biliAndroidRechargeRpc = 597, 235 Store_biliAndroidRechargeRpc = 597,
@@ -245,7 +250,7 @@ actionCodes = { @@ -245,7 +250,7 @@ actionCodes = {
245 Activity_actCalendaTaskRpc = 655, 250 Activity_actCalendaTaskRpc = 655,
246 Activity_actPaySignRpc = 656, 251 Activity_actPaySignRpc = 656,
247 Activity_exchangeRpc = 657, 252 Activity_exchangeRpc = 657,
248 - Activity_gachakonRpc = 658, 253 + Activity_gachakonRpc = 658, --狩猎祭 抽扭蛋机
249 Activity_hangDropRpc = 659, 254 Activity_hangDropRpc = 659,
250 Activity_startBattleRpc = 660, 255 Activity_startBattleRpc = 660,
251 Activity_endBattleRpc = 661, 256 Activity_endBattleRpc = 661,
@@ -263,6 +268,7 @@ actionCodes = { @@ -263,6 +268,7 @@ actionCodes = {
263 Activity_returnerTaskRpc = 673, 268 Activity_returnerTaskRpc = 673,
264 Activity_actNewUserTaskRpc = 674, 269 Activity_actNewUserTaskRpc = 674,
265 Activity_buyBattleTicketRpc = 675, 270 Activity_buyBattleTicketRpc = 675,
  271 + Activity_resetGachakonRpc = 676, --狩猎祭,重制扭蛋机
266 272
267 Radio_startQuestRpc = 700, 273 Radio_startQuestRpc = 700,
268 Radio_finishQuestRpc = 701, 274 Radio_finishQuestRpc = 701,
@@ -281,10 +287,12 @@ actionCodes = { @@ -281,10 +287,12 @@ actionCodes = {
281 Capsule_drawRpc = 854, --抽扭蛋机 287 Capsule_drawRpc = 854, --抽扭蛋机
282 --Capsule_switchRoomRpc = 855, --切换扭蛋机房间 288 --Capsule_switchRoomRpc = 855, --切换扭蛋机房间
283 Capsule_notifyChange = 856, -- 通知信息变动 289 Capsule_notifyChange = 856, -- 通知信息变动
284 - Capsule_payReward = 857, -- 特殊赏 奖励通知 290 + Capsule_specialRewardRpc = 857, -- 获取 未领取特殊赏通知 主动
285 Capsule_exitRpc = 858, -- 退出 291 Capsule_exitRpc = 858, -- 退出
286 Capsule_getDataRpc = 859, --获取扭蛋机信息 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 rpcResponseBegin = 10000 298 rpcResponseBegin = 10000
src/actions/ActivityAction.lua
@@ -315,7 +315,27 @@ function _M.actBattleCommandTaskRpc(agent, data) @@ -315,7 +315,27 @@ function _M.actBattleCommandTaskRpc(agent, data)
315 315
316 role:updateProperty({field = "bcTask", value = calTask}) 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 role:log("activity", { 340 role:log("activity", {
321 activity_id = taskId, -- 活动ID(或活动指定任务的ID) 341 activity_id = taskId, -- 活动ID(或活动指定任务的ID)
@@ -479,6 +499,20 @@ function _M.gachakonRpc(agent, data) @@ -479,6 +499,20 @@ function _M.gachakonRpc(agent, data)
479 return true 499 return true
480 end 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 function _M.hangDropRpc(agent, data) 516 function _M.hangDropRpc(agent, data)
483 local role = agent.role 517 local role = agent.role
484 local msg = MsgPack.unpack(data) 518 local msg = MsgPack.unpack(data)
@@ -605,6 +639,8 @@ function _M.startBattleRpc(agent, data) @@ -605,6 +639,8 @@ function _M.startBattleRpc(agent, data)
605 end 639 end
606 end 640 end
607 num = num * count 641 num = num * count
  642 + else
  643 + num = 0
608 end 644 end
609 if ticket < num then 645 if ticket < num then
610 return 6 646 return 6
@@ -643,7 +679,7 @@ function _M.startBattleRpc(agent, data) @@ -643,7 +679,7 @@ function _M.startBattleRpc(agent, data)
643 award[k] = v * count 679 award[k] = v * count
644 end 680 end
645 local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) 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 changeFlag = true 683 changeFlag = true
648 actData["ticket"] = ticket - num 684 actData["ticket"] = ticket - num
649 685
@@ -663,11 +699,15 @@ function _M.startBattleRpc(agent, data) @@ -663,11 +699,15 @@ function _M.startBattleRpc(agent, data)
663 end 699 end
664 role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) 700 role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal)
665 end 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 end 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 return true 712 return true
673 end 713 end
@@ -801,10 +841,12 @@ function _M.endBattleRpc(agent, data) @@ -801,10 +841,12 @@ function _M.endBattleRpc(agent, data)
801 end 841 end
802 842
803 if battleCfg.rank ~= 0 and isWin then 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 battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg) 852 battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg)
@@ -1337,8 +1379,8 @@ function _M.buyBattleCommandLvlRpc(agent, data) @@ -1337,8 +1379,8 @@ function _M.buyBattleCommandLvlRpc(agent, data)
1337 end 1379 end
1338 if cost == 0 then return 5 end 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 actData["lvl"] = nextLvl 1384 actData["lvl"] = nextLvl
1343 role.activity:updateActData("BattleCommand", actData) 1385 role.activity:updateActData("BattleCommand", actData)
1344 role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl}) 1386 role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl})
@@ -1486,7 +1528,7 @@ function _M.buyBattleTicketRpc(agent, data) @@ -1486,7 +1528,7 @@ function _M.buyBattleTicketRpc(agent, data)
1486 end 1528 end
1487 local cost = globalCsv.activity_scrofa_tickets[curCount + 1] 1529 local cost = globalCsv.activity_scrofa_tickets[curCount + 1]
1488 if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end 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 actData["ticket"] = (actData["ticket"] or 0) + 1 1532 actData["ticket"] = (actData["ticket"] or 0) + 1
1491 actData["buyC"] = curCount + count 1533 actData["buyC"] = curCount + count
1492 1534
src/actions/AdvAction.lua
@@ -459,11 +459,12 @@ function _M.endHangRpc(agent, data) @@ -459,11 +459,12 @@ function _M.endHangRpc(agent, data)
459 heroCnt = heroCnt + 1 459 heroCnt = heroCnt + 1
460 end 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 end 468 end
468 469
469 local bnousReward = role:getBnousAdv() 470 local bnousReward = role:getBnousAdv()
src/actions/CapsuleAction.lua
@@ -17,18 +17,18 @@ function _M.listRpc(agent, data) @@ -17,18 +17,18 @@ function _M.listRpc(agent, data)
17 local role = agent.role 17 local role = agent.role
18 local msg = MsgPack.unpack(data) 18 local msg = MsgPack.unpack(data)
19 local typ = msg.typ 19 local typ = msg.typ
20 - local coin = msg.coin 20 + local id = msg.id
21 21
22 local capsules = {} 22 local capsules = {}
23 if typ == 1 then 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 if next(ret) then 25 if next(ret) then
26 for k, v in pairs(ret) do 26 for k, v in pairs(ret) do
27 capsules[k] = v 27 capsules[k] = v
28 end 28 end
29 end 29 end
30 elseif typ == 0 then 30 elseif typ == 0 then
31 - local ret = role:getCapsuleList(coin) 31 + local ret = role:getCapsuleList(id)
32 if next(ret) then 32 if next(ret) then
33 for k, v in pairs(ret) do 33 for k, v in pairs(ret) do
34 capsules[k] = v 34 capsules[k] = v
@@ -51,7 +51,7 @@ function _M.joinRpc(agent, data) @@ -51,7 +51,7 @@ function _M.joinRpc(agent, data)
51 if typ == 1 then 51 if typ == 1 then
52 ret = skynet.call(agent.capsule_serv, "lua", "join", roleId, capsuleId) 52 ret = skynet.call(agent.capsule_serv, "lua", "join", roleId, capsuleId)
53 elseif typ == 0 then 53 elseif typ == 0 then
54 - ret = role:joinCapsule() 54 + ret = role:joinCapsule(roleId, capsuleId)
55 end 55 end
56 SendPacket(actionCodes.Capsule_joinRpc, MsgPack.pack(ret)) 56 SendPacket(actionCodes.Capsule_joinRpc, MsgPack.pack(ret))
57 return true 57 return true
@@ -96,7 +96,7 @@ function _M.drawRpc(agent, data) @@ -96,7 +96,7 @@ function _M.drawRpc(agent, data)
96 local full = msg.full or 0-- 0=单次,1=十连抽 2=全收 96 local full = msg.full or 0-- 0=单次,1=十连抽 2=全收
97 local cares = msg.cares 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 if typ == 1 then 102 if typ == 1 then
@@ -127,26 +127,23 @@ function _M.drawRpc(agent, data) @@ -127,26 +127,23 @@ function _M.drawRpc(agent, data)
127 127
128 --开始抽奖 128 --开始抽奖
129 if typ == 1 then 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 else 131 else
132 - ret, reward, rewardByGoods, capsule= role:drawCapsule(capsuleId, full, cares) 132 + ret, drawReward, capsule = role:drawCapsule(capsuleId, full, cares)
133 end 133 end
134 if ret < 5 then 134 if ret < 5 then
135 return ret 135 return ret
136 end 136 end
137 137
138 - --dump(rewardByGoods)  
139 - --dump(capsule)  
140 -  
141 if ret == 5 then 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 return true 140 return true
144 end 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 else 147 else
151 return ret 148 return ret
152 end 149 end
@@ -164,7 +161,7 @@ function _M.getDataRpc(agent, data) @@ -164,7 +161,7 @@ function _M.getDataRpc(agent, data)
164 if typ == 1 then 161 if typ == 1 then
165 capsule = skynet.call(agent.capsule_serv, "lua", "capsule_data", roleId, capsuleId) 162 capsule = skynet.call(agent.capsule_serv, "lua", "capsule_data", roleId, capsuleId)
166 else 163 else
167 - capsule = role:getCapsuleData(capsuleId) 164 + capsule = role:getCapsuleData(roleId, capsuleId)
168 end 165 end
169 if not capsule then return 1 end 166 if not capsule then return 1 end
170 167
@@ -190,9 +187,67 @@ function _M.convertCapsuleRpc(agent, data) @@ -190,9 +187,67 @@ function _M.convertCapsuleRpc(agent, data)
190 if not role:checkItemEnough(cost) then return 1 end 187 if not role:checkItemEnough(cost) then return 1 end
191 role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}}) 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 SendPacket(actionCodes.Capsule_convertCapsuleRpc, MsgPack.pack(role:packReward(reward, change))) 192 SendPacket(actionCodes.Capsule_convertCapsuleRpc, MsgPack.pack(role:packReward(reward, change)))
195 return true 193 return true
196 end 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 return _M 253 return _M
199 \ No newline at end of file 254 \ No newline at end of file
src/actions/GmAction.lua
@@ -675,6 +675,13 @@ function _M.helpRpc(agent, data) @@ -675,6 +675,13 @@ function _M.helpRpc(agent, data)
675 return true 675 return true
676 end 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 function _M.test(role, pms) 685 function _M.test(role, pms)
679 local id = tonum(pms.pm1, 0) 686 local id = tonum(pms.pm1, 0)
680 local actid = nil 687 local actid = nil
@@ -722,6 +729,8 @@ function _M.cz(role, pms) @@ -722,6 +729,8 @@ function _M.cz(role, pms)
722 pay_time = skynet.timex(), 729 pay_time = skynet.timex(),
723 sid = sid == 1 and IOS_SID or 0, 730 sid = sid == 1 and IOS_SID or 0,
724 }) 731 })
  732 + -- 补发邮件
  733 + role:sendMail(MailId.RechargeBack)
725 role:mylog("gm_action", {desc = "recharge", int1 = id, key1 = pms.sender}) 734 role:mylog("gm_action", {desc = "recharge", int1 = id, key1 = pms.sender})
726 return "指令成功" 735 return "指令成功"
727 end 736 end
@@ -1086,4 +1095,10 @@ function _M.reset_capsule(role, pms, capsule_serv) @@ -1086,4 +1095,10 @@ function _M.reset_capsule(role, pms, capsule_serv)
1086 return "成功" 1095 return "成功"
1087 end 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 return _M 1104 return _M
1090 \ No newline at end of file 1105 \ No newline at end of file
src/actions/HangAction.lua
@@ -528,16 +528,20 @@ function _M.quickRpc(agent , data) @@ -528,16 +528,20 @@ function _M.quickRpc(agent , data)
528 end 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 end 536 end
539 end 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 local change 545 local change
542 reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) 546 reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
543 if reward[ItemId.Gold] then 547 if reward[ItemId.Gold] then
src/actions/HeroAction.lua
@@ -42,10 +42,14 @@ function _M.levelUpRpc( agent, data ) @@ -42,10 +42,14 @@ function _M.levelUpRpc( agent, data )
42 if not role:checkItemEnough(cost) then return 3 end 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 role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}}) 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,10 +90,10 @@ function _M.breakRpc( agent, data )
86 if not role:checkItemEnough(cost) then return 4 end 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 role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}}) 98 role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}})
95 local oldAttr = hero:getTotalAttrs() 99 local oldAttr = hero:getTotalAttrs()
@@ -147,9 +151,11 @@ function _M.wakeRpc(agent, data) @@ -147,9 +151,11 @@ function _M.wakeRpc(agent, data)
147 local oldBattleV = hero:getProperty("battleV") 151 local oldBattleV = hero:getProperty("battleV")
148 hero:updateProperty({field = "wakeL", delta = 1}) 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 if curLevel == 3 then -- 解锁cg 156 if curLevel == 3 then -- 解锁cg
152 role:checkTaskEnter("WakeCG", {heroType = typ}) 157 role:checkTaskEnter("WakeCG", {heroType = typ})
  158 + role:checkTaskEnter("WakeCGSum", {count = 1})
153 end 159 end
154 160
155 if curLevel >= 4 then --自动觉醒技能 161 if curLevel >= 4 then --自动觉醒技能
@@ -173,6 +179,7 @@ function _M.wakeRpc(agent, data) @@ -173,6 +179,7 @@ function _M.wakeRpc(agent, data)
173 SendPacket(actionCodes.Hero_wakeRpc, '') 179 SendPacket(actionCodes.Hero_wakeRpc, '')
174 180
175 role:checkTaskEnter("HeroStarCollect", {}) 181 role:checkTaskEnter("HeroStarCollect", {})
  182 + role:checkTaskEnter("HeroStartSum", {})
176 return true 183 return true
177 end 184 end
178 185
@@ -212,7 +219,7 @@ function _M.talentRpc(agent, data) @@ -212,7 +219,7 @@ function _M.talentRpc(agent, data)
212 talent = talent:setv(1, curLevel + 1) 219 talent = talent:setv(1, curLevel + 1)
213 end 220 end
214 curStage = talent:getv(0, 1) 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 hero:updateProperty({field = "talent", value = talent}) 224 hero:updateProperty({field = "talent", value = talent})
218 225
src/actions/HttpAction.lua
@@ -143,7 +143,7 @@ function _M.gm_action(query) @@ -143,7 +143,7 @@ function _M.gm_action(query)
143 role:startActionUcode() 143 role:startActionUcode()
144 local status = gmFuncs[query.cmd](role, query) 144 local status = gmFuncs[query.cmd](role, query)
145 role:endActionUcode() 145 role:endActionUcode()
146 - role:update() 146 + role:saveRoleData()
147 147
148 return status 148 return status
149 end 149 end
@@ -174,6 +174,7 @@ function _M.pay_action(query) @@ -174,6 +174,7 @@ function _M.pay_action(query)
174 role:startActionUcode() 174 role:startActionUcode()
175 local status = gmFuncs[query.cmd](role, query) 175 local status = gmFuncs[query.cmd](role, query)
176 role:endActionUcode() 176 role:endActionUcode()
  177 + role:saveRoleData()
177 178
178 return status 179 return status
179 end 180 end
src/actions/RoleAction.lua
@@ -288,7 +288,9 @@ function _M.loginRpc( agent, data ) @@ -288,7 +288,9 @@ function _M.loginRpc( agent, data )
288 288
289 -- 注册全服广播 289 -- 注册全服广播
290 if not role._channelIdx then 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 role._channelIdx = channel 294 role._channelIdx = channel
293 end 295 end
294 if not mcast_util.channel_world() then 296 if not mcast_util.channel_world() then
@@ -1710,36 +1712,112 @@ function _M.setBgRpc(agent, data) @@ -1710,36 +1712,112 @@ function _M.setBgRpc(agent, data)
1710 return true 1712 return true
1711 end 1713 end
1712 1714
1713 -function _M.itemConvertMonthCardRpc(agent, data) 1715 +function _M.itemConvertSpecialRpc(agent, data)
1714 local role = agent.role 1716 local role = agent.role
1715 local msg = MsgPack.unpack(data) 1717 local msg = MsgPack.unpack(data)
1716 local itemId = msg.item_id 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 local rechargeData = csvdb["shop_rechargeCsv"][exchangeId] 1724 local rechargeData = csvdb["shop_rechargeCsv"][exchangeId]
1727 if not rechargeData then 1725 if not rechargeData then
1728 skynet.error("[recharge] recharge id not exist", exchangeId) 1726 skynet.error("[recharge] recharge id not exist", exchangeId)
1729 - return 3 1727 + return 2
1730 end 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 if tmpreward then 1751 if tmpreward then
1735 table.rewardMerge(reward, tmpreward) 1752 table.rewardMerge(reward, tmpreward)
1736 - else  
1737 - return  
1738 end 1753 end
1739 end 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 end 1821 end
1744 1822
1745 return _M 1823 return _M
1746 \ No newline at end of file 1824 \ No newline at end of file
src/actions/SeaportAction.lua
@@ -267,7 +267,7 @@ function _M.shopRpc(agent, data) @@ -267,7 +267,7 @@ function _M.shopRpc(agent, data)
267 local shopCsv = {} 267 local shopCsv = {}
268 local dataSet = csvdb["shop_normalCsv"] 268 local dataSet = csvdb["shop_normalCsv"]
269 for _, datat in pairs(dataSet) do 269 for _, datat in pairs(dataSet) do
270 - if datat.shop == 5 then 270 + if datat.shop == 4 then
271 shopCsv[datat.id] = datat 271 shopCsv[datat.id] = datat
272 end 272 end
273 end 273 end
src/actions/StoreAction.lua
@@ -52,6 +52,19 @@ local function signPms(params, secret_key) @@ -52,6 +52,19 @@ local function signPms(params, secret_key)
52 return md5.sumhexa(urlCode .. secret_key):lower() 52 return md5.sumhexa(urlCode .. secret_key):lower()
53 end 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 -- bili android 充值 入口 68 -- bili android 充值 入口
56 function _M.biliAndroidRechargeRpc(agent, data) 69 function _M.biliAndroidRechargeRpc(agent, data)
57 local role = agent.role 70 local role = agent.role
@@ -226,7 +239,7 @@ function _M.iosRechargeRpc(agent, data) @@ -226,7 +239,7 @@ function _M.iosRechargeRpc(agent, data)
226 --创建订单号 239 --创建订单号
227 local partnerOrderId = role:getPurchaseOrder(id,nil,choose) 240 local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
228 -- 签名 241 -- 签名
229 - local secret_key = "1916d62251dd4a8aa5e452121eefc9a1" 242 + local secret_key = "2b2036e1f44640a59168c92462714870"
230 local need = { 243 local need = {
231 out_trade_no = partnerOrderId, 244 out_trade_no = partnerOrderId,
232 money = dataSet.rmb * 100, 245 money = dataSet.rmb * 100,
@@ -234,12 +247,40 @@ function _M.iosRechargeRpc(agent, data) @@ -234,12 +247,40 @@ function _M.iosRechargeRpc(agent, data)
234 product_id = dataSet.iap_product_id, 247 product_id = dataSet.iap_product_id,
235 notify_url = msg.notifyUrl 248 notify_url = msg.notifyUrl
236 } 249 }
237 - local sign = signPms(need, secret_key) 250 + local sign = signDyhPms(need, secret_key)
238 251
239 SendPacket(actionCodes.Store_iosRechargeRpc, MsgPack.pack({ order = partnerOrderId, sign = sign})) 252 SendPacket(actionCodes.Store_iosRechargeRpc, MsgPack.pack({ order = partnerOrderId, sign = sign}))
240 return true 253 return true
241 end 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 function _M.purchaseOrderResult(agent, data) 284 function _M.purchaseOrderResult(agent, data)
244 local role = agent.role 285 local role = agent.role
245 286
@@ -315,7 +356,7 @@ function _M.shopBuyRpc(agent , data) @@ -315,7 +356,7 @@ function _M.shopBuyRpc(agent , data)
315 role.storeData:updateProperty({field = "buyR", value = buyRecord}) 356 role.storeData:updateProperty({field = "buyR", value = buyRecord})
316 limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) 357 limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit)
317 end 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 local gift = {} 361 local gift = {}
321 for _id, _count in pairs(dataSet.gift:toNumMap()) do 362 for _id, _count in pairs(dataSet.gift:toNumMap()) do
@@ -35,10 +35,17 @@ local function handle_timeout() @@ -35,10 +35,17 @@ local function handle_timeout()
35 skynet.timeout(100, handle_timeout) 35 skynet.timeout(100, handle_timeout)
36 end 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 function start_agent_timer() 44 function start_agent_timer()
39 if agentInfo.open_timer then return end 45 if agentInfo.open_timer then return end
40 agentInfo.open_timer = true 46 agentInfo.open_timer = true
41 skynet.timeout(150, handle_timeout) 47 skynet.timeout(150, handle_timeout)
  48 + skynet.timeout(6000, handle_gc)
42 end 49 end
43 50
44 function cancel_agent_timer() 51 function cancel_agent_timer()
1 -Subproject commit 4d894270d4aeb6352a29dfd3a8686cbaea5b427c 1 +Subproject commit 45264603ff07db4cd2eaf8822c17f453bf5f00de
src/models/Activity.lua
@@ -93,6 +93,8 @@ Activity.schema = { @@ -93,6 +93,8 @@ Activity.schema = {
93 93
94 act34 = {"table", {}}, -- 战令记录{unlock = 1, freeR = "", payR = "", lvl = 10, sum = 100} 94 act34 = {"table", {}}, -- 战令记录{unlock = 1, freeR = "", payR = "", lvl = 10, sum = 100}
95 act36 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1} 95 act36 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1}
  96 +
  97 + reset20 = {"number", 1}, -- 重置扭蛋机
96 } 98 }
97 99
98 function Activity:data() 100 function Activity:data()
@@ -121,6 +123,8 @@ function Activity:data() @@ -121,6 +123,8 @@ function Activity:data()
121 123
122 act34 = self:getProperty("act34"), 124 act34 = self:getProperty("act34"),
123 act36 = self:getProperty("act36"), 125 act36 = self:getProperty("act36"),
  126 +
  127 + reset20 = self:getProperty("reset20")
124 } 128 }
125 end 129 end
126 130
@@ -207,6 +211,24 @@ function Activity:isOpenById(id, activityType) @@ -207,6 +211,24 @@ function Activity:isOpenById(id, activityType)
207 return self._isOpen[id] 211 return self._isOpen[id]
208 end 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 function Activity:getActData(actType) 232 function Activity:getActData(actType)
211 actType = checkActivityType(actType) 233 actType = checkActivityType(actType)
212 return self:getProperty("act" .. actType) 234 return self:getProperty("act" .. actType)
@@ -497,6 +519,7 @@ activityFunc[Activity.ActivityType.CalendaTask] = { @@ -497,6 +519,7 @@ activityFunc[Activity.ActivityType.CalendaTask] = {
497 --role:checkTaskEnter("HangPass", {id = 0}) 519 --role:checkTaskEnter("HangPass", {id = 0})
498 role:checkCalendaTask(true, 15, 3) 520 role:checkCalendaTask(true, 15, 3)
499 role:checkTaskEnter("HeroStarCollect", {}) 521 role:checkTaskEnter("HeroStarCollect", {})
  522 + role:checkTaskEnter("HeroStartSum", {})
500 role:checkTaskEnter("RuneQualityCollect", {}) 523 role:checkTaskEnter("RuneQualityCollect", {})
501 524
502 end, 525 end,
@@ -565,6 +588,7 @@ activityFunc[Activity.ActivityType.BattleCommandTask] = { @@ -565,6 +588,7 @@ activityFunc[Activity.ActivityType.BattleCommandTask] = {
565 --role:checkTaskEnter("HangPass", {id = 0}) 588 --role:checkTaskEnter("HangPass", {id = 0})
566 role:checkCalendaTask(true, 15, 3) 589 role:checkCalendaTask(true, 15, 3)
567 role:checkTaskEnter("HeroStarCollect", {}) 590 role:checkTaskEnter("HeroStarCollect", {})
  591 + role:checkTaskEnter("HeroStartSum", {})
568 role:checkTaskEnter("RuneQualityCollect", {}) 592 role:checkTaskEnter("RuneQualityCollect", {})
569 593
570 end, 594 end,
@@ -669,6 +693,7 @@ activityFunc[Activity.ActivityType.NewUserTask] = { @@ -669,6 +693,7 @@ activityFunc[Activity.ActivityType.NewUserTask] = {
669 --role:checkTaskEnter("HangPass", {id = 0}) 693 --role:checkTaskEnter("HangPass", {id = 0})
670 role:checkCalendaTask(true, 15, 3) 694 role:checkCalendaTask(true, 15, 3)
671 role:checkTaskEnter("HeroStarCollect", {}) 695 role:checkTaskEnter("HeroStarCollect", {})
  696 + role:checkTaskEnter("HeroStartSum", {})
672 role:checkTaskEnter("RuneQualityCollect", {}) 697 role:checkTaskEnter("RuneQualityCollect", {})
673 698
674 end, 699 end,
@@ -753,8 +778,14 @@ activityFunc[Activity.ActivityType.Gachakon] = { @@ -753,8 +778,14 @@ activityFunc[Activity.ActivityType.Gachakon] = {
753 self:updateActData(actType, {}, not notify) 778 self:updateActData(actType, {}, not notify)
754 end, 779 end,
755 ["crossDay"] = function(self, actType, notify) 780 ["crossDay"] = function(self, actType, notify)
756 - self:updateActData(actType, {}, not notify) 781 + self:updateResetData(actType, 1)
  782 + --self:updateActData(actType, {}, not notify)
757 end, 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,6 +893,15 @@ function Activity:refreshWeekData(notify)
862 end 893 end
863 end 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 function Activity:checkActivity(notNotify, activityType, ...) 905 function Activity:checkActivity(notNotify, activityType, ...)
866 if not activityType then return end 906 if not activityType then return end
867 if not self:isOpen(activityType) then return end 907 if not self:isOpen(activityType) then return end
src/models/Capsule.lua
@@ -44,8 +44,8 @@ Capsule.schema = { @@ -44,8 +44,8 @@ Capsule.schema = {
44 goods = {"table", {}}, --奖励池 44 goods = {"table", {}}, --奖励池
45 specials = {"table", {}}, --特殊赏 45 specials = {"table", {}}, --特殊赏
46 incentive = {"table", {}}, --激励奖 46 incentive = {"table", {}}, --激励奖
47 - incentiveRecord = {"table", {}}, --激励奖记录  
48 - specialsRecord= {"table", {}}, --特殊赏领取记录 47 + incentiveRecord = {"table", {}}, --激励奖记录 {roleId = {}, roleId={}}
  48 + specialsRecord= {"table", {}}, --特殊赏领取记录 {1={},2={}} key=触发特殊赏的 抽奖次数, v=特殊赏商品 table
49 resetTimes = {"number", 0}, --每日一次手动重置的机会 49 resetTimes = {"number", 0}, --每日一次手动重置的机会
50 hideTime = {"number", 0} , --隐藏时间 50 hideTime = {"number", 0} , --隐藏时间
51 drawEndTime = {"number", 0}, --抽完时间 51 drawEndTime = {"number", 0}, --抽完时间
@@ -145,6 +145,80 @@ function Capsule:isShow() @@ -145,6 +145,80 @@ function Capsule:isShow()
145 return true 145 return true
146 end 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 function Capsule:refreshing(now) 222 function Capsule:refreshing(now)
149 local id = self:getProperty("id") 223 local id = self:getProperty("id")
150 local room = self:getProperty("room") 224 local room = self:getProperty("room")
@@ -154,30 +228,13 @@ function Capsule:refreshing(now) @@ -154,30 +228,13 @@ function Capsule:refreshing(now)
154 if reset == "0" then 228 if reset == "0" then
155 return false 229 return false
156 elseif reset == "1" then 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 return true 233 return true
159 end 234 end
160 return false 235 return false
161 else 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 end 238 end
182 239
183 return false 240 return false
@@ -274,7 +331,7 @@ function Capsule:checkSpecialFlag(typ) @@ -274,7 +331,7 @@ function Capsule:checkSpecialFlag(typ)
274 return spKey, special 331 return spKey, special
275 end 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 local rewardByRole = {} 335 local rewardByRole = {}
279 while(count > 0 and next(rewardRecord)) do 336 while(count > 0 and next(rewardRecord)) do
280 local roleId = math.randWeight(rewardRecord, "amount") 337 local roleId = math.randWeight(rewardRecord, "amount")
@@ -285,19 +342,9 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now) @@ -285,19 +342,9 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now)
285 342
286 if tmp["amount"] <= 0 then rewardRecord[roleId] = nil end 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 count = count - 1 349 count = count - 1
303 end 350 end
@@ -306,20 +353,11 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now) @@ -306,20 +353,11 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now)
306 end 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 end 361 end
324 end 362 end
325 363
@@ -357,12 +395,12 @@ function Capsule:getTop(record, recordAmount,now) @@ -357,12 +395,12 @@ function Capsule:getTop(record, recordAmount,now)
357 end 395 end
358 end 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 special["amount"] = count 400 special["amount"] = count
363 specials[spKey] = special 401 specials[spKey] = special
364 402
365 - rewardToNtyFunc(specialsRecord, rewardByRole) 403 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
366 404
367 self:setProperties({specialsRecord = specialsRecord, specials = specials}) 405 self:setProperties({specialsRecord = specialsRecord, specials = specials})
368 return rewardByRole 406 return rewardByRole
@@ -379,12 +417,11 @@ function Capsule:getCore(record, recordAmount,now) @@ -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 local roleRecord = {} 425 local roleRecord = {}
389 for i, v in ipairs(record) do 426 for i, v in ipairs(record) do
390 if count <= 0 then break end 427 if count <= 0 then break end
@@ -407,17 +444,17 @@ function Capsule:getCore(record, recordAmount,now) @@ -407,17 +444,17 @@ function Capsule:getCore(record, recordAmount,now)
407 444
408 end 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 special["amount"] = count 449 special["amount"] = count
413 specials[spKey] = special 450 specials[spKey] = special
414 451
415 - rewardToNtyFunc(specialsRecord, rewardByRole) 452 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
416 self:setProperties({specialsRecord = specialsRecord, specials = specials}) 453 self:setProperties({specialsRecord = specialsRecord, specials = specials})
417 return rewardByRole 454 return rewardByRole
418 end 455 end
419 456
420 -function Capsule:getLast(record,now) 457 +function Capsule:getLast(record, recordAmount, now)
421 local spKey, special = self:checkSpecialFlag(SpecialType.LAST) 458 local spKey, special = self:checkSpecialFlag(SpecialType.LAST)
422 if not special then return nil end 459 if not special then return nil end
423 460
@@ -426,8 +463,7 @@ function Capsule:getLast(record,now) @@ -426,8 +463,7 @@ function Capsule:getLast(record,now)
426 463
427 table.sort(record, function(a, b) return a.create_time > b.create_time end) 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 local roleRecord = {} 467 local roleRecord = {}
432 for _, v in ipairs(record) do 468 for _, v in ipairs(record) do
433 if count <= 0 then break end 469 if count <= 0 then break end
@@ -448,17 +484,17 @@ function Capsule:getLast(record,now) @@ -448,17 +484,17 @@ function Capsule:getLast(record,now)
448 end 484 end
449 end 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 special["amount"] = count 489 special["amount"] = count
454 specials[spKey] = special 490 specials[spKey] = special
455 491
456 - rewardToNtyFunc(specialsRecord, rewardByRole) 492 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
457 self:setProperties({specialsRecord = specialsRecord, specials = specials}) 493 self:setProperties({specialsRecord = specialsRecord, specials = specials})
458 return rewardByRole 494 return rewardByRole
459 end 495 end
460 496
461 -function Capsule:getJoker(record,now) 497 +function Capsule:getJoker(record, recordAmount, now)
462 local spKey, special = self:checkSpecialFlag(SpecialType.JOKER) 498 local spKey, special = self:checkSpecialFlag(SpecialType.JOKER)
463 if not special then return nil end 499 if not special then return nil end
464 500
@@ -474,37 +510,50 @@ function Capsule:getJoker(record,now) @@ -474,37 +510,50 @@ function Capsule:getJoker(record,now)
474 end 510 end
475 end 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 special["amount"] = count 515 special["amount"] = count
480 specials[spKey] = special 516 specials[spKey] = special
481 517
482 - rewardToNtyFunc(specialsRecord, rewardByRole) 518 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
483 self:setProperties({specialsRecord = specialsRecord, specials = specials}) 519 self:setProperties({specialsRecord = specialsRecord, specials = specials})
484 return rewardByRole 520 return rewardByRole
485 end 521 end
486 522
487 -function Capsule:getKing(record,now) 523 +function Capsule:getKing(record, recordAmount, now)
488 local spKey, special = self:checkSpecialFlag(SpecialType.KING) 524 local spKey, special = self:checkSpecialFlag(SpecialType.KING)
489 if not special then return nil end 525 if not special then return nil end
490 526
491 local specials = self:getProperty("specials") or {} 527 local specials = self:getProperty("specials") or {}
492 local specialsRecord = self:getProperty("specialsRecord") or {} 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 local roleRecord = {} 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 end 551 end
502 552
503 - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], spKey, SpecialType.KING,now)  
504 special["amount"] = count 553 special["amount"] = count
505 specials[spKey] = special 554 specials[spKey] = special
506 555
507 - rewardToNtyFunc(specialsRecord, rewardByRole) 556 + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole)
508 self:setProperties({specialsRecord = specialsRecord, specials = specials}) 557 self:setProperties({specialsRecord = specialsRecord, specials = specials})
509 return rewardByRole 558 return rewardByRole
510 end 559 end
@@ -523,16 +572,16 @@ function Capsule:checkSpecialReward(now, goodsAmount) @@ -523,16 +572,16 @@ function Capsule:checkSpecialReward(now, goodsAmount)
523 572
524 if goodsAmount == 0 then 573 if goodsAmount == 0 then
525 local coreReward = self:getCore(record, recordAmount, now) 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 end 585 end
537 586
538 return notify 587 return notify
@@ -572,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now) @@ -572,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now)
572 end 621 end
573 622
574 local count = math.floor(amount / incentive["amount"]["np"]) 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 end 641 end
591 end 642 end
592 -  
593 end 643 end
594 end 644 end
595 645
@@ -601,12 +651,44 @@ function Capsule:checkIncentive(roleId, name, now) @@ -601,12 +651,44 @@ function Capsule:checkIncentive(roleId, name, now)
601 651
602 end 652 end
603 end 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 incentiveRecord[roleId] = incentiveByRole 661 incentiveRecord[roleId] = incentiveByRole
606 self:setProperty("incentiveRecord", incentiveRecord) 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 end 692 end
611 693
612 function Capsule:drawByCount(roleId, count) 694 function Capsule:drawByCount(roleId, count)
@@ -614,6 +696,8 @@ function Capsule:drawByCount(roleId, count) @@ -614,6 +696,8 @@ function Capsule:drawByCount(roleId, count)
614 696
615 local goods = self:getProperty("goods") or {} 697 local goods = self:getProperty("goods") or {}
616 local record = self:getProperty("record") or {} 698 local record = self:getProperty("record") or {}
  699 + local rank = self:getProperty("rank") or {}
  700 + local rankRole = rank[roleId] or 0
617 local recordByRole = self:getProperty("recordByRole") or {} 701 local recordByRole = self:getProperty("recordByRole") or {}
618 local roleRecord = recordByRole[roleId] or {} 702 local roleRecord = recordByRole[roleId] or {}
619 703
@@ -623,9 +707,8 @@ function Capsule:drawByCount(roleId, count) @@ -623,9 +707,8 @@ function Capsule:drawByCount(roleId, count)
623 local goods_id = ichibankuji["goods_id"] 707 local goods_id = ichibankuji["goods_id"]
624 local now = skynet.timex() 708 local now = skynet.timex()
625 709
626 - --奖励, 通知信息  
627 - local notify= {}  
628 - notify[roleId] = {} 710 + --奖励,普通奖品信息
  711 + local goodsByUsual= {}
629 712
630 local name = getNameByRoleId(roleId) 713 local name = getNameByRoleId(roleId)
631 while (goods and next(goods) and count > 0) do 714 while (goods and next(goods) and count > 0) do
@@ -636,15 +719,18 @@ function Capsule:drawByCount(roleId, count) @@ -636,15 +719,18 @@ function Capsule:drawByCount(roleId, count)
636 if good and good.amount > 0 then 719 if good and good.amount > 0 then
637 good.amount = good.amount - 1 720 good.amount = good.amount - 1
638 721
  722 + --插入rank
  723 + rankRole = rankRole + 1
  724 +
639 --插入记录 725 --插入记录
640 local tmpNotify = {roleId = roleId, name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = 1, quality = good.quality, create_time= now} 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 table.insert(record, tmpNotify) 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 else 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 end 734 end
649 735
650 --记录角色的抽奖记录 计算激励奖需要用到 736 --记录角色的抽奖记录 计算激励奖需要用到
@@ -659,48 +745,52 @@ function Capsule:drawByCount(roleId, count) @@ -659,48 +745,52 @@ function Capsule:drawByCount(roleId, count)
659 end 745 end
660 746
661 end 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 end 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 end 776 end
691 777
692 function Capsule:drawAll(roleId) 778 function Capsule:drawAll(roleId)
693 local goods = self:getProperty("goods") or {} 779 local goods = self:getProperty("goods") or {}
694 local record = self:getProperty("record") or {} 780 local record = self:getProperty("record") or {}
  781 + local rank = self:getProperty("rank") or {}
  782 + local rankRole = rank[roleId] or 0
695 local recordByRole = self:getProperty("recordByRole") or {} 783 local recordByRole = self:getProperty("recordByRole") or {}
696 local roleRecord = recordByRole[roleId] or {} 784 local roleRecord = recordByRole[roleId] or {}
697 local now = skynet.timex() 785 local now = skynet.timex()
698 786
699 local name = getNameByRoleId(roleId) 787 local name = getNameByRoleId(roleId)
700 - local notify = {}  
701 - notify[roleId] = {} 788 + local goodsByUsual = {}
702 for good_id, good in pairs(goods) do 789 for good_id, good in pairs(goods) do
703 if good.amount > 0 then 790 if good.amount > 0 then
  791 + --插入rank
  792 + rankRole = rankRole + good.amount
  793 +
704 --插入记录 794 --插入记录
705 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} 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 for i = 1, good.amount do 796 for i = 1, good.amount do
@@ -708,10 +798,10 @@ function Capsule:drawAll(roleId) @@ -708,10 +798,10 @@ function Capsule:drawAll(roleId)
708 end 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 else 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 end 805 end
716 806
717 --记录角色的抽奖记录 807 --记录角色的抽奖记录
@@ -725,40 +815,32 @@ function Capsule:drawAll(roleId) @@ -725,40 +815,32 @@ function Capsule:drawAll(roleId)
725 end 815 end
726 816
727 end 817 end
  818 + rank[roleId] = rankRole
728 recordByRole[roleId] = roleRecord 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 if goodsAmount == 0 then 830 if goodsAmount == 0 then
758 self:setProperty("drawEndTime", now) 831 self:setProperty("drawEndTime", now)
759 end 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 end 844 end
763 845
764 --@param 846 --@param
@@ -789,6 +871,77 @@ function Capsule:draw(roleId, full, cares) @@ -789,6 +871,77 @@ function Capsule:draw(roleId, full, cares)
789 end 871 end
790 end 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 function Capsule:data(roleId) 946 function Capsule:data(roleId)
794 return { 947 return {
@@ -799,12 +952,13 @@ function Capsule:data(roleId) @@ -799,12 +952,13 @@ function Capsule:data(roleId)
799 coin = self:getProperty("coin"), 952 coin = self:getProperty("coin"),
800 onlineCount = self:getOnlineCount(), 953 onlineCount = self:getOnlineCount(),
801 playerStatus = self:getRegisterByRoleId(roleId), 954 playerStatus = self:getRegisterByRoleId(roleId),
802 - record = self:getProperty("record"), 955 + record = self:pageRecord() or {},
803 rank = self:getProperty("rank"), 956 rank = self:getProperty("rank"),
804 goods = self:getProperty("goods"), 957 goods = self:getProperty("goods"),
805 specials = self:getProperty("specials"), 958 specials = self:getProperty("specials"),
806 incentive = self:getProperty("incentive"), 959 incentive = self:getProperty("incentive"),
807 specialsRecord= self:getProperty("specialsRecord"), 960 specialsRecord= self:getProperty("specialsRecord"),
  961 + roleProgress = self:getRoleProgress(roleId),
808 } 962 }
809 end 963 end
810 964
src/models/Role.lua
@@ -214,6 +214,9 @@ Role.schema = { @@ -214,6 +214,9 @@ Role.schema = {
214 heroCnt = {"number", 0}, -- 英雄数量 214 heroCnt = {"number", 0}, -- 英雄数量
215 friendTeam = {"table", {}}, -- 好友切磋队伍信息 {bInfo = {}, team = {}, v = 0} 215 friendTeam = {"table", {}}, -- 好友切磋队伍信息 {bInfo = {}, team = {}, v = 0}
216 bgId = {"number", 0}, -- 看板娘id 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,6 +460,8 @@ function Role:data()
457 unlockChap = self:getProperty("unlockChap"), -- 解锁的章节 460 unlockChap = self:getProperty("unlockChap"), -- 解锁的章节
458 friendTeam = self:getProperty("friendTeam"), 461 friendTeam = self:getProperty("friendTeam"),
459 bgId = self:getProperty("bgId"), 462 bgId = self:getProperty("bgId"),
  463 + worldChangePoints = self:getProperty("worldChangePoints"),
  464 + worldLineReward = self:getProperty("worldLineReward"),
460 } 465 }
461 end 466 end
462 467
src/models/RoleCross.lua
@@ -168,6 +168,9 @@ RoleCross.bind = function (Role) @@ -168,6 +168,9 @@ RoleCross.bind = function (Role)
168 self:checkTaskEnter("Wake", {heroType = heroId, wakeL = initData.heros.wakeL}) 168 self:checkTaskEnter("Wake", {heroType = heroId, wakeL = initData.heros.wakeL})
169 self:checkTaskEnter("WakeCG", {heroType = heroId}) 169 self:checkTaskEnter("WakeCG", {heroType = heroId})
170 self:checkTaskEnter("HeroTalent", {heroType = heroId, alv = aheadLevel}) 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 end 175 end
173 end 176 end
@@ -211,7 +214,6 @@ RoleCross.bind = function (Role) @@ -211,7 +214,6 @@ RoleCross.bind = function (Role)
211 end 214 end
212 215
213 function Role:paySpecialReward(roleId, notify) 216 function Role:paySpecialReward(roleId, notify)
214 - dump(notify)  
215 if notify and next(notify) then 217 if notify and next(notify) then
216 local reward = {} 218 local reward = {}
217 for key, val in pairs(notify) do 219 for key, val in pairs(notify) do
@@ -221,6 +223,7 @@ RoleCross.bind = function (Role) @@ -221,6 +223,7 @@ RoleCross.bind = function (Role)
221 223
222 end 224 end
223 self:award(reward, {log = {desc = "CapsuleReward", int1=roleId}}) 225 self:award(reward, {log = {desc = "CapsuleReward", int1=roleId}})
  226 + SendPacket(actionCodes.Capsule_notifyChange, MsgPack.pack({special = notify}))
224 end 227 end
225 end 228 end
226 229
@@ -385,7 +388,6 @@ function CMD.redPTag(roleId, tag, pms) @@ -385,7 +388,6 @@ function CMD.redPTag(roleId, tag, pms)
385 end 388 end
386 389
387 function CMD.paySpecialReward(roleId, notify) 390 function CMD.paySpecialReward(roleId, notify)
388 - dump(notify)  
389 if notify and next(notify) then 391 if notify and next(notify) then
390 local reward = {} 392 local reward = {}
391 for key, val in pairs(notify) do 393 for key, val in pairs(notify) do
src/models/RoleLog.lua
@@ -66,8 +66,10 @@ local ItemReason = { @@ -66,8 +66,10 @@ local ItemReason = {
66 shopBuy = 150, -- 商店购买 66 shopBuy = 150, -- 商店购买
67 monthCardReward = 151, --月卡奖励 67 monthCardReward = 151, --月卡奖励
68 smonthCardReward = 152, --特刊奖励 68 smonthCardReward = 152, --特刊奖励
69 - itemConvertmonthCard = 153, --兑换月卡  
70 - itemConvertsmonthCard = 154, --兑换特刊 69 + itemConvertSpecial = 153, --兑换月卡/战令/探索指令 特殊道具
  70 + buyDiamondCardReward = 154, --购买钻石额外赠送奖励
  71 + firstMonthCardReward = 155, --首次订阅月卡奖励
  72 + firstSMonthCardReward = 156, --首次订阅特刊奖励
71 73
72 advHang = 301, -- 拾荒挂机 74 advHang = 301, -- 拾荒挂机
73 hangBattle = 302, -- 挂机战斗 75 hangBattle = 302, -- 挂机战斗
@@ -163,6 +165,8 @@ local ItemReason = { @@ -163,6 +165,8 @@ local ItemReason = {
163 CapsuleReward = 1411, --扭蛋机奖励 165 CapsuleReward = 1411, --扭蛋机奖励
164 CapsuleConvert = 1412, --扭蛋机 消耗票 兑换 166 CapsuleConvert = 1412, --扭蛋机 消耗票 兑换
165 CapsuleCoinCost = 1413, --抽扭蛋机消耗 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,6 +32,8 @@ function RolePlugin.bind(Role)
32 function Role:onOfflineEvent() 32 function Role:onOfflineEvent()
33 -- 设置最新的登录时间 33 -- 设置最新的登录时间
34 self:setProperty("ltime", skynet.timex()) 34 self:setProperty("ltime", skynet.timex())
  35 +
  36 + self:saveRoleData()
35 end 37 end
36 38
37 local function checkItemCount(self, itemId, count) 39 local function checkItemCount(self, itemId, count)
@@ -212,6 +214,8 @@ function RolePlugin.bind(Role) @@ -212,6 +214,8 @@ function RolePlugin.bind(Role)
212 end 214 end
213 end 215 end
214 if not next(allChange) then allChange = nil end 216 if not next(allChange) then allChange = nil end
  217 + -- 加道具及时刷新数据
  218 + self:update()
215 return reward, allChange --实际获得的奖励 和 最高级奖励转化过程 219 return reward, allChange --实际获得的奖励 和 最高级奖励转化过程
216 end 220 end
217 221
@@ -426,8 +430,15 @@ function RolePlugin.bind(Role) @@ -426,8 +430,15 @@ function RolePlugin.bind(Role)
426 return 430 return
427 end 431 end
428 end 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 for itemId, count in pairs(itemCountT) do 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 pms.itemId = itemId 442 pms.itemId = itemId
432 pms.count = - count 443 pms.count = - count
433 self:addItem(pms) 444 self:addItem(pms)
@@ -563,9 +574,16 @@ function RolePlugin.bind(Role) @@ -563,9 +574,16 @@ function RolePlugin.bind(Role)
563 self:notifyUpdateProperty("diamond", self:getAllDiamond()) 574 self:notifyUpdateProperty("diamond", self:getAllDiamond())
564 575
565 self:checkTaskEnter("CostDiamond", {count = count}) 576 self:checkTaskEnter("CostDiamond", {count = count})
  577 + self:checkWorldChangePoints({[ItemWorldLine.CostDiamond]=count})
566 return true 578 return true
567 end 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 function Role:increBy(field, val) 587 function Role:increBy(field, val)
570 local roleIncre = self:getProperty("roleIncre") 588 local roleIncre = self:getProperty("roleIncre")
571 local curId = roleIncre[field] or 0 589 local curId = roleIncre[field] or 0
@@ -592,6 +610,7 @@ function RolePlugin.bind(Role) @@ -592,6 +610,7 @@ function RolePlugin.bind(Role)
592 } 610 }
593 if heroInfo.wakeL == 3 then 611 if heroInfo.wakeL == 3 then
594 self:checkTaskEnter("WakeCG", {heroType = heroType}) 612 self:checkTaskEnter("WakeCG", {heroType = heroType})
  613 + self:checkTaskEnter("WakeCGSum", {count = 1})
595 end 614 end
596 local newHero = require("models.Hero").new(heroInfo) 615 local newHero = require("models.Hero").new(heroInfo)
597 newHero:create() 616 newHero:create()
@@ -604,6 +623,8 @@ function RolePlugin.bind(Role) @@ -604,6 +623,8 @@ function RolePlugin.bind(Role)
604 end 623 end
605 self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job, ssrCount = ssrCount}, params.notNotify) 624 self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job, ssrCount = ssrCount}, params.notNotify)
606 self:checkTaskEnter("HeroQualityCollect", {}) 625 self:checkTaskEnter("HeroQualityCollect", {})
  626 + self:checkTaskEnter("HeroStartSum", {})
  627 +
607 if not params.notNotify then 628 if not params.notNotify then
608 local heroResponse = {} 629 local heroResponse = {}
609 table.insert(heroResponse, newHero:data()) 630 table.insert(heroResponse, newHero:data())
@@ -2037,10 +2058,10 @@ function RolePlugin.bind(Role) @@ -2037,10 +2058,10 @@ function RolePlugin.bind(Role)
2037 2058
2038 local SAVE_DATA_INTERVAL = 3 2059 local SAVE_DATA_INTERVAL = 3
2039 function Role:saveRoleData(now) 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 return 2062 return
2042 end 2063 end
2043 - self._lastSaveTs = now 2064 + self._lastSaveTs = now or skynet.timex()
2044 self:update() 2065 self:update()
2045 local objs = {self.activity, self.dailyData, self.dinerData, self.storeData, self.roleIncre} 2066 local objs = {self.activity, self.dailyData, self.dinerData, self.storeData, self.roleIncre}
2046 for _, info in ipairs(objs) do 2067 for _, info in ipairs(objs) do
@@ -2090,7 +2111,7 @@ function RolePlugin.bind(Role) @@ -2090,7 +2111,7 @@ function RolePlugin.bind(Role)
2090 local emailSync = math.max(emailSync + 1, globalEmail - EMAIL_LIMIT + 1) 2111 local emailSync = math.max(emailSync + 1, globalEmail - EMAIL_LIMIT + 1)
2091 local redret = redisproxy:pipelining(function (red) 2112 local redret = redisproxy:pipelining(function (red)
2092 for id = emailSync, globalEmail do 2113 for id = emailSync, globalEmail do
2093 - red:hgetall(string.format("globalEmail:%s", id)) 2114 + red:hgetall(string.format("globalEmail:%s", id))
2094 end 2115 end
2095 end) 2116 end)
2096 for _, data in ipairs(redret) do 2117 for _, data in ipairs(redret) do
@@ -2414,7 +2435,7 @@ function RolePlugin.bind(Role) @@ -2414,7 +2435,7 @@ function RolePlugin.bind(Role)
2414 return 1 2435 return 1
2415 end 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 return 2 2439 return 2
2419 end 2440 end
2420 2441
@@ -2429,6 +2450,12 @@ function RolePlugin.bind(Role) @@ -2429,6 +2450,12 @@ function RolePlugin.bind(Role)
2429 self:updateProperty({field = "rechargeF", value = rechargeF}) 2450 self:updateProperty({field = "rechargeF", value = rechargeF})
2430 end 2451 end
2431 self:gainDiamond({count = diamondCount, isRecharge = true, sid = params.sid, log = {desc = "recharge", int1 = id}}) 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 elseif rechargeData.shop == 2 then --通行证商店 2459 elseif rechargeData.shop == 2 then --通行证商店
2433 --签收 + 订阅奖励 2460 --签收 + 订阅奖励
2434 local tmpreward, _ = self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) 2461 local tmpreward, _ = self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id)
@@ -2437,6 +2464,8 @@ function RolePlugin.bind(Role) @@ -2437,6 +2464,8 @@ function RolePlugin.bind(Role)
2437 end 2464 end
2438 elseif rechargeData.shop == 3 then -- 礼包商店 2465 elseif rechargeData.shop == 3 then -- 礼包商店
2439 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) 2466 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
  2467 +
  2468 + self:checkTaskEnter("BuyLimitPack", {id = id})
2440 else 2469 else
2441 skynet.error("[recharge] invalid recharge shop type " .. id) 2470 skynet.error("[recharge] invalid recharge shop type " .. id)
2442 return 3 2471 return 3
@@ -2991,6 +3020,22 @@ function RolePlugin.bind(Role) @@ -2991,6 +3020,22 @@ function RolePlugin.bind(Role)
2991 return levelBnous[SystemBnousType.ChangeBuyCount] or 0 3020 return levelBnous[SystemBnousType.ChangeBuyCount] or 0
2992 end 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 function Role:getLevelBnous() 3039 function Role:getLevelBnous()
2995 local levelBnous = {} 3040 local levelBnous = {}
2996 local curLevel = self:getProperty("level") 3041 local curLevel = self:getProperty("level")
@@ -3019,6 +3064,11 @@ function RolePlugin.bind(Role) @@ -3019,6 +3064,11 @@ function RolePlugin.bind(Role)
3019 levelBnous[pm1] = 0 3064 levelBnous[pm1] = 0
3020 end 3065 end
3021 levelBnous[pm1] = levelBnous[pm1] + pm2 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 else 3072 else
3023 levelBnous[pm1][pm2] = (levelBnous[pm1][pm2] or 0) + pm3 3073 levelBnous[pm1][pm2] = (levelBnous[pm1][pm2] or 0) + pm3
3024 end 3074 end
@@ -3153,10 +3203,10 @@ function RolePlugin.bind(Role) @@ -3153,10 +3203,10 @@ function RolePlugin.bind(Role)
3153 return itemRandomOccupy 3203 return itemRandomOccupy
3154 end 3204 end
3155 3205
3156 - function Role:getCapsuleList(coin) 3206 + function Role:getCapsuleList(id)
3157 local capsules = {} 3207 local capsules = {}
3158 for k, v in pairs(self.capsules) do 3208 for k, v in pairs(self.capsules) do
3159 - if v:getProperty("coin") == coin then 3209 + if v:getProperty("id") == id then
3160 local onlineCount= v:getOnlineCount() 3210 local onlineCount= v:getOnlineCount()
3161 capsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")} 3211 capsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")}
3162 end 3212 end
@@ -3165,17 +3215,20 @@ function RolePlugin.bind(Role) @@ -3165,17 +3215,20 @@ function RolePlugin.bind(Role)
3165 end 3215 end
3166 3216
3167 function Role:drawCapsule(capsuleId, full, cares) 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 end 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 end 3232 end
3180 3233
3181 function Role:checkCapsule(now) 3234 function Role:checkCapsule(now)
@@ -3188,13 +3241,17 @@ function RolePlugin.bind(Role) @@ -3188,13 +3241,17 @@ function RolePlugin.bind(Role)
3188 end 3241 end
3189 3242
3190 function Role:goodStock(capsuleId) 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 return capsule:getGoodsAmount(), capsule:getProperty("token") 3247 return capsule:getGoodsAmount(), capsule:getProperty("token")
3193 end 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 end 3255 end
3199 3256
3200 function Role:resetCapsule() 3257 function Role:resetCapsule()
@@ -3220,6 +3277,38 @@ function RolePlugin.bind(Role) @@ -3220,6 +3277,38 @@ function RolePlugin.bind(Role)
3220 end 3277 end
3221 end 3278 end
3222 end 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 end 3312 end
3224 3313
3225 return RolePlugin 3314 return RolePlugin
3226 \ No newline at end of file 3315 \ No newline at end of file
src/models/RoleTask.lua
@@ -17,6 +17,9 @@ local TaskType = { @@ -17,6 +17,9 @@ local TaskType = {
17 HeroStarCollect = 12, -- 英雄星级收集进度 17 HeroStarCollect = 12, -- 英雄星级收集进度
18 DrawHeroNotFriend = 13, -- 非友情招募 -- count 18 DrawHeroNotFriend = 13, -- 非友情招募 -- count
19 DrawHeroLimitPack = 14, -- 抽卡限时礼貌 -- count 19 DrawHeroLimitPack = 14, -- 抽卡限时礼貌 -- count
  20 + HeroStartSum = 15, -- 英雄星级总数
  21 + WakeCGSum = 16, -- 累计解锁xx张CG
  22 +
20 23
21 --装备相关 24 --装备相关
22 AddEquip = 101, -- 获得装备 - equipId rarity 25 AddEquip = 101, -- 获得装备 - equipId rarity
@@ -112,6 +115,8 @@ local TaskType = { @@ -112,6 +115,8 @@ local TaskType = {
112 ActBattlePass = 911, -- 活动关卡通关 -- chapterId 115 ActBattlePass = 911, -- 活动关卡通关 -- chapterId
113 Appoint = 912, -- 触发限时礼包,指定id 116 Appoint = 912, -- 触发限时礼包,指定id
114 Rename = 913, -- 重命名 117 Rename = 913, -- 重命名
  118 + CostJade = 914, -- 消耗虹光玉
  119 + BuyLimitPack = 915, -- 购买指定id礼包触发
115 120
116 --功能未实现 todo 121 --功能未实现 todo
117 AdvShop = 1002, -- 冒险商城 122 AdvShop = 1002, -- 冒险商城
@@ -271,6 +276,13 @@ local StoreListener = { @@ -271,6 +276,13 @@ local StoreListener = {
271 [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, 276 [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}},
272 [TaskType.DrawHeroLimitPack] = {{TriggerEventType.DrawHeroCnt, f("count")}}, 277 [TaskType.DrawHeroLimitPack] = {{TriggerEventType.DrawHeroCnt, f("count")}},
273 [TaskType.Appoint] = {{TriggerEventType.Appoint, f("id")}}, 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,6 +330,9 @@ local CalendaTaskListener = {
318 [TaskType.AdvKill] = {{39, 1, f("chapterId")}}, 330 [TaskType.AdvKill] = {{39, 1, f("chapterId")}},
319 [TaskType.ActBattlePass] = {{40, 3, f("chapterId")}}, 331 [TaskType.ActBattlePass] = {{40, 3, f("chapterId")}},
320 [TaskType.AdvPass] = {{41, 3, f("id")}}, 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,7 +753,7 @@ function RoleTask.bind(Role)
738 for _,uid in pairs(hero:getRunes()) do 753 for _,uid in pairs(hero:getRunes()) do
739 if uid > 0 then 754 if uid > 0 then
740 local runeData = self.runeBag[uid] 755 local runeData = self.runeBag[uid]
741 - if runeData then 756 + if runeData then
742 local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")] 757 local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")]
743 758
744 if csvData and cfg.condition2 <= csvData.rarity then 759 if csvData and cfg.condition2 <= csvData.rarity then
@@ -758,9 +773,9 @@ function RoleTask.bind(Role) @@ -758,9 +773,9 @@ function RoleTask.bind(Role)
758 end 773 end
759 elseif cfg.type == 15 then -- 通关关卡 774 elseif cfg.type == 15 then -- 通关关卡
760 if (calTask[id] or 0) == 0 then 775 if (calTask[id] or 0) == 0 then
761 - if self:checkHangPass(cfg.condition2) then 776 + if self:checkHangPass(cfg.condition2) then
762 calTask[id] = 1 777 calTask[id] = 1
763 - end 778 + end
764 --local hangPass = self:getProperty("hangPass") 779 --local hangPass = self:getProperty("hangPass")
765 --local diff = math.floor(cfg.condition2 / 10000) 780 --local diff = math.floor(cfg.condition2 / 10000)
766 --if (hangPass[diff] or 0) >= cfg.condition2 then 781 --if (hangPass[diff] or 0) >= cfg.condition2 then
@@ -791,7 +806,7 @@ function RoleTask.bind(Role) @@ -791,7 +806,7 @@ function RoleTask.bind(Role)
791 elseif cfg.type == 37 then -- 拾荒使用道具 806 elseif cfg.type == 37 then -- 拾荒使用道具
792 if cfg.condition2 == param1 then 807 if cfg.condition2 == param1 then
793 calTask[id] = (calTask[id] or 0) + (param2 or 0) 808 calTask[id] = (calTask[id] or 0) + (param2 or 0)
794 - end 809 + end
795 elseif cfg.type == 38 then -- 和指定建筑交互 810 elseif cfg.type == 38 then -- 和指定建筑交互
796 local condArr = cfg.condition3:toArray(true, "=") 811 local condArr = cfg.condition3:toArray(true, "=")
797 for i = 0, #condArr do 812 for i = 0, #condArr do
@@ -820,6 +835,14 @@ function RoleTask.bind(Role) @@ -820,6 +835,14 @@ function RoleTask.bind(Role)
820 if cfg.condition2 <= param1 and param2 == 1 then 835 if cfg.condition2 <= param1 and param2 == 1 then
821 calTask[id] = (calTask[id] or 0) + 1 836 calTask[id] = (calTask[id] or 0) + 1
822 end 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 end 846 end
824 end 847 end
825 end 848 end
src/models/Store.lua
@@ -30,11 +30,12 @@ Store.schema = { @@ -30,11 +30,12 @@ Store.schema = {
30 30
31 monthCardEx = {"number", 0}, -- 期数 31 monthCardEx = {"number", 0}, -- 期数
32 monthCardId = {"number", 0}, -- 月卡id 32 monthCardId = {"number", 0}, -- 月卡id
33 - firstMonthCard = {"number", 1}, -- 首次订阅月卡 33 + firstMonthCard = {"number", 0}, -- 首次订阅月卡
34 monthCardReceive = {"number", 0}, -- 月卡奖励领取记录 当天 0-未领取, 1-已经领取 34 monthCardReceive = {"number", 0}, -- 月卡奖励领取记录 当天 0-未领取, 1-已经领取
35 35
36 smonthCards = {"table", {}}, --特刊信息 {[id]={["buyCount"]=0, ["periods"]=0}} buyCount: 购买次数,periods: 剩余期数, 36 smonthCards = {"table", {}}, --特刊信息 {[id]={["buyCount"]=0, ["periods"]=0}} buyCount: 购买次数,periods: 剩余期数,
37 smonthCardReceive = {"number", 0}, -- 特刊奖励领取记录 当天 0-未领取, 1-已经领取 37 smonthCardReceive = {"number", 0}, -- 特刊奖励领取记录 当天 0-未领取, 1-已经领取
  38 + firstSMonthCard = {"table", {}}, -- 首次订阅当期特刊
38 39
39 battleCard = {"number", 0}, -- 赛季卡 40 battleCard = {"number", 0}, -- 赛季卡
40 battleFR = {"string", ""}, -- 免费赛季卡领取记录 41 battleFR = {"string", ""}, -- 免费赛季卡领取记录
@@ -55,6 +56,7 @@ Store.schema = { @@ -55,6 +56,7 @@ Store.schema = {
55 56
56 dailyShop = {"table", {}}, 57 dailyShop = {"table", {}},
57 weekShop = {"table", {}}, 58 weekShop = {"table", {}},
  59 + dayLimitInfo = {"table", {}}, -- {[id]={count=0, trigger=0}}
58 } 60 }
59 61
60 function Store:updateProperty(params) 62 function Store:updateProperty(params)
@@ -80,6 +82,7 @@ function Store:onCrossDay() @@ -80,6 +82,7 @@ function Store:onCrossDay()
80 --self:sendMonthCardEmail() 82 --self:sendMonthCardEmail()
81 self:deleteExpireLimitGoods() 83 self:deleteExpireLimitGoods()
82 --self:checkPaySignReward() 84 --self:checkPaySignReward()
  85 + self:resetDayLimitPackTriggerCount()
83 86
84 --刷新商店 87 --刷新商店
85 self:flushDailyShop() 88 self:flushDailyShop()
@@ -93,100 +96,15 @@ function Store:refreshWeekData(notify) @@ -93,100 +96,15 @@ function Store:refreshWeekData(notify)
93 self:flushWeekShop() 96 self:flushWeekShop()
94 end 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 local smonthCards = self:getProperty("smonthCards") or {} 101 local smonthCards = self:getProperty("smonthCards") or {}
179 local smonthCard = smonthCards[id] or {} 102 local smonthCard = smonthCards[id] or {}
180 return smonthCard["periods"] or 0 103 return smonthCard["periods"] or 0
181 end 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 if cur_ex == 0 then return nil, nil end 108 if cur_ex == 0 then return nil, nil end
191 cur_ex = cur_ex - 1 109 cur_ex = cur_ex - 1
192 110
@@ -201,7 +119,7 @@ SuperMonthCard[&quot;itemDaily&quot;] = function(self, id) @@ -201,7 +119,7 @@ SuperMonthCard[&quot;itemDaily&quot;] = function(self, id)
201 return reward, change, cur_ex 119 return reward, change, cur_ex
202 end 120 end
203 121
204 -SuperMonthCard["itemFirst"] = function(self, id) 122 +local function getCardItemFirstReward(self, id)
205 local card = csvdb["shop_cardCsv"][id] or {} 123 local card = csvdb["shop_cardCsv"][id] or {}
206 local reward, _ = self.owner:award(card["itemFirst"], {isRecharge = true, log = {desc = "recharge", int1 = id}}) 124 local reward, _ = self.owner:award(card["itemFirst"], {isRecharge = true, log = {desc = "recharge", int1 = id}})
207 return reward 125 return reward
@@ -219,6 +137,15 @@ function Store:deleteExpireLimitGoods() @@ -219,6 +137,15 @@ function Store:deleteExpireLimitGoods()
219 self:updateProperty({field = "limitTPack", value = limitGoodsList, notNotify = true}) 137 self:updateProperty({field = "limitTPack", value = limitGoodsList, notNotify = true})
220 end 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 function Store:sendMonthCardEmail() 150 function Store:sendMonthCardEmail()
224 local timeNow = skynet.timex() 151 local timeNow = skynet.timex()
@@ -373,8 +300,8 @@ end @@ -373,8 +300,8 @@ end
373 function Store:getSMonthCardDailyReward(id) 300 function Store:getSMonthCardDailyReward(id)
374 if not id then return nil end 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 self:updateProperty({field = "smonthCardReceive", value = 1}) 307 self:updateProperty({field = "smonthCardReceive", value = 1})
@@ -391,14 +318,110 @@ function Store:getSMonthCardDailyReward(id) @@ -391,14 +318,110 @@ function Store:getSMonthCardDailyReward(id)
391 end 318 end
392 319
393 function Store:firstBuyMonthCard(id) 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 local card = csvdb["shop_cardCsv"][id] or {} 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 end 336 end
399 return nil 337 return nil
400 end 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 function Store:onBuyCard(type, duration, id, actid) 426 function Store:onBuyCard(type, duration, id, actid)
404 local timeNow = skynet.timex() 427 local timeNow = skynet.timex()
@@ -409,20 +432,23 @@ function Store:onBuyCard(type, duration, id, actid) @@ -409,20 +432,23 @@ function Store:onBuyCard(type, duration, id, actid)
409 self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + 30}) 432 self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + 30})
410 433
411 local reward = {} 434 local reward = {}
412 - --初回特典 仅首次购买月卡时赠送SSR级角色"拉塔托娅"  
413 - local tmpreward, _ = self:firstBuyMonthCard(id) 435 + local tmpreward, _ = self:firstBuyMonthCard(id) --初回特典 仅首次购买月卡
414 if tmpreward then table.rewardMerge(reward, tmpreward) end 436 if tmpreward then table.rewardMerge(reward, tmpreward) end
415 437
416 - --订阅奖励  
417 - tmpreward = SuperMonthCard["itemFirst"](self, id) 438 + tmpreward = getCardItemFirstReward(self, id) --订阅奖励
418 if next(tmpreward) then table.rewardMerge(reward, tmpreward) end 439 if next(tmpreward) then table.rewardMerge(reward, tmpreward) end
419 440
420 return reward 441 return reward
421 elseif type == CardType.SuperMonthCard then 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 end 449 end
  450 +
  451 + skynet.error("特刊购买失败:"..id)
426 return nil 452 return nil
427 elseif type == CardType.NormalMonthCardLevelUp then 453 elseif type == CardType.NormalMonthCardLevelUp then
428 if self:isMonthCardExpire() then 454 if self:isMonthCardExpire() then
@@ -474,7 +500,7 @@ function Store:onBuyCard(type, duration, id, actid) @@ -474,7 +500,7 @@ function Store:onBuyCard(type, duration, id, actid)
474 self:updateProperty({field = "bpInfo", value = bpInfo}) 500 self:updateProperty({field = "bpInfo", value = bpInfo})
475 elseif type == CardType.ActBattleCommandCard then 501 elseif type == CardType.ActBattleCommandCard then
476 if not self.owner.activity:isOpenById(actid, "ActShopGoods") then 502 if not self.owner.activity:isOpenById(actid, "ActShopGoods") then
477 - return 503 + return nil
478 end 504 end
479 local actCfg = csvdb["activity_ctrlCsv"][actid] 505 local actCfg = csvdb["activity_ctrlCsv"][actid]
480 if not actCfg then return end 506 if not actCfg then return end
@@ -486,6 +512,10 @@ function Store:onBuyCard(type, duration, id, actid) @@ -486,6 +512,10 @@ function Store:onBuyCard(type, duration, id, actid)
486 end 512 end
487 self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0}) 513 self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0})
488 self.owner.activity:updateActData("BattleCommand", actData) 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 end 519 end
490 return nil, nil 520 return nil, nil
491 end 521 end
@@ -587,58 +617,64 @@ function Store:OnTriggerLimitTimePack(eventType, param) @@ -587,58 +617,64 @@ function Store:OnTriggerLimitTimePack(eventType, param)
587 local limitPack = self:getProperty("limitTPack") 617 local limitPack = self:getProperty("limitTPack")
588 --local payRecord = self:getProperty("payR") 618 --local payRecord = self:getProperty("payR")
589 local timeNow = skynet.timex() 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 local config = nil 621 local config = nil
619 for id, cfg in pairs(csvdb["shop_packCsv"]) do 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 config = cfg 624 config = cfg
  625 + break
622 end 626 end
623 end 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 end 667 end
640 - self:updateProperty({field = "limitTPack", value = limitPack})  
641 end 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 end 678 end
643 --if next(result) then 679 --if next(result) then
644 -- self:updateProperty({field = "packTrigger", value = triggerRecord}) 680 -- self:updateProperty({field = "packTrigger", value = triggerRecord})
@@ -831,6 +867,7 @@ function Store:data() @@ -831,6 +867,7 @@ function Store:data()
831 totalRR = self:getProperty("totalRR"), 867 totalRR = self:getProperty("totalRR"),
832 monthCardId = self:getProperty("monthCardId"), 868 monthCardId = self:getProperty("monthCardId"),
833 firstMonthCard = self:getProperty("firstMonthCard"), 869 firstMonthCard = self:getProperty("firstMonthCard"),
  870 + firstsMonthCard = self:getProperty("firstsMonthCard"),
834 monthCardReceive = self:getProperty("monthCardReceive"), 871 monthCardReceive = self:getProperty("monthCardReceive"),
835 smonthCards = self:getProperty("smonthCards"), 872 smonthCards = self:getProperty("smonthCards"),
836 smonthCardReceive = self:getProperty("smonthCardReceive"), 873 smonthCardReceive = self:getProperty("smonthCardReceive"),
src/services/agent_ctrl.lua
@@ -141,10 +141,11 @@ function _M:check_agent_status() @@ -141,10 +141,11 @@ function _M:check_agent_status()
141 end 141 end
142 end 142 end
143 143
  144 + local count = table_nums(self.u2f)
  145 + datacenter.set("onlineCount", count)
144 if now >= next_log_time and now % 60 == 0 then 146 if now >= next_log_time and now % 60 == 0 then
145 next_log_time = now + 60 147 next_log_time = now + 60
146 - local count = table_nums(self.u2f)  
147 - datacenter.set("onlineCount", count) 148 + --datacenter.set("onlineCount", count)
148 logproxy:log({["@type"] = "online", count = count}, "log") 149 logproxy:log({["@type"] = "online", count = count}, "log")
149 end 150 end
150 end 151 end
src/services/capsuled.lua
@@ -51,7 +51,9 @@ function getNameByRoleId(roleId) @@ -51,7 +51,9 @@ function getNameByRoleId(roleId)
51 end 51 end
52 52
53 function broadCastCapsule(roleId, capsuleId, broadInfo) 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 local register = capsule:getProperty("register") or {} 57 local register = capsule:getProperty("register") or {}
56 if next(capsule) then 58 if next(capsule) then
57 for id, _ in pairs(register) do 59 for id, _ in pairs(register) do
@@ -63,21 +65,23 @@ function broadCastCapsule(roleId, capsuleId, broadInfo) @@ -63,21 +65,23 @@ function broadCastCapsule(roleId, capsuleId, broadInfo)
63 end 65 end
64 66
65 function broadCastSpecial(roleId, capsuleId, broadInfo) 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 local register = capsule:getProperty("register") or {} 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 end 77 end
75 end 78 end
76 end 79 end
77 end 80 end
78 81
79 local function add(roleId, capsuleId) 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 if next(capsule) then 85 if next(capsule) then
82 capsule:join(roleId) 86 capsule:join(roleId)
83 broadCastCapsule(roleId, capsuleId, {notifyType= NotifyChangeType.JOIN, roleId = roleId}) 87 broadCastCapsule(roleId, capsuleId, {notifyType= NotifyChangeType.JOIN, roleId = roleId})
@@ -87,9 +91,12 @@ local function add(roleId, capsuleId) @@ -87,9 +91,12 @@ local function add(roleId, capsuleId)
87 return nil 91 return nil
88 end 92 end
89 93
90 -local function capsuleRefreshing() 94 +local function capsuleRefreshing(now)
91 for _, v in pairs(capsules) do 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 v:init() 100 v:init()
94 v:create() 101 v:create()
95 end 102 end
@@ -98,8 +105,9 @@ end @@ -98,8 +105,9 @@ end
98 105
99 --扭蛋机刷新 106 --扭蛋机刷新
100 local function check_capsules() 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 end 111 end
104 112
105 function CMD.reset() 113 function CMD.reset()
@@ -114,13 +122,11 @@ function CMD.reset() @@ -114,13 +122,11 @@ function CMD.reset()
114 for _, val in ipairs(data) do 122 for _, val in ipairs(data) do
115 if val.type == 1 then 123 if val.type == 1 then
116 local key = val.id..val.room 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 end 130 end
125 end 131 end
126 end 132 end
@@ -149,11 +155,14 @@ function CMD.start() @@ -149,11 +155,14 @@ function CMD.start()
149 if val.type == 1 then 155 if val.type == 1 then
150 local key = val.id..val.room 156 local key = val.id..val.room
151 if not capsules[key] then 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 end 166 end
158 end 167 end
159 end 168 end
@@ -162,10 +171,10 @@ function CMD.start() @@ -162,10 +171,10 @@ function CMD.start()
162 check_capsules() 171 check_capsules()
163 end 172 end
164 173
165 -function CMD.list(coin) 174 +function CMD.list(id)
166 local tmpCapsules = {} 175 local tmpCapsules = {}
167 for k, v in pairs(capsules) do 176 for k, v in pairs(capsules) do
168 - if v:getProperty("coin") == coin then 177 + if v:getProperty("id") == id then
169 local onlineCount= v:getOnlineCount() 178 local onlineCount= v:getOnlineCount()
170 tmpCapsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")} 179 tmpCapsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")}
171 end 180 end
@@ -183,49 +192,76 @@ end @@ -183,49 +192,76 @@ end
183 192
184 function CMD.exit(roleId, capsuleId) 193 function CMD.exit(roleId, capsuleId)
185 if capsuleId then 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 else 200 else
192 - for _, capsule in pairs(capsules) do 201 + for id, capsule in pairs(capsules) do
193 if next(capsule) then 202 if next(capsule) then
194 capsule:exit(roleId) 203 capsule:exit(roleId)
195 - broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.EXIT, roleId = roleId}) 204 + broadCastCapsule(roleId, id, {notifyType = NotifyChangeType.EXIT, roleId = roleId})
196 end 205 end
197 end 206 end
198 end 207 end
199 end 208 end
200 209
201 function CMD.draw_capsule(roleId, capsuleId, full, drawsNum, cares) 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 end 218 end
211 - return 2 219 + drawReward["specials"] = nil
  220 + return ret, drawReward, capsule:data(roleId)
212 end 221 end
213 222
214 function CMD.register(roleId, capsuleId) 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 return capsule:register(roleId) 227 return capsule:register(roleId)
217 end 228 end
218 229
219 function CMD.goods_stock(capsuleId) 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 return capsule:getGoodsAmount(), capsule:getProperty("token") 234 return capsule:getGoodsAmount(), capsule:getProperty("token")
222 end 235 end
223 236
224 function CMD.capsule_data(roleId, capsuleId) 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 return capsule:data(roleId) 241 return capsule:data(roleId)
227 end 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 skynet.start(function() 265 skynet.start(function()
230 skynet.dispatch("lua", function(session, address, cmd, ...) 266 skynet.dispatch("lua", function(session, address, cmd, ...)
231 local f = CMD[string.lower(cmd)] 267 local f = CMD[string.lower(cmd)]
src/services/watchdog.lua
@@ -56,7 +56,7 @@ end @@ -56,7 +56,7 @@ end
56 56
57 -- 创建world以及union channel 用于广播 57 -- 创建world以及union channel 用于广播
58 function create_mutilcast() 58 function create_mutilcast()
59 - for i = 1, 10 do 59 + for i = 1, 50 do
60 local chan_w = mc:new() 60 local chan_w = mc:new()
61 datacenter.set("MC_W_CHANNEL" .. i, chan_w.channel) 61 datacenter.set("MC_W_CHANNEL" .. i, chan_w.channel)
62 end 62 end
src/shared/ModelBaseMysql.lua
@@ -510,6 +510,11 @@ function ModelBaseMysql:updateFields(fields) @@ -510,6 +510,11 @@ function ModelBaseMysql:updateFields(fields)
510 skynet.error("error sql:"..sql) 510 skynet.error("error sql:"..sql)
511 skynet.error("error str:"..res["err"]) 511 skynet.error("error str:"..res["err"])
512 return false 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 end 518 end
514 end 519 end
515 return true 520 return true