Commit 40745a5b3dae152c348cc9c3802d62ff9013063b
Merge branch 'cn/develop' into cn/player
Showing
26 changed files
with
670 additions
and
146 deletions
 
Show diff stats
src/ProtocolCode.lua
| @@ -8,6 +8,7 @@ actionCodes = { | @@ -8,6 +8,7 @@ actionCodes = { | ||
| 8 | Sys_maintainNotice = 6, | 8 | Sys_maintainNotice = 6, | 
| 9 | Sys_customNotice = 7, | 9 | Sys_customNotice = 7, | 
| 10 | Sys_checkQueue = 8, | 10 | Sys_checkQueue = 8, | 
| 11 | + Sys_gameNotice = 9, | ||
| 11 | 12 | ||
| 12 | Gm_clientRequest = 20, | 13 | Gm_clientRequest = 20, | 
| 13 | Gm_receiveResponse = 21, | 14 | Gm_receiveResponse = 21, | 
| @@ -222,6 +223,7 @@ actionCodes = { | @@ -222,6 +223,7 @@ actionCodes = { | ||
| 222 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 | 223 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 | 
| 223 | Store_getExploreCommandRewardRpc = 563, --探索指令 | 224 | Store_getExploreCommandRewardRpc = 563, --探索指令 | 
| 224 | Store_getTotalRechargeAwardRpc = 564, -- 累计充值 | 225 | Store_getTotalRechargeAwardRpc = 564, -- 累计充值 | 
| 226 | + Store_monthCardRewardRpc = 565, --每日月卡+特刊奖励 | ||
| 225 | 227 | ||
| 226 | Store_biliCloudRechargeRpc = 596, | 228 | Store_biliCloudRechargeRpc = 596, | 
| 227 | Store_biliAndroidRechargeRpc = 597, | 229 | Store_biliAndroidRechargeRpc = 597, | 
| @@ -259,6 +261,7 @@ actionCodes = { | @@ -259,6 +261,7 @@ actionCodes = { | ||
| 259 | Activity_buyBattleCommandLvlRpc = 672, | 261 | Activity_buyBattleCommandLvlRpc = 672, | 
| 260 | Activity_returnerTaskRpc = 673, | 262 | Activity_returnerTaskRpc = 673, | 
| 261 | Activity_actNewUserTaskRpc = 674, | 263 | Activity_actNewUserTaskRpc = 674, | 
| 264 | + Activity_buyBattleTicketRpc = 675, | ||
| 262 | 265 | ||
| 263 | Radio_startQuestRpc = 700, | 266 | Radio_startQuestRpc = 700, | 
| 264 | Radio_finishQuestRpc = 701, | 267 | Radio_finishQuestRpc = 701, | 
src/actions/ActivityAction.lua
| @@ -119,7 +119,7 @@ end | @@ -119,7 +119,7 @@ end | ||
| 119 | function _M.signRpc(agent, data) | 119 | function _M.signRpc(agent, data) | 
| 120 | local role = agent.role | 120 | local role = agent.role | 
| 121 | 121 | ||
| 122 | - local serverT = skynet.timex() | 122 | + local serverT = skynet.timex() - RESET_TIME * 3600 | 
| 123 | local tm = os.date("*t", serverT) | 123 | local tm = os.date("*t", serverT) | 
| 124 | 124 | ||
| 125 | local curDay = tm.day | 125 | local curDay = tm.day | 
| @@ -588,24 +588,23 @@ function _M.startBattleRpc(agent, data) | @@ -588,24 +588,23 @@ function _M.startBattleRpc(agent, data) | ||
| 588 | role.activity:getBattleTicket(actid) | 588 | role.activity:getBattleTicket(actid) | 
| 589 | num = battleCfg.type:toArray(true, "=")[3] | 589 | num = battleCfg.type:toArray(true, "=")[3] | 
| 590 | if count and count > 0 then | 590 | if count and count > 0 then | 
| 591 | - if battleCfg.rank == 0 then | ||
| 592 | - return 7 | 591 | + if battleCfg.rank ~= 0 then | 
| 592 | + local bi = actData[id] | ||
| 593 | + if not bi then return 8 end | ||
| 594 | + local star = bi["star"] or 0 | ||
| 595 | + local maxP = bi["maxP"] or 0 | ||
| 596 | + -- 世界boss | ||
| 597 | + if battleCfg.worldBoss_award ~= 0 then | ||
| 598 | + if maxP < 1 then | ||
| 599 | + return 9 | ||
| 600 | + end | ||
| 601 | + else | ||
| 602 | + if star < 1 then | ||
| 603 | + return 9 | ||
| 604 | + end | ||
| 605 | + end | ||
| 593 | end | 606 | end | 
| 594 | - local bi = actData[id] | ||
| 595 | - if not bi then return 8 end | ||
| 596 | - local star = bi["star"] or 0 | ||
| 597 | - local maxP = bi["maxP"] or 0 | ||
| 598 | - -- 世界boss | ||
| 599 | - if battleCfg.worldBoss_award ~= 0 then | ||
| 600 | - if maxP < 1 then | ||
| 601 | - return 9 | ||
| 602 | - end | ||
| 603 | - else | ||
| 604 | - if star < 1 then | ||
| 605 | - return 9 | ||
| 606 | - end | ||
| 607 | - end | ||
| 608 | - num = num * count | 607 | + num = num * count | 
| 609 | end | 608 | end | 
| 610 | if ticket < num then | 609 | if ticket < num then | 
| 611 | return 6 | 610 | return 6 | 
| @@ -627,40 +626,44 @@ function _M.startBattleRpc(agent, data) | @@ -627,40 +626,44 @@ function _M.startBattleRpc(agent, data) | ||
| 627 | if count <= 0 then | 626 | if count <= 0 then | 
| 628 | return | 627 | return | 
| 629 | end | 628 | end | 
| 630 | - if battleCfg.rank == 0 then | ||
| 631 | - return 7 | ||
| 632 | - end | 629 | + | 
| 633 | local bi = actData[id] | 630 | local bi = actData[id] | 
| 634 | local star = bi["star"] or 0 | 631 | local star = bi["star"] or 0 | 
| 635 | local award = battleCfg.item_clear:toNumMap() | 632 | local award = battleCfg.item_clear:toNumMap() | 
| 636 | - if getStarCount(battleCfg, star) == 3 then | ||
| 637 | - local aw = battleCfg.perfect_reward:toNumMap() | ||
| 638 | - for k, v in pairs(aw) do | ||
| 639 | - award[k] = (award[k] or 0) + v | ||
| 640 | - end | ||
| 641 | - end | 633 | + | 
| 634 | + if battleCfg.rank ~= 0 then | ||
| 635 | + if getStarCount(battleCfg, star) == 3 then | ||
| 636 | + local aw = battleCfg.perfect_reward:toNumMap() | ||
| 637 | + for k, v in pairs(aw) do | ||
| 638 | + award[k] = (award[k] or 0) + v | ||
| 639 | + end | ||
| 640 | + end | ||
| 641 | + end | ||
| 642 | for k, v in pairs(award) do | 642 | for k, v in pairs(award) do | 
| 643 | award[k] = v * count | 643 | award[k] = v * count | 
| 644 | end | 644 | end | 
| 645 | local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) | 645 | 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))) | 646 | SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change))) | 
| 647 | + changeFlag = true | ||
| 648 | + actData["ticket"] = ticket - num | ||
| 647 | 649 | ||
| 648 | - if battleCfg.worldBoss_award ~= 0 and (bi["maxP"] or 0) > 0 then | ||
| 649 | - bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] * count | 650 | + if battleCfg.rank ~= 0 then | 
| 651 | + if battleCfg.worldBoss_award ~= 0 and (bi["maxP"] or 0) > 0 then | ||
| 652 | + bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] * count | ||
| 653 | + end | ||
| 654 | + | ||
| 655 | + bi["sum"] = bi["sum"] + bi["top"] * count | ||
| 656 | + actData[id] = bi | ||
| 657 | + | ||
| 658 | + local rankVal = 0 | ||
| 659 | + if battleCfg.rank == 1 then | ||
| 660 | + rankVal = bi["sum"] | ||
| 661 | + elseif battleCfg.rank == 2 then | ||
| 662 | + rankVal = bi["top"] | ||
| 663 | + end | ||
| 664 | + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | ||
| 650 | end | 665 | end | 
| 651 | 666 | ||
| 652 | - bi["sum"] = bi["sum"] + bi["top"] * count | ||
| 653 | - actData["ticket"] = ticket - num | ||
| 654 | - actData[id] = bi | ||
| 655 | - changeFlag = true | ||
| 656 | - | ||
| 657 | - local rankVal = 0 | ||
| 658 | - if battleCfg.rank == 1 then | ||
| 659 | - rankVal = bi["sum"] | ||
| 660 | - elseif battleCfg.rank == 2 then | ||
| 661 | - rankVal = bi["top"] | ||
| 662 | - end | ||
| 663 | - role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | ||
| 664 | end | 667 | end | 
| 665 | if changeFlag then | 668 | if changeFlag then | 
| 666 | role.activity:updateActData("ChallengeLevel", actData) | 669 | role.activity:updateActData("ChallengeLevel", actData) | 
| @@ -1434,7 +1437,7 @@ function _M.returnerTaskRpc(agent, data) | @@ -1434,7 +1437,7 @@ function _M.returnerTaskRpc(agent, data) | ||
| 1434 | local TaskCsv = csvdb["activity_taskCsv"][76] or {} | 1437 | local TaskCsv = csvdb["activity_taskCsv"][76] or {} | 
| 1435 | local taskData = TaskCsv[taskId] | 1438 | local taskData = TaskCsv[taskId] | 
| 1436 | if not taskData then return 2 end | 1439 | if not taskData then return 2 end | 
| 1437 | - if curAllDay < taskData.day then return 2 end | 1440 | + if curAllDay < taskData.day then return 5 end | 
| 1438 | 1441 | ||
| 1439 | local status = returner.status or {} | 1442 | local status = returner.status or {} | 
| 1440 | if status[taskId] then return 3 end | 1443 | if status[taskId] then return 3 end | 
| @@ -1466,4 +1469,30 @@ function _M.returnerTaskRpc(agent, data) | @@ -1466,4 +1469,30 @@ function _M.returnerTaskRpc(agent, data) | ||
| 1466 | return true | 1469 | return true | 
| 1467 | end | 1470 | end | 
| 1468 | 1471 | ||
| 1472 | +function _M.buyBattleTicketRpc(agent, data) | ||
| 1473 | + local role = agent.role | ||
| 1474 | + local msg = MsgPack.unpack(data) | ||
| 1475 | + local actid = msg.actid | ||
| 1476 | + local count = msg.count | ||
| 1477 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | ||
| 1478 | + role.activity:getBattleTicket(actid) | ||
| 1479 | + local actData = role.activity:getActData("ChallengeLevel") or {} | ||
| 1480 | + local battleInfo = actData[id] or {} | ||
| 1481 | + --["activity_scrofa_tickets"] = { 10, 20, 30, 40, 50, 100, 150, 200, 200, 200 } | ||
| 1482 | + local limit = #(globalCsv.activity_scrofa_tickets) | ||
| 1483 | + local curCount = actData["buyC"] or 0 | ||
| 1484 | + if count <= 0 or curCount + count > limit then | ||
| 1485 | + return 2 | ||
| 1486 | + end | ||
| 1487 | + local cost = globalCsv.activity_scrofa_tickets[curCount + 1] | ||
| 1488 | + 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}}) | ||
| 1490 | + actData["ticket"] = (actData["ticket"] or 0) + 1 | ||
| 1491 | + actData["buyC"] = curCount + count | ||
| 1492 | + | ||
| 1493 | + role.activity:updateActData("ChallengeLevel", actData) | ||
| 1494 | + SendPacket(actionCodes.Activity_buyBattleTicketRpc, "") | ||
| 1495 | + return true | ||
| 1496 | +end | ||
| 1497 | + | ||
| 1469 | return _M | 1498 | return _M | 
src/actions/AdvAction.lua
| @@ -301,18 +301,16 @@ function _M.startHangRpc(agent, data) | @@ -301,18 +301,16 @@ function _M.startHangRpc(agent, data) | ||
| 301 | 301 | ||
| 302 | local player = {} | 302 | local player = {} | 
| 303 | local attrs = role:getTeamBattleInfo(format).heros | 303 | local attrs = role:getTeamBattleInfo(format).heros | 
| 304 | - for attrName, _ in pairs(AdvAttsEnum) do | ||
| 305 | - for _, hero in pairs(attrs) do | ||
| 306 | - player[attrName] = (player[attrName] or 0) + hero[attrName] | 304 | + for _, hero in pairs(attrs) do | 
| 305 | + --根据系数计算拾荒属性 | ||
| 306 | + role:checkPlayerAttr(hero) | ||
| 307 | + | ||
| 308 | + for attrName, _ in pairs(AdvAttsEnum) do | ||
| 309 | + player[attrName] = (player[attrName] or 0) + hero[attrName] | ||
| 307 | end | 310 | end | 
| 308 | - player[attrName] = player[attrName] * (globalCsv.adv_battle_attr_ratio[attrName] or 1) | ||
| 309 | end | 311 | end | 
| 310 | 312 | ||
| 311 | - local battleV = 1 * player["hp"] | ||
| 312 | - + 2 * player["atk"] | ||
| 313 | - + 1.25 * player["def"] | ||
| 314 | - + 0.226 * player["hit"] | ||
| 315 | - + 0.26 * player["miss"] | 313 | + local battleV = role:getSurvivability(player, #attrs) | 
| 316 | 314 | ||
| 317 | --print(math.ceil(battleV), campSiteData.idleValue) | 315 | --print(math.ceil(battleV), campSiteData.idleValue) | 
| 318 | if math.ceil(battleV) < campSiteData.idleValue then return 9 end -- 战斗力是否满足 | 316 | if math.ceil(battleV) < campSiteData.idleValue then return 9 end -- 战斗力是否满足 | 
src/actions/DinerAction.lua
| @@ -112,6 +112,8 @@ function _M.addSellRpc( agent, data ) | @@ -112,6 +112,8 @@ function _M.addSellRpc( agent, data ) | ||
| 112 | 112 | ||
| 113 | role:mylog("diner_action", {desc = "addSell", int1 = dish, int2 = count}) | 113 | role:mylog("diner_action", {desc = "addSell", int1 = dish, int2 = count}) | 
| 114 | 114 | ||
| 115 | + role:mylog("diner_action", {desc = "onSell", short1 = 1, int1 = dish, int2 = count, cint1 = msg.slot, cint2 = count, cint3 = dishLevel}) | ||
| 116 | + | ||
| 115 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) | 117 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) | 
| 116 | SendPacket(actionCodes.Diner_addSellRpc, "") | 118 | SendPacket(actionCodes.Diner_addSellRpc, "") | 
| 117 | return true | 119 | return true | 
| @@ -192,7 +194,10 @@ function _M.getSellRewardRpc( agent, data ) | @@ -192,7 +194,10 @@ function _M.getSellRewardRpc( agent, data ) | ||
| 192 | } | 194 | } | 
| 193 | deltaTimes[slot] = temp.deltaTime | 195 | deltaTimes[slot] = temp.deltaTime | 
| 194 | local sellCount = oldCount - temp.lastCount | 196 | local sellCount = oldCount - temp.lastCount | 
| 195 | - role:mylog("diner_action", {desc = "sell", int1 = sellDish, int2 = sellCount}) | 197 | + if sellCount > 0 then | 
| 198 | + role:mylog("diner_action", {desc = "sell", int1 = sellDish, int2 = sellCount}) | ||
| 199 | + role:mylog("diner_action", {desc = "onSell", short1 = 2, int1 = sellDish, int2 = sellCount, cint1 = tonumber(slot), cint2 = temp.lastCount, cint3 = sell.level}) | ||
| 200 | + end | ||
| 196 | end | 201 | end | 
| 197 | sells = json.decode(role.dinerData:getProperty("sells")) | 202 | sells = json.decode(role.dinerData:getProperty("sells")) | 
| 198 | for slot, sell in pairs(sells) do | 203 | for slot, sell in pairs(sells) do | 
| @@ -310,6 +315,9 @@ function _M.expediteSellRpc( agent, data ) | @@ -310,6 +315,9 @@ function _M.expediteSellRpc( agent, data ) | ||
| 310 | restaurant_sale_coin = rewards[ItemId.DinerCoin] or 0, -- 售卖获得美食币 | 315 | restaurant_sale_coin = rewards[ItemId.DinerCoin] or 0, -- 售卖获得美食币 | 
| 311 | restaurant_sale_gear = rewards[ItemId.Gold] or 0, -- 售卖获得齿轮 | 316 | restaurant_sale_gear = rewards[ItemId.Gold] or 0, -- 售卖获得齿轮 | 
| 312 | }) | 317 | }) | 
| 318 | + if result.expediteCount > 0 then | ||
| 319 | + role:mylog("diner_action", {desc = "onSell", short1 = 3, int1 = sell.dish, int2 = result.expediteCount, cint1 = tonumber(slot), cint2 = result.lastCount, cint3 = sell.level}) | ||
| 320 | + end | ||
| 313 | end | 321 | end | 
| 314 | end | 322 | end | 
| 315 | 323 | 
src/actions/EmailAction.lua
| @@ -129,7 +129,7 @@ function _M.drawAllAttachRpc(agent, data) | @@ -129,7 +129,7 @@ function _M.drawAllAttachRpc(agent, data) | ||
| 129 | for key, v in pairs(attachments:toNumMap()) do | 129 | for key, v in pairs(attachments:toNumMap()) do | 
| 130 | reward[key] = (reward[key] or 0) + v | 130 | reward[key] = (reward[key] or 0) + v | 
| 131 | end | 131 | end | 
| 132 | - role:mylog("mail_action", {desc = "draw_attach", int1 = email:getProperty("emailId"), key1 = email:getProperty("title"), key2 = attachments}) | 132 | + --role:mylog("mail_action", {desc = "draw_attach", int1 = email:getProperty("emailId"), key1 = email:getProperty("title"), key2 = attachments}) | 
| 133 | end | 133 | end | 
| 134 | end | 134 | end | 
| 135 | if role:checkRuneFullyByReward(reward) then return 1 end | 135 | if role:checkRuneFullyByReward(reward) then return 1 end | 
| @@ -168,7 +168,7 @@ function _M.drawAttachRpc(agent, data) | @@ -168,7 +168,7 @@ function _M.drawAttachRpc(agent, data) | ||
| 168 | email:setProperty("status", 2, true) | 168 | email:setProperty("status", 2, true) | 
| 169 | email:log(role, 2) | 169 | email:log(role, 2) | 
| 170 | SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) | 170 | SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) | 
| 171 | - role:mylog("mail_action", {desc = "draw_attach", int1 = email:getProperty("emailId"), key1 = email:getProperty("title"), key2 = attachments}) | 171 | + --role:mylog("mail_action", {desc = "draw_attach", int1 = email:getProperty("emailId"), key1 = email:getProperty("title"), key2 = attachments}) | 
| 172 | return true | 172 | return true | 
| 173 | end | 173 | end | 
| 174 | 174 | ||
| @@ -184,7 +184,7 @@ function _M.checkRpc(agent, data) | @@ -184,7 +184,7 @@ function _M.checkRpc(agent, data) | ||
| 184 | 184 | ||
| 185 | email:setProperty("status", 1, true) | 185 | email:setProperty("status", 1, true) | 
| 186 | email:log(role, 1) | 186 | email:log(role, 1) | 
| 187 | - role:mylog("mail_action", {desc = "check_mail", int1 = id}) | 187 | + --role:mylog("mail_action", {desc = "check_mail", int1 = id}) | 
| 188 | 188 | ||
| 189 | SendPacket(actionCodes.Email_checkRpc, '') | 189 | SendPacket(actionCodes.Email_checkRpc, '') | 
| 190 | return true | 190 | return true | 
src/actions/GmAction.lua
| @@ -38,6 +38,7 @@ function _M.ban(role, pms) | @@ -38,6 +38,7 @@ function _M.ban(role, pms) | ||
| 38 | 38 | ||
| 39 | role:setBan(time, ctype) | 39 | role:setBan(time, ctype) | 
| 40 | role:mylog("gm_action", {desc = "ban", int1 = time, int2 = ctype, key1 = pms.sender}) | 40 | role:mylog("gm_action", {desc = "ban", int1 = time, int2 = ctype, key1 = pms.sender}) | 
| 41 | + | ||
| 41 | return "封杀成功" | 42 | return "封杀成功" | 
| 42 | end | 43 | end | 
| 43 | 44 | ||
| @@ -64,14 +65,16 @@ function _M.reset_rank(role, pms) | @@ -64,14 +65,16 @@ function _M.reset_rank(role, pms) | ||
| 64 | end | 65 | end | 
| 65 | 66 | ||
| 66 | function _M.silent(role, pms) | 67 | function _M.silent(role, pms) | 
| 67 | - local pm1 = tonum(pms.pm1) | 68 | + local pm1 = tonum(pms.pm1, 0) | 
| 69 | + dump(pms, pm1) | ||
| 68 | if pm1 < 1 then | 70 | if pm1 < 1 then | 
| 69 | role:updateProperty({field = "silent", value = 0}) | 71 | role:updateProperty({field = "silent", value = 0}) | 
| 72 | + role:setProperty("silentType", 0) | ||
| 70 | return "解禁言成功" | 73 | return "解禁言成功" | 
| 71 | end | 74 | end | 
| 72 | role:updateProperty({field = "silent", value = specTime({hour = 0}, skynet.timex()) + pm1 * 86400}) | 75 | role:updateProperty({field = "silent", value = specTime({hour = 0}, skynet.timex()) + pm1 * 86400}) | 
| 73 | - | ||
| 74 | - role:mylog("gm_action", {desc = "silent", int1 = pms.pm1, key1 = pms.sender}) | 76 | + role:setProperty("silentType", pms.pm2 or 0) | 
| 77 | + role:mylog("gm_action", {desc = "silent", int1 = pm1, key1 = pms.sender}) | ||
| 75 | return "禁言成功" | 78 | return "禁言成功" | 
| 76 | end | 79 | end | 
| 77 | 80 | 
src/actions/HangAction.lua
| @@ -353,10 +353,12 @@ function _M.endBattleRpc(agent, data) | @@ -353,10 +353,12 @@ function _M.endBattleRpc(agent, data) | ||
| 353 | reward = reward, | 353 | reward = reward, | 
| 354 | }) | 354 | }) | 
| 355 | 355 | ||
| 356 | - local team = role:getProperty("pvpTC") | 356 | + --local team = role:getProperty("pvpTC") | 
| 357 | + local team = role:getTeamFormatByType(TeamSystemType.Hang) | ||
| 357 | 358 | ||
| 358 | local battleTime = skynet.timex() - role._StartBattleTs | 359 | local battleTime = skynet.timex() - role._StartBattleTs | 
| 359 | - role:mylog("hang_action", {desc = "hangBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = carbonId, int2 = role:getProperty("hangTBV"), cint1 = role:getHerosCamp(team.heros), cint2 = battleTime}) | 360 | + role:mylog("hang_action", {desc = "hangBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = carbonId, int2 = role:getProperty("hangTBV"), | 
| 361 | + cint1 = role:getHerosCamp(team.heros), cint2 = battleTime, key1 = role:getHerosLogStr(team.heros), key2 = role:getRewardLogStr(reward)}) | ||
| 360 | 362 | ||
| 361 | SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ | 363 | SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ | 
| 362 | starNum = msg.starNum, | 364 | starNum = msg.starNum, | 
src/actions/HeroAction.lua
| @@ -1040,6 +1040,7 @@ function _M.drawHeroRpc(agent, data) | @@ -1040,6 +1040,7 @@ function _M.drawHeroRpc(agent, data) | ||
| 1040 | end | 1040 | end | 
| 1041 | end | 1041 | end | 
| 1042 | 1042 | ||
| 1043 | + local itemCount = 1 | ||
| 1043 | if role:isHaveHero(itemData.id - ItemStartId.Hero) then | 1044 | if role:isHaveHero(itemData.id - ItemStartId.Hero) then | 
| 1044 | local fragId = itemData.id - ItemStartId.Hero | 1045 | local fragId = itemData.id - ItemStartId.Hero | 
| 1045 | local heroData = csvdb["unitCsv"][fragId] | 1046 | local heroData = csvdb["unitCsv"][fragId] | 
| @@ -1047,6 +1048,7 @@ function _M.drawHeroRpc(agent, data) | @@ -1047,6 +1048,7 @@ function _M.drawHeroRpc(agent, data) | ||
| 1047 | role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId, short1=isFloorBack and 1 or 0}}) | 1048 | role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId, short1=isFloorBack and 1 or 0}}) | 
| 1048 | logReward[fragId] = (logReward[fragId] or 0) + count | 1049 | logReward[fragId] = (logReward[fragId] or 0) + count | 
| 1049 | table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) | 1050 | table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) | 
| 1051 | + itemCount = count | ||
| 1050 | else | 1052 | else | 
| 1051 | role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId, short1=isFloorBack and 1 or 0}}) | 1053 | role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId, short1=isFloorBack and 1 or 0}}) | 
| 1052 | logReward[itemId] = (logReward[itemId] or 0) + 1 | 1054 | logReward[itemId] = (logReward[itemId] or 0) + 1 | 
| @@ -1064,6 +1066,10 @@ function _M.drawHeroRpc(agent, data) | @@ -1064,6 +1066,10 @@ function _M.drawHeroRpc(agent, data) | ||
| 1064 | 1066 | ||
| 1065 | dailyDrawCnt = dailyDrawCnt + 1 | 1067 | dailyDrawCnt = dailyDrawCnt + 1 | 
| 1066 | role:checkTaskEnter("DrawHeroLimitPack", {count = dailyDrawCnt}) | 1068 | role:checkTaskEnter("DrawHeroLimitPack", {count = dailyDrawCnt}) | 
| 1069 | + | ||
| 1070 | + local ssrUpMap = role:getProperty("ssrUp") or {} | ||
| 1071 | + local ssrFloorCnt = ssrUpMap[poolId] or 0 | ||
| 1072 | + role:mylog("hero_action", {desc = "drawHero", int1=poolId, int2=btype, short1 = drawCount[drawType], cint1 = ssrFloorCnt, cint2 = itemId, cint3 = itemCount}) | ||
| 1067 | end | 1073 | end | 
| 1068 | 1074 | ||
| 1069 | role:award(drawAddReward, {log = {desc = "drawHero", int1 = btype}}) | 1075 | role:award(drawAddReward, {log = {desc = "drawHero", int1 = btype}}) | 
| @@ -1089,6 +1095,16 @@ function _M.drawHeroRpc(agent, data) | @@ -1089,6 +1095,16 @@ function _M.drawHeroRpc(agent, data) | ||
| 1089 | end | 1095 | end | 
| 1090 | role:finishGuide(8) | 1096 | role:finishGuide(8) | 
| 1091 | 1097 | ||
| 1098 | + --每次抽卡获得对应货币,可在招募商城购买道具 | ||
| 1099 | + if buildTypeData["draw_type_item"] ~= 0 then | ||
| 1100 | + local drawTypeItem = {} | ||
| 1101 | + for id, count in pairs(buildTypeData["draw_type_item"]:toNumMap()) do | ||
| 1102 | + drawTypeItem[id] = count * drawCount[drawType] | ||
| 1103 | + drawAddReward[id] = drawTypeItem[id] | ||
| 1104 | + end | ||
| 1105 | + role:award(drawTypeItem, {log = {desc = "drawHero", int1 = btype}}) | ||
| 1106 | + end | ||
| 1107 | + | ||
| 1092 | role:log("gacha", { | 1108 | role:log("gacha", { | 
| 1093 | gacha_id = poolId, -- 卡池ID | 1109 | gacha_id = poolId, -- 卡池ID | 
| 1094 | gacha_type = btype, -- 卡池类型 | 1110 | gacha_type = btype, -- 卡池类型 | 
| @@ -1099,7 +1115,7 @@ function _M.drawHeroRpc(agent, data) | @@ -1099,7 +1115,7 @@ function _M.drawHeroRpc(agent, data) | ||
| 1099 | gacha_cnt = floorHeroCount, | 1115 | gacha_cnt = floorHeroCount, | 
| 1100 | }) | 1116 | }) | 
| 1101 | 1117 | ||
| 1102 | - role:mylog("hero_action", {desc = "drawHero", int1=poolId, int2=btype, short1 = drawCount[drawType]}) | 1118 | + --role:mylog("hero_action", {desc = "drawHero", int1=poolId, int2=btype, short1 = drawCount[drawType]}) | 
| 1103 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward, subReward = drawAddReward})) -- 这个 reward 是数组 | 1119 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward, subReward = drawAddReward})) -- 这个 reward 是数组 | 
| 1104 | 1120 | ||
| 1105 | local feedbackId = buildTypeData["can_feedback"] or 0 | 1121 | local feedbackId = buildTypeData["can_feedback"] or 0 | 
src/actions/HttpAction.lua
| @@ -143,6 +143,7 @@ function _M.gm_action(query) | @@ -143,6 +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 | 147 | ||
| 147 | return status | 148 | return status | 
| 148 | end | 149 | end | 
| @@ -208,7 +209,14 @@ function _M.broadcast(query) | @@ -208,7 +209,14 @@ function _M.broadcast(query) | ||
| 208 | msg["body"] = query.content | 209 | msg["body"] = query.content | 
| 209 | msg["logout"] = query.logout | 210 | msg["logout"] = query.logout | 
| 210 | end | 211 | end | 
| 211 | - } | 212 | + }, | 
| 213 | + ["game"] = { | ||
| 214 | + code = actionCodes.Sys_gameNotice, | ||
| 215 | + exec = function() | ||
| 216 | + msg["new"] = query.status | ||
| 217 | + msg["channels"] = query.channels | ||
| 218 | + end | ||
| 219 | + }, | ||
| 212 | } | 220 | } | 
| 213 | if not handle[query.cmd] then return "错误" end | 221 | if not handle[query.cmd] then return "错误" end | 
| 214 | handle[query.cmd].exec() | 222 | handle[query.cmd].exec() | 
src/actions/PvpAction.lua
| @@ -472,7 +472,8 @@ function _M.endBattleRpc(agent, data) | @@ -472,7 +472,8 @@ function _M.endBattleRpc(agent, data) | ||
| 472 | reward = reward, | 472 | reward = reward, | 
| 473 | rank = myRank, | 473 | rank = myRank, | 
| 474 | }) | 474 | }) | 
| 475 | - role:mylog("pvp_action", {desc = "battleEnd", short1 = 1, int1 = isWin and 1 or 0, int2 = revenge and 1 or 0}) | 475 | + role:mylog("pvp_action", {desc = "battleEnd", short1 = 1, int1 = isWin and 1 or 0, int2 = revenge and 1 or 0, cint1 = oldMyRank, cint2 = myRank, | 
| 476 | + cint3 = match.id, long1 = 1, key1 = msg.key, key2 = role:getHerosLogStr(role:getProperty("pvpTC").heros)}) | ||
| 476 | 477 | ||
| 477 | _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 | 478 | _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 | 
| 478 | _pvpRecordInfoCacheC = {} -- 记录刷新了 | 479 | _pvpRecordInfoCacheC = {} -- 记录刷新了 | 
| @@ -578,7 +579,6 @@ function _M.startBattleHRpc(agent, data) | @@ -578,7 +579,6 @@ function _M.startBattleHRpc(agent, data) | ||
| 578 | 579 | ||
| 579 | if not revenge then | 580 | if not revenge then | 
| 580 | -- 次数扣一波 | 581 | -- 次数扣一波 | 
| 581 | - print("xxxxx") | ||
| 582 | local pvpFreeH = role.dailyData:getProperty("pvpFreeH") | 582 | local pvpFreeH = role.dailyData:getProperty("pvpFreeH") | 
| 583 | if pvpFreeH >= globalCsv.pvp_battle_free_count_high then | 583 | if pvpFreeH >= globalCsv.pvp_battle_free_count_high then | 
| 584 | local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} | 584 | local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} | 
| @@ -676,11 +676,13 @@ function _M.endBattleHRpc(agent, data) | @@ -676,11 +676,13 @@ function _M.endBattleHRpc(agent, data) | ||
| 676 | video = video, | 676 | video = video, | 
| 677 | }) | 677 | }) | 
| 678 | 678 | ||
| 679 | + local curStatus | ||
| 679 | -- 检查是否结束战斗 | 680 | -- 检查是否结束战斗 | 
| 680 | local winCount, loseCount = 0, 0 | 681 | local winCount, loseCount = 0, 0 | 
| 681 | for _, status in pairs(_pvpStartBattleCacheH.result) do | 682 | for _, status in pairs(_pvpStartBattleCacheH.result) do | 
| 682 | if status.isWin then | 683 | if status.isWin then | 
| 683 | winCount = winCount + 1 | 684 | winCount = winCount + 1 | 
| 685 | + curStatus = true | ||
| 684 | else | 686 | else | 
| 685 | loseCount = loseCount + 1 | 687 | loseCount = loseCount + 1 | 
| 686 | end | 688 | end | 
| @@ -696,6 +698,8 @@ function _M.endBattleHRpc(agent, data) | @@ -696,6 +698,8 @@ function _M.endBattleHRpc(agent, data) | ||
| 696 | return true | 698 | return true | 
| 697 | end | 699 | end | 
| 698 | 700 | ||
| 701 | + local curHTeam = _pvpStartBattleCacheH.pvpTH[#_pvpStartBattleCacheH.result] or {} | ||
| 702 | + | ||
| 699 | if winCount >= 2 then | 703 | if winCount >= 2 then | 
| 700 | isWin = true | 704 | isWin = true | 
| 701 | elseif loseCount >= 2 then | 705 | elseif loseCount >= 2 then | 
| @@ -720,6 +724,8 @@ function _M.endBattleHRpc(agent, data) | @@ -720,6 +724,8 @@ function _M.endBattleHRpc(agent, data) | ||
| 720 | video = video, -- 返回让客户端上传录像 | 724 | video = video, -- 返回让客户端上传录像 | 
| 721 | headers = headers, | 725 | headers = headers, | 
| 722 | })) | 726 | })) | 
| 727 | + role:mylog("pvp_action", {desc = "battleEnd", short1 = 2, int1 = curStatus and 1 or 0, int2 = revenge and 1 or 0, cint1 = 0, cint2 = 0, | ||
| 728 | + cint3 = match.id, long1 = #_pvpStartBattleCacheH.result, key1 = msg.key, key2 = role:getHerosLogStr(curHTeam.heros)}) | ||
| 723 | return true | 729 | return true | 
| 724 | end | 730 | end | 
| 725 | if revenge and isWin then | 731 | if revenge and isWin then | 
| @@ -814,6 +820,8 @@ function _M.endBattleHRpc(agent, data) | @@ -814,6 +820,8 @@ function _M.endBattleHRpc(agent, data) | ||
| 814 | rank = myRank, | 820 | rank = myRank, | 
| 815 | }) | 821 | }) | 
| 816 | 822 | ||
| 823 | + role:mylog("pvp_action", {desc = "battleEnd", short1 = 2, int1 = curStatus and 1 or 0, int2 = revenge and 1 or 0, cint1 = oldMyRank, cint2 = myRank, | ||
| 824 | + cint3 = match.id, long1 = #_pvpStartBattleCacheH.result, key1 = msg.key, key2 = role:getHerosLogStr(curHTeam.heros)}) | ||
| 817 | 825 | ||
| 818 | _pvpBattleInfoCacheH = {} --重新发阵容了 没毛病 | 826 | _pvpBattleInfoCacheH = {} --重新发阵容了 没毛病 | 
| 819 | _pvpRecordInfoCacheH = {} -- 记录刷新了 | 827 | _pvpRecordInfoCacheH = {} -- 记录刷新了 | 
| @@ -825,7 +833,7 @@ function _M.endBattleHRpc(agent, data) | @@ -825,7 +833,7 @@ function _M.endBattleHRpc(agent, data) | ||
| 825 | if isWin then | 833 | if isWin then | 
| 826 | role:checkTaskEnter("PvpWin", {score = myScore}) | 834 | role:checkTaskEnter("PvpWin", {score = myScore}) | 
| 827 | end | 835 | end | 
| 828 | - role:mylog("pvp_action", {desc = "battleEnd", short1 = 2, int1 = isWin and 1 or 0, int2 = revenge and 1 or 0}) | 836 | + | 
| 829 | 837 | ||
| 830 | SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({ | 838 | SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({ | 
| 831 | reward = reward, | 839 | reward = reward, | 
src/actions/RoleAction.lua
| @@ -340,6 +340,36 @@ function _M.loginRpc( agent, data ) | @@ -340,6 +340,36 @@ function _M.loginRpc( agent, data ) | ||
| 340 | return true | 340 | return true | 
| 341 | end | 341 | end | 
| 342 | 342 | ||
| 343 | +local function onCb1Back(newRole) | ||
| 344 | + -- cb1活跃返利 | ||
| 345 | + skynet.timeout(0, function() | ||
| 346 | + local cbbackd = cluster.query("center", "cb1backd") | ||
| 347 | + local uid = newRole:getProperty("uid") | ||
| 348 | + local roleId = newRole:getProperty("id") | ||
| 349 | + local start = uid:find("_") | ||
| 350 | + if start then | ||
| 351 | + uid = uid:sub(start + 1) | ||
| 352 | + end | ||
| 353 | + if cbbackd then | ||
| 354 | + local status, back = pcall(cluster.call, "center", cbbackd, "getCb1Reward", {uid = uid, id = roleId}) | ||
| 355 | + if status then | ||
| 356 | + if back then | ||
| 357 | + if back == 0 then | ||
| 358 | + mysqlproxy:insertEmail({roleId = roleId, emailId = MailId.CB1BackAward1, createtime = skynet.timex()}) | ||
| 359 | + elseif back == 1 then | ||
| 360 | + mysqlproxy:insertEmail({roleId = roleId, emailId = MailId.CB1BackAward2, createtime = skynet.timex()}) | ||
| 361 | + end | ||
| 362 | + newRole:mylog("cb1back", {key1 = uid, int2 = roleId, int1=back}) | ||
| 363 | + end | ||
| 364 | + else | ||
| 365 | + skynet.error("[ERROR] cb1backd cant call center uid: " .. uid .. " roleId:" .. roleId) | ||
| 366 | + end | ||
| 367 | + else | ||
| 368 | + skynet.error("[ERROR] cb1backd cant call center uid: " .. uid .. " roleId:" .. roleId) | ||
| 369 | + end | ||
| 370 | + end) | ||
| 371 | +end | ||
| 372 | + | ||
| 343 | function _M.createRpc(agent, data) | 373 | function _M.createRpc(agent, data) | 
| 344 | local msg = MsgPack.unpack(data) | 374 | local msg = MsgPack.unpack(data) | 
| 345 | local response = {} | 375 | local response = {} | 
| @@ -446,6 +476,9 @@ function _M.createRpc(agent, data) | @@ -446,6 +476,9 @@ function _M.createRpc(agent, data) | ||
| 446 | end | 476 | end | 
| 447 | end) | 477 | end) | 
| 448 | 478 | ||
| 479 | + -- cb1活跃回馈 | ||
| 480 | + onCb1Back(newRole) | ||
| 481 | + | ||
| 449 | return true | 482 | return true | 
| 450 | end | 483 | end | 
| 451 | 484 | ||
| @@ -1183,7 +1216,7 @@ function _M.chatRpc(agent, data) | @@ -1183,7 +1216,7 @@ function _M.chatRpc(agent, data) | ||
| 1183 | [1] = function () | 1216 | [1] = function () | 
| 1184 | if role:getProperty("silent") > now then --禁言 | 1217 | if role:getProperty("silent") > now then --禁言 | 
| 1185 | result = 1 | 1218 | result = 1 | 
| 1186 | - return | 1219 | + --return | 
| 1187 | end | 1220 | end | 
| 1188 | if role:getProperty("level") < (globalCsv.chat_level or 15) then | 1221 | if role:getProperty("level") < (globalCsv.chat_level or 15) then | 
| 1189 | result = 3 | 1222 | result = 3 | 
| @@ -1212,7 +1245,12 @@ function _M.chatRpc(agent, data) | @@ -1212,7 +1245,12 @@ function _M.chatRpc(agent, data) | ||
| 1212 | return | 1245 | return | 
| 1213 | end | 1246 | end | 
| 1214 | end | 1247 | end | 
| 1215 | - mcast_util.pub_world(actionCodes.Role_chat, MsgPack.pack(response)) | 1248 | + if result == 1 then | 
| 1249 | + SendPacket(actionCodes.Role_chat, MsgPack.pack(response)) | ||
| 1250 | + result = 0 | ||
| 1251 | + else | ||
| 1252 | + mcast_util.pub_world(actionCodes.Role_chat, MsgPack.pack(response)) | ||
| 1253 | + end | ||
| 1216 | -- pcall(skynet.send, '.globald', "lua", "sendWorldMsg", role._channelIdx, response) | 1254 | -- pcall(skynet.send, '.globald', "lua", "sendWorldMsg", role._channelIdx, response) | 
| 1217 | role:mylog("role_action", {desc = "chatWorld", text1 = content}) | 1255 | role:mylog("role_action", {desc = "chatWorld", text1 = content}) | 
| 1218 | end, | 1256 | end, | 
| @@ -1328,7 +1366,7 @@ function _M.drawCodeRpc(agent, data) | @@ -1328,7 +1366,7 @@ function _M.drawCodeRpc(agent, data) | ||
| 1328 | gift_name = "", -- 礼包名称 | 1366 | gift_name = "", -- 礼包名称 | 
| 1329 | gift_reason = 0, -- 礼包发放原因,见发放原因枚举表 | 1367 | gift_reason = 0, -- 礼包发放原因,见发放原因枚举表 | 
| 1330 | }) | 1368 | }) | 
| 1331 | - role:mylog("role_action", {desc = "drawCode", int1 = giftId, key1 = code}) | 1369 | + role:mylog("role_action", {desc = "drawCode", int1 = giftId, key1 = code, key2 = role:getRewardLogStr(result.gift)}) | 
| 1332 | SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({ | 1370 | SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({ | 
| 1333 | result = ret, | 1371 | result = ret, | 
| 1334 | reward = reward, | 1372 | reward = reward, | 
src/actions/StoreAction.lua
| @@ -307,9 +307,11 @@ function _M.shopBuyRpc(agent , data) | @@ -307,9 +307,11 @@ function _M.shopBuyRpc(agent , data) | ||
| 307 | 307 | ||
| 308 | if not role:checkItemEnough(cost) then return 4 end | 308 | if not role:checkItemEnough(cost) then return 4 end | 
| 309 | 309 | ||
| 310 | + local limitStr = "" | ||
| 310 | if dataSet.limit ~= 0 then | 311 | if dataSet.limit ~= 0 then | 
| 311 | buyRecord[id] = (buyRecord[id] or 0) + count | 312 | buyRecord[id] = (buyRecord[id] or 0) + count | 
| 312 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) | 313 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) | 
| 314 | + limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) | ||
| 313 | end | 315 | end | 
| 314 | role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, short1 = dataSet.shop}}) | 316 | role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, short1 = dataSet.shop}}) | 
| 315 | 317 | ||
| @@ -333,7 +335,7 @@ function _M.shopBuyRpc(agent , data) | @@ -333,7 +335,7 @@ function _M.shopBuyRpc(agent , data) | ||
| 333 | shop_purchase_current = costCount or 0, -- 购买道具消耗的货币数量 | 335 | shop_purchase_current = costCount or 0, -- 购买道具消耗的货币数量 | 
| 334 | shop_id = dataSet.shop, -- 商店ID | 336 | shop_id = dataSet.shop, -- 商店ID | 
| 335 | }) | 337 | }) | 
| 336 | - role:mylog("role_action", {desc = desc, int1 = id, int2 = count}) | 338 | + role:mylog("role_action", {desc = "shopBuy", int1 = id, int2 = count, short1=dataSet.shop, key1 = limitStr}) | 
| 337 | SendPacket(actionCodes.Store_shopBuyRpc, MsgPack.pack({reward = reward})) | 339 | SendPacket(actionCodes.Store_shopBuyRpc, MsgPack.pack({reward = reward})) | 
| 338 | return true | 340 | return true | 
| 339 | end | 341 | end | 
| @@ -546,4 +548,32 @@ function _M.getTotalRechargeAwardRpc(agent, data) | @@ -546,4 +548,32 @@ function _M.getTotalRechargeAwardRpc(agent, data) | ||
| 546 | return true | 548 | return true | 
| 547 | end | 549 | end | 
| 548 | 550 | ||
| 551 | +function _M.monthCardRewardRpc(agent, data) | ||
| 552 | + local role = agent.role | ||
| 553 | + local msg = MsgPack.unpack(data) | ||
| 554 | + local mcid = msg.mcid | ||
| 555 | + local smcid = msg.smcid | ||
| 556 | + | ||
| 557 | + local reward,change = {}, {} | ||
| 558 | + --月卡奖励 | ||
| 559 | + local tmpreward, tmpchange = role.storeData:getMonthCardDailyReward(mcid) | ||
| 560 | + if tmpreward then | ||
| 561 | + for k, v in pairs(tmpreward) do | ||
| 562 | + reward[k] = (reward[k] or 0) + v | ||
| 563 | + end | ||
| 564 | + if tmpchange then table.insert(change, tmpchange) end | ||
| 565 | + end | ||
| 566 | + | ||
| 567 | + --特刊奖励 | ||
| 568 | + tmpreward, tmpchange = role.storeData:getSMonthCardDailyReward(smcid) | ||
| 569 | + if tmpreward then | ||
| 570 | + for k, v in pairs(tmpreward) do | ||
| 571 | + reward[k] = (reward[k] or 0) + v | ||
| 572 | + end | ||
| 573 | + if tmpchange then table.insert(change, tmpchange) end | ||
| 574 | + end | ||
| 575 | + SendPacket(actionCodes.Store_monthCardRewardRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 576 | + return true | ||
| 577 | +end | ||
| 578 | + | ||
| 549 | return _M | 579 | return _M | 
| 550 | \ No newline at end of file | 580 | \ No newline at end of file | 
src/actions/TowerAction.lua
| @@ -150,7 +150,11 @@ function _M.endBattleRpc(agent, data) | @@ -150,7 +150,11 @@ function _M.endBattleRpc(agent, data) | ||
| 150 | rank = rank, | 150 | rank = rank, | 
| 151 | tower = towerType + 1 | 151 | tower = towerType + 1 | 
| 152 | }) | 152 | }) | 
| 153 | - role:mylog("tower_action", {desc = "endBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id}) | 153 | + local team = role:getTowerTeamFormat(towerType + 1) | 
| 154 | + | ||
| 155 | + | ||
| 156 | + role:mylog("tower_action", {desc = "endBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id, int2 = towerType, | ||
| 157 | + cint1 = curLevel, key1 = role:getHerosLogStr(team.heros), key2 = role:getRewardLogStr(reward)}) | ||
| 154 | 158 | ||
| 155 | SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward, change = change})) | 159 | SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward, change = change})) | 
| 156 | return true | 160 | return true | 
src/adv/Adv.lua
| @@ -924,24 +924,23 @@ function Adv:over(success, rewardRatio, overType) | @@ -924,24 +924,23 @@ function Adv:over(success, rewardRatio, overType) | ||
| 924 | end | 924 | end | 
| 925 | self:clearAdvUnlockCache() | 925 | self:clearAdvUnlockCache() | 
| 926 | 926 | ||
| 927 | - self:mylog({desc = "over", short1 = success and 1 or 0, int1 = overType, int2 = self.chapterId, long1 = self.level}) | 927 | + local team = self.owner:getProperty("advTeam") | 
| 928 | + self:mylog({desc = "over", short1 = success and 1 or 0, int1 = overType, int2 = self.chapterId, long1 = self.level, | ||
| 929 | + key1 = self.owner:getRewardLogStr(reward), key2 = self.owner:getHerosLogStr(team.heros)}) | ||
| 928 | 930 | ||
| 929 | 931 | ||
| 930 | - local team = self.owner:getProperty("advTeam") | ||
| 931 | local player = {} | 932 | local player = {} | 
| 932 | local attrs = self.owner:getTeamBattleInfo(team).heros | 933 | local attrs = self.owner:getTeamBattleInfo(team).heros | 
| 933 | - for attrName, _ in pairs(AdvAttsEnum) do | ||
| 934 | - for _, hero in pairs(attrs) do | ||
| 935 | - player[attrName] = (player[attrName] or 0) + hero[attrName] | 934 | + for _, hero in pairs(attrs) do | 
| 935 | + --根据系数计算拾荒属性 | ||
| 936 | + self.owner:checkPlayerAttr(hero) | ||
| 937 | + | ||
| 938 | + for attrName, _ in pairs(AdvAttsEnum) do | ||
| 939 | + player[attrName] = (player[attrName] or 0) + hero[attrName] | ||
| 936 | end | 940 | end | 
| 937 | - player[attrName] = player[attrName] * (globalCsv.adv_battle_attr_ratio[attrName] or 1) | ||
| 938 | end | 941 | end | 
| 939 | 942 | ||
| 940 | - local battleV = 1 * player["hp"] | ||
| 941 | - + 2 * player["atk"] | ||
| 942 | - + 1.25 * player["def"] | ||
| 943 | - + 0.226 * player["hit"] | ||
| 944 | - + 0.26 * player["miss"] | 943 | + local battleV = self.owner:getSurvivability(player, #attrs) | 
| 945 | 944 | ||
| 946 | local heroList = {team.leader, team.leader2} | 945 | local heroList = {team.leader, team.leader2} | 
| 947 | for _, hid in pairs(team.heros) do | 946 | for _, hid in pairs(team.heros) do | 
| @@ -1714,7 +1713,7 @@ local function clickTrader(self, room, block, params) | @@ -1714,7 +1713,7 @@ local function clickTrader(self, room, block, params) | ||
| 1714 | local goodsData = csvdb["event_trader_goodsCsv"][block.event.shop[buyId][1]] | 1713 | local goodsData = csvdb["event_trader_goodsCsv"][block.event.shop[buyId][1]] | 
| 1715 | if not goodsData then return false, 5 end | 1714 | if not goodsData then return false, 5 end | 
| 1716 | 1715 | ||
| 1717 | - local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) | 1716 | + local costCount = math.ceil(goodsData.price * (1 - (block.event.shop[buyId][2] or 100) / 100)) | 
| 1718 | if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够 | 1717 | if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够 | 
| 1719 | self:backCost({[goodsData.currency] = costCount}) | 1718 | self:backCost({[goodsData.currency] = costCount}) | 
| 1720 | self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}, {}) | 1719 | self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}, {}) | 
src/adv/AdvBattle.lua
| @@ -95,14 +95,13 @@ function Battle:initPlayer() | @@ -95,14 +95,13 @@ function Battle:initPlayer() | ||
| 95 | 95 | ||
| 96 | local attrs = self.adv.owner:getTeamBattleInfo(advTeam).heros | 96 | local attrs = self.adv.owner:getTeamBattleInfo(advTeam).heros | 
| 97 | 97 | ||
| 98 | + for _, hero in pairs(attrs) do | ||
| 99 | + --根据系数计算拾荒属性 | ||
| 100 | + self.adv.owner:checkPlayerAttr(hero) | ||
| 98 | 101 | ||
| 99 | - for attrName, _ in pairs(AdvAttsEnum) do | ||
| 100 | - for _, hero in pairs(attrs) do | ||
| 101 | - player[attrName] = (player[attrName] or 0) + hero[attrName] | 102 | + for attrName, _ in pairs(AdvAttsEnum) do | 
| 103 | + player[attrName] = (player[attrName] or 0) + hero[attrName] | ||
| 102 | end | 104 | end | 
| 103 | - player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) * (globalCsv.adv_battle_attr_ratio[attrName] or 1) | ||
| 104 | - -- player.growth[attrName] = player[attrName] * (globalCsv.adv_battle_attr_growth_ratio[attrName] or 1) | ||
| 105 | - -- player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1) | ||
| 106 | end | 105 | end | 
| 107 | 106 | ||
| 108 | player.hpMax = player.hp or 0 | 107 | player.hpMax = player.hp or 0 | 
src/models/Activity.lua
| @@ -797,7 +797,12 @@ activityFunc[Activity.ActivityType.ChallengeLevel] = { | @@ -797,7 +797,12 @@ activityFunc[Activity.ActivityType.ChallengeLevel] = { | ||
| 797 | end, | 797 | end, | 
| 798 | ["login"] = function(self, actType, actId) | 798 | ["login"] = function(self, actType, actId) | 
| 799 | self:getBattleTicket(actId) | 799 | self:getBattleTicket(actId) | 
| 800 | - end | 800 | + end, | 
| 801 | + ["crossDay"] = function(self, actType, notify) | ||
| 802 | + local actData = self:getActData(actType) | ||
| 803 | + actData["buyC"] = 0 | ||
| 804 | + self:updateActData(actType, actData, not notify) | ||
| 805 | + end, | ||
| 801 | } | 806 | } | 
| 802 | 807 | ||
| 803 | function Activity:onLoginActivity(actId) | 808 | function Activity:onLoginActivity(actId) | 
src/models/Email.lua
| @@ -33,6 +33,8 @@ function Email:log(role, action) | @@ -33,6 +33,8 @@ function Email:log(role, action) | ||
| 33 | mail_friend_id = 0, -- 收件方账号id | 33 | mail_friend_id = 0, -- 收件方账号id | 
| 34 | mail_friend_roleid = 0, -- 收件方角色id | 34 | mail_friend_roleid = 0, -- 收件方角色id | 
| 35 | }) | 35 | }) | 
| 36 | + role:mylog("mail_action", {desc = "onMail", int1 = self:getProperty("id"), int2 = self:getProperty("status"), cint1 = self:getProperty("emailId"), | ||
| 37 | + short1 = action, key1=self:getProperty("title"), key2=self:getProperty("attachments")}) | ||
| 36 | end | 38 | end | 
| 37 | 39 | ||
| 38 | function Email:data() | 40 | function Email:data() | 
src/models/Role.lua
| @@ -8,6 +8,7 @@ local RoleChangeStruct = import(".RoleChangeStruct") --角色数据额结构更 | @@ -8,6 +8,7 @@ local RoleChangeStruct = import(".RoleChangeStruct") --角色数据额结构更 | ||
| 8 | local RolePvp = import(".RolePvp") -- pvp | 8 | local RolePvp = import(".RolePvp") -- pvp | 
| 9 | local RoleCross = import(".RoleCross") -- 跨服务请求相关 | 9 | local RoleCross = import(".RoleCross") -- 跨服务请求相关 | 
| 10 | local RoleBattle = import(".RoleBattle") -- 跨服务请求相关 | 10 | local RoleBattle = import(".RoleBattle") -- 跨服务请求相关 | 
| 11 | +local mysqlproxy = require "shared.mysqlproxy" | ||
| 11 | 12 | ||
| 12 | RoleLog.bind(Role) | 13 | RoleLog.bind(Role) | 
| 13 | RolePlugin.bind(Role) | 14 | RolePlugin.bind(Role) | 
| @@ -56,6 +57,7 @@ Role.schema = { | @@ -56,6 +57,7 @@ Role.schema = { | ||
| 56 | lday = {"number", 0}, | 57 | lday = {"number", 0}, | 
| 57 | banTime = {"number", 0}, | 58 | banTime = {"number", 0}, | 
| 58 | banType = {"number", 0}, | 59 | banType = {"number", 0}, | 
| 60 | + banReason = {"string", "", "", 512}, | ||
| 59 | heartWarning = {"number", 0}, | 61 | heartWarning = {"number", 0}, | 
| 60 | cheatCount = {"number", 0}, | 62 | cheatCount = {"number", 0}, | 
| 61 | ltime = {"number", 0}, -- 最后登录时间 | 63 | ltime = {"number", 0}, -- 最后登录时间 | 
| @@ -79,6 +81,7 @@ Role.schema = { | @@ -79,6 +81,7 @@ Role.schema = { | ||
| 79 | -- loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL | 81 | -- loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL | 
| 80 | crown = {"number", 0}, -- 看伴娘 | 82 | crown = {"number", 0}, -- 看伴娘 | 
| 81 | silent = {"number", 0}, --禁言解禁时间 | 83 | silent = {"number", 0}, --禁言解禁时间 | 
| 84 | + silentType = {"number", 0}, -- 禁言类型 | ||
| 82 | timeGift = {"number", 0}, -- 创建角色时间礼包 | 85 | timeGift = {"number", 0}, -- 创建角色时间礼包 | 
| 83 | 86 | ||
| 84 | bagLimit = {"table", globalCsv.store_limit_max}, | 87 | bagLimit = {"table", globalCsv.store_limit_max}, | 
| @@ -345,6 +348,7 @@ end | @@ -345,6 +348,7 @@ end | ||
| 345 | function Role:data() | 348 | function Role:data() | 
| 346 | return { | 349 | return { | 
| 347 | id = self:getProperty("id"), | 350 | id = self:getProperty("id"), | 
| 351 | + uid = self:getProperty("uid"), | ||
| 348 | name = self:getProperty("name"), | 352 | name = self:getProperty("name"), | 
| 349 | intro = self:getProperty("intro"), | 353 | intro = self:getProperty("intro"), | 
| 350 | headId = self:getProperty("headId"), | 354 | headId = self:getProperty("headId"), | 
| @@ -358,7 +362,8 @@ function Role:data() | @@ -358,7 +362,8 @@ function Role:data() | ||
| 358 | timeReset = self:getProperty("timeReset"), | 362 | timeReset = self:getProperty("timeReset"), | 
| 359 | diamond = self:getAllDiamond(), | 363 | diamond = self:getAllDiamond(), | 
| 360 | bagLimit = self:getProperty("bagLimit"), | 364 | bagLimit = self:getProperty("bagLimit"), | 
| 361 | - silent = self:getProperty("silent"), | 365 | + --silent = self:getProperty("silent"), | 
| 366 | + silent = 0, | ||
| 362 | timeGift = self:getProperty("timeGift"), | 367 | timeGift = self:getProperty("timeGift"), | 
| 363 | 368 | ||
| 364 | advPass = self:getProperty("advPass"), | 369 | advPass = self:getProperty("advPass"), | 
src/models/RoleBattle.lua
| @@ -348,9 +348,41 @@ function Role:checkBattle(battleType, params) | @@ -348,9 +348,41 @@ function Role:checkBattle(battleType, params) | ||
| 348 | }) | 348 | }) | 
| 349 | end | 349 | end | 
| 350 | 350 | ||
| 351 | + local function initPlayer(player) | ||
| 352 | + player["hp"] = player["hp"] or 0 | ||
| 353 | + player["atk"] = player["atk"] or 0 | ||
| 354 | + player["def"] = player["def"] or 0 | ||
| 355 | + player["hit"] = player["hit"] or 0 | ||
| 356 | + player["miss"] = player["miss"] or 0 | ||
| 357 | + player["crit"] = player["crit"] or 0 | ||
| 358 | + player["critHurt"] = player["critHurt"] or 0 | ||
| 359 | + player["pierce"] = player["pierce"] or 0 | ||
| 360 | + player["vampire"] = player["vampire"] or 0 | ||
| 361 | + end | ||
| 362 | + | ||
| 363 | + function Role:checkPlayerAttr(player) | ||
| 364 | + if next(player) == nil then return end | ||
| 365 | + initPlayer(player) | ||
| 351 | 366 | ||
| 367 | + player["hp"] = math.floor(player["hp"] / globalCsv.adv_battle_attr_ratio["hp"]) | ||
| 368 | + player["atk"] = math.floor(player["atk"] / globalCsv.adv_battle_attr_ratio["atk"]) | ||
| 369 | + player["def"] = math.floor(player["def"] / globalCsv.adv_battle_attr_ratio["def"]) | ||
| 370 | + player["hit"] = math.floor((player["hit"] + player["miss"] )/ globalCsv.adv_battle_attr_ratio["hit"]) | ||
| 371 | + player["miss"] = math.floor((player["crit"] + player["critHurt"] + player["pierce"] + player["vampire"])/ globalCsv.adv_battle_attr_ratio["miss"]) | ||
| 372 | + end | ||
| 352 | 373 | ||
| 374 | + function Role:getSurvivability(player, heroCount) | ||
| 375 | + if next(player) == nil then return 0 end | ||
| 376 | + heroCount = heroCount or 1 | ||
| 377 | + initPlayer(player) | ||
| 353 | 378 | ||
| 379 | + local battleV = (globalCsv.adv_battle_fight_points["hp"] * player["hp"] | ||
| 380 | + + globalCsv.adv_battle_fight_points["atk"] * player["atk"] | ||
| 381 | + + globalCsv.adv_battle_fight_points["def"] * player["def"] | ||
| 382 | + + globalCsv.adv_battle_fight_points["hit"] * player["hit"] ) | ||
| 383 | + * (1 + (player["miss"]- heroCount * globalCsv.adv_battle_fight_points["miss"])/ 100) | ||
| 384 | + return battleV | ||
| 385 | + end | ||
| 354 | 386 | ||
| 355 | end | 387 | end | 
| 356 | 388 | 
src/models/RoleLog.lua
| @@ -63,6 +63,9 @@ local ItemReason = { | @@ -63,6 +63,9 @@ local ItemReason = { | ||
| 63 | giftTime = 147, -- 创角后的时间礼包 | 63 | giftTime = 147, -- 创角后的时间礼包 | 
| 64 | activityCrisis = 148, -- 物资危机奖励 | 64 | activityCrisis = 148, -- 物资危机奖励 | 
| 65 | glodConvertRune = 149, -- 金币兑换铭文 | 65 | glodConvertRune = 149, -- 金币兑换铭文 | 
| 66 | + shopBuy = 150, -- 商店购买 | ||
| 67 | + monthCardReward = 151, --月卡奖励 | ||
| 68 | + smonthCardReward = 152, --特刊奖励 | ||
| 66 | 69 | ||
| 67 | advHang = 301, -- 拾荒挂机 | 70 | advHang = 301, -- 拾荒挂机 | 
| 68 | hangBattle = 302, -- 挂机战斗 | 71 | hangBattle = 302, -- 挂机战斗 | 
| @@ -107,6 +110,7 @@ local ItemReason = { | @@ -107,6 +110,7 @@ local ItemReason = { | ||
| 107 | actMilecrisis = 1010, -- 物资危机 | 110 | actMilecrisis = 1010, -- 物资危机 | 
| 108 | battleCommandTask = 1011, -- 将军令任务 | 111 | battleCommandTask = 1011, -- 将军令任务 | 
| 109 | newUserTask = 1012, -- 新玩家任务 | 112 | newUserTask = 1012, -- 新玩家任务 | 
| 113 | + buyActivityBattleTicket = 1013, -- 购买门票 | ||
| 110 | 114 | ||
| 111 | -- 餐厅 | 115 | -- 餐厅 | 
| 112 | greenHourse = 1101, -- 食材获得 | 116 | greenHourse = 1101, -- 食材获得 | 
| @@ -391,7 +395,15 @@ local MethodType = { | @@ -391,7 +395,15 @@ local MethodType = { | ||
| 391 | currency_type = true, -- 购买道具消耗的货币类型,记录货币ID | 395 | currency_type = true, -- 购买道具消耗的货币类型,记录货币ID | 
| 392 | shop_purchase_current = true, -- 购买道具消耗的货币数量 | 396 | shop_purchase_current = true, -- 购买道具消耗的货币数量 | 
| 393 | shop_id = true, -- 商店ID | 397 | shop_id = true, -- 商店ID | 
| 394 | - }, | 398 | + }, | 
| 399 | + month_card = { --月卡+特刊奖励 | ||
| 400 | + item_type = true, --月卡 1, 特刊 2 | ||
| 401 | + item_id = true, --月卡id | ||
| 402 | + before_ex = true, --未领取奖励前的期 | ||
| 403 | + cur_ex = true, --剩余期数 | ||
| 404 | + reward_time = true, --奖励时间 | ||
| 405 | + month_reward_detail = "json", --奖励物品 {'itemid1':123,'itemid2':456,………...} | ||
| 406 | + }, | ||
| 395 | --[[ | 407 | --[[ | 
| 396 | 100 添加好友 | 408 | 100 添加好友 | 
| 397 | 200 删除好友 | 409 | 200 删除好友 | 
src/models/RolePlugin.lua
| 1 | local httpc = require("http.httpc") | 1 | local httpc = require("http.httpc") | 
| 2 | local md5 = require "md5" | 2 | local md5 = require "md5" | 
| 3 | local cjson = require "shared.json" | 3 | local cjson = require "shared.json" | 
| 4 | +local mysqlproxy = require "shared.mysqlproxy" | ||
| 4 | 5 | ||
| 5 | local serverId = tonumber(skynet.getenv("servId")) | 6 | local serverId = tonumber(skynet.getenv("servId")) | 
| 6 | local RolePlugin = {} | 7 | local RolePlugin = {} | 
| @@ -337,6 +338,8 @@ function RolePlugin.bind(Role) | @@ -337,6 +338,8 @@ function RolePlugin.bind(Role) | ||
| 337 | end | 338 | end | 
| 338 | log["cint1"] = params.id | 339 | log["cint1"] = params.id | 
| 339 | log["cint2"] = math.abs(params.count) | 340 | log["cint2"] = math.abs(params.count) | 
| 341 | + log["cint3"] = nums | ||
| 342 | + log["long1"] = origin | ||
| 340 | if params.count <= 0 then | 343 | if params.count <= 0 then | 
| 341 | self:mylog("out_item", log) | 344 | self:mylog("out_item", log) | 
| 342 | else | 345 | else | 
| @@ -377,6 +380,8 @@ function RolePlugin.bind(Role) | @@ -377,6 +380,8 @@ function RolePlugin.bind(Role) | ||
| 377 | end | 380 | end | 
| 378 | log["cint1"] = params.itemId | 381 | log["cint1"] = params.itemId | 
| 379 | log["cint2"] = math.abs(params.count) | 382 | log["cint2"] = math.abs(params.count) | 
| 383 | + log["cint3"] = nums | ||
| 384 | + log["long1"] = origin | ||
| 380 | if params.count <= 0 then | 385 | if params.count <= 0 then | 
| 381 | self:mylog("out_item", log) | 386 | self:mylog("out_item", log) | 
| 382 | else | 387 | else | 
| @@ -494,6 +499,7 @@ function RolePlugin.bind(Role) | @@ -494,6 +499,7 @@ function RolePlugin.bind(Role) | ||
| 494 | end | 499 | end | 
| 495 | log["cint1"] = origin | 500 | log["cint1"] = origin | 
| 496 | log["cint2"] = count | 501 | log["cint2"] = count | 
| 502 | + log["cint3"] = origin + count | ||
| 497 | self:mylog("in_diamond", log) | 503 | self:mylog("in_diamond", log) | 
| 498 | else | 504 | else | 
| 499 | print("gainDiamond no log ", debug.traceback()) | 505 | print("gainDiamond no log ", debug.traceback()) | 
| @@ -547,6 +553,7 @@ function RolePlugin.bind(Role) | @@ -547,6 +553,7 @@ function RolePlugin.bind(Role) | ||
| 547 | end | 553 | end | 
| 548 | log["cint1"] = origin | 554 | log["cint1"] = origin | 
| 549 | log["cint2"] = count | 555 | log["cint2"] = count | 
| 556 | + log["cint3"] = origin - count | ||
| 550 | self:mylog("out_diamond", log) | 557 | self:mylog("out_diamond", log) | 
| 551 | else | 558 | else | 
| 552 | print("costDiamond no log ", debug.traceback()) | 559 | print("costDiamond no log ", debug.traceback()) | 
| @@ -905,7 +912,8 @@ function RolePlugin.bind(Role) | @@ -905,7 +912,8 @@ function RolePlugin.bind(Role) | ||
| 905 | end | 912 | end | 
| 906 | 913 | ||
| 907 | log["cint1"] = sparkUid | 914 | log["cint1"] = sparkUid | 
| 908 | - log["cint2"] = params.cfg_id | 915 | + log["cint2"] = params.id | 
| 916 | + log["cint3"] = 0 | ||
| 909 | 917 | ||
| 910 | self:mylog("in_spark", log) | 918 | self:mylog("in_spark", log) | 
| 911 | else | 919 | else | 
| @@ -935,6 +943,7 @@ function RolePlugin.bind(Role) | @@ -935,6 +943,7 @@ function RolePlugin.bind(Role) | ||
| 935 | 943 | ||
| 936 | log["cint1"] = sparkId | 944 | log["cint1"] = sparkId | 
| 937 | log["cint2"] = spark:getProperty("cfg_id") | 945 | log["cint2"] = spark:getProperty("cfg_id") | 
| 946 | + log["cint3"] = spark:getProperty("level") | ||
| 938 | 947 | ||
| 939 | self:mylog("out_spark", log) | 948 | self:mylog("out_spark", log) | 
| 940 | else | 949 | else | 
| @@ -1144,6 +1153,38 @@ function RolePlugin.bind(Role) | @@ -1144,6 +1153,38 @@ function RolePlugin.bind(Role) | ||
| 1144 | -- return result | 1153 | -- return result | 
| 1145 | -- end | 1154 | -- end | 
| 1146 | 1155 | ||
| 1156 | + function Role:getRewardLogStr(gift) | ||
| 1157 | + if not gift then return '' end | ||
| 1158 | + local tgift = {} | ||
| 1159 | + if type(gift) == "string" then | ||
| 1160 | + for _, one in pairs(gift:toTableArray(true)) do | ||
| 1161 | + tgift[one[1]] = (tgift[one[1]] or 0) + one[2] | ||
| 1162 | + end | ||
| 1163 | + else | ||
| 1164 | + tgift = gift | ||
| 1165 | + end | ||
| 1166 | + local t = {} | ||
| 1167 | + for k, v in pairs(tgift) do | ||
| 1168 | + local name = csvdb['itemCsv'][k].name | ||
| 1169 | + table.insert(t, string.format("%s*%s", name, v)) | ||
| 1170 | + end | ||
| 1171 | + return table.concat(t, ',') | ||
| 1172 | + end | ||
| 1173 | + | ||
| 1174 | + function Role:getHerosLogStr(heros) | ||
| 1175 | + local t = {} | ||
| 1176 | + for _, id in pairs(heros or {}) do | ||
| 1177 | + local hero = self.heros[id] | ||
| 1178 | + if hero then | ||
| 1179 | + local name = csvdb["unitCsv"][hero:getProperty("type")].name | ||
| 1180 | + local level = hero:getProperty("level") | ||
| 1181 | + local wakeL = hero:getProperty("wakeL") | ||
| 1182 | + table.insert(t, string.format("%s(%s %s)", name,level,wakeL)) | ||
| 1183 | + end | ||
| 1184 | + end | ||
| 1185 | + return table.concat(t, ',') | ||
| 1186 | + end | ||
| 1187 | + | ||
| 1147 | function Role:getHerosCamp(heros) | 1188 | function Role:getHerosCamp(heros) | 
| 1148 | local had = {} | 1189 | local had = {} | 
| 1149 | for _, id in pairs(heros or {}) do | 1190 | for _, id in pairs(heros or {}) do | 
| @@ -2174,16 +2215,16 @@ function RolePlugin.bind(Role) | @@ -2174,16 +2215,16 @@ function RolePlugin.bind(Role) | ||
| 2174 | if not self.activity:isOpenById(rechargeData.activity_id, "ActShopGoods") then return "" end | 2215 | if not self.activity:isOpenById(rechargeData.activity_id, "ActShopGoods") then return "" end | 
| 2175 | end | 2216 | end | 
| 2176 | 2217 | ||
| 2177 | - local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId) | ||
| 2178 | - if orderId then | ||
| 2179 | - local uid = orderId * MAX_SVR_ID + serverId | ||
| 2180 | - local orderObject = require("models.Order").new({ key = string.format("%d", uid), id = uid }) | ||
| 2181 | - if orderObject:load() and orderObject:getProperty("rechargeId") == rechargeId and math.abs(skynet.timex() - orderObject:getProperty("createTime")) < 5 * 60 then | ||
| 2182 | - return string.format("%d", uid) | ||
| 2183 | - end | ||
| 2184 | - end | 2218 | + -- local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId) | 
| 2219 | + -- if orderId then | ||
| 2220 | + -- local uid = orderId * MAX_SVR_ID + serverId | ||
| 2221 | + -- local orderObject = require("models.Order").new({ key = string.format("%d", uid), id = uid }) | ||
| 2222 | + -- if orderObject:load() and orderObject:getProperty("rechargeId") == rechargeId and math.abs(skynet.timex() - orderObject:getProperty("createTime")) < 5 * 60 then | ||
| 2223 | + -- return string.format("%d", uid) | ||
| 2224 | + -- end | ||
| 2225 | + -- end | ||
| 2185 | 2226 | ||
| 2186 | - orderId = redisproxy:hincrby("autoincrement_set", "order", 1) | 2227 | + local orderId = redisproxy:hincrby("autoincrement_set", "order", 1) | 
| 2187 | local uid = orderId * MAX_SVR_ID + serverId | 2228 | local uid = orderId * MAX_SVR_ID + serverId | 
| 2188 | local partnerOrderId = string.format("%d", orderId * MAX_SVR_ID + serverId) | 2229 | local partnerOrderId = string.format("%d", orderId * MAX_SVR_ID + serverId) | 
| 2189 | local orderKey = string.format(R_ORDER, roleId, orderId) | 2230 | local orderKey = string.format(R_ORDER, roleId, orderId) | 
| @@ -2200,7 +2241,7 @@ function RolePlugin.bind(Role) | @@ -2200,7 +2241,7 @@ function RolePlugin.bind(Role) | ||
| 2200 | }) | 2241 | }) | 
| 2201 | order:create() | 2242 | order:create() | 
| 2202 | -- 正在进行中的订单 缓存 | 2243 | -- 正在进行中的订单 缓存 | 
| 2203 | - redisproxy:hset(string.format(R_ORDERS, roleId), rechargeId, orderId) | 2244 | + -- redisproxy:hset(string.format(R_ORDERS, roleId), rechargeId, orderId) | 
| 2204 | return partnerOrderId | 2245 | return partnerOrderId | 
| 2205 | end | 2246 | end | 
| 2206 | 2247 | ||
| @@ -2253,7 +2294,7 @@ function RolePlugin.bind(Role) | @@ -2253,7 +2294,7 @@ function RolePlugin.bind(Role) | ||
| 2253 | -- redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | 2294 | -- redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | 
| 2254 | elseif status == "finsh" then | 2295 | elseif status == "finsh" then | 
| 2255 | orderObject:setProperty("finishTime", skynet.time()) | 2296 | orderObject:setProperty("finishTime", skynet.time()) | 
| 2256 | - redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | 2297 | + -- redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | 
| 2257 | end | 2298 | end | 
| 2258 | 2299 | ||
| 2259 | orderObject:update() | 2300 | orderObject:update() | 
| @@ -2301,7 +2342,7 @@ function RolePlugin.bind(Role) | @@ -2301,7 +2342,7 @@ function RolePlugin.bind(Role) | ||
| 2301 | end | 2342 | end | 
| 2302 | local rechargeId = back | 2343 | local rechargeId = back | 
| 2303 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] | 2344 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] | 
| 2304 | - if (params.is_mycard and rechargeData.twd * 100 ~= tonumber(params.amount)) or (not params.is_mycard and rechargeData.rmb * 100 ~= tonumber(params.amount)) then | 2345 | + if (params.is_mycard and rechargeData.twd * 100 ~= tonumber(params.amount)) or (not params.is_mycard and ((rechargeData.rmb * 100) / globalCsv.QArecharge) ~= tonumber(params.amount)) then | 
| 2305 | skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s", | 2346 | skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s", | 
| 2306 | params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount | 2347 | params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount | 
| 2307 | )) | 2348 | )) | 
| @@ -2328,7 +2369,6 @@ function RolePlugin.bind(Role) | @@ -2328,7 +2369,6 @@ function RolePlugin.bind(Role) | ||
| 2328 | return rechargeId | 2369 | return rechargeId | 
| 2329 | end | 2370 | end | 
| 2330 | 2371 | ||
| 2331 | - | ||
| 2332 | function Role:recharge(params) | 2372 | function Role:recharge(params) | 
| 2333 | local id = tonumber(params.id) | 2373 | local id = tonumber(params.id) | 
| 2334 | local rechargeData = csvdb["shop_rechargeCsv"][id] | 2374 | local rechargeData = csvdb["shop_rechargeCsv"][id] | 
| @@ -2353,8 +2393,16 @@ function RolePlugin.bind(Role) | @@ -2353,8 +2393,16 @@ function RolePlugin.bind(Role) | ||
| 2353 | end | 2393 | end | 
| 2354 | self:gainDiamond({count = diamondCount, isRecharge = true, sid = params.sid, log = {desc = "recharge", int1 = id}}) | 2394 | self:gainDiamond({count = diamondCount, isRecharge = true, sid = params.sid, log = {desc = "recharge", int1 = id}}) | 
| 2355 | elseif rechargeData.shop == 2 then --通行证商店 | 2395 | elseif rechargeData.shop == 2 then --通行证商店 | 
| 2396 | + --订阅奖励 | ||
| 2356 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 2397 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 
| 2357 | - self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) | 2398 | + | 
| 2399 | + --签收奖励 | ||
| 2400 | + local tmpreward, _ = self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) | ||
| 2401 | + if tmpreward then | ||
| 2402 | + for k, v in pairs(tmpreward) do | ||
| 2403 | + reward[k] = (reward[k] or 0) + v | ||
| 2404 | + end | ||
| 2405 | + end | ||
| 2358 | elseif rechargeData.shop == 3 then -- 礼包商店 | 2406 | elseif rechargeData.shop == 3 then -- 礼包商店 | 
| 2359 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 2407 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 
| 2360 | else | 2408 | else | 
src/models/RoleTask.lua
| @@ -487,6 +487,7 @@ function RoleTask.bind(Role) | @@ -487,6 +487,7 @@ function RoleTask.bind(Role) | ||
| 487 | if status[taskId] ~= -1 and data.type == stype and (data.condition2 == 0 or data.condition2 == cond1) then | 487 | if status[taskId] ~= -1 and data.type == stype and (data.condition2 == 0 or data.condition2 == cond1) then | 
| 488 | status[taskId] = (status[taskId] or 0) + count | 488 | status[taskId] = (status[taskId] or 0) + count | 
| 489 | isChange[key] = 1 | 489 | isChange[key] = 1 | 
| 490 | + self:mylog("role_action", {desc = "onTask", int1 = taskId, int2 = status[taskId], short1 = key, cint1 = data.condition1}) | ||
| 490 | end | 491 | end | 
| 491 | end | 492 | end | 
| 492 | end | 493 | end | 
| @@ -612,6 +613,9 @@ function RoleTask.bind(Role) | @@ -612,6 +613,9 @@ function RoleTask.bind(Role) | ||
| 612 | end | 613 | end | 
| 613 | end | 614 | end | 
| 614 | if next(change) then | 615 | if next(change) then | 
| 616 | + for _, info in ipairs(change) do | ||
| 617 | + self:mylog("role_action", {desc = "onTask", int1 = info.field, int2 = info.value, short1 = 3, cint1 = 0}) | ||
| 618 | + end | ||
| 615 | self:changeUpdates(change, notNotify) | 619 | self:changeUpdates(change, notNotify) | 
| 616 | end | 620 | end | 
| 617 | end | 621 | end | 
src/models/RoleTimeReset.lua
| @@ -85,6 +85,7 @@ ResetFunc["CrossWeek"] = function(self, notify, response) | @@ -85,6 +85,7 @@ ResetFunc["CrossWeek"] = function(self, notify, response) | ||
| 85 | response.dinerS = {} | 85 | response.dinerS = {} | 
| 86 | 86 | ||
| 87 | self.activity:refreshWeekData(notify) | 87 | self.activity:refreshWeekData(notify) | 
| 88 | + self.storeData:refreshWeekData(notify) | ||
| 88 | 89 | ||
| 89 | -- 跨周送一些道具 | 90 | -- 跨周送一些道具 | 
| 90 | local BnousReward = self:getBnousPvpTicket() | 91 | local BnousReward = self:getBnousPvpTicket() | 
src/models/Store.lua
| @@ -8,24 +8,13 @@ end | @@ -8,24 +8,13 @@ end | ||
| 8 | 8 | ||
| 9 | function Store:onLoad() | 9 | function Store:onLoad() | 
| 10 | local monEx = self:getProperty("monthCardEx") | 10 | local monEx = self:getProperty("monthCardEx") | 
| 11 | - local smonEx = self:getProperty("smonthCardEx") | ||
| 12 | local monId = self:getProperty("monthCardId") | 11 | local monId = self:getProperty("monthCardId") | 
| 13 | - local smonId = self:getProperty("smonthCardId") | ||
| 14 | - local timeNow = skynet.timex() | ||
| 15 | local flag = false | 12 | local flag = false | 
| 16 | - if monEx > timeNow and monId == 0 then | 13 | + if monEx > 0 and monId == 0 then | 
| 17 | self:updateProperty({field = "monthCardId", value = 101}) | 14 | self:updateProperty({field = "monthCardId", value = 101}) | 
| 18 | self:updateProperty({field = "getMailT1", value = 0}) | 15 | self:updateProperty({field = "getMailT1", value = 0}) | 
| 19 | flag = true | 16 | flag = true | 
| 20 | end | 17 | end | 
| 21 | - if smonEx > timeNow and smonId == 0 then | ||
| 22 | - self:updateProperty({field = "smonthCardId", value = 102}) | ||
| 23 | - self:updateProperty({field = "getMailT2", value = 0}) | ||
| 24 | - flag = true | ||
| 25 | - end | ||
| 26 | - if flag then | ||
| 27 | - self:sendMonthCardEmail() | ||
| 28 | - end | ||
| 29 | end | 18 | end | 
| 30 | 19 | ||
| 31 | ActGoodsType = { | 20 | ActGoodsType = { | 
| @@ -39,10 +28,13 @@ Store.schema = { | @@ -39,10 +28,13 @@ Store.schema = { | ||
| 39 | growFund = {"number", 0}, -- 成长基金 | 28 | growFund = {"number", 0}, -- 成长基金 | 
| 40 | growFundR = {"string", ""}, -- 成长基金领取记录 | 29 | growFundR = {"string", ""}, -- 成长基金领取记录 | 
| 41 | 30 | ||
| 42 | - monthCardEx = {"number", 0}, -- 月卡过期时间戳 | 31 | + monthCardEx = {"number", 0}, -- 期数 | 
| 43 | monthCardId = {"number", 0}, -- 月卡id | 32 | monthCardId = {"number", 0}, -- 月卡id | 
| 44 | - smonthCardEx = {"number", 0}, -- 超级月卡过期时间戳 | ||
| 45 | - smonthCardId = {"number", 0}, -- 超级月卡id | 33 | + firstMonthCard = {"number", 1}, -- 首次订阅月卡 | 
| 34 | + monthCardReceive = {"number", 0}, -- 月卡奖励领取记录 当天 0-未领取, 1-已经领取 | ||
| 35 | + | ||
| 36 | + smonthCards = {"table", {}}, --特刊信息 {[id]={["buyCount"]=0, ["periods"]=0}} buyCount: 购买次数,periods: 剩余期数, | ||
| 37 | + smonthCardReceive = {"number", 0}, -- 特刊奖励领取记录 当天 0-未领取, 1-已经领取 | ||
| 46 | 38 | ||
| 47 | battleCard = {"number", 0}, -- 赛季卡 | 39 | battleCard = {"number", 0}, -- 赛季卡 | 
| 48 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 | 40 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 | 
| @@ -60,6 +52,9 @@ Store.schema = { | @@ -60,6 +52,9 @@ Store.schema = { | ||
| 60 | bpInfo = {"table", {}}, -- battle pass 探索指令 1={flag=0 为1表示买了,br=""付费领取记录, fr=""免费领取记录},2,3,4 | 52 | bpInfo = {"table", {}}, -- battle pass 探索指令 1={flag=0 为1表示买了,br=""付费领取记录, fr=""免费领取记录},2,3,4 | 
| 61 | 53 | ||
| 62 | totalRR = {"string", ""}, -- 累计充值奖励领取记录 | 54 | totalRR = {"string", ""}, -- 累计充值奖励领取记录 | 
| 55 | + | ||
| 56 | + dailyShop = {"table", {}}, | ||
| 57 | + weekShop = {"table", {}}, | ||
| 63 | } | 58 | } | 
| 64 | 59 | ||
| 65 | function Store:updateProperty(params) | 60 | function Store:updateProperty(params) | 
| @@ -82,9 +77,134 @@ function Store:updateProperty(params) | @@ -82,9 +77,134 @@ function Store:updateProperty(params) | ||
| 82 | end | 77 | end | 
| 83 | 78 | ||
| 84 | function Store:onCrossDay() | 79 | function Store:onCrossDay() | 
| 85 | - self:sendMonthCardEmail() | 80 | + --self:sendMonthCardEmail() | 
| 86 | self:deleteExpireLimitGoods() | 81 | self:deleteExpireLimitGoods() | 
| 87 | --self:checkPaySignReward() | 82 | --self:checkPaySignReward() | 
| 83 | + | ||
| 84 | + --刷新商店 | ||
| 85 | + self:flushDailyShop() | ||
| 86 | + | ||
| 87 | + --重置月卡、特刊奖励领取记录 | ||
| 88 | + self:updateProperty({field = "monthCardReceive", value = 0}) | ||
| 89 | + self:updateProperty({field = "smonthCardReceive", value = 0}) | ||
| 90 | +end | ||
| 91 | + | ||
| 92 | +function Store:refreshWeekData(notify) | ||
| 93 | + self:flushWeekShop() | ||
| 94 | +end | ||
| 95 | + | ||
| 96 | +local SuperMonthCard = {} | ||
| 97 | + | ||
| 98 | +SuperMonthCard["buy"] = function(self, id) | ||
| 99 | + local smonthCards = self:getProperty("smonthCards") or {} | ||
| 100 | + | ||
| 101 | + local buyLimitFunc = function(buylimit) | ||
| 102 | + for k, v in pairs(buylimit) do | ||
| 103 | + if k == 1 then | ||
| 104 | + if v == 101 then | ||
| 105 | + if self:isMonthCardExpire() then | ||
| 106 | + skynet.error("月卡过期") | ||
| 107 | + return false | ||
| 108 | + end | ||
| 109 | + else | ||
| 110 | + if smonthCards[v] == nil then | ||
| 111 | + skynet.error("没有购买增刊里的条件, %d", v) | ||
| 112 | + return false | ||
| 113 | + end | ||
| 114 | + end | ||
| 115 | + elseif k == 2 then | ||
| 116 | + if smonthCards[v] == nil and v ~= 101 then | ||
| 117 | + skynet.error("没有购买增刊里的条件, %d", v) | ||
| 118 | + return false | ||
| 119 | + end | ||
| 120 | + if SuperMonthCard["isExpired"](self, v) == false and v ~= 101 then | ||
| 121 | + skynet.error("上期特刊奖励没有领取完") | ||
| 122 | + return false | ||
| 123 | + end | ||
| 124 | + end | ||
| 125 | + end | ||
| 126 | + return true | ||
| 127 | + end | ||
| 128 | + | ||
| 129 | + local BuyMonthCard = {} | ||
| 130 | + BuyMonthCard["renewal"]= function() | ||
| 131 | + --续刊 | ||
| 132 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 133 | + if card["buyLimit"] and card["buyLimit"] ~= "" then | ||
| 134 | + if buyLimitFunc(card["buyLimit"]:toNumMap()) == false then | ||
| 135 | + skynet.error("不满足购买条件") | ||
| 136 | + return false | ||
| 137 | + end | ||
| 138 | + end | ||
| 139 | + | ||
| 140 | + local smonthCard = smonthCards[id] or {} | ||
| 141 | + if next(smonthCard) then | ||
| 142 | + smonthCard["buyCount"] = (smonthCard["buyCount"] or 0) + 1 | ||
| 143 | + local periods = SuperMonthCard["periods"](self, id) + (card["amount"] or 30) | ||
| 144 | + smonthCard["periods"] = periods | ||
| 145 | + | ||
| 146 | + self:updateProperty({field = "smonthCards", value = smonthCards}) | ||
| 147 | + return true | ||
| 148 | + end | ||
| 149 | + end | ||
| 150 | + BuyMonthCard["order"] = function() | ||
| 151 | + --增刊条件 | ||
| 152 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 153 | + if card["buyLimit"] and card["buyLimit"] ~= "" then | ||
| 154 | + if buyLimitFunc(card["buyLimit"]:toNumMap()) == false then | ||
| 155 | + skynet.error("不满足增刊条件") | ||
| 156 | + return false | ||
| 157 | + end | ||
| 158 | + end | ||
| 159 | + smonthCards[id] = {["periods"] = (card["amount"] or 30), ["buyCount"] = 1} | ||
| 160 | + | ||
| 161 | + self:updateProperty({field= "smonthCards", value = smonthCards}) | ||
| 162 | + return true | ||
| 163 | + end | ||
| 164 | + | ||
| 165 | + if SuperMonthCard["isExpired"](self, id) then | ||
| 166 | + local smonthCard = smonthCards[id] or {} | ||
| 167 | + if next(smonthCard) then | ||
| 168 | + return BuyMonthCard["renewal"]() | ||
| 169 | + else | ||
| 170 | + return BuyMonthCard["order"]() | ||
| 171 | + end | ||
| 172 | + else | ||
| 173 | + return BuyMonthCard["renewal"]() | ||
| 174 | + end | ||
| 175 | +end | ||
| 176 | + | ||
| 177 | +SuperMonthCard["periods"] = function(self, id) | ||
| 178 | + local smonthCards = self:getProperty("smonthCards") or {} | ||
| 179 | + local smonthCard = smonthCards[id] or {} | ||
| 180 | + return smonthCard["periods"] or 0 | ||
| 181 | +end | ||
| 182 | + | ||
| 183 | +SuperMonthCard["isExpired"] = function (self, id) | ||
| 184 | + local periods = SuperMonthCard["periods"](self, id) | ||
| 185 | + return periods == 0 | ||
| 186 | +end | ||
| 187 | + | ||
| 188 | +SuperMonthCard["itemDaily"] = function(self, id) | ||
| 189 | + local cur_ex = SuperMonthCard["periods"](self, id) | ||
| 190 | + if cur_ex == 0 then return nil, nil end | ||
| 191 | + cur_ex = cur_ex - 1 | ||
| 192 | + | ||
| 193 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 194 | + local reward, change = self.owner:award(card["itemDaily"], {log = {desc = "smonthCardReward", int1 = id, int2 = cur_ex}}) | ||
| 195 | + | ||
| 196 | + local smonthCards = self:getProperty("smonthCards") or {} | ||
| 197 | + local smonthCard = smonthCards[id] or {} | ||
| 198 | + smonthCard["periods"] = cur_ex | ||
| 199 | + self:updateProperty({field = "smonthCards", value = smonthCards}) | ||
| 200 | + | ||
| 201 | + return reward, change, cur_ex | ||
| 202 | +end | ||
| 203 | + | ||
| 204 | +SuperMonthCard["itemFirst"] = function(self, id) | ||
| 205 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 206 | + local reward, _ = self.owner:award(card["itemFirst"], {isRecharge = true, log = {desc = "recharge", int1 = id}}) | ||
| 207 | + return reward | ||
| 88 | end | 208 | end | 
| 89 | 209 | ||
| 90 | -- 删除过期商品 | 210 | -- 删除过期商品 | 
| @@ -139,15 +259,11 @@ function Store:sendMonthCardEmail() | @@ -139,15 +259,11 @@ function Store:sendMonthCardEmail() | ||
| 139 | end | 259 | end | 
| 140 | 260 | ||
| 141 | function Store:isMonthCardExpire() | 261 | function Store:isMonthCardExpire() | 
| 142 | - local timeNow = skynet.timex() | ||
| 143 | - local ts = self:getProperty("monthCardEx") | ||
| 144 | - return ts < timeNow | 262 | + return self:getProperty("monthCardEx") == 0 | 
| 145 | end | 263 | end | 
| 146 | 264 | ||
| 147 | -function Store:isSuperMonthCardExpire() | ||
| 148 | - local timeNow = skynet.timex() | ||
| 149 | - local ts = self:getProperty("smonthCardEx") | ||
| 150 | - return ts < timeNow | 265 | +function Store:isSuperMonthCardExpire(id) | 
| 266 | + return false | ||
| 151 | end | 267 | end | 
| 152 | 268 | ||
| 153 | function Store:isPrivCardExpire() | 269 | function Store:isPrivCardExpire() | 
| @@ -225,23 +341,97 @@ function Store:getCurMonthCardLvl(isSuper) | @@ -225,23 +341,97 @@ function Store:getCurMonthCardLvl(isSuper) | ||
| 225 | return cfg.level or 0 | 341 | return cfg.level or 0 | 
| 226 | end | 342 | end | 
| 227 | 343 | ||
| 344 | +--获取月卡每日奖励 | ||
| 345 | +function Store:getMonthCardDailyReward(id) | ||
| 346 | + if self:isMonthCardExpire() or self:getProperty("monthCardReceive") == 1 then return nil, nil end | ||
| 347 | + | ||
| 348 | + local before_ex = self:getProperty("monthCardEx") | ||
| 349 | + self:updateProperty({field = "monthCardEx", delta = -1}) | ||
| 350 | + local cur_ex = self:getProperty("monthCardEx") | ||
| 351 | + | ||
| 352 | + local actCfg = csvdb["shop_cardCsv"][id] or {} | ||
| 353 | + local award = actCfg.itemDaily:toNumMap() | ||
| 354 | + local reward, change = self.owner:award(award, {log = {desc = "monthCardReward", int1 = id, int2 = cur_ex}}) | ||
| 355 | + | ||
| 356 | + --今日月卡奖励已经领取 | ||
| 357 | + self:updateProperty({field = "monthCardReceive", value = 1}) | ||
| 358 | + | ||
| 359 | + self.owner:log("month_card", { | ||
| 360 | + item_type = CardType.NormalMonthCard, | ||
| 361 | + item_id = id, --月卡id | ||
| 362 | + before_ex = before_ex, --未领取奖励前的期 | ||
| 363 | + cur_ex = cur_ex, --剩余期数 | ||
| 364 | + reward_time = skynet.timex(), --奖励时间 | ||
| 365 | + month_reward_detail = reward, | ||
| 366 | + }) | ||
| 367 | + return reward, change | ||
| 368 | +end | ||
| 369 | + | ||
| 370 | +--获取特刊每日奖励 | ||
| 371 | +function Store:getSMonthCardDailyReward(id) | ||
| 372 | + local before_ex = SuperMonthCard["periods"](self, id) | ||
| 373 | + local reward, change, cur_ex= SuperMonthCard["itemDaily"](self, id) | ||
| 374 | + | ||
| 375 | + --今日特刊奖励已经领取 | ||
| 376 | + self:updateProperty({field = "smonthCardReceive", value = 1}) | ||
| 377 | + | ||
| 378 | + self.owner:log("month_card", { | ||
| 379 | + item_type = CardType.SuperMonthCard, | ||
| 380 | + item_id = id, --月卡id | ||
| 381 | + before_ex = before_ex, --未领取奖励前的期 | ||
| 382 | + cur_ex = cur_ex, --剩余期数 | ||
| 383 | + reward_time = skynet.timex(), --奖励时间 | ||
| 384 | + month_reward_detail = reward, | ||
| 385 | + }) | ||
| 386 | + return reward, change | ||
| 387 | +end | ||
| 388 | + | ||
| 389 | +function Store:firstBuyMonthCard(id) | ||
| 390 | + if self:getProperty("firstMonthCard") == 1 then | ||
| 391 | + self:updateProperty({field = "firstMonthCard", value = 0}) | ||
| 392 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 393 | + return self.owner:award(card["itemOnce"], {log = {desc = "monthCardReward", int1 = id, int2 = 30}}) | ||
| 394 | + end | ||
| 395 | + return nil | ||
| 396 | +end | ||
| 397 | + | ||
| 228 | -- 购买通行证 | 398 | -- 购买通行证 | 
| 229 | function Store:onBuyCard(type, duration, id, actid) | 399 | function Store:onBuyCard(type, duration, id, actid) | 
| 230 | local timeNow = skynet.timex() | 400 | local timeNow = skynet.timex() | 
| 231 | if type == CardType.NormalMonthCard then | 401 | if type == CardType.NormalMonthCard then | 
| 232 | if self:isMonthCardExpire() then | 402 | if self:isMonthCardExpire() then | 
| 233 | self:updateProperty({field = "monthCardId", value = id}) | 403 | self:updateProperty({field = "monthCardId", value = id}) | 
| 234 | - self:updateProperty({field = "monthCardEx", value = timeNow + duration}) | ||
| 235 | - else | ||
| 236 | - self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) | ||
| 237 | end | 404 | end | 
| 238 | - self:sendMonthCardEmail() | 405 | + self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + 30}) | 
| 406 | + | ||
| 407 | + --初回特典 仅首次购买月卡时赠送SSR级角色"拉塔托娅" | ||
| 408 | + local reward = {} | ||
| 409 | + local tmpreward, _ = self:firstBuyMonthCard(id) | ||
| 410 | + if tmpreward then | ||
| 411 | + for k, v in pairs(tmpreward) do | ||
| 412 | + reward[k] = (reward[k] or 0) + v | ||
| 413 | + end | ||
| 414 | + end | ||
| 415 | + | ||
| 416 | + tmpreward = SuperMonthCard["itemFirst"](self, id) | ||
| 417 | + if next(tmpreward) then | ||
| 418 | + for k, v in pairs(tmpreward) do | ||
| 419 | + reward[k] = (reward[k] or 0) + v | ||
| 420 | + end | ||
| 421 | + end | ||
| 422 | + return reward | ||
| 423 | + elseif type == CardType.SuperMonthCard then | ||
| 424 | + if SuperMonthCard["buy"](self, id) then | ||
| 425 | + skynet.error("特刊购买成功:"..id) | ||
| 426 | + return SuperMonthCard["itemFirst"](self, id) | ||
| 427 | + end | ||
| 428 | + return nil | ||
| 239 | elseif type == CardType.NormalMonthCardLevelUp then | 429 | elseif type == CardType.NormalMonthCardLevelUp then | 
| 240 | if self:isMonthCardExpire() then | 430 | if self:isMonthCardExpire() then | 
| 241 | skynet.error(string.format("month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | 431 | skynet.error(string.format("month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | 
| 242 | else | 432 | else | 
| 243 | local cfg = csvdb["shop_cardCsv"][id] | 433 | local cfg = csvdb["shop_cardCsv"][id] | 
| 244 | - if not cfg then return end | 434 | + if not cfg then return end | 
| 245 | local dif = cfg.level - self:getCurMonthCardLvl(false) | 435 | local dif = cfg.level - self:getCurMonthCardLvl(false) | 
| 246 | if dif > 1 and dif < 0 then | 436 | if dif > 1 and dif < 0 then | 
| 247 | return | 437 | return | 
| @@ -250,20 +440,13 @@ function Store:onBuyCard(type, duration, id, actid) | @@ -250,20 +440,13 @@ function Store:onBuyCard(type, duration, id, actid) | ||
| 250 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) | 440 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) | 
| 251 | end | 441 | end | 
| 252 | self:sendMonthCardEmail() | 442 | self:sendMonthCardEmail() | 
| 253 | - elseif type == CardType.SuperMonthCard then | ||
| 254 | - if self:isSuperMonthCardExpire() then | ||
| 255 | - self:updateProperty({field = "smonthCardId", value = id}) | ||
| 256 | - self:updateProperty({field = "smonthCardEx", value = timeNow + duration}) | ||
| 257 | - else | ||
| 258 | - self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration}) | ||
| 259 | - end | ||
| 260 | - self:sendMonthCardEmail() | 443 | + | 
| 261 | elseif type == CardType.SuperMonthCardLevelUp then | 444 | elseif type == CardType.SuperMonthCardLevelUp then | 
| 262 | if self:isSuperMonthCardExpire() then | 445 | if self:isSuperMonthCardExpire() then | 
| 263 | skynet.error(string.format("super month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | 446 | skynet.error(string.format("super month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | 
| 264 | else | 447 | else | 
| 265 | local cfg = csvdb["shop_cardCsv"][id] | 448 | local cfg = csvdb["shop_cardCsv"][id] | 
| 266 | - if not cfg then return end | 449 | + if not cfg then return end | 
| 267 | local dif = cfg.level - self:getCurMonthCardLvl(true) | 450 | local dif = cfg.level - self:getCurMonthCardLvl(true) | 
| 268 | if dif > 1 and dif < 0 then | 451 | if dif > 1 and dif < 0 then | 
| 269 | return | 452 | return | 
| @@ -306,6 +489,7 @@ function Store:onBuyCard(type, duration, id, actid) | @@ -306,6 +489,7 @@ function Store:onBuyCard(type, duration, id, actid) | ||
| 306 | self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0}) | 489 | self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0}) | 
| 307 | self.owner.activity:updateActData("BattleCommand", actData) | 490 | self.owner.activity:updateActData("BattleCommand", actData) | 
| 308 | end | 491 | end | 
| 492 | + return nil, nil | ||
| 309 | end | 493 | end | 
| 310 | 494 | ||
| 311 | --检测购买是否超过限制数量 | 495 | --检测购买是否超过限制数量 | 
| @@ -548,6 +732,88 @@ function Store:OnTriggerLimitTimePackAfterTs(eventType, param) | @@ -548,6 +732,88 @@ function Store:OnTriggerLimitTimePackAfterTs(eventType, param) | ||
| 548 | end | 732 | end | 
| 549 | end | 733 | end | 
| 550 | 734 | ||
| 735 | +local function checkShopFinish(shop, shopPool) | ||
| 736 | + local tmpShop = shopPool[shop.id] or {} | ||
| 737 | + if next(tmpShop) then | ||
| 738 | + if tmpShop.expire_ts then | ||
| 739 | + if skynet.timex() > tmpShop.expire_ts then | ||
| 740 | + shopPool[shop.id] = nil | ||
| 741 | + return true | ||
| 742 | + else | ||
| 743 | + return false | ||
| 744 | + end | ||
| 745 | + else | ||
| 746 | + tmpShop.expire_ts = skynet.timex() + tmpShop.cool_time * DAY_SEC | ||
| 747 | + return false | ||
| 748 | + end | ||
| 749 | + else | ||
| 750 | + return true | ||
| 751 | + end | ||
| 752 | +end | ||
| 753 | + | ||
| 754 | +--随机日/周商店随机两个商品 | ||
| 755 | +-- 1. 让缓存里的商品进入冷却时间 | ||
| 756 | +-- 2. 删除缓存里的已经冷却好的商品 | ||
| 757 | +-- 3. 随机两件商品放入缓存中 | ||
| 758 | +function Store:flushDailyShop() | ||
| 759 | + local dailyShop = self:getProperty("dailyShop") or {} | ||
| 760 | + local tmpDailyShop = {} | ||
| 761 | + | ||
| 762 | + for id, data in pairs(csvdb["shop_normalCsv"]) do | ||
| 763 | + if data.shop == 1 and data.shopType == 3 then | ||
| 764 | + if data.resetTime == 1 and checkShopFinish(data, dailyShop) then | ||
| 765 | + tmpDailyShop[id] = {["id"] = data.id, ["weight"] = 100, ["cool_time"] = data.cool_time} | ||
| 766 | + end | ||
| 767 | + end | ||
| 768 | + end | ||
| 769 | + | ||
| 770 | + --随机两件商品放入缓存 跨天刷新 | ||
| 771 | + if next(tmpDailyShop) then | ||
| 772 | + local id = math.randWeight(tmpDailyShop) | ||
| 773 | + if id then | ||
| 774 | + dailyShop[id] = tmpDailyShop[id] | ||
| 775 | + tmpDailyShop[id] = nil | ||
| 776 | + end | ||
| 777 | + | ||
| 778 | + id = math.randWeight(tmpDailyShop) | ||
| 779 | + if id then | ||
| 780 | + dailyShop[id] = tmpDailyShop[id] | ||
| 781 | + tmpDailyShop[id] = nil | ||
| 782 | + end | ||
| 783 | + end | ||
| 784 | + | ||
| 785 | + self:updateProperty({field="dailyShop", value= dailyShop}) | ||
| 786 | +end | ||
| 787 | + | ||
| 788 | +function Store:flushWeekShop() | ||
| 789 | + local weekShop = self:getProperty("weekShop") or {} | ||
| 790 | + local tmpWeekShop = {} | ||
| 791 | + | ||
| 792 | + for id, data in pairs(csvdb["shop_normalCsv"]) do | ||
| 793 | + if data.shop == 1 and data.shopType == 3 then | ||
| 794 | + if data.resetTime == 2 and checkShopFinish(data, weekShop)then | ||
| 795 | + tmpWeekShop[id] = {["id"] = data.id, ["weight"] = 100, ["cool_time"] = data.cool_time} | ||
| 796 | + end | ||
| 797 | + end | ||
| 798 | + end | ||
| 799 | + | ||
| 800 | + --随机两件商品放入缓存 跨周刷新 | ||
| 801 | + if next(tmpWeekShop) then | ||
| 802 | + local id = math.randWeight(tmpWeekShop) | ||
| 803 | + if id then | ||
| 804 | + weekShop[id] = weekShop[id] | ||
| 805 | + tmpWeekShop[id] = nil | ||
| 806 | + end | ||
| 807 | + | ||
| 808 | + id = math.randWeight(tmpWeekShop) | ||
| 809 | + if id then | ||
| 810 | + weekShop[id] = weekShop[id] | ||
| 811 | + tmpWeekShop[id] = nil | ||
| 812 | + end | ||
| 813 | + end | ||
| 814 | + self:updateProperty({field="weekShop", value= weekShop}) | ||
| 815 | +end | ||
| 816 | + | ||
| 551 | function Store:data() | 817 | function Store:data() | 
| 552 | self:OnTriggerLimitTimePackAfterTs(TriggerEventType.AfterTs, skynet.timex()) | 818 | self:OnTriggerLimitTimePackAfterTs(TriggerEventType.AfterTs, skynet.timex()) | 
| 553 | return { | 819 | return { | 
| @@ -556,7 +822,6 @@ function Store:data() | @@ -556,7 +822,6 @@ function Store:data() | ||
| 556 | growFund = self:getProperty("growFund"), | 822 | growFund = self:getProperty("growFund"), | 
| 557 | growFundR = self:getProperty("growFundR"), | 823 | growFundR = self:getProperty("growFundR"), | 
| 558 | monthCardEx = self:getProperty("monthCardEx"), | 824 | monthCardEx = self:getProperty("monthCardEx"), | 
| 559 | - smonthCardEx = self:getProperty("smonthCardEx"), | ||
| 560 | battleCard = self:getProperty("battleCard"), | 825 | battleCard = self:getProperty("battleCard"), | 
| 561 | battleFR = self:getProperty("battleFR"), | 826 | battleFR = self:getProperty("battleFR"), | 
| 562 | battleLR = self:getProperty("battleLR"), | 827 | battleLR = self:getProperty("battleLR"), | 
| @@ -567,7 +832,10 @@ function Store:data() | @@ -567,7 +832,10 @@ function Store:data() | ||
| 567 | bpInfo = self:getProperty("bpInfo"), | 832 | bpInfo = self:getProperty("bpInfo"), | 
| 568 | totalRR = self:getProperty("totalRR"), | 833 | totalRR = self:getProperty("totalRR"), | 
| 569 | monthCardId = self:getProperty("monthCardId"), | 834 | monthCardId = self:getProperty("monthCardId"), | 
| 570 | - smonthCardId = self:getProperty("smonthCardId"), | 835 | + smonthCards = self:getProperty("smonthCards"), | 
| 836 | + smonthCardReceive = self:getProperty("smonthCardReceive"), | ||
| 837 | + dailyShop = self:getProperty("dailyShop"), | ||
| 838 | + weekShop = self:getProperty("weekShop"), | ||
| 571 | } | 839 | } | 
| 572 | end | 840 | end | 
| 573 | 841 | 
src/shared/ModelBaseMysql.lua
| @@ -2,6 +2,8 @@ local ModelBaseMysql = class("ModelBaseMysql") | @@ -2,6 +2,8 @@ local ModelBaseMysql = class("ModelBaseMysql") | ||
| 2 | ModelBaseMysql.key = "key" | 2 | ModelBaseMysql.key = "key" | 
| 3 | ModelBaseMysql.schema = {} | 3 | ModelBaseMysql.schema = {} | 
| 4 | 4 | ||
| 5 | +local mysqlproxy = require "shared.mysqlproxy" | ||
| 6 | + | ||
| 5 | local string_format = string.format | 7 | local string_format = string.format | 
| 6 | local table_insert = table.insert | 8 | local table_insert = table.insert | 
| 7 | local table_unpack = table.unpack | 9 | local table_unpack = table.unpack |