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 8dfad0d..fd97aee 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -48,6 +48,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..31a76c9 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 @@ -162,16 +165,6 @@ function _M.startRpc( agent, data ) role:updateProperty({field = "hangInfo", value = hangInfo}) - -- 指定当前引导的步骤 - if carbonId == 10101 then - role:saveGuide(5,11) - elseif carbonId == 10102 then - role:saveGuide(8,2) - elseif carbonId == 10103 then - role:saveGuide(9,2) - elseif carbonId == 10220 then - role:saveGuide(22,1) - end role:mylog("hang_action", {desc = "startHang", int1 = carbonId}) SendPacket(actionCodes.Hang_startRpc, '') return true @@ -262,12 +255,7 @@ function _M.endBattleRpc(agent, data) -- 引导 if carbonId == 10101 then - role:finishGuide(5) - elseif carbonId == 10102 then - role:finishGuide(8) - role:saveGuide(9, 2) - elseif carbonId == 10103 then - role:finishGuide(9) + role:finishGuide(6) elseif carbonId == 20101 then role:finishGuide(22) end @@ -341,7 +329,7 @@ function _M.roleFormatRpc(agent , data) hangTeam.leader = msg.leader hangTeam.supports = supports role:saveHangTeam(hangTeam) - role:saveGuide(5,8) + role:finishGuide(5) SendPacket(actionCodes.Hang_roleFormatRpc, '') return true end @@ -500,8 +488,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 +530,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 +556,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 +574,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..6235b7c 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -54,9 +54,6 @@ function _M.levelUpRpc( agent, data ) hero_upgrade_scoreget = hero:getProperty("battleV") - oldBattleV, -- 通过英雄升级提升的评分 }) - if hero:getProperty("type") == 103 then - role:finishGuide(7) - end hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")}) role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) @@ -129,6 +126,10 @@ function _M.wakeRpc(agent, data) hero_rise_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} }) + if hero:getProperty("type") == 204 then + role:finishGuide(7) + end + SendPacket(actionCodes.Hero_wakeRpc, '') role:checkTaskEnter("HeroStarCollect", {}) @@ -846,9 +847,9 @@ function _M.drawHeroRpc(agent, data) role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) - local guideHero - if role:getProperty("newerGuide") == "11=1" then - guideHero = globalCsv.newdraw_hero_item_id or 613 + local guideHero = nil + if role:getProperty("newerGuide") == "8=1" then + guideHero = globalCsv.newdraw_hero_item_id or 503 end local ssrCount = 0 @@ -867,12 +868,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 @@ -903,7 +908,7 @@ function _M.drawHeroRpc(agent, data) if ssrCount > 0 then role:checkTaskEnter("DrawSSR", {count = ssrCount}) end - role:finishGuide(11) + role:finishGuide(8) role:log("gacha", { gacha_id = poolId, -- 卡池ID @@ -1023,4 +1028,4 @@ function _M.changeCrown(agent, data) return true end -return _M \ No newline at end of file +return _M diff --git a/src/agent.lua b/src/agent.lua index 2b37c5d..cf6e8ac 100644 --- a/src/agent.lua +++ b/src/agent.lua @@ -29,12 +29,6 @@ _codeSession = {} --- {{{ 定时器相关 local function handle_timeout() if not agentInfo.open_timer then return end - - if not agentInfo.role then - skynet.timeout(100, handle_timeout) - return - end - agent_util:update(agentInfo) skynet.timeout(100, handle_timeout) end @@ -274,6 +268,8 @@ function CMD.start(session, source, gate, fd, ip, hotfixs) end end + start_agent_timer() + -- 这里将消息伪装成 watchdog 发出,这样就由 A->B->C->B->A 变成 A->B->C->A skynet.redirect(gate, source, "lua", session, skynet.pack("forward", fd, 0, skynet.self())) end 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"), } diff --git a/src/services/agent_util.lua b/src/services/agent_util.lua index 933dd8a..6c05154 100644 --- a/src/services/agent_util.lua +++ b/src/services/agent_util.lua @@ -17,15 +17,32 @@ local HEART_TIMEOUT_COUNT_MAX = 20 local HEART_QUICK_COUNT_MAX = 5 -- 心跳定时间隔 local HEART_TIMER_INTERVAL = 5 +-- 忽略心跳的等待时间 +local WAIT_IGNORE_HEART = 300 + +--开始忽略心跳的时间 +local ignoreHeartTime = nil local function check_heart_beat(agent, now) -- 充值等操作不检查心跳 local role = agent.role - if role.ignoreHeartbeat then + if not role or role.ignoreHeartbeat then lastHeartCheckTime = now - HEART_TIMER_INTERVAL heartTimeoutCount = 0 + + if not ignoreHeartTime then + ignoreHeartTime = now + end + + if now - ignoreHeartTime >= WAIT_IGNORE_HEART then -- 等待太久了 踢掉 + skynet.error("timeout! then agent will shut down by self with ignoreHeartbeat or no login", agent.client_fd) + skynet.call(agent.gate_serv, "lua", "kick", agent.client_fd) + ignoreHeartTime = nil + end return end + ignoreHeartTime = nil + if lastHeartCheckTime - now > HEART_TIMER_INTERVAL or now - lastHeartCheckTime > HEART_TIMER_INTERVAL then heartTimeoutCount = heartTimeoutCount + 1 @@ -46,6 +63,7 @@ function _M:update(agent) pcall(check_heart_beat, agent, now) nextCheckTime = now + HEART_TIMER_INTERVAL end + if not role then return end pcall(role.onRecoverTimer, role, now) end @@ -73,6 +91,7 @@ end function _M:reset() heartTimeoutCount = 0 heartQuickCount = 0 + ignoreHeartTime = nil lastHeartCheckTime = skynet.timex() end -- libgit2 0.21.2