From 00bf602997553cb76b3b9360da30d171b742d418 Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Wed, 14 Oct 2020 17:49:09 +0800 Subject: [PATCH] 限时礼包,抽卡ssr广播 --- src/GlobalVar.lua | 7 +++++-- src/ProtocolCode.lua | 1 + src/actions/HangAction.lua | 14 ++++++++++---- src/actions/HeroAction.lua | 8 ++++++-- src/csvdata | 2 +- src/models/Hero.lua | 4 ++++ src/models/RolePlugin.lua | 16 +++++++++++++++- src/models/RoleTask.lua | 4 ++++ src/models/Store.lua | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------- 9 files changed, 108 insertions(+), 63 deletions(-) diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index e1fad09..9e861ca 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -307,9 +307,12 @@ MailId = { } TriggerEventType = { - HangPass = 1, - LevelUp = 2, + HangPass = 1, + AdvPass = 2, TowerPass = 3, + LevelUp = 4, + AddNewHero = 5, + SSRCount = 6, } DrawCardType = { diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index d864e92..b1ef457 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -47,6 +47,7 @@ actionCodes = { Role_getDownloadCvRewardRpc = 132, Role_updateFeedbackInfoRpc = 133, Role_useSelectItemRpc = 134, -- 使用多选一礼包 + Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 Adv_startAdvRpc = 151, Adv_startHangRpc = 152, diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 2b56e2b..335d26e 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -26,6 +26,8 @@ local function checkReward(role) local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) + local expCoef, itemCoef = role.storeData:getHangDropCoef() + -- 此次挂机,其中翻倍时长占多少 local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime) local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime @@ -39,7 +41,7 @@ local function checkReward(role) hangInfo.itemTime = nowItemTime local items = role:getProperty("hangBag") - coinCount = coinCount + coinDoubleCount + coinCount = (coinCount + coinDoubleCount) * expCoef items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * expCarbonData.money) items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) @@ -75,6 +77,7 @@ local function checkReward(role) if cur[1] == ItemId.BreakCost and doubleTime > 0 then cur[2] = cur[2] * 2 end + cur[2] = cur[2] * itemCoef if (items[cur[1]] and math.ceil((items[cur[1]] + cur[2]) / globalCsv.idle_field_limit) > math.ceil(items[cur[1]] / globalCsv.idle_field_limit)) or not items[cur[1]] then --要占用新栏位的情况 local addFC @@ -500,8 +503,9 @@ function _M.buyBonusCountRpc(agent, data) end local bonusC = role.dailyData:getProperty("bonusC") + local extraCnt = role.storeData:getBonusExtraFightCount() bonusC[btype] = bonusC[btype] or {c = 0, b = 0} - local lastCount = globalCsv.bonus_daily_buy_count * coef - bonusC[btype]["b"] + local lastCount = globalCsv.bonus_daily_buy_count * coef + extraCnt - bonusC[btype]["b"] if math.illegalNum(count, 1, lastCount) then return 1 end if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end @@ -541,12 +545,13 @@ function _M.startBonusBattleRpc(agent, data) local actData = csvdb["activity_ctrlCsv"][actId] + local extraCnt = role.storeData:getBonusExtraFightCount() local coef = 1 if open and actData then coef = tonumber(actData.condition2) end - if globalCsv.bonus_daily_count * coef - bonusC[bonusData.type]["c"] <= 0 then return 7 end + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 7 end role.__bonusBattleCache = { @@ -566,6 +571,7 @@ function _M.endBonusBattleRpc(agent, data) if not role.__bonusBattleCache then return 1 end local open, actId = role.activity:isOpen("BonusDouble") local actData = csvdb["activity_ctrlCsv"][actId] + local extraCnt = role.storeData:getBonusExtraFightCount() local coef = 1 if open and actData then @@ -583,7 +589,7 @@ function _M.endBonusBattleRpc(agent, data) -- 胜利扣除次数 local bonusC = role.dailyData:getProperty("bonusC") bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} - if globalCsv.bonus_daily_count * coef - bonusC[bonusData.type]["c"] <= 0 then return 3 end + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 3 end bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1 role.dailyData:updateProperty({field = "bonusC", value = bonusC}) diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index b5418ca..74f6ba2 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -846,7 +846,7 @@ function _M.drawHeroRpc(agent, data) role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) - local guideHero + local guideHero = nil if role:getProperty("newerGuide") == "11=1" then guideHero = globalCsv.newdraw_hero_item_id or 613 end @@ -867,12 +867,16 @@ function _M.drawHeroRpc(agent, data) local itemId = math.randWeight(resultPool, 1) if guideHero then itemId = guideHero - guideHero = nil end local itemData = csvdb["itemCsv"][itemId] if itemData.quality == HeroQuality.SSR then ssrCount = ssrCount + 1 + if not guideHero then + -- STODO 广播获得ssr英雄 + local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} + mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) + end end if itemData.quality >= HeroQuality.SR then diff --git a/src/csvdata b/src/csvdata index 29d26c6..a79b329 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 29d26c6e3083676ddaa828f8d0b22cd1d0ee48cf +Subproject commit a79b3296ccaa4f24e2263de83dc8dc581f1eb75a diff --git a/src/models/Hero.lua b/src/models/Hero.lua index 37ac7b7..d700672 100644 --- a/src/models/Hero.lua +++ b/src/models/Hero.lua @@ -109,4 +109,8 @@ function Hero:getCamp() return csvdb["unitCsv"][self:getProperty("type")].camp end +function Hero:getRare() + return csvdb["unitCsv"][self:getProperty("type")].rare +end + return Hero \ No newline at end of file diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index accd842..6827b5c 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -452,7 +452,11 @@ function RolePlugin.bind(Role) newHero.owner = self newHero:saveBattleValue() self.heros[heroId] = newHero - self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify) + local ssrCount = 0 + if unitData.rare == HeroQuality.SSR then + ssrCount = self:getSSRHeroCount() + end + self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job, ssrCount = ssrCount}, params.notNotify) self:checkTaskEnter("HeroQualityCollect", {}) if not params.notNotify then local heroResponse = {} @@ -486,6 +490,16 @@ function RolePlugin.bind(Role) end end + function Role:getSSRHeroCount() + local count = 0 + for _, hero in pairs(self.heros) do + if hero:getRare() == HeroQuality.SSR then + count = count + 1 + end + end + return count + end + function Role:loadHeros() local roleId = self:getProperty("id") diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index bf28102..874df13 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -235,6 +235,8 @@ local StoreListener = { [TaskType.HangPass] = {{TriggerEventType.HangPass, f("id")}}, [TaskType.RoleLevelUp] = {{TriggerEventType.LevelUp, f("level")}}, [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}}, + [TaskType.AdvPass] = {{TriggerEventType.AdvPass, f("id")}}, + [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, } } @@ -580,10 +582,12 @@ function RoleTask.bind(Role) end function Role:checkActivityTask(notNotify, activityType, ...) + if not self.activity then return end self.activity:checkActivity(notNotify, activityType, ...) end function Role:checkStoreTask(notNotify, triggerType, param) + if not self.storeData then return end self.storeData:OnTriggerLimitTimePack(triggerType, param) end diff --git a/src/models/Store.lua b/src/models/Store.lua index c559f64..c7d9d01 100644 --- a/src/models/Store.lua +++ b/src/models/Store.lua @@ -23,11 +23,11 @@ Store.schema = { battleFR = {"string", ""}, -- 免费赛季卡领取记录 battleLR = {"string", ""}, -- 付费赛季卡领取记录 - limitTPack = {"table", {}}, -- 限时礼包 {id=expire_ts} + limitTPack = {"table", {}}, -- 限时礼包 {id={expire_ts, trigger_type}} privCardEx = {"number", 0}, -- 特权卡过期时间戳 getMailT1 = {"number",0}, -- 上次发送月卡福利邮件的时间 getMailT2 = {"number",0}, -- 上次发送超级月卡福利邮件的时间 - packTrigger = {"table", {}}, -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...} + --packTrigger = {"table", {}}, -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...} -- 活动商品购买记录 actGoodsFlag = {"table", {}}, -- ActGoodsType 1购买,0未购买 @@ -65,10 +65,11 @@ function Store:deleteExpireLimitGoods() local timeNow = skynet.timex() local limitGoodsList = self:getProperty("limitTPack") for k, v in pairs(limitGoodsList) do - if timeNow > v then + if timeNow > v[1] then limitGoodsList[k] = nil end end + self:updateProperty({field = "limitTPack", value = limitGoodsList, notNotify = true}) end -- 发送月卡邮件 @@ -162,6 +163,26 @@ function Store:getGearExchangeCoef() return 1 + coef end +-- 奖励关卡 特权卡额外数量 +function Store:getBonusExtraFightCount() + if self:isPrivCardExpire() then + return 0 + end + + local cnt = globalCsv.bonus_extra_fight_count or 1 + return cnt +end + +-- 挂机道具掉落系数 特权卡挂机掉落系数 +function Store:getHangDropCoef() + if self:isPrivCardExpire() then + return 0, 0 + end + + return (1 + globalCsv.hang_drop_exp_coef) or 1, (1 + globalCsv.hang_drop_item_coef) or 1 +end + + -- 购买通行证 function Store:onBuyCard(type, duration, id) local timeNow = skynet.timex() @@ -292,64 +313,52 @@ end --触发限时礼包 function Store:OnTriggerLimitTimePack(eventType, param) local limitPack = self:getProperty("limitTPack") - local payRecord = self:getProperty("payR") + --local payRecord = self:getProperty("payR") local timeNow = skynet.timex() - local find = false + --local find = false -- 有未过期的限时礼包不再推送 - for k, v in pairs(limitPack) do - if v > timeNow and not payRecord[k] then - find = true - break - end - end - if find == true then - return - end - limitPack = {} - local hangPass = self.owner:getProperty("hangPass") - local triggerRecord = self:getProperty("packTrigger") - local result = {} - local maxDiff = 0 + --for k, v in pairs(limitPack) do + -- if v > timeNow and not payRecord[k] then + -- find = true + -- break + -- end + --end + --if find == true then + -- return + --end + --local hangPass = self.owner:getProperty("hangPass") + --local triggerRecord = self:getProperty("packTrigger") + --local result = {} + --local maxDiff = 0 -- 取满足限时礼包关卡要求的对应数据 - for diff, maxCarbonId in pairs(hangPass) do - for id, cfg in pairs(csvdb["shop_packCsv"]) do - local range = cfg.showRange:toArray(true, "=") - local beginRange = range[1] or 0 - local endRange = range[2] or 0 - if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then - result[diff] = cfg - maxDiff = math.max(maxDiff, diff) - break - end - end - end - local shopGoodsId = 0 - for diff, cfg in pairs(result) do - if diff == maxDiff then - local record = triggerRecord[diff] or {} - if (record[0] or 0) ~= cfg.id and next(record) then - record = {} - end - record[0] = cfg.id - record[eventType] = (record[eventType] or 0) + 1 - if record[eventType] > 0 and record[eventType] % 10 == 0 then - local pool = cfg.packId:toArray(true, "=") - local idx = math.random(1, #pool) - shopGoodsId = pool[idx] - end - triggerRecord[diff] = record + --for diff, maxCarbonId in pairs(hangPass) do + -- for id, cfg in pairs(csvdb["shop_packCsv"]) do + -- local range = cfg.showRange:toArray(true, "=") + -- local beginRange = range[1] or 0 + -- local endRange = range[2] or 0 + -- if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then + -- result[diff] = cfg + -- maxDiff = math.max(maxDiff, diff) + -- break + -- end + -- end + --end + local config = nil + for id, cfg in pairs(csvdb["shop_packCsv"]) do + if cfg.type == eventType and cfg.condition == param then + config = cfg end end - if shopGoodsId ~= 0 then - local rechargeCfg = csvdb["shop_rechargeCsv"][shopGoodsId] + if config ~= nil then + local rechargeCfg = csvdb["shop_rechargeCsv"][config.packId] if rechargeCfg then - limitPack[rechargeCfg.id] = timeNow + rechargeCfg.time + limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id} self:updateProperty({field = "limitTPack", value = limitPack}) end end - if next(result) then - self:updateProperty({field = "packTrigger", value = triggerRecord}) - end + --if next(result) then + -- self:updateProperty({field = "packTrigger", value = triggerRecord}) + --end end function GetActGoodsIndex(goodsType) @@ -419,7 +428,7 @@ function Store:data() battleLR = self:getProperty("battleLR"), limitTPack = self:getProperty("limitTPack"), privCardEx = self:getProperty("privCardEx"), - packTrigger = self:getProperty("packTrigger"), + --packTrigger = self:getProperty("packTrigger"), actGoodsFlag = self:getProperty("actGoodsFlag"), bpInfo = self:getProperty("bpInfo"), } -- libgit2 0.21.2