优化一下性能

This commit is contained in:
xiekaidong 2023-07-18 15:35:49 +08:00
parent ed400f1b75
commit a2ca40f00c

View File

@ -445,28 +445,34 @@ function BIReport:postAdEvent()
end end
CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_AdRewardAD", json.encode({})) CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_AdRewardAD", json.encode({}))
CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_AdRewardAD", json.encode({})) CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_AdRewardAD", json.encode({}))
local afPostAdCount = { if not self.afPostAdCount then
[2] = true, self.afPostAdCount = {
[3] = true, [2] = true,
[5] = true, [3] = true,
[10] = true, [5] = true,
[20] = true, [10] = true,
[40] = true, [20] = true,
[80] = true, [40] = true,
} [80] = true,
if afPostAdCount[adCount] then }
end
if self.afPostAdCount[adCount] then
local args = {} local args = {}
CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_AdRewardAD_" .. adCount, json.encode(args)) CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_AdRewardAD_" .. adCount, json.encode(args))
end end
local fbPostAdCount = { if not self.fbPostAdCount then
[2] = true, self.fbPostAdCount = {
[3] = true, [2] = true,
[5] = true, [3] = true,
[10] = true, [5] = true,
[20] = true, [10] = true,
} [20] = true,
if fbPostAdCount[adCount] then }
end
if self.fbPostAdCount[adCount] then
local args = {} local args = {}
CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_AdRewardAD_" .. adCount, json.encode(args)) CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_AdRewardAD_" .. adCount, json.encode(args))
end end
@ -487,55 +493,59 @@ function BIReport:postChapterEvent(chapter)
end end
CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_Level", json.encode({})) CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_Level", json.encode({}))
CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_Level", json.encode({})) CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_Level", json.encode({}))
local postChapter = { if not self.afPostChapter then
[1] = true, self.afPostChapter = {
[2] = true, [1] = true,
[3] = true, [2] = true,
[4] = true, [3] = true,
[5] = true, [4] = true,
[6] = true, [5] = true,
[7] = true, [6] = true,
[8] = true, [7] = true,
[9] = true, [8] = true,
[10] = true, [9] = true,
[11] = true, [10] = true,
[12] = true, [11] = true,
[13] = true, [12] = true,
[14] = true, [13] = true,
[15] = true, [14] = true,
[16] = true, [15] = true,
[17] = true, [16] = true,
[18] = true, [17] = true,
[19] = true, [18] = true,
[20] = true, [19] = true,
[30] = true, [20] = true,
[40] = true, [30] = true,
[50] = true, [40] = true,
} [50] = true,
if postChapter[chapter] then }
end
if self.afPostChapter[chapter] then
local args = {} local args = {}
CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_Chapter_" .. chapter, json.encode(args)) CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_Chapter_" .. chapter, json.encode(args))
end end
local fbPostChapter = { if not self.fbPostChapter then
[1] = true, self.fbPostChapter = {
[2] = true, [1] = true,
[3] = true, [2] = true,
[4] = true, [3] = true,
[5] = true, [4] = true,
[6] = true, [5] = true,
[7] = true, [6] = true,
[8] = true, [7] = true,
[9] = true, [8] = true,
[10] = true, [9] = true,
[15] = true, [10] = true,
[20] = true, [15] = true,
[30] = true, [20] = true,
[40] = true, [30] = true,
[50] = true, [40] = true,
} [50] = true,
}
end
if fbPostChapter[chapter] then if self.fbPostChapter[chapter] then
local args = {} local args = {}
CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_Chapter_" .. chapter, json.encode(args)) CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_Chapter_" .. chapter, json.encode(args))
end end
@ -551,18 +561,21 @@ function BIReport:postFirstGetHero(num)
if CS.BF.BFMain.IsShenhe or CS.BF.BFMain.IsWhite then if CS.BF.BFMain.IsShenhe or CS.BF.BFMain.IsWhite then
return return
end end
local postHeroNum = { if not self.postHeroNum then
[4] = true, self.postHeroNum = {
[6] = true, [4] = true,
[8] = true, [6] = true,
[10] = true, [8] = true,
[12] = true, [10] = true,
[14] = true, [12] = true,
[16] = true, [14] = true,
[18] = true, [16] = true,
[20] = true, [18] = true,
} [20] = true,
if not postHeroNum[num] then }
end
if not self.postHeroNum[num] then
return return
end end
local args = {} local args = {}
@ -582,15 +595,18 @@ function BIReport:postHeroLev(beforeLv, lv)
end end
local allHeroes = DataManager.HeroData:getAllHeroes() local allHeroes = DataManager.HeroData:getAllHeroes()
local postHeroLevel = { if not self.postHeroLevel then
[3] = true, self.postHeroLevel = {
[5] = true, [3] = true,
[7] = true, [5] = true,
[9] = true [7] = true,
} [9] = true
}
end
local temp = {} local temp = {}
for heroid, heroEntity in pairs(allHeroes) do for heroid, heroEntity in pairs(allHeroes) do
for heroLv, _ in pairs(postHeroLevel) do for heroLv, _ in pairs(self.postHeroLevel) do
if heroEntity:getLv() >= heroLv then if heroEntity:getLv() >= heroLv then
temp[heroLv] = (temp[heroLv] or 0) + 1 temp[heroLv] = (temp[heroLv] or 0) + 1
end end
@ -618,25 +634,28 @@ function BIReport:postLvEvent(beforeLv, nowLv)
if not nowLv then if not nowLv then
return return
end end
local postLV = { if not self.postLV then
[1] = true, self.postLV = {
[2] = true, [1] = true,
[3] = true, [2] = true,
[5] = true, [3] = true,
[10] = true, [5] = true,
[15] = true, [10] = true,
[20] = true, [15] = true,
[30] = true, [20] = true,
[40] = true, [30] = true,
[50] = true, [40] = true,
[60] = true, [50] = true,
[70] = true, [60] = true,
[80] = true, [70] = true,
} [80] = true,
}
end
-- CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_grade", json.encode({})) -- CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_grade", json.encode({}))
-- CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_grade", json.encode({})) -- CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_grade", json.encode({}))
local reportLv local reportLv
for lv, _ in pairs(postLV) do for lv, _ in pairs(self.postLV) do
if beforeLv < lv and nowLv >= lv then if beforeLv < lv and nowLv >= lv then
reportLv = lv reportLv = lv
break break
@ -660,28 +679,31 @@ function BIReport:postFirstRechargeEvent(id)
if CS.BF.BFMain.IsShenhe or CS.BF.BFMain.IsWhite then if CS.BF.BFMain.IsShenhe or CS.BF.BFMain.IsWhite then
return return
end end
local postRechargeID = { if not self.postRechargeID then
[1] = false, -- 0.99 self.postRechargeID = {
[2] = false, -- 1.99 [1] = false, -- 0.99
[3] = true, -- 2.99 [2] = false, -- 1.99
[4] = false, -- 3.99 [3] = true, -- 2.99
[5] = true, -- 4.99 [4] = false, -- 3.99
[6] = false, -- 5.99 [5] = true, -- 4.99
[7] = false, -- 6.99 [6] = false, -- 5.99
[8] = false, -- 7.99 [7] = false, -- 6.99
[9] = false, -- 8.99 [8] = false, -- 7.99
[10] = true, -- 9.99 [9] = false, -- 8.99
[11] = false, -- 11.99 [10] = true, -- 9.99
[12] = false, -- 14.99 [11] = false, -- 11.99
[13] = true, -- 19.99 [12] = false, -- 14.99
[14] = false, -- 24.99 [13] = true, -- 19.99
[15] = true, -- 29.99 [14] = false, -- 24.99
[16] = true, -- 49.99 [15] = true, -- 29.99
[17] = false, -- 69.99 [16] = true, -- 49.99
[18] = false, -- 99.99 [17] = false, -- 69.99
[19] = false, -- 199.99 [18] = false, -- 99.99
} [19] = false, -- 199.99
if not postRechargeID[id] then }
end
if not self.postRechargeID[id] then
return return
end end
local cfg = ConfigManager:getConfig("recharge")[id] local cfg = ConfigManager:getConfig("recharge")[id]
@ -706,13 +728,16 @@ function BIReport:post24GradeFailEvent(chapterId)
if not DataManager:getIsInCreate24Hour() then if not DataManager:getIsInCreate24Hour() then
return return
end end
local postChapterId = { if not self.postChapterId then
[1] = true, self.postChapterId = {
[2] = true, [1] = true,
[3] = true, [2] = true,
[4] = true, [3] = true,
} [4] = true,
if not postChapterId[chapterId] then }
end
if not self.postChapterId[chapterId] then
return return
end end
local args = {} local args = {}
@ -737,17 +762,20 @@ function BIReport:post24HeroLevel(heroId)
if not heroEntity or heroEntity:getLv() > 2 then if not heroEntity or heroEntity:getLv() > 2 then
return return
end end
local postHeroId = { if not self.postHeroId then
[22001] = "24_blade_levelup", self.postHeroId = {
[32001] = "24_onion_levelup", [22001] = "24_blade_levelup",
[42001] = "24_iceheart_levelup", [32001] = "24_onion_levelup",
} [42001] = "24_iceheart_levelup",
if not postHeroId[heroId] then }
end
if not self.postHeroId[heroId] then
return return
end end
local args = {} local args = {}
CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_" .. postHeroId[heroId], json.encode(args)) CS.BF.BFMain.Instance.SDKMgr.BFThirdReportSDKMgr:PostAppsflyerEvent("af_" .. self.postHeroId[heroId], json.encode(args))
CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_" .. postHeroId[heroId], json.encode(args)) CS.BF.BFMain.Instance.SDKMgr.BFLoginSDKMgr.FBSdk:LogAppEvent("fb_" .. self.postHeroId[heroId], json.encode(args))
end end
-- 上报24小时内开宝箱 -- 上报24小时内开宝箱
@ -763,10 +791,13 @@ function BIReport:post24OpenBox(count)
if not DataManager:getIsInCreate24Hour() then if not DataManager:getIsInCreate24Hour() then
return return
end end
local postCount = { if not self.postBoxCount then
[3] = true self.postBoxCount = {
} [3] = true
if not postCount[count] then }
end
if not self.postBoxCount[count] then
return return
end end