From e52c384f1048cf45fc2d22d9c3dbf8d24a0d6a9e Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Thu, 10 Sep 2020 17:23:20 +0800 Subject: [PATCH] 探索指令bug, 充值返利活动 --- src/actions/GmAction.lua | 2 +- src/actions/RoleAction.lua | 7 +++---- src/actions/StoreAction.lua | 2 +- src/csvdata | 2 +- src/models/Activity.lua | 21 +++++++++++++++++++++ src/models/Role.lua | 2 ++ src/models/RolePlugin.lua | 36 +++++++++++++++++++++++++++++++++++- src/models/RoleTask.lua | 2 ++ 8 files changed, 66 insertions(+), 8 deletions(-) diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index c359400..4988aa9 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -487,7 +487,7 @@ function _M.test(role, pms) local id = tonum(pms.pm1, 0) --local hero = require ("actions.HeroAction") --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) - print(role:getNextCarbonId(id)) + print(role:getPaybackReward(0, 10000)) return "成功" end diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 8ea3519..1aa3a6f 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -1211,20 +1211,18 @@ function _M.useSelectItemRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local itemId = msg.itemId - local index = msg.index + local subId = msg.subId local count = msg.count if math.illegalNum(count, 1, role:getItemCount(itemId)) then return end local itemData = csvdb["itemCsv"][itemId] if itemData.type ~= ItemType.SelectItemBox then return end local itemMap = itemData.use_effect:toNumMap() - local i = 1 local reward, change = {} for k, v in pairs(itemMap) do - if i == index then + if k == subId then reward[k] = v * count break end - i = i + 1 end if next(reward) then @@ -1232,6 +1230,7 @@ function _M.useSelectItemRpc(agent, data) role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) end SendPacket(actionCodes.Role_useSelectItemRpc, MsgPack.pack(role:packReward(reward, change))) + return true end return _M \ No newline at end of file diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index 70ec224..12084ac 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -386,7 +386,7 @@ function _M.getExploreCommandRewardRpc(agent, data) local subId = msg.subId -- 领取的阶段id local tab_name = "reward_levelpass" .. id .. "Csv" - local config = csvdb[tab_name][id] + local config = csvdb[tab_name][subId] if not config then return end local bpInfo = role.storeData:getProperty("bpInfo") or {} diff --git a/src/csvdata b/src/csvdata index 2cd316b..9ce6c8d 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 2cd316b4df0f855713b9457114a97714df4d55f1 +Subproject commit 9ce6c8d165817a183c2867c4e7dca9d6a5600669 diff --git a/src/models/Activity.lua b/src/models/Activity.lua index 6229558..83a521e 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -9,6 +9,7 @@ Activity.ActivityType = { AdvDraw = 5, --拾荒抽周 资助 OpenBox = 6, --拆解周 时钟箱 PaySignIn = 7, --付费签到 + PayBack = 9, --返利 SsrUpPoolChange = 10, -- 特定英雄活动,切卡池 } @@ -38,6 +39,7 @@ Activity.schema = { act5 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 act6 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 act7 = {"table", {}}, -- {1 = 1, 2 = 1} == 付费签到活动 + act9 = {"number", 0}, -- 充值返利 } function Activity:data() @@ -50,6 +52,7 @@ function Activity:data() act5 = self:getProperty("act5"), act6 = self:getProperty("act6"), act7 = self:getProperty("act7"), + act9 = self:getProperty("act9"), } end @@ -324,6 +327,24 @@ activityFunc[Activity.ActivityType.PaySignIn] = { -- end, } +-- 充值反馈 +activityFunc[Activity.ActivityType.PayBack] = { + ["check"] = function(self, actType, notify, twd) -- 检查 + local oldVal = self:getActData(actType) or 0 + local newVal = oldVal + twd + local gift = self.owner:getPaybackReward(oldVal, newVal) + if gift ~= "" then + self.owner:sendMail(MailId.MonthCard, nil, gift) + end + self:updateActData(actType, newVal, not notify) + end, + ["init"] = function(self, actType, isCrossDay, notify) + self:updateActData(actType, {}, not notify) + end, + -- ["close"] = function(self, actType, notify) + -- end, +} + function Activity:initActivity(actType, isCrossDay, notify) if activityFunc[actType] and activityFunc[actType]['close'] then activityFunc[actType]["init"](self, actType, isCrossDay, notify) diff --git a/src/models/Role.lua b/src/models/Role.lua index 0e677de..a3abc0c 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -149,6 +149,7 @@ Role.schema = { battlePoint = {"number", 0}, -- 赛季卡使用的活跃点 rmbC = {"number", 0}, -- 人民币重置额 + twdC = {"number", 0}, -- 台币总充值金额 emailSync = {"number", 0}, -- 已经同步到的邮件Id @@ -373,6 +374,7 @@ function Role:data() battlePoint = self:getProperty("battlePoint"), rmbC = self:getProperty("rmbC"), + twdC = self:getProperty("twdC"), repayHero = self:getProperty("repayHero"), newerDraw = self:getProperty("newerDraw"), floorHero = self:getProperty("floorHero"), diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 4757bab..8c21a5d 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1586,10 +1586,13 @@ function RolePlugin.bind(Role) reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount end + self:checkTaskEnter("Pay", {rmb = rechargeData.rmb, twd = rechargeData.twd}) + -- 累充 local rmb = rechargeData.rmb self:updateProperty({field = "rmbC", delta = rmb}) - + self:updateProperty({field = "twdC", delta = rechargeData.twd}) + self:mylog("role_action", {desc = "recharge", int1 = id, int2 = rmb, key1 = params.transactionId, key2 = params.order, long1 = params.pay_time}) return nil, reward @@ -1695,6 +1698,37 @@ function RolePlugin.bind(Role) return nextId end + -- 根据累计充值金额计算奖励档位 + function Role:getPaybackReward(oldVal, newVal) + local maxVal, diff, extraReward = 0, 0, "" + local gift = "" + for k, v in pairs(csvdb["rebateCsv"]) do + if k > maxVal then + maxVal = k + end + if v.isLoop > diff then + diff = v.isLoop + extraReward = v.reward + end + if oldVal < k and newVal > k then + gift = gift .. v.reward .. " " + end + end + if newVal > maxVal then + local cnt = 0 + if oldVal < maxVal then + cnt = math.floor((newVal - maxVal) / diff) + else + cnt = math.floor((newVal - maxVal) / diff) - math.floor((oldVal - maxVal) / diff) + end + for i = 1, cnt do + gift = gift .. extraReward .. " " + end + end + + return gift + end + end return RolePlugin \ No newline at end of file diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 263ea9a..0f4d482 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -89,6 +89,7 @@ local TaskType = { WeBlog = 1010, -- 关注微博 SignIn = 1011, -- 签到 ShopAll = 1013, -- 在任意商店购买 + Pay = 1014, -- 充值 } local function f(field, func) @@ -216,6 +217,7 @@ local ActivityListener = { [TaskType.FoodSell] = {{Activity.ActivityType.FoodSell, f("count")}}, [TaskType.AdvDraw] = {{Activity.ActivityType.AdvDraw, f("count")}}, [TaskType.OpenBox] = {{Activity.ActivityType.OpenBox, f("count")}}, + [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, } } -- libgit2 0.21.2