Commit e2e205bee8bbf028476d2134243657a934f3b610

Authored by zhangqijia
1 parent 756cd488

feat: 玩家等级奖励

src/GlobalVar.lua
... ... @@ -397,10 +397,16 @@ TeamSystemType = {
397 397 Dinner = 4,
398 398 FriendBattle = 5,
399 399 }
  400 +-- 加速类型
  401 +UpSpeedType = {
  402 + ExplorationUpSpeed = 1, -- 探索加速
  403 + GearUpSpeed = 2, -- 齿轮加速
  404 + Restaurant = 3, -- 餐厅加速
400 405  
  406 +}
401 407 -- 某个功能对其他系统功能的加成类型
402 408 SystemBnousType = {
403   - TowerBuff = 1, -- 电波塔内战斗开始时获得buff
  409 + TowerBuff = 1, -- 电波塔内战斗开始时获得buff or
404 410 CrusadeTask = 2, -- 讨伐电台任务加速
405 411 DinerGet = 3, -- 食材供应商获取速度
406 412 DinerLimit = 4, -- 食材供应商上限
... ... @@ -410,4 +416,10 @@ SystemBnousType = {
410 416 HangTime = 8, -- 挂机时间上限
411 417 PvpTicket = 9, -- 每周额外获得竞技场门票数量
412 418 SweepReward = 10, -- 奖励关卡每次扫荡额外获得道具
  419 + DismantlingMaximum = 11,-- 拆解术式模块运行时间上限
  420 + DismantlingImproved = 12,-- 拆解术式构筑效率提升
  421 + DailyReward = 13,-- 每日签到额外获得道具
  422 + TreasureBaseMaximum = 14, -- 增加宝藏资源值上限
  423 + UpSpeedNum = 15, -- 加速次数上限增加 15=1探索加速or 2齿轮加速or 3餐厅加速=增加次数
  424 + ChangeBaseCount = 16, -- 每日奖励关卡挑战卡基础数量增加
413 425 }
... ...
src/actions/ActivityAction.lua
... ... @@ -136,7 +136,14 @@ function _M.signRpc(agent, data)
136 136 end
137 137 signs[curDay] = yearMonth
138 138  
139   - local reward, change = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}})
  139 + -- 达到一定等级,签到会有额外奖励
  140 + local reward = role:getBnousDaily()
  141 + local change
  142 + local award = monthData[curDay].item:toNumMap() or {}
  143 + for k, v in pairs(award) do
  144 + reward[k] = (reward[k] or 0) + v
  145 + end
  146 + reward, change = role:award(reward, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}})
140 147 role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}})
141 148 role:checkTaskEnter("SignIn")
142 149  
... ...
src/actions/DinerAction.lua
... ... @@ -251,11 +251,20 @@ end
251 251 function _M.expediteSellRpc( agent, data )
252 252 local role = agent.role
253 253 local count = role.dinerData:getProperty("expedite")
254   - local max = #globalCsv.diner_sell_quick_cost
255   - if count > max then
256   - return 1
  254 + local maxIdx = #globalCsv.diner_sell_quick_cost
  255 +
  256 + -- 增加今日餐厅加速次数
  257 + local max = maxIdx + role:getBnousUpSpeedNum(UpSpeedType.Restaurant)
  258 + if count > max then return 1 end
  259 +
  260 + local costs = clone(globalCsv.diner_sell_quick_cost)
  261 + if count > maxIdx then
  262 + for idx = maxIdx+1, count do
  263 + costs[idx] = costs[maxIdx]
  264 + end
257 265 end
258   - local diamond = globalCsv.diner_sell_quick_cost[count]
  266 +
  267 + local diamond = costs[count]
259 268 if diamond > 0 then
260 269 local cost = {[ItemId.Jade] = diamond}
261 270 if not role:checkItemEnough(cost) then
... ...
src/actions/EmailAction.lua
... ... @@ -124,6 +124,8 @@ function _M.drawAllAttachRpc(agent, data)
124 124 role:mylog("mail_action", {desc = "draw_attach", int1 = email:getProperty("emailId"), key1 = email:getProperty("title"), key2 = attachments})
125 125 end
126 126 end
  127 + if role:checkRuneFullyByReward(reward) then return 1 end
  128 +
