Compare View
Commits (11)
-
# Conflicts: # src/ProtocolCode.lua # src/actions/HeroAction.lua # src/models/RoleLog.lua
Showing
14 changed files
Show diff stats
src/ProtocolCode.lua
| ... | ... | @@ -67,6 +67,8 @@ actionCodes = { |
| 67 | 67 | Role_itemConvertDevilTicketRpc = 148, -- 兑换魔鬼训练营门票 |
| 68 | 68 | Role_unRegisterRpc = 149, --注销账号 |
| 69 | 69 | Role_searchAllRoleRpc = 150, --查询所有服的角色信息 |
| 70 | + Role_takeTreasureRpc = 151, --抓取额外宝藏 | |
| 71 | + Role_treasureMapRpc = 152, --兑换宝藏图 | |
| 70 | 72 | |
| 71 | 73 | Adv_startAdvRpc = 151, |
| 72 | 74 | Adv_startHangRpc = 152, |
| ... | ... | @@ -121,6 +123,10 @@ actionCodes = { |
| 121 | 123 | Hero_changeSparkRpc = 227, |
| 122 | 124 | Hero_saveGeniusTreeRpc = 228, |
| 123 | 125 | Hero_stickersConvertRpc = 229, --兑换英雄贴纸 |
| 126 | + Hero_trainStartRpc = 230, --开始魔鬼训练 | |
| 127 | + Hero_trainFinishRpc = 231, | |
| 128 | + Hero_trainTaskRewardRpc = 232, --领取魔鬼训练营任务 | |
| 129 | + Hero_trainQuickRpc = 233, --魔鬼训练营加速 | |
| 124 | 130 | |
| 125 | 131 | Hang_startRpc = 251, |
| 126 | 132 | Hang_checkRpc = 252, | ... | ... |
src/actions/GmAction.lua
| ... | ... | @@ -692,19 +692,36 @@ function _M.test(role, pms) |
| 692 | 692 | if id > 100 then |
| 693 | 693 | actid = tonum(pms.pm2, 0) |
| 694 | 694 | end |
| 695 | - --local hero = require ("actions.HeroAction") | |
| 696 | - --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) | |
| 695 | + --if id == 1 then | |
| 696 | + -- local hero = require ("actions.HeroAction") | |
| 697 | + -- local ret = hero.trainStartRpc({role = role}, MsgPack.pack({id = 1})) | |
| 698 | + -- if ret ~= true then | |
| 699 | + -- return ret | |
| 700 | + -- end | |
| 701 | + --elseif id == 2 then | |
| 702 | + -- local hero = require ("actions.HeroAction") | |
| 703 | + -- local ret = hero.trainFinishRpc({role = role}, MsgPack.pack({id = 1})) | |
| 704 | + -- if ret ~= true then | |
| 705 | + -- return ret | |
| 706 | + -- end | |
| 707 | + --elseif id == 3 then | |
| 708 | + -- local hero = require ("actions.HeroAction") | |
| 709 | + -- local ret = hero.trainQuickRpc({role = role}, MsgPack.pack({id = 1})) | |
| 710 | + -- if ret ~= true then | |
| 711 | + -- return ret | |
| 712 | + -- end | |
| 713 | + --end | |
| 697 | 714 | |
| 698 | 715 | --role:sendMail(13, nil, "1=2", {111}) |
| 699 | - local file = io.open("draw_hero_"..id..".csv", "a") | |
| 700 | - for i=1, 10000 do | |
| 701 | - local heroIds = _M.drawHero(role, id, actid) | |
| 702 | - for k, v in ipairs(heroIds) do | |
| 703 | - print((i - 1)* 10 + k, v) | |
| 704 | - file:write(v.."\n") | |
| 705 | - end | |
| 706 | - end | |
| 707 | - io.close(file) | |
| 716 | + --local file = io.open("draw_hero_"..id..".csv", "a") | |
| 717 | + --for i=1, 10000 do | |
| 718 | + -- local heroIds = _M.drawHero(role, id, actid) | |
| 719 | + -- for k, v in ipairs(heroIds) do | |
| 720 | + -- print((i - 1)* 10 + k, v) | |
| 721 | + -- file:write(v.."\n") | |
| 722 | + -- end | |
| 723 | + --end | |
| 724 | + --io.close(file) | |
| 708 | 725 | return "成功" |
| 709 | 726 | end |
| 710 | 727 | |
| ... | ... | @@ -1012,7 +1029,7 @@ function _M.treasure(role, pms) |
| 1012 | 1029 | dump(treasureList) |
| 1013 | 1030 | return "宝藏图鉴" |
| 1014 | 1031 | elseif pm1 == "FLUSH" then |
| 1015 | - local treasureList= role.dailyData:getTreasrueList(role) | |
| 1032 | + local treasureList= role.dailyData:getTreasureList(role) | |
| 1016 | 1033 | dump(treasureList) |
| 1017 | 1034 | return "宝藏图鉴" |
| 1018 | 1035 | elseif pm1 == "CHECK" then |
| ... | ... | @@ -1175,5 +1192,40 @@ function _M.draw_code(role, pms) |
| 1175 | 1192 | return ret |
| 1176 | 1193 | end |
| 1177 | 1194 | |
| 1195 | +table.insert(helpDes, {"抓取额外宝藏", "treasure_extra"}) | |
| 1196 | +function _M.treasure_extra(role, pms) | |
| 1197 | + local extraCount = role.dailyData:getProperty("treasureExtraCount") --每日发现额外宝藏使用次数(累计),隔天清零 | |
| 1198 | + local mapCount = role.dailyData:getProperty("treasureMapCount") | |
| 1199 | + local baseExtra = role.dailyData:getProperty("treasureBaseExtra") | |
| 1200 | + | |
| 1201 | + if extraCount >= globalCsv.idle_treasure_extra_limie then return 1 end | |
| 1202 | + if mapCount <= 0 then return 2 end | |
| 1203 | + | |
| 1204 | + baseExtra = baseExtra + globalCsv.idle_treasure_base_extra | |
| 1205 | + | |
| 1206 | + local tmpTreasure, treasureListExtra = role.dailyData:getTreasureExtra(baseExtra) | |
| 1207 | + | |
| 1208 | + dump(tmpTreasure) | |
| 1209 | + dump(treasureListExtra) | |
| 1210 | + if not tmpTreasure then return 3 end | |
| 1211 | + | |
| 1212 | + role.dailyData:updateProperty({field = "treasureExtraCount", delta = 1}) | |
| 1213 | + role.dailyData:updateProperty({field = "treasureBaseExtra", value = mapCount - 1}) | |
| 1214 | + role.dailyData:updateProperty({field = "treasureBaseExtra", value = baseExtra}) | |
| 1215 | + | |
| 1216 | + return "成功" | |
| 1217 | +end | |
| 1218 | + | |
| 1219 | +table.insert(helpDes, {"兑换宝藏图", "treasure_map"}) | |
| 1220 | +function _M.treasure_map(role, pms) | |
| 1221 | + local count = tonumber(pms.pm1 or 1) | |
| 1222 | + local cost ={[ItemId.Jade] = globalCsv.idle_treasure_buy * count} | |
| 1223 | + if not role:checkItemEnough(cost) then return -1 end | |
| 1224 | + if not role:costItems(cost, {log = {desc = "treasureMap", int1 = count}}) then return -2 end | |
| 1225 | + role.dailyData:updateProperty({field = "treasureMapCount", delta = 1*count}) | |
| 1226 | + | |
| 1227 | + local treasureMapCount = role.dailyData:getProperty("treasureMapCount") | |
| 1228 | + return treasureMapCount | |
| 1229 | +end | |
| 1178 | 1230 | |
| 1179 | 1231 | return _M |
| 1180 | 1232 | \ No newline at end of file | ... | ... |
src/actions/HangAction.lua
| ... | ... | @@ -125,10 +125,18 @@ local function checkReward(role, isTreasure, carbonId) |
| 125 | 125 | randomItem() |
| 126 | 126 | end |
| 127 | 127 | |
| 128 | - --挂机得到的宝藏加入到挂机奖励 | |
| 129 | - if isTreasure or false == true then | |
| 130 | - local treasureList= role.dailyData:checkTreasureList(carbonId or hangInfo.carbonId) or {} | |
| 131 | - for _, val in pairs(treasureList) do | |
| 128 | + --挂机得到的宝藏加入到挂机奖励 + 额外宝藏奖励 | |
| 129 | + if isTreasure then | |
| 130 | + local treasureList= role.dailyData:checkTreasureList(carbonId or hangInfo.carbonId) | |
| 131 | + for _, val in pairs(treasureList or {}) do | |
| 132 | + local award = val.award:toNumMap() | |
| 133 | + for k,v in pairs(award) do | |
| 134 | + items[k] = (items[k] or 0) + v | |
| 135 | + end | |
| 136 | + end | |
| 137 | + | |
| 138 | + treasureList = role.dailyData:checkTreasureListExtra(carbonId or hangInfo.carbonId) | |
| 139 | + for _, val in pairs(treasureList or {}) do | |
| 132 | 140 | local award = val.award:toNumMap() |
| 133 | 141 | for k,v in pairs(award) do |
| 134 | 142 | items[k] = (items[k] or 0) + v |
| ... | ... | @@ -339,7 +347,7 @@ function _M.endBattleRpc(agent, data) |
| 339 | 347 | |
| 340 | 348 | --刷新宝藏图鉴 |
| 341 | 349 | if isWin and globalCsv.idle_treasure_point and globalCsv.idle_treasure_point == carbonId then |
| 342 | - role.dailyData:getTreasrueList() | |
| 350 | + role.dailyData:getTreasureList() | |
| 343 | 351 | end |
| 344 | 352 | |
| 345 | 353 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
| ... | ... | @@ -513,8 +521,17 @@ function _M.quickRpc(agent , data) |
| 513 | 521 | end |
| 514 | 522 | |
| 515 | 523 | --宝藏加速 |
| 516 | - local treasureList = role.dailyData:quickTreasureList(hangInfo.carbonId, time) or {} | |
| 517 | - for id, val in pairs(treasureList) do | |
| 524 | + local treasureList = role.dailyData:quickTreasureList(hangInfo.carbonId, time) | |
| 525 | + for _, val in pairs(treasureList or {}) do | |
| 526 | + local award = val.award:toNumMap() | |
| 527 | + for k,v in pairs(award) do | |
| 528 | + reward[k] = (reward[k] or 0) + v | |
| 529 | + end | |
| 530 | + end | |
| 531 | + | |
| 532 | + --额外宝藏加速 | |
| 533 | + treasureList = role.dailyData:quickTreasureListExtra(hangInfo.carbonId, time) | |
| 534 | + for _, val in pairs(treasureList or {}) do | |
| 518 | 535 | local award = val.award:toNumMap() |
| 519 | 536 | for k,v in pairs(award) do |
| 520 | 537 | reward[k] = (reward[k] or 0) + v | ... | ... |
src/actions/HeroAction.lua
| ... | ... | @@ -117,6 +117,8 @@ function _M.wakeRpc(agent, data) |
| 117 | 117 | local hero = role.heros[msg.id] |
| 118 | 118 | if not hero then return 1 end |
| 119 | 119 | if hero:getProperty("wakeL") >= #csvdb["unit_wakeCsv"] then return 2 end |
| 120 | + if hero:getProperty("trainTs") ~= 0 then return 9 end | |
| 121 | + | |
| 120 | 122 | local typ = hero:getProperty("type") |
| 121 | 123 | local wakeData = csvdb["unit_wakeCsv"][hero:getProperty("wakeL")] |
| 122 | 124 | if not wakeData then return 3 end |
| ... | ... | @@ -180,6 +182,8 @@ function _M.wakeRpc(agent, data) |
| 180 | 182 | |
| 181 | 183 | role:checkTaskEnter("HeroStarCollect", {}) |
| 182 | 184 | role:checkTaskEnter("HeroStartSum", {}) |
| 185 | + role:checkTaskEnter("SSRHeroStarSum", {}) | |
| 186 | + role:checkTaskEnter("SRHeroStarSum", {}) | |
| 183 | 187 | return true |
| 184 | 188 | end |
| 185 | 189 | |
| ... | ... | @@ -1435,4 +1439,166 @@ function _M.stickersConvertRpc(agent, data) |
| 1435 | 1439 | return true |
| 1436 | 1440 | end |
| 1437 | 1441 | |
| 1442 | +function _M.trainStartRpc(agent, data) | |
| 1443 | + local role = agent.role | |
| 1444 | + local msg = MsgPack.unpack(data) | |
| 1445 | + local hero = role.heros[msg.id] | |
| 1446 | + if not hero then return 1 end | |
| 1447 | + local rare = hero:getRare() | |
| 1448 | + if rare ~= HeroQuality.SSR and rare ~= HeroQuality.SR then return 2 end | |
| 1449 | + local trainTimeCfg = (rare == HeroQuality.SSR and globalCsv.training_camp_ssr or globalCsv.training_camp_sr) | |
| 1450 | + local trainCostCfg = (rare == HeroQuality.SSR and globalCsv.training_camp_ssr_cost or globalCsv.training_camp_sr_cost) | |
| 1451 | + dump(trainTimeCfg) | |
| 1452 | + dump(trainCostCfg) | |
| 1453 | + | |
| 1454 | + local curLevel = hero:getProperty("wakeL") | |
| 1455 | + local trainTs = hero:getProperty("trainTs") | |
| 1456 | + local sparkInfo = hero:getProperty("spark") | |
| 1457 | + print(msg.id, rare, curLevel) | |
| 1458 | + if trainTs ~= 0 then return 3 end | |
| 1459 | + | |
| 1460 | + local sec = trainTimeCfg[curLevel] or 0 | |
| 1461 | + if sec == 0 then return 4 end | |
| 1462 | + | |
| 1463 | + if not trainCostCfg[curLevel] then return 10 end | |
| 1464 | + | |
| 1465 | + local costs = trainCostCfg[curLevel]:toNumMap() | |
| 1466 | + | |
| 1467 | + if not role:checkItemEnough(costs) then return 5 end | |
| 1468 | + | |
| 1469 | + -- 大于等于7的时候需要装备火花才能升 | |
| 1470 | + if curLevel >= 7 then | |
| 1471 | + if #sparkInfo == 0 then | |
| 1472 | + return 6 | |
| 1473 | + end | |
| 1474 | + local ok = false | |
| 1475 | + for _, info in ipairs(sparkInfo) do | |
| 1476 | + local cfg = csvdb["sparkCsv"][info.cfg_id][info.level or 0] | |
| 1477 | + if not cfg then return 7 end | |
| 1478 | + if cfg.star == curLevel then | |
| 1479 | + ok = true | |
| 1480 | + break | |
| 1481 | + end | |
| 1482 | + end | |
| 1483 | + if not ok then return 8 end | |
| 1484 | + end | |
| 1485 | + | |
| 1486 | + if not role:costItems(costs, {log = {desc = "trainHero", int1 = hero:getProperty("type")}}) then return 9 end | |
| 1487 | + | |
| 1488 | + hero:updateProperty({field="trainTs", value = skynet.timex() + sec}) | |
| 1489 | + | |
| 1490 | + hero:mylog({desc = "trainHeroStart", int1 = hero:getProperty("type"), int2 = curLevel}) | |
| 1491 | + | |
| 1492 | + SendPacket(actionCodes.Hero_trainStartRpc, '') | |
| 1493 | + | |
| 1494 | + return true | |
| 1495 | +end | |
| 1496 | + | |
| 1497 | +function _M.trainQuickRpc(agent, data) | |
| 1498 | + local role = agent.role | |
| 1499 | + local msg = MsgPack.unpack(data) | |
| 1500 | + local hero = role.heros[msg.id] | |
| 1501 | + if not hero then return 1 end | |
| 1502 | + local trainTs = hero:getProperty("trainTs") | |
| 1503 | + if trainTs == 0 then return 2 end | |
| 1504 | + local timeNow = skynet.timex() | |
| 1505 | + if timeNow >= trainTs then return 3 end | |
| 1506 | + | |
| 1507 | + local h = math.ceil((trainTs - timeNow)/3600) | |
| 1508 | + | |
| 1509 | + local cost = {[ItemId.Jade] = h * (globalCsv.training_camp_quick or 60)} | |
| 1510 | + if not role:checkItemEnough(cost) then return 4 end | |
| 1511 | + | |
| 1512 | + if not role:costItems(cost, {log = {desc = "trainQuickHero", int1 = hero:getProperty("type")}}) then return 9 end | |
| 1513 | + | |
| 1514 | + hero:updateProperty({field="trainTs", value = skynet.timex()}) | |
| 1515 | + | |
| 1516 | + hero:mylog({desc = "trainQuick", int1 = hero:getProperty("type")}) | |
| 1517 | + | |
| 1518 | + SendPacket(actionCodes.Hero_trainQuickRpc, '') | |
| 1519 | + | |
| 1520 | + return true | |
| 1521 | +end | |
| 1522 | + | |
| 1523 | + | |
| 1524 | +function _M.trainFinishRpc(agent, data) | |
| 1525 | + local role = agent.role | |
| 1526 | + local msg = MsgPack.unpack(data) | |
| 1527 | + local hero = role.heros[msg.id] | |
| 1528 | + if not hero then return 1 end | |
| 1529 | + | |
| 1530 | + local curLevel = hero:getProperty("wakeL") | |
| 1531 | + local trainTs = hero:getProperty("trainTs") | |
| 1532 | + local typ = hero:getProperty("type") | |
| 1533 | + if trainTs == 0 then return 2 end | |
| 1534 | + if skynet.timex() < trainTs then return 3 end | |
| 1535 | + | |
| 1536 | + hero:updateProperty({field = "wakeL", delta = 1}) | |
| 1537 | + hero:updateProperty({field = "trainTs", value = 0}) | |
| 1538 | + | |
| 1539 | + curLevel = curLevel + 1 | |
| 1540 | + role:checkTaskEnter("Wake", {heroType = typ, wakeL = curLevel}) | |
| 1541 | + if curLevel == 3 then -- 解锁cg | |
| 1542 | + role:checkTaskEnter("WakeCG", {heroType = typ}) | |
| 1543 | + role:checkTaskEnter("WakeCGSum", {count = 1}) | |
| 1544 | + end | |
| 1545 | + | |
| 1546 | + if curLevel >= 4 then --自动觉醒技能 | |
| 1547 | + local new = hero:increGeniusTree() | |
| 1548 | + hero:updateProperty({field = "genius", value = new}) | |
| 1549 | + end | |
| 1550 | + hero:mylog({desc = "trainFinish", int1 = hero:getProperty("type")}) | |
| 1551 | + | |
| 1552 | + SendPacket(actionCodes.Hero_trainFinishRpc, '') | |
| 1553 | + | |
| 1554 | + role:checkTaskEnter("HeroStarCollect", {}) | |
| 1555 | + role:checkTaskEnter("HeroStartSum", {}) | |
| 1556 | + role:checkTaskEnter("SSRHeroStarSum", {}) | |
| 1557 | + role:checkTaskEnter("SRHeroStarSum", {}) | |
| 1558 | + | |
| 1559 | + return true | |
| 1560 | +end | |
| 1561 | + | |
| 1562 | +function _M.trainTaskRewardRpc(agent, data) | |
| 1563 | + local role = agent.role | |
| 1564 | + local msg = MsgPack.unpack(data) | |
| 1565 | + local taskId = msg.id | |
| 1566 | + local trainTask = role:getProperty("trainTask") or {} | |
| 1567 | + local record = trainTask["r"] or {} | |
| 1568 | + local flag = record[taskId] or 0 | |
| 1569 | + if flag == 1 then return 1 end | |
| 1570 | + local taskCfg = csvdb["training_camp_taskCsv"][taskId] | |
| 1571 | + | |
| 1572 | + if not taskCfg then return 2 end | |
| 1573 | + | |
| 1574 | + --只有类型4的任务可以完成,领取奖励 | |
| 1575 | + if taskCfg.type < 4 then | |
| 1576 | + return 3 | |
| 1577 | + end | |
| 1578 | + | |
| 1579 | + --前置任务1一 | |
| 1580 | + local preTask1 = csvdb["training_camp_taskCsv"][taskCfg.condition1] | |
| 1581 | + if trainTask[preTask1.id] < preTask1.condition1 then | |
| 1582 | + return 4 | |
| 1583 | + end | |
| 1584 | + | |
| 1585 | + --前置任务2一 | |
| 1586 | + local preTask2 = csvdb["training_camp_taskCsv"][taskCfg.condition2] | |
| 1587 | + if trainTask[preTask2.id] < preTask1.condition1 then | |
| 1588 | + return 5 | |
| 1589 | + end | |
| 1590 | + | |
| 1591 | + record[taskId] = 1 | |
| 1592 | + | |
| 1593 | + trainTask["r"] = record | |
| 1594 | + | |
| 1595 | + role:updateProperty({field = "trainTask", value = trainTask}) | |
| 1596 | + | |
| 1597 | + local reward, change = role:award(taskCfg.reward, {log = {desc = "trainTask"}}) | |
| 1598 | + | |
| 1599 | + SendPacket(actionCodes.Hero_trainTaskRewardRpc, MsgPack.pack(role:packReward(reward, change))) | |
| 1600 | + | |
| 1601 | + return true | |
| 1602 | +end | |
| 1603 | + | |
| 1438 | 1604 | return _M | ... | ... |
src/actions/RoleAction.lua
| ... | ... | @@ -185,6 +185,7 @@ function _M.loginRpc( agent, data ) |
| 185 | 185 | role.activity:checkActivityStatus(now, false, false) |
| 186 | 186 | role:log("onLogin") |
| 187 | 187 | end |
| 188 | + role:checkTaskEnter("LoginAddUp", {}) | |
| 188 | 189 | |
| 189 | 190 | redisproxy:zadd(FRIEND_RECOMMEND, now, roleId) |
| 190 | 191 | |
| ... | ... | @@ -357,6 +358,14 @@ function _M.loginRpc( agent, data ) |
| 357 | 358 | end |
| 358 | 359 | end |
| 359 | 360 | |
| 361 | + local hangPass = role:getProperty("hangPass") | |
| 362 | + for _, carbonId in pairs(hangPass) do | |
| 363 | + role:checkTaskEnter("HangPass", {id = carbonId}) | |
| 364 | + end | |
| 365 | + | |
| 366 | + role:checkTaskEnter("SSRHeroStarSum", {}) | |
| 367 | + role:checkTaskEnter("SRHeroStarSum", {}) | |
| 368 | + | |
| 360 | 369 | return true |
| 361 | 370 | end |
| 362 | 371 | |
| ... | ... | @@ -1900,4 +1909,40 @@ function _M.itemConvertDevilTicketRpc(agent, data) |
| 1900 | 1909 | return true |
| 1901 | 1910 | end |
| 1902 | 1911 | |
| 1912 | +function _M.takeTreasureRpc(agent, data) | |
| 1913 | + local role = agent.role | |
| 1914 | + local extraCount = role.dailyData:getProperty("treasureExtraCount") --每日发现额外宝藏使用次数(累计),隔天清零 | |
| 1915 | + local mapCount = role.dailyData:getProperty("treasureMapCount") | |
| 1916 | + local baseExtra = role.dailyData:getProperty("treasureBaseExtra") | |
| 1917 | + | |
| 1918 | + if extraCount >= globalCsv.idle_treasure_extra_limie then return 1 end | |
| 1919 | + if mapCount <= 0 then return 2 end | |
| 1920 | + | |
| 1921 | + baseExtra = baseExtra + globalCsv.idle_treasure_base_extra | |
| 1922 | + | |
| 1923 | + local tmpTreasure, treasureListExtra = role.dailyData:getTreasureExtra(baseExtra) | |
| 1924 | + if not tmpTreasure then return 3 end | |
| 1925 | + | |
| 1926 | + role.dailyData:updateProperty({field = "treasureExtraCount", delta = 1}) | |
| 1927 | + role.dailyData:updateProperty({field = "treasureBaseExtra", value = mapCount - 1}) | |
| 1928 | + role.dailyData:updateProperty({field = "treasureBaseExtra", value = baseExtra}) | |
| 1929 | + | |
| 1930 | + SendPacket(actionCodes.Role_takeTreasureRpc, MsgPack.pack({treasureListExtra = treasureListExtra, treasure = tmpTreasure})) | |
| 1931 | + return true | |
| 1932 | +end | |
| 1933 | + | |
| 1934 | +function _M.treasureMapRpc(agent,data) | |
| 1935 | + local role = agent.role | |
| 1936 | + local msg = MsgPack.unpack(data) | |
| 1937 | + local count = msg.count or 1 | |
| 1938 | + local cost ={[ItemId.Jade] = globalCsv.idle_treasure_buy * count} | |
| 1939 | + if not role:checkItemEnough(cost) then return 1 end | |
| 1940 | + if not role:costItems(cost, {log = {desc = "treasureMap", int1 = count}}) then return 2 end | |
| 1941 | + role.dailyData:updateProperty({field = "treasureMapCount", delta = 1*count}) | |
| 1942 | + | |
| 1943 | + local treasureMapCount = role.dailyData:getProperty("treasureMapCount") | |
| 1944 | + SendPacket(actionCodes.Role_treasureMapRpc, MsgPack.pack({mapCount = treasureMapCount})) | |
| 1945 | + return true | |
| 1946 | +end | |
| 1947 | + | |
| 1903 | 1948 | return _M |
| 1904 | 1949 | \ No newline at end of file | ... | ... |
src/models/Daily.lua
| 1 | 1 | -- 日常数据 |
| 2 | 2 | |
| 3 | 3 | local Daily = class("Daily", require("shared.ModelBaseMysql")) |
| 4 | - | |
| 5 | -oneDay = 60*60*24 | |
| 4 | +local DailyPlugin = import(".DailyPlugin") --宝藏相关 | |
| 5 | +DailyPlugin.bind(Daily) | |
| 6 | 6 | |
| 7 | 7 | function Daily:ctor(properties) |
| 8 | 8 | Daily.super.ctor(self, properties) |
| ... | ... | @@ -37,6 +37,11 @@ Daily.schema = { |
| 37 | 37 | treasureBase = {"number", 0}, -- 资源值 |
| 38 | 38 | treasureList = {"table", {}}, --挂机图鉴 |
| 39 | 39 | |
| 40 | + treasureListExtra = {"table", {}}, --额外宝藏,挂机图鉴扩展功能 | |
| 41 | + treasureMapCount = {"number", 0}, --宝藏图,消耗一张宝藏图可以发现一次额外宝藏 | |
| 42 | + treasureExtraCount = {"number", 0}, --每日发现额外宝藏使用次数(累计),隔天清零 | |
| 43 | + treasureBaseExtra = {"number", 0}, --额外宝藏资源值 | |
| 44 | + | |
| 40 | 45 | chatTimes = {"number", 0}, --每日发言次数 |
| 41 | 46 | } |
| 42 | 47 | |
| ... | ... | @@ -73,7 +78,9 @@ function Daily:refreshDailyData(notify) |
| 73 | 78 | elseif field == "treasureBase" then |
| 74 | 79 | dataMap[field] = globalCsv.idle_treasure_base + self.owner:getBnousTreasureBaseMaximum() |
| 75 | 80 | elseif field == "treasureList" then |
| 76 | - dataMap[field] = self:getTreasrueList() | |
| 81 | + dataMap[field] = self:getTreasureList() | |
| 82 | + elseif field == "treasureExtraCount" then | |
| 83 | + dataMap[field] = 0 | |
| 77 | 84 | elseif field == "pvpBought" then |
| 78 | 85 | dataMap[field] = 0 |
| 79 | 86 | elseif field ~= "key" then |
| ... | ... | @@ -101,300 +108,6 @@ function Daily:refreshDailyData(notify) |
| 101 | 108 | end |
| 102 | 109 | end |
| 103 | 110 | |
| 104 | ---解锁 | |
| 105 | -function Daily:checkUnlock(treaval) | |
| 106 | - local role = self.owner | |
| 107 | - local treasureC = treaval.unlock:toArray(true, "=") | |
| 108 | - local show = false | |
| 109 | - if treasureC[1] == 1 then --通关关卡 | |
| 110 | - show = self.owner:checkHangPass(treasureC[2]) | |
| 111 | - elseif treasureC[1] == 2 then --通关拾荒章节=x层 | |
| 112 | - show = role:checkAdvChapterPass(treasureC[2]) | |
| 113 | - elseif treasureC[1] == 3 then --拥有指定id的角色时 | |
| 114 | - local hero = role:getHeroByID(treasureC[2]) | |
| 115 | - if hero then show = true end | |
| 116 | - else | |
| 117 | - show = true | |
| 118 | - end | |
| 119 | - return show | |
| 120 | -end | |
| 121 | - | |
| 122 | ---CD | |
| 123 | -function Daily:checkTreasureExpired(treasureAttr, treasureList) | |
| 124 | - local curInfo = treasureList[treasureAttr.id] | |
| 125 | - if curInfo then | |
| 126 | - -- check finish | |
| 127 | - if curInfo["expire_time"] then | |
| 128 | - if curInfo.cool_time > 1 then | |
| 129 | - if skynet.timex() >= curInfo["expire_time"] then | |
| 130 | - treasureList[treasureAttr.id] = nil | |
| 131 | - curInfo = clone(treasureAttr) | |
| 132 | - elseif skynet.timex() >= curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却 | |
| 133 | - curInfo = nil | |
| 134 | - else | |
| 135 | - curInfo = clone(treasureAttr) | |
| 136 | - end | |
| 137 | - else | |
| 138 | - if skynet.timex() >= curInfo["expire_time"] then | |
| 139 | - treasureList[treasureAttr.id] = nil | |
| 140 | - end | |
| 141 | - curInfo = clone(treasureAttr) | |
| 142 | - end | |
| 143 | - end | |
| 144 | - else | |
| 145 | - curInfo = clone(treasureAttr) | |
| 146 | - end | |
| 147 | - | |
| 148 | - return curInfo | |
| 149 | -end | |
| 150 | - | |
| 151 | ---资源 | |
| 152 | -function Daily:checkTreasureBase(treasureList, treasureBase, removeId) | |
| 153 | - local tmptreasure = {} | |
| 154 | - local num = 0 | |
| 155 | - for k, val in pairs(treasureList) do | |
| 156 | - if removeId and val.id == removeId then | |
| 157 | - treasureList[k] = nil | |
| 158 | - else | |
| 159 | - if treasureBase >= val.treasure_value then | |
| 160 | - treasureBase = treasureBase - val.treasure_value | |
| 161 | - tmptreasure[val.id] = val | |
| 162 | - num = num + 1 | |
| 163 | - end | |
| 164 | - end | |
| 165 | - | |
| 166 | - end | |
| 167 | - return tmptreasure, num | |
| 168 | -end | |
| 169 | - | |
| 170 | ---绑定通关关卡 | |
| 171 | -function Daily:checkChapters() | |
| 172 | - local chapters = {} | |
| 173 | - local tmp_chapters = {} | |
| 174 | - local treasureList = self:getProperty("treasureList") | |
| 175 | - if next(treasureList) then | |
| 176 | - for _, curInfo in pairs(treasureList) do | |
| 177 | - if curInfo["expire_time"] or not curInfo["end_time"] then | |
| 178 | - tmp_chapters[curInfo.chapter_id] = curInfo | |
| 179 | - end | |
| 180 | - end | |
| 181 | - end | |
| 182 | - local hangInfo = self.owner:getProperty("hangInfo") or {} | |
| 183 | - for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do | |
| 184 | - if chapter_id ~= hangInfo.carbonId then | |
| 185 | - if self.owner:checkHangPass(chapter_id) then | |
| 186 | - if next(tmp_chapters) and not tmp_chapters[chapter_id] then | |
| 187 | - chapters[chapter_id] = val | |
| 188 | - else | |
| 189 | - chapters[chapter_id] = val | |
| 190 | - end | |
| 191 | - end | |
| 192 | - end | |
| 193 | - | |
| 194 | - end | |
| 195 | - return chapters | |
| 196 | -end | |
| 197 | - | |
| 198 | ---权重 | |
| 199 | -function Daily:checkTreasureWeight(treasureList, tmptreasure, treasureBase) | |
| 200 | - local removeId | |
| 201 | - local chapters = self:checkChapters() | |
| 202 | - local treasure | |
| 203 | - if next(chapters) == nil then return end | |
| 204 | - | |
| 205 | - --扣除在挖宝列表里未过期宝藏的资源值 | |
| 206 | - for _, val in pairs(treasureList) do | |
| 207 | - if not val["expire_time"] then | |
| 208 | - treasureBase = treasureBase - val["treasure_value"] | |
| 209 | - end | |
| 210 | - end | |
| 211 | - | |
| 212 | - while next(tmptreasure) do | |
| 213 | - local tmp, num = self:checkTreasureBase(tmptreasure, treasureBase, removeId) | |
| 214 | - | |
| 215 | - if num == 0 then | |
| 216 | - break | |
| 217 | - elseif num == 1 then | |
| 218 | - for _, val in pairs(tmp) do | |
| 219 | - treasure = val | |
| 220 | - end | |
| 221 | - else | |
| 222 | - local id = math.randWeight(tmp, "weight") --宝藏id | |
| 223 | - if not id then | |
| 224 | - break | |
| 225 | - end | |
| 226 | - treasure = tmp[id] | |
| 227 | - end | |
| 228 | - | |
| 229 | - if treasureBase >= treasure.treasure_value then | |
| 230 | - --扣除资源值 | |
| 231 | - treasureBase = treasureBase - treasure.treasure_value | |
| 232 | - else | |
| 233 | - break | |
| 234 | - end | |
| 235 | - local chapterId = math.randWeight(chapters, "treasure_weight") --关卡id | |
| 236 | - if not chapterId then | |
| 237 | - break | |
| 238 | - end | |
| 239 | - | |
| 240 | - treasure.chapter_id = chapterId | |
| 241 | - treasureList[treasure.id] = treasure | |
| 242 | - removeId = treasure.id | |
| 243 | - end | |
| 244 | -end | |
| 245 | - | |
| 246 | ---chapterId | |
| 247 | -function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId) | |
| 248 | - local treasure = nil | |
| 249 | - | |
| 250 | - if not curInfo then | |
| 251 | - return treasure | |
| 252 | - end | |
| 253 | - local treasureBase = self:getProperty("treasureBase") | |
| 254 | - | |
| 255 | - --开始挖宝关卡ID=挂机关卡ID | |
| 256 | - if chapterId == curInfo.chapter_id then | |
| 257 | - --开始挖宝 | |
| 258 | - if not curInfo["end_time"] then | |
| 259 | - curInfo["end_time"] = skynet.timex() + curInfo.working_time | |
| 260 | - else | |
| 261 | - if skynet.timex() >= curInfo["end_time"] then | |
| 262 | - if curInfo.cool_time > 1 then | |
| 263 | - --宝藏冷却时间 | |
| 264 | - if not curInfo["expire_time"] then | |
| 265 | - if treasureBase >= curInfo["treasure_value"] then | |
| 266 | - treasureBase = treasureBase - curInfo["treasure_value"] | |
| 267 | - | |
| 268 | - treasure = treasureList[curInfo.id] | |
| 269 | - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay | |
| 270 | - end | |
| 271 | - else | |
| 272 | - --已经领取宝藏 检索宝藏冷却时间 | |
| 273 | - if skynet.timex() >= curInfo["expire_time"] then | |
| 274 | - treasureList[curInfo.id] = nil | |
| 275 | - end | |
| 276 | - end | |
| 277 | - else | |
| 278 | - if treasureBase >= curInfo["treasure_value"] then | |
| 279 | - treasureBase = treasureBase - curInfo["treasure_value"] | |
| 280 | - | |
| 281 | - treasure = treasureList[curInfo.id] | |
| 282 | - treasureList[curInfo.id] = nil | |
| 283 | - end | |
| 284 | - end | |
| 285 | - end | |
| 286 | - end | |
| 287 | - else | |
| 288 | - --已经开始挖宝 | |
| 289 | - if curInfo["end_time"] then | |
| 290 | - if skynet.timex() >= curInfo["end_time"] then | |
| 291 | - if curInfo.cool_time > 1 then | |
| 292 | - --宝藏冷却时间 | |
| 293 | - if not curInfo["expire_time"] then | |
| 294 | - if treasureBase >= curInfo["treasure_value"] then | |
| 295 | - treasureBase = treasureBase - curInfo["treasure_value"] | |
| 296 | - | |
| 297 | - treasure = treasureList[curInfo.id] | |
| 298 | - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay | |
| 299 | - end | |
| 300 | - | |
| 301 | - else | |
| 302 | - --已经领取宝藏 检索宝藏冷却时间 | |
| 303 | - if skynet.timex() >= curInfo["expire_time"] then | |
| 304 | - treasureList[curInfo.id] = nil | |
| 305 | - end | |
| 306 | - end | |
| 307 | - else | |
| 308 | - if treasureBase >= curInfo["treasure_value"] then | |
| 309 | - treasureBase = treasureBase - curInfo["treasure_value"] | |
| 310 | - | |
| 311 | - treasure = treasureList[curInfo.id] | |
| 312 | - treasureList[curInfo.id] = nil | |
| 313 | - end | |
| 314 | - end | |
| 315 | - else | |
| 316 | - curInfo["end_time"] = nil | |
| 317 | - end | |
| 318 | - end | |
| 319 | - end | |
| 320 | - return treasure | |
| 321 | -end | |
| 322 | - | |
| 323 | -function Daily:buyTreasure(treasureList) | |
| 324 | - local boughtTreasurer = {} | |
| 325 | - local treasureBase = self:getProperty("treasureBase") | |
| 326 | - for id, val in pairs(treasureList) do | |
| 327 | - if treasureBase >= val.treasure_value then | |
| 328 | - boughtTreasurer[id] = val | |
| 329 | - treasureBase = treasureBase - val.treasure_value | |
| 330 | - end | |
| 331 | - end | |
| 332 | - self:updateProperty({field = "treasureBase", value = treasureBase}) | |
| 333 | - return boughtTreasurer | |
| 334 | -end | |
| 335 | - | |
| 336 | ---重置宝藏图鉴 | |
| 337 | -function Daily:resetTreasureList() | |
| 338 | - self:updateProperty({field = "treasureList", value = {}}) | |
| 339 | -end | |
| 340 | - | |
| 341 | ---宝藏图鉴 | |
| 342 | -function Daily:getTreasrueList() | |
| 343 | - local tmpcsv = csvdb["idle_treasureCsv"] | |
| 344 | - local treasureList = self:getProperty("treasureList") or {} --挖宝列表 过期删除 领取奖励删除 跨天更新 | |
| 345 | - local tmptreasure = {} | |
| 346 | - local treasureBase = globalCsv.idle_treasure_base + self.owner:getBnousTreasureBaseMaximum() | |
| 347 | - for id, val in pairs(tmpcsv) do | |
| 348 | - if self:checkUnlock(val) == true then | |
| 349 | - local treasure = self:checkTreasureExpired(val, treasureList) | |
| 350 | - if treasure then | |
| 351 | - table.insert(tmptreasure, treasure) | |
| 352 | - end | |
| 353 | - end | |
| 354 | - end | |
| 355 | - table.sort(tmptreasure, function (a,b) return a.treasure_value > b.treasure_value end) | |
| 356 | - | |
| 357 | - self:checkTreasureWeight(treasureList, tmptreasure, treasureBase) | |
| 358 | - self:updateProperty({field = "treasureList", value = treasureList}) | |
| 359 | - self:updateProperty({field = "treasureBase", value = treasureBase}) | |
| 360 | - return treasureList | |
| 361 | -end | |
| 362 | - | |
| 363 | - | |
| 364 | ---检索挖宝列表 | |
| 365 | -function Daily:checkTreasureList(chapterId) | |
| 366 | - local treasureList = self:getProperty("treasureList") or {} | |
| 367 | - local tmptreasure = {} | |
| 368 | - for id, val in pairs(treasureList) do | |
| 369 | - local treasure = self:checkTreasureChapterId(val, treasureList, chapterId) | |
| 370 | - if treasure ~= nil then | |
| 371 | - tmptreasure[id] = treasure | |
| 372 | - end | |
| 373 | - end | |
| 374 | - | |
| 375 | - if next(tmptreasure) == nil then | |
| 376 | - self:updateProperty({field = "treasureList", value = treasureList}) | |
| 377 | - return nil | |
| 378 | - end | |
| 379 | - local boughtTreasurer = self:buyTreasure(tmptreasure) | |
| 380 | - self:updateProperty({field = "treasureList", value = treasureList}) | |
| 381 | - return boughtTreasurer | |
| 382 | -end | |
| 383 | - | |
| 384 | ---宝藏加速 | |
| 385 | -function Daily:quickTreasureList(chapterId, time) | |
| 386 | - local treasureList = self:getProperty("treasureList") or {} | |
| 387 | - if next(treasureList) then | |
| 388 | - for id, val in pairs(treasureList) do | |
| 389 | - if val["end_time"] and val["chapter_id"] and chapterId == val["chapter_id"] then | |
| 390 | - val["end_time"] = val["end_time"] - time | |
| 391 | - end | |
| 392 | - end | |
| 393 | - end | |
| 394 | - self:updateProperty({field = "treasureList", value = treasureList}) | |
| 395 | - return self:checkTreasureList(chapterId) | |
| 396 | -end | |
| 397 | - | |
| 398 | 111 | function Daily:data() |
| 399 | 112 | return { |
| 400 | 113 | hangQC = self:getProperty("hangQC"), |
| ... | ... | @@ -417,6 +130,10 @@ function Daily:data() |
| 417 | 130 | curPool = self:getProperty("curPool"), |
| 418 | 131 | treasureBase = self:getProperty("treasureBase"), |
| 419 | 132 | treasureList = self:getProperty("treasureList"), |
| 133 | + treasureListExtra = self:getProperty("treasureListExtra"), | |
| 134 | + treasureMapCount = self:getProperty("treasureMapCount"), | |
| 135 | + treasureExtraCount = self:getProperty("treasureExtraCount"), | |
| 136 | + treasureBaseExtra = self:getProperty("treasureBaseExtra"), | |
| 420 | 137 | chatTimes = self:getProperty("chatTimes"), |
| 421 | 138 | } |
| 422 | 139 | end | ... | ... |
| ... | ... | @@ -0,0 +1,402 @@ |
| 1 | + | |
| 2 | +local DailyPlugin = {} | |
| 3 | +oneDay = 60*60*24 | |
| 4 | +function DailyPlugin.bind(Daily) | |
| 5 | + --解锁 | |
| 6 | + function Daily:checkUnlock(treaval) | |
| 7 | + local role = self.owner | |
| 8 | + local treasureC = treaval.unlock:toArray(true, "=") | |
| 9 | + if treasureC[1] == 1 then --通关关卡 | |
| 10 | + return self.owner:checkHangPass(treasureC[2]) | |
| 11 | + elseif treasureC[1] == 2 then --通关拾荒章节=x层 | |
| 12 | + return role:checkAdvChapterPass(treasureC[2]) | |
| 13 | + elseif treasureC[1] == 3 then --拥有指定id的角色时 | |
| 14 | + local hero = role:getHeroByID(treasureC[2]) | |
| 15 | + if hero then return true end | |
| 16 | + else | |
| 17 | + return true | |
| 18 | + end | |
| 19 | + return false | |
| 20 | + end | |
| 21 | + | |
| 22 | + --CD | |
| 23 | + function Daily:checkTreasureExpired(treasureAttr, treasureList) | |
| 24 | + local curInfo = treasureList[treasureAttr.id] | |
| 25 | + if curInfo then | |
| 26 | + -- check finish | |
| 27 | + if curInfo["expire_time"] then | |
| 28 | + if curInfo.cool_time > 1 then | |
| 29 | + if skynet.timex() >= curInfo["expire_time"] then | |
| 30 | + treasureList[treasureAttr.id] = nil | |
| 31 | + curInfo = clone(treasureAttr) | |
| 32 | + elseif skynet.timex() >= curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却 | |
| 33 | + curInfo = nil | |
| 34 | + else | |
| 35 | + curInfo = clone(treasureAttr) | |
| 36 | + end | |
| 37 | + else | |
| 38 | + if skynet.timex() >= curInfo["expire_time"] then | |
| 39 | + treasureList[treasureAttr.id] = nil | |
| 40 | + end | |
| 41 | + curInfo = clone(treasureAttr) | |
| 42 | + end | |
| 43 | + end | |
| 44 | + else | |
| 45 | + curInfo = clone(treasureAttr) | |
| 46 | + end | |
| 47 | + | |
| 48 | + return curInfo | |
| 49 | + end | |
| 50 | + | |
| 51 | + --绑定通关关卡 | |
| 52 | + function Daily:checkChapters(treasureList, treasureListOther) | |
| 53 | + local chapters = {} | |
| 54 | + local tmp_chapters = {} | |
| 55 | + | |
| 56 | + for _, curInfo in pairs(treasureList or {}) do | |
| 57 | + if curInfo["expire_time"] or not curInfo["end_time"] then | |
| 58 | + tmp_chapters[curInfo.chapter_id] = curInfo | |
| 59 | + end | |
| 60 | + end | |
| 61 | + | |
| 62 | + for _, curInfo in pairs(treasureListOther or {}) do | |
| 63 | + if curInfo["expire_time"] or not curInfo["end_time"] then | |
| 64 | + tmp_chapters[curInfo.chapter_id] = curInfo | |
| 65 | + end | |
| 66 | + end | |
| 67 | + | |
| 68 | + local hangInfo = self.owner:getProperty("hangInfo") or {} | |
| 69 | + for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do | |
| 70 | + if chapter_id ~= hangInfo.carbonId then | |
| 71 | + if self.owner:checkHangPass(chapter_id) then | |
| 72 | + if next(tmp_chapters) and not tmp_chapters[chapter_id] then | |
| 73 | + chapters[chapter_id] = val | |
| 74 | + else | |
| 75 | + chapters[chapter_id] = val | |
| 76 | + end | |
| 77 | + end | |
| 78 | + end | |
| 79 | + | |
| 80 | + end | |
| 81 | + return chapters | |
| 82 | + end | |
| 83 | + | |
| 84 | + --权重 | |
| 85 | + function Daily:checkTreasureWeight(treasureList, tmpTreasure, treasureBase, treasureListOther) | |
| 86 | + local chapters = self:checkChapters(treasureList, treasureListOther) | |
| 87 | + if not chapters or not next(chapters) then return end | |
| 88 | + | |
| 89 | + --扣除在挖宝列表里未过期宝藏的资源值 | |
| 90 | + for _, val in pairs(treasureList) do | |
| 91 | + if not val["expire_time"] then | |
| 92 | + treasureBase = treasureBase - val["treasure_value"] | |
| 93 | + end | |
| 94 | + end | |
| 95 | + | |
| 96 | + if tmpTreasure and next(tmpTreasure) then | |
| 97 | + table.sort(tmpTreasure, function (a, b) return a.treasure_value > b.treasure_value end) | |
| 98 | + end | |
| 99 | + | |
| 100 | + local treasure | |
| 101 | + while next(tmpTreasure or {}) do | |
| 102 | + local tmp = {} | |
| 103 | + local tmpBase = treasureBase | |
| 104 | + for _, val in pairs(tmpTreasure) do | |
| 105 | + if tmpBase >= val.treasure_value then | |
| 106 | + tmpBase = tmpBase - val.treasure_value | |
| 107 | + tmp[val.id] = val | |
| 108 | + end | |
| 109 | + end | |
| 110 | + if not next(tmp) then break end | |
| 111 | + | |
| 112 | + local id = math.randWeight(tmp, "weight") --宝藏id | |
| 113 | + if not id then break end | |
| 114 | + | |
| 115 | + treasure = tmp[id] | |
| 116 | + if treasureBase < treasure.treasure_value then break end | |
| 117 | + --扣除资源值 | |
| 118 | + treasureBase = treasureBase - treasure.treasure_value | |
| 119 | + | |
| 120 | + local chapterId = math.randWeight(chapters, "treasure_weight") --关卡id | |
| 121 | + if not chapterId then break end | |
| 122 | + | |
| 123 | + treasure.chapter_id = chapterId | |
| 124 | + treasureList[treasure.id] = treasure | |
| 125 | + | |
| 126 | + tmpTreasure[treasure.id] = nil | |
| 127 | + chapters[chapterId] = nil | |
| 128 | + end | |
| 129 | + end | |
| 130 | + | |
| 131 | + --只抓一个 额外宝藏 | |
| 132 | + function Daily:getOneTreasureExtra(treasureList, tmpTreasure, treasureBase, treasureListOther) | |
| 133 | + local chapters = self:checkChapters(treasureList, treasureListOther) | |
| 134 | + if not chapters or not next(chapters) then return end | |
| 135 | + | |
| 136 | + --扣除在挖宝列表里未过期宝藏的资源值 | |
| 137 | + for _, val in pairs(treasureList) do | |
| 138 | + if not val["expire_time"] then | |
| 139 | + treasureBase = treasureBase - val["treasure_value"] | |
| 140 | + end | |
| 141 | + end | |
| 142 | + | |
| 143 | + if tmpTreasure and next(tmpTreasure) then | |
| 144 | + table.sort(tmpTreasure, function (a, b) return a.treasure_value > b.treasure_value end) | |
| 145 | + end | |
| 146 | + | |
| 147 | + local treasure | |
| 148 | + local tmp = {} | |
| 149 | + local tmpBase = treasureBase | |
| 150 | + for _, val in pairs(tmpTreasure) do | |
| 151 | + if tmpBase >= val.treasure_value then | |
| 152 | + tmpBase = tmpBase - val.treasure_value | |
| 153 | + tmp[val.id] = val | |
| 154 | + end | |
| 155 | + end | |
| 156 | + if not next(tmp) then return end | |
| 157 | + | |
| 158 | + local id = math.randWeight(tmp, "weight") --宝藏id | |
| 159 | + if not id then return end | |
| 160 | + | |
| 161 | + treasure = tmp[id] | |
| 162 | + if treasureBase < treasure.treasure_value then return end | |
| 163 | + --扣除资源值 | |
| 164 | + treasureBase = treasureBase - treasure.treasure_value | |
| 165 | + | |
| 166 | + local chapterId = math.randWeight(chapters, "treasure_weight") --关卡id | |
| 167 | + if not chapterId then return end | |
| 168 | + | |
| 169 | + | |
| 170 | + treasure.chapter_id = chapterId | |
| 171 | + treasureList[treasure.id] = treasure | |
| 172 | + | |
| 173 | + return treasure | |
| 174 | + end | |
| 175 | + | |
| 176 | + --chapterId | |
| 177 | + function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId, treasureBase) | |
| 178 | + if not curInfo then return nil end | |
| 179 | + | |
| 180 | + local treasure = nil | |
| 181 | + --开始挖宝关卡ID=挂机关卡ID | |
| 182 | + if chapterId == curInfo.chapter_id then | |
| 183 | + --开始挖宝 | |
| 184 | + if not curInfo["end_time"] then | |
| 185 | + curInfo["end_time"] = skynet.timex() + curInfo.working_time | |
| 186 | + else | |
| 187 | + if skynet.timex() >= curInfo["end_time"] then | |
| 188 | + if curInfo.cool_time > 1 then | |
| 189 | + --宝藏冷却时间 | |
| 190 | + if not curInfo["expire_time"] then | |
| 191 | + if treasureBase >= curInfo["treasure_value"] then | |
| 192 | + treasureBase = treasureBase - curInfo["treasure_value"] | |
| 193 | + | |
| 194 | + treasure = treasureList[curInfo.id] | |
| 195 | + curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay | |
| 196 | + end | |
| 197 | + else | |
| 198 | + --已经领取宝藏 检索宝藏冷却时间 | |
| 199 | + if skynet.timex() >= curInfo["expire_time"] then | |
| 200 | + treasureList[curInfo.id] = nil | |
| 201 | + end | |
| 202 | + end | |
| 203 | + else | |
| 204 | + if treasureBase >= curInfo["treasure_value"] then | |
| 205 | + treasureBase = treasureBase - curInfo["treasure_value"] | |
| 206 | + | |
| 207 | + treasure = treasureList[curInfo.id] | |
| 208 | + treasureList[curInfo.id] = nil | |
| 209 | + end | |
| 210 | + end | |
| 211 | + end | |
| 212 | + end | |
| 213 | + else | |
| 214 | + --已经开始挖宝 | |
| 215 | + if curInfo["end_time"] then | |
| 216 | + if skynet.timex() >= curInfo["end_time"] then | |
| 217 | + if curInfo.cool_time > 1 then | |
| 218 | + --宝藏冷却时间 | |
| 219 | + if not curInfo["expire_time"] then | |
| 220 | + if treasureBase >= curInfo["treasure_value"] then | |
| 221 | + treasureBase = treasureBase - curInfo["treasure_value"] | |
| 222 | + | |
| 223 | + treasure = treasureList[curInfo.id] | |
| 224 | + curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay | |
| 225 | + end | |
| 226 | + | |
| 227 | + else | |
| 228 | + --已经领取宝藏 检索宝藏冷却时间 | |
| 229 | + if skynet.timex() >= curInfo["expire_time"] then | |
| 230 | + treasureList[curInfo.id] = nil | |
| 231 | + end | |
| 232 | + end | |
| 233 | + else | |
| 234 | + if treasureBase >= curInfo["treasure_value"] then | |
| 235 | + treasureBase = treasureBase - curInfo["treasure_value"] | |
| 236 | + | |
| 237 | + treasure = treasureList[curInfo.id] | |
| 238 | + treasureList[curInfo.id] = nil | |
| 239 | + end | |
| 240 | + end | |
| 241 | + else | |
| 242 | + curInfo["end_time"] = nil | |
| 243 | + end | |
| 244 | + end | |
| 245 | + end | |
| 246 | + return treasure | |
| 247 | + end | |
| 248 | + | |
| 249 | + function Daily:buyTreasure(treasureList) | |
| 250 | + local boughtTreasure = {} | |
| 251 | + local treasureBase = self:getProperty("treasureBase") | |
| 252 | + for id, val in pairs(treasureList) do | |
| 253 | + if treasureBase >= val.treasure_value then | |
| 254 | + boughtTreasure[id] = val | |
| 255 | + treasureBase = treasureBase - val.treasure_value | |
| 256 | + end | |
| 257 | + end | |
| 258 | + self:updateProperty({field = "treasureBase", value = treasureBase}) | |
| 259 | + return boughtTreasure | |
| 260 | + end | |
| 261 | + | |
| 262 | + --重置宝藏图鉴 | |
| 263 | + function Daily:resetTreasureList() | |
| 264 | + self:updateProperty({field = "treasureList", value = {}}) | |
| 265 | + self:updateProperty({field = "treasureListExtra", value = {}}) | |
| 266 | + end | |
| 267 | + | |
| 268 | + --宝藏图鉴 | |
| 269 | + function Daily:getTreasureList() | |
| 270 | + local tmpcsv = csvdb["idle_treasureCsv"] | |
| 271 | + local treasureList = self:getProperty("treasureList") or {} --挖宝列表 过期删除 领取奖励删除 跨天更新 | |
| 272 | + local treasureListExtra = self:getProperty("treasureListExtra") or {} --额外宝藏列表 过期删除 领取奖励删除 跨天更新 | |
| 273 | + local tmpTreasure = {} | |
| 274 | + local treasureBase = globalCsv.idle_treasure_base + self.owner:getBnousTreasureBaseMaximum() | |
| 275 | + for _, val in pairs(tmpcsv) do | |
| 276 | + if self:checkUnlock(val) == true then | |
| 277 | + local treasure = self:checkTreasureExpired(val, treasureList) | |
| 278 | + if treasure then | |
| 279 | + table.insert(tmpTreasure, treasure) | |
| 280 | + end | |
| 281 | + end | |
| 282 | + end | |
| 283 | + | |
| 284 | + if not next(tmpTreasure) then return treasureList end | |
| 285 | + | |
| 286 | + self:checkTreasureWeight(treasureList, tmpTreasure, treasureBase, treasureListExtra) | |
| 287 | + self:updateProperty({field = "treasureList", value = treasureList}) | |
| 288 | + self:updateProperty({field = "treasureBase", value = treasureBase}) | |
| 289 | + return treasureList | |
| 290 | + end | |
| 291 | + | |
| 292 | + | |
| 293 | + --检索挖宝列表 获得宝藏 | |
| 294 | + function Daily:checkTreasureList(chapterId) | |
| 295 | + local treasureList = self:getProperty("treasureList") or {} | |
| 296 | + local treasureBase = self:getProperty("treasureBase") or {} | |
| 297 | + local tmpTreasure = {} | |
| 298 | + for id, val in pairs(treasureList) do | |
| 299 | + local treasure = self:checkTreasureChapterId(val, treasureList, chapterId, treasureBase) | |
| 300 | + if treasure then | |
| 301 | + tmpTreasure[id] = treasure | |
| 302 | + end | |
| 303 | + end | |
| 304 | + | |
| 305 | + if not next(tmpTreasure) then | |
| 306 | + self:updateProperty({field = "treasureList", value = treasureList}) | |
| 307 | + return nil | |
| 308 | + end | |
| 309 | + local boughtTreasure = self:buyTreasure(tmpTreasure) | |
| 310 | + self:updateProperty({field = "treasureList", value = treasureList}) | |
| 311 | + return boughtTreasure | |
| 312 | + end | |
| 313 | + | |
| 314 | + --宝藏加速 | |
| 315 | + function Daily:quickTreasureList(chapterId, time) | |
| 316 | + local treasureList = self:getProperty("treasureList") or {} | |
| 317 | + if next(treasureList) then | |
| 318 | + for _, val in pairs(treasureList) do | |
| 319 | + if val["end_time"] and val["chapter_id"] and chapterId == val["chapter_id"] then | |
| 320 | + val["end_time"] = val["end_time"] - time | |
| 321 | + end | |
| 322 | + end | |
| 323 | + end | |
| 324 | + self:updateProperty({field = "treasureList", value = treasureList}) | |
| 325 | + return self:checkTreasureList(chapterId) | |
| 326 | + end | |
| 327 | + | |
| 328 | + --宝藏功能优化——增加"发现宝藏"功能 | |
| 329 | + function Daily:buyTreasureExtra(treasureList) | |
| 330 | + local boughtTreasure = {} | |
| 331 | + local treasureBase = self:getProperty("treasureExtraBase") | |
| 332 | + for id, val in pairs(treasureList) do | |
| 333 | + if treasureBase >= val.treasure_value then | |
| 334 | + boughtTreasure[id] = val | |
| 335 | + treasureBase = treasureBase - val.treasure_value | |
| 336 | + end | |
| 337 | + end | |
| 338 | + self:updateProperty({field = "treasureExtraBase", value = treasureBase}) | |
| 339 | + return boughtTreasure | |
| 340 | + end | |
| 341 | + | |
| 342 | + function Daily:getTreasureExtra(tmpBaseExtra) | |
| 343 | + local tmpcsv = csvdb["idle_treasureCsv"] | |
| 344 | + local treasureList = self:getProperty("treasureList") or {} --挖宝列表 过期删除 领取奖励删除 跨天更新 | |
| 345 | + local treasureListExtra = self:getProperty("treasureListExtra") or {} --额外宝藏 过期删除 领取奖励删除 跨天更新 | |
| 346 | + | |
| 347 | + local tmpTreasure = {} | |
| 348 | + for _, val in pairs(tmpcsv) do | |
| 349 | + if self:checkUnlock(val) then | |
| 350 | + local treasure = self:checkTreasureExpired(val, treasureListExtra) | |
| 351 | + if treasure then | |
| 352 | + table.insert(tmpTreasure, treasure) | |
| 353 | + end | |
| 354 | + end | |
| 355 | + end | |
| 356 | + if not next(tmpTreasure) then return nil, treasureListExtra end | |
| 357 | + | |
| 358 | + local tmp = self:getOneTreasureExtra(treasureListExtra, tmpTreasure, tmpBaseExtra, treasureList) | |
| 359 | + self:updateProperty({field = "treasureListExtra", value = treasureListExtra}) | |
| 360 | + return tmp, treasureListExtra | |
| 361 | + end | |
| 362 | + | |
| 363 | + --检索宝藏列表 获得额外宝藏 | |
| 364 | + function Daily:checkTreasureListExtra(chapterId) | |
| 365 | + local treasureListExtra = self:getProperty("treasureListExtra") or {} | |
| 366 | + local treasureBaseExtra = self:getProperty("treasureBaseExtra") or {} | |
| 367 | + local tmpTreasure = {} | |
| 368 | + for id, val in pairs(treasureListExtra) do | |
| 369 | + local treasure = self:checkTreasureChapterId(val, treasureListExtra, chapterId, treasureBaseExtra) | |
| 370 | + if treasure then | |
| 371 | + tmpTreasure[id] = treasure | |
| 372 | + end | |
| 373 | + end | |
| 374 | + | |
| 375 | + if next(tmpTreasure) then | |
| 376 | + self:updateProperty({field = "treasureListExtra", value = treasureListExtra}) | |
| 377 | + return nil | |
| 378 | + end | |
| 379 | + | |
| 380 | + local boughtTreasure = self:buyTreasureExtra(tmpTreasure) | |
| 381 | + self:updateProperty({field = "treasureListExtra", value = treasureListExtra}) | |
| 382 | + return boughtTreasure | |
| 383 | + end | |
| 384 | + | |
| 385 | + --额外宝藏加速 | |
| 386 | + function Daily:quickTreasureListExtra(chapterId, time) | |
| 387 | + local treasureListExtra = self:getProperty("treasureListExtra") or {} | |
| 388 | + if next(treasureListExtra) then | |
| 389 | + for _, val in pairs(treasureListExtra) do | |
| 390 | + if val["end_time"] and val["chapter_id"] and chapterId == val["chapter_id"] then | |
| 391 | + val["end_time"] = val["end_time"] - time | |
| 392 | + end | |
| 393 | + end | |
| 394 | + end | |
| 395 | + | |
| 396 | + self:updateProperty({field = "treasureListExtra", value = treasureListExtra}) | |
| 397 | + return self:checkTreasureListExtra(chapterId) | |
| 398 | + end | |
| 399 | +end | |
| 400 | + | |
| 401 | + | |
| 402 | +return DailyPlugin | |
| 0 | 403 | \ No newline at end of file | ... | ... |
src/models/Hero.lua
| ... | ... | @@ -19,6 +19,7 @@ Hero.schema = { |
| 19 | 19 | faith = {"number", 0}, -- 信赖 |
| 20 | 20 | spark = {"table", {}}, -- 火花属性 |
| 21 | 21 | genius = {"string", "" }, --天赋点 4=10201 5=10201 6=10203 7=10204 |
| 22 | + trainTs = {"number", 0}, -- 魔鬼训练营截止时间 0为未训练 | |
| 22 | 23 | } |
| 23 | 24 | |
| 24 | 25 | function Hero:ctor( properties ) |
| ... | ... | @@ -113,6 +114,7 @@ function Hero:data() |
| 113 | 114 | faith = self:getProperty("faith"), |
| 114 | 115 | spark = self:getProperty("spark"), |
| 115 | 116 | genius = self:getProperty("genius"), |
| 117 | + trainTs = self:getProperty("trainTs"), | |
| 116 | 118 | } |
| 117 | 119 | end |
| 118 | 120 | ... | ... |
src/models/Role.lua
| ... | ... | @@ -218,6 +218,7 @@ Role.schema = { |
| 218 | 218 | worldChangePoints = {"table", {}}, -- 世界变动积分 {[1]= 转盘抽取次数, [2]= 获得的积分, [3]=魔导石消耗, [4]= 虹光玉消耗} |
| 219 | 219 | worldLineReward = {"table", {}}, -- 世界积分 领取记录 {[id] = 1} |
| 220 | 220 | del = {"number", 0}, -- 标记删除 0=未删除,1=已删除 |
| 221 | + trainTask = {"table", {}}, -- 训练营任务 | |
| 221 | 222 | } |
| 222 | 223 | |
| 223 | 224 | |
| ... | ... | @@ -463,6 +464,7 @@ function Role:data() |
| 463 | 464 | bgId = self:getProperty("bgId"), |
| 464 | 465 | worldChangePoints = self:getProperty("worldChangePoints"), |
| 465 | 466 | worldLineReward = self:getProperty("worldLineReward"), |
| 467 | + trainTask = self:getProperty("trainTask"), | |
| 466 | 468 | } |
| 467 | 469 | end |
| 468 | 470 | ... | ... |
src/models/RoleLog.lua
| ... | ... | @@ -74,6 +74,9 @@ local ItemReason = { |
| 74 | 74 | regularWorldBossMilestone = 158, -- 常规世界boss伤害里程碑 |
| 75 | 75 | regularWorldBossBattle = 159, -- 常规世界boss战斗奖励 |
| 76 | 76 | itemConvertDevilTicket = 160, -- 兑换魔鬼训练营门票 |
| 77 | + trainHero = 161, -- 魔鬼训练开始 | |
| 78 | + trainQuickHero = 162, -- 魔鬼训练加速 | |
| 79 | + treasureMap = 163, --虹光玉兑换宝藏图 | |
| 77 | 80 | |
| 78 | 81 | |
| 79 | 82 | ... | ... |
src/models/RolePlugin.lua
| ... | ... | @@ -185,6 +185,8 @@ function RolePlugin.bind(Role) |
| 185 | 185 | itemType = itemCfg.type |
| 186 | 186 | end |
| 187 | 187 | self:checkTaskEnter("AddItem", {id = itemId, count = count, type = itemType}) |
| 188 | + elseif count < 0 then | |
| 189 | + self:checkTaskEnter("CostItem", {id = itemId, count = count}) | |
| 188 | 190 | end |
| 189 | 191 | -- 对数量筛查 |
| 190 | 192 | count = checkItemCount(self, itemId, count) |
| ... | ... | @@ -647,6 +649,8 @@ function RolePlugin.bind(Role) |
| 647 | 649 | self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job, ssrCount = ssrCount}, params.notNotify) |
| 648 | 650 | self:checkTaskEnter("HeroQualityCollect", {}) |
| 649 | 651 | self:checkTaskEnter("HeroStartSum", {}) |
| 652 | + self:checkTaskEnter("SSRHeroStarSum", {}) | |
| 653 | + self:checkTaskEnter("SRHeroStarSum", {}) | |
| 650 | 654 | |
| 651 | 655 | if not params.notNotify then |
| 652 | 656 | local heroResponse = {} |
| ... | ... | @@ -2315,6 +2319,18 @@ function RolePlugin.bind(Role) |
| 2315 | 2319 | -- end |
| 2316 | 2320 | -- end |
| 2317 | 2321 | |
| 2322 | + --月卡-特刊加判断; | |
| 2323 | + -- 问题描述: 支付回调里订单支付完成,但是没有奖励,对应的特刊也没有购买成功。 | |
| 2324 | + -- 避免这种情况发生,在生成订单的时候就判断是否能购买特刊,生成对应的订单id | |
| 2325 | + if rechargeData.shop == 2 and rechargeData.type == CardType.SuperMonthCard then | |
| 2326 | + local card = csvdb["shop_cardCsv"][rechargeData.id] | |
| 2327 | + if not card then return "" end | |
| 2328 | + | |
| 2329 | + if not self.storeData:buySMonthCardLimit(card["buyLimit"]) then | |
| 2330 | + return "" | |
| 2331 | + end | |
| 2332 | + end | |
| 2333 | + | |
| 2318 | 2334 | local orderId = redisproxy:hincrby("autoincrement_set", "order", 1) |
| 2319 | 2335 | local uid = orderId * MAX_SVR_ID + serverId |
| 2320 | 2336 | local partnerOrderId = string.format("%d", orderId * MAX_SVR_ID + serverId) | ... | ... |
src/models/RoleTask.lua
| ... | ... | @@ -19,6 +19,8 @@ local TaskType = { |
| 19 | 19 | DrawHeroLimitPack = 14, -- 抽卡限时礼貌 -- count |
| 20 | 20 | HeroStartSum = 15, -- 英雄星级总数 |
| 21 | 21 | WakeCGSum = 16, -- 累计解锁xx张CG |
| 22 | + SSRHeroStarSum = 17, -- SSR英雄星级总数 | |
| 23 | + SRHeroStarSum = 18, -- SR英雄星级总数 | |
| 22 | 24 | |
| 23 | 25 | |
| 24 | 26 | --装备相关 |
| ... | ... | @@ -117,6 +119,8 @@ local TaskType = { |
| 117 | 119 | Rename = 913, -- 重命名 |
| 118 | 120 | CostJade = 914, -- 消耗虹光玉 |
| 119 | 121 | BuyLimitPack = 915, -- 购买指定id礼包触发 |
| 122 | + CostItem = 916, -- 消耗道具 | |
| 123 | + LoginAddUp = 917, -- 累计登录 | |
| 120 | 124 | |
| 121 | 125 | --功能未实现 todo |
| 122 | 126 | AdvShop = 1002, -- 冒险商城 |
| ... | ... | @@ -333,6 +337,7 @@ local CalendaTaskListener = { |
| 333 | 337 | [TaskType.CostJade] = {{43, 1, f("count")}}, |
| 334 | 338 | [TaskType.HeroStartSum] = {{44, 3}}, |
| 335 | 339 | [TaskType.WakeCGSum] = {{45, 1, f("count")}}, |
| 340 | + [TaskType.LoginAddUp] = {{46, 1}}, | |
| 336 | 341 | } |
| 337 | 342 | } |
| 338 | 343 | |
| ... | ... | @@ -351,6 +356,16 @@ local ReturnerTask = { |
| 351 | 356 | listen = CalendaTaskListener["listen"] |
| 352 | 357 | } |
| 353 | 358 | |
| 359 | +local TraningCampTask = { | |
| 360 | + func = "checkTraingCampTask", | |
| 361 | + listen = { | |
| 362 | + [TaskType.HangPass]= {{1, 3}}, | |
| 363 | + [TaskType.SSRHeroStarSum] = {{2, 3}}, | |
| 364 | + [TaskType.SRHeroStarSum] = {{3, 3}}, | |
| 365 | + [TaskType.CostItem] = {{4, 3, f("id"), f("count")}}, | |
| 366 | + } | |
| 367 | +} | |
| 368 | + | |
| 354 | 369 | local TaskListeners = { |
| 355 | 370 | StoryListener, |
| 356 | 371 | CommonListener, |
| ... | ... | @@ -362,6 +377,7 @@ local TaskListeners = { |
| 362 | 377 | BattleCommandTaskListener, |
| 363 | 378 | ReturnerTask, |
| 364 | 379 | NewUserTaskListener, |
| 380 | + TraningCampTask, | |
| 365 | 381 | } |
| 366 | 382 | |
| 367 | 383 | local RoleTask = {} |
| ... | ... | @@ -900,6 +916,52 @@ function RoleTask.bind(Role) |
| 900 | 916 | self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) |
| 901 | 917 | end |
| 902 | 918 | |
| 919 | + function Role:checkTraingCampTask(notNotify, mainType, subType, param1, param2) | |
| 920 | + local trainTask = self:getProperty("trainTask") or {} | |
| 921 | + param1 = param1 or 1 | |
| 922 | + for id, cfg in pairs(csvdb["training_camp_taskCsv"]) do | |
| 923 | + if cfg.type == mainType then | |
| 924 | + if subType == 1 then -- 增加数值 | |
| 925 | + trainTask[id] = (trainTask[id] or 0) + param1 | |
| 926 | + elseif subType == 2 then -- 直接赋值 | |
| 927 | + trainTask[id] = param1 | |
| 928 | + elseif subType == 3 then -- 自定义类型 | |
| 929 | + if cfg.type == 1 then -- 通关关卡 | |
| 930 | + if (trainTask[id] or 0) == 0 then | |
| 931 | + if self:checkHangPass(cfg.condition2) then | |
| 932 | + trainTask[id] = 1 | |
| 933 | + end | |
| 934 | + end | |
| 935 | + elseif cfg.type == 2 then --玩家拥有SR拾荒者总星级达到xxx | |
| 936 | + local count = 0 | |
| 937 | + for _, hero in pairs(self.heros) do | |
| 938 | + if hero:getRare() == HeroQuality.SR then | |
| 939 | + count = count + hero:getProperty("wakeL") | |
| 940 | + end | |
| 941 | + end | |
| 942 | + if (trainTask[id] or 0) < count then | |
| 943 | + trainTask[id] = count | |
| 944 | + end | |
| 945 | + elseif cfg.type == 3 then --玩家拥有SR拾荒者总星级达到xxx | |
| 946 | + local count = 0 | |
| 947 | + for _, hero in pairs(self.heros) do | |
| 948 | + if hero:getRare() == HeroQuality.SSR then | |
| 949 | + count = count + hero:getProperty("wakeL") | |
| 950 | + end | |
| 951 | + end | |
| 952 | + if (trainTask[id] or 0) < count then | |
| 953 | + trainTask[id] = count | |
| 954 | + end | |
| 955 | + elseif cfg.type == 4 then -- 消耗指定id道具多少个 | |
| 956 | + -- if cfg.condition2 == param1 then | |
| 957 | + -- trainTask[id] = (trainTask[id] or 0) + (param2 or 0) | |
| 958 | + -- end | |
| 959 | + end | |
| 960 | + end | |
| 961 | + end | |
| 962 | + end | |
| 963 | + self:updateProperty({field = "trainTask", value = trainTask, notNotify = notNotify}) | |
| 964 | + end | |
| 903 | 965 | end |
| 904 | 966 | |
| 905 | 967 | return RoleTask | ... | ... |
src/models/Store.lua
| ... | ... | @@ -342,26 +342,26 @@ function Store:isSMonthCardExpired(id) |
| 342 | 342 | end |
| 343 | 343 | |
| 344 | 344 | function Store:buySMonthCardLimit(buylimit) |
| 345 | + if not buylimit or buylimit == "" then return true end | |
| 346 | + | |
| 345 | 347 | local smonthCards = self:getProperty("smonthCards") or {} |
| 346 | - for k, v in pairs(buylimit) do | |
| 348 | + for k, v in pairs(buylimit:toNumMap() or {}) do | |
| 347 | 349 | if k == 1 then |
| 348 | 350 | if v == 101 then |
| 349 | 351 | if self:isMonthCardExpire() then |
| 350 | - skynet.error("月卡过期") | |
| 351 | 352 | return false |
| 352 | 353 | end |
| 353 | 354 | else |
| 354 | - if smonthCards[v] == nil then | |
| 355 | - skynet.error("没有购买增刊里的条件, %d", v) | |
| 355 | + if not smonthCards[v] then | |
| 356 | 356 | return false |
| 357 | 357 | end |
| 358 | 358 | end |
| 359 | 359 | elseif k == 2 then |
| 360 | - if smonthCards[v] == nil and v ~= 101 then | |
| 360 | + if not smonthCards[v] then | |
| 361 | 361 | skynet.error("没有购买增刊条件里的特刊, %d", v) |
| 362 | 362 | return false |
| 363 | 363 | end |
| 364 | - if self:isSMonthCardExpired(v) == false and v ~= 101 then | |
| 364 | + if not self:isSMonthCardExpired(v) then | |
| 365 | 365 | skynet.error("上期特刊奖励没领完") --策划yc+hbw 没领完上期特刊,新一期特刊不展示,不允许购买 |
| 366 | 366 | return false |
| 367 | 367 | end |
| ... | ... | @@ -372,18 +372,17 @@ end |
| 372 | 372 | |
| 373 | 373 | function Store:buySMonthCard(id) |
| 374 | 374 | local smonthCards = self:getProperty("smonthCards") or {} |
| 375 | + local card = csvdb["shop_cardCsv"][id] | |
| 376 | + if not card then return false end | |
| 377 | + | |
| 378 | + if not self:buySMonthCardLimit(card["buyLimit"]) then | |
| 379 | + skynet.error("不满足购买条件") | |
| 380 | + return false | |
| 381 | + end | |
| 375 | 382 | |
| 376 | 383 | local BuyMonthCard = {} |
| 377 | 384 | BuyMonthCard["renewal"]= function() |
| 378 | 385 | --续刊 |
| 379 | - local card = csvdb["shop_cardCsv"][id] or {} | |
| 380 | - if card["buyLimit"] and card["buyLimit"] ~= "" then | |
| 381 | - if not self:buySMonthCardLimit(card["buyLimit"]:toNumMap()) then | |
| 382 | - skynet.error("不满足购买条件") | |
| 383 | - return false | |
| 384 | - end | |
| 385 | - end | |
| 386 | - | |
| 387 | 386 | local smonthCard = smonthCards[id] or {} |
| 388 | 387 | if next(smonthCard) then |
| 389 | 388 | smonthCard["buyCount"] = (smonthCard["buyCount"] or 0) + 1 |
| ... | ... | @@ -397,14 +396,6 @@ function Store:buySMonthCard(id) |
| 397 | 396 | |
| 398 | 397 | BuyMonthCard["order"] = function() |
| 399 | 398 | --增刊 |
| 400 | - local card = csvdb["shop_cardCsv"][id] or {} | |
| 401 | - if card["buyLimit"] and card["buyLimit"] ~= "" then | |
| 402 | - if not self:buySMonthCardLimit(card["buyLimit"]:toNumMap()) then | |
| 403 | - skynet.error("不满足增刊条件") | |
| 404 | - return false | |
| 405 | - end | |
| 406 | - end | |
| 407 | - | |
| 408 | 399 | smonthCards[id] = {["periods"] = (card["amount"] or 30), ["buyCount"] = 1} |
| 409 | 400 | self:updateProperty({field= "smonthCards", value = smonthCards}) |
| 410 | 401 | return true | ... | ... |