Commit 95d3923ec332094d359b6480837a0143d4234fe5
Merge branch 'cn/develop' into cn/publish/preview
Showing
16 changed files
with
506 additions
and
117 deletions
Show diff stats
src/ProtocolCode.lua
| @@ -222,6 +222,7 @@ actionCodes = { | @@ -222,6 +222,7 @@ actionCodes = { | ||
| 222 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 | 222 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 |
| 223 | Store_getExploreCommandRewardRpc = 563, --探索指令 | 223 | Store_getExploreCommandRewardRpc = 563, --探索指令 |
| 224 | Store_getTotalRechargeAwardRpc = 564, -- 累计充值 | 224 | Store_getTotalRechargeAwardRpc = 564, -- 累计充值 |
| 225 | + Store_monthCardRewardRpc = 565, --每日月卡+特刊奖励 | ||
| 225 | 226 | ||
| 226 | Store_biliCloudRechargeRpc = 596, | 227 | Store_biliCloudRechargeRpc = 596, |
| 227 | Store_biliAndroidRechargeRpc = 597, | 228 | Store_biliAndroidRechargeRpc = 597, |
| @@ -259,6 +260,7 @@ actionCodes = { | @@ -259,6 +260,7 @@ actionCodes = { | ||
| 259 | Activity_buyBattleCommandLvlRpc = 672, | 260 | Activity_buyBattleCommandLvlRpc = 672, |
| 260 | Activity_returnerTaskRpc = 673, | 261 | Activity_returnerTaskRpc = 673, |
| 261 | Activity_actNewUserTaskRpc = 674, | 262 | Activity_actNewUserTaskRpc = 674, |
| 263 | + Activity_buyBattleTicketRpc = 675, | ||
| 262 | 264 | ||
| 263 | Radio_startQuestRpc = 700, | 265 | Radio_startQuestRpc = 700, |
| 264 | Radio_finishQuestRpc = 701, | 266 | 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,9 +626,7 @@ function _M.startBattleRpc(agent, data) | @@ -627,9 +626,7 @@ 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() |
| @@ -644,23 +641,26 @@ function _M.startBattleRpc(agent, data) | @@ -644,23 +641,26 @@ function _M.startBattleRpc(agent, data) | ||
| 644 | end | 641 | end |
| 645 | local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) | 642 | 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))) | 643 | SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change))) |
| 644 | + changeFlag = true | ||
| 645 | + actData["ticket"] = ticket - num | ||
| 647 | 646 | ||
| 648 | - if battleCfg.worldBoss_award ~= 0 and (bi["maxP"] or 0) > 0 then | ||
| 649 | - bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] * count | 647 | + if battleCfg.rank ~= 0 then |
| 648 | + if battleCfg.worldBoss_award ~= 0 and (bi["maxP"] or 0) > 0 then | ||
| 649 | + bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] * count | ||
| 650 | + end | ||
| 651 | + | ||
| 652 | + bi["sum"] = bi["sum"] + bi["top"] * count | ||
| 653 | + actData[id] = bi | ||
| 654 | + | ||
| 655 | + local rankVal = 0 | ||
| 656 | + if battleCfg.rank == 1 then | ||
| 657 | + rankVal = bi["sum"] | ||
| 658 | + elseif battleCfg.rank == 2 then | ||
| 659 | + rankVal = bi["top"] | ||
| 660 | + end | ||
| 661 | + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | ||
| 650 | end | 662 | end |
| 651 | 663 | ||
| 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 | 664 | end |
| 665 | if changeFlag then | 665 | if changeFlag then |
| 666 | role.activity:updateActData("ChallengeLevel", actData) | 666 | role.activity:updateActData("ChallengeLevel", actData) |
| @@ -1466,4 +1466,30 @@ function _M.returnerTaskRpc(agent, data) | @@ -1466,4 +1466,30 @@ function _M.returnerTaskRpc(agent, data) | ||
| 1466 | return true | 1466 | return true |
| 1467 | end | 1467 | end |
| 1468 | 1468 | ||
| 1469 | +function _M.buyBattleTicketRpc(agent, data) | ||
| 1470 | + local role = agent.role | ||
| 1471 | + local msg = MsgPack.unpack(data) | ||
| 1472 | + local actid = msg.actid | ||
| 1473 | + local count = msg.count | ||
| 1474 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | ||
| 1475 | + role.activity:getBattleTicket(actid) | ||
| 1476 | + local actData = role.activity:getActData("ChallengeLevel") or {} | ||
| 1477 | + local battleInfo = actData[id] or {} | ||
| 1478 | + --["activity_scrofa_tickets"] = { 10, 20, 30, 40, 50, 100, 150, 200, 200, 200 } | ||
| 1479 | + local limit = #(globalCsv.activity_scrofa_tickets) | ||
| 1480 | + local curCount = actData["buyC"] or 0 | ||
| 1481 | + if count <= 0 or curCount + count > limit then | ||
| 1482 | + return 2 | ||
| 1483 | + end | ||
| 1484 | + local cost = globalCsv.activity_scrofa_tickets[curCount + 1] | ||
| 1485 | + if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end | ||
| 1486 | + role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyActivityBattleTicket", int1 = actid, int2 = count, cint1 = curCount}}) | ||
| 1487 | + actData["ticket"] = (actData["ticket"] or 0) + 1 | ||
| 1488 | + actData["buyC"] = curCount + count | ||
| 1489 | + | ||
| 1490 | + role.activity:updateActData("ChallengeLevel", actData) | ||
| 1491 | + SendPacket(actionCodes.Activity_buyBattleTicketRpc, "") | ||
| 1492 | + return true | ||
| 1493 | +end | ||
| 1494 | + | ||
| 1469 | return _M | 1495 | 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/HangAction.lua
| @@ -128,8 +128,8 @@ local function checkReward(role, isTreasure, carbonId) | @@ -128,8 +128,8 @@ local function checkReward(role, isTreasure, carbonId) | ||
| 128 | --挂机得到的宝藏加入到挂机奖励 | 128 | --挂机得到的宝藏加入到挂机奖励 |
| 129 | if isTreasure or false == true then | 129 | if isTreasure or false == true then |
| 130 | local treasureList= role.dailyData:checkTreasureList(carbonId or hangInfo.carbonId) or {} | 130 | local treasureList= role.dailyData:checkTreasureList(carbonId or hangInfo.carbonId) or {} |
| 131 | - if next(treasureList) ~= nil then | ||
| 132 | - for id, val in pairs(treasureList) do | 131 | + if next(treasureList) then |
| 132 | + for _, val in pairs(treasureList) do | ||
| 133 | local award = val.award:toNumMap() | 133 | local award = val.award:toNumMap() |
| 134 | for k,v in pairs(award) do | 134 | for k,v in pairs(award) do |
| 135 | items[k] = (items[k] or 0) + v | 135 | items[k] = (items[k] or 0) + v |
src/actions/HeroAction.lua
| @@ -1089,6 +1089,16 @@ function _M.drawHeroRpc(agent, data) | @@ -1089,6 +1089,16 @@ function _M.drawHeroRpc(agent, data) | ||
| 1089 | end | 1089 | end |
| 1090 | role:finishGuide(8) | 1090 | role:finishGuide(8) |
| 1091 | 1091 | ||
| 1092 | + --每次抽卡获得对应货币,可在招募商城购买道具 | ||
| 1093 | + if buildTypeData["draw_type_item"] ~= 0 then | ||
| 1094 | + local drawTypeItem = {} | ||
| 1095 | + for id, count in pairs(buildTypeData["draw_type_item"]:toNumMap()) do | ||
| 1096 | + drawTypeItem[id] = count * drawCount[drawType] | ||
| 1097 | + drawAddReward[id] = drawTypeItem[id] | ||
| 1098 | + end | ||
| 1099 | + role:award(drawTypeItem, {log = {desc = "drawHero", int1 = btype}}) | ||
| 1100 | + end | ||
| 1101 | + | ||
| 1092 | role:log("gacha", { | 1102 | role:log("gacha", { |
| 1093 | gacha_id = poolId, -- 卡池ID | 1103 | gacha_id = poolId, -- 卡池ID |
| 1094 | gacha_type = btype, -- 卡池类型 | 1104 | gacha_type = btype, -- 卡池类型 |
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 |
src/actions/StoreAction.lua
| @@ -547,4 +547,32 @@ function _M.getTotalRechargeAwardRpc(agent, data) | @@ -547,4 +547,32 @@ function _M.getTotalRechargeAwardRpc(agent, data) | ||
| 547 | return true | 547 | return true |
| 548 | end | 548 | end |
| 549 | 549 | ||
| 550 | +function _M.monthCardRewardRpc(agent, data) | ||
| 551 | + local role = agent.role | ||
| 552 | + local msg = MsgPack.unpack(data) | ||
| 553 | + local mcid = msg.mcid | ||
| 554 | + local smcid = msg.smcid | ||
| 555 | + | ||
| 556 | + local reward,change = {}, {} | ||
| 557 | + --月卡奖励 | ||
| 558 | + local tmpreward, tmpchange = role.storeData:getMonthCardDailyReward(mcid) | ||
| 559 | + if tmpreward then | ||
| 560 | + for k, v in pairs(tmpreward) do | ||
| 561 | + reward[k] = (reward[k] or 0) + v | ||
| 562 | + end | ||
| 563 | + if tmpchange then table.insert(change, tmpchange) end | ||
| 564 | + end | ||
| 565 | + | ||
| 566 | + --特刊奖励 | ||
| 567 | + tmpreward, tmpchange = role.storeData:getSMonthCardDailyReward(smcid) | ||
| 568 | + if tmpreward then | ||
| 569 | + for k, v in pairs(tmpreward) do | ||
| 570 | + reward[k] = (reward[k] or 0) + v | ||
| 571 | + end | ||
| 572 | + if tmpchange then table.insert(change, tmpchange) end | ||
| 573 | + end | ||
| 574 | + SendPacket(actionCodes.Store_monthCardRewardRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 575 | + return true | ||
| 576 | +end | ||
| 577 | + | ||
| 550 | return _M | 578 | return _M |
| 551 | \ No newline at end of file | 579 | \ No newline at end of file |
src/adv/Adv.lua
| @@ -930,18 +930,16 @@ function Adv:over(success, rewardRatio, overType) | @@ -930,18 +930,16 @@ function Adv:over(success, rewardRatio, overType) | ||
| 930 | local team = self.owner:getProperty("advTeam") | 930 | local team = self.owner:getProperty("advTeam") |
| 931 | local player = {} | 931 | local player = {} |
| 932 | local attrs = self.owner:getTeamBattleInfo(team).heros | 932 | 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] | 933 | + for _, hero in pairs(attrs) do |
| 934 | + --根据系数计算拾荒属性 | ||
| 935 | + self.owner:checkPlayerAttr(hero) | ||
| 936 | + | ||
| 937 | + for attrName, _ in pairs(AdvAttsEnum) do | ||
| 938 | + player[attrName] = (player[attrName] or 0) + hero[attrName] | ||
| 936 | end | 939 | end |
| 937 | - player[attrName] = player[attrName] * (globalCsv.adv_battle_attr_ratio[attrName] or 1) | ||
| 938 | end | 940 | end |
| 939 | 941 | ||
| 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"] | 942 | + local battleV = self.owner:getSurvivability(player, #attrs) |
| 945 | 943 | ||
| 946 | local heroList = {team.leader, team.leader2} | 944 | local heroList = {team.leader, team.leader2} |
| 947 | for _, hid in pairs(team.heros) do | 945 | for _, hid in pairs(team.heros) do |
| @@ -1714,7 +1712,7 @@ local function clickTrader(self, room, block, params) | @@ -1714,7 +1712,7 @@ local function clickTrader(self, room, block, params) | ||
| 1714 | local goodsData = csvdb["event_trader_goodsCsv"][block.event.shop[buyId][1]] | 1712 | local goodsData = csvdb["event_trader_goodsCsv"][block.event.shop[buyId][1]] |
| 1715 | if not goodsData then return false, 5 end | 1713 | if not goodsData then return false, 5 end |
| 1716 | 1714 | ||
| 1717 | - local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) | 1715 | + 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 --不够 | 1716 | 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}) | 1717 | self:backCost({[goodsData.currency] = costCount}) |
| 1720 | self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}, {}) | 1718 | 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/Daily.lua
| @@ -170,26 +170,25 @@ function Daily:checkChapters() | @@ -170,26 +170,25 @@ function Daily:checkChapters() | ||
| 170 | local chapters = {} | 170 | local chapters = {} |
| 171 | local tmp_chapters = {} | 171 | local tmp_chapters = {} |
| 172 | local treasureList = self:getProperty("treasureList") | 172 | local treasureList = self:getProperty("treasureList") |
| 173 | - if next(treasureList) ~= nil then | ||
| 174 | - for id, curInfo in pairs(treasureList) do | ||
| 175 | - if curInfo["end_time"] then | ||
| 176 | - if skynet.timex() < curInfo["end_time"] then | ||
| 177 | - tmp_chapters[curInfo.chapter_id] = curInfo | ||
| 178 | - end | 173 | + if next(treasureList) then |
| 174 | + for _, curInfo in pairs(treasureList) do | ||
| 175 | + if curInfo["expire_time"] or not curInfo["end_time"] then | ||
| 176 | + tmp_chapters[curInfo.chapter_id] = curInfo | ||
| 179 | end | 177 | end |
| 180 | end | 178 | end |
| 181 | end | 179 | end |
| 182 | - | 180 | + local hangInfo = self.owner:getProperty("hangInfo") or {} |
| 183 | for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do | 181 | for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do |
| 184 | - if self.owner:checkHangPass(chapter_id) then | ||
| 185 | - if next(tmp_chapters) == nil then | ||
| 186 | - chapters[chapter_id] = val | ||
| 187 | - else | ||
| 188 | - if not tmp_chapters[chapter_id] then | 182 | + if chapter_id ~= hangInfo.carbonId then |
| 183 | + if self.owner:checkHangPass(chapter_id) then | ||
| 184 | + if next(tmp_chapters) and not tmp_chapters[chapter_id] then | ||
| 185 | + chapters[chapter_id] = val | ||
| 186 | + else | ||
| 189 | chapters[chapter_id] = val | 187 | chapters[chapter_id] = val |
| 190 | end | 188 | end |
| 191 | end | 189 | end |
| 192 | end | 190 | end |
| 191 | + | ||
| 193 | end | 192 | end |
| 194 | return chapters | 193 | return chapters |
| 195 | end | 194 | end |
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,8 @@ local ItemReason = { | @@ -63,6 +63,8 @@ local ItemReason = { | ||
| 63 | giftTime = 147, -- 创角后的时间礼包 | 63 | giftTime = 147, -- 创角后的时间礼包 |
| 64 | activityCrisis = 148, -- 物资危机奖励 | 64 | activityCrisis = 148, -- 物资危机奖励 |
| 65 | glodConvertRune = 149, -- 金币兑换铭文 | 65 | glodConvertRune = 149, -- 金币兑换铭文 |
| 66 | + monthCardReward = 150, --月卡奖励 | ||
| 67 | + smonthCardReward = 151, --特刊奖励 | ||
| 66 | 68 | ||
| 67 | advHang = 301, -- 拾荒挂机 | 69 | advHang = 301, -- 拾荒挂机 |
| 68 | hangBattle = 302, -- 挂机战斗 | 70 | hangBattle = 302, -- 挂机战斗 |
| @@ -107,6 +109,7 @@ local ItemReason = { | @@ -107,6 +109,7 @@ local ItemReason = { | ||
| 107 | actMilecrisis = 1010, -- 物资危机 | 109 | actMilecrisis = 1010, -- 物资危机 |
| 108 | battleCommandTask = 1011, -- 将军令任务 | 110 | battleCommandTask = 1011, -- 将军令任务 |
| 109 | newUserTask = 1012, -- 新玩家任务 | 111 | newUserTask = 1012, -- 新玩家任务 |
| 112 | + buyActivityBattleTicket = 1013, -- 购买门票 | ||
| 110 | 113 | ||
| 111 | -- 餐厅 | 114 | -- 餐厅 |
| 112 | greenHourse = 1101, -- 食材获得 | 115 | greenHourse = 1101, -- 食材获得 |
| @@ -391,7 +394,15 @@ local MethodType = { | @@ -391,7 +394,15 @@ local MethodType = { | ||
| 391 | currency_type = true, -- 购买道具消耗的货币类型,记录货币ID | 394 | currency_type = true, -- 购买道具消耗的货币类型,记录货币ID |
| 392 | shop_purchase_current = true, -- 购买道具消耗的货币数量 | 395 | shop_purchase_current = true, -- 购买道具消耗的货币数量 |
| 393 | shop_id = true, -- 商店ID | 396 | shop_id = true, -- 商店ID |
| 394 | - }, | 397 | + }, |
| 398 | + month_card = { --月卡+特刊奖励 | ||
| 399 | + item_type = true, --月卡 1, 特刊 2 | ||
| 400 | + item_id = true, --月卡id | ||
| 401 | + before_ex = true, --未领取奖励前的期 | ||
| 402 | + cur_ex = true, --剩余期数 | ||
| 403 | + reward_time = true, --奖励时间 | ||
| 404 | + month_reward_detail = "json", --奖励物品 {'itemid1':123,'itemid2':456,………...} | ||
| 405 | + }, | ||
| 395 | --[[ | 406 | --[[ |
| 396 | 100 添加好友 | 407 | 100 添加好友 |
| 397 | 200 删除好友 | 408 | 200 删除好友 |
src/models/RolePlugin.lua
| @@ -2328,7 +2328,6 @@ function RolePlugin.bind(Role) | @@ -2328,7 +2328,6 @@ function RolePlugin.bind(Role) | ||
| 2328 | return rechargeId | 2328 | return rechargeId |
| 2329 | end | 2329 | end |
| 2330 | 2330 | ||
| 2331 | - | ||
| 2332 | function Role:recharge(params) | 2331 | function Role:recharge(params) |
| 2333 | local id = tonumber(params.id) | 2332 | local id = tonumber(params.id) |
| 2334 | local rechargeData = csvdb["shop_rechargeCsv"][id] | 2333 | local rechargeData = csvdb["shop_rechargeCsv"][id] |
| @@ -2353,8 +2352,16 @@ function RolePlugin.bind(Role) | @@ -2353,8 +2352,16 @@ function RolePlugin.bind(Role) | ||
| 2353 | end | 2352 | end |
| 2354 | self:gainDiamond({count = diamondCount, isRecharge = true, sid = params.sid, log = {desc = "recharge", int1 = id}}) | 2353 | self:gainDiamond({count = diamondCount, isRecharge = true, sid = params.sid, log = {desc = "recharge", int1 = id}}) |
| 2355 | elseif rechargeData.shop == 2 then --通行证商店 | 2354 | elseif rechargeData.shop == 2 then --通行证商店 |
| 2355 | + --订阅奖励 | ||
| 2356 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 2356 | 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) | 2357 | + |
| 2358 | + --签收奖励 | ||
| 2359 | + local tmpreward, _ = self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) | ||
| 2360 | + if tmpreward then | ||
| 2361 | + for k, v in pairs(tmpreward) do | ||
| 2362 | + reward[k] = (reward[k] or 0) + v | ||
| 2363 | + end | ||
| 2364 | + end | ||
| 2358 | elseif rechargeData.shop == 3 then -- 礼包商店 | 2365 | elseif rechargeData.shop == 3 then -- 礼包商店 |
| 2359 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 2366 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) |
| 2360 | else | 2367 | else |
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, ["openFlag"]= 1}} buyCount: 购买次数,periods: 剩余期数,openFlag: 是否开放标识 | ||
| 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,106 @@ function Store:updateProperty(params) | @@ -82,9 +77,106 @@ 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 BuyMonthCard = {} | ||
| 102 | + BuyMonthCard["renewal"]= function() | ||
| 103 | + --续刊 | ||
| 104 | + if self:isMonthCardExpire() then return false end | ||
| 105 | + | ||
| 106 | + local smonthCard = smonthCards[id] or {} | ||
| 107 | + if next(smonthCard) then | ||
| 108 | + local rechargeData = csvdb["shop_rechargeCsv"][id] or {} | ||
| 109 | + local buyCount = smonthCard["buyCount"] or 0 | ||
| 110 | + if buyCount >= (rechargeData["limit"] or 3) then return false end | ||
| 111 | + | ||
| 112 | + smonthCard["buyCount"] = (smonthCard["buyCount"] or 0) + 1 | ||
| 113 | + | ||
| 114 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 115 | + local periods = SuperMonthCard["periods"](self, id) + (card["cardPlusPeriods"] or 30) | ||
| 116 | + smonthCard["periods"] = periods | ||
| 117 | + | ||
| 118 | + self:updateProperty({filed = "smonthCards", value = smonthCards}) | ||
| 119 | + return true | ||
| 120 | + end | ||
| 121 | + end | ||
| 122 | + BuyMonthCard["order"] = function() | ||
| 123 | + --增刊条件 + 标识 | ||
| 124 | + for _, val in pairs(smonthCards) do | ||
| 125 | + val["openFlag"] = 0 | ||
| 126 | + end | ||
| 127 | + | ||
| 128 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 129 | + if (card["cardPlusFlag"] or 0) ~= 1 then return false end | ||
| 130 | + | ||
| 131 | + --判断是否购买过增刊条件里的特刊 | ||
| 132 | + | ||
| 133 | + local cardPlusCondition = card["cardPlusCondition"] or 0 | ||
| 134 | + if self:isMonthCardExpire() or smonthCards[cardPlusCondition] == nil then return false end | ||
| 135 | + | ||
| 136 | + local smonthCard = {["periods"] = (card["cardPlusPeriods"] or 30), ["buyCount"] = 1, ["openFlag"] = 1 } | ||
| 137 | + smonthCards[id] = smonthCard | ||
| 138 | + | ||
| 139 | + self:updateProperty({filed = "smonthCards", value = smonthCards}) | ||
| 140 | + return true | ||
| 141 | + end | ||
| 142 | + | ||
| 143 | + if SuperMonthCard["isExpired"](self, id) then | ||
| 144 | + local smonthCard = smonthCards[id] or {} | ||
| 145 | + if next(smonthCard) then | ||
| 146 | + return BuyMonthCard["renewal"]() | ||
| 147 | + else | ||
| 148 | + return BuyMonthCard["order"]() | ||
| 149 | + end | ||
| 150 | + else | ||
| 151 | + return BuyMonthCard["renewal"]() | ||
| 152 | + end | ||
| 153 | +end | ||
| 154 | + | ||
| 155 | +SuperMonthCard["periods"] = function(self, id) | ||
| 156 | + local smonthCards = self:getProperty("smonthCards") or {} | ||
| 157 | + local smonthCard = smonthCards[id] or {} | ||
| 158 | + return smonthCard["periods"] or 0 | ||
| 159 | +end | ||
| 160 | + | ||
| 161 | +SuperMonthCard["isExpired"] = function (self, id) | ||
| 162 | + local periods = SuperMonthCard["periods"](self, id) | ||
| 163 | + return periods == 0 | ||
| 164 | +end | ||
| 165 | + | ||
| 166 | +SuperMonthCard["itemDaily"] = function(self, id) | ||
| 167 | + local cur_ex = SuperMonthCard["periods"](self, id) | ||
| 168 | + if cur_ex == 0 then return nil, nil end | ||
| 169 | + cur_ex = cur_ex - 1 | ||
| 170 | + | ||
| 171 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 172 | + local reward, change = self.owner:award(card["itemDaily"], {log = {desc = "smonthCardReward", int1 = id, int2 = cur_ex}}) | ||
| 173 | + | ||
| 174 | + local smonthCards = self:getProperty("smonthCards") or {} | ||
| 175 | + local smonthCard = smonthCards[id] or {} | ||
| 176 | + smonthCard["periods"] = cur_ex | ||
| 177 | + self:updateProperty({field = "smonthCards", value = smonthCards}) | ||
| 178 | + | ||
| 179 | + return reward, change, cur_ex | ||
| 88 | end | 180 | end |
| 89 | 181 | ||
| 90 | -- 删除过期商品 | 182 | -- 删除过期商品 |
| @@ -139,15 +231,11 @@ function Store:sendMonthCardEmail() | @@ -139,15 +231,11 @@ function Store:sendMonthCardEmail() | ||
| 139 | end | 231 | end |
| 140 | 232 | ||
| 141 | function Store:isMonthCardExpire() | 233 | function Store:isMonthCardExpire() |
| 142 | - local timeNow = skynet.timex() | ||
| 143 | - local ts = self:getProperty("monthCardEx") | ||
| 144 | - return ts < timeNow | 234 | + return self:getProperty("monthCardEx") == 0 |
| 145 | end | 235 | end |
| 146 | 236 | ||
| 147 | -function Store:isSuperMonthCardExpire() | ||
| 148 | - local timeNow = skynet.timex() | ||
| 149 | - local ts = self:getProperty("smonthCardEx") | ||
| 150 | - return ts < timeNow | 237 | +function Store:isSuperMonthCardExpire(id) |
| 238 | + return false | ||
| 151 | end | 239 | end |
| 152 | 240 | ||
| 153 | function Store:isPrivCardExpire() | 241 | function Store:isPrivCardExpire() |
| @@ -225,23 +313,97 @@ function Store:getCurMonthCardLvl(isSuper) | @@ -225,23 +313,97 @@ function Store:getCurMonthCardLvl(isSuper) | ||
| 225 | return cfg.level or 0 | 313 | return cfg.level or 0 |
| 226 | end | 314 | end |
| 227 | 315 | ||
| 316 | +--获取月卡每日奖励 | ||
| 317 | +function Store:getMonthCardDailyReward(id) | ||
| 318 | + if self:isMonthCardExpire() or self:getProperty("monthCardReceive") == 1 then return nil, nil end | ||
| 319 | + | ||
| 320 | + local before_ex = self:getProperty("monthCardEx") | ||
| 321 | + self:updateProperty({field = "monthCardEx", delta = -1}) | ||
| 322 | + local cur_ex = self:getProperty("monthCardEx") | ||
| 323 | + | ||
| 324 | + local actCfg = csvdb["shop_card"][id] or {} | ||
| 325 | + local award = actCfg.itemDaily:toNumMap() | ||
| 326 | + local reward, change = self.owner:award(award, {log = {desc = "monthCardReward", int1 = id, int2 = cur_ex}}) | ||
| 327 | + | ||
| 328 | + --今日月卡奖励已经领取 | ||
| 329 | + self:updateProperty({field = "monthCardReceive", value = 1}) | ||
| 330 | + | ||
| 331 | + self.owner:log("month_card", { | ||
| 332 | + item_type = CardType.NormalMonthCard, | ||
| 333 | + item_id = id, --月卡id | ||
| 334 | + before_ex = before_ex, --未领取奖励前的期 | ||
| 335 | + cur_ex = cur_ex, --剩余期数 | ||
| 336 | + reward_time = skynet.timex(), --奖励时间 | ||
| 337 | + month_reward_detail = reward, | ||
| 338 | + }) | ||
| 339 | + return reward, change | ||
| 340 | +end | ||
| 341 | + | ||
| 342 | +--获取特刊每日奖励 | ||
| 343 | +function Store:getSMonthCardDailyReward(id) | ||
| 344 | + local before_ex = SuperMonthCard["periods"](self, id) | ||
| 345 | + local reward, change, cur_ex= SuperMonthCard["itemDaily"](self, id) | ||
| 346 | + | ||
| 347 | + --今日特刊奖励已经领取 | ||
| 348 | + self:updateProperty({field = "smonthCardReceive", value = 1}) | ||
| 349 | + | ||
| 350 | + self.owner:log("month_card", { | ||
| 351 | + item_type = CardType.SuperMonthCard, | ||
| 352 | + item_id = id, --月卡id | ||
| 353 | + before_ex = before_ex, --未领取奖励前的期 | ||
| 354 | + cur_ex = cur_ex, --剩余期数 | ||
| 355 | + reward_time = skynet.timex(), --奖励时间 | ||
| 356 | + month_reward_detail = reward, | ||
| 357 | + }) | ||
| 358 | + return reward, change | ||
| 359 | +end | ||
| 360 | + | ||
| 361 | +function Store:firstBuyMonthCard(id) | ||
| 362 | + if self:getProperty("firstMonthCard") == 1 then | ||
| 363 | + self:updateProperty({field = "firstMonthCard", value = 0}) | ||
| 364 | + local card = csvdb["shop_cardCsv"][id] or {} | ||
| 365 | + return self:award(card["cardFirst"], {log = {desc = "monthCardReward", int1 = id, int2 = 30}}) | ||
| 366 | + end | ||
| 367 | + return nil | ||
| 368 | +end | ||
| 369 | + | ||
| 228 | -- 购买通行证 | 370 | -- 购买通行证 |
| 229 | function Store:onBuyCard(type, duration, id, actid) | 371 | function Store:onBuyCard(type, duration, id, actid) |
| 230 | local timeNow = skynet.timex() | 372 | local timeNow = skynet.timex() |
| 231 | if type == CardType.NormalMonthCard then | 373 | if type == CardType.NormalMonthCard then |
| 232 | if self:isMonthCardExpire() then | 374 | if self:isMonthCardExpire() then |
| 233 | self:updateProperty({field = "monthCardId", value = id}) | 375 | 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 | 376 | end |
| 238 | - self:sendMonthCardEmail() | 377 | + self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + 30}) |
| 378 | + | ||
| 379 | + --初回特典 仅首次购买月卡时赠送SSR级角色"拉塔托娅" | ||
| 380 | + local reward = {} | ||
| 381 | + local tmpreward, _ = self:firstBuyMonthCard(id) | ||
| 382 | + if tmpreward then | ||
| 383 | + for k, v in pairs(tmpreward) do | ||
| 384 | + reward[k] = (reward[k] or 0) + v | ||
| 385 | + end | ||
| 386 | + end | ||
| 387 | + | ||
| 388 | + --签收奖励 | ||
| 389 | + tmpreward, _= self:getMonthCardDailyReward(id) | ||
| 390 | + if tmpreward then | ||
| 391 | + for k, v in pairs(tmpreward) do | ||
| 392 | + reward[k] = (reward[k] or 0) + v | ||
| 393 | + end | ||
| 394 | + end | ||
| 395 | + return reward | ||
| 396 | + elseif type == CardType.SuperMonthCard then | ||
| 397 | + if SuperMonthCard["buy"](self, id) then | ||
| 398 | + return self:getSMonthCardDailyReward(id) | ||
| 399 | + end | ||
| 400 | + return nil, nil | ||
| 239 | elseif type == CardType.NormalMonthCardLevelUp then | 401 | elseif type == CardType.NormalMonthCardLevelUp then |
| 240 | if self:isMonthCardExpire() then | 402 | if self:isMonthCardExpire() then |
| 241 | skynet.error(string.format("month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | 403 | skynet.error(string.format("month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) |
| 242 | else | 404 | else |
| 243 | local cfg = csvdb["shop_cardCsv"][id] | 405 | local cfg = csvdb["shop_cardCsv"][id] |
| 244 | - if not cfg then return end | 406 | + if not cfg then return end |
| 245 | local dif = cfg.level - self:getCurMonthCardLvl(false) | 407 | local dif = cfg.level - self:getCurMonthCardLvl(false) |
| 246 | if dif > 1 and dif < 0 then | 408 | if dif > 1 and dif < 0 then |
| 247 | return | 409 | return |
| @@ -250,20 +412,13 @@ function Store:onBuyCard(type, duration, id, actid) | @@ -250,20 +412,13 @@ function Store:onBuyCard(type, duration, id, actid) | ||
| 250 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) | 412 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) |
| 251 | end | 413 | end |
| 252 | self:sendMonthCardEmail() | 414 | 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() | 415 | + |
| 261 | elseif type == CardType.SuperMonthCardLevelUp then | 416 | elseif type == CardType.SuperMonthCardLevelUp then |
| 262 | if self:isSuperMonthCardExpire() then | 417 | if self:isSuperMonthCardExpire() then |
| 263 | skynet.error(string.format("super month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | 418 | skynet.error(string.format("super month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) |
| 264 | else | 419 | else |
| 265 | local cfg = csvdb["shop_cardCsv"][id] | 420 | local cfg = csvdb["shop_cardCsv"][id] |
| 266 | - if not cfg then return end | 421 | + if not cfg then return end |
| 267 | local dif = cfg.level - self:getCurMonthCardLvl(true) | 422 | local dif = cfg.level - self:getCurMonthCardLvl(true) |
| 268 | if dif > 1 and dif < 0 then | 423 | if dif > 1 and dif < 0 then |
| 269 | return | 424 | return |
| @@ -306,6 +461,7 @@ function Store:onBuyCard(type, duration, id, actid) | @@ -306,6 +461,7 @@ function Store:onBuyCard(type, duration, id, actid) | ||
| 306 | self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0}) | 461 | self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0}) |
| 307 | self.owner.activity:updateActData("BattleCommand", actData) | 462 | self.owner.activity:updateActData("BattleCommand", actData) |
| 308 | end | 463 | end |
| 464 | + return nil, nil | ||
| 309 | end | 465 | end |
| 310 | 466 | ||
| 311 | --检测购买是否超过限制数量 | 467 | --检测购买是否超过限制数量 |
| @@ -548,6 +704,88 @@ function Store:OnTriggerLimitTimePackAfterTs(eventType, param) | @@ -548,6 +704,88 @@ function Store:OnTriggerLimitTimePackAfterTs(eventType, param) | ||
| 548 | end | 704 | end |
| 549 | end | 705 | end |
| 550 | 706 | ||
| 707 | +local function checkShopFinish(shop, shopPool) | ||
| 708 | + local tmpShop = shopPool[shop.id] or {} | ||
| 709 | + if next(tmpShop) then | ||
| 710 | + if tmpShop.expire_ts then | ||
| 711 | + if skynet.timex() > tmpShop.expire_ts then | ||
| 712 | + shopPool[shop.id] = nil | ||
| 713 | + return true | ||
| 714 | + else | ||
| 715 | + return false | ||
| 716 | + end | ||
| 717 | + else | ||
| 718 | + tmpShop.expire_ts = skynet.timex() + tmpShop.cool_time * DAY_SEC | ||
| 719 | + return false | ||
| 720 | + end | ||
| 721 | + else | ||
| 722 | + return true | ||
| 723 | + end | ||
| 724 | +end | ||
| 725 | + | ||
| 726 | +--随机日/周商店随机两个商品 | ||
| 727 | +-- 1. 让缓存里的商品进入冷却时间 | ||
| 728 | +-- 2. 删除缓存里的已经冷却好的商品 | ||
| 729 | +-- 3. 随机两件商品放入缓存中 | ||
| 730 | +function Store:flushDailyShop() | ||
| 731 | + local dailyShop = self:getProperty("dailyShop") or {} | ||
| 732 | + local tmpDailyShop = {} | ||
| 733 | + | ||
| 734 | + for id, data in pairs(csvdb["shop_normalCsv"]) do | ||
| 735 | + if data.shop == 1 and data.shopType == 3 then | ||
| 736 | + if data.resetTime == 1 and checkShopFinish(data, dailyShop) then | ||
| 737 | + tmpDailyShop[id] = {["id"] = data.id, ["weight"] = 100, ["cool_time"] = data.cool_time} | ||
| 738 | + end | ||
| 739 | + end | ||
| 740 | + end | ||
| 741 | + | ||
| 742 | + --随机两件商品放入缓存 跨天刷新 | ||
| 743 | + if next(tmpDailyShop) then | ||
| 744 | + local id = math.randWeight(tmpDailyShop) | ||
| 745 | + if id then | ||
| 746 | + dailyShop[id] = tmpDailyShop[id] | ||
| 747 | + tmpDailyShop[id] = nil | ||
| 748 | + end | ||
| 749 | + | ||
| 750 | + id = math.randWeight(tmpDailyShop) | ||
| 751 | + if id then | ||
| 752 | + dailyShop[id] = tmpDailyShop[id] | ||
| 753 | + tmpDailyShop[id] = nil | ||
| 754 | + end | ||
| 755 | + end | ||
| 756 | + | ||
| 757 | + self:updateProperty({field="dailyShop", value= dailyShop}) | ||
| 758 | +end | ||
| 759 | + | ||
| 760 | +function Store:flushWeekShop() | ||
| 761 | + local weekShop = self:getProperty("weekShop") or {} | ||
| 762 | + local tmpWeekShop = {} | ||
| 763 | + | ||
| 764 | + for id, data in pairs(csvdb["shop_normalCsv"]) do | ||
| 765 | + if data.shop == 1 and data.shopType == 3 then | ||
| 766 | + if data.resetTime == 2 and checkShopFinish(data, weekShop)then | ||
| 767 | + tmpWeekShop[id] = {["id"] = data.id, ["weight"] = 100, ["cool_time"] = data.cool_time} | ||
| 768 | + end | ||
| 769 | + end | ||
| 770 | + end | ||
| 771 | + | ||
| 772 | + --随机两件商品放入缓存 跨周刷新 | ||
| 773 | + if next(tmpWeekShop) then | ||
| 774 | + local id = math.randWeight(tmpWeekShop) | ||
| 775 | + if id then | ||
| 776 | + weekShop[id] = weekShop[id] | ||
| 777 | + tmpWeekShop[id] = nil | ||
| 778 | + end | ||
| 779 | + | ||
| 780 | + id = math.randWeight(tmpWeekShop) | ||
| 781 | + if id then | ||
| 782 | + weekShop[id] = weekShop[id] | ||
| 783 | + tmpWeekShop[id] = nil | ||
| 784 | + end | ||
| 785 | + end | ||
| 786 | + self:updateProperty({field="weekShop", value= weekShop}) | ||
| 787 | +end | ||
| 788 | + | ||
| 551 | function Store:data() | 789 | function Store:data() |
| 552 | self:OnTriggerLimitTimePackAfterTs(TriggerEventType.AfterTs, skynet.timex()) | 790 | self:OnTriggerLimitTimePackAfterTs(TriggerEventType.AfterTs, skynet.timex()) |
| 553 | return { | 791 | return { |
| @@ -556,7 +794,6 @@ function Store:data() | @@ -556,7 +794,6 @@ function Store:data() | ||
| 556 | growFund = self:getProperty("growFund"), | 794 | growFund = self:getProperty("growFund"), |
| 557 | growFundR = self:getProperty("growFundR"), | 795 | growFundR = self:getProperty("growFundR"), |
| 558 | monthCardEx = self:getProperty("monthCardEx"), | 796 | monthCardEx = self:getProperty("monthCardEx"), |
| 559 | - smonthCardEx = self:getProperty("smonthCardEx"), | ||
| 560 | battleCard = self:getProperty("battleCard"), | 797 | battleCard = self:getProperty("battleCard"), |
| 561 | battleFR = self:getProperty("battleFR"), | 798 | battleFR = self:getProperty("battleFR"), |
| 562 | battleLR = self:getProperty("battleLR"), | 799 | battleLR = self:getProperty("battleLR"), |
| @@ -567,7 +804,10 @@ function Store:data() | @@ -567,7 +804,10 @@ function Store:data() | ||
| 567 | bpInfo = self:getProperty("bpInfo"), | 804 | bpInfo = self:getProperty("bpInfo"), |
| 568 | totalRR = self:getProperty("totalRR"), | 805 | totalRR = self:getProperty("totalRR"), |
| 569 | monthCardId = self:getProperty("monthCardId"), | 806 | monthCardId = self:getProperty("monthCardId"), |
| 570 | - smonthCardId = self:getProperty("smonthCardId"), | 807 | + smonthCards = self:getProperty("smonthCards"), |
| 808 | + smonthCardReceive = self:getProperty("smonthCardReceive"), | ||
| 809 | + dailyShop = self:getProperty("dailyShop"), | ||
| 810 | + weekShop = self:getProperty("weekShop"), | ||
| 571 | } | 811 | } |
| 572 | end | 812 | end |
| 573 | 813 |