127 129 reward, change = role:award(reward, {log = {desc = "draw_attach"}})
128 130 SendPacket(actionCodes.Email_drawAllAttachRpc, MsgPack.pack({ids = ids, reward = reward, change = change}))
129 131 return true
... ... @@ -143,8 +145,17 @@ function _M.drawAttachRpc(agent, data)
143 145 local attachments = getEmailAttachments(email)
144 146 if attachments == "" then return end
145 147  
146   - local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = id}})
  148 + local reward, change = {}
  149 + if type(attachments) == "string" then
  150 + for key, v in pairs(attachments:toNumMap()) do
  151 + reward[key] = (reward[key] or 0) + v
  152 + end
  153 + else
  154 + reward = attachments
  155 + end
147 156 if role:checkRuneFullyByReward(reward) then return 1 end
  157 + reward, change = role:award(reward, {log = {desc = "draw_attach", int1 = id}})
  158 +
148 159  
149 160 email:setProperty("status", 2, true)
150 161 email:log(role, 2)
... ...
src/actions/HangAction.lua
... ... @@ -478,6 +478,18 @@ function _M.quickRpc(agent , data)
478 478  
479 479 local curCount = role.dailyData:getProperty("hangQC") + 1
480 480 local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=")
  481 +
  482 + -- 增加今日探索加速次数
  483 + local maxIdx = #costs
  484 + local maxCount = maxIdx + role:getBnousUpSpeedNum(UpSpeedType.ExplorationUpSpeed)
  485 + if curCount > maxCount then return end
  486 +
  487 + if curCount > maxIdx then
  488 + for idx = maxIdx+1, curCount do
  489 + costs[idx] = costs[maxIdx]
  490 + end
  491 + end
  492 +
481 493 if not costs[curCount] then return end
482 494 if costs[curCount] > 0 then
483 495 if not role:checkItemEnough({[ItemId.Jade] = costs[curCount]}) then return end
... ... @@ -666,7 +678,7 @@ function _M.startBonusBattleRpc(agent, data)
666 678 if open and actData then
667 679 coef = tonumber(actData.condition2)
668 680 end
669   - if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end
  681 + if math.illegalNum(count, 1, (globalCsv.bonus_daily_count + role:getBnousChangeBaseCount()) * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end
670 682  
671 683 bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count
672 684 role.dailyData:updateProperty({field = "bonusC", value = bonusC})
... ...
src/actions/RoleAction.lua
... ... @@ -633,6 +633,7 @@ function _M.openTimeBoxRpc(agent, data)
633 633 else
634 634 local oldId, process, time = boxL[slot].id, boxL[slot].process, boxL[slot].time
635 635 local unitTime = globalCsv.box_key_time[oldId] * 60
  636 + unitTime = unitTime + role:getBnousDismantlingImproved(unitTime)
636 637 local doneCnt = time == 0 and 0 or math.floor((process + skynet.timex() - time) / unitTime)
637 638 if doneCnt > 0 then
638 639 reward = role:award({[oldId] = doneCnt}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}})
... ... @@ -642,7 +643,7 @@ function _M.openTimeBoxRpc(agent, data)
642 643 if role:getItemCount(itemId) >= limit then return 3 end
643 644  
644 645 boxL[slot] = {id = itemId, process = 0, time = skynet.timex()}
645   - role:pushMsg({type = "box", slot = slot, time = skynet.timex() + globalCsv.box_productLine_time * 3600})
  646 + role:pushMsg({type = "box", slot = slot, time = skynet.timex() + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()})
646 647 elseif oper == 2 then -- 重置运行时间(可以使用加速)
647 648 local quick = msg.quick
648 649 if not boxL[slot] then return 4 end
... ... @@ -652,6 +653,7 @@ function _M.openTimeBoxRpc(agent, data)
652 653 local stopTime = nowTime
653 654 local itemData = csvdb["itemCsv"][itemId]
654 655 local unitTime = globalCsv.box_key_time[itemId] * 60
  656 + unitTime = unitTime + role:getBnousDismantlingImproved(unitTime)
655 657 if quick then
656 658 stopTime = nowTime + quick
657 659 local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=")
... ... @@ -661,6 +663,8 @@ function _M.openTimeBoxRpc(agent, data)
661 663 else
662 664 stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600)
663 665 end
  666 + stopTime = stopTime + role:getBnousDismantlingMaximum()
  667 +
664 668 role:pushCancel({type = "box", slot = slot})
665 669  
666 670 local doneCnt = math.floor((process + stopTime - time) / unitTime)
... ... @@ -672,21 +676,23 @@ function _M.openTimeBoxRpc(agent, data)
672 676 end
673 677  
674 678 boxL[slot] = {id = itemId, process = (process + stopTime - time) % unitTime, time = nowTime}
675   - role:pushMsg({type = "box", slot = slot, time = nowTime + globalCsv.box_productLine_time * 3600})
  679 + role:pushMsg({type = "box", slot = slot, time = nowTime + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()})
