diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index b172f99..60a3166 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -178,7 +178,7 @@ end function Adv:clear() self.chapterId = nil self.level = nil - self.actid = 0 + self.actid = nil self.score = {} self.round = 0 self.lastEnemyId = 1 @@ -769,6 +769,10 @@ function Adv:isEndless() return AdvCommon.isEndless(self.chapterId) end +function Adv:isActivity() + return self.actid ~= nil +end + function Adv:getCurFloorData() local chapter = self.chapterId % 100 return (csvdb["adv_chapter_floorCsv"][self.chapterId] or {})[self.level] diff --git a/src/models/Activity.lua b/src/models/Activity.lua index c80e80a..5eae0bf 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -1030,6 +1030,55 @@ activityFunc[Activity.ActivityType.NewSign] = { end, } +local function closeActAdvHang(role, chapterId) + local advHang = role:getProperty("advHang") + local info = advHang[chapterId] + if not info then return end + + local index = info.index or 1 + local chapterData = csvdb["adv_chapter_campsiteCsv"][chapterId] + if not chapterData then return end + local campSiteData = chapterData[info.campId or 2] + if not campSiteData then return 1 end + if campSiteData.idleReward_1 == "" and campSiteData.idleReward_2 == "" then return 2 end --没有奖励 没有挂机 + + local adv_idle_time = globalCsv.adv_idle_time[index] + local adv_idle_energy = globalCsv.adv_idle_energy[index] + local adv_idle_reward_coef = globalCsv.adv_idle_reward[index] + if not adv_idle_time or not adv_idle_energy or not adv_idle_reward_coef then + return 2 + end + adv_idle_time = adv_idle_time * 60 + + local reward, isFull, change, heroFaithMap + local heroCnt = 0 + if skynet.timex() >= info.time then + -- 增加英雄信赖 + local exp = info.duration / 60 + heroFaithMap = {} + for _, heroId in pairs(info.format.heros) do + local curFaith = role:addHeroFaith(heroId, exp) + heroFaithMap[heroId] = curFaith + heroCnt = heroCnt + 1 + end + + local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2 + + local idleReward = totalReward:toNumMap() + for itemId, count in pairs(idleReward) do + idleReward[itemId] = count * adv_idle_reward_coef + end + reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) + end + + role:changeUpdates({{type = "advHang", field = chapterId, value = nil}}) + + role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = 2}) + + role:checkTaskEnter("AdvHang", {}) + role:checkTaskEnter("AdvHangHeroCnt", {count = heroCnt}) +end + activityFunc[Activity.ActivityType.AdvLevel] = { -- ["check"] = function(self, actType, notify) -- 检查 -- end, @@ -1042,7 +1091,16 @@ activityFunc[Activity.ActivityType.AdvLevel] = { local advPass = self.owner:getProperty("advPass") advPass[chapterId] = nil self.owner:updateProperty({field="advPass", value=advPass}) + + -- 关闭活动代理拾荒 + closeActAdvHang(chapterId) + end + -- 强制关闭活动拾荒关卡 + local adv = self:getAdvData() + if adv:isRunning() and adv:isActivity() then + adv:forceOver() end + end, } diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 863afe6..3bee256 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -2049,6 +2049,15 @@ function RolePlugin.bind(Role) return {list = list, rank = rank} end + function Role:addHeroFaith(heroId, exp) + local hero = self.heros[heroId] + if not hero then + return + end + + hero:addHeroFaith(exp) + return hero:getProperty("faith") + end end -- libgit2 0.21.2