Commit 00bf602997553cb76b3b9360da30d171b742d418
1 parent
bb5d94bd
限时礼包,抽卡ssr广播
Showing
9 changed files
with
108 additions
and
63 deletions
Show diff stats
src/GlobalVar.lua
src/ProtocolCode.lua
src/actions/HangAction.lua
| ... | ... | @@ -26,6 +26,8 @@ local function checkReward(role) |
| 26 | 26 | local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) |
| 27 | 27 | local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) |
| 28 | 28 | |
| 29 | + local expCoef, itemCoef = role.storeData:getHangDropCoef() | |
| 30 | + | |
| 29 | 31 | -- 此次挂机,其中翻倍时长占多少 |
| 30 | 32 | local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime) |
| 31 | 33 | local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime |
| ... | ... | @@ -39,7 +41,7 @@ local function checkReward(role) |
| 39 | 41 | hangInfo.itemTime = nowItemTime |
| 40 | 42 | |
| 41 | 43 | local items = role:getProperty("hangBag") |
| 42 | - coinCount = coinCount + coinDoubleCount | |
| 44 | + coinCount = (coinCount + coinDoubleCount) * expCoef | |
| 43 | 45 | items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * expCarbonData.money) |
| 44 | 46 | items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) |
| 45 | 47 | items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) |
| ... | ... | @@ -75,6 +77,7 @@ local function checkReward(role) |
| 75 | 77 | if cur[1] == ItemId.BreakCost and doubleTime > 0 then |
| 76 | 78 | cur[2] = cur[2] * 2 |
| 77 | 79 | end |
| 80 | + cur[2] = cur[2] * itemCoef | |
| 78 | 81 | 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)) |
| 79 | 82 | or not items[cur[1]] then --要占用新栏位的情况 |
| 80 | 83 | local addFC |
| ... | ... | @@ -500,8 +503,9 @@ function _M.buyBonusCountRpc(agent, data) |
| 500 | 503 | end |
| 501 | 504 | |
| 502 | 505 | local bonusC = role.dailyData:getProperty("bonusC") |
| 506 | + local extraCnt = role.storeData:getBonusExtraFightCount() | |
| 503 | 507 | bonusC[btype] = bonusC[btype] or {c = 0, b = 0} |
| 504 | - local lastCount = globalCsv.bonus_daily_buy_count * coef - bonusC[btype]["b"] | |
| 508 | + local lastCount = globalCsv.bonus_daily_buy_count * coef + extraCnt - bonusC[btype]["b"] | |
| 505 | 509 | if math.illegalNum(count, 1, lastCount) then return 1 end |
| 506 | 510 | |
| 507 | 511 | if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end |
| ... | ... | @@ -541,12 +545,13 @@ function _M.startBonusBattleRpc(agent, data) |
| 541 | 545 | |
| 542 | 546 | local actData = csvdb["activity_ctrlCsv"][actId] |
| 543 | 547 | |
| 548 | + local extraCnt = role.storeData:getBonusExtraFightCount() | |
| 544 | 549 | local coef = 1 |
| 545 | 550 | if open and actData then |
| 546 | 551 | coef = tonumber(actData.condition2) |
| 547 | 552 | end |
| 548 | 553 | |
| 549 | - if globalCsv.bonus_daily_count * coef - bonusC[bonusData.type]["c"] <= 0 then return 7 end | |
| 554 | + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 7 end | |
| 550 | 555 | |
| 551 | 556 | |
| 552 | 557 | role.__bonusBattleCache = { |
| ... | ... | @@ -566,6 +571,7 @@ function _M.endBonusBattleRpc(agent, data) |
| 566 | 571 | if not role.__bonusBattleCache then return 1 end |
| 567 | 572 | local open, actId = role.activity:isOpen("BonusDouble") |
| 568 | 573 | local actData = csvdb["activity_ctrlCsv"][actId] |
| 574 | + local extraCnt = role.storeData:getBonusExtraFightCount() | |
| 569 | 575 | |
| 570 | 576 | local coef = 1 |
| 571 | 577 | if open and actData then |
| ... | ... | @@ -583,7 +589,7 @@ function _M.endBonusBattleRpc(agent, data) |
| 583 | 589 | -- 胜利扣除次数 |
| 584 | 590 | local bonusC = role.dailyData:getProperty("bonusC") |
| 585 | 591 | bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} |
| 586 | - if globalCsv.bonus_daily_count * coef - bonusC[bonusData.type]["c"] <= 0 then return 3 end | |
| 592 | + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 3 end | |
| 587 | 593 | bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1 |
| 588 | 594 | role.dailyData:updateProperty({field = "bonusC", value = bonusC}) |
| 589 | 595 | ... | ... |
src/actions/HeroAction.lua
| ... | ... | @@ -846,7 +846,7 @@ function _M.drawHeroRpc(agent, data) |
| 846 | 846 | |
| 847 | 847 | role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) |
| 848 | 848 | |
| 849 | - local guideHero | |
| 849 | + local guideHero = nil | |
| 850 | 850 | if role:getProperty("newerGuide") == "11=1" then |
| 851 | 851 | guideHero = globalCsv.newdraw_hero_item_id or 613 |
| 852 | 852 | end |
| ... | ... | @@ -867,12 +867,16 @@ function _M.drawHeroRpc(agent, data) |
| 867 | 867 | local itemId = math.randWeight(resultPool, 1) |
| 868 | 868 | if guideHero then |
| 869 | 869 | itemId = guideHero |
| 870 | - guideHero = nil | |
| 871 | 870 | end |
| 872 | 871 | |
| 873 | 872 | local itemData = csvdb["itemCsv"][itemId] |
| 874 | 873 | if itemData.quality == HeroQuality.SSR then |
| 875 | 874 | ssrCount = ssrCount + 1 |
| 875 | + if not guideHero then | |
| 876 | + -- STODO 广播获得ssr英雄 | |
| 877 | + local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} | |
| 878 | + mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) | |
| 879 | + end | |
| 876 | 880 | end |
| 877 | 881 | |
| 878 | 882 | if itemData.quality >= HeroQuality.SR then | ... | ... |
src/models/Hero.lua
| ... | ... | @@ -109,4 +109,8 @@ function Hero:getCamp() |
| 109 | 109 | return csvdb["unitCsv"][self:getProperty("type")].camp |
| 110 | 110 | end |
| 111 | 111 | |
| 112 | +function Hero:getRare() | |
| 113 | + return csvdb["unitCsv"][self:getProperty("type")].rare | |
| 114 | +end | |
| 115 | + | |
| 112 | 116 | return Hero |
| 113 | 117 | \ No newline at end of file | ... | ... |
src/models/RolePlugin.lua
| ... | ... | @@ -452,7 +452,11 @@ function RolePlugin.bind(Role) |
| 452 | 452 | newHero.owner = self |
| 453 | 453 | newHero:saveBattleValue() |
| 454 | 454 | self.heros[heroId] = newHero |
| 455 | - self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify) | |
| 455 | + local ssrCount = 0 | |
| 456 | + if unitData.rare == HeroQuality.SSR then | |
| 457 | + ssrCount = self:getSSRHeroCount() | |
| 458 | + end | |
| 459 | + self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job, ssrCount = ssrCount}, params.notNotify) | |
| 456 | 460 | self:checkTaskEnter("HeroQualityCollect", {}) |
| 457 | 461 | if not params.notNotify then |
| 458 | 462 | local heroResponse = {} |
| ... | ... | @@ -486,6 +490,16 @@ function RolePlugin.bind(Role) |
| 486 | 490 | end |
| 487 | 491 | end |
| 488 | 492 | |
| 493 | + function Role:getSSRHeroCount() | |
| 494 | + local count = 0 | |
| 495 | + for _, hero in pairs(self.heros) do | |
| 496 | + if hero:getRare() == HeroQuality.SSR then | |
| 497 | + count = count + 1 | |
| 498 | + end | |
| 499 | + end | |
| 500 | + return count | |
| 501 | + end | |
| 502 | + | |
| 489 | 503 | |
| 490 | 504 | function Role:loadHeros() |
| 491 | 505 | local roleId = self:getProperty("id") | ... | ... |
src/models/RoleTask.lua
| ... | ... | @@ -235,6 +235,8 @@ local StoreListener = { |
| 235 | 235 | [TaskType.HangPass] = {{TriggerEventType.HangPass, f("id")}}, |
| 236 | 236 | [TaskType.RoleLevelUp] = {{TriggerEventType.LevelUp, f("level")}}, |
| 237 | 237 | [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}}, |
| 238 | + [TaskType.AdvPass] = {{TriggerEventType.AdvPass, f("id")}}, | |
| 239 | + [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, | |
| 238 | 240 | } |
| 239 | 241 | } |
| 240 | 242 | |
| ... | ... | @@ -580,10 +582,12 @@ function RoleTask.bind(Role) |
| 580 | 582 | end |
| 581 | 583 | |
| 582 | 584 | function Role:checkActivityTask(notNotify, activityType, ...) |
| 585 | + if not self.activity then return end | |
| 583 | 586 | self.activity:checkActivity(notNotify, activityType, ...) |
| 584 | 587 | end |
| 585 | 588 | |
| 586 | 589 | function Role:checkStoreTask(notNotify, triggerType, param) |
| 590 | + if not self.storeData then return end | |
| 587 | 591 | self.storeData:OnTriggerLimitTimePack(triggerType, param) |
| 588 | 592 | end |
| 589 | 593 | ... | ... |
src/models/Store.lua
| ... | ... | @@ -23,11 +23,11 @@ Store.schema = { |
| 23 | 23 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 |
| 24 | 24 | battleLR = {"string", ""}, -- 付费赛季卡领取记录 |
| 25 | 25 | |
| 26 | - limitTPack = {"table", {}}, -- 限时礼包 {id=expire_ts} | |
| 26 | + limitTPack = {"table", {}}, -- 限时礼包 {id={expire_ts, trigger_type}} | |
| 27 | 27 | privCardEx = {"number", 0}, -- 特权卡过期时间戳 |
| 28 | 28 | getMailT1 = {"number",0}, -- 上次发送月卡福利邮件的时间 |
| 29 | 29 | getMailT2 = {"number",0}, -- 上次发送超级月卡福利邮件的时间 |
| 30 | - packTrigger = {"table", {}}, -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...} | |
| 30 | + --packTrigger = {"table", {}}, -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...} | |
| 31 | 31 | |
| 32 | 32 | -- 活动商品购买记录 |
| 33 | 33 | actGoodsFlag = {"table", {}}, -- ActGoodsType 1购买,0未购买 |
| ... | ... | @@ -65,10 +65,11 @@ function Store:deleteExpireLimitGoods() |
| 65 | 65 | local timeNow = skynet.timex() |
| 66 | 66 | local limitGoodsList = self:getProperty("limitTPack") |
| 67 | 67 | for k, v in pairs(limitGoodsList) do |
| 68 | - if timeNow > v then | |
| 68 | + if timeNow > v[1] then | |
| 69 | 69 | limitGoodsList[k] = nil |
| 70 | 70 | end |
| 71 | 71 | end |
| 72 | + self:updateProperty({field = "limitTPack", value = limitGoodsList, notNotify = true}) | |
| 72 | 73 | end |
| 73 | 74 | |
| 74 | 75 | -- 发送月卡邮件 |
| ... | ... | @@ -162,6 +163,26 @@ function Store:getGearExchangeCoef() |
| 162 | 163 | return 1 + coef |
| 163 | 164 | end |
| 164 | 165 | |
| 166 | +-- 奖励关卡 特权卡额外数量 | |
| 167 | +function Store:getBonusExtraFightCount() | |
| 168 | + if self:isPrivCardExpire() then | |
| 169 | + return 0 | |
| 170 | + end | |
| 171 | + | |
| 172 | + local cnt = globalCsv.bonus_extra_fight_count or 1 | |
| 173 | + return cnt | |
| 174 | +end | |
| 175 | + | |
| 176 | +-- 挂机道具掉落系数 特权卡挂机掉落系数 | |
| 177 | +function Store:getHangDropCoef() | |
| 178 | + if self:isPrivCardExpire() then | |
| 179 | + return 0, 0 | |
| 180 | + end | |
| 181 | + | |
| 182 | + return (1 + globalCsv.hang_drop_exp_coef) or 1, (1 + globalCsv.hang_drop_item_coef) or 1 | |
| 183 | +end | |
| 184 | + | |
| 185 | + | |
| 165 | 186 | -- 购买通行证 |
| 166 | 187 | function Store:onBuyCard(type, duration, id) |
| 167 | 188 | local timeNow = skynet.timex() |
| ... | ... | @@ -292,64 +313,52 @@ end |
| 292 | 313 | --触发限时礼包 |
| 293 | 314 | function Store:OnTriggerLimitTimePack(eventType, param) |
| 294 | 315 | local limitPack = self:getProperty("limitTPack") |
| 295 | - local payRecord = self:getProperty("payR") | |
| 316 | + --local payRecord = self:getProperty("payR") | |
| 296 | 317 | local timeNow = skynet.timex() |
| 297 | - local find = false | |
| 318 | + --local find = false | |
| 298 | 319 | -- 有未过期的限时礼包不再推送 |
| 299 | - for k, v in pairs(limitPack) do | |
| 300 | - if v > timeNow and not payRecord[k] then | |
| 301 | - find = true | |
| 302 | - break | |
| 303 | - end | |
| 304 | - end | |
| 305 | - if find == true then | |
| 306 | - return | |
| 307 | - end | |
| 308 | - limitPack = {} | |
| 309 | - local hangPass = self.owner:getProperty("hangPass") | |
| 310 | - local triggerRecord = self:getProperty("packTrigger") | |
| 311 | - local result = {} | |
| 312 | - local maxDiff = 0 | |
| 320 | + --for k, v in pairs(limitPack) do | |
| 321 | + -- if v > timeNow and not payRecord[k] then | |
| 322 | + -- find = true | |
| 323 | + -- break | |
| 324 | + -- end | |
| 325 | + --end | |
| 326 | + --if find == true then | |
| 327 | + -- return | |
| 328 | + --end | |
| 329 | + --local hangPass = self.owner:getProperty("hangPass") | |
| 330 | + --local triggerRecord = self:getProperty("packTrigger") | |
| 331 | + --local result = {} | |
| 332 | + --local maxDiff = 0 | |
| 313 | 333 | -- 取满足限时礼包关卡要求的对应数据 |
| 314 | - for diff, maxCarbonId in pairs(hangPass) do | |
| 315 | - for id, cfg in pairs(csvdb["shop_packCsv"]) do | |
| 316 | - local range = cfg.showRange:toArray(true, "=") | |
| 317 | - local beginRange = range[1] or 0 | |
| 318 | - local endRange = range[2] or 0 | |
| 319 | - if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then | |
| 320 | - result[diff] = cfg | |
| 321 | - maxDiff = math.max(maxDiff, diff) | |
| 322 | - break | |
| 323 | - end | |
| 324 | - end | |
| 325 | - end | |
| 326 | - local shopGoodsId = 0 | |
| 327 | - for diff, cfg in pairs(result) do | |
| 328 | - if diff == maxDiff then | |
| 329 | - local record = triggerRecord[diff] or {} | |
| 330 | - if (record[0] or 0) ~= cfg.id and next(record) then | |
| 331 | - record = {} | |
| 332 | - end | |
| 333 | - record[0] = cfg.id | |
| 334 | - record[eventType] = (record[eventType] or 0) + 1 | |
| 335 | - if record[eventType] > 0 and record[eventType] % 10 == 0 then | |
| 336 | - local pool = cfg.packId:toArray(true, "=") | |
| 337 | - local idx = math.random(1, #pool) | |
| 338 | - shopGoodsId = pool[idx] | |
| 339 | - end | |
| 340 | - triggerRecord[diff] = record | |
| 334 | + --for diff, maxCarbonId in pairs(hangPass) do | |
| 335 | + -- for id, cfg in pairs(csvdb["shop_packCsv"]) do | |
| 336 | + -- local range = cfg.showRange:toArray(true, "=") | |
| 337 | + -- local beginRange = range[1] or 0 | |
| 338 | + -- local endRange = range[2] or 0 | |
| 339 | + -- if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then | |
| 340 | + -- result[diff] = cfg | |
| 341 | + -- maxDiff = math.max(maxDiff, diff) | |
| 342 | + -- break | |
| 343 | + -- end | |
| 344 | + -- end | |
| 345 | + --end | |
| 346 | + local config = nil | |
| 347 | + for id, cfg in pairs(csvdb["shop_packCsv"]) do | |
| 348 | + if cfg.type == eventType and cfg.condition == param then | |
| 349 | + config = cfg | |
| 341 | 350 | end |
| 342 | 351 | end |
| 343 | - if shopGoodsId ~= 0 then | |
| 344 | - local rechargeCfg = csvdb["shop_rechargeCsv"][shopGoodsId] | |
| 352 | + if config ~= nil then | |
| 353 | + local rechargeCfg = csvdb["shop_rechargeCsv"][config.packId] | |
| 345 | 354 | if rechargeCfg then |
| 346 | - limitPack[rechargeCfg.id] = timeNow + rechargeCfg.time | |
| 355 | + limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id} | |
| 347 | 356 | self:updateProperty({field = "limitTPack", value = limitPack}) |
| 348 | 357 | end |
| 349 | 358 | end |
| 350 | - if next(result) then | |
| 351 | - self:updateProperty({field = "packTrigger", value = triggerRecord}) | |
| 352 | - end | |
| 359 | + --if next(result) then | |
| 360 | + -- self:updateProperty({field = "packTrigger", value = triggerRecord}) | |
| 361 | + --end | |
| 353 | 362 | end |
| 354 | 363 | |
| 355 | 364 | function GetActGoodsIndex(goodsType) |
| ... | ... | @@ -419,7 +428,7 @@ function Store:data() |
| 419 | 428 | battleLR = self:getProperty("battleLR"), |
| 420 | 429 | limitTPack = self:getProperty("limitTPack"), |
| 421 | 430 | privCardEx = self:getProperty("privCardEx"), |
| 422 | - packTrigger = self:getProperty("packTrigger"), | |
| 431 | + --packTrigger = self:getProperty("packTrigger"), | |
| 423 | 432 | actGoodsFlag = self:getProperty("actGoodsFlag"), |
| 424 | 433 | bpInfo = self:getProperty("bpInfo"), |
| 425 | 434 | } | ... | ... |
-
mentioned in commit 46a0db220ccf4acdc740ada8ca8e36d26e838883
-
mentioned in commit 46a0db220ccf4acdc740ada8ca8e36d26e838883