676 680 elseif oper == 3 then -- 开箱子
677 681 local costId = msg.costId
678 682 local costs = (msg.costs or ""):toNumMap()
679 683 if not costId or not csvdb["itemCsv"][costId] or not next(costs) then return 6 end
680 684  
681 685 local costIdData = csvdb["itemCsv"][costId]
682   - local count = 0
  686 + local count, runeCount = 0, 0
683 687 for itemId, num in pairs(costs) do
684 688 local itemIdData = csvdb["itemCsv"][itemId]
685 689 if not itemIdData or not csvdb["item_randomCsv"][itemId] or costIdData.quality ~= itemIdData.quality then return 7 end
  690 +
  691 + if itemIdData.type == ItemType.Rune then runeCount = runeCount + num end
686 692 count = count + num
687 693 end
688 694  
689   - if role:checkRuneFully(count) then return 10 end --开箱子,如果铭文仓库已经满了则不让开箱
  695 + if role:checkRuneFully(runeCount) then return 10 end --开箱子,如果铭文仓库已经满了则不让开箱
690 696  
691 697 if role:getItemCount(costId) < count then return 8 end
692 698 if not role:checkItemEnough(costs) then return 9 end
... ... @@ -701,8 +707,8 @@ function _M.openTimeBoxRpc(agent, data)
701 707 role:costItems({[itemId] = value}, {log = {desc = "openTimeBox"}})
702 708 for _ = 1, value do
703 709 for i = 1, 10 do
704   - local num = randomData["num" .. i]
705   - local gift = randomData["gift" .. i]
  710 + local num = randomData["num" .. tostring(i)]
  711 + local gift = randomData["gift" .. tostring(i)]
706 712 if num and gift and num > 0 and gift ~= "" then
707 713 local pool = {}
708 714 for _, temp in ipairs(gift:toArray()) do
... ... @@ -1392,7 +1398,20 @@ end
1392 1398 function _M.goldBuyRpc(agent, data)
1393 1399 local role = agent.role
1394 1400 local curT = role.dailyData:getProperty("goldBuyT")
1395   - local costD = globalCsv.idle_quickMoney_cost[curT]
  1401 +
  1402 + local costs = clone(globalCsv.idle_quickMoney_cost)
  1403 + -- 增加今日齿轮加速次数
  1404 + local maxIdx = #globalCsv.idle_quickMoney_cost
  1405 + local maxCount = maxIdx + role:getBnousUpSpeedNum(UpSpeedType.GearUpSpeed)
  1406 + if curT > maxCount then return end
  1407 + if curT > maxIdx then
  1408 + for idx = maxIdx+1, curCount do
  1409 + costs[idx] = costs[maxIdx]
  1410 + end
  1411 + end
  1412 +
  1413 + local costD = costs[curT]
  1414 +
1396 1415 if not costD then
1397 1416 return 1
1398 1417 end
... ...
src/models/Role.lua
... ... @@ -75,6 +75,7 @@ Role.schema = {
75 75 expireItem = {"table", {}}, --物品过期检查
76 76 funcOpen = {"table", {}}, --功能是否开放
77 77 funcLv = {"table", {}}, --功能等级
  78 + levelBnous = {"table", {}}, --等级奖励
78 79 -- loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL
79 80 crown = {"number", 0}, -- 看伴娘
80 81 silent = {"number", 0}, --禁言解禁时间
... ... @@ -349,6 +350,7 @@ function Role:data()
349 350 items = self:getProperty("items"):toNumMap(),
350 351 funcOpen = self:getProperty("funcOpen"),
351 352 funcLv = self:getProperty("funcLv"),
  353 + levelBnous = self:getProperty("levelBnous"),
352 354 -- loveStatus = self:getProperty("loveStatus"):toNumMap(),
353 355 timeReset = self:getProperty("timeReset"),
354 356 diamond = self:getAllDiamond(),
... ...
src/models/RolePlugin.lua
... ... @@ -284,6 +284,7 @@ function RolePlugin.bind(Role)
284 284 newExp = newExp - csvdb["player_expCsv"][level].exp
285 285 level = level + 1
286 286 self:checkTaskEnter("RoleLevelUp", {level = level})
  287 + self:getLevelBnous(level)
287 288 else
288 289 newExp = csvdb["player_expCsv"][level].exp - 1 -- 没有下一级了 经验溢出太多 扣除
289 290 end
... ... @@ -2753,45 +2754,145 @@ function RolePlugin.bind(Role)
2753 2754  
2754 2755 function Role:getBnousCrusade(value)
2755 2756 local towerBnous = self:getTowerBnousActive()
2756   - return self:getDeltaValue(towerBnous[SystemBnousType.CrusadeTask], value)
  2757 + local levelValue = self:getDeltaValue(self:getProperty("levelBnous")[SystemBnousType.CrusadeTask], value)
  2758 + local towerValue = self:getDeltaValue(towerBnous[SystemBnousType.CrusadeTask], value)
  2759 + return levelValue + towerValue
2757 2760 end
2758 2761  
2759 2762 function Role:getBnousDiner(type, value)
2760 2763 local towerBnous = self:getTowerBnousActive()
2761 2764 type = type or 1
2762   - local result
  2765 + local result, levelReault
2763 2766 if type == 1 then
2764 2767 result = towerBnous[SystemBnousType.DinerGet]
  2768 + levelReault = self:getProperty("levelBnous")[SystemBnousType.DinerGet]
2765 2769 elseif type == 2 then
2766 2770 result = towerBnous[SystemBnousType.DinerLimit]
  2771 + levelReault = self:getProperty("levelBnous")[SystemBnousType.DinerLimit]
2767 2772 elseif type == 3 then
2768 2773 result = towerBnous[SystemBnousType.DinerSell]
  2774 + levelReault = self:getProperty("levelBnous")[SystemBnousType.DinerSell]
2769 2775 elseif type == 4 then
2770 2776 result = towerBnous[SystemBnousType.DinerPrice]
  2777 + levelReault = self:getProperty("levelBnous")[SystemBnousType.DinerPrice]
2771 2778 end
2772   - return self:getDeltaValue(result, value)
  2779 + return self:getDeltaValue(result, value) + self:getDeltaValue(levelReault, value)
2773 2780 end
2774 2781  
  2782 + local function appendBnous(dstBnous, srcBnous)
  2783 + if not dstBnous or not srcBnous then return end
  2784 + for time, set in pairs(srcBnous) do
  2785 + if not dstBnous[time] then
  2786 + dstBnous[time] = {}
  2787 + end
  2788 + for key, value in pairs(set) do
  2789 + dstBnous[time][key] = (dstBnous[time][key] or 0) + value
  2790 + end
  2791 + end
  2792 + end
2775 2793 function Role:getBnousAdv()
2776 2794 local towerBnous = self:getTowerBnousActive()
  2795 + local levelBnous = self:getProperty("levelBnous")[SystemBnousType.Adv] or {}
  2796 + appendBnous(towerBnous[SystemBnousType.Adv], levelBnous)
2777 2797 return towerBnous[SystemBnousType.Adv] or {}
2778 2798 end
2779 2799  
2780 2800 function Role:getBnousHangTime()
2781 2801 local towerBnous = self:getTowerBnousActive()
2782   - return towerBnous[SystemBnousType.HangTime] or 0
  2802 + local levelBnous = self:getProperty("levelBnous") or {}
  2803 + local tmptime = 0
  2804 + if next(levelBnous) then
  2805 + tmptime = levelBnous[SystemBnousType.HangTime] or 0
  2806 + end
  2807 + return towerBnous[SystemBnousType.HangTime] or 0 + tmptime
2783 2808 end
2784 2809  
2785 2810 function Role:getBnousPvpTicket()
2786 2811 local towerBnous = self:getTowerBnousActive()
  2812 + local levelBnous = self:getProperty("levelBnous")[SystemBnousType.PvpTicket] or {}
  2813 + appendBnous(towerBnous[SystemBnousType.PvpTicket], levelBnous)
2787 2814 return towerBnous[SystemBnousType.PvpTicket] or {}
2788 2815 end
2789 2816  
2790 2817 function Role:getBnousSweep()
2791 2818 local towerBnous = self:getTowerBnousActive()
  2819 + local levelBnous = self:getProperty("levelBnous")[SystemBnousType.SweepReward] or {}
  2820 + appendBnous(towerBnous[SystemBnousType.SweepReward], levelBnous)
2792 2821 return towerBnous[SystemBnousType.SweepReward] or {}
2793 2822 end
2794 2823  
  2824 + function Role:getBnousDismantlingMaximum()
  2825 + return self:getProperty("levelBnous")[SystemBnousType.DismantlingMaximum] or 0
  2826 + end
  2827 +
  2828 + function Role:getBnousDismantlingImproved(value)
  2829 + local result = self:getProperty("levelBnous")[SystemBnousType.DismantlingImproved] or {}
  2830 + return self:getDeltaValue(result, value)
  2831 + end
  2832 +
  2833 + function Role:getBnousDaily()
  2834 + local reward = {}
  2835 + local levelBnous = self:getProperty("levelBnous")[SystemBnousType.DailyReward] or {}
  2836 + for k, v in pairs(levelBnous) do
  2837 + reward[k] = (reward[k] or 0) + v
  2838 + end
  2839 + return reward
  2840 + end
  2841 +
  2842 + function Role:getBnousTreasureBaseMaximum()
  2843 + local levelBnous = self:getProperty("levelBnous")[SystemBnousType.TreasureBaseMaximum] or 0
  2844 + local treasureBase = self.dailyData:getProperty("treasureBase") + levelBnous
  2845 + self.dailyData:updateProperty({field = "treasureBase", value = treasureBase})
  2846 + end
  2847 +
  2848 + --@upType 加速类型 1探索加速, 2齿轮加速, 3餐厅加速
  2849 + function Role:getBnousUpSpeedNum(upType)
  2850 + local levelBnous = self:getProperty("levelBnous")[SystemBnousType.UpSpeedNum] or {}
  2851 + if next(levelBnous) then
  2852 + return levelBnous[upType] or 0
  2853 + end
  2854 + return 0
  2855 + end
  2856 +
  2857 + function Role:getBnousChangeBaseCount()
  2858 + return self:getProperty("levelBnous")[SystemBnousType.ChangeBaseCount] or 0
  2859 + end
  2860 +
  2861 + function Role:getLevelBnous(level)
  2862 + local levelBnous = self:getProperty("levelBnous")
  2863 + local additionData = csvdb["level_additionCsv"][level]
  2864 + if additionData then
  2865 + local effects = additionData.effect:toTableArraySec()
  2866 + for _, effect in pairs(effects) do
  2867 + local pm1, pm2, pm3, pm4 = tonumber(effect[1]), tonumber(effect[2]), tonumber(effect[3]), tonumber(effect[4])
  2868 + if not levelBnous[pm1] then
  2869 + levelBnous[pm1] = {}
  2870 + end
  2871 + if pm1 == SystemBnousType.TowerBuff then
  2872 +
  2873 + elseif pm1 == SystemBnousType.Adv then
  2874 + if not levelBnous[pm1][pm4] then
  2875 + levelBnous[pm1][pm4] = {}
  2876 + end
  2877 + levelBnous[pm1][pm4][pm2] = (levelBnous[pm1][pm4][pm2] or 0) + pm3
  2878 + elseif pm1 == SystemBnousType.HangTime or
  2879 + pm1 == SystemBnousType.ExploreMaximum or
  2880 + pm1 == SystemBnousType.DismantlingMaximum or
  2881 + pm1 == SystemBnousType.TreasureBaseMaximum or
  2882 + pm1 == SystemBnousType.ChangeBaseCount then
  2883 + if type(levelBnous[pm1]) == "table" then
  2884 + levelBnous[pm1] = 0
  2885 + end
  2886 + levelBnous[pm1] = levelBnous[pm1] + pm2
  2887 + else
  2888 + levelBnous[pm1][pm2] = (levelBnous[pm1][pm2] or 0) + pm3
  2889 + end
  2890 + end
  2891 + end
  2892 + self:updateProperty({field = "levelBnous", value= levelBnous})
  2893 + return levelBnous
  2894 + end
  2895 +
2795 2896 function Role:getPotionLevel(id)
2796 2897 local level = self.dinerData:getProperty("dishTree"):getv(id, 1)
2797 2898 local talentSet = csvdb["diner_talentCsv"][id]
... ... @@ -2838,7 +2939,7 @@ function RolePlugin.bind(Role)
2838 2939 count = count or 0
2839 2940 local page = globalCsv.store_type[ItemType.Rune]
2840 2941 local limit = self:getProperty("bagLimit")[page]
2841   - return self:getRuneBatCount() + count >= limit
  2942 + return self:getRuneBatCount() + count > limit
2842 2943 end
2843 2944  
2844 2945 function Role:checkRuneFullyByReward(reward)
... ... @@ -2889,6 +2990,8 @@ function RolePlugin.bind(Role)
2889 2990 self:sendMail(20, nil, tmpreward)
2890 2991 end
2891 2992 end
  2993 +
  2994 +
2892 2995 end
2893 2996  
2894 2997 return RolePlugin
2895 2998 \ No newline at end of file
... ...