Commit 64aca5be2fc4badd5538d04589743f1a276a6ca5
Merge branch 'cn/develop' into cn/publish/ts
Showing
23 changed files
with
945 additions
and
367 deletions
Show diff stats
src/GlobalVar.lua
| @@ -383,6 +383,11 @@ TriggerEventType = { | @@ -383,6 +383,11 @@ TriggerEventType = { | ||
| 383 | AfterTs = 7, -- 某时间以后 | 383 | AfterTs = 7, -- 某时间以后 |
| 384 | DrawHeroCnt = 8, -- 每日抽卡次数 | 384 | DrawHeroCnt = 8, -- 每日抽卡次数 |
| 385 | Appoint = 0, -- 触发指定id礼包 | 385 | Appoint = 0, -- 触发指定id礼包 |
| 386 | + SignIn = 9, -- 签到 | ||
| 387 | + DrawHero = 10, -- 循环抽卡 | ||
| 388 | + FoodSell = 11, -- 循环卖菜 | ||
| 389 | + RuneUp = 12, -- 循环强化符文 | ||
| 390 | + CostDiamond = 13, -- 循环消耗钻石 | ||
| 386 | } | 391 | } |
| 387 | 392 | ||
| 388 | DrawCardType = { | 393 | DrawCardType = { |
src/ProtocolCode.lua
| @@ -59,7 +59,7 @@ actionCodes = { | @@ -59,7 +59,7 @@ actionCodes = { | ||
| 59 | Role_runeBuyRpc = 142, -- 铭文购买 | 59 | Role_runeBuyRpc = 142, -- 铭文购买 |
| 60 | Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍 | 60 | Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍 |
| 61 | Role_setBgRpc = 144, -- 设置看板娘 | 61 | Role_setBgRpc = 144, -- 设置看板娘 |
| 62 | - Role_itemExchangeRpc = 145, -- 道具兑换 | 62 | + Role_itemConvertMonthCardRpc = 145, -- 兑换月卡道具 |
| 63 | 63 | ||
| 64 | Adv_startAdvRpc = 151, | 64 | Adv_startAdvRpc = 151, |
| 65 | Adv_startHangRpc = 152, | 65 | Adv_startHangRpc = 152, |
| @@ -279,10 +279,14 @@ actionCodes = { | @@ -279,10 +279,14 @@ actionCodes = { | ||
| 279 | Capsule_joinRpc = 851, --扭蛋机详情 | 279 | Capsule_joinRpc = 851, --扭蛋机详情 |
| 280 | Capsule_registerRpc = 853, --报名扭蛋机 "报名"后,抽取按钮才会开放,未报名的玩家分在围观玩家中 | 280 | Capsule_registerRpc = 853, --报名扭蛋机 "报名"后,抽取按钮才会开放,未报名的玩家分在围观玩家中 |
| 281 | Capsule_drawRpc = 854, --抽扭蛋机 | 281 | Capsule_drawRpc = 854, --抽扭蛋机 |
| 282 | - Capsule_switchRoomRpc = 855, --切换扭蛋机房间 | 282 | + --Capsule_switchRoomRpc = 855, --切换扭蛋机房间 |
| 283 | Capsule_notifyChange = 856, -- 通知信息变动 | 283 | Capsule_notifyChange = 856, -- 通知信息变动 |
| 284 | - Capsule_payReward = 857, -- 特殊赏 奖励通知 | 284 | + Capsule_specialRewardRpc = 857, -- 获取 未领取特殊赏通知 主动 |
| 285 | Capsule_exitRpc = 858, -- 退出 | 285 | Capsule_exitRpc = 858, -- 退出 |
| 286 | + Capsule_getDataRpc = 859, --获取扭蛋机信息 | ||
| 287 | + Capsule_convertCapsuleRpc = 860, --兑换消耗票 | ||
| 288 | + Capsule_pageRecordRpc = 861, --抽奖记录分页查询 | ||
| 289 | + Capsule_clearSpecialNtyRpc = 862, --消除特殊赏通知 | ||
| 286 | } | 290 | } |
| 287 | 291 | ||
| 288 | rpcResponseBegin = 10000 | 292 | rpcResponseBegin = 10000 |
src/actions/ActivityAction.lua
| @@ -605,6 +605,8 @@ function _M.startBattleRpc(agent, data) | @@ -605,6 +605,8 @@ function _M.startBattleRpc(agent, data) | ||
| 605 | end | 605 | end |
| 606 | end | 606 | end |
| 607 | num = num * count | 607 | num = num * count |
| 608 | + else | ||
| 609 | + num = 0 | ||
| 608 | end | 610 | end |
| 609 | if ticket < num then | 611 | if ticket < num then |
| 610 | return 6 | 612 | return 6 |
| @@ -643,7 +645,7 @@ function _M.startBattleRpc(agent, data) | @@ -643,7 +645,7 @@ function _M.startBattleRpc(agent, data) | ||
| 643 | award[k] = v * count | 645 | award[k] = v * count |
| 644 | end | 646 | end |
| 645 | local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) | 647 | 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))) | 648 | + |
| 647 | changeFlag = true | 649 | changeFlag = true |
| 648 | actData["ticket"] = ticket - num | 650 | actData["ticket"] = ticket - num |
| 649 | 651 | ||
| @@ -663,11 +665,15 @@ function _M.startBattleRpc(agent, data) | @@ -663,11 +665,15 @@ function _M.startBattleRpc(agent, data) | ||
| 663 | end | 665 | end |
| 664 | role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | 666 | role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) |
| 665 | end | 667 | end |
| 668 | + role.activity:updateActData("ChallengeLevel", actData) | ||
| 666 | 669 | ||
| 670 | + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 671 | + | ||
| 672 | + return true | ||
| 667 | end | 673 | end |
| 668 | - if changeFlag then | ||
| 669 | - role.activity:updateActData("ChallengeLevel", actData) | ||
| 670 | - end | 674 | + --if changeFlag then |
| 675 | + -- role.activity:updateActData("ChallengeLevel", actData) | ||
| 676 | + --end | ||
| 671 | 677 | ||
| 672 | return true | 678 | return true |
| 673 | end | 679 | end |
| @@ -801,10 +807,12 @@ function _M.endBattleRpc(agent, data) | @@ -801,10 +807,12 @@ function _M.endBattleRpc(agent, data) | ||
| 801 | end | 807 | end |
| 802 | 808 | ||
| 803 | if battleCfg.rank ~= 0 and isWin then | 809 | 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) | 810 | + if battleCfg.type ~= "" then |
| 811 | + -- 消耗门票 | ||
| 812 | + role.activity:getBattleTicket(actid) | ||
| 813 | + local num = battleCfg.type:toArray(true, "=")[3] | ||
| 814 | + actData["ticket"] = math.max(actData["ticket"] - num, 0) | ||
| 815 | + end | ||
| 808 | 816 | ||
| 809 | -- 更新排行榜 最高伤害 | 817 | -- 更新排行榜 最高伤害 |
| 810 | battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg) | 818 | battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg) |
| @@ -1337,8 +1345,8 @@ function _M.buyBattleCommandLvlRpc(agent, data) | @@ -1337,8 +1345,8 @@ function _M.buyBattleCommandLvlRpc(agent, data) | ||
| 1337 | end | 1345 | end |
| 1338 | if cost == 0 then return 5 end | 1346 | if cost == 0 then return 5 end |
| 1339 | 1347 | ||
| 1340 | - if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 6 end | ||
| 1341 | - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}}) | 1348 | + if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 6 end |
| 1349 | + role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}}) | ||
| 1342 | actData["lvl"] = nextLvl | 1350 | actData["lvl"] = nextLvl |
| 1343 | role.activity:updateActData("BattleCommand", actData) | 1351 | role.activity:updateActData("BattleCommand", actData) |
| 1344 | role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl}) | 1352 | role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl}) |
| @@ -1486,7 +1494,7 @@ function _M.buyBattleTicketRpc(agent, data) | @@ -1486,7 +1494,7 @@ function _M.buyBattleTicketRpc(agent, data) | ||
| 1486 | end | 1494 | end |
| 1487 | local cost = globalCsv.activity_scrofa_tickets[curCount + 1] | 1495 | local cost = globalCsv.activity_scrofa_tickets[curCount + 1] |
| 1488 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end | 1496 | 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}}) | 1497 | + role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyActivityBattleTicket", int1 = actid, int2 = count, long1 = curCount}}) |
| 1490 | actData["ticket"] = (actData["ticket"] or 0) + 1 | 1498 | actData["ticket"] = (actData["ticket"] or 0) + 1 |
| 1491 | actData["buyC"] = curCount + count | 1499 | actData["buyC"] = curCount + count |
| 1492 | 1500 |
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 |
| @@ -93,39 +93,160 @@ function _M.drawRpc(agent, data) | @@ -93,39 +93,160 @@ function _M.drawRpc(agent, data) | ||
| 93 | local roleId = role:getProperty("id") | 93 | local roleId = role:getProperty("id") |
| 94 | local capsuleId = msg.capsule_id | 94 | local capsuleId = msg.capsule_id |
| 95 | local typ = msg.typ --0=独享,1= 公开 | 95 | local typ = msg.typ --0=独享,1= 公开 |
| 96 | - local full = msg.full -- 0=单次,1=十连抽 2=全收 | 96 | + local full = msg.full or 0-- 0=单次,1=十连抽 2=全收 |
| 97 | local cares = msg.cares | 97 | local cares = msg.cares |
| 98 | 98 | ||
| 99 | - local ret, reward, change, rewardByGoods, capsule | 99 | + local ret, token, change, drawReward, capsule |
| 100 | + | ||
| 101 | + --检查库存 | ||
| 102 | + if typ == 1 then | ||
| 103 | + ret, token = skynet.call(agent.capsule_serv, "lua", "goods_stock", capsuleId) | ||
| 104 | + else | ||
| 105 | + ret, token = role:goodStock(capsuleId) | ||
| 106 | + end | ||
| 107 | + if ret == 0 then skynet.error("零库存 " .. capsuleId) return 0 end | ||
| 108 | + | ||
| 109 | + --检查余额 | ||
| 110 | + if not next(token) then skynet.error("代币未配置 " .. capsuleId) return 1 end | ||
| 111 | + local cost, drawsNum = {}, 0 | ||
| 112 | + if full == 0 then | ||
| 113 | + drawsNum = 1 | ||
| 114 | + elseif full == 1 then | ||
| 115 | + if ret < 10 then | ||
| 116 | + drawsNum = ret | ||
| 117 | + else | ||
| 118 | + drawsNum = 10 | ||
| 119 | + end | ||
| 120 | + elseif full == 2 then | ||
| 121 | + drawsNum = ret | ||
| 122 | + end | ||
| 123 | + cost[token[1]] = drawsNum * token[2] | ||
| 124 | + | ||
| 125 | + if not role:checkItemEnough(cost) then return 2 end | ||
| 126 | + role:costItems(cost, {log = {desc = "CapsuleCoinCost", int1 = token[1], int2 = cost[token[1]]}}) | ||
| 127 | + | ||
| 128 | + --开始抽奖 | ||
| 100 | if typ == 1 then | 129 | if typ == 1 then |
| 101 | - ret, reward, rewardByGoods, capsule = skynet.call(agent.capsule_serv, "lua", "draw_capsule", roleId, capsuleId, full, cares) | 130 | + ret, drawReward, capsule = skynet.call(agent.capsule_serv, "lua", "draw_capsule", roleId, capsuleId, full, cares) |
| 102 | else | 131 | else |
| 103 | - ret, reward, rewardByGoods, capsule= role:drawCapsule(capsuleId, full, cares) | 132 | + ret, drawReward, capsule = role:drawCapsule(capsuleId, full, cares) |
| 133 | + end | ||
| 134 | + if ret < 5 then | ||
| 135 | + return ret | ||
| 136 | + end | ||
| 137 | + | ||
| 138 | + if ret == 5 then | ||
| 139 | + SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({change = drawReward, capsule = capsule})) | ||
| 140 | + return true | ||
| 104 | end | 141 | end |
| 105 | - if ret < 4 then | 142 | + |
| 143 | + if drawReward["reward"] and next(drawReward["reward"]) then | ||
| 144 | + _, change = role:award(drawReward["reward"], {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}}) | ||
| 145 | + drawReward["capsule"] = capsule | ||
| 146 | + SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack(drawReward)) | ||
| 147 | + else | ||
| 106 | return ret | 148 | return ret |
| 107 | end | 149 | end |
| 150 | + return true | ||
| 151 | +end | ||
| 152 | + | ||
| 153 | +function _M.getDataRpc(agent, data) | ||
| 154 | + local role = agent.role | ||
| 155 | + local msg = MsgPack.unpack(data) | ||
| 156 | + local capsuleId = msg.capsule_id | ||
| 157 | + local typ = msg.typ --0=独享,1= 公开 | ||
| 158 | + local roleId = role:getProperty("id") | ||
| 159 | + | ||
| 160 | + local capsule | ||
| 161 | + if typ == 1 then | ||
| 162 | + capsule = skynet.call(agent.capsule_serv, "lua", "capsule_data", roleId, capsuleId) | ||
| 163 | + else | ||
| 164 | + capsule = role:getCapsuleData(roleId, capsuleId) | ||
| 165 | + end | ||
| 166 | + if not capsule then return 1 end | ||
| 167 | + | ||
| 168 | + SendPacket(actionCodes.Capsule_getDataRpc, MsgPack.pack({capsule = capsule})) | ||
| 169 | + return true | ||
| 170 | + | ||
| 171 | +end | ||
| 172 | + | ||
| 173 | +function _M.convertCapsuleRpc(agent, data) | ||
| 174 | + local role = agent.role | ||
| 175 | + local msg = MsgPack.unpack(data) | ||
| 176 | + local coin = msg.coin | ||
| 177 | + local count = msg.count or 1 | ||
| 178 | + | ||
| 179 | + local cost, convert = {} | ||
| 180 | + for k, v in pairs(globalCsv.ichibankuji_buy_cost)do | ||
| 181 | + if k == coin then | ||
| 182 | + convert = v:toArray(true, "=") | ||
| 183 | + break | ||
| 184 | + end | ||
| 185 | + end | ||
| 186 | + cost[convert[1]] = convert[2] * count | ||
| 187 | + if not role:checkItemEnough(cost) then return 1 end | ||
| 188 | + role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}}) | ||
| 189 | + | ||
| 190 | + | ||
| 191 | + local reward, change = role:award({[coin]= count}, {log = {desc = "CapsuleConvert"}}) | ||
| 192 | + SendPacket(actionCodes.Capsule_convertCapsuleRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 193 | + return true | ||
| 194 | +end | ||
| 195 | + | ||
| 196 | +function _M.pageRecordRpc(agent, data) | ||
| 197 | + local role = agent.role | ||
| 198 | + local msg = MsgPack.unpack(data) | ||
| 199 | + local idx = msg.idx | ||
| 200 | + local up = msg.up or 0 | ||
| 201 | + local capsuleId = msg.capsule_id | ||
| 202 | + local typ = msg.typ --0=独享,1= 公开 | ||
| 108 | 203 | ||
| 109 | - if ret == 4 then | ||
| 110 | - SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack(reward)) | 204 | + local record |
| 205 | + if typ == 1 then | ||
| 206 | + record = skynet.call(agent.capsule_serv, "lua", "page_record", capsuleId, up, idx) | ||
| 207 | + else | ||
| 208 | + record = role:pageRecord(capsuleId, up, idx) | ||
| 111 | end | 209 | end |
| 210 | + if not record then return 1 end | ||
| 211 | + | ||
| 212 | + SendPacket(actionCodes.Capsule_pageRecordRpc, MsgPack.pack({record = record})) | ||
| 213 | + return true | ||
| 214 | +end | ||
| 215 | + | ||
| 216 | +function _M.specialRewardRpc(agent, data) | ||
| 217 | + local role = agent.role | ||
| 218 | + local msg = MsgPack.unpack(data) | ||
| 219 | + local capsuleId = msg.capsule_id | ||
| 220 | + local typ = msg.typ or 1 --0=独享,1= 公开 | ||
| 221 | + local roleId = role:getProperty("id") | ||
| 112 | 222 | ||
| 113 | - if rewardByGoods and next(rewardByGoods) then | ||
| 114 | - reward, change = role:award(reward, {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}}) | ||
| 115 | - SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({reward = rewardByGoods, capsule = capsule})) | 223 | + local ret |
| 224 | + if typ == 1 then | ||
| 225 | + ret = skynet.call(agent.capsule_serv, "lua", "get_special_nty", roleId, capsuleId) | ||
| 116 | else | 226 | else |
| 117 | - return 5 | 227 | + ret = role:getSpecialNotify(roleId, capsuleId) |
| 118 | end | 228 | end |
| 229 | + if not ret or not next(ret) then return 1 end | ||
| 230 | + | ||
| 231 | + SendPacket(actionCodes.Capsule_specialRewardRpc, MsgPack.pack({special= ret})) | ||
| 119 | return true | 232 | return true |
| 120 | end | 233 | end |
| 121 | 234 | ||
| 122 | -function _M.switchRoomRpc(agent, data) | 235 | +function _M.clearSpecialNtyRpc(agent, data) |
| 123 | local role = agent.role | 236 | local role = agent.role |
| 124 | local msg = MsgPack.unpack(data) | 237 | local msg = MsgPack.unpack(data) |
| 238 | + local capsuleId = msg.capsule_id | ||
| 239 | + local typ = msg.typ --0=独享,1= 公开 | ||
| 240 | + local good_ids = msg.good_ids | ||
| 125 | local roleId = role:getProperty("id") | 241 | local roleId = role:getProperty("id") |
| 126 | 242 | ||
| 127 | - local ret = skynet.call(agent.capsule_serv, "lua", "switch_room", roleId) | ||
| 128 | - SendPacket(actionCodes.Capsule_switchRoomRpc, MsgPack.pack(ret)) | 243 | + local ret |
| 244 | + if typ == 1 then | ||
| 245 | + ret = skynet.call(agent.capsule_serv, "lua", "clear_special_nty", roleId, capsuleId, good_ids) | ||
| 246 | + end | ||
| 247 | + if not ret or not next(ret) then return 1 end | ||
| 248 | + | ||
| 249 | + SendPacket(actionCodes.Capsule_clearSpecialNtyRpc, MsgPack.pack({})) | ||
| 129 | return true | 250 | return true |
| 130 | end | 251 | end |
| 131 | 252 |
src/actions/GmAction.lua
| @@ -9,7 +9,7 @@ function _M.clientRequest(agent, data) | @@ -9,7 +9,7 @@ function _M.clientRequest(agent, data) | ||
| 9 | SendPacket(actionCodes.Gm_receiveResponse, bin) | 9 | SendPacket(actionCodes.Gm_receiveResponse, bin) |
| 10 | return true | 10 | return true |
| 11 | end | 11 | end |
| 12 | - local ret = action(role, msg) | 12 | + local ret = action(role, msg, agent.capsule_serv) |
| 13 | bin = MsgPack.pack({ cmd = ret }) | 13 | bin = MsgPack.pack({ cmd = ret }) |
| 14 | SendPacket(actionCodes.Gm_receiveResponse, bin) | 14 | SendPacket(actionCodes.Gm_receiveResponse, bin) |
| 15 | return true | 15 | return true |
| @@ -1075,4 +1075,15 @@ function _M.clear_sea(role, pms) | @@ -1075,4 +1075,15 @@ function _M.clear_sea(role, pms) | ||
| 1075 | return "成功" | 1075 | return "成功" |
| 1076 | end | 1076 | end |
| 1077 | 1077 | ||
| 1078 | +table.insert(helpDes, {"重置扭蛋机", "reset_capsule", "typ"}) | ||
| 1079 | +function _M.reset_capsule(role, pms, capsule_serv) | ||
| 1080 | + local typ = tonumber(pms.pm1) | ||
| 1081 | + if typ == 1 then | ||
| 1082 | + skynet.call(capsule_serv, "lua", "reset") | ||
| 1083 | + else | ||
| 1084 | + role:resetCapsule() | ||
| 1085 | + end | ||
| 1086 | + return "成功" | ||
| 1087 | +end | ||
| 1088 | + | ||
| 1078 | return _M | 1089 | return _M |
| 1079 | \ No newline at end of file | 1090 | \ No newline at end of file |
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,7 +1712,7 @@ function _M.setBgRpc(agent, data) | @@ -1710,7 +1712,7 @@ function _M.setBgRpc(agent, data) | ||
| 1710 | return true | 1712 | return true |
| 1711 | end | 1713 | end |
| 1712 | 1714 | ||
| 1713 | -function _M.itemExchangeRpc(agent, data) | 1715 | +function _M.itemConvertMonthCardRpc(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 |
| @@ -1738,7 +1740,7 @@ function _M.itemExchangeRpc(agent, data) | @@ -1738,7 +1740,7 @@ function _M.itemExchangeRpc(agent, data) | ||
| 1738 | end | 1740 | end |
| 1739 | end | 1741 | end |
| 1740 | 1742 | ||
| 1741 | - SendPacket(actionCodes.Role_itemExchangeRpc, MsgPack.pack(role:packReward(reward))) | 1743 | + SendPacket(actionCodes.Role_itemConvertMonthCardRpc, MsgPack.pack(role:packReward(reward))) |
| 1742 | return status | 1744 | return status |
| 1743 | end | 1745 | end |
| 1744 | 1746 |
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
| @@ -53,6 +53,19 @@ local function signPms(params, secret_key) | @@ -53,6 +53,19 @@ local function signPms(params, secret_key) | ||
| 53 | return md5.sumhexa(urlCode .. secret_key):lower() | 53 | return md5.sumhexa(urlCode .. secret_key):lower() |
| 54 | end | 54 | end |
| 55 | 55 | ||
| 56 | +local function signDyhPms(params, secret_key) | ||
| 57 | + local keys = table_keys(params) | ||
| 58 | + table.sort(keys) | ||
| 59 | + local str2Sign = "" | ||
| 60 | + for index, key in ipairs(keys) do | ||
| 61 | + if str2Sign ~= "" then | ||
| 62 | + str2Sign = str2Sign .. '&' | ||
| 63 | + end | ||
| 64 | + str2Sign = str2Sign .. string.format("%s=%s", key, params[key]) | ||
| 65 | + end | ||
| 66 | + return md5.sumhexa(str2Sign .. secret_key):lower() | ||
| 67 | +end | ||
| 68 | + | ||
| 56 | -- bili android 充值 入口 | 69 | -- bili android 充值 入口 |
| 57 | function _M.biliAndroidRechargeRpc(agent, data) | 70 | function _M.biliAndroidRechargeRpc(agent, data) |
| 58 | local role = agent.role | 71 | local role = agent.role |
| @@ -227,7 +240,7 @@ function _M.iosRechargeRpc(agent, data) | @@ -227,7 +240,7 @@ function _M.iosRechargeRpc(agent, data) | ||
| 227 | --创建订单号 | 240 | --创建订单号 |
| 228 | local partnerOrderId = role:getPurchaseOrder(id,nil,choose) | 241 | local partnerOrderId = role:getPurchaseOrder(id,nil,choose) |
| 229 | -- 签名 | 242 | -- 签名 |
| 230 | - local secret_key = "1916d62251dd4a8aa5e452121eefc9a1" | 243 | + local secret_key = "2b2036e1f44640a59168c92462714870" |
| 231 | local need = { | 244 | local need = { |
| 232 | out_trade_no = partnerOrderId, | 245 | out_trade_no = partnerOrderId, |
| 233 | money = dataSet.rmb * 100, | 246 | money = dataSet.rmb * 100, |
| @@ -235,7 +248,7 @@ function _M.iosRechargeRpc(agent, data) | @@ -235,7 +248,7 @@ function _M.iosRechargeRpc(agent, data) | ||
| 235 | product_id = dataSet.iap_product_id, | 248 | product_id = dataSet.iap_product_id, |
| 236 | notify_url = msg.notifyUrl | 249 | notify_url = msg.notifyUrl |
| 237 | } | 250 | } |
| 238 | - local sign = signPms(need, secret_key) | 251 | + local sign = signDyhPms(need, secret_key) |
| 239 | 252 | ||
| 240 | SendPacket(actionCodes.Store_iosRechargeRpc, MsgPack.pack({ order = partnerOrderId, sign = sign})) | 253 | SendPacket(actionCodes.Store_iosRechargeRpc, MsgPack.pack({ order = partnerOrderId, sign = sign})) |
| 241 | return true | 254 | return true |
| @@ -316,7 +329,7 @@ function _M.shopBuyRpc(agent , data) | @@ -316,7 +329,7 @@ function _M.shopBuyRpc(agent , data) | ||
| 316 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) | 329 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) |
| 317 | limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) | 330 | limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) |
| 318 | end | 331 | end |
| 319 | - role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, cint1= dataSet.shop}}) | 332 | + role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}}) |
| 320 | 333 | ||
| 321 | local gift = {} | 334 | local gift = {} |
| 322 | for _id, _count in pairs(dataSet.gift:toNumMap()) do | 335 | for _id, _count in pairs(dataSet.gift:toNumMap()) do |
src/agent.lua
| @@ -284,7 +284,7 @@ function CMD.close() | @@ -284,7 +284,7 @@ function CMD.close() | ||
| 284 | local role = agentInfo.role | 284 | local role = agentInfo.role |
| 285 | if not role then return end | 285 | if not role then return end |
| 286 | 286 | ||
| 287 | - skynet.call(agent.capsule_serv, "lua", "exit", role:getProperty("id")) | 287 | + skynet.call(agentInfo.capsule_serv, "lua", "exit", role:getProperty("id")) |
| 288 | role:log("onLogout", {logtime = skynet.timex()-role:getProperty("ltime")}) | 288 | role:log("onLogout", {logtime = skynet.timex()-role:getProperty("ltime")}) |
| 289 | role:mylog("logout", {int1 = skynet.timex()-role:getProperty("ltime")}) | 289 | role:mylog("logout", {int1 = skynet.timex()-role:getProperty("ltime")}) |
| 290 | role:onOfflineEvent() | 290 | role:onOfflineEvent() |
src/models/Activity.lua
| @@ -497,6 +497,7 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | @@ -497,6 +497,7 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | ||
| 497 | --role:checkTaskEnter("HangPass", {id = 0}) | 497 | --role:checkTaskEnter("HangPass", {id = 0}) |
| 498 | role:checkCalendaTask(true, 15, 3) | 498 | role:checkCalendaTask(true, 15, 3) |
| 499 | role:checkTaskEnter("HeroStarCollect", {}) | 499 | role:checkTaskEnter("HeroStarCollect", {}) |
| 500 | + role:checkTaskEnter("HeroStartSum", {}) | ||
| 500 | role:checkTaskEnter("RuneQualityCollect", {}) | 501 | role:checkTaskEnter("RuneQualityCollect", {}) |
| 501 | 502 | ||
| 502 | end, | 503 | end, |
| @@ -565,6 +566,7 @@ activityFunc[Activity.ActivityType.BattleCommandTask] = { | @@ -565,6 +566,7 @@ activityFunc[Activity.ActivityType.BattleCommandTask] = { | ||
| 565 | --role:checkTaskEnter("HangPass", {id = 0}) | 566 | --role:checkTaskEnter("HangPass", {id = 0}) |
| 566 | role:checkCalendaTask(true, 15, 3) | 567 | role:checkCalendaTask(true, 15, 3) |
| 567 | role:checkTaskEnter("HeroStarCollect", {}) | 568 | role:checkTaskEnter("HeroStarCollect", {}) |
| 569 | + role:checkTaskEnter("HeroStartSum", {}) | ||
| 568 | role:checkTaskEnter("RuneQualityCollect", {}) | 570 | role:checkTaskEnter("RuneQualityCollect", {}) |
| 569 | 571 | ||
| 570 | end, | 572 | end, |
| @@ -669,6 +671,7 @@ activityFunc[Activity.ActivityType.NewUserTask] = { | @@ -669,6 +671,7 @@ activityFunc[Activity.ActivityType.NewUserTask] = { | ||
| 669 | --role:checkTaskEnter("HangPass", {id = 0}) | 671 | --role:checkTaskEnter("HangPass", {id = 0}) |
| 670 | role:checkCalendaTask(true, 15, 3) | 672 | role:checkCalendaTask(true, 15, 3) |
| 671 | role:checkTaskEnter("HeroStarCollect", {}) | 673 | role:checkTaskEnter("HeroStarCollect", {}) |
| 674 | + role:checkTaskEnter("HeroStartSum", {}) | ||
| 672 | role:checkTaskEnter("RuneQualityCollect", {}) | 675 | role:checkTaskEnter("RuneQualityCollect", {}) |
| 673 | 676 | ||
| 674 | end, | 677 | end, |
src/models/Capsule.lua
| @@ -36,6 +36,7 @@ Capsule.schema = { | @@ -36,6 +36,7 @@ Capsule.schema = { | ||
| 36 | name = {"string"}, | 36 | name = {"string"}, |
| 37 | typ = {"number", 1}, -- 1=共享,2=独享 | 37 | typ = {"number", 1}, -- 1=共享,2=独享 |
| 38 | coin = {"number", 0}, --货币代号 | 38 | coin = {"number", 0}, --货币代号 |
| 39 | + token = {"table", {}}, --抽一次,货币=消耗 | ||
| 39 | register = {"table", {}}, --人数 {["id"]=0}, 0 围观, 1 已报名 | 40 | register = {"table", {}}, --人数 {["id"]=0}, 0 围观, 1 已报名 |
| 40 | record = {"table", {}}, --抽取记录 列表 | 41 | record = {"table", {}}, --抽取记录 列表 |
| 41 | recordByRole = {"table", {}}, -- 抽取记录,hash, {roleid=record} | 42 | recordByRole = {"table", {}}, -- 抽取记录,hash, {roleid=record} |
| @@ -43,8 +44,8 @@ Capsule.schema = { | @@ -43,8 +44,8 @@ Capsule.schema = { | ||
| 43 | goods = {"table", {}}, --奖励池 | 44 | goods = {"table", {}}, --奖励池 |
| 44 | specials = {"table", {}}, --特殊赏 | 45 | specials = {"table", {}}, --特殊赏 |
| 45 | incentive = {"table", {}}, --激励奖 | 46 | incentive = {"table", {}}, --激励奖 |
| 46 | - incentiveRecord = {"table", {}}, --激励奖记录 | ||
| 47 | - specialsRecord= {"table", {}}, --特殊赏领取记录 | 47 | + incentiveRecord = {"table", {}}, --激励奖记录 {roleId = {}, roleId={}} |
| 48 | + specialsRecord= {"table", {}}, --特殊赏领取记录 {1={},2={}} key=触发特殊赏的 抽奖次数, v=特殊赏商品 table | ||
| 48 | resetTimes = {"number", 0}, --每日一次手动重置的机会 | 49 | resetTimes = {"number", 0}, --每日一次手动重置的机会 |
| 49 | hideTime = {"number", 0} , --隐藏时间 | 50 | hideTime = {"number", 0} , --隐藏时间 |
| 50 | drawEndTime = {"number", 0}, --抽完时间 | 51 | drawEndTime = {"number", 0}, --抽完时间 |
| @@ -56,6 +57,7 @@ function Capsule:getResetFields() | @@ -56,6 +57,7 @@ function Capsule:getResetFields() | ||
| 56 | room = self:getProperty("room"), | 57 | room = self:getProperty("room"), |
| 57 | typ = self:getProperty("typ"), | 58 | typ = self:getProperty("typ"), |
| 58 | coin = 0, | 59 | coin = 0, |
| 60 | + token = {}, | ||
| 59 | register = {}, | 61 | register = {}, |
| 60 | record = {}, | 62 | record = {}, |
| 61 | recordByRole = {}, | 63 | recordByRole = {}, |
| @@ -132,7 +134,8 @@ function Capsule:init() | @@ -132,7 +134,8 @@ function Capsule:init() | ||
| 132 | end | 134 | end |
| 133 | --货币类型 | 135 | --货币类型 |
| 134 | local coin = ichibankuji["token"]:toArray(true, "=") | 136 | local coin = ichibankuji["token"]:toArray(true, "=") |
| 135 | - self:setProperties({coin = coin[1] or 0, hideTime = ichibankuji.hide_time, goods = goods, specials = specials, incentive = incentive}) | 137 | + self:setProperties({coin = coin[1] or 0, token = coin, hideTime = ichibankuji.hide_time, goods = goods, specials = specials, incentive = incentive}) |
| 138 | + | ||
| 136 | end | 139 | end |
| 137 | 140 | ||
| 138 | function Capsule:isShow() | 141 | function Capsule:isShow() |
| @@ -142,6 +145,80 @@ function Capsule:isShow() | @@ -142,6 +145,80 @@ function Capsule:isShow() | ||
| 142 | return true | 145 | return true |
| 143 | end | 146 | end |
| 144 | 147 | ||
| 148 | +function Capsule:reset2TimeOut(curTime, now) | ||
| 149 | + now = now or skynet.timex() | ||
| 150 | + local interval | ||
| 151 | + if now >= curTime then | ||
| 152 | + self:init() | ||
| 153 | + self:create() | ||
| 154 | + else | ||
| 155 | + interval = curTime - now | ||
| 156 | + end | ||
| 157 | + interval = (interval)* 100 | ||
| 158 | + skynet.timeout(interval, handler(self,self.reset3TimeOut)(curTime)) | ||
| 159 | +end | ||
| 160 | + | ||
| 161 | +function Capsule:reset3TimeOut(curTime, now) | ||
| 162 | + now = now or skynet.timex() | ||
| 163 | + local cur4Time = curTime or (specTime({hour = 4},now)) | ||
| 164 | + | ||
| 165 | + local interval | ||
| 166 | + if cur4Time > now then | ||
| 167 | + interval = cur4Time - now | ||
| 168 | + elseif cur4Time < now then | ||
| 169 | + local nextTime = dayLater(now) | ||
| 170 | + interval = nextTime - now | ||
| 171 | + elseif cur4Time == now then | ||
| 172 | + self:init() | ||
| 173 | + self:create() | ||
| 174 | + | ||
| 175 | + local nextTime = dayLater(now) | ||
| 176 | + interval = nextTime - now | ||
| 177 | + end | ||
| 178 | + interval = (interval)* 100 | ||
| 179 | + skynet.timeout(interval, handler(self,self.reset3TimeOut)) | ||
| 180 | +end | ||
| 181 | + | ||
| 182 | +function Capsule:reset4TimeOut(curTime, now) | ||
| 183 | + now = now or skynet.timex() | ||
| 184 | + local interval | ||
| 185 | + if curTime > now then | ||
| 186 | + interval = curTime - now | ||
| 187 | + elseif curTime < now then | ||
| 188 | + local nextTime = dayLater(now) | ||
| 189 | + interval = nextTime - now | ||
| 190 | + elseif curTime == now then | ||
| 191 | + self:init() | ||
| 192 | + self:create() | ||
| 193 | + | ||
| 194 | + return false | ||
| 195 | + end | ||
| 196 | + interval = (interval)* 100 | ||
| 197 | + skynet.timeout(interval, handler(self,self.reset4TimeOut)) | ||
| 198 | +end | ||
| 199 | + | ||
| 200 | +function Capsule:checkTime(reset, now) | ||
| 201 | + local resetArr = reset:toArray(true, "=") | ||
| 202 | + if not next(resetArr) then return false end | ||
| 203 | + | ||
| 204 | + if resetArr[1] == 2 then | ||
| 205 | + if self:getGoodsAmount() > 0 then return false end | ||
| 206 | + local drawEndTime = self:getProperty("drawEndTime") or 0 | ||
| 207 | + if drawEndTime == 0 then return false end | ||
| 208 | + if now - drawEndTime >= resetArr[2] then return true end | ||
| 209 | + --self:reset2TimeOut(drawEndTime + resetArr[2], now) | ||
| 210 | + elseif resetArr[1] == 3 then | ||
| 211 | + local cur4Time = specTime({hour = 4},now) | ||
| 212 | + if now == cur4Time then return true end | ||
| 213 | + --self:reset3TimeOut(cur4Time, now) | ||
| 214 | + elseif resetArr[1] == 4 then | ||
| 215 | + if now == resetArr[2] then return true end | ||
| 216 | + --self:reset4TimeOut(resetArr[2], now) | ||
| 217 | + end | ||
| 218 | + | ||
| 219 | + return false | ||
| 220 | +end | ||
| 221 | + | ||
| 145 | function Capsule:refreshing(now) | 222 | function Capsule:refreshing(now) |
| 146 | local id = self:getProperty("id") | 223 | local id = self:getProperty("id") |
| 147 | local room = self:getProperty("room") | 224 | local room = self:getProperty("room") |
| @@ -151,30 +228,13 @@ function Capsule:refreshing(now) | @@ -151,30 +228,13 @@ function Capsule:refreshing(now) | ||
| 151 | if reset == "0" then | 228 | if reset == "0" then |
| 152 | return false | 229 | return false |
| 153 | elseif reset == "1" then | 230 | elseif reset == "1" then |
| 154 | - if self:getProperty("resetTimes") == 1 then | 231 | + if self:getProperty("resetTimes") == 0 then |
| 232 | + self:setProperty("resetTime", 1) | ||
| 155 | return true | 233 | return true |
| 156 | end | 234 | end |
| 157 | return false | 235 | return false |
| 158 | else | 236 | else |
| 159 | - local resetArr = reset:toArray(true, "=") | ||
| 160 | - if not next(resetArr) then return false end | ||
| 161 | - | ||
| 162 | - if resetArr[1] == "2" then | ||
| 163 | - if self:getGoodsAmount() > 0 then return false end | ||
| 164 | - | ||
| 165 | - local drawEndTime = self:getProperty("drawEndTime") or 0 | ||
| 166 | - if drawEndTime == 0 then return false end | ||
| 167 | - | ||
| 168 | - if now - drawEndTime >= resetArr[2] then | ||
| 169 | - return true | ||
| 170 | - end | ||
| 171 | - return false | ||
| 172 | - | ||
| 173 | - elseif resetArr[1] == "3" then | ||
| 174 | - | ||
| 175 | - elseif resetArr[1] == "4" then | ||
| 176 | - if now >= resetArr[2] then return true end | ||
| 177 | - end | 237 | + return self:checkTime(reset, now) |
| 178 | end | 238 | end |
| 179 | 239 | ||
| 180 | return false | 240 | return false |
| @@ -233,11 +293,11 @@ function Capsule:confirmed(cares) | @@ -233,11 +293,11 @@ function Capsule:confirmed(cares) | ||
| 233 | for k, v in pairs(cares) do | 293 | for k, v in pairs(cares) do |
| 234 | if v.typ == 1 then | 294 | if v.typ == 1 then |
| 235 | if goods[k] and goods[k].amount ~= v.count then | 295 | if goods[k] and goods[k].amount ~= v.count then |
| 236 | - change[k] = goods[k].amount | 296 | + change[k] = {typ=1, count = goods[k].amount} |
| 237 | end | 297 | end |
| 238 | else | 298 | else |
| 239 | if specials[k] and specials[k].amount ~= v.count then | 299 | if specials[k] and specials[k].amount ~= v.count then |
| 240 | - change[k] = specials[k].amount | 300 | + change[k] = {typ=1, count = specials[k].amount} |
| 241 | end | 301 | end |
| 242 | end | 302 | end |
| 243 | end | 303 | end |
| @@ -271,7 +331,7 @@ function Capsule:checkSpecialFlag(typ) | @@ -271,7 +331,7 @@ function Capsule:checkSpecialFlag(typ) | ||
| 271 | return spKey, special | 331 | return spKey, special |
| 272 | end | 332 | end |
| 273 | 333 | ||
| 274 | -local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now) | 334 | +local function getSpecialReward(rewardRecord, count, award, spKey, typ, now) |
| 275 | local rewardByRole = {} | 335 | local rewardByRole = {} |
| 276 | while(count > 0 and next(rewardRecord)) do | 336 | while(count > 0 and next(rewardRecord)) do |
| 277 | local roleId = math.randWeight(rewardRecord, "amount") | 337 | local roleId = math.randWeight(rewardRecord, "amount") |
| @@ -282,19 +342,9 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now) | @@ -282,19 +342,9 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now) | ||
| 282 | 342 | ||
| 283 | if tmp["amount"] <= 0 then rewardRecord[roleId] = nil end | 343 | if tmp["amount"] <= 0 then rewardRecord[roleId] = nil end |
| 284 | 344 | ||
| 285 | - tmp = rewardByRole[roleId] | ||
| 286 | - if not tmp then | ||
| 287 | - local name = getNameByRoleId(roleId) | ||
| 288 | - tmp[spKey] = {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = award, amount = 1, quality = typ, create_time= now} | ||
| 289 | - else | ||
| 290 | - if not tmp[spKey] then | ||
| 291 | - local name = getNameByRoleId(roleId) | ||
| 292 | - tmp[spKey] = {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = award, amount = 1, quality = typ, create_time= now} | ||
| 293 | - else | ||
| 294 | - tmp[spKey].amount = tmp[spKey].amount + 1 | ||
| 295 | - end | ||
| 296 | - end | ||
| 297 | - rewardByRole[roleId] = tmp | 345 | + local name = getNameByRoleId(roleId) |
| 346 | + tmp = {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = award, amount = 1, quality = typ, create_time= now} | ||
| 347 | + table.insert(rewardByRole, tmp) | ||
| 298 | 348 | ||
| 299 | count = count - 1 | 349 | count = count - 1 |
| 300 | end | 350 | end |
| @@ -302,13 +352,28 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now) | @@ -302,13 +352,28 @@ local function getSpecialRoleNotify(rewardRecord, count, award, spKey, typ, now) | ||
| 302 | return rewardByRole, count | 352 | return rewardByRole, count |
| 303 | end | 353 | end |
| 304 | 354 | ||
| 305 | -function Capsule:getTop(record) | 355 | + |
| 356 | +local rewardToRecordFunc = function(specialsRecord, recordAmount, rewardByRole) | ||
| 357 | + if not specialsRecord[recordAmount] then | ||
| 358 | + specialsRecord[recordAmount] = rewardByRole | ||
| 359 | + else | ||
| 360 | + table.insert(specialsRecord[recordAmount], rewardByRole) | ||
| 361 | + end | ||
| 362 | +end | ||
| 363 | + | ||
| 364 | +local function getRecordAmount(record) | ||
| 365 | + return #record | ||
| 366 | +end | ||
| 367 | + | ||
| 368 | + | ||
| 369 | +function Capsule:getTop(record, recordAmount,now) | ||
| 306 | local spKey, special = self:checkSpecialFlag(SpecialType.TOP) | 370 | local spKey, special = self:checkSpecialFlag(SpecialType.TOP) |
| 307 | if not special then return nil end | 371 | if not special then return nil end |
| 308 | local specials = self:getProperty("specials") or {} | 372 | local specials = self:getProperty("specials") or {} |
| 309 | local specialsRecord = self:getProperty("specialsRecord") or {} | 373 | local specialsRecord = self:getProperty("specialsRecord") or {} |
| 310 | 374 | ||
| 311 | - if #record < special["np"] then return nil end | 375 | + if recordAmount < special["np"] then return nil end |
| 376 | + | ||
| 312 | local topRecord = {} | 377 | local topRecord = {} |
| 313 | local count = special["np"] | 378 | local count = special["np"] |
| 314 | for _, v in ipairs(record) do | 379 | for _, v in ipairs(record) do |
| @@ -330,32 +395,33 @@ function Capsule:getTop(record) | @@ -330,32 +395,33 @@ function Capsule:getTop(record) | ||
| 330 | end | 395 | end |
| 331 | end | 396 | end |
| 332 | 397 | ||
| 333 | - local rewardByRole, count = getSpecialRoleNotify(topRecord, special["amount"], special["award"], spKey, SpecialType.TOP) | 398 | + local rewardByRole, count = getSpecialReward(topRecord, special["amount"], special["award"], spKey, SpecialType.TOP,now) |
| 334 | 399 | ||
| 335 | special["amount"] = count | 400 | special["amount"] = count |
| 336 | specials[spKey] = special | 401 | specials[spKey] = special |
| 337 | - specialsRecord[SpecialType.TOP] = rewardByRole | 402 | + |
| 403 | + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole) | ||
| 404 | + | ||
| 338 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) | 405 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) |
| 339 | return rewardByRole | 406 | return rewardByRole |
| 340 | 407 | ||
| 341 | end | 408 | end |
| 342 | 409 | ||
| 343 | --TODO | 410 | --TODO |
| 344 | -function Capsule:getCore(record) | 411 | +function Capsule:getCore(record, recordAmount,now) |
| 345 | local spKey, special = self:checkSpecialFlag(SpecialType.CORE) | 412 | local spKey, special = self:checkSpecialFlag(SpecialType.CORE) |
| 346 | if not special then return nil end | 413 | if not special then return nil end |
| 347 | 414 | ||
| 348 | local specials = self:getProperty("specials") or {} | 415 | local specials = self:getProperty("specials") or {} |
| 349 | local specialsRecord = self:getProperty("specialsRecord") or {} | 416 | local specialsRecord = self:getProperty("specialsRecord") or {} |
| 350 | 417 | ||
| 351 | - if self:getGoodsAmount() > 0 then return nil end | ||
| 352 | 418 | ||
| 353 | - local np = special["np"] | ||
| 354 | - if np > #record then return nil end | 419 | + |
| 420 | + local count = special["np"] | ||
| 421 | + if count > recordAmount then return nil end | ||
| 355 | 422 | ||
| 356 | 423 | ||
| 357 | - local left = math.ceil((np - #record)/2) or 0 | ||
| 358 | - local count = np | 424 | + local left = math.ceil((count - recordAmount)/2) or 0 |
| 359 | local roleRecord = {} | 425 | local roleRecord = {} |
| 360 | for i, v in ipairs(record) do | 426 | for i, v in ipairs(record) do |
| 361 | if count <= 0 then break end | 427 | if count <= 0 then break end |
| @@ -372,34 +438,32 @@ function Capsule:getCore(record) | @@ -372,34 +438,32 @@ function Capsule:getCore(record) | ||
| 372 | if not roleRecord[v.roleId]then | 438 | if not roleRecord[v.roleId]then |
| 373 | roleRecord[v.roleId] = {amount = v.amount } | 439 | roleRecord[v.roleId] = {amount = v.amount } |
| 374 | else | 440 | else |
| 375 | - roleRecord[v.roleId] = {amount = (roleRecord[v.rol_id]["amount"] or 0) + tmpCount} | 441 | + roleRecord[v.roleId] = {amount = (roleRecord[v.roleId]["amount"] or 0) + tmpCount} |
| 376 | end | 442 | end |
| 377 | end | 443 | end |
| 378 | 444 | ||
| 379 | end | 445 | end |
| 380 | 446 | ||
| 381 | - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], SpecialType.CORE) | 447 | + local rewardByRole, count = getSpecialReward(roleRecord, special["amount"], special["award"], spKey, SpecialType.CORE,now) |
| 382 | 448 | ||
| 383 | special["amount"] = count | 449 | special["amount"] = count |
| 384 | specials[spKey] = special | 450 | specials[spKey] = special |
| 385 | - specialsRecord[SpecialType.CORE] = rewardByRole | 451 | + |
| 452 | + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole) | ||
| 386 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) | 453 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) |
| 387 | return rewardByRole | 454 | return rewardByRole |
| 388 | end | 455 | end |
| 389 | 456 | ||
| 390 | -function Capsule:getLast(record) | 457 | +function Capsule:getLast(record, recordAmount, now) |
| 391 | local spKey, special = self:checkSpecialFlag(SpecialType.LAST) | 458 | local spKey, special = self:checkSpecialFlag(SpecialType.LAST) |
| 392 | if not special then return nil end | 459 | if not special then return nil end |
| 393 | 460 | ||
| 394 | local specials = self:getProperty("specials") or {} | 461 | local specials = self:getProperty("specials") or {} |
| 395 | local specialsRecord = self:getProperty("specialsRecord") or {} | 462 | local specialsRecord = self:getProperty("specialsRecord") or {} |
| 396 | 463 | ||
| 397 | - if self:getGoodsAmount() > 0 then return nil end | ||
| 398 | - | ||
| 399 | 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) |
| 400 | 465 | ||
| 401 | - local np = special["np"] | ||
| 402 | - local count = np | 466 | + local count = special["np"] |
| 403 | local roleRecord = {} | 467 | local roleRecord = {} |
| 404 | for _, v in ipairs(record) do | 468 | for _, v in ipairs(record) do |
| 405 | if count <= 0 then break end | 469 | if count <= 0 then break end |
| @@ -416,90 +480,85 @@ function Capsule:getLast(record) | @@ -416,90 +480,85 @@ function Capsule:getLast(record) | ||
| 416 | if not roleRecord[v.roleId]then | 480 | if not roleRecord[v.roleId]then |
| 417 | roleRecord[v.roleId] = {amount = v.amount } | 481 | roleRecord[v.roleId] = {amount = v.amount } |
| 418 | else | 482 | else |
| 419 | - roleRecord[v.roleId] = {amount = (roleRecord[v.rol_id]["amount"] or 0) + tmpCount} | 483 | + roleRecord[v.roleId] = {amount = (roleRecord[v.roleId]["amount"] or 0) + tmpCount} |
| 420 | end | 484 | end |
| 421 | end | 485 | end |
| 422 | 486 | ||
| 423 | - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], SpecialType.LAST) | 487 | + local rewardByRole, count = getSpecialReward(roleRecord, special["amount"], special["award"], spKey, SpecialType.LAST,now) |
| 424 | 488 | ||
| 425 | special["amount"] = count | 489 | special["amount"] = count |
| 426 | specials[spKey] = special | 490 | specials[spKey] = special |
| 427 | - specialsRecord[SpecialType.LAST] = rewardByRole | 491 | + |
| 492 | + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole) | ||
| 428 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) | 493 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) |
| 429 | return rewardByRole | 494 | return rewardByRole |
| 430 | end | 495 | end |
| 431 | 496 | ||
| 432 | -function Capsule:getJoker(record) | 497 | +function Capsule:getJoker(record, recordAmount, now) |
| 433 | local spKey, special = self:checkSpecialFlag(SpecialType.JOKER) | 498 | local spKey, special = self:checkSpecialFlag(SpecialType.JOKER) |
| 434 | if not special then return nil end | 499 | if not special then return nil end |
| 435 | 500 | ||
| 436 | local specials = self:getProperty("specials") or {} | 501 | local specials = self:getProperty("specials") or {} |
| 437 | local specialsRecord = self:getProperty("specialsRecord") or {} | 502 | local specialsRecord = self:getProperty("specialsRecord") or {} |
| 438 | 503 | ||
| 439 | - if self:getGoodsAmount() > 0 then return nil end | ||
| 440 | - | ||
| 441 | local roleRecord = {} | 504 | local roleRecord = {} |
| 442 | for _, v in ipairs(record) do | 505 | for _, v in ipairs(record) do |
| 443 | if not roleRecord[v.roleId]then | 506 | if not roleRecord[v.roleId]then |
| 444 | roleRecord[v.roleId] = {amount = v.amount } | 507 | roleRecord[v.roleId] = {amount = v.amount } |
| 445 | else | 508 | else |
| 446 | - roleRecord[v.roleId] = {amount = (roleRecord[v.rol_id]["amount"] or 0) + v.amount} | 509 | + roleRecord[v.roleId] = {amount = (roleRecord[v.roleId]["amount"] or 0) + v.amount} |
| 447 | end | 510 | end |
| 448 | end | 511 | end |
| 449 | 512 | ||
| 450 | - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], SpecialType.JOKER) | 513 | + local rewardByRole, count = getSpecialReward(roleRecord, special["amount"], special["award"], spKey, SpecialType.JOKER,now) |
| 451 | 514 | ||
| 452 | special["amount"] = count | 515 | special["amount"] = count |
| 453 | specials[spKey] = special | 516 | specials[spKey] = special |
| 454 | - specialsRecord[SpecialType.JOKER] = rewardByRole | 517 | + |
| 518 | + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole) | ||
| 455 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) | 519 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) |
| 456 | return rewardByRole | 520 | return rewardByRole |
| 457 | end | 521 | end |
| 458 | 522 | ||
| 459 | -function Capsule:getKing(record) | 523 | +function Capsule:getKing(record, recordAmount, now) |
| 460 | local spKey, special = self:checkSpecialFlag(SpecialType.KING) | 524 | local spKey, special = self:checkSpecialFlag(SpecialType.KING) |
| 461 | if not special then return nil end | 525 | if not special then return nil end |
| 462 | 526 | ||
| 463 | local specials = self:getProperty("specials") or {} | 527 | local specials = self:getProperty("specials") or {} |
| 464 | local specialsRecord = self:getProperty("specialsRecord") or {} | 528 | local specialsRecord = self:getProperty("specialsRecord") or {} |
| 465 | - | ||
| 466 | - if self:getGoodsAmount() > 0 then return nil end | 529 | + local rank = self:getProperty("rank") or {} |
| 530 | + if not next(rank) then return nil end | ||
| 467 | 531 | ||
| 468 | local roleRecord = {} | 532 | local roleRecord = {} |
| 469 | - for _, v in ipairs(record) do | ||
| 470 | - if not roleRecord[v.roleId]then | ||
| 471 | - roleRecord[v.roleId] = {amount = v.amount } | ||
| 472 | - else | ||
| 473 | - roleRecord[v.roleId] = {amount = (roleRecord[v.rol_id]["amount"] or 0) + v.amount} | ||
| 474 | - end | 533 | + |
| 534 | + for roleId, count in pairs(rank) do | ||
| 535 | + table.insert(roleRecord, {roleId = roleId, count = count}) | ||
| 536 | + end | ||
| 537 | + table.sort(roleRecord, function(a, b) return a.count > b.count end) | ||
| 538 | + | ||
| 539 | + local count = math.min(special["amount"], #roleRecord) | ||
| 540 | + | ||
| 541 | + local rewardByRole = {} | ||
| 542 | + local index = 1 | ||
| 543 | + while (count > 0 ) do | ||
| 544 | + count = count - 1 | ||
| 545 | + local tmp = roleRecord[index] | ||
| 546 | + if not tmp then break end | ||
| 547 | + index = index + 1 | ||
| 548 | + | ||
| 549 | + local name = getNameByRoleId(tmp.roleId) | ||
| 550 | + table.insert(rewardByRole, {name = name, good_id = spKey, typ = RewardType.SPECIAL, award = special["award"], amount = 1, SpecialType.KING, create_time= now}) | ||
| 475 | end | 551 | end |
| 476 | 552 | ||
| 477 | - local rewardByRole, count = getSpecialRoleNotify(roleRecord, special["amount"], special["award"], SpecialType.KING) | ||
| 478 | special["amount"] = count | 553 | special["amount"] = count |
| 479 | specials[spKey] = special | 554 | specials[spKey] = special |
| 480 | - specialsRecord[SpecialType.KING] = rewardByRole | 555 | + |
| 556 | + rewardToRecordFunc(specialsRecord, recordAmount, rewardByRole) | ||
| 481 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) | 557 | self:setProperties({specialsRecord = specialsRecord, specials = specials}) |
| 482 | return rewardByRole | 558 | return rewardByRole |
| 483 | end | 559 | end |
| 484 | 560 | ||
| 485 | -local rewardToNtyFunc = function(notify, tmpReward) | ||
| 486 | - for key, val in pairs(tmpReward or {}) do | ||
| 487 | - if not notify[key] then | ||
| 488 | - notify[key] = val | ||
| 489 | - else | ||
| 490 | - for k, v in pairs(val) do | ||
| 491 | - if not notify[key][k] then | ||
| 492 | - notify[key][k] = v | ||
| 493 | - else | ||
| 494 | - notify[key][k] = notify[key][k].amount + v.amount | ||
| 495 | - end | ||
| 496 | - end | ||
| 497 | - | ||
| 498 | - end | ||
| 499 | - end | ||
| 500 | -end | ||
| 501 | - | ||
| 502 | -function Capsule:checkSpecialReward( now) | 561 | +function Capsule:checkSpecialReward(now, goodsAmount) |
| 503 | local specials = self:getProperty("specials") or {} | 562 | local specials = self:getProperty("specials") or {} |
| 504 | if not next(specials) then return nil end | 563 | if not next(specials) then return nil end |
| 505 | local record = self:getProperty("record") or {} | 564 | local record = self:getProperty("record") or {} |
| @@ -507,23 +566,24 @@ function Capsule:checkSpecialReward( now) | @@ -507,23 +566,24 @@ function Capsule:checkSpecialReward( now) | ||
| 507 | if not next(record) then return nil end | 566 | if not next(record) then return nil end |
| 508 | table.sort(record, function(a, b) return a.create_time < b.create_time end ) | 567 | table.sort(record, function(a, b) return a.create_time < b.create_time end ) |
| 509 | 568 | ||
| 569 | + local recordAmount = getRecordAmount(record) | ||
| 510 | 570 | ||
| 511 | - local notify = self:getTop(record) or {} | 571 | + local notify = self:getTop(record, recordAmount,now) or {} |
| 512 | 572 | ||
| 513 | - local coreReward = self:getCore(record) | ||
| 514 | - rewardToNtyFunc(notify, coreReward) | 573 | + if goodsAmount == 0 then |
| 574 | + local coreReward = self:getCore(record, recordAmount, now) | ||
| 575 | + rewardToRecordFunc(notify, recordAmount, coreReward) | ||
| 515 | 576 | ||
| 516 | - local lastReward = self:getLast(record) | ||
| 517 | - rewardToNtyFunc(notify, lastReward) | 577 | + local lastReward = self:getLast(record, recordAmount, now) |
| 578 | + rewardToRecordFunc(notify, recordAmount, lastReward) | ||
| 518 | 579 | ||
| 519 | - local jokerReward = self:getJoker(record) | ||
| 520 | - rewardToNtyFunc(notify, jokerReward) | 580 | + local jokerReward = self:getJoker(record, recordAmount, now) |
| 581 | + rewardToRecordFunc(notify, recordAmount, jokerReward) | ||
| 521 | 582 | ||
| 522 | - local kingReward = self:getKing(record) | ||
| 523 | - rewardToNtyFunc(notify, kingReward) | 583 | + local kingReward = self:getKing(record, recordAmount, now) |
| 584 | + rewardToRecordFunc(notify, recordAmount, kingReward) | ||
| 585 | + end | ||
| 524 | 586 | ||
| 525 | - --广播出去TODO | ||
| 526 | - --rpcRole(roleId, "paySpecialReward", RewardTYpe.JOKER, jokerReward.award) | ||
| 527 | return notify | 587 | return notify |
| 528 | end | 588 | end |
| 529 | 589 | ||
| @@ -561,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now) | @@ -561,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now) | ||
| 561 | end | 621 | end |
| 562 | 622 | ||
| 563 | local count = math.floor(amount / incentive["amount"]["np"]) | 623 | local count = math.floor(amount / incentive["amount"]["np"]) |
| 564 | - local tmpCount = count * incentive["amount"]["np"] | ||
| 565 | - notify["amount"] = {name = name, good_id = "amount", typ = RewardType.INCENTIVE, award = incentive["amount"]["award"], amount = count, quality = 2, create_time= now} | ||
| 566 | - | ||
| 567 | - --填充v.calculated 字段,标识已经用于每x抽的计算中。 | ||
| 568 | - for _, v in pairs(roleRecord) do | ||
| 569 | - if tmpCount <= 0 then break end | ||
| 570 | - | ||
| 571 | - v.calculated = v.calculated or 0 | ||
| 572 | - if v.calculated ~= v.amount then | ||
| 573 | - if tmpCount <= v.amount then | ||
| 574 | - v.calculated = tmpCount | ||
| 575 | - tmpCount = 0 | ||
| 576 | - else | ||
| 577 | - v.calculated = v.amount | ||
| 578 | - tmpCount = tmpCount - v.amount | 624 | + if count > 0 then |
| 625 | + local tmpCount = count * incentive["amount"]["np"] | ||
| 626 | + notify["amount"] = {name = name, roleId= roleId, good_id = "amount", typ = RewardType.INCENTIVE, award = incentive["amount"]["award"], amount = count, quality = 2, create_time= now} | ||
| 627 | + | ||
| 628 | + --填充v.calculated 字段,标识已经用于每x抽的计算中。 | ||
| 629 | + for _, v in pairs(roleRecord) do | ||
| 630 | + if tmpCount <= 0 then break end | ||
| 631 | + | ||
| 632 | + v.calculated = v.calculated or 0 | ||
| 633 | + if v.calculated ~= v.amount then | ||
| 634 | + if tmpCount <= v.amount then | ||
| 635 | + v.calculated = tmpCount | ||
| 636 | + tmpCount = 0 | ||
| 637 | + else | ||
| 638 | + v.calculated = v.amount | ||
| 639 | + tmpCount = tmpCount - v.amount | ||
| 640 | + end | ||
| 579 | end | 641 | end |
| 580 | end | 642 | end |
| 581 | - | ||
| 582 | end | 643 | end |
| 583 | end | 644 | end |
| 584 | 645 | ||
| @@ -590,11 +651,44 @@ function Capsule:checkIncentive(roleId, name, now) | @@ -590,11 +651,44 @@ function Capsule:checkIncentive(roleId, name, now) | ||
| 590 | 651 | ||
| 591 | end | 652 | end |
| 592 | end | 653 | end |
| 593 | - table.insert(incentiveByRole, notify) | 654 | + for k, v in pairs(notify) do |
| 655 | + if not incentiveByRole[k] then | ||
| 656 | + incentiveByRole[k] = v | ||
| 657 | + else | ||
| 658 | + incentiveByRole[k].amount = incentiveByRole[k].amount + v.amount | ||
| 659 | + end | ||
| 660 | + end | ||
| 594 | incentiveRecord[roleId] = incentiveByRole | 661 | incentiveRecord[roleId] = incentiveByRole |
| 595 | self:setProperty("incentiveRecord", incentiveRecord) | 662 | self:setProperty("incentiveRecord", incentiveRecord) |
| 596 | 663 | ||
| 597 | - return notify | 664 | + return incentiveByRole |
| 665 | +end | ||
| 666 | + | ||
| 667 | +local rewardCollect = function(reward, goods) | ||
| 668 | + for _, v in pairs(goods) do | ||
| 669 | + for id, count in pairs(v.award:toNumMap()) do | ||
| 670 | + reward[id] = (reward[id] or 0) + count * v.amount | ||
| 671 | + end | ||
| 672 | + end | ||
| 673 | +end | ||
| 674 | + | ||
| 675 | +local rewardCollectByRoleId = function(roleId, reward, goods) | ||
| 676 | + local tmp = {} | ||
| 677 | + for _, val in pairs(goods) do | ||
| 678 | + for _, v in ipairs(val) do | ||
| 679 | + if v.roleId == roleId then | ||
| 680 | + for id, count in pairs(v.award:toNumMap()) do | ||
| 681 | + reward[id] = (reward[id] or 0) + count * v.amount | ||
| 682 | + end | ||
| 683 | + if not tmp[v.good_id] then | ||
| 684 | + tmp[v.good_id] = v | ||
| 685 | + else | ||
| 686 | + tmp[v.good_id].amount = tmp[v.good_id].amount + v.amount | ||
| 687 | + end | ||
| 688 | + end | ||
| 689 | + end | ||
| 690 | + end | ||
| 691 | + return tmp | ||
| 598 | end | 692 | end |
| 599 | 693 | ||
| 600 | function Capsule:drawByCount(roleId, count) | 694 | function Capsule:drawByCount(roleId, count) |
| @@ -602,6 +696,8 @@ function Capsule:drawByCount(roleId, count) | @@ -602,6 +696,8 @@ function Capsule:drawByCount(roleId, count) | ||
| 602 | 696 | ||
| 603 | local goods = self:getProperty("goods") or {} | 697 | local goods = self:getProperty("goods") or {} |
| 604 | 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 | ||
| 605 | local recordByRole = self:getProperty("recordByRole") or {} | 701 | local recordByRole = self:getProperty("recordByRole") or {} |
| 606 | local roleRecord = recordByRole[roleId] or {} | 702 | local roleRecord = recordByRole[roleId] or {} |
| 607 | 703 | ||
| @@ -611,98 +707,106 @@ function Capsule:drawByCount(roleId, count) | @@ -611,98 +707,106 @@ function Capsule:drawByCount(roleId, count) | ||
| 611 | local goods_id = ichibankuji["goods_id"] | 707 | local goods_id = ichibankuji["goods_id"] |
| 612 | local now = skynet.timex() | 708 | local now = skynet.timex() |
| 613 | 709 | ||
| 614 | - --奖励, 通知信息 | ||
| 615 | - local notify= {} | ||
| 616 | - notify[roleId] = {} | 710 | + --奖励,普通奖品信息 |
| 711 | + local goodsByUsual= {} | ||
| 617 | 712 | ||
| 618 | local name = getNameByRoleId(roleId) | 713 | local name = getNameByRoleId(roleId) |
| 619 | while (goods and next(goods) and count > 0) do | 714 | while (goods and next(goods) and count > 0) do |
| 620 | local good_id = math.randWeight(goods, "weight") | 715 | local good_id = math.randWeight(goods, "weight") |
| 621 | - if good_id then | ||
| 622 | - local good = goods[good_id] or {} | ||
| 623 | - if good and good.amount > 0 then | ||
| 624 | - good.amount = good.amount - 1 | ||
| 625 | - | ||
| 626 | - --插入记录 | ||
| 627 | - local tmpNotify = {name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = 1, quality = good.quality, create_time= now} | ||
| 628 | - table.insert(record, tmpNotify) | ||
| 629 | - | ||
| 630 | - --作为奖励记录+通知 | ||
| 631 | - if not notify[roleId][good_id] then | ||
| 632 | - notify[roleId][good_id] = tmpNotify | ||
| 633 | - else | ||
| 634 | - notify[roleId][good_id].amount = notify[roleId][good_id].amount + 1 | ||
| 635 | - end | 716 | + if not good_id then break end |
| 636 | 717 | ||
| 637 | - --记录角色的抽奖记录 计算激励奖需要用到 | ||
| 638 | - if not roleRecord[good_id] then | ||
| 639 | - roleRecord[good_id] = tmpNotify | ||
| 640 | - else | ||
| 641 | - roleRecord[good_id].amount = roleRecord[good_id].amount + 1 | ||
| 642 | - end | 718 | + local good = goods[good_id] or {} |
| 719 | + if good and good.amount > 0 then | ||
| 720 | + good.amount = good.amount - 1 | ||
| 721 | + | ||
| 722 | + --插入rank | ||
| 723 | + rankRole = rankRole + 1 | ||
| 643 | 724 | ||
| 644 | - good.weight = good.weight - csvdb["ichibankuji_goodsCsv"][goods_id][good.id].weight | ||
| 645 | - count = count - 1 | 725 | + --插入记录 |
| 726 | + local tmpNotify = {roleId = roleId, name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = 1, quality = good.quality, create_time= now} | ||
| 727 | + table.insert(record, tmpNotify) | ||
| 728 | + | ||
| 729 | + --作为奖励记录+通知 | ||
| 730 | + if not goodsByUsual[good_id] then | ||
| 731 | + goodsByUsual[good_id] = tmpNotify | ||
| 732 | + else | ||
| 733 | + goodsByUsual[good_id].amount = goodsByUsual[good_id].amount + 1 | ||
| 646 | end | 734 | end |
| 647 | - end | ||
| 648 | 735 | ||
| 649 | - end | ||
| 650 | - recordByRole[roleId] = roleRecord | ||
| 651 | - self:setProperties({recordByRole = recordByRole, record = record, goods = goods}) | 736 | + --记录角色的抽奖记录 计算激励奖需要用到 |
| 737 | + if not roleRecord[good_id] then | ||
| 738 | + roleRecord[good_id] = tmpNotify | ||
| 739 | + else | ||
| 740 | + roleRecord[good_id].amount = roleRecord[good_id].amount + 1 | ||
| 741 | + end | ||
| 652 | 742 | ||
| 653 | - local tmpNotify = self:checkIncentive(roleId, name, now) | ||
| 654 | - for k, v in pairs(tmpNotify) do | ||
| 655 | - if not notify[roleId][k] then | ||
| 656 | - notify[roleId][k] = v | ||
| 657 | - else | ||
| 658 | - notify[roleId][k].amount = notify[roleId][k].amount + v.amount | 743 | + good.weight = good.weight - csvdb["ichibankuji_goodsCsv"][goods_id][good.id].weight |
| 744 | + count = count - 1 | ||
| 659 | end | 745 | end |
| 746 | + | ||
| 660 | end | 747 | end |
| 661 | 748 | ||
| 662 | - local speciNotify = self:checkSpecialReward(now) | ||
| 663 | - rewardToNtyFunc(notify, speciNotify) | 749 | + --奖励池重新赋值 |
| 750 | + rank[roleId] = rankRole | ||
| 751 | + recordByRole[roleId] = roleRecord | ||
| 752 | + self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank}) | ||
| 664 | 753 | ||
| 665 | - local reward, rewardByGoods = {}, {} | ||
| 666 | - for key, val in pairs(notify) do | ||
| 667 | - if key == roleId then | ||
| 668 | - for k, v in pairs(val) do | ||
| 669 | - for id, count in pairs(v.award:toNumMap()) do | ||
| 670 | - reward[id] = (reward[id] or 0) + count | ||
| 671 | - end | ||
| 672 | - rewardByGoods[k] = v | ||
| 673 | - end | ||
| 674 | - end | 754 | + --奖励收集 |
| 755 | + local reward = {} | ||
| 756 | + rewardCollect(reward, goodsByUsual) | ||
| 675 | 757 | ||
| 758 | + local goodsByIncentive = self:checkIncentive(roleId, name, now) | ||
| 759 | + rewardCollect(reward, goodsByIncentive) | ||
| 760 | + | ||
| 761 | + local goodsAmount = self:getGoodsAmount() | ||
| 762 | + if goodsAmount == 0 then | ||
| 763 | + self:setProperty("drawEndTime", now) | ||
| 676 | end | 764 | end |
| 677 | - return reward, rewardByGoods, notify | 765 | + |
| 766 | + local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) | ||
| 767 | + local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial) | ||
| 768 | + | ||
| 769 | + local drawReward = {} | ||
| 770 | + drawReward["reward"] = reward | ||
| 771 | + drawReward["usual"] = goodsByUsual | ||
| 772 | + drawReward["specials"] = goodsBySpecial | ||
| 773 | + if next(goodsByIncentive) then drawReward["incentive"] = goodsByIncentive end | ||
| 774 | + if next(specialByRole) then drawReward["special"] = specialByRole end | ||
| 775 | + return drawReward | ||
| 678 | end | 776 | end |
| 679 | 777 | ||
| 680 | function Capsule:drawAll(roleId) | 778 | function Capsule:drawAll(roleId) |
| 681 | local goods = self:getProperty("goods") or {} | 779 | local goods = self:getProperty("goods") or {} |
| 682 | 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 | ||
| 683 | local recordByRole = self:getProperty("recordByRole") or {} | 783 | local recordByRole = self:getProperty("recordByRole") or {} |
| 684 | local roleRecord = recordByRole[roleId] or {} | 784 | local roleRecord = recordByRole[roleId] or {} |
| 685 | local now = skynet.timex() | 785 | local now = skynet.timex() |
| 686 | 786 | ||
| 687 | local name = getNameByRoleId(roleId) | 787 | local name = getNameByRoleId(roleId) |
| 688 | - local notify = {} | ||
| 689 | - notify[roleId] = {} | 788 | + local goodsByUsual = {} |
| 690 | for good_id, good in pairs(goods) do | 789 | for good_id, good in pairs(goods) do |
| 691 | if good.amount > 0 then | 790 | if good.amount > 0 then |
| 791 | + --插入rank | ||
| 792 | + rankRole = rankRole + good.amount | ||
| 793 | + | ||
| 692 | --插入记录 | 794 | --插入记录 |
| 693 | - local tmpNotify = {name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = good.amount, quality = good.quality, create_time = now} | ||
| 694 | - table.insert(record, notify) | 795 | + local tmpNotify = {roleId = roleId, name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = good.amount, quality = good.quality, create_time = now} |
| 796 | + for i = 1, good.amount do | ||
| 797 | + table.insert(record, {roleId = roleId, name= name, good_id = good_id, typ = RewardType.GOODS, award = good.award, amount = 1, quality = good.quality, create_time = now}) | ||
| 798 | + end | ||
| 695 | 799 | ||
| 696 | --作为奖励记录+通知 | 800 | --作为奖励记录+通知 |
| 697 | - if not notify[roleId][good_id] then | ||
| 698 | - notify[roleId][good_id] = tmpNotify | 801 | + if not goodsByUsual[good_id] then |
| 802 | + goodsByUsual[good_id] = tmpNotify | ||
| 699 | else | 803 | else |
| 700 | - notify[roleId][good_id].amount = notify[roleId][good_id].amount + good.award | 804 | + goodsByUsual[good_id].amount = goodsByUsual[good_id].amount + good.award |
| 701 | end | 805 | end |
| 702 | 806 | ||
| 703 | --记录角色的抽奖记录 | 807 | --记录角色的抽奖记录 |
| 704 | if not roleRecord[good_id] then | 808 | if not roleRecord[good_id] then |
| 705 | - roleRecord[good_id] = notify | 809 | + roleRecord[good_id] = tmpNotify |
| 706 | else | 810 | else |
| 707 | roleRecord[good_id].amount = roleRecord[good_id].amount + good.amount | 811 | roleRecord[good_id].amount = roleRecord[good_id].amount + good.amount |
| 708 | end | 812 | end |
| @@ -711,34 +815,32 @@ function Capsule:drawAll(roleId) | @@ -711,34 +815,32 @@ function Capsule:drawAll(roleId) | ||
| 711 | end | 815 | end |
| 712 | 816 | ||
| 713 | end | 817 | end |
| 818 | + rank[roleId] = rankRole | ||
| 714 | recordByRole[roleId] = roleRecord | 819 | recordByRole[roleId] = roleRecord |
| 715 | - self:setProperties({recordByRole = recordByRole, record = record, goods = goods}) | ||
| 716 | - | ||
| 717 | - local tmpNotify = self:checkIncentive(roleId, name, now) | ||
| 718 | - for k, v in pairs(tmpNotify) do | ||
| 719 | - if not notify[roleId][k] then | ||
| 720 | - notify[roleId][k] = v | ||
| 721 | - else | ||
| 722 | - notify[roleId][k].amount = notify[roleId][k].amount + v.amount | ||
| 723 | - end | ||
| 724 | - end | 820 | + self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank}) |
| 725 | 821 | ||
| 726 | - local speciNotify = self:checkSpecialReward(now) | ||
| 727 | - rewardToNtyFunc(notify, speciNotify) | 822 | + --奖励收集 |
| 823 | + local reward = {} | ||
| 824 | + rewardCollect(reward, goodsByUsual) | ||
| 728 | 825 | ||
| 729 | - local reward, rewardByGoods = {}, {} | ||
| 730 | - for key, val in pairs(notify) do | ||
| 731 | - if key == roleId then | ||
| 732 | - for k, v in pairs(val) do | ||
| 733 | - for id, count in pairs(v.award:toNumMap()) do | ||
| 734 | - reward[id] = (reward[id] or 0) + count | ||
| 735 | - end | ||
| 736 | - rewardByGoods[k] = v | ||
| 737 | - end | ||
| 738 | - end | 826 | + local goodsByIncentive = self:checkIncentive(roleId, name, now) |
| 827 | + rewardCollect(reward, goodsByIncentive) | ||
| 739 | 828 | ||
| 829 | + local goodsAmount = self:getGoodsAmount() | ||
| 830 | + if goodsAmount == 0 then | ||
| 831 | + self:setProperty("drawEndTime", now) | ||
| 740 | end | 832 | end |
| 741 | - return reward, rewardByGoods, notify | 833 | + |
| 834 | + local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) | ||
| 835 | + local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial) | ||
| 836 | + | ||
| 837 | + local drawReward = {} | ||
| 838 | + drawReward["reward"] = reward | ||
| 839 | + drawReward["usual"] = goodsByUsual | ||
| 840 | + drawReward["specials"] = goodsBySpecial | ||
| 841 | + if next(goodsByIncentive) then drawReward["incentive"] = goodsByIncentive end | ||
| 842 | + if next(specialByRole) then drawReward["special"] = specialByRole end | ||
| 843 | + return drawReward | ||
| 742 | end | 844 | end |
| 743 | 845 | ||
| 744 | --@param | 846 | --@param |
| @@ -749,27 +851,97 @@ end | @@ -749,27 +851,97 @@ end | ||
| 749 | ]]-- | 851 | ]]-- |
| 750 | 852 | ||
| 751 | function Capsule:draw(roleId, full, cares) | 853 | function Capsule:draw(roleId, full, cares) |
| 752 | - if self:getGoodsAmount() == 0 then return 2 end | ||
| 753 | if self:getProperty("typ") == 1 then | 854 | if self:getProperty("typ") == 1 then |
| 754 | --是否报名 | 855 | --是否报名 |
| 755 | - if self:isRegister(roleId) == false then return 3 end | 856 | + if self:isRegister(roleId) == false then return 4 end |
| 756 | 857 | ||
| 757 | --关注的奖品的数量发生了变化 | 858 | --关注的奖品的数量发生了变化 |
| 758 | if cares then | 859 | if cares then |
| 759 | local change = self:confirmed(cares) | 860 | local change = self:confirmed(cares) |
| 760 | - if next(change) then return 4, change end | 861 | + if next(change) then return 5, change end |
| 761 | end | 862 | end |
| 762 | end | 863 | end |
| 763 | 864 | ||
| 764 | if full == 0 then | 865 | if full == 0 then |
| 765 | - return 5, self:drawByCount(roleId, 1) | 866 | + return 6, self:drawByCount(roleId, 1) |
| 766 | elseif full == 1 then | 867 | elseif full == 1 then |
| 767 | - return 5, self:drawByCount(roleId, 10) | 868 | + return 6, self:drawByCount(roleId, 10) |
| 768 | elseif full == 2 then | 869 | elseif full == 2 then |
| 769 | - return 5, self:drawAll(roleId) | 870 | + return 6, self:drawAll(roleId) |
| 770 | end | 871 | end |
| 771 | end | 872 | end |
| 772 | 873 | ||
| 874 | +function Capsule:pageRecord(up, idx) | ||
| 875 | + local record = self:getProperty("record") or {} | ||
| 876 | + if not next(record) then return nil end | ||
| 877 | + | ||
| 878 | + --默认取20条 | ||
| 879 | + idx = idx or #record | ||
| 880 | + up = up or 0 | ||
| 881 | + | ||
| 882 | + local count = 0 | ||
| 883 | + local tmpRecord = {} | ||
| 884 | + if up == 1 then | ||
| 885 | + --向上获取索引更大的 从上往下拉 | ||
| 886 | + count = math.min(#record - idx, 20) | ||
| 887 | + for i = idx, count do | ||
| 888 | + tmpRecord[i] = record[i] | ||
| 889 | + end | ||
| 890 | + else | ||
| 891 | + --向下获取索引更小的 从下往上拉 | ||
| 892 | + count = math.max(idx - 20, 0) | ||
| 893 | + for i = count, idx do | ||
| 894 | + tmpRecord[i] = record[i] | ||
| 895 | + end | ||
| 896 | + end | ||
| 897 | + | ||
| 898 | + return tmpRecord | ||
| 899 | +end | ||
| 900 | + | ||
| 901 | +--检查是否有未领取奖励的通知 | ||
| 902 | +function Capsule:getSpecialNotify(roleId) | ||
| 903 | + local specialsRecord = self:getProperty("specialsRecord") or {} | ||
| 904 | + local tmp = {} | ||
| 905 | + for _, goods in pairs(specialsRecord) do | ||
| 906 | + for _, good in ipairs(goods) do | ||
| 907 | + if good.roleId == roleId then | ||
| 908 | + if not good.nty or good.nty == 0 then | ||
| 909 | + tmp[good.good_id] = good | ||
| 910 | + end | ||
| 911 | + end | ||
| 912 | + end | ||
| 913 | + end | ||
| 914 | + self:setProperty("specialsRecord", specialsRecord) | ||
| 915 | + | ||
| 916 | + return tmp | ||
| 917 | +end | ||
| 918 | + | ||
| 919 | +function Capsule:clearSpecialNty(roleId, good_ids) | ||
| 920 | + local specialsRecord = self:getProperty("specialsRecord") or {} | ||
| 921 | + for _, goods in pairs(specialsRecord) do | ||
| 922 | + for _, good in ipairs(goods) do | ||
| 923 | + for _, good_id in ipairs(good_ids) do | ||
| 924 | + if good_id == good.good_id and good.roleId == roleId then | ||
| 925 | + good.nty = 1 | ||
| 926 | + end | ||
| 927 | + end | ||
| 928 | + end | ||
| 929 | + end | ||
| 930 | + self:setProperty("specialsRecord", specialsRecord) | ||
| 931 | +end | ||
| 932 | + | ||
| 933 | +function Capsule:getRoleProgress(roleId) | ||
| 934 | + local recordByRole = self:getProperty("recordByRole") or {} | ||
| 935 | + local roleRecord = recordByRole[roleId] or {} | ||
| 936 | + local amount = 0 | ||
| 937 | + for _, v in pairs(roleRecord) do | ||
| 938 | + v.calculated = v.calculated or 0 | ||
| 939 | + if v.calculated ~= v.amount then | ||
| 940 | + amount = amount + (v.amount - v.calculated) | ||
| 941 | + end | ||
| 942 | + end | ||
| 943 | + return amount | ||
| 944 | +end | ||
| 773 | 945 | ||
| 774 | function Capsule:data(roleId) | 946 | function Capsule:data(roleId) |
| 775 | return { | 947 | return { |
| @@ -780,12 +952,13 @@ function Capsule:data(roleId) | @@ -780,12 +952,13 @@ function Capsule:data(roleId) | ||
| 780 | coin = self:getProperty("coin"), | 952 | coin = self:getProperty("coin"), |
| 781 | onlineCount = self:getOnlineCount(), | 953 | onlineCount = self:getOnlineCount(), |
| 782 | playerStatus = self:getRegisterByRoleId(roleId), | 954 | playerStatus = self:getRegisterByRoleId(roleId), |
| 783 | - record = self:getProperty("record"), | 955 | + record = self:pageRecord() or {}, |
| 784 | rank = self:getProperty("rank"), | 956 | rank = self:getProperty("rank"), |
| 785 | goods = self:getProperty("goods"), | 957 | goods = self:getProperty("goods"), |
| 786 | specials = self:getProperty("specials"), | 958 | specials = self:getProperty("specials"), |
| 787 | incentive = self:getProperty("incentive"), | 959 | incentive = self:getProperty("incentive"), |
| 788 | specialsRecord= self:getProperty("specialsRecord"), | 960 | specialsRecord= self:getProperty("specialsRecord"), |
| 961 | + roleProgress = self:getRoleProgress(roleId), | ||
| 789 | } | 962 | } |
| 790 | end | 963 | end |
| 791 | 964 |
src/models/RoleCross.lua
| @@ -167,6 +167,7 @@ RoleCross.bind = function (Role) | @@ -167,6 +167,7 @@ RoleCross.bind = function (Role) | ||
| 167 | }) | 167 | }) |
| 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("WakeCGSum", {count = 1}) | ||
| 170 | self:checkTaskEnter("HeroTalent", {heroType = heroId, alv = aheadLevel}) | 171 | self:checkTaskEnter("HeroTalent", {heroType = heroId, alv = aheadLevel}) |
| 171 | 172 | ||
| 172 | end | 173 | end |
| @@ -210,10 +211,18 @@ RoleCross.bind = function (Role) | @@ -210,10 +211,18 @@ RoleCross.bind = function (Role) | ||
| 210 | return "成功" | 211 | return "成功" |
| 211 | end | 212 | end |
| 212 | 213 | ||
| 213 | - function Role:paySpecialReward(typ, reward) | ||
| 214 | - local tmpReward, _= self:award(reward, {log = {desc = "specialsReward", int1=self:getKey(), int2 = typ}}) | ||
| 215 | - SendPacket(actionCodes.Capsule_payReward, MsgPack.pack({reward=tmpReward})) | ||
| 216 | - return "reward" | 214 | + function Role:paySpecialReward(roleId, notify) |
| 215 | + if notify and next(notify) then | ||
| 216 | + local reward = {} | ||
| 217 | + for key, val in pairs(notify) do | ||
| 218 | + for id, count in pairs(val.award:toNumMap()) do | ||
| 219 | + reward[id] = (reward[id] or 0) + count | ||
| 220 | + end | ||
| 221 | + | ||
| 222 | + end | ||
| 223 | + self:award(reward, {log = {desc = "CapsuleReward", int1=roleId}}) | ||
| 224 | + SendPacket(actionCodes.Capsule_notifyChange, MsgPack.pack({special = notify})) | ||
| 225 | + end | ||
| 217 | end | 226 | end |
| 218 | 227 | ||
| 219 | end | 228 | end |
| @@ -376,9 +385,19 @@ function CMD.redPTag(roleId, tag, pms) | @@ -376,9 +385,19 @@ function CMD.redPTag(roleId, tag, pms) | ||
| 376 | end | 385 | end |
| 377 | end | 386 | end |
| 378 | 387 | ||
| 379 | -function CMD.paySpecialReward(roleId, typ, reward) | ||
| 380 | - local role = require("models.Role").new({key = string.format("%s",roleId), id = roleId}) | ||
| 381 | - role:award(reward, {log = {desc = "specialsReward", int1=self:getKey(), int2 = typ}}) | 388 | +function CMD.paySpecialReward(roleId, notify) |
| 389 | + if notify and next(notify) then | ||
| 390 | + local reward = {} | ||
| 391 | + for key, val in pairs(notify) do | ||
| 392 | + for id, count in pairs(val.award:toNumMap()) do | ||
| 393 | + reward[id] = (reward[id] or 0) + count | ||
| 394 | + end | ||
| 395 | + | ||
| 396 | + end | ||
| 397 | + local role = require("models.Role").new({key = string.format("%s",roleId), id = roleId}) | ||
| 398 | + role:award(reward, {log = {desc = "CapsuleReward", int1=roleId}}) | ||
| 399 | + end | ||
| 400 | + | ||
| 382 | end | 401 | end |
| 383 | 402 | ||
| 384 | RoleCross.handle = function(cmd, roleId, ...) | 403 | RoleCross.handle = function(cmd, roleId, ...) |
src/models/RoleLog.lua
| @@ -161,7 +161,8 @@ local ItemReason = { | @@ -161,7 +161,8 @@ local ItemReason = { | ||
| 161 | returner = 1410, -- 回归者奖励 | 161 | returner = 1410, -- 回归者奖励 |
| 162 | 162 | ||
| 163 | CapsuleReward = 1411, --扭蛋机奖励 | 163 | CapsuleReward = 1411, --扭蛋机奖励 |
| 164 | - specialsReward = 1412, --特殊赏 | 164 | + CapsuleConvert = 1412, --扭蛋机 消耗票 兑换 |
| 165 | + CapsuleCoinCost = 1413, --抽扭蛋机消耗 | ||
| 165 | } | 166 | } |
| 166 | 167 | ||
| 167 | 168 |
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) |
| @@ -566,6 +577,11 @@ function RolePlugin.bind(Role) | @@ -566,6 +577,11 @@ function RolePlugin.bind(Role) | ||
| 566 | return true | 577 | return true |
| 567 | end | 578 | end |
| 568 | 579 | ||
| 580 | + function Role:costJade(param) | ||
| 581 | + self:addItem(param) | ||
| 582 | + self:checkTaskEnter("CostJade", {count = - param.count}) | ||
| 583 | + end | ||
| 584 | + | ||
| 569 | function Role:increBy(field, val) | 585 | function Role:increBy(field, val) |
| 570 | local roleIncre = self:getProperty("roleIncre") | 586 | local roleIncre = self:getProperty("roleIncre") |
| 571 | local curId = roleIncre[field] or 0 | 587 | local curId = roleIncre[field] or 0 |
| @@ -592,6 +608,7 @@ function RolePlugin.bind(Role) | @@ -592,6 +608,7 @@ function RolePlugin.bind(Role) | ||
| 592 | } | 608 | } |
| 593 | if heroInfo.wakeL == 3 then | 609 | if heroInfo.wakeL == 3 then |
| 594 | self:checkTaskEnter("WakeCG", {heroType = heroType}) | 610 | self:checkTaskEnter("WakeCG", {heroType = heroType}) |
| 611 | + self:checkTaskEnter("WakeCGSum", {count = 1}) | ||
| 595 | end | 612 | end |
| 596 | local newHero = require("models.Hero").new(heroInfo) | 613 | local newHero = require("models.Hero").new(heroInfo) |
| 597 | newHero:create() | 614 | newHero:create() |
| @@ -2037,10 +2054,10 @@ function RolePlugin.bind(Role) | @@ -2037,10 +2054,10 @@ function RolePlugin.bind(Role) | ||
| 2037 | 2054 | ||
| 2038 | local SAVE_DATA_INTERVAL = 3 | 2055 | local SAVE_DATA_INTERVAL = 3 |
| 2039 | function Role:saveRoleData(now) | 2056 | function Role:saveRoleData(now) |
| 2040 | - if now - self._lastSaveTs < SAVE_DATA_INTERVAL then | 2057 | + if now and (now - self._lastSaveTs < SAVE_DATA_INTERVAL) then |
| 2041 | return | 2058 | return |
| 2042 | end | 2059 | end |
| 2043 | - self._lastSaveTs = now | 2060 | + self._lastSaveTs = now or skynet.timex() |
| 2044 | self:update() | 2061 | self:update() |
| 2045 | local objs = {self.activity, self.dailyData, self.dinerData, self.storeData, self.roleIncre} | 2062 | local objs = {self.activity, self.dailyData, self.dinerData, self.storeData, self.roleIncre} |
| 2046 | for _, info in ipairs(objs) do | 2063 | for _, info in ipairs(objs) do |
| @@ -2090,7 +2107,7 @@ function RolePlugin.bind(Role) | @@ -2090,7 +2107,7 @@ function RolePlugin.bind(Role) | ||
| 2090 | local emailSync = math.max(emailSync + 1, globalEmail - EMAIL_LIMIT + 1) | 2107 | local emailSync = math.max(emailSync + 1, globalEmail - EMAIL_LIMIT + 1) |
| 2091 | local redret = redisproxy:pipelining(function (red) | 2108 | local redret = redisproxy:pipelining(function (red) |
| 2092 | for id = emailSync, globalEmail do | 2109 | for id = emailSync, globalEmail do |
| 2093 | - red:hgetall(string.format("globalEmail:%s", id)) | 2110 | + red:hgetall(string.format("globalEmail:%s", id)) |
| 2094 | end | 2111 | end |
| 2095 | end) | 2112 | end) |
| 2096 | for _, data in ipairs(redret) do | 2113 | for _, data in ipairs(redret) do |
| @@ -2437,6 +2454,11 @@ function RolePlugin.bind(Role) | @@ -2437,6 +2454,11 @@ function RolePlugin.bind(Role) | ||
| 2437 | end | 2454 | end |
| 2438 | elseif rechargeData.shop == 3 then -- 礼包商店 | 2455 | elseif rechargeData.shop == 3 then -- 礼包商店 |
| 2439 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 2456 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) |
| 2457 | + | ||
| 2458 | + --增加购买记录 | ||
| 2459 | + local buyRecord = self.storeData:getProperty("buyR") or {} | ||
| 2460 | + buyRecord[id] = (buyRecord[id] or 0) + 1 | ||
| 2461 | + self.storeData:updateProperty({field = "buyR", value = buyRecord}) | ||
| 2440 | else | 2462 | else |
| 2441 | skynet.error("[recharge] invalid recharge shop type " .. id) | 2463 | skynet.error("[recharge] invalid recharge shop type " .. id) |
| 2442 | return 3 | 2464 | return 3 |
| @@ -3153,10 +3175,10 @@ function RolePlugin.bind(Role) | @@ -3153,10 +3175,10 @@ function RolePlugin.bind(Role) | ||
| 3153 | return itemRandomOccupy | 3175 | return itemRandomOccupy |
| 3154 | end | 3176 | end |
| 3155 | 3177 | ||
| 3156 | - function Role:getCapsuleList(coin) | 3178 | + function Role:getCapsuleList(id) |
| 3157 | local capsules = {} | 3179 | local capsules = {} |
| 3158 | for k, v in pairs(self.capsules) do | 3180 | for k, v in pairs(self.capsules) do |
| 3159 | - if v:getProperty("coin") == coin then | 3181 | + if v:getProperty("id") == id then |
| 3160 | local onlineCount= v:getOnlineCount() | 3182 | 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")} | 3183 | capsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")} |
| 3162 | end | 3184 | end |
| @@ -3165,17 +3187,20 @@ function RolePlugin.bind(Role) | @@ -3165,17 +3187,20 @@ function RolePlugin.bind(Role) | ||
| 3165 | end | 3187 | end |
| 3166 | 3188 | ||
| 3167 | function Role:drawCapsule(capsuleId, full, cares) | 3189 | function Role:drawCapsule(capsuleId, full, cares) |
| 3168 | - local capsule = self.capsules[capsuleId] or {} | ||
| 3169 | - if next(capsule) then | ||
| 3170 | - local roleId = self:getProperty("id") | ||
| 3171 | - return capsule:draw(roleId, full, cares) | ||
| 3172 | - end | ||
| 3173 | - return 1 | 3190 | + local capsule = self.capsules[capsuleId] |
| 3191 | + if not capsule then return nil end | ||
| 3192 | + | ||
| 3193 | + local roleId = self:getProperty("id") | ||
| 3194 | + local ret, drawReward = capsule:draw(roleId, full, cares) | ||
| 3195 | + drawReward["specials"] = nil | ||
| 3196 | + return ret, drawReward, capsule:data(roleId) | ||
| 3174 | end | 3197 | end |
| 3175 | 3198 | ||
| 3176 | - function Role:joinCapsule(capsuleId) | ||
| 3177 | - local capsule = self.capsules[capsuleId] or {} | ||
| 3178 | - return capsule:data() | 3199 | + function Role:joinCapsule(roleId, capsuleId) |
| 3200 | + local capsule = self.capsules[capsuleId] | ||
| 3201 | + if not capsule then return nil end | ||
| 3202 | + | ||
| 3203 | + return capsule:data(roleId) | ||
| 3179 | end | 3204 | end |
| 3180 | 3205 | ||
| 3181 | function Role:checkCapsule(now) | 3206 | function Role:checkCapsule(now) |
| @@ -3186,6 +3211,58 @@ function RolePlugin.bind(Role) | @@ -3186,6 +3211,58 @@ function RolePlugin.bind(Role) | ||
| 3186 | end | 3211 | end |
| 3187 | end | 3212 | end |
| 3188 | end | 3213 | end |
| 3214 | + | ||
| 3215 | + function Role:goodStock(capsuleId) | ||
| 3216 | + local capsule = self.capsules[capsuleId] | ||
| 3217 | + if not capsule then return 0 end | ||
| 3218 | + | ||
| 3219 | + return capsule:getGoodsAmount(), capsule:getProperty("token") | ||
| 3220 | + end | ||
| 3221 | + | ||
| 3222 | + function Role:getCapsuleData(roleId, capsuleId) | ||
| 3223 | + local capsule = self.capsules[capsuleId] | ||
| 3224 | + if not capsule then return nil end | ||
| 3225 | + | ||
| 3226 | + return capsule:data(roleId) | ||
| 3227 | + end | ||
| 3228 | + | ||
| 3229 | + function Role:resetCapsule() | ||
| 3230 | + local roleId = self:getProperty("id") | ||
| 3231 | + local res = redisproxy:smembers(CAPSULE_ID_ROLE:format(roleId)) or {} | ||
| 3232 | + for _, key in pairs(res) do | ||
| 3233 | + redisproxy:del(CAPSULE_ROLE:format(roleId, tonumber(key))) | ||
| 3234 | + redisproxy:srem(CAPSULE_ID_ROLE, key) | ||
| 3235 | + end | ||
| 3236 | + | ||
| 3237 | + for _, data in pairs(csvdb["ichibankuji_mainCsv"]) do | ||
| 3238 | + for _, val in pairs(data) do | ||
| 3239 | + if val.typ == 0 then | ||
| 3240 | + local key = val.id..val.room | ||
| 3241 | + if not self.capsules[key] then | ||
| 3242 | + local capsule = require("models.Capsule").new({ key = CAPSULE_ROLE:format(roleId, tonumber(key)), id= val.id, room = val.room, typ = 0, name=val.name}) | ||
| 3243 | + capsule:init() | ||
| 3244 | + capsule:create() | ||
| 3245 | + self.capsules[key] = capsule | ||
| 3246 | + redisproxy.sadd(CAPSULE_ID_ROLE:format(roleId), key) | ||
| 3247 | + end | ||
| 3248 | + end | ||
| 3249 | + end | ||
| 3250 | + end | ||
| 3251 | + end | ||
| 3252 | + | ||
| 3253 | + function Role:pageRecord(capsuleId, up, idx) | ||
| 3254 | + local capsule = self.capsules[capsuleId] | ||
| 3255 | + if not capsule then return nil end | ||
| 3256 | + | ||
| 3257 | + return capsule:pageRecord(up, idx) | ||
| 3258 | + end | ||
| 3259 | + | ||
| 3260 | + function Role:getSpecialNotify(roleId, capsuleId) | ||
| 3261 | + local capsule = self.capsules[capsuleId] | ||
| 3262 | + if not capsule then return nil end | ||
| 3263 | + | ||
| 3264 | + return capsule:getSpecialNotify(roleId) | ||
| 3265 | + end | ||
| 3189 | end | 3266 | end |
| 3190 | 3267 | ||
| 3191 | return RolePlugin | 3268 | return RolePlugin |
| 3192 | \ No newline at end of file | 3269 | \ 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,7 @@ local TaskType = { | @@ -112,6 +115,7 @@ 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, -- 消耗虹光玉 | ||
| 115 | 119 | ||
| 116 | --功能未实现 todo | 120 | --功能未实现 todo |
| 117 | AdvShop = 1002, -- 冒险商城 | 121 | AdvShop = 1002, -- 冒险商城 |
| @@ -271,6 +275,11 @@ local StoreListener = { | @@ -271,6 +275,11 @@ local StoreListener = { | ||
| 271 | [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, | 275 | [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, |
| 272 | [TaskType.DrawHeroLimitPack] = {{TriggerEventType.DrawHeroCnt, f("count")}}, | 276 | [TaskType.DrawHeroLimitPack] = {{TriggerEventType.DrawHeroCnt, f("count")}}, |
| 273 | [TaskType.Appoint] = {{TriggerEventType.Appoint, f("id")}}, | 277 | [TaskType.Appoint] = {{TriggerEventType.Appoint, f("id")}}, |
| 278 | + [TaskType.SignIn] = {{TriggerEventType.SignIn, 1}}, | ||
| 279 | + [TaskType.DrawHero] = {{TriggerEventType.DrawHero, f("count")}}, | ||
| 280 | + [TaskType.FoodSell]= {{TriggerEventType.FoodSell, f("count")}}, | ||
| 281 | + [TaskType.RuneUp] = {{TriggerEventType.RuneUp, 1}}, | ||
| 282 | + [TaskType.CostDiamond] = {{TriggerEventType.CostDiamond, f("count")}}, | ||
| 274 | } | 283 | } |
| 275 | } | 284 | } |
| 276 | 285 | ||
| @@ -318,6 +327,9 @@ local CalendaTaskListener = { | @@ -318,6 +327,9 @@ local CalendaTaskListener = { | ||
| 318 | [TaskType.AdvKill] = {{39, 1, f("chapterId")}}, | 327 | [TaskType.AdvKill] = {{39, 1, f("chapterId")}}, |
| 319 | [TaskType.ActBattlePass] = {{40, 3, f("chapterId")}}, | 328 | [TaskType.ActBattlePass] = {{40, 3, f("chapterId")}}, |
| 320 | [TaskType.AdvPass] = {{41, 3, f("id")}}, | 329 | [TaskType.AdvPass] = {{41, 3, f("id")}}, |
| 330 | + [TaskType.CostJade] = {{43, 1, f("count")}}, | ||
| 331 | + [TaskType.HeroStartSum] = {{44, 3}}, | ||
| 332 | + [TaskType.WakeCGSum] = {{45, 1, f("count")}}, | ||
| 321 | } | 333 | } |
| 322 | } | 334 | } |
| 323 | 335 | ||
| @@ -738,7 +750,7 @@ function RoleTask.bind(Role) | @@ -738,7 +750,7 @@ function RoleTask.bind(Role) | ||
| 738 | for _,uid in pairs(hero:getRunes()) do | 750 | for _,uid in pairs(hero:getRunes()) do |
| 739 | if uid > 0 then | 751 | if uid > 0 then |
| 740 | local runeData = self.runeBag[uid] | 752 | local runeData = self.runeBag[uid] |
| 741 | - if runeData then | 753 | + if runeData then |
| 742 | local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")] | 754 | local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")] |
| 743 | 755 | ||
| 744 | if csvData and cfg.condition2 <= csvData.rarity then | 756 | if csvData and cfg.condition2 <= csvData.rarity then |
| @@ -758,9 +770,9 @@ function RoleTask.bind(Role) | @@ -758,9 +770,9 @@ function RoleTask.bind(Role) | ||
| 758 | end | 770 | end |
| 759 | elseif cfg.type == 15 then -- 通关关卡 | 771 | elseif cfg.type == 15 then -- 通关关卡 |
| 760 | if (calTask[id] or 0) == 0 then | 772 | if (calTask[id] or 0) == 0 then |
| 761 | - if self:checkHangPass(cfg.condition2) then | 773 | + if self:checkHangPass(cfg.condition2) then |
| 762 | calTask[id] = 1 | 774 | calTask[id] = 1 |
| 763 | - end | 775 | + end |
| 764 | --local hangPass = self:getProperty("hangPass") | 776 | --local hangPass = self:getProperty("hangPass") |
| 765 | --local diff = math.floor(cfg.condition2 / 10000) | 777 | --local diff = math.floor(cfg.condition2 / 10000) |
| 766 | --if (hangPass[diff] or 0) >= cfg.condition2 then | 778 | --if (hangPass[diff] or 0) >= cfg.condition2 then |
| @@ -791,7 +803,7 @@ function RoleTask.bind(Role) | @@ -791,7 +803,7 @@ function RoleTask.bind(Role) | ||
| 791 | elseif cfg.type == 37 then -- 拾荒使用道具 | 803 | elseif cfg.type == 37 then -- 拾荒使用道具 |
| 792 | if cfg.condition2 == param1 then | 804 | if cfg.condition2 == param1 then |
| 793 | calTask[id] = (calTask[id] or 0) + (param2 or 0) | 805 | calTask[id] = (calTask[id] or 0) + (param2 or 0) |
| 794 | - end | 806 | + end |
| 795 | elseif cfg.type == 38 then -- 和指定建筑交互 | 807 | elseif cfg.type == 38 then -- 和指定建筑交互 |
| 796 | local condArr = cfg.condition3:toArray(true, "=") | 808 | local condArr = cfg.condition3:toArray(true, "=") |
| 797 | for i = 0, #condArr do | 809 | for i = 0, #condArr do |
| @@ -820,6 +832,14 @@ function RoleTask.bind(Role) | @@ -820,6 +832,14 @@ function RoleTask.bind(Role) | ||
| 820 | if cfg.condition2 <= param1 and param2 == 1 then | 832 | if cfg.condition2 <= param1 and param2 == 1 then |
| 821 | calTask[id] = (calTask[id] or 0) + 1 | 833 | calTask[id] = (calTask[id] or 0) + 1 |
| 822 | end | 834 | end |
| 835 | + elseif cfg.type == 44 then --玩家拥有拾荒者总星级达到xxx | ||
| 836 | + local count = 0 | ||
| 837 | + for _, hero in pairs(self.heros) do | ||
| 838 | + count = count + hero:getProperty("wakeL") | ||
| 839 | + end | ||
| 840 | + if (calTask[id] or 0) < count then | ||
| 841 | + calTask[id] = count | ||
| 842 | + end | ||
| 823 | end | 843 | end |
| 824 | end | 844 | end |
| 825 | end | 845 | end |
src/models/Store.lua
| @@ -55,6 +55,7 @@ Store.schema = { | @@ -55,6 +55,7 @@ Store.schema = { | ||
| 55 | 55 | ||
| 56 | dailyShop = {"table", {}}, | 56 | dailyShop = {"table", {}}, |
| 57 | weekShop = {"table", {}}, | 57 | weekShop = {"table", {}}, |
| 58 | + dayLimitInfo = {"table", {}}, -- {[id]={count=0, trigger=0}} | ||
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | function Store:updateProperty(params) | 61 | function Store:updateProperty(params) |
| @@ -80,6 +81,7 @@ function Store:onCrossDay() | @@ -80,6 +81,7 @@ function Store:onCrossDay() | ||
| 80 | --self:sendMonthCardEmail() | 81 | --self:sendMonthCardEmail() |
| 81 | self:deleteExpireLimitGoods() | 82 | self:deleteExpireLimitGoods() |
| 82 | --self:checkPaySignReward() | 83 | --self:checkPaySignReward() |
| 84 | + self:resetDayLimitPackTriggerCount() | ||
| 83 | 85 | ||
| 84 | --刷新商店 | 86 | --刷新商店 |
| 85 | self:flushDailyShop() | 87 | self:flushDailyShop() |
| @@ -219,6 +221,15 @@ function Store:deleteExpireLimitGoods() | @@ -219,6 +221,15 @@ function Store:deleteExpireLimitGoods() | ||
| 219 | self:updateProperty({field = "limitTPack", value = limitGoodsList, notNotify = true}) | 221 | self:updateProperty({field = "limitTPack", value = limitGoodsList, notNotify = true}) |
| 220 | end | 222 | end |
| 221 | 223 | ||
| 224 | +-- 每日充值循环限时礼包的触发次数 | ||
| 225 | +function Store:resetDayLimitPackTriggerCount() | ||
| 226 | + local dayLimitInfo = self:getProperty("dayLimitInfo") | ||
| 227 | + for k, v in pairs(dayLimitInfo) do | ||
| 228 | + v['trigger'] = nil | ||
| 229 | + end | ||
| 230 | + self:updateProperty({field = "dayLimitInfo", value = dayLimitInfo, notNotify = true}) | ||
| 231 | +end | ||
| 232 | + | ||
| 222 | -- 发送月卡邮件 | 233 | -- 发送月卡邮件 |
| 223 | function Store:sendMonthCardEmail() | 234 | function Store:sendMonthCardEmail() |
| 224 | local timeNow = skynet.timex() | 235 | local timeNow = skynet.timex() |
| @@ -474,7 +485,7 @@ function Store:onBuyCard(type, duration, id, actid) | @@ -474,7 +485,7 @@ function Store:onBuyCard(type, duration, id, actid) | ||
| 474 | self:updateProperty({field = "bpInfo", value = bpInfo}) | 485 | self:updateProperty({field = "bpInfo", value = bpInfo}) |
| 475 | elseif type == CardType.ActBattleCommandCard then | 486 | elseif type == CardType.ActBattleCommandCard then |
| 476 | if not self.owner.activity:isOpenById(actid, "ActShopGoods") then | 487 | if not self.owner.activity:isOpenById(actid, "ActShopGoods") then |
| 477 | - return | 488 | + return nil |
| 478 | end | 489 | end |
| 479 | local actCfg = csvdb["activity_ctrlCsv"][actid] | 490 | local actCfg = csvdb["activity_ctrlCsv"][actid] |
| 480 | if not actCfg then return end | 491 | if not actCfg then return end |
| @@ -486,6 +497,10 @@ function Store:onBuyCard(type, duration, id, actid) | @@ -486,6 +497,10 @@ function Store:onBuyCard(type, duration, id, actid) | ||
| 486 | end | 497 | end |
| 487 | self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0}) | 498 | self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0}) |
| 488 | self.owner.activity:updateActData("BattleCommand", actData) | 499 | self.owner.activity:updateActData("BattleCommand", actData) |
| 500 | + local rechargeData = csvdb["shop_rechargeCsv"][id] | ||
| 501 | + if rechargeData then | ||
| 502 | + return self.owner:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | ||
| 503 | + end | ||
| 489 | end | 504 | end |
| 490 | return nil, nil | 505 | return nil, nil |
| 491 | end | 506 | end |
| @@ -587,41 +602,40 @@ function Store:OnTriggerLimitTimePack(eventType, param) | @@ -587,41 +602,40 @@ function Store:OnTriggerLimitTimePack(eventType, param) | ||
| 587 | local limitPack = self:getProperty("limitTPack") | 602 | local limitPack = self:getProperty("limitTPack") |
| 588 | --local payRecord = self:getProperty("payR") | 603 | --local payRecord = self:getProperty("payR") |
| 589 | local timeNow = skynet.timex() | 604 | 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 | 605 | + |
| 618 | local config = nil | 606 | local config = nil |
| 619 | for id, cfg in pairs(csvdb["shop_packCsv"]) do | 607 | for id, cfg in pairs(csvdb["shop_packCsv"]) do |
| 620 | - if cfg.type == eventType and cfg.condition == param then | 608 | + if cfg.type == eventType and (cfg.condition == param or cfg.isLoop ~= 0) then |
| 621 | config = cfg | 609 | config = cfg |
| 610 | + break | ||
| 622 | end | 611 | end |
| 623 | end | 612 | end |
| 624 | if config ~= nil then | 613 | if config ~= nil then |
| 614 | + -- 每日循环弹窗 | ||
| 615 | + local typeMap = {[TriggerEventType.DrawHero] = 1, [TriggerEventType.FoodSell] = 1, [TriggerEventType.RuneUp] = 1, [TriggerEventType.CostDiamond] = 1} | ||
| 616 | + if typeMap[eventType] then | ||
| 617 | + local dayInfo = self:getProperty("dayLimitInfo") | ||
| 618 | + local info = dayInfo[eventType] or {} | ||
| 619 | + local count = (info["count"] or 0) + param | ||
| 620 | + local triggerCount = info["trigger"] or 0 | ||
| 621 | + local flag = nil | ||
| 622 | + if count >= config.condition then | ||
| 623 | + if triggerCount < config.triggerLimit then | ||
| 624 | + info["trigger"] = triggerCount + 1 | ||
| 625 | + info["count"] = 0 | ||
| 626 | + flag = true | ||
| 627 | + else | ||
| 628 | + info["count"] = config.condition - 1 | ||
| 629 | + end | ||
| 630 | + else | ||
| 631 | + info["count"] = count | ||
| 632 | + end | ||
| 633 | + dayInfo[eventType] = info | ||
| 634 | + self:updateProperty({field = "dayLimitInfo", value = dayInfo}) | ||
| 635 | + if not flag then | ||
| 636 | + return | ||
| 637 | + end | ||
| 638 | + end | ||
| 625 | local rechargeCfg = csvdb["shop_normalCsv"][config.packId] | 639 | local rechargeCfg = csvdb["shop_normalCsv"][config.packId] |
| 626 | if rechargeCfg then | 640 | if rechargeCfg then |
| 627 | limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id} | 641 | limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id} |
| @@ -629,14 +643,21 @@ function Store:OnTriggerLimitTimePack(eventType, param) | @@ -629,14 +643,21 @@ function Store:OnTriggerLimitTimePack(eventType, param) | ||
| 629 | gift_id = rechargeCfg.id, --礼包ID | 643 | gift_id = rechargeCfg.id, --礼包ID |
| 630 | gift_name = rechargeCfg.descId, --礼包名称 | 644 | gift_name = rechargeCfg.descId, --礼包名称 |
| 631 | }) | 645 | }) |
| 632 | - -- 每日抽卡限时礼包 触发重置 | ||
| 633 | - if eventType == TriggerEventType.DrawHeroCnt then | ||
| 634 | - local payR = self:getProperty("buyR") | 646 | + if config.isLoop ~= 0 then |
| 647 | + local payR = self:getProperty("payR") | ||
| 635 | if payR[rechargeCfg.id] then | 648 | if payR[rechargeCfg.id] then |
| 636 | payR[rechargeCfg.id] = nil | 649 | payR[rechargeCfg.id] = nil |
| 637 | - self:updateProperty({field = "buyR", value = payR}) | 650 | + self:updateProperty({field = "payR", value = payR}) |
| 638 | end | 651 | end |
| 639 | end | 652 | end |
| 653 | + -- 每日抽卡限时礼包 触发重置 | ||
| 654 | + --if eventType == TriggerEventType.DrawHeroCnt then | ||
| 655 | + -- local payR = self:getProperty("buyR") | ||
| 656 | + -- if payR[rechargeCfg.id] then | ||
| 657 | + -- payR[rechargeCfg.id] = nil | ||
| 658 | + -- self:updateProperty({field = "buyR", value = payR}) | ||
| 659 | + -- end | ||
| 660 | + --end | ||
| 640 | self:updateProperty({field = "limitTPack", value = limitPack}) | 661 | self:updateProperty({field = "limitTPack", value = limitPack}) |
| 641 | end | 662 | end |
| 642 | end | 663 | end |
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
| @@ -16,27 +16,44 @@ NotifyChangeType = { | @@ -16,27 +16,44 @@ NotifyChangeType = { | ||
| 16 | EXIT = 2, | 16 | EXIT = 2, |
| 17 | DRAW = 3, | 17 | DRAW = 3, |
| 18 | SPECIAL = 4, | 18 | SPECIAL = 4, |
| 19 | - INCENTIVE = 5, | 19 | +} |
| 20 | + | ||
| 21 | +skynet.register_protocol { | ||
| 22 | + name = "role", | ||
| 23 | + id = 101, | ||
| 24 | + pack = skynet.pack, | ||
| 25 | + unpack = skynet.unpack, | ||
| 20 | } | 26 | } |
| 21 | 27 | ||
| 22 | local function rpcRole(roleId, funcName, ...) | 28 | local function rpcRole(roleId, funcName, ...) |
| 23 | local fields = ... | 29 | local fields = ... |
| 24 | local agent = datacenter.get("agent", roleId) | 30 | local agent = datacenter.get("agent", roleId) |
| 25 | - local roleCross = require("models.RoleCross") | ||
| 26 | - if funcName == "getProperties" then | ||
| 27 | - return roleCross.handle(funcName, roleId, fields) | 31 | + if agent and agent.serv then |
| 32 | + if funcName == "getProperties" then | ||
| 33 | + return true, skynet.call(agent.serv, "role", funcName, fields) | ||
| 34 | + else | ||
| 35 | + return true, skynet.call(agent.serv, "role", funcName, ...) | ||
| 36 | + end | ||
| 28 | else | 37 | else |
| 29 | - return roleCross.handle(funcName, roleId, ...) | 38 | + local roleCross = require("models.RoleCross") |
| 39 | + if funcName == "getProperties" then | ||
| 40 | + return false, roleCross.handle(funcName, roleId, fields) | ||
| 41 | + else | ||
| 42 | + return false, roleCross.handle(funcName, roleId, ...) | ||
| 43 | + end | ||
| 30 | end | 44 | end |
| 31 | end | 45 | end |
| 32 | 46 | ||
| 33 | function getNameByRoleId(roleId) | 47 | function getNameByRoleId(roleId) |
| 34 | - return rpcRole(roleId, "getProperty", "name") | 48 | + local status, name = rpcRole(roleId, "getProperty", "name") |
| 49 | + return name | ||
| 35 | 50 | ||
| 36 | end | 51 | end |
| 37 | 52 | ||
| 38 | function broadCastCapsule(roleId, capsuleId, broadInfo) | 53 | function broadCastCapsule(roleId, capsuleId, broadInfo) |
| 39 | - local capsule = capsules[capsuleId] or {} | 54 | + local capsule = capsules[capsuleId] |
| 55 | + if not capsule then print("not capsule :" .. capsuleId) return end | ||
| 56 | + | ||
| 40 | local register = capsule:getProperty("register") or {} | 57 | local register = capsule:getProperty("register") or {} |
| 41 | if next(capsule) then | 58 | if next(capsule) then |
| 42 | for id, _ in pairs(register) do | 59 | for id, _ in pairs(register) do |
| @@ -47,25 +64,39 @@ function broadCastCapsule(roleId, capsuleId, broadInfo) | @@ -47,25 +64,39 @@ function broadCastCapsule(roleId, capsuleId, broadInfo) | ||
| 47 | end | 64 | end |
| 48 | end | 65 | end |
| 49 | 66 | ||
| 50 | -local function getCapsuleId(id, room) | ||
| 51 | - return string.format("%d%d", id, room) | ||
| 52 | -end | 67 | +function broadCastSpecial(roleId, capsuleId, broadInfo) |
| 68 | + if not broadInfo or not next(broadInfo) then return end | ||
| 69 | + local capsule = capsules[capsuleId] | ||
| 70 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return end | ||
| 53 | 71 | ||
| 72 | + local register = capsule:getProperty("register") or {} | ||
| 73 | + for id, _ in pairs(register) do | ||
| 74 | + if id ~= roleId then | ||
| 75 | + if broadInfo[id] then | ||
| 76 | + rpcRole(id, "paySpecialReward", id, broadInfo[id]) | ||
| 77 | + end | ||
| 78 | + end | ||
| 79 | + end | ||
| 80 | +end | ||
| 54 | 81 | ||
| 55 | local function add(roleId, capsuleId) | 82 | local function add(roleId, capsuleId) |
| 56 | - local capsule = capsules[capsuleId] or {} | 83 | + local capsule = capsules[capsuleId] |
| 84 | + if not capsule then skynet.error("add not capsule: " .. capsuleId) return end | ||
| 57 | if next(capsule) then | 85 | if next(capsule) then |
| 58 | capsule:join(roleId) | 86 | capsule:join(roleId) |
| 59 | - broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.JOIN, roleId = roleId}) | 87 | + broadCastCapsule(roleId, capsuleId, {notifyType= NotifyChangeType.JOIN, roleId = roleId}) |
| 60 | return capsule:data(roleId) | 88 | return capsule:data(roleId) |
| 61 | end | 89 | end |
| 62 | print("id 不存在: ".. capsuleId) | 90 | print("id 不存在: ".. capsuleId) |
| 63 | return nil | 91 | return nil |
| 64 | end | 92 | end |
| 65 | 93 | ||
| 66 | -local function capsuleRefreshing() | 94 | +local function capsuleRefreshing(now) |
| 67 | for _, v in pairs(capsules) do | 95 | for _, v in pairs(capsules) do |
| 68 | - if v:refreshing() then | 96 | + if v:refreshing(now) then |
| 97 | + print("刷新机器looooook....") | ||
| 98 | + print(v:getProperty("id")) | ||
| 99 | + print(v:getProperty("room")) | ||
| 69 | v:init() | 100 | v:init() |
| 70 | v:create() | 101 | v:create() |
| 71 | end | 102 | end |
| @@ -74,8 +105,31 @@ end | @@ -74,8 +105,31 @@ end | ||
| 74 | 105 | ||
| 75 | --扭蛋机刷新 | 106 | --扭蛋机刷新 |
| 76 | local function check_capsules() | 107 | local function check_capsules() |
| 77 | - pcall(capsuleRefreshing) | ||
| 78 | - skynet.timeout(60, check_capsules) | 108 | + local now = skynet.timex() |
| 109 | + pcall(capsuleRefreshing, now) | ||
| 110 | + skynet.timeout(100, check_capsules) | ||
| 111 | +end | ||
| 112 | + | ||
| 113 | +function CMD.reset() | ||
| 114 | + local now = skynet.timex() | ||
| 115 | + local res = redisproxy:smembers(CAPSULE_INFO) or {} | ||
| 116 | + for _, key in pairs(res) do | ||
| 117 | + redisproxy:del(CAPSULE_PUBLIC:format(key)) | ||
| 118 | + redisproxy:srem(CAPSULE_INFO, key) | ||
| 119 | + end | ||
| 120 | + | ||
| 121 | + for _, data in pairs(csvdb["ichibankuji_mainCsv"]) do | ||
| 122 | + for _, val in ipairs(data) do | ||
| 123 | + if val.type == 1 then | ||
| 124 | + local key = val.id..val.room | ||
| 125 | + local capsule = require("models.Capsule").new({ key = CAPSULE_PUBLIC:format(key), id= val.id, room = val.room, typ = 1, name=val.name}) | ||
| 126 | + capsule:init() | ||
| 127 | + capsule:create() | ||
| 128 | + capsules[key] = capsule | ||
| 129 | + redisproxy:sadd(CAPSULE_INFO, key) | ||
| 130 | + end | ||
| 131 | + end | ||
| 132 | + end | ||
| 79 | end | 133 | end |
| 80 | 134 | ||
| 81 | function CMD.start() | 135 | function CMD.start() |
| @@ -101,11 +155,14 @@ function CMD.start() | @@ -101,11 +155,14 @@ function CMD.start() | ||
| 101 | if val.type == 1 then | 155 | if val.type == 1 then |
| 102 | local key = val.id..val.room | 156 | local key = val.id..val.room |
| 103 | if not capsules[key] then | 157 | if not capsules[key] then |
| 104 | - local capsule = require("models.Capsule").new({ key = CAPSULE_PUBLIC:format(key), id= val.id, room = val.room, typ = 1, name=val.name}) | ||
| 105 | - capsule:init() | ||
| 106 | - capsule:create() | ||
| 107 | - capsules[key] = capsule | ||
| 108 | - redisproxy:sadd(CAPSULE_INFO, key) | 158 | + if now < val.hide_time then |
| 159 | + local capsule = require("models.Capsule").new({ key = CAPSULE_PUBLIC:format(key), id= val.id, room = val.room, typ = 1, name=val.name}) | ||
| 160 | + capsule:init() | ||
| 161 | + capsule:create() | ||
| 162 | + | ||
| 163 | + capsules[key] = capsule | ||
| 164 | + redisproxy:sadd(CAPSULE_INFO, key) | ||
| 165 | + end | ||
| 109 | end | 166 | end |
| 110 | end | 167 | end |
| 111 | end | 168 | end |
| @@ -114,10 +171,10 @@ function CMD.start() | @@ -114,10 +171,10 @@ function CMD.start() | ||
| 114 | check_capsules() | 171 | check_capsules() |
| 115 | end | 172 | end |
| 116 | 173 | ||
| 117 | -function CMD.list(coin) | 174 | +function CMD.list(id) |
| 118 | local tmpCapsules = {} | 175 | local tmpCapsules = {} |
| 119 | for k, v in pairs(capsules) do | 176 | for k, v in pairs(capsules) do |
| 120 | - if v:getProperty("coin") == coin then | 177 | + if v:getProperty("id") == id then |
| 121 | local onlineCount= v:getOnlineCount() | 178 | local onlineCount= v:getOnlineCount() |
| 122 | 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")} |
| 123 | end | 180 | end |
| @@ -135,39 +192,74 @@ end | @@ -135,39 +192,74 @@ end | ||
| 135 | 192 | ||
| 136 | function CMD.exit(roleId, capsuleId) | 193 | function CMD.exit(roleId, capsuleId) |
| 137 | if capsuleId then | 194 | if capsuleId then |
| 138 | - local capsule = capsules[capsuleId] or {} | ||
| 139 | - if next(capsule) then | ||
| 140 | - capsule:exit(roleId) | ||
| 141 | - broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.EXIT, roleId = roleId}) | ||
| 142 | - end | 195 | + local capsule = capsules[capsuleId] |
| 196 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return end | ||
| 197 | + | ||
| 198 | + capsule:exit(roleId) | ||
| 199 | + broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.EXIT, roleId = roleId}) | ||
| 143 | else | 200 | else |
| 144 | - for _, capsule in pairs(capsules) do | 201 | + for id, capsule in pairs(capsules) do |
| 145 | if next(capsule) then | 202 | if next(capsule) then |
| 146 | capsule:exit(roleId) | 203 | capsule:exit(roleId) |
| 147 | - broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.EXIT, roleId = roleId}) | 204 | + broadCastCapsule(roleId, id, {notifyType = NotifyChangeType.EXIT, roleId = roleId}) |
| 148 | end | 205 | end |
| 149 | end | 206 | end |
| 150 | end | 207 | end |
| 151 | end | 208 | end |
| 152 | 209 | ||
| 153 | -function CMD.draw_capsule(roleId, capsuleId, full, cares) | ||
| 154 | - local capsule = capsules[capsuleId] or {} | ||
| 155 | - if next(capsule) then | ||
| 156 | - local ret, reward, rewardByGoods, notify = capsule:draw(roleId, full, cares) | ||
| 157 | - --if ret > 4 then | ||
| 158 | - -- broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.DRAW, roleId = roleId, notify = notify}) | ||
| 159 | - --end | ||
| 160 | - return ret, reward, rewardByGoods, capsule:data(roleId) | 210 | +function CMD.draw_capsule(roleId, capsuleId, full, drawsNum, cares) |
| 211 | + local capsule = capsules[capsuleId] | ||
| 212 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return 2 end | ||
| 213 | + | ||
| 214 | + local ret, drawReward = capsule:draw(roleId, full, drawsNum, cares) | ||
| 215 | + if ret > 5 then | ||
| 216 | + --broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.DRAW, notify = notify}) | ||
| 217 | + broadCastSpecial(roleId, capsuleId, drawReward["specials"]) | ||
| 161 | end | 218 | end |
| 162 | - return 1 | 219 | + drawReward["specials"] = nil |
| 220 | + return ret, drawReward, capsule:data(roleId) | ||
| 163 | end | 221 | end |
| 164 | 222 | ||
| 165 | function CMD.register(roleId, capsuleId) | 223 | function CMD.register(roleId, capsuleId) |
| 166 | - local capsule = capsules[capsuleId] or {} | ||
| 167 | - if next(capsule) then | ||
| 168 | - return capsule:register(roleId) | ||
| 169 | - end | ||
| 170 | - return nil | 224 | + local capsule = capsules[capsuleId] |
| 225 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end | ||
| 226 | + | ||
| 227 | + return capsule:register(roleId) | ||
| 228 | +end | ||
| 229 | + | ||
| 230 | +function CMD.goods_stock(capsuleId) | ||
| 231 | + local capsule = capsules[capsuleId] | ||
| 232 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return 0 end | ||
| 233 | + | ||
| 234 | + return capsule:getGoodsAmount(), capsule:getProperty("token") | ||
| 235 | +end | ||
| 236 | + | ||
| 237 | +function CMD.capsule_data(roleId, capsuleId) | ||
| 238 | + local capsule = capsules[capsuleId] | ||
| 239 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end | ||
| 240 | + | ||
| 241 | + return capsule:data(roleId) | ||
| 242 | +end | ||
| 243 | + | ||
| 244 | +function CMD.page_record(capsuleId, up, idx) | ||
| 245 | + local capsule = capsules[capsuleId] | ||
| 246 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end | ||
| 247 | + | ||
| 248 | + return capsule:pageRecord(up, idx) | ||
| 249 | +end | ||
| 250 | + | ||
| 251 | +function CMD.get_special_nty(roleId, capsuleId) | ||
| 252 | + local capsule = capsules[capsuleId] | ||
| 253 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end | ||
| 254 | + | ||
| 255 | + return capsule:getSpecialNotify(roleId) | ||
| 256 | +end | ||
| 257 | + | ||
| 258 | +function CMD.clear_special_nty(roleId, capsuleId, good_ids) | ||
| 259 | + local capsule = capsules[capsuleId] | ||
| 260 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end | ||
| 261 | + | ||
| 262 | + return capsule:clearSpecialNty(roleId, good_ids) | ||
| 171 | end | 263 | end |
| 172 | 264 | ||
| 173 | skynet.start(function() | 265 | skynet.start(function() |
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 |