From 317a46a9ed113032c8ee1709008c60cedfe025c0 Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Wed, 5 Aug 2020 21:07:56 +0800 Subject: [PATCH] 添加特权卡 --- src/ProtocolCode.lua | 6 +++--- src/actions/DinerAction.lua | 7 +++++++ src/actions/HangAction.lua | 14 +++++++++++++- src/actions/HeroAction.lua | 51 ++++++++++++++++++++++++++------------------------- src/actions/RoleAction.lua | 15 ++++++++++++--- src/actions/StoreAction.lua | 3 +++ src/models/Daily.lua | 2 ++ src/models/Role.lua | 5 ++++- src/models/Store.lua | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 9 files changed, 153 insertions(+), 38 deletions(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 58ba452..ca3c931 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -185,9 +185,9 @@ actionCodes = { Store_iosRechargeRpc = 557, Store_shopBuyRpc = 558, Store_updateproperty = 559, - Store_getFreeChectRpc = 559, - Store_getGrowFundRewardRpc = 560, --成长助力奖励 - Store_getBattlePassRewardRpc = 561, --赛季卡奖励 + Store_getFreeChectRpc = 560, + Store_getGrowFundRewardRpc = 561, --成长助力奖励 + Store_getBattlePassRewardRpc = 562, --赛季卡奖励 Email_listRpc = 600, diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index a5b3f56..14ca073 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -261,7 +261,14 @@ function _M.expediteSellRpc( agent, data ) role.dinerData:setProperty("expedite",count+1) role.dinerData:notifyUpdateProperty("expedite", count+1) local gift = reward:toNumMap() + + -- 特权卡获取加速获得额外道具 + local coef = role.storeData:getProduceItemSpeedCoef() for k, v in pairs(gift) do + if coef > 1 then + v = math.floor(v * coef) + gift[k] = v + end if k == ItemId.Gold then role:checkTaskEnter("FoodSellGold", {count = v}) end diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 44baef5..3c56a61 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -48,7 +48,10 @@ local function checkReward(role) curIC = curIC + count end end - local selfFC = role:getProperty("hangBagLimit") --再加上月卡的栏位 TODO + + -- 特权卡挂机额外栏位 + local privExtraCnt = role.storeData:getHangSlotExtraCount() + local selfFC = role:getProperty("hangBagLimit") + privExtraCnt local selfIC = selfFC * globalCsv.idle_field_limit local function randomItem() @@ -391,6 +394,15 @@ function _M.quickRpc(agent , data) local cur = pool[math.randWeight(pool, 3)] reward[cur[1]] = (reward[cur[1]] or 0) + cur[2] end + + -- 特权卡获取加速获得额外道具 + local coef = role.storeData:getProduceItemSpeedCoef() + if coef > 1 then + for k, cnt in pairs(reward) do + reward[k] = math.floor(cnt * coef) + end + end + local change reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) if reward[ItemId.Gold] then diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 4f0cd38..6739c49 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -921,32 +921,33 @@ function _M.drawHeroRpc(agent, data) return true end --- function _M.repayHeroRpc(agent, data) --- local role = agent.role +function _M.repayHeroRpc(agent, data) + local role = agent.role --- local repayHero = role:getProperty("repayHero") --- if repayHero < globalCsv.draw_super_repay_count then --- return --- end + local repayHero = role:getProperty("repayHero") + if repayHero < globalCsv.draw_free_count then + return + end + local result = repayHero - globalCsv.draw_free_count --- role:updateProperty({field = "repayHero", value = 0}) --- local id = math.randWeight(csvdb["build_giftCsv"], "pool_1") - --- local reward = {} --- local itemData = csvdb["itemCsv"][id] --- if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then --- local fragId = itemData.id - ItemStartId.Hero --- local heroData = csvdb["unitCsv"][fragId] --- local count = globalCsv.draw_unit_tofragment[heroData.rare] --- role:award({[fragId] = count}, {log = {desc = "heroRepay"}}) --- reward = {id = fragId, count = count, from = id, fcount = 1} --- else --- role:award({[id] = 1}, {log = {desc = "heroRepay"}}) --- reward = {id = id, count = 1} --- end --- role:log("hero_action", {desc = "heroRepay"}) --- SendPacket(actionCodes.Hero_repayHeroRpc, MsgPack.pack({reward = reward})) --- return true --- end + role:updateProperty({field = "repayHero", value = result}) + local id = math.randWeight(csvdb["build_giftCsv"], "pool_1") + + local reward = {} + local itemData = csvdb["itemCsv"][id] + if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then + local fragId = itemData.id - ItemStartId.Hero + local heroData = csvdb["unitCsv"][fragId] + local count = globalCsv.draw_unit_tofragment[heroData.rare] + role:award({[fragId] = count}, {log = {desc = "heroRepay"}}) + reward = {id = fragId, count = count, from = id, fcount = 1} + else + role:award({[id] = 1}, {log = {desc = "heroRepay"}}) + reward = {id = id, count = 1} + end + role:log("hero_action", {desc = "heroRepay", int1=result}) + SendPacket(actionCodes.Hero_repayHeroRpc, MsgPack.pack({reward = reward})) + return true +end return _M \ No newline at end of file diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index b4dac38..d82c4cd 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -459,7 +459,12 @@ function _M.openTimeBoxRpc(agent, data) local msg = MsgPack.unpack(data) local oper = msg.oper -- 操作 1 - 2 local slot = msg.slot -- 位置 1 - 6 - if math.illegalNum(slot, 1, role:getFuncLv(FuncOpenType.TimeBoxSlot)) then return end + + -- 特权卡时间箱额外栏位 + local privExtraCnt = role.storeData:getTimeBoxSlotExtraCount() + if oper == 1 then + if math.illegalNum(slot, 1, role:getFuncLv(FuncOpenType.TimeBoxSlot) + privExtraCnt) then return end + end local boxL = role:getProperty("boxL") local reward, change = {} @@ -635,7 +640,7 @@ function _M.taskRpc(agent, data) if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end - local taskType = msg.type -- 1 日常 2 周长 + local taskType = msg.type -- 1 日常 2 周常 local taskId = msg.id --任务id local roleField = {"dTask", "wTask"} if not roleField[taskType] then return 1 end @@ -655,9 +660,11 @@ function _M.taskRpc(agent, data) role:changeUpdates({ { type = roleField[taskType], field = {"t", taskId}, value = -1 }, - { type = roleField[taskType], field = "a", value = active} + { type = roleField[taskType], field = "a", value = active}, }) + role:updateProperty({field = "battlePoint", role:getProperty("battlePoint") + 100}) + SendPacket(actionCodes.Role_taskRpc, MsgPack.pack(role:packReward(reward, change))) return true end @@ -1047,6 +1054,8 @@ function _M.goldBuyRpc(agent, data) if goldC == 0 then return 3 end + local coef = role.storeData:getGearExchangeCoef() + goldC = goldC * coef role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}}) local reward, change = role:award({[ItemId.Gold] = goldC}, {log = {desc = "goldBuy"}}) diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index 6e124e1..d9468f0 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -323,6 +323,7 @@ function _M.getFreeCheckRpc(agent, data) role.storeData:updateProperty({field = "payR", value = rechargeRecord}) SendPacket(actionCodes.Store_getFreeChectRpc, MsgPack.pack({reward = reward})) + return true end function _M.getGrowFundRewardRpc(agent, data) @@ -358,6 +359,7 @@ function _M.getGrowFundRewardRpc(agent, data) local reward, _ = role:award(gift, {log = {desc = "grownFund", int1 = id}}) SendPacket(actionCodes.Store_getGrowFundRewardRpc, MsgPack.pack({reward = reward})) + return true end function _M.getBattlePassRewardRpc(agent, data) @@ -406,6 +408,7 @@ function _M.getBattlePassRewardRpc(agent, data) local reward, _ = role:award(gift, {log = {desc = "battleCard", int1 = id}}) SendPacket(actionCodes.Store_getBattlePassRewardRpc, MsgPack.pack({reward = reward})) + return true end return _M \ No newline at end of file diff --git a/src/models/Daily.lua b/src/models/Daily.lua index 138491f..5082d66 100644 --- a/src/models/Daily.lua +++ b/src/models/Daily.lua @@ -25,6 +25,8 @@ Daily.schema = { advSupRe = {"number", 0}, -- 冒险支援效果刷新次数 goldBuyT = {"number", 0}, -- 金币购买次数 + + unlockPool = {"table", {}} -- 解锁的属性卡池 } function Daily:updateProperty(params) diff --git a/src/models/Role.lua b/src/models/Role.lua index 80fb0ea..b15d695 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -20,6 +20,7 @@ function Role:ctor( properties ) Role.super.ctor(self, properties) self.ignoreHeartbeat = false self.dailyData = nil + self.storeData = nil self.heros = {} self.runeBag = {} self.advData = nil @@ -140,12 +141,13 @@ Role.schema = { rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过 dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count} + battlePoint = {"number", 0}, -- 赛季卡使用的活跃点 rmbC = {"number", 0}, -- 人民币重置额 emailSync = {"number", 0}, -- 已经同步到的邮件Id - -- repayHero = {"number", 0}, -- 超级招募 回馈 + repayHero = {"number", 0}, -- 超级招募 回馈 floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr @@ -360,6 +362,7 @@ function Role:data() rechargeF = self:getProperty("rechargeF"), dinerS = self:getProperty("dinerS"), + battlePoint = self:getProperty("battlePoint"), rmbC = self:getProperty("rmbC"), -- repayHero = self:getProperty("repayHero"), diff --git a/src/models/Store.lua b/src/models/Store.lua index 66752d3..0ef66e0 100644 --- a/src/models/Store.lua +++ b/src/models/Store.lua @@ -16,7 +16,8 @@ Store.schema = { battleCardEx = {"number", 0}, -- 赛季卡过期时间戳 battleFR = {"string", ""}, -- 免费赛季卡领取记录 battleLR = {"string", ""}, -- 付费赛季卡领取记录 - limitTPack = {"table", {}} -- 限时礼包 {id=expire_ts} + limitTPack = {"table", {}}, -- 限时礼包 {id=expire_ts} + privCardEx = {"number", 0} -- 特权卡过期时间戳 } function Store:updateProperty(params) @@ -81,19 +82,95 @@ function Store:sendMonthCardEmail() end end +function Store:isMonthCardExpire() + local timeNow = skynet.timex() + local ts = self:getProperty("monthCardEx") + return ts < timeNow +end + +function Store:isSuperMonthCardExpire() + local timeNow = skynet.timex() + local ts = self:getProperty("smonthCardEx") + return ts < timeNow +end + +function Store:isPrivCardExpire() + local timeNow = skynet.timex() + local ts = self:getProperty("privCardEx") + return ts < timeNow +end + +function Store:isBattleCardExpire() + local timeNow = skynet.timex() + local ts = self:getProperty("battleCardEx") + return ts < timeNow +end + +-- 挂机栏位 特权卡额外个数 +function Store:getHangSlotExtraCount() + if self:isPrivCardExpire() then + return 0 + end + + return 4 +end + +-- 探索加速/餐厅加速 特权卡系数 +function Store:getProduceItemSpeedCoef() + if self:isPrivCardExpire() then + return 1 + end + + return 1 + 0.25 +end + +-- 拆解室栏位 特权卡额外个数 +function Store:getTimeBoxSlotExtraCount() + if self:isPrivCardExpire() then + return 0 + end + + return 3 +end + +-- 齿轮兑换 特权卡系数 +function Store:getGearExchangeCoef() + if self:isPrivCardExpire() then + return 1 + end + + return 1 + 0.5 +end + -- 购买通行证 function Store:onBuyCard(type, duration) - duration = duration == "" and 0 or tonumber(duration) local timeNow = skynet.timex() if type == CardType.NormalMonthCard then - self:updateProperty({field = "monthCardEx", value = timeNow + duration}) + if self:isMonthCardExpire() then + self:updateProperty({field = "monthCardEx", value = timeNow + duration}) + else + self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) + end elseif type == CardType.SuperMonthCard then - self:updateProperty({field = "smonthCardEx", value = timeNow + duration}) + if self:isSuperMonthCardExpire() then + self:updateProperty({field = "smonthCardEx", value = timeNow + duration}) + else + self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration}) + end elseif type == CardType.PrivilegeCard then + if self:isPrivCardExpire() then + self:updateProperty({field = "privCardEx", value = timeNow + duration}) + else + self:updateProperty({field = "privCardEx", value = self:getProperty("privCardEx") + duration}) + end elseif type == CardType.GrowFund then self:updateProperty({field = "growFund", value = 1}) elseif type == CardType.BattleCard then - self:updateProperty({field = "battleCardEx", value = timeNow + duration}) + if self:isBattleCardExpire() then + self:updateProperty({field = "battleCardEx", value = timeNow + duration}) + else + self:updateProperty({field = "battleCardEx", value = self:getProperty("battleCardEx") + duration}) + end end end @@ -128,6 +205,7 @@ function Store:data() battleCardEx = self:getProperty("battleCardEx"), battleCardR = self:getProperty("battleCardR"), limitTPack = self:getProperty("limitTPack"), + privCardEx = self:getProperty("privCardEx"), } end -- libgit2 0.21.2