Update - 1.13.0.124

EN: 1.13.0.124
CN: 1.13.0.124
JP: 1.13.0.128
KR: 1.13.0.130
This commit is contained in:
SL1900
2026-07-21 12:30:00 +09:00
parent a12087abad
commit 8c4bd41668
1334 changed files with 873026 additions and 95164 deletions
@@ -3,7 +3,6 @@ local BreakOutData = class("BreakOutData", ActivityDataBase)
local LocalData = require("GameCore.Data.LocalData")
local RapidJson = require("rapidjson")
local RedDotManager = require("GameCore.RedDot.RedDotManager")
local ClientManager = CS.ClientManager.Instance
local BreakOutLevelData = require("GameCore.Data.DataClass.Activity.BreakOutLevelData")
function BreakOutData:Init()
self.allLevelData = {}
@@ -391,7 +390,7 @@ function BreakOutData:ShowActivityClosedAlert()
EventManager.Hit(EventId.OpenMessageBox, msg)
end
function BreakOutData:ForceExitOnFinishFail()
EventManager.Hit(EventId.ClosePanel, PanelId.BreakOutPlayPanelS2)
EventManager.Hit(EventId.ClosePanel, PanelId.BreakOutLevelDetailPanelS2)
EventManager.Hit(EventId.ClosePanel, PanelId.BreakOutPlayPanelS3)
EventManager.Hit(EventId.ClosePanel, PanelId.BreakOutLevelDetailPanelS3)
end
return BreakOutData
@@ -0,0 +1,83 @@
local ActivityDataBase = require("GameCore.Data.DataClass.Activity.ActivityDataBase")
local FollowSocialMediaData = class("FollowSocialMediaData", ActivityDataBase)
function FollowSocialMediaData:Init()
self.tbRewardData = {}
end
function FollowSocialMediaData:RefreshFollowSocialMediaActData(actId, msgData)
self:Init()
local tbData = UTILS.ParseByteString(msgData.State)
local tbActive = self:GetBitsAsBooleanArray(tbData)
for i, v in ipairs(tbActive) do
if v then
self.tbRewardData[i] = true
end
end
end
function FollowSocialMediaData:GetAllRewardData()
return self.tbRewardData
end
function FollowSocialMediaData:GetRewardData(nConfigId)
return self.tbRewardData[nConfigId] or false
end
function FollowSocialMediaData:SetRewardData(nConfigId, bGet)
self.tbRewardData[nConfigId] = bGet
end
function FollowSocialMediaData:SendRewardReceive(nConfigId, callback)
local backCallback = function(_, msgData)
self:SetRewardData(nConfigId, true)
if callback ~= nil then
callback()
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.activity_share_reward_receive_req, {
ActivityId = self.nActId,
ChannelId = nConfigId
}, nil, backCallback)
end
function FollowSocialMediaData:GetBitsAsBooleanArray(byteArray)
local bits = {}
local totalBits = #byteArray * 8
for i = 1, totalBits do
bits[i] = false
end
for i = #byteArray, 1, -1 do
local value = byteArray[i]
local byteOffset = #byteArray - i
local baseBitIndex = byteOffset * 8
for bitPos = 0, 7 do
local mask = 2 ^ bitPos
bits[baseBitIndex + bitPos + 1] = value & mask ~= 0
end
end
return bits
end
function FollowSocialMediaData:CheckActShow()
if NovaAPI.IsReviewServerEnv() then
return false
end
if self.actCfg.PreLimit == GameEnum.activityPreLimit.WorldClass then
local nCurWorldClass = PlayerData.Base:GetWorldClass()
local nNeedWorldClass = tonumber(self.actCfg.LimitParam)
if nCurWorldClass < nNeedWorldClass then
return false
end
elseif self.actCfg.PreLimit == GameEnum.activityPreLimit.questLimit then
local nStoryId = tonumber(self.actCfg.LimitParam)
local bReaded = PlayerData.Avg:IsStoryReaded(nStoryId)
if not bReaded then
return false
end
end
if self.actCfg.EndType == GameEnum.activityEndType.NoLimit then
return not self.bBanner and self:CheckActivityOpen()
else
return self:CheckActivityOpen()
end
end
function FollowSocialMediaData:CheckShowBanner()
if NovaAPI.IsReviewServerEnv() then
return false
end
return self:CheckActPlay() and self.actCfg.BannerRes ~= "" and self.bBanner == false
end
return FollowSocialMediaData
@@ -0,0 +1,271 @@
local ActivityDataBase = require("GameCore.Data.DataClass.Activity.ActivityDataBase")
local IceCreamActData = class("IceCreamActData", ActivityDataBase)
local LocalData = require("GameCore.Data.LocalData")
local IceCreamLevelData = require("Game.UI.Play_IceCreamTruck.Play.IceCreamLevelData")
local ClientManager = CS.ClientManager.Instance
local RapidJson = require("rapidjson")
function IceCreamActData:Init()
self.mapLevelData = {}
self.tbLevelList = {}
self.tbLevelByType = {}
self.tbSkipNewLevel = {}
self.tbNewLevel = {}
self:ParseConfig()
self:AddListeners()
end
function IceCreamActData:AddListeners()
EventManager.Add("ClearAllIceLevels", self, self.OnEvent_GMClearAllIceLevels)
end
function IceCreamActData:ParseConfig()
local foreach_level = function(data)
if data.ActivityId ~= self.nActId then
return
end
table.insert(self.tbLevelList, {
nId = data.Id,
nLevelType = data.LevelType
})
local bucket = self.tbLevelByType[data.LevelType]
if bucket == nil then
bucket = {}
self.tbLevelByType[data.LevelType] = bucket
end
table.insert(bucket, data.Id)
end
ForEachTableLine(DataTable.ActivityIceCreamLevel, foreach_level)
table.sort(self.tbLevelList, function(a, b)
if a.nLevelType ~= b.nLevelType then
return a.nLevelType < b.nLevelType
end
return a.nId < b.nId
end)
for _, bucket in pairs(self.tbLevelByType) do
table.sort(bucket, function(a, b)
return a < b
end)
end
local sJson = LocalData.GetPlayerLocalData("IceCreamLevel")
local tb = decodeJson(sJson)
if type(tb) == "table" then
self.tbSkipNewLevel = tb
end
end
function IceCreamActData:RefreshIceCreamActData(nActId, msgData)
self.nActId = nActId
self:CacheLevelData(msgData)
end
function IceCreamActData:CacheLevelData(msgData)
local LeveList = self:GetLevelList()
for _, v in ipairs(LeveList) do
self.mapLevelData[v.nId] = {nScore = 0, bFirstComplete = false}
end
if msgData ~= nil then
tbLevel = msgData.Levels
for _, v in ipairs(tbLevel) do
self.mapLevelData[v.LevelId] = {
nScore = v.Score,
bFirstComplete = v.FirstComplete
}
end
end
self:RefreshLevelRedDot()
end
function IceCreamActData:CacheLevelData_GM(msgData)
local LeveList = self:GetLevelList()
for _, v in ipairs(LeveList) do
self.mapLevelData[v.nId] = {nScore = 0, bFirstComplete = false}
end
if msgData ~= nil then
tbLevel = msgData.levels
for _, v in ipairs(tbLevel) do
self.mapLevelData[v.LevelId] = {
nScore = v.Score,
bFirstComplete = v.FirstComplete
}
end
end
self:RefreshLevelRedDot()
end
function IceCreamActData:GetLevelList()
return self.tbLevelList
end
function IceCreamActData:GetLevelTypeTable()
return self.tbLevelByType
end
function IceCreamActData:GetLevelsByType(index)
if self.tbLevelByType then
return self.tbLevelByType[index]
end
return nil
end
function IceCreamActData:GetNextIslandIsLock(index)
if self.tbLevelByType then
local nLevelIds = self.tbLevelByType[index + 1]
if nLevelIds and nLevelIds[1] then
return self:CheckLevelIsLockByTime(nLevelIds[1])
end
end
return true
end
function IceCreamActData:CheckLevelLock(nLevelId)
local bLock = self:CheckLevelIsLockByTime(nLevelId)
if bLock then
return bLock
end
bLock = self:CheckLevelLockByPrev(nLevelId)
return bLock
end
function IceCreamActData:CheckLevelIsLockByTime(nLevelId)
local nRemain = self:GetLevelStartTime(nLevelId) - ClientManager.serverTimeStamp
local bLock = 0 < nRemain
return bLock, nRemain
end
function IceCreamActData:CheckLevelLockByPrev(nLevelId)
local mapCfg = ConfigTable.GetData("ActivityIceCreamLevel", nLevelId)
if not mapCfg then
return true
end
local nPrev = mapCfg.PreLevelId
if nPrev == 0 then
return false
end
return not self.mapLevelData[nPrev].bFirstComplete
end
function IceCreamActData:GetLevelData(nId)
return self.mapLevelData[nId] or {nScore = 0, bFirstComplete = false}
end
function IceCreamActData:GetLevelMapData(nLevelId)
local mapCfg = ConfigTable.GetData("ActivityIceCreamLevel", nLevelId)
if not mapCfg then
return nil
end
return mapCfg
end
function IceCreamActData:GetLevelStartTime(nLevelId)
local mapCfg = ConfigTable.GetData("ActivityIceCreamLevel", nLevelId)
if not mapCfg then
return 0
end
local openActDayNextTime = ClientManager:GetNextRefreshTime(self.nOpenTime)
local openTime = openActDayNextTime - 86400
return openTime + mapCfg.Duration * 86400
end
function IceCreamActData:EnterLevel(nLevelId)
self.IceCreamLevelData = IceCreamLevelData.new()
self.IceCreamLevelData:InitData(nLevelId, self.nActId)
end
function IceCreamActData:SetLevelMaxScore(nLevelId, nScore)
if self.mapLevelData[nLevelId] then
local nCurrentScore = self.mapLevelData[nLevelId].nScore
if nScore > nCurrentScore then
self.mapLevelData[nLevelId].nScore = nScore
end
end
end
function IceCreamActData:GetLevelMaxScore(nLevelId)
if self.mapLevelData[nLevelId].nScore then
return self.mapLevelData[nLevelId].nScore
end
return 0
end
function IceCreamActData:RefreshLevelRedDot()
self.tbNewLevel = {}
local foreachLevel = function(mapData)
if mapData.ActivityId == self.nActId then
local bNewState = self:GetLevelNewStateInternal(mapData.Id)
if bNewState then
table.insert(self.tbNewLevel, mapData.Id)
end
RedDotManager.SetValid(RedDotDefine.Activity_IceCreamTruck_NewLevel, {
self.nActId,
mapData.LevelType,
mapData.Id
}, bNewState)
end
end
ForEachTableLine(DataTable.ActivityIceCreamLevel, foreachLevel)
end
function IceCreamActData:GetLevelNewStateInternal(nLevelId)
local mapLevelCfgData = ConfigTable.GetData("ActivityIceCreamLevel", nLevelId)
if mapLevelCfgData == nil then
return false
end
if not self:CheckLevelLock(nLevelId) then
local sKey = tostring(self.nActId) .. tostring(nLevelId) .. "LevelNew"
local bIsFirst = LocalData.GetPlayerLocalData(sKey)
if bIsFirst == nil then
bIsFirst = true
else
bIsFirst = false
end
return bIsFirst
end
return false
end
function IceCreamActData:SetLevelNew(nLevelType, nLevelId)
local idx = table.indexof(self.tbNewLevel, nLevelId)
if 0 < idx then
table.remove(self.tbNewLevel, idx)
else
return
end
local sKey = tostring(self.nActId) .. tostring(nLevelId) .. "LevelNew"
LocalData.SetPlayerLocalData(sKey, false)
RedDotManager.SetValid(RedDotDefine.Activity_IceCreamTruck_NewLevel, {
self.nActId,
nLevelType,
nLevelId
}, false)
end
function IceCreamActData:SendActivityIceCreamLevelSettleReq(msgData, bResult, callback)
if self:IsActivityClosed() then
self:ShowActivityClosedAlert()
return
end
local ResultCallback = function(_, mapMainData)
if callback ~= nil then
callback(mapMainData)
if bResult then
self:UpdateLevelData({
Id = msgData.LevelId,
FirstComplete = mapMainData.Passed
})
end
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.activity_ice_cream_level_settle_req, msgData, nil, ResultCallback)
end
function IceCreamActData:UpdateLevelData(levelData)
if self.mapLevelData[levelData.Id] and not self.mapLevelData[levelData.Id].bFirstComplete then
self.mapLevelData[levelData.Id].bFirstComplete = levelData.FirstComplete
end
local nLevelType = self:GetLevelMapData(levelData.Id).LevelType
self:SetLevelNew(nLevelType, levelData.Id)
self:RefreshLevelRedDot()
end
function IceCreamActData:IsActivityClosed()
if self == nil or self.CheckActivityOpen == nil then
return false
end
return not self:CheckActivityOpen()
end
function IceCreamActData:ShowActivityClosedAlert()
local msg = {
nType = AllEnum.MessageBox.Alert,
sContent = ConfigTable.GetUIText("Activity_End_Notice"),
callbackConfirm = function()
self:ForceExitOnFinishFail()
end
}
EventManager.Hit(EventId.OpenMessageBox, msg)
end
function IceCreamActData:ForceExitOnFinishFail()
EventManager.Hit(EventId.ClosePanel, PanelId.IceCreamTruckGamePanel)
EventManager.Hit(EventId.ClosePanel, PanelId.IceCreamLevelsSelectPanel)
end
function IceCreamActData:OnEvent_GMClearAllIceLevels(mapMsgData)
if mapMsgData ~= nil then
self:CacheLevelData_GM(mapMsgData)
end
end
return IceCreamActData
@@ -2,11 +2,19 @@ local ActivityDataBase = require("GameCore.Data.DataClass.Activity.ActivityDataB
local JointDrillActData = class("JointDrillActData", ActivityDataBase)
local ClientManager = CS.ClientManager.Instance
local TimerManager = require("GameCore.Timer.TimerManager")
local LocalData = require("GameCore.Data.LocalData")
local sJointDrillDailyEnterKeyPrefix = "JointDrillDailyEnter_"
local GetDailyEnterLocalKey = function(nActId)
return sJointDrillDailyEnterKeyPrefix .. tostring(nActId)
end
function JointDrillActData:Init()
self.jointDrillActCfg = nil
self.nJointDrillType = 0
self.nActStatus = 0
self.actTimer = nil
self.bDailyEnterLoaded = false
self.nDailyEnterNextRefreshTime = nil
self.bDailyEnterRedDotValid = false
self.tbPassedLevels = {}
self.tbQuests = {}
self.nTotalScore = 0
@@ -54,6 +62,7 @@ function JointDrillActData:RefreshJointDrillActData(msgData)
self.tbQuests = msgData.Quests
end
self:RefreshJointDrillQuestRedDot()
self:RefreshDailyEnterRedDot()
self:StartActTimer()
end
function JointDrillActData:GetChallengeStartTime()
@@ -76,6 +85,44 @@ function JointDrillActData:RefreshJointDrillQuestRedDot()
end
RedDotManager.SetValid(RedDotDefine.JointDrillQuest, nil, bHasReward)
end
function JointDrillActData:CheckInChallengeTime()
local nChallengeStartTime = self:GetChallengeStartTime()
local nChallengeEndTime = self:GetChallengeEndTime()
if nChallengeStartTime == nil or nChallengeEndTime == nil then
return false
end
local nCurTime = ClientManager.serverTimeStamp
return nChallengeStartTime <= nCurTime and nChallengeEndTime > nCurTime
end
function JointDrillActData:CheckEnteredToday()
if not self.bDailyEnterLoaded then
local sData = LocalData.GetPlayerLocalData(GetDailyEnterLocalKey(self.nActId))
self.nDailyEnterNextRefreshTime = tonumber(sData)
self.bDailyEnterLoaded = true
end
local nCurTime = ClientManager.serverTimeStamp
return self.nDailyEnterNextRefreshTime ~= nil and nCurTime < self.nDailyEnterNextRefreshTime
end
function JointDrillActData:RefreshDailyEnterRedDot()
local bShowRedDot = self:CheckInChallengeTime() and not self:CheckEnteredToday()
if self.bDailyEnterRedDotValid == bShowRedDot then
return
end
self.bDailyEnterRedDotValid = bShowRedDot
RedDotManager.SetValid(RedDotDefine.JointDrillDailyEnter, self.nActId, bShowRedDot)
end
function JointDrillActData:MarkEnteredToday()
if not self:CheckInChallengeTime() then
self:RefreshDailyEnterRedDot()
return
end
local nNowTime = ClientManager.serverTimeStamp
local nNextRefreshTime = ClientManager:GetNextRefreshTime(nNowTime)
self.nDailyEnterNextRefreshTime = nNextRefreshTime
self.bDailyEnterLoaded = true
LocalData.SetPlayerLocalData(GetDailyEnterLocalKey(self.nActId), tostring(nNextRefreshTime))
self:RefreshDailyEnterRedDot()
end
function JointDrillActData:RefreshQuestData(questData)
local bHasData = false
for k, v in ipairs(self.tbQuests) do
@@ -141,6 +188,7 @@ function JointDrillActData:StartActTimer()
self.nActStatus = AllEnum.JointDrillActStatus.Closed
nRemainTime = 0
end
self:RefreshDailyEnterRedDot()
EventManager.Hit("RefreshJointDrillActTime", self.nActStatus, nRemainTime)
if nRemainTime <= 0 and self.actTimer ~= nil and self.nActStatus == AllEnum.JointDrillActStatus.Closed then
self.actTimer:Cancel()
@@ -33,12 +33,19 @@ end
function MiningGameData:CacheAllQuestData(questListData)
self.tbQuestDataList = {}
for _, v in pairs(questListData) do
local questData = {
nId = v.Id,
nStatus = self:QuestServer2Client(v.Status),
progress = v.Progress
}
table.insert(self.tbQuestDataList, questData)
local config = ConfigTable.GetData("MiningQuest", v.Id)
if config ~= nil then
local nGroupId = config.GroupId
local questData = {
nId = v.Id,
nStatus = self:QuestServer2Client(v.Status),
progress = v.Progress
}
if self.tbQuestDataList[nGroupId] == nil then
self.tbQuestDataList[nGroupId] = {}
end
table.insert(self.tbQuestDataList[nGroupId], questData)
end
end
self:RefreshQuestReddot()
end
@@ -48,43 +55,79 @@ end
function MiningGameData:GetQuestData(nQuestId)
local questData
for _, v in pairs(self.tbQuestDataList) do
if v.nId == nQuestId then
questData = v
for _, v2 in ipairs(v) do
if v2.nId == nQuestId then
questData = v2
break
end
end
end
return questData
end
function MiningGameData:GetCompleteCount()
function MiningGameData:GetAllReceivedCount()
local nCount = 0
for _, v in pairs(self.tbQuestDataList) do
if v.nStatus == AllEnum.ActQuestStatus.Complete or v.nStatus == AllEnum.ActQuestStatus.Received then
for _, v2 in ipairs(v) do
if v2.nStatus == AllEnum.ActQuestStatus.Received then
nCount = nCount + 1
end
end
end
return nCount
end
function MiningGameData:GetAllQuestCount()
local nCount = 0
for _, v in pairs(self.tbQuestDataList) do
nCount = nCount + #v
end
return nCount
end
function MiningGameData:GetAllGroupId()
local tbGroupId = {}
for k, _ in pairs(self.tbQuestDataList) do
table.insert(tbGroupId, k)
end
return tbGroupId
end
function MiningGameData:GetQuestbyGroupId(nGroupId)
return self.tbQuestDataList[nGroupId]
end
function MiningGameData:GetGroupQuestReceiveCount(nGroupId)
local nCount = 0
for _, v in pairs(self.tbQuestDataList[nGroupId]) do
if v.nStatus == AllEnum.ActQuestStatus.Received then
nCount = nCount + 1
end
end
return nCount
end
function MiningGameData:RefreshQuestData(questData)
for _, v in pairs(self.tbQuestDataList) do
for _, v2 in ipairs(v) do
if v2.nId == questData.Id then
v2.nStatus = self:QuestServer2Client(questData.Status)
v2.progress = questData.Progress
break
end
end
end
self:RefreshQuestReddot()
EventManager.Hit("MiningQuestUpdate")
end
function MiningGameData:RefreshQuestReddot()
local bTabReddot = false
if next(self.tbQuestDataList) ~= nil then
for _, v in pairs(self.tbQuestDataList) do
local bReddot = v.nStatus == AllEnum.ActQuestStatus.Complete
RedDotManager.SetValid(RedDotDefine.Activity_Mining_Quest, v.nId, bReddot)
for _, v in pairs(self.tbQuestDataList) do
for _, v2 in ipairs(v) do
local bReddot = v2.nStatus == AllEnum.ActQuestStatus.Complete
local nGroupId = ConfigTable.GetData("MiningQuest", v2.nId).GroupId
RedDotManager.SetValid(RedDotDefine.Activity_Mining_Quest, {
nGroupId,
v2.nId
}, bReddot)
bTabReddot = bTabReddot or bReddot
end
end
RedDotManager.SetValid(RedDotDefine.Activity_Tab, self.nActId, bTabReddot or self.bIsFirst)
end
function MiningGameData:HasFinishQuest(...)
local bHasFinish = false
for _, v in pairs(self.tbQuestDataList) do
if v.nStatus == AllEnum.ActQuestStatus.Complete then
bHasFinish = true
break
end
end
return bHasFinish
RedDotManager.SetValid(RedDotDefine.Activity_Mining_AllQuest, self.nActId, bTabReddot)
end
function MiningGameData:QuestServer2Client(nStatus)
if nStatus == 0 then
@@ -173,6 +216,7 @@ function MiningGameData:RefreshMiningGameActData(actId, msgData)
end
self:InitCurDicData()
self.nScore = msgData.Score
self:CacheAllQuestData(msgData.Quests)
end
function MiningGameData:GetIsFirstIn()
return self.bIsFirst
@@ -377,13 +421,15 @@ function MiningGameData:RequestFinishAvg(storyId, callback)
StoryId = storyId
}, nil, msgCallback)
end
function MiningGameData:SendQuestReceive(nQuestId)
function MiningGameData:SendQuestReceive(nQuestId, nGroupId)
local callback = function(_, msgData)
UTILS.OpenReceiveByChangeInfo(msgData.ChangeInfo, nil)
UTILS.OpenReceiveByChangeInfo(msgData, nil)
if nQuestId == 0 then
for _, v in pairs(self.tbQuestDataList) do
if v.nStatus == AllEnum.ActQuestStatus.Complete then
v.nStatus = AllEnum.ActQuestStatus.Received
if nGroupId ~= 0 then
for _, v in pairs(self.tbQuestDataList[nGroupId]) do
if v.nStatus == AllEnum.ActQuestStatus.Complete then
v.nStatus = AllEnum.ActQuestStatus.Received
end
end
end
else
@@ -393,11 +439,13 @@ function MiningGameData:SendQuestReceive(nQuestId)
end
end
EventManager.Hit("MiningQuestUpdate")
self:UpdateAxe()
self:RefreshQuestReddot()
end
HttpNetHandler.SendMsg(NetMsgId.Id.activity_mining_quest_reward_receive_req, {
ActivityId = self.nActId,
QuestId = nQuestId
QuestId = nQuestId,
GroupId = nGroupId
}, nil, callback)
end
return MiningGameData
@@ -1,7 +1,7 @@
local ActivityDataBase = require("GameCore.Data.DataClass.Activity.ActivityDataBase")
local PenguinCardActData = class("PenguinCardActData", ActivityDataBase)
local LocalData = require("GameCore.Data.LocalData")
local PenguinLevel = require("Game.UI.Play_PenguinCard.PenguinLevel")
local PenguinLevel = require("Game.UI.Play_PenguinCard.NormalMode.PenguinLevel_Normal")
local ClientManager = CS.ClientManager.Instance
local RapidJson = require("rapidjson")
function PenguinCardActData:Init()
@@ -28,11 +28,16 @@ local Postal_10106Data = require("GameCore.Data.DataClass.Activity.Postal_10106D
local Viewfinder_10107Data = require("GameCore.Data.DataClass.Activity.Viewfinder_10107Data")
local Tech_10108Data = require("GameCore.Data.DataClass.Activity.Tech_10108Data")
local GunStorm_10109Data = require("GameCore.Data.DataClass.Activity.GunStorm_10109Data")
local Summer_10110Data = require("GameCore.Data.DataClass.Activity.Summer_10110Data")
local PenguinCardActData = require("GameCore.Data.DataClass.Activity.PenguinCardActData")
local GoldenSpyData = require("GameCore.Data.DataClass.Activity.GoldenSpyData")
local Solodance_20102Data = require("GameCore.Data.DataClass.Activity.Solodance_20102Data")
local SwimTheme_11100Data = require("GameCore.Data.DataClass.Activity.SwimTheme_11100Data")
local DoubleDropsActData = require("GameCore.Data.DataClass.Activity.DoubleDropsActData")
local FollowSocialMediaData = require("GameCore.Data.DataClass.Activity.FollowSocialMediaData")
local Summer_20103Data = require("GameCore.Data.DataClass.Activity.Summer_20103Data")
local IceCreamActData = require("GameCore.Data.DataClass.Activity.IceCreamActData")
local SoldierActData = require("GameCore.Data.DataClass.Activity.SoldierActData")
function PlayerActivityData:Init()
self.bCacheActData = false
self.tbAllActivity = {}
@@ -146,6 +151,12 @@ function PlayerActivityData:CacheAllActivityData(mapNetMsg)
self:RefreshGoldenSpyActData(nActId, v.GDS)
elseif actCfg.ActivityType == GameEnum.activityType.Double then
self:RefreshDoubleDropsActData(nActId, v.Double)
elseif actCfg.ActivityType == GameEnum.activityType.FollowSocialMedia then
self:RefreshFollowSocialMediaActData(nActId, v.Share)
elseif actCfg.ActivityType == GameEnum.activityType.IceCream then
self:RefreshIceCreamActData(nActId, v.IceCream)
elseif actCfg.ActivityType == GameEnum.activityType.Soldier then
self:RefreshSoldierActData(nActId, v.Soldier)
end
end
end
@@ -245,6 +256,12 @@ function PlayerActivityData:CreateActivityIns(actData)
actIns = GoldenSpyData.new(actData)
elseif actCfg.ActivityType == GameEnum.activityType.Double then
actIns = DoubleDropsActData.new(actData)
elseif actCfg.ActivityType == GameEnum.activityType.FollowSocialMedia then
actIns = FollowSocialMediaData.new(actData)
elseif actCfg.ActivityType == GameEnum.activityType.IceCream then
actIns = IceCreamActData.new(actData)
elseif actCfg.ActivityType == GameEnum.activityType.Soldier then
actIns = SoldierActData.new(actData)
end
if actIns ~= nil then
self.tbAllActivity[actData.Id] = actIns
@@ -361,6 +378,10 @@ function PlayerActivityData:CreateActivityGroupIns(actData)
actIns = Tech_10108Data.new(actData)
elseif actCfg.ActivityThemeType == GameEnum.activityThemeType.GunStorm_10109 then
actIns = GunStorm_10109Data.new(actData)
elseif actCfg.ActivityThemeType == GameEnum.activityThemeType.Summer_10110 then
actIns = Summer_10110Data.new(actData)
elseif actCfg.ActivityThemeType == GameEnum.activityThemeType.Summer_20103 then
actIns = Summer_20103Data.new(actData)
end
self.tbAllActivityGroup[actData.Id] = actIns
PlayerData.ActivityAvg:RefreshAvgRedDot()
@@ -493,7 +514,11 @@ function PlayerActivityData:RefreshSingleQuest(questData)
if nil ~= self.tbAllActivity[questData.ActivityId] then
self.tbAllActivity[questData.ActivityId]:RefreshQuestData(questData)
end
elseif actCfg.ActivityType == GameEnum.activityType.Double and nil ~= self.tbAllActivity[questData.ActivityId] then
elseif actCfg.ActivityType == GameEnum.activityType.Double then
if nil ~= self.tbAllActivity[questData.ActivityId] then
self.tbAllActivity[questData.ActivityId]:RefreshQuestData(questData)
end
elseif actCfg.ActivityType == GameEnum.activityType.Soldier and nil ~= self.tbAllActivity[questData.ActivityId] then
self.tbAllActivity[questData.ActivityId]:RefreshQuestData(questData)
end
end
@@ -603,6 +628,21 @@ function PlayerActivityData:RefreshGoldenSpyActData(nActId, msgData)
self.tbAllActivity[nActId]:RefreshGoldenSpyActData(nActId, msgData)
end
end
function PlayerActivityData:RefreshFollowSocialMediaActData(nActId, msgData)
if nil ~= self.tbAllActivity[nActId] then
self.tbAllActivity[nActId]:RefreshFollowSocialMediaActData(nActId, msgData)
end
end
function PlayerActivityData:RefreshIceCreamActData(nActId, msgData)
if nil ~= self.tbAllActivity[nActId] then
self.tbAllActivity[nActId]:RefreshIceCreamActData(nActId, msgData)
end
end
function PlayerActivityData:RefreshSoldierActData(nActId, msgData)
if nil ~= self.tbAllActivity[nActId] then
self.tbAllActivity[nActId]:RefreshSoldierActData(nActId, msgData)
end
end
function PlayerActivityData:RefreshActivityLevelGameActData(nActId, msgData)
if nil ~= self.tbAllActivity[nActId] then
self.tbAllActivity[nActId]:RefreshActivityLevelGameActData(nActId, msgData)
@@ -0,0 +1,38 @@
local ActivityDataBase = require("GameCore.Data.DataClass.Activity.ActivityDataBase")
local SoldierActData = class("SoldierActData", ActivityDataBase)
local LocalData = require("GameCore.Data.LocalData")
local RedDotManager = require("GameCore.RedDot.RedDotManager")
function SoldierActData:Init()
self:InitData()
end
function SoldierActData:InitData()
self.bLevelNewKey = LocalData.GetPlayerLocalData("SoliderLevel_New")
if self.bLevelNewKey == nil then
self.bLevelNewKey = true
end
RedDotManager.SetValid(RedDotDefine.Solider_Level_New, nil, self.bLevelNewKey)
end
function SoldierActData:RefreshSoldierActData(nActId, msgData)
self:InitData()
self.nActId = nActId
PlayerData.SoldierData:SetCurGradeChallengeData(msgData.CurGradeChallengeId, msgData.Stage, msgData.NodeIndex)
PlayerData.SoldierData:SetHighestChallengeId(msgData.GradeChallengeId)
PlayerData.SoldierData:SetQuestDataList(msgData.Quests)
end
function SoldierActData:RefreshQuestData(questData)
PlayerData.SoldierData:SetQuestData(questData)
end
function SoldierActData:RefreshLevelNew()
self.bLevelNewKey = false
LocalData.SetPlayerLocalData("SoliderLevel_New", self.bLevelNewKey)
RedDotManager.SetValid(RedDotDefine.Solider_Level_New, nil, self.bLevelNewKey)
end
function SoldierActData:RefreshAllQuestData(callback)
local callFunc = function()
if callback ~= nil then
callback()
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.activity_detail_req, {}, nil, callFunc)
end
return SoldierActData
@@ -0,0 +1,70 @@
local ActivityGroupDataBase = require("GameCore.Data.DataClass.Activity.ActivityGroupDataBase")
local Summer_10110Data = class("Summer_10110Data", ActivityGroupDataBase)
function Summer_10110Data:Init()
self.tbAllActivity = {}
self.nCGActivityId = 0
self.sCGPath = ""
self.bPlayedCG = false
self:ParseActivity()
end
function Summer_10110Data:ParseActivity()
if self.actGroupConfig == nil then
self.actGroupConfig = ConfigTable.GetData("ActivityGroup", self.nActGroupId)
end
if self.actGroupConfig == nil then
printError("ActivityGroup config not found for id: " .. tostring(self.nActGroupId))
return
end
local sJson = self.actGroupConfig.Enter
local tbJson = decodeJson(sJson)
if tbJson == nil then
printError("ActivityGroup Enter json is nil for id: " .. tostring(self.nActGroupId))
end
for _, activity in pairs(tbJson) do
local data = {
ActivityId = activity[1],
Index = activity[2],
PanelId = activity[3]
}
table.insert(self.tbAllActivity, data)
end
local sCgJson = self.actGroupConfig.CG
if sCgJson ~= nil then
local tbCGJson = decodeJson(sCgJson)
if tbCGJson and 2 <= #tbCGJson then
self.nCGActivityId = tonumber(tbCGJson[1])
self.sCGPath = tbCGJson[2]
end
end
end
function Summer_10110Data:GetActivityDataByIndex(nIndex)
for _, activity in pairs(self.tbAllActivity) do
if activity.Index == nIndex then
return activity
end
end
end
function Summer_10110Data:PlayCG()
self:SendMsg_CG_READ(self.nCGActivityId)
end
function Summer_10110Data:GetActivityGroupCGPlayed()
if self.bPlayedCG then
return true
end
return PlayerData.Activity:IsCGPlayed(self.nCGActivityId)
end
function Summer_10110Data:IsActivityInActivityGroup(nActivityId)
for _, activity in pairs(self.tbAllActivity) do
if activity.ActivityId == nActivityId then
return true, self.nActGroupId
end
end
return false
end
function Summer_10110Data:SendMsg_CG_READ(nActivityId)
local Callback = function()
self.bPlayedCG = true
end
HttpNetHandler.SendMsg(NetMsgId.Id.activity_cg_read_req, {nActivityId}, nil, Callback)
end
return Summer_10110Data
@@ -0,0 +1,61 @@
local ActivityGroupDataBase = require("GameCore.Data.DataClass.Activity.ActivityGroupDataBase")
local Summer_20103Data = class("Summer_20103Data", ActivityGroupDataBase)
function Summer_20103Data:Init()
self.tbAllActivity = {}
self.nCGActivityId = 0
self.sCGPath = ""
self.bPlayedCG = false
self:ParseActivity()
end
function Summer_20103Data:ParseActivity()
if self.actGroupConfig == nil then
self.actGroupConfig = ConfigTable.GetData("ActivityGroup", self.nActGroupId)
end
local sJson = self.actGroupConfig.Enter
local tbJson = decodeJson(sJson)
for _, activity in pairs(tbJson) do
local data = {
ActivityId = activity[1],
Index = activity[2],
PanelId = activity[3]
}
table.insert(self.tbAllActivity, data)
end
local sCgJson = self.actGroupConfig.CG
if sCgJson ~= nil then
local tbCGJson = decodeJson(sCgJson)
self.nCGActivityId = tonumber(tbCGJson[1])
self.sCGPath = tbCGJson[2]
end
end
function Summer_20103Data:GetActivityDataByIndex(nIndex)
for _, activity in pairs(self.tbAllActivity) do
if activity.Index == nIndex then
return activity
end
end
end
function Summer_20103Data:PlayCG()
self:SendMsg_CG_READ(self.nCGActivityId)
end
function Summer_20103Data:GetActivityGroupCGPlayed()
if self.bPlayedCG then
return true
end
return PlayerData.Activity:IsCGPlayed(self.nCGActivityId)
end
function Summer_20103Data:IsActivityInActivityGroup(nActivityId)
for _, activity in pairs(self.tbAllActivity) do
if activity.ActivityId == nActivityId then
return true, self.nActGroupId
end
end
return false
end
function Summer_20103Data:SendMsg_CG_READ(nActivityId)
local Callback = function()
self.bPlayedCG = true
end
HttpNetHandler.SendMsg(NetMsgId.Id.activity_cg_read_req, {nActivityId}, nil, Callback)
end
return Summer_20103Data
@@ -165,7 +165,7 @@ function TrekkerVersusData:GetCurFanData()
end
function TrekkerVersusData:GetDuelHistory()
table.sort(self.tbDuelHistory, function(a, b)
return a.SelfHotValue > b.SelfHotValue
return a.RivalHotValue > b.RivalHotValue
end)
return self.tbDuelHistory
end
@@ -426,7 +426,7 @@ function TrekkerVersusData:RequestReceiveScheduleReward(nActId, nScheduleType)
end
if nScheduleType == 1 then
local foreachHeatQuest = function(mapQuestData)
if mapQuestData.TargetValue <= self.nSelfHotValue and table.indexof(self.tbHotValueRewardIds, mapQuestData.Id) <= 0 then
if mapQuestData.GroupId == self.nActId and mapQuestData.TargetValue <= self.nSelfHotValue and table.indexof(self.tbHotValueRewardIds, mapQuestData.Id) <= 0 then
table.insert(self.tbHotValueRewardIds, mapQuestData.Id)
end
end
@@ -564,7 +564,7 @@ function TrekkerVersusData:RefreshQusetRedDot()
end
local bHeatQuestVisible = false
local foreachHeatReward = function(mapData)
if mapData.TargetValue <= self.nSelfHotValue and table.indexof(self.tbHotValueRewardIds, mapData.Id) <= 0 then
if mapData.GroupId == self.nActId and mapData.TargetValue <= self.nSelfHotValue and table.indexof(self.tbHotValueRewardIds, mapData.Id) <= 0 then
bHeatQuestVisible = true
end
end
@@ -576,6 +576,14 @@ function TrekkerVersusData:RefreshQusetRedDot()
}, bHeatQuestVisible)
end
end
function TrekkerVersusData:GetCanReceiveAllQuestReward()
for _, mapQuest in pairs(self.mapQuests) do
if mapQuest.Status == 1 then
return true
end
end
return false
end
function TrekkerVersusData:GetFirstIn()
local bFirst = self.bFirstIn
if self.bFirstIn == true then
+18 -1
View File
@@ -12,6 +12,17 @@ local OnEvent_NewDay = function()
EventManager.Hit("UpdateDispatchData")
end
local OnEvent_SettingsNotificationClose = function()
if tbAllDispatchData == nil then
return
end
for k, v in pairs(tbAllDispatchData) do
if v.State == AllEnum.DispatchState.Accepting then
NotificationManager.UnregisterNotification(20000000, v.Data.Id)
end
if LocalSettingData.GetLocalSettingData("Dispatch") then
NotificationManager.RegisterNotification(20000000, v.Data.Id, v.Data.StartTime + v.Data.ProcessTime * 60)
end
end
end
local Init = function()
EventManager.Add(EventId.IsNewDay, DispatchData, OnEvent_NewDay)
@@ -24,10 +35,12 @@ local CacheDispatchData = function(data)
return
end
for k, v in pairs(data.Infos) do
NotificationManager.UnregisterNotification(20000000, v.Id)
local state = AllEnum.DispatchState.Accepting
if v.ProcessTime * 60 + v.StartTime <= CS.ClientManager.Instance.serverTimeStamp then
state = AllEnum.DispatchState.Complete
else
elseif LocalSettingData.GetLocalSettingData("Dispatch") then
NotificationManager.RegisterNotification(20000000, v.Id, v.StartTime + v.ProcessTime * 60)
end
tbAllDispatchData[v.Id] = {Data = v, State = state}
end
@@ -347,6 +360,9 @@ local ReqApplyAgent = function(agentList, agentData, callback)
if callback ~= nil then
callback()
end
if LocalSettingData.GetLocalSettingData("Dispatch") then
NotificationManager.RegisterNotification(20000000, v.Id, v.BeginTime + agentData[v.Id].ProcessTime * 60)
end
end
EventManager.Hit(EventId.DispatchRefreshPanel, AllEnum.DispatchState.Accepting)
bReqApplyAgent = false
@@ -376,6 +392,7 @@ local ReqGiveUpAgent = function(dispatchId, callback)
callback()
end
EventManager.Hit(EventId.DispatchRefreshPanel)
NotificationManager.UnregisterNotification(20000000, dispatchId)
end
HttpNetHandler.SendMsg(NetMsgId.Id.agent_give_up_req, mapData, nil, func_callback)
end
@@ -172,6 +172,7 @@ function PlayerBaseData:CacheEnergyInfo(mapData)
self._nEnergyTime = mapData.Energy.IsPrimary == true and mapData.Energy.NextDuration + nServerTime or 0
self._nEnergyBatteryTime = mapData.Energy.IsPrimary == true and 0 or mapData.Energy.NextDuration + nServerTime
self._nBuyEnergyCount = mapData.Count
NotificationManager.UnregisterNotification(10000000, 0)
if self._mapEnergyTimer ~= nil then
self._mapEnergyTimer:Cancel(nil)
end
@@ -183,6 +184,11 @@ function PlayerBaseData:CacheEnergyInfo(mapData)
else
self._mapEnergyTimer = TimerManager.Add(1, mapData.Energy.NextDuration, self, self.HandleEnergyTimer, true, true, false)
end
if LocalSettingData.GetLocalSettingData("Energy") and self._nCurEnergy < ConfigTable.GetConfigNumber("EnergyMaxLimit") then
local nEmptyEnergy = ConfigTable.GetConfigNumber("EnergyMaxLimit") - self._nCurEnergy - 1
local nTime = ConfigTable.GetConfigNumber("EnergyGain") * 60 * nEmptyEnergy + self._nEnergyTime
NotificationManager.RegisterNotification(10000000, 0, nTime)
end
end
end
function PlayerBaseData:CacheTitleInfo(mapData)
@@ -416,6 +422,12 @@ function PlayerBaseData:ChangeEnergy(mapData)
end
EventManager.Hit(EventId.UpdateEnergyBattery)
EventManager.Hit(EventId.UpdateEnergy)
NotificationManager.UnregisterNotification(10000000, 0)
if LocalSettingData.GetLocalSettingData("Energy") and self._nCurEnergy < ConfigTable.GetConfigNumber("EnergyMaxLimit") then
local nEmptyEnergy = ConfigTable.GetConfigNumber("EnergyMaxLimit") - self._nCurEnergy - 1
local nTime = ConfigTable.GetConfigNumber("EnergyGain") * 60 * nEmptyEnergy + self._nEnergyTime
NotificationManager.RegisterNotification(10000000, 0, nTime)
end
end
end
function PlayerBaseData:ChangeTitle(mapData)
@@ -1311,5 +1323,11 @@ function PlayerBaseData:OnCS2LuaEvent_AppFocus(bFocus)
end
end
function PlayerBaseData:OnEvent_SettingsNotificationClose()
NotificationManager.UnregisterNotification(10000000, 0)
if LocalSettingData.GetLocalSettingData("Energy") and self._nCurEnergy < ConfigTable.GetConfigNumber("EnergyMaxLimit") then
local nEmptyEnergy = ConfigTable.GetConfigNumber("EnergyMaxLimit") - self._nCurEnergy - 1
local nTime = ConfigTable.GetConfigNumber("EnergyGain") * 60 * nEmptyEnergy + self._nEnergyTime
NotificationManager.RegisterNotification(10000000, 0, nTime)
end
end
return PlayerBaseData
@@ -92,6 +92,21 @@ end
function PlayerFriendData:GetEnergyCount()
return self._nEnergyCount
end
function PlayerFriendData:CacheFriendAddStranger(mapFriend)
self.mapStrangerFriend = mapFriend
end
function PlayerFriendData:TryOpenFriendAddStranger()
if not self.mapStrangerFriend then
return
end
local mapFriend = clone(self.mapStrangerFriend)
self.mapStrangerFriend = nil
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
EventManager.Hit(EventId.OpenPanel, PanelId.FriendAddStranger, mapFriend)
end
cs_coroutine.start(wait)
end
function PlayerFriendData:JudgeEnergyGetAble()
if not self._tbFriendList then
return false
@@ -108,7 +123,7 @@ function PlayerFriendData:JudgeEnergySendAble()
return false
end
for _, v in pairs(self._tbFriendList) do
if v.bSendEnergy == false then
if not v.bSendEnergy then
return true
end
end
@@ -57,11 +57,13 @@ function PlayerHandbookData:UpdateHandbook(msgData)
local curResult = UTILS.IsBitSet(tbData, nIndex)
if lastResult ~= curResult and nil ~= self.tbHandbookCfgData[msgData.Type] then
local id = self.tbHandbookCfgData[msgData.Type][nIndex]
if nil == self.tbHandbookData[id] then
local handbookData = self:CreateHandbook(msgData.Type, id, 1)
self.tbHandbookData[id] = handbookData
else
self.tbHandbookData[id]:UpdateUnlockState(1)
if id ~= nil then
if nil == self.tbHandbookData[id] then
local handbookData = self:CreateHandbook(msgData.Type, id, 1)
self.tbHandbookData[id] = handbookData
else
self.tbHandbookData[id]:UpdateUnlockState(1)
end
end
end
end
@@ -880,6 +880,14 @@ function PlayerItemData:ProcessRewardChangeInfo(mapChangeInfo)
end
end
end
if type(mapDecodeInfo["proto.TraceHuntItem"]) == "table" then
for _, mapData in ipairs(mapDecodeInfo["proto.TraceHuntItem"]) do
local itemInfo = ConfigTable.GetData_Item(mapData.Tid)
if itemInfo and 0 < mapData.ConvertQty + mapData.GrantQty then
add_reward(mapData.Tid, mapData.ConvertQty + mapData.GrantQty)
end
end
end
for nId, nCount in pairs(tbRewardById) do
if nCount <= 0 then
tbRewardById[nId] = nil
@@ -4,6 +4,7 @@ function PlayerSideBannerData:Init()
self.tbDictionaryEntry = {}
self.tbAchievement = {}
self.tbFavour = {}
self.tbItem = {}
EventManager.Add("DispatchMsgDone", self, self.OnEvent_TryOpenSideBanner)
end
function PlayerSideBannerData:UnInit()
@@ -79,12 +80,24 @@ function PlayerSideBannerData:TryOpenSideBanner(bLimit)
})
end
end
if next(self.tbItem) ~= nil then
for _, v in ipairs(self.tbItem) do
table.insert(mapData, {
nType = AllEnum.SideBaner.Item,
mapReward = {
id = v.nId,
count = v.nCount
}
})
end
end
if next(mapData) == nil then
return
end
self.tbDictionaryEntry = {}
self.tbAchievement = {}
self.tbFavour = {}
self.tbItem = {}
EventManager.Hit("OpenSideBanner", mapData)
end
function PlayerSideBannerData:AddDictionaryEntry(nId)
@@ -96,4 +109,7 @@ end
function PlayerSideBannerData:AddFavour(nId)
table.insert(self.tbFavour, nId)
end
function PlayerSideBannerData:AddItem(nId, nCount)
table.insert(self.tbItem, {nId = nId, nCount = nCount})
end
return PlayerSideBannerData
@@ -31,6 +31,7 @@ function PlayerStateData:CacheStateData(mapMsgData)
PlayerData.ScoreBoss:UpdateRedDot(mapMsgData.ScoreBoss)
PlayerData.Activity:UpdateActivityState(mapMsgData.Activities)
PlayerData.StorySet:UpdateStorySetState(mapMsgData.StorySet)
PlayerData.TraceHunt:UpdateBossRewardRedDot(mapMsgData.TraceHunt.BossRewardCanReceive)
self.nVampireId = mapMsgData.VampireSurvivorId
else
self.bMailState = false
@@ -0,0 +1,869 @@
local PlayerTraceHuntData = class("PlayerTraceHuntData")
local ClientManager = CS.ClientManager.Instance
local TimerManager = require("GameCore.Timer.TimerManager")
function PlayerTraceHuntData:Init()
self.timerControl = nil
self.timerHelp = nil
self.timerHunt = nil
self.bRefreshHelpCD = false
self.tbRecommend = {}
self.bNewControl = false
self.bHuntWarning = true
self.nMaxStar = 0
self.nControlId = 0
self.nBossId = 0
self.nTraceProgress = 0
self.nHuntProgress = 0
self.nBossCreateTime = 0
self.nSelfBossHuntCount = 0
self.tbTraceLog = {}
self.tbHuntLog = {}
self.tbBossCollection = {}
self.nLevel = 0
self.nExp = 0
self.mapHuntPermit = {
nEnergyOverflow = 0,
nConvertedCount = 0,
nGrantedCount = 0,
nDailyCount = 0
}
self.mapTraceRequest = {
nEnergyOverflow = 0,
nConvertedCount = 0,
nGrantedCount = 0,
nDailyCount = 0
}
self.nBuildId = 0
EventManager.Add(EventId.IsNewDay, self, self.OnEvent_NewDay)
self:ProcessTableData()
end
function PlayerTraceHuntData:ProcessTableData()
self.tbTraceHuntStar = {}
local func_ForEach_Star = function(mapData)
self.tbTraceHuntStar[mapData.Star] = mapData.ScoreNeed
end
ForEachTableLine(DataTable.TraceHuntStar, func_ForEach_Star)
self.tbHuntExtraCost = {}
local func_ForEach_ExtraCost = function(mapData)
self.tbHuntExtraCost[mapData.Times] = {
Tid = mapData.ExtraCost1Tid,
Qty = mapData.ExtraCost1Qty
}
end
ForEachTableLine(DataTable.TraceHuntSelfHuntExtraCost, func_ForEach_ExtraCost)
self:ProcessTableData_Level()
self:ProcessTableData_Config()
self:ProcessTableData_Log()
end
function PlayerTraceHuntData:ProcessTableData_Config()
self.nHuntPermitTid = ConfigTable.GetConfigNumber("TraceHuntPermitItemTid")
self.nTraceRequestTid = ConfigTable.GetConfigNumber("TraceHuntRequestItemTid")
self.tbPieceNeedTraceProgress = ConfigTable.GetConfigNumberArray("TraceHuntPieceNeedTraceProgress")
self.nBossHuntLimitTime = ConfigTable.GetConfigNumber("TraceHuntBossHuntLimitTime")
self.nRefreshHelpCD = ConfigTable.GetConfigNumber("TraceHuntRefreshHelpCD")
self.nMaxTraceProgress = ConfigTable.GetConfigNumber("TraceHuntMaxTraceProgress")
self.nMaxHuntProgress = ConfigTable.GetConfigNumber("TraceHuntMaxHuntProgress")
end
function PlayerTraceHuntData:ProcessTableData_Log()
self.mapLogTemplate = {}
local func_ForEach_Log = function(mapData)
if mapData.Type == GameEnum.TraceHuntLogType.TraceStart then
self.mapLogTemplate[GameEnum.TraceHuntLogType.TraceStart] = mapData.Id
elseif mapData.Type == GameEnum.TraceHuntLogType.TraceEnd then
self.mapLogTemplate[GameEnum.TraceHuntLogType.TraceEnd] = mapData.Id
elseif mapData.Type == GameEnum.TraceHuntLogType.TraceRestart then
self.mapLogTemplate[GameEnum.TraceHuntLogType.TraceRestart] = mapData.Id
elseif mapData.Type == GameEnum.TraceHuntLogType.HuntBeforeStart then
self.mapLogTemplate[GameEnum.TraceHuntLogType.HuntBeforeStart] = mapData.Id
elseif mapData.Type == GameEnum.TraceHuntLogType.HuntStart then
self.mapLogTemplate[GameEnum.TraceHuntLogType.HuntStart] = mapData.Id
elseif mapData.Type == GameEnum.TraceHuntLogType.HuntInterrupt then
self.mapLogTemplate[GameEnum.TraceHuntLogType.HuntInterrupt] = mapData.Id
elseif mapData.Type == GameEnum.TraceHuntLogType.HuntEnd then
self.mapLogTemplate[GameEnum.TraceHuntLogType.HuntEnd] = mapData.Id
elseif mapData.Type == GameEnum.TraceHuntLogType.Settlement then
self.mapLogTemplate[GameEnum.TraceHuntLogType.Settlement] = mapData.Id
end
end
ForEachTableLine(DataTable.TraceHuntLogEntryTemplate, func_ForEach_Log)
end
function PlayerTraceHuntData:ProcessTableData_Level()
self.tbTraceHuntLevel = {}
self.nMaxTraceHuntLevel = 0
local func_ForEach_Level = function(mapData)
self.tbTraceHuntLevel[mapData.Level] = {
Exp = mapData.Exp,
WorldClass = mapData.WorldClass,
MaxStar = mapData.MaxStar,
Level = mapData.Level,
DisplayMaxStar = mapData.DisplayMaxStar,
DisplayTokenRate = mapData.DisplayTokenRate,
DisplayLuckyRate = mapData.DisplayLuckyRate,
DisplayAddRate = mapData.DisplayAddRate,
DisplayFreeRate = mapData.DisplayFreeRate,
DisplayWorldClass = 0
}
if mapData.Level > self.nMaxTraceHuntLevel then
self.nMaxTraceHuntLevel = mapData.Level
end
end
ForEachTableLine(DataTable.TraceHuntLevel, func_ForEach_Level)
for i = 1, self.nMaxTraceHuntLevel do
local mapCurLevel = self.tbTraceHuntLevel[i]
local mapNextLevel = self.tbTraceHuntLevel[i + 1]
if mapNextLevel and mapNextLevel.WorldClass > mapCurLevel.WorldClass and self.tbTraceHuntLevel[i + 2] then
self.tbTraceHuntLevel[i + 2].DisplayWorldClass = mapNextLevel.WorldClass
end
end
end
function PlayerTraceHuntData:UnInit()
EventManager.Remove(EventId.IsNewDay, self, self.OnEvent_NewDay)
end
function PlayerTraceHuntData:OnEvent_NewDay()
self.mapHuntPermit.nDailyCount = 0
self.mapTraceRequest.nDailyCount = 0
end
function PlayerTraceHuntData:CacheItemInfo(mapHuntPermit, mapTraceRequest)
self.mapHuntPermit = {
nEnergyOverflow = mapHuntPermit.EnergyOverflow,
nConvertedCount = mapHuntPermit.ConvertedCount,
nGrantedCount = mapHuntPermit.GrantedCount,
nDailyCount = mapHuntPermit.DailyCount
}
self.mapTraceRequest = {
nEnergyOverflow = mapTraceRequest.EnergyOverflow,
nConvertedCount = mapTraceRequest.ConvertedCount,
nGrantedCount = mapTraceRequest.GrantedCount,
nDailyCount = mapTraceRequest.DailyCount
}
self:UpdateItemRedDot()
end
function PlayerTraceHuntData:ChangeItem(tbTraceHuntItem)
if tbTraceHuntItem == nil then
return
end
for _, mapTraceHuntItem in ipairs(tbTraceHuntItem) do
self:ChangeTraceHuntItem(mapTraceHuntItem)
end
self:UpdateItemRedDot()
EventManager.Hit("TraceHuntItemChange")
end
function PlayerTraceHuntData:ChangeItemNotify(mapTraceHuntItem)
if mapTraceHuntItem == nil then
return
end
self:ChangeTraceHuntItem(mapTraceHuntItem)
if mapTraceHuntItem.ConvertQty > 0 then
PlayerData.SideBanner:AddItem(mapTraceHuntItem.Tid, mapTraceHuntItem.ConvertQty)
end
self:UpdateItemRedDot()
EventManager.Hit("TraceHuntItemChange")
end
function PlayerTraceHuntData:ChangeTraceHuntItem(mapTraceHuntItem)
if mapTraceHuntItem.Tid == self.nHuntPermitTid then
self.mapHuntPermit.nEnergyOverflow = self.mapHuntPermit.nEnergyOverflow + mapTraceHuntItem.PointQty
self.mapHuntPermit.nConvertedCount = self.mapHuntPermit.nConvertedCount + mapTraceHuntItem.ConvertQty
self.mapHuntPermit.nGrantedCount = self.mapHuntPermit.nGrantedCount + mapTraceHuntItem.GrantQty
self.mapHuntPermit.nDailyCount = self.mapHuntPermit.nDailyCount + mapTraceHuntItem.DailyCount
elseif mapTraceHuntItem.Tid == self.nTraceRequestTid then
self.mapTraceRequest.nEnergyOverflow = self.mapTraceRequest.nEnergyOverflow + mapTraceHuntItem.PointQty
self.mapTraceRequest.nConvertedCount = self.mapTraceRequest.nConvertedCount + mapTraceHuntItem.ConvertQty
self.mapTraceRequest.nGrantedCount = self.mapTraceRequest.nGrantedCount + mapTraceHuntItem.GrantQty
self.mapTraceRequest.nDailyCount = self.mapTraceRequest.nDailyCount + mapTraceHuntItem.DailyCount
end
end
function PlayerTraceHuntData:CacheTraceHuntInfo(mapTraceHuntInfo)
self.nControlId = mapTraceHuntInfo.ControlID
self.nBossId = mapTraceHuntInfo.BossID
self.nTraceProgress = mapTraceHuntInfo.TraceProgress
self.nHuntProgress = mapTraceHuntInfo.HuntProgress
self.nBossCreateTime = mapTraceHuntInfo.BossCreateTime
if self.nBossCreateTime ~= 0 then
self:SetHuntTimer()
end
self.nSelfBossHuntCount = mapTraceHuntInfo.SelfHuntTimes
self.tbTraceLog = {}
self:AddTraceLog(mapTraceHuntInfo.TraceLog)
self.tbHuntLog = {}
self:AddHuntLog(mapTraceHuntInfo.HuntLog)
self.tbBossCollection = {}
for _, v in ipairs(mapTraceHuntInfo.BossCollections) do
self:UpdateBossCollection(v.Id, v.HuntCount, v.AssistHuntCount)
end
self:UpdateControlData()
self:UpdateLevel(mapTraceHuntInfo.Level, mapTraceHuntInfo.Exp)
self:SetSelBuildId(mapTraceHuntInfo.BuildID)
self:UpdateBossRewardRedDot(self.nHuntProgress >= self.nMaxHuntProgress)
if NovaAPI.IsEditorPlatform() then
printLog("TraceHunt 赛季id" .. " " .. mapTraceHuntInfo.ControlID)
printLog("TraceHunt Boss id" .. " " .. mapTraceHuntInfo.BossID)
printLog("TraceHunt 追踪进度:" .. " " .. mapTraceHuntInfo.TraceProgress)
printLog("TraceHunt 讨伐进度:" .. " " .. mapTraceHuntInfo.HuntProgress)
printLog("TraceHunt boss 创建时间:" .. " " .. mapTraceHuntInfo.BossCreateTime)
printLog("TraceHunt boss 自己讨伐的次数:" .. " " .. mapTraceHuntInfo.SelfHuntTimes)
end
end
function PlayerTraceHuntData:UpdateControlData()
if self.nControlId == 0 then
return
end
local mapCfg = ConfigTable.GetData("TraceHuntControl", self.nControlId)
if not mapCfg then
return
end
self.nEndTime = ClientManager:ISO8601StrToTimeStamp(mapCfg.EndTime)
self.nStartTime = ClientManager:ISO8601StrToTimeStamp(mapCfg.StartTime)
self.tbBossList = mapCfg.BossList
self.tbStarDropCount = mapCfg.StarDropCount
self:SetControlTimer()
end
function PlayerTraceHuntData:UpdateBossCollection(nId, nCompleteHuntCount, nAssistHuntCount)
if not self.tbBossCollection[nId] then
self.tbBossCollection[nId] = {
nId = nId,
nCompleteHuntCount = 0,
nAssistHuntCount = 0
}
end
self.tbBossCollection[nId].nCompleteHuntCount = self.tbBossCollection[nId].nCompleteHuntCount + nCompleteHuntCount
self.tbBossCollection[nId].nAssistHuntCount = self.tbBossCollection[nId].nAssistHuntCount + nAssistHuntCount
end
function PlayerTraceHuntData:UpdateLevel(nLevel, nExp)
self.nLevel = nLevel
self.nExp = nExp
local mapCfg = self.tbTraceHuntLevel[nLevel]
self.nMaxStar = mapCfg.MaxStar
end
function PlayerTraceHuntData:SetNewControl(bNew)
self.bNewControl = bNew
end
function PlayerTraceHuntData:GetNewControl()
return self.bNewControl
end
function PlayerTraceHuntData:GetAddExp(nLevel1, nExp1, nLevel2, nExp2)
if nLevel1 == nLevel2 then
return nExp2 - nExp1
elseif nLevel1 < nLevel2 then
local nAll = 0
for i = nLevel1, nLevel2 - 1 do
nAll = nAll + self.tbTraceHuntLevel[i].Exp
end
nAll = nAll + nExp2 - nExp1
return nAll
else
return 0
end
end
function PlayerTraceHuntData:GetCurControlId()
return self.nControlId
end
function PlayerTraceHuntData:GetHuntWarning()
return self.bHuntWarning
end
function PlayerTraceHuntData:SetHuntWarning(bAble)
self.bHuntWarning = bAble
end
function PlayerTraceHuntData:GetEndTime()
return self.nEndTime or 0
end
function PlayerTraceHuntData:GetStartTime()
return self.nStartTime or 0
end
function PlayerTraceHuntData:GetControlLeftTime()
if not self.nEndTime then
return 0
end
local nLeft = self.nEndTime - ClientManager.serverTimeStamp
if nLeft < 0 then
nLeft = 0
end
return nLeft
end
function PlayerTraceHuntData:GetHuntLeftTime()
if self.nBossCreateTime == 0 then
return 0
end
if self.nHuntProgress >= self.nMaxHuntProgress then
return 0
end
local nLeft = self.nBossCreateTime + self.nBossHuntLimitTime - ClientManager.serverTimeStamp
if nLeft < 0 then
nLeft = 0
end
return nLeft
end
function PlayerTraceHuntData:GetBossCreateTime()
return self.nBossCreateTime
end
function PlayerTraceHuntData:ClearCurBoss()
self.nBossId = 0
self.nTraceProgress = 0
self.nHuntProgress = 0
self.nBossCreateTime = 0
self.nSelfBossHuntCount = 0
self.tbTraceLog = {}
self.tbHuntLog = {}
end
function PlayerTraceHuntData:GetTraceHuntLevel()
return self.nLevel, self.nExp
end
function PlayerTraceHuntData:GetTraceHuntLevelData(nLevel)
return self.tbTraceHuntLevel[nLevel]
end
function PlayerTraceHuntData:GetTraceHuntMaxLevel()
return self.nMaxTraceHuntLevel
end
function PlayerTraceHuntData:GetBossId()
return self.nBossId
end
function PlayerTraceHuntData:CheckMaxTrace()
return self.nTraceProgress >= self.nMaxTraceProgress
end
function PlayerTraceHuntData:GetMaxStar()
return self.nMaxStar
end
function PlayerTraceHuntData:GetTraceProgress()
return self.nTraceProgress / self.nMaxTraceProgress * 100
end
function PlayerTraceHuntData:GetHuntProgress()
return self.nHuntProgress / self.nMaxHuntProgress * 100
end
function PlayerTraceHuntData:GetHuntRecommend()
return self.tbRecommend
end
function PlayerTraceHuntData:GetSelfHuntCount()
return self.nSelfBossHuntCount
end
function PlayerTraceHuntData:GetStarScore(nStar)
return self.tbTraceHuntStar[nStar] or 0
end
function PlayerTraceHuntData:GetHuntCostCount(bSelf)
if self.nControlId == 0 then
return 0
end
local mapCfg = ConfigTable.GetData("TraceHuntControl", self.nControlId)
if not mapCfg then
return 0
end
if bSelf then
local nNext = self.nSelfBossHuntCount
local nMax = #self.tbHuntExtraCost
if nNext >= nMax then
nNext = nMax
end
if nNext == 0 then
return mapCfg.SelfHuntCost1Qty
else
return mapCfg.SelfHuntCost1Qty + self.tbHuntExtraCost[nNext].Qty
end
else
return mapCfg.OtherHuntCost1Qty
end
end
function PlayerTraceHuntData:GetTraceCostCount()
if self.nControlId == 0 then
return 0
end
local mapCfg = ConfigTable.GetData("TraceHuntControl", self.nControlId)
if not mapCfg then
return 0
end
return mapCfg.TraceCost1Qty
end
function PlayerTraceHuntData:GetHuntRewardRange()
if self.nControlId == 0 then
return 0, 0
end
local mapCfg = ConfigTable.GetData("TraceHuntControl", self.nControlId)
if not mapCfg then
return 0, 0
end
local tbCount = mapCfg.StarDropCount
local nMin = tbCount[1]
local nMax = 0
for nStar, v in ipairs(tbCount) do
if nStar <= self.nMaxStar then
nMax = v
end
end
return nMin, nMax
end
function PlayerTraceHuntData:GetHuntTokenCount()
return self.mapHuntPermit.nConvertedCount + self.mapHuntPermit.nGrantedCount
end
function PlayerTraceHuntData:GetTraceTokenCount()
return self.mapTraceRequest.nConvertedCount + self.mapTraceRequest.nGrantedCount
end
function PlayerTraceHuntData:GetHuntTokenDailyCount()
return self.mapHuntPermit.nDailyCount
end
function PlayerTraceHuntData:GetTraceTokenDailyCount()
return self.mapTraceRequest.nDailyCount
end
function PlayerTraceHuntData:AddTraceLog(tbLog, bAdd)
if next(tbLog) == nil then
return
end
if next(self.tbTraceLog) == nil then
table.insert(self.tbTraceLog, {
nId = self.mapLogTemplate[GameEnum.TraceHuntLogType.TraceStart],
tbArgs = {},
nType = GameEnum.TraceHuntLogType.TraceStart
})
end
for _, v in ipairs(tbLog) do
local mapCfg = ConfigTable.GetData("TraceHuntLogEntryTemplate", v.Tid)
if mapCfg then
table.insert(self.tbTraceLog, {
nId = v.Tid,
tbArgs = v.args,
nType = mapCfg.Type
})
if mapCfg.Type == GameEnum.TraceHuntLogType.TraceBeforeEnd then
table.insert(self.tbTraceLog, {
nId = self.mapLogTemplate[GameEnum.TraceHuntLogType.TraceEnd],
tbArgs = {},
nType = GameEnum.TraceHuntLogType.TraceEnd
})
elseif mapCfg.Type == GameEnum.TraceHuntLogType.TraceInterrupt then
table.insert(self.tbTraceLog, {
nId = self.mapLogTemplate[GameEnum.TraceHuntLogType.TraceRestart],
tbArgs = {},
nType = GameEnum.TraceHuntLogType.TraceRestart
})
end
end
if bAdd and mapCfg and mapCfg.Type == GameEnum.TraceHuntLogType.Tracing then
self.nTraceProgress = self.nTraceProgress + tonumber(v.args[1])
if self.nTraceProgress >= self.nMaxTraceProgress then
self.nTraceProgress = self.nMaxTraceProgress
end
end
end
end
function PlayerTraceHuntData:GetTraceLog()
return clone(self.tbTraceLog)
end
function PlayerTraceHuntData:AddHuntLog(tbLog, bAdd)
if next(tbLog) == nil then
return
end
if next(self.tbHuntLog) == nil then
table.insert(self.tbHuntLog, {
nId = self.mapLogTemplate[GameEnum.TraceHuntLogType.HuntBeforeStart],
tbArgs = {},
nType = GameEnum.TraceHuntLogType.HuntBeforeStart
})
table.insert(self.tbHuntLog, {
nId = self.mapLogTemplate[GameEnum.TraceHuntLogType.HuntStart],
tbArgs = {},
nType = GameEnum.TraceHuntLogType.HuntStart
})
end
for _, v in ipairs(tbLog) do
local mapCfg = ConfigTable.GetData("TraceHuntLogEntryTemplate", v.Tid)
if mapCfg then
table.insert(self.tbHuntLog, {
nId = v.Tid,
tbArgs = v.args,
nType = mapCfg.Type
})
if mapCfg.Type == GameEnum.TraceHuntLogType.HuntPlayerFatal or mapCfg.Type == GameEnum.TraceHuntLogType.HuntNPCFatal then
table.insert(self.tbHuntLog, {
nId = self.mapLogTemplate[GameEnum.TraceHuntLogType.HuntEnd],
tbArgs = {},
nType = GameEnum.TraceHuntLogType.HuntEnd
})
end
end
if bAdd and mapCfg and (mapCfg.Type == GameEnum.TraceHuntLogType.HuntPlayer or mapCfg.Type == GameEnum.TraceHuntLogType.HuntNPC) then
local nIndex = 1
if mapCfg.Type == GameEnum.TraceHuntLogType.HuntPlayer then
nIndex = 2
elseif mapCfg.Type == GameEnum.TraceHuntLogType.HuntNPC then
nIndex = 1
end
self.nHuntProgress = self.nHuntProgress + tonumber(v.args[nIndex])
if self.nHuntProgress >= self.nMaxHuntProgress then
self.nHuntProgress = self.nMaxHuntProgress
end
end
end
if self:CheckHuntInterrupt() then
self:AddHuntLog_HuntInterrupt()
end
end
function PlayerTraceHuntData:AddHuntLog_HuntInterrupt()
local bHas = false
for _, v in ipairs(self.tbHuntLog) do
if v.nType == GameEnum.TraceHuntLogType.HuntInterrupt then
bHas = true
break
end
end
if bHas then
return
end
table.insert(self.tbHuntLog, {
nId = self.mapLogTemplate[GameEnum.TraceHuntLogType.HuntInterrupt],
tbArgs = {},
nType = GameEnum.TraceHuntLogType.HuntInterrupt
})
table.insert(self.tbHuntLog, {
nId = self.mapLogTemplate[GameEnum.TraceHuntLogType.HuntEnd],
tbArgs = {},
nType = GameEnum.TraceHuntLogType.HuntEnd
})
end
function PlayerTraceHuntData:AddHuntLog_Settlement(nExp)
table.insert(self.tbHuntLog, {
nId = self.mapLogTemplate[GameEnum.TraceHuntLogType.Settlement],
tbArgs = {nExp},
nType = GameEnum.TraceHuntLogType.Settlement
})
end
function PlayerTraceHuntData:CheckHuntInterrupt()
return self.nHuntProgress < self.nMaxHuntProgress and self.nBossCreateTime ~= 0 and 0 >= self:GetHuntLeftTime()
end
function PlayerTraceHuntData:CheckHuntComplete()
return self.nHuntProgress >= self.nMaxHuntProgress
end
function PlayerTraceHuntData:GetHuntLog()
return clone(self.tbHuntLog)
end
function PlayerTraceHuntData:GetBossCollection()
return self.tbBossCollection, self.tbBossList or {}
end
function PlayerTraceHuntData:GetStarDropCount()
return self.tbStarDropCount or {}
end
function PlayerTraceHuntData:SetControlTimer()
if self.timerControl ~= nil then
self.timerControl:Cancel(false)
self.timerControl = nil
end
local nLeft = self:GetControlLeftTime()
if 0 < nLeft then
self.timerControl = TimerManager.Add(1, nLeft, self, function()
local callback = function()
EventManager.Hit("TraceHuntNewControl")
end
self:SendTraceHuntInfoReq(callback)
end, true, true, false)
end
end
function PlayerTraceHuntData:SetHuntTimer()
if self.timerHunt ~= nil then
self.timerHunt:Cancel(false)
self.timerHunt = nil
end
local nLeft = self:GetHuntLeftTime()
if 0 < nLeft then
self.timerHunt = TimerManager.Add(1, nLeft, self, function()
if self:CheckHuntInterrupt() then
self:AddHuntLog_HuntInterrupt()
EventManager.Hit("TraceHuntCurBossExpired")
end
end, true, true, false)
end
end
function PlayerTraceHuntData:SetHelpTimer()
if self.timerHelp ~= nil then
self.timerHelp:Cancel(false)
self.timerHelp = nil
end
self.timerHelp = TimerManager.Add(1, self.nRefreshHelpCD, self, function()
self.bRefreshHelpCD = false
end, true, true, false)
end
function PlayerTraceHuntData:SendTraceHuntInfoReq(callback)
local successCallback = function(_, mapMainData)
self:CacheTraceHuntInfo(mapMainData)
if callback then
callback()
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.trace_hunt_info_req, {}, nil, successCallback)
end
function PlayerTraceHuntData:SendTraceHuntApplyReq(nOwnerUID, nBossID, nBuildId, nBossCreateTime, mapFriend)
local msgData = {
OwnerUID = nOwnerUID,
BossID = nBossID,
BuildID = nBuildId,
BossCreateTime = nBossCreateTime
}
local successCallback = function(_, mapMainData)
self.CurHPLvScore = 0
self.HPLvScore = 0
self.CurHPDamage = 0
self.bSelfBoss = PlayerData.Base._nPlayerId == nOwnerUID
self:EnterTraceHunt(nBossID, nBuildId)
PlayerData.Friend:CacheFriendAddStranger(mapFriend)
end
HttpNetHandler.SendMsg(NetMsgId.Id.trace_hunt_apply_req, msgData, nil, successCallback)
end
function PlayerTraceHuntData:SendTraceHuntSettleReq(nBossId, callback)
local nStar = self:ScoreToStar()
local nScore = self:GetTotalScore()
local msgData = {
Score = nScore,
Star = nStar,
Events = {
List = PlayerData.Achievement:GetBattleAchievement(GameEnum.levelType.TraceHunt, true)
}
}
CS.AdventureModuleHelper.PauseLogic()
local successCallback = function(_, mapMainData)
local nExp = 0
local bUpgrade = false
local nBeforeMaxStar = self:GetMaxStar()
if 1 <= nStar then
nExp = self:GetAddExp(self.nLevel, self.nExp, mapMainData.Level, mapMainData.Exp)
bUpgrade = mapMainData.Level > self.nLevel
self:UpdateLevel(mapMainData.Level, mapMainData.Exp)
if self.bSelfBoss then
self.tbHuntLog = {}
self.nHuntProgress = 0
self:AddHuntLog(mapMainData.HuntLog, true)
self.nSelfBossHuntCount = mapMainData.SelfHuntTimes
if mapMainData.BossCreateTime ~= 0 then
self.nBossCreateTime = mapMainData.BossCreateTime
self:SetHuntTimer()
end
self:UpdateBossRewardRedDot(self.nHuntProgress >= self.nMaxHuntProgress)
else
self:UpdateBossCollection(nBossId, 0, 1)
self.bRefreshHelpCD = false
end
end
CS.AdventureModuleHelper.ResumeLogic()
EventManager.Hit("TraceHuntSettleSuccess", self.entryLevelId, nStar, nExp, self.bSelfBoss, mapMainData.ChangeInfo or {}, bUpgrade, nBeforeMaxStar)
self:LevelEnd()
if callback then
callback()
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.trace_hunt_settle_req, msgData, nil, successCallback)
end
function PlayerTraceHuntData:ReceiveTraceHuntSettleFailed()
local nStar = 0
local nExp = 0
local bUpgrade = false
local nBeforeMaxStar = self:GetMaxStar()
CS.AdventureModuleHelper.ResumeLogic()
EventManager.Hit("TraceHuntSettleSuccess", self.entryLevelId, nStar, nExp, self.bSelfBoss, {}, bUpgrade, nBeforeMaxStar)
self:LevelEnd()
end
function PlayerTraceHuntData:SendTraceHuntRecommendReq(callback)
if self.bRefreshHelpCD then
if callback then
callback()
end
return
end
local successCallback = function(_, mapMainData)
self.bRefreshHelpCD = true
self:SetHelpTimer()
self.tbRecommend = {}
for _, v in ipairs(mapMainData.Recommendations) do
local mapData = {
nUID = v.OwnerUID,
nBossId = v.BossID,
nBossCreateTime = v.BossCreateTime,
bFriend = v.IsFriend,
bStar = v.IsStar,
mapFriend = {}
}
PlayerData.Friend:ParseFriendData(mapData.mapFriend, v.Info)
table.insert(self.tbRecommend, mapData)
table.sort(self.tbRecommend, function(a, b)
if a.bStar ~= b.bStar then
return a.bStar and not b.bStar
elseif a.bFriend ~= b.bFriend then
return a.bFriend and not b.bFriend
else
return a.nBossCreateTime < b.nBossCreateTime
end
end)
end
if callback then
callback()
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.trace_hunt_recommend_req, {}, nil, successCallback)
end
function PlayerTraceHuntData:SendTraceHuntRewardReceiveReq(callback)
if self.nBossId == 0 then
return
end
local bComplete = PlayerData.TraceHunt:CheckHuntComplete()
local bInterrupt = PlayerData.TraceHunt:CheckHuntInterrupt()
if not bComplete and not bInterrupt then
return
end
local successCallback = function(_, mapMainData)
local mapBeforeLevel = {
nLevel = self.nLevel,
nExp = self.nExp,
nMaxLevel = self.nMaxTraceHuntLevel,
nMaxExp = self.tbTraceHuntLevel[self.nLevel].Exp
}
local mapAfterLevel = {
nLevel = mapMainData.Level,
nExp = mapMainData.Exp,
nMaxLevel = self.nMaxTraceHuntLevel,
nMaxExp = self.tbTraceHuntLevel[mapMainData.Level].Exp
}
self:UpdateBossRewardRedDot(false)
self:UpdateBossCollection(self.nBossId, 1, 0)
local nExp = self:GetAddExp(self.nLevel, self.nExp, mapMainData.Level, mapMainData.Exp)
self:UpdateLevel(mapMainData.Level, mapMainData.Exp)
self:AddHuntLog_Settlement(nExp)
if callback then
callback(mapBeforeLevel, mapAfterLevel, mapMainData.ChangeInfo)
end
self:ClearCurBoss()
end
HttpNetHandler.SendMsg(NetMsgId.Id.trace_hunt_boss_reward_receive_req, {}, nil, successCallback)
end
function PlayerTraceHuntData:SendTraceHuntTraceReq(nCount, callback)
local msgData = {Value = nCount}
local successCallback = function(_, mapMainData)
self:AddTraceLog(mapMainData.TraceLog, true)
if mapMainData.BossID ~= 0 then
self.nBossId = mapMainData.BossID
end
if callback then
callback()
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.trace_hunt_trace_req, msgData, nil, successCallback)
end
function PlayerTraceHuntData:UpdateBossRewardRedDot(bAble)
RedDotManager.SetValid(RedDotDefine.TraceHunt_Reward_Boss, nil, bAble)
self:UpdateItemEntranceRedDot()
end
function PlayerTraceHuntData:UpdateItemRedDot()
self:UpdateHuntItemRedDot()
self:UpdateTraceItemRedDot()
self:UpdateItemEntranceRedDot()
end
function PlayerTraceHuntData:UpdateHuntItemRedDot()
local tbMax = ConfigTable.GetConfigNumberArray("TraceHuntPermitItem")
local nHasCoin = self:GetHuntTokenCount()
local bAble = nHasCoin >= tbMax[3]
RedDotManager.SetValid(RedDotDefine.TraceHunt_HuntItem, nil, bAble)
end
function PlayerTraceHuntData:UpdateTraceItemRedDot()
local tbMax = ConfigTable.GetConfigNumberArray("TraceHuntRequestItem")
local nHasCoin = self:GetTraceTokenCount()
local bAble = nHasCoin >= tbMax[3]
RedDotManager.SetValid(RedDotDefine.TraceHunt_TraceItem, nil, bAble)
end
function PlayerTraceHuntData:UpdateItemEntranceRedDot()
local bReward = RedDotManager.GetValid(RedDotDefine.TraceHunt_Reward_Boss)
local bHuntMax = RedDotManager.GetValid(RedDotDefine.TraceHunt_HuntItem)
local bTraceMax = RedDotManager.GetValid(RedDotDefine.TraceHunt_TraceItem)
RedDotManager.SetValid(RedDotDefine.TraceHunt_Item, nil, not bReward and (bHuntMax or bTraceMax))
end
function PlayerTraceHuntData:EnterTraceHunt(nLevelId, nBuildId)
self.entryLevelId = nLevelId
self.entryBuild = nBuildId
if self.curLevel == nil then
local luaClass = require("Game.Adventure.TraceHunt.TraceHuntLevel")
if luaClass == nil then
return
end
self.curLevel = luaClass
end
if type(self.curLevel.BindEvent) == "function" and not self.isGoAgain then
self.curLevel:BindEvent()
end
if type(self.curLevel.Init) == "function" then
self.curLevel:Init(self, nLevelId, nBuildId, self.isGoAgain)
end
self.isGoAgain = false
end
function PlayerTraceHuntData:LevelEnd()
if nil ~= self.curLevel and type(self.curLevel.UnBindEvent) == "function" then
self.curLevel:UnBindEvent()
end
self.curLevel = nil
end
function PlayerTraceHuntData:SetSelBuildId(nBuildId)
self.nCachedBuildId = nBuildId
end
function PlayerTraceHuntData:GetCachedBuild()
return self.nCachedBuildId or 0
end
function PlayerTraceHuntData:DamageToScore(damageValue, SwitchRate, battleLv)
self.CurHPDamage = damageValue
self.CurHPLvScore = math.floor(damageValue / SwitchRate)
EventManager.Hit("TraceHunt_Score_Change")
self:CheckMaxStar()
end
function PlayerTraceHuntData:HPLevelChanged()
self.HPLvScore = self.HPLvScore + self.CurHPLvScore
self.CurHPLvScore = 0
self.CurHPDamage = 0
EventManager.Hit("TraceHunt_Score_Change")
self:CheckMaxStar()
end
function PlayerTraceHuntData:CheckMaxStar()
local nStar = self:ScoreToStar()
if nStar >= self.nMaxStar then
NovaAPI.DispatchEventWithData("TraceHunt_MaxStar")
EventManager.Hit("TraceHunt_MaxStar")
end
end
function PlayerTraceHuntData:GetTotalScore()
local totalScore = self.HPLvScore + self.CurHPLvScore
return totalScore
end
function PlayerTraceHuntData:ScoreToStar()
local tmpStar = 0
local totalScore = self.HPLvScore + self.CurHPLvScore
for i, v in pairs(self.tbTraceHuntStar) do
if v <= totalScore and i > tmpStar then
tmpStar = i
end
end
if tmpStar >= self.nMaxStar then
tmpStar = self.nMaxStar
end
return tmpStar
end
function PlayerTraceHuntData:QuiteLevel()
self:LevelEnd()
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
CS.WwiseAudioManager.Instance:PostEvent("ui_loading_combatSFX_mute", nil, false)
end
cs_coroutine.start(wait)
CS.AdventureModuleHelper.ResumeLogic()
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
NovaAPI.EnterModule("MainMenuModuleScene", true)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
CS.AdventureModuleHelper.LevelStateChanged(true, 0, true)
end
function PlayerTraceHuntData:SendEnterLvAgain()
if self.curLevel ~= nil then
self.curLevel.isCanPause = false
end
self.isGoAgain = true
CS.AdventureModuleHelper.LevelStateChanged(false)
EventManager.Hit("BattleRestart")
end
function PlayerTraceHuntData:EntryLvAgain()
if self.isGoAgain then
self.CurHPLvScore = 0
self.HPLvScore = 0
self.CurHPDamage = 0
EventManager.Hit("TraceHunt_Restart_Again")
self:EnterTraceHunt(self.entryLevelId, self.entryBuild)
end
end
return PlayerTraceHuntData
@@ -339,7 +339,7 @@ function PlayerVoiceData:PlayBoardClickVoice()
end
end
end
function PlayerVoiceData:PlayBoardNPCClickVoice(nNpcId, nSkinId)
function PlayerVoiceData:PlayBoardNPCClickVoice(nNpcId, nSkinId, sClickVoiceKey)
self.bNpc = true
self.nNpcId = nNpcId
self.nNPCSkinId = nSkinId or 0
@@ -354,7 +354,11 @@ function PlayerVoiceData:PlayBoardNPCClickVoice(nNpcId, nSkinId)
table.insert(tbVoiceKey, "hfc_npc")
self:ResetBoardClickTimer()
else
table.insert(tbVoiceKey, "posterchat_npc")
local sKey = "posterchat_npc"
if sClickVoiceKey then
sKey = sClickVoiceKey
end
table.insert(tbVoiceKey, sKey)
end
self:PlayCharVoice(tbVoiceKey, curBoardCharId, self.nNPCSkinId, true)
end
@@ -0,0 +1,431 @@
local PlayerSoldierData = class("PlayerSoldierData")
local PlayerSoldierQuestData = require("GameCore.Data.DataClass.Soldier.PlayerSoldierQuestData")
local PlayerSoldierRecommendData = require("GameCore.Data.DataClass.Soldier.PlayerSoldierRecommendData")
function PlayerSoldierData:Init()
self.questData = PlayerSoldierQuestData.new()
self.recommendData = PlayerSoldierRecommendData.new()
self.questData:InitData()
self.recommendData:InitData()
self.nHighestChallengeId = 0
self.curChallengeData = {
nGradeChallengeId = 0,
nStage = 0,
nNodeIndex = 0
}
self.curLevel = nil
self:InitConfig()
end
function PlayerSoldierData:UnInit()
if self.curLevel ~= nil then
self.curLevel:Exit()
self.curLevel = nil
end
end
function PlayerSoldierData:InitConfig()
local func_ForEach_SoldierPartner = function(mapLine)
CacheTable.SetField("_SoldierPartner", mapLine.PartnerType, mapLine.Level, mapLine)
end
ForEachTableLine(ConfigTable.Get("SoldierPartner"), func_ForEach_SoldierPartner)
local func_ForEach_SoldierPositionEffect = function(mapLine)
CacheTable.SetField("_SoldierPositionEffect", mapLine.PositionType, mapLine.Index, mapLine)
end
ForEachTableLine(ConfigTable.Get("SoldierPositionEffect"), func_ForEach_SoldierPositionEffect)
local func_ForEach_SoldierPartnerGroup = function(mapLine)
CacheTable.SetData("_SoldierPartnerGroup", mapLine.PartnerType, mapLine)
end
ForEachTableLine(ConfigTable.Get("SoldierPartnerGroup"), func_ForEach_SoldierPartnerGroup)
local _mapSoldierNodePlan = {}
local func_ForEach_SoldierNodePlan = function(mapLine)
if _mapSoldierNodePlan[mapLine.NodeGroupId] == nil then
_mapSoldierNodePlan[mapLine.NodeGroupId] = {}
end
table.insert(_mapSoldierNodePlan[mapLine.NodeGroupId], mapLine)
end
ForEachTableLine(ConfigTable.Get("SoldierNodePlan"), func_ForEach_SoldierNodePlan)
for nGroupId, list in pairs(_mapSoldierNodePlan) do
table.sort(list, function(a, b)
return a.Index < b.Index
end)
CacheTable.SetData("_SoldierNodePlan", nGroupId, list)
end
local func_ForEach_SoldierChessType = function(mapLine)
CacheTable.SetData("_SoldierChessType", mapLine.ChessType, mapLine)
end
ForEachTableLine(ConfigTable.Get("SoldierChessType"), func_ForEach_SoldierChessType)
end
function PlayerSoldierData:GetCurLevelData()
return self.curLevel
end
function PlayerSoldierData:CheckInSoldierLevel()
return self:GetCurGradeChallengeId() ~= 0
end
function PlayerSoldierData:EnterSoldier(nSeasonId, nGradeChallengeId, callback)
if self:GetCurGradeChallengeId() == 0 then
self:SendApply(nSeasonId, nGradeChallengeId, callback)
else
self:SendInfo(callback)
end
end
function PlayerSoldierData:SoldierLevelEnd(bClear)
if self.curLevel ~= nil then
self.curLevel:Exit()
self.curLevel = nil
end
if bClear then
self:SetCurGradeChallengeData(0, 0, 0)
self:ClearInSoldierRecommendData()
end
end
function PlayerSoldierData:SendApply(nSeasonId, nGradeChallengeId, callback)
local netCallback = function(_, netMsg)
self:SetCurGradeChallengeData(nGradeChallengeId, 0, 0)
self:ClearInSoldierRecommendData()
if self.curLevel == nil then
self.curLevel = require("Game.Adventure.Soldier.SoldierLevelData").new()
end
self.curLevel:Init(self, netMsg.Info, netMsg.Chess, netMsg.CoinQty)
if callback ~= nil then
callback()
end
end
local sendMsg = {SeasonId = nSeasonId, GradeChallengeId = nGradeChallengeId}
HttpNetHandler.SendMsg(NetMsgId.Id.soldier_apply_req, sendMsg, nil, netCallback)
end
function PlayerSoldierData:SendInfo(callback)
local netCallback = function(_, netMsg)
if self.curLevel == nil then
self.curLevel = require("Game.Adventure.Soldier.SoldierLevelData").new()
end
self.curLevel:Init(self, netMsg)
if callback ~= nil then
callback()
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.soldier_info_req, {}, nil, netCallback)
end
function PlayerSoldierData:SendStepOut(tbMain, tbSup, tbWaiting, callback)
local tbDeploy = {}
tbDeploy.Master = {}
tbDeploy.Assist = {}
tbDeploy.Waiting = {}
for _, v in ipairs(tbMain) do
table.insert(tbDeploy.Master, {
Id = v.nId,
Qty = 1,
Star = v.nStar
})
end
for _, v in ipairs(tbSup) do
table.insert(tbDeploy.Assist, {
Id = v.nId,
Qty = 1,
Star = v.nStar
})
end
for _, v in ipairs(tbWaiting) do
table.insert(tbDeploy.Waiting, {
Id = v.nId,
Qty = 1,
Star = v.nStar
})
end
local netCallback = function(_, netMsg)
if self.curLevel ~= nil then
self.curLevel:StepOut()
end
if callback ~= nil then
callback()
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.soldier_step_out_req, {Deploy = tbDeploy}, nil, netCallback)
end
function PlayerSoldierData:SendGiveUp(callback)
local netCallback = function(_, netMsg)
self:SetCurGradeChallengeData(0, 0, 0)
self:ClearInSoldierRecommendData()
if self.curLevel ~= nil then
self.curLevel:GiveUp(netMsg)
else
local mapData = {
nTotalScore = netMsg.TotalScore,
nRewardScore = netMsg.RewardScore
}
EventManager.Hit(EventId.OpenPanel, PanelId.SoldierBattleResult, AllEnum.SoldierResultType.ChallengeFail, mapData)
end
if callback then
callback()
end
end
HttpNetHandler.SendMsg(NetMsgId.Id.soldier_give_up_req, {}, nil, netCallback)
end
function PlayerSoldierData:SetQuestDataList(questDataList)
if questDataList == nil then
return
end
self.questData:SetQuestDataList(questDataList)
end
function PlayerSoldierData:SetQuestData(questData)
if questData == nil then
return
end
self.questData:SetQuestData(questData)
end
function PlayerSoldierData:GetAllQuestData()
if self.questData == nil then
return {}
end
return self.questData:GetAllQuestData()
end
function PlayerSoldierData:GetQuestData()
if self.questData == nil then
return {}
end
return self.questData:GetAllQuestData()
end
function PlayerSoldierData:GetQuestDataByGroupId(nGroupId)
if self.questData == nil then
return {}
end
return self.questData:GetQuestDataListByGroupId(nGroupId)
end
function PlayerSoldierData:IsViewedGroupId(nGroupId)
if self.questData == nil then
return false
end
return self.questData:IsViewedGroupId(nGroupId)
end
function PlayerSoldierData:SetViewedGroupId(nGroupId)
if self.questData == nil then
return
end
self.questData:SetViewedGroupId(nGroupId)
end
function PlayerSoldierData:IsGroupLock(nGroupId)
if self.questData == nil then
return false
end
return self.questData:IsGroupLock(nGroupId)
end
function PlayerSoldierData:GetAllQuestCount()
if self.questData == nil then
return 0
end
return self.questData:GetAllQuestCount()
end
function PlayerSoldierData:GetAllReceivedCount()
if self.questData == nil then
return 0
end
return self.questData:GetAllReceivedCount()
end
function PlayerSoldierData:ReceiveQuestReward(nGroupId, nId, callback)
if self.questData == nil then
return
end
self.questData:ReceiveQuestReward(nGroupId, nId, callback)
end
function PlayerSoldierData:SetHighestChallengeId(nHighestChallengeId)
self.nHighestChallengeId = math.max(self.nHighestChallengeId, nHighestChallengeId)
end
function PlayerSoldierData:GetHighestChallengeId()
return self.nHighestChallengeId
end
function PlayerSoldierData:SetCurGradeChallengeData(nGradeChallengeId, nStage, nNodeIndex)
self.curChallengeData = {
nGradeChallengeId = nGradeChallengeId,
nStage = nStage,
nNodeIndex = nNodeIndex
}
end
function PlayerSoldierData:GetCurChallengeData()
return self.curChallengeData
end
function PlayerSoldierData:GetCurGradeChallengeId()
return self.curChallengeData.nGradeChallengeId
end
function PlayerSoldierData:CheckChallengeUnlocked(nGradeChallengeId)
local config = ConfigTable.GetData("SoldierGradeChallenge", nGradeChallengeId)
if config == nil then
return false
end
if config.UnlockGradeLevel == 0 then
return true
end
if self.nHighestChallengeId == 0 then
return false
end
local highestChallengeConfig = ConfigTable.GetData("SoldierGradeChallenge", self.nHighestChallengeId)
if highestChallengeConfig == nil then
return true
end
return config.UnlockGradeLevel <= highestChallengeConfig.Id
end
function PlayerSoldierData:SetRecommendData(nRecommendId, bInSoldier)
self.recommendData:SetRecommendData(nRecommendId, bInSoldier)
end
function PlayerSoldierData:GetRecommendData(bInSoldier)
return self.recommendData:GetRecommendData(bInSoldier)
end
function PlayerSoldierData:GetAllRecommendData()
return self.recommendData:GetAllRecommendData()
end
function PlayerSoldierData:GetSoldierPositionEffectDataId(nIndex)
return self.recommendData:GetSoldierPositionEffectDataId(nIndex)
end
function PlayerSoldierData:ClearInSoldierRecommendData()
self.recommendData:ClearInSoldierRecommendData()
end
function PlayerSoldierData:CheckChessRecommendState(nChessId)
return self.recommendData:CheckChessRecommendState(nChessId)
end
function PlayerSoldierData:CheckStarterCardRecommendState(nStarterCardId)
return self.recommendData:CheckStarterCardRecommendState(nStarterCardId)
end
function PlayerSoldierData:CheckStrategyCardRecommendState(nStrategyCardId)
return self.recommendData:CheckStrategyCardRecommendState(nStrategyCardId)
end
function PlayerSoldierData:CheckPartnerRecommendState(nPartnerType)
return self.recommendData:CheckPartnerRecommendState(nPartnerType)
end
function PlayerSoldierData:GetCurChallengeState()
if self.curChallengeData == nil then
return 0, 0
end
if self.curChallengeData.nGradeChallengeId == 0 then
return 0, 0
end
local curChallengeCfg = ConfigTable.GetData("SoldierGradeChallenge", self.curChallengeData.nGradeChallengeId)
if not curChallengeCfg then
return 0, 0
end
local tbAllNodeList = {}
local func_ForEach_SoldierNodePlan = function(mapLine)
if curChallengeCfg.NodeGroupId == mapLine.NodeGroupId then
table.insert(tbAllNodeList, mapLine)
end
end
ForEachTableLine(DataTable.SoldierNodePlan, func_ForEach_SoldierNodePlan)
table.sort(tbAllNodeList, function(a, b)
return a.Index < b.Index
end)
local nNodexIndex = self.curChallengeData.nNodeIndex
local nStage = self.curChallengeData.nStage
if nStage == 0 then
return 1, 1
end
for i = 1, #tbAllNodeList do
local nodeCfg = tbAllNodeList[i]
if nStage > nodeCfg.Stage then
nNodexIndex = nNodexIndex - 1
end
end
return nStage, nNodexIndex
end
function PlayerSoldierData:CheckGMSkipNodeRefreshAllowed()
if self.curLevel == nil then
printWarn("[Soldier] receive sd_soldier_info_notify, but curLevel is nil")
return false
end
if self.curLevel.curBattle ~= nil then
printWarn("[Soldier] sdSkipNode is ignored during soldier battle")
return false
end
if not PanelManager.CheckPanelOpen(PanelId.SoldierSandtable) then
printWarn("[Soldier] sdSkipNode is ignored outside soldier sandtable")
return false
end
local tbBlockPanels = {
PanelId.SoldierBattlePanel,
PanelId.SoldierBattleEventPanel,
PanelId.SoldierSelectPolicy,
PanelId.SoldierBattleResult
}
for _, nPanelId in ipairs(tbBlockPanels) do
if PanelManager.CheckPanelOpen(nPanelId) then
printWarn("[Soldier] sdSkipNode is ignored because soldier flow panel is open: " .. tostring(nPanelId))
return false
end
end
return true
end
function PlayerSoldierData:OnSoldierInfoNotify(mapSoldierInfo)
if mapSoldierInfo == nil or mapSoldierInfo.Meta == nil or mapSoldierInfo.Node == nil then
printWarn("[Soldier] receive invalid sd_soldier_info_notify")
return
end
if not self:CheckGMSkipNodeRefreshAllowed() then
return
end
EventManager.Hit(EventId.ClosePanel, PanelId.SoldierPartnerTips)
EventManager.Hit(EventId.ClosePanel, PanelId.SoldierCharCardTips)
EventManager.Hit(EventId.ClosePanel, PanelId.SoldierCharSkillDetail)
EventManager.Hit(EventId.ClosePanel, PanelId.SoldierCharPontentialDetailPanel)
EventManager.Hit(EventId.ClosePanel, PanelId.SoldierShopProbabilityPanel)
EventManager.Hit(EventId.ClosePanel, PanelId.SoldierSandtable)
self.curLevel:Exit()
self.curLevel = require("Game.Adventure.Soldier.SoldierLevelData").new()
self.curLevel:Init(self, mapSoldierInfo)
end
function PlayerSoldierData:OnBuffCardAddNotify(mapCardData)
if mapCardData == nil then
return
end
if self.curLevel == nil then
printWarn("[Soldier] receive buff card add notify, but curLevel is nil")
return
end
self.curLevel:UpdateCardList(mapCardData)
EventManager.Hit("SoldierBuffCardChange")
end
function PlayerSoldierData:OnItemChangeNotify(mapChangeInfo)
if mapChangeInfo == nil then
return
end
if self.curLevel == nil then
printWarn("[Soldier] receive item change notify, but curLevel is nil")
return
end
local tbChange = {}
self.curLevel:UpdateChangeInfo(mapChangeInfo, tbChange)
if tbChange.tbChessChangeStep ~= nil and #tbChange.tbChessChangeStep > 0 then
EventManager.Hit("SoldierGMRefresh", tbChange.tbChessChangeStep)
end
end
function PlayerSoldierData:OnSoldierEffectNotify(mapMsgData)
if mapMsgData == nil then
return
end
if self.curLevel == nil then
printWarn("[Soldier] receive soldier effect notify, but curLevel is nil")
return
end
self.curLevel:UpdateSoldierEffectNotify(mapMsgData)
end
function PlayerSoldierData:OnShopDataNotify(mapShopData)
if mapShopData == nil then
return
end
if self.curLevel == nil then
printWarn("[Soldier] receive shop data notify, but curLevel is nil")
return
end
self.curLevel:UpdateShopDataNotify(mapShopData)
end
function PlayerSoldierData:ApplyGMSoldierHp(nHp)
if nHp == nil then
return
end
if self.curLevel == nil then
printWarn("[Soldier] apply gm soldier hp, but curLevel is nil")
return
end
self.curLevel:UpdateGMSoldierHp(nHp)
end
function PlayerSoldierData:GMEnterSoldier(tbDeploy)
if self.curLevel == nil then
self.curLevel = require("Game.Adventure.Soldier.SoldierLevelData").new()
end
self.curLevel:Init(self)
self.curLevel:GMEnterBattle(tbDeploy)
end
return PlayerSoldierData
@@ -0,0 +1,161 @@
local PlayerSoldierQuestData = class("PlayerSoldierQuestData")
local ClientManager = CS.ClientManager.Instance
local LocalData = require("GameCore.Data.LocalData")
local RapidJson = require("rapidjson")
function PlayerSoldierQuestData:ctor()
end
function PlayerSoldierQuestData:InitData()
self.tbAllQuestData = {}
self.tbEnterQuestGroupId = nil
self:InitConfig()
end
function PlayerSoldierQuestData:InitConfig()
end
function PlayerSoldierQuestData:GetEnterQuestGroupId()
if self.tbEnterQuestGroupId ~= nil then
return self.tbEnterQuestGroupId
end
local sJson = LocalData.GetPlayerLocalData("SoldierQuestGroupId")
local tb = decodeJson(sJson)
if type(tb) == "table" then
self.tbEnterQuestGroupId = tb
end
return self.tbEnterQuestGroupId or {}
end
function PlayerSoldierQuestData:SetQuestDataList(questDataList)
for _, questData in ipairs(questDataList) do
self:SetQuestData(questData)
end
end
function PlayerSoldierQuestData:SetQuestData(questData)
local questConfig = ConfigTable.GetData("SoldierQuest", questData.Id)
if questConfig == nil then
return
end
if self:IsGroupLock(questConfig.Group) then
return
end
if self.tbAllQuestData[questConfig.Group] == nil then
self.tbAllQuestData[questConfig.Group] = {}
end
local nState = self:QuestStateServer2Client(questData.Status)
self.tbAllQuestData[questConfig.Group][questData.Id] = {
nId = questData.Id,
nStatus = nState,
Progress = questData.Progress
}
RedDotManager.SetValid(RedDotDefine.Solider_Quest, {
questConfig.Group,
questData.Id
}, nState == AllEnum.ActQuestStatus.Complete)
if not self:IsViewedGroupId(questConfig.Group) then
RedDotManager.SetValid(RedDotDefine.Solider_Quest_New_Group, questConfig.Group, true)
end
end
function PlayerSoldierQuestData:QuestStateServer2Client(nStatus)
if nStatus == 0 then
return AllEnum.ActQuestStatus.UnComplete
elseif nStatus == 1 then
return AllEnum.ActQuestStatus.Complete
else
return AllEnum.ActQuestStatus.Received
end
end
function PlayerSoldierQuestData:GetAllQuestData()
return self.tbAllQuestData
end
function PlayerSoldierQuestData:GetQuestData(nGroupId, nId)
return self.tbAllQuestData[nGroupId][nId]
end
function PlayerSoldierQuestData:GetQuestDataListByGroupId(nGroupId)
return self.tbAllQuestData[nGroupId]
end
function PlayerSoldierQuestData:IsViewedGroupId(nGroupId)
local tbEnterQuestGroupId = self:GetEnterQuestGroupId()
return table.indexof(tbEnterQuestGroupId, nGroupId) > 0
end
function PlayerSoldierQuestData:SetViewedGroupId(nGroupId)
local tbEnterQuestGroupId = self:GetEnterQuestGroupId()
if table.indexof(tbEnterQuestGroupId, nGroupId) > 0 then
return
else
table.insert(tbEnterQuestGroupId, nGroupId)
RedDotManager.SetValid(RedDotDefine.Solider_Quest_New_Group, nGroupId, false)
end
LocalData.SetPlayerLocalData("SoldierQuestGroupId", RapidJson.encode(tbEnterQuestGroupId))
end
function PlayerSoldierQuestData:IsGroupLock(nGroupId)
return self:GetGroupStartTime(nGroupId) > ClientManager.serverTimeStamp
end
function PlayerSoldierQuestData:GetGroupStartTime(nGroupId)
local groupConfig = ConfigTable.GetData("SoldierQuestGroup", nGroupId)
if groupConfig == nil then
return 0
end
if 0 >= groupConfig.OpenDay then
return 0
end
local actData = PlayerData.Activity:GetActivityDataByType(GameEnum.activityType.Soldier)
if actData == nil then
return 0
end
return groupConfig.OpenDay * 86400 + actData.nOpenTime
end
function PlayerSoldierQuestData:GetAllQuestCount()
local nCount = 0
for _, v in pairs(self.tbAllQuestData) do
for _, v2 in pairs(v) do
nCount = nCount + 1
end
end
return nCount
end
function PlayerSoldierQuestData:GetAllReceivedCount()
local nCount = 0
for _, v in pairs(self.tbAllQuestData) do
for _, v2 in pairs(v) do
if v2.nStatus == AllEnum.ActQuestStatus.Received then
nCount = nCount + 1
end
end
end
return nCount
end
function PlayerSoldierQuestData:ReceiveQuestReward(nGroupId, nId, callback)
local msgCallback = function(_, msgData)
local mapDecodedChangeInfo = UTILS.DecodeChangeInfo(msgData)
HttpNetHandler.ProcChangeInfo(mapDecodedChangeInfo)
UTILS.OpenReceiveByChangeInfo(msgData)
if nId ~= 0 then
self.tbAllQuestData[nGroupId][nId].nStatus = AllEnum.ActQuestStatus.Received
self.tbAllQuestData[nGroupId][nId].Progress[1].Cur = 0
self.tbAllQuestData[nGroupId][nId].Progress[1].Max = 0
RedDotManager.SetValid(RedDotDefine.Solider_Quest, {nGroupId, nId}, false)
else
for _, v in pairs(self.tbAllQuestData[nGroupId]) do
if v.nStatus == AllEnum.ActQuestStatus.Complete then
v.nStatus = AllEnum.ActQuestStatus.Received
v.Progress[1].Cur = 0
v.Progress[1].Max = 0
RedDotManager.SetValid(RedDotDefine.Solider_Quest, {
nGroupId,
v.nId
}, false)
end
end
end
if callback ~= nil then
callback()
end
end
local actData = PlayerData.Activity:GetActivityDataByType(GameEnum.activityType.Soldier)
if actData == nil then
return
end
HttpNetHandler.SendMsg(NetMsgId.Id.activity_soldier_quest_reward_receive_req, {
ActivityId = actData.nActId,
GroupId = nGroupId,
QuestId = nId
}, nil, msgCallback)
end
return PlayerSoldierQuestData
@@ -0,0 +1,230 @@
local PlayerSoldierRecommendData = class("PlayerSoldierRecommendData")
local ClientManager = CS.ClientManager.Instance
local LocalData = require("GameCore.Data.LocalData")
local SoldierAttrData = require("GameCore.Data.DataClass.Soldier.SoldierAttrData")
function PlayerSoldierRecommendData:ctor()
end
function PlayerSoldierRecommendData:InitData()
self.nRecommendId = nil
self.nInSoldierRecommendId = nil
self.bInSoldierChanged = nil
self.tbAllRecommendData = {}
self:InitConfig()
self.tbSoldierPositionEffectData = {}
local func_ForEach_SoldierPositionEffect = function(mapLineData)
if mapLineData.PositionType == GameEnum.SoldierPositionType.FightPosition then
self.tbSoldierPositionEffectData[mapLineData.Index] = mapLineData.Id
end
end
ForEachTableLine(DataTable.SoldierPositionEffect, func_ForEach_SoldierPositionEffect)
end
function PlayerSoldierRecommendData:InitConfig()
local func_ForEach_Recommend = function(mapLineData)
local RecommendData = {
nRecommendId = mapLineData.Id,
nCharId = mapLineData.CharacterId,
charList = {},
nStarterCardId = mapLineData.StarterCard,
tbStrategyCardId = mapLineData.StrategyCard,
tbPartner = {}
}
for i = 1, 3 do
local charData = mapLineData["Front" .. i]
if charData ~= nil then
table.insert(RecommendData.charList, {
nId = charData[1],
nStar = charData[2],
nPositionType = 1,
nPosIndex = charData[4]
})
end
end
local backCharJson = mapLineData.Back
local tbBackCharList = {}
if backCharJson ~= nil then
local tbBackChar = decodeJson(backCharJson)
if type(tbBackChar) == "table" then
for charId, star in pairs(tbBackChar) do
table.insert(tbBackCharList, {
nId = tonumber(charId),
nStar = tonumber(star),
nPositionType = 2,
nPosIndex = 0
})
end
end
end
table.sort(tbBackCharList, function(a, b)
local aConfig = ConfigTable.GetData("SoldierCharacter", a.nId)
local bConfig = ConfigTable.GetData("SoldierCharacter", b.nId)
if aConfig.Rarity ~= bConfig.Rarity then
return aConfig.Rarity > bConfig.Rarity
end
return a.nId < b.nId
end)
for _, charData in ipairs(tbBackCharList) do
table.insert(RecommendData.charList, charData)
end
local tbPartnerAdd = decodeJson(mapLineData.PartnerAdd)
local mapExtraPartner = {}
for k, v in pairs(tbPartnerAdd) do
mapExtraPartner[tonumber(k)] = tonumber(v)
end
local tbExPartner = {}
for partnerId, addLevel in pairs(mapExtraPartner) do
local partnerCfg = ConfigTable.GetData("SoldierPartner", partnerId)
if partnerCfg then
tbExPartner[partnerCfg.PartnerType] = addLevel
end
end
local _, tbUIData = SoldierAttrData.CalcActivePartners(RecommendData.charList, tbExPartner)
RecommendData.tbPartner = tbUIData
self.tbAllRecommendData[mapLineData.Id] = RecommendData
end
ForEachTableLine(DataTable.SoldierRecommendBuilds, func_ForEach_Recommend)
end
function PlayerSoldierRecommendData:SetRecommendData(nRecommendId, bInSoldier)
if bInSoldier then
self.nInSoldierRecommendId = nRecommendId
self.bInSoldierChanged = true
else
self.nRecommendId = nRecommendId
end
EventManager.Hit("SoldierRecommend_Update")
self:SaveData()
end
function PlayerSoldierRecommendData:GetRecommendData(bInSoldier)
local nRecommendId = self:GetRecommendId()
local nInSoldierRecommendId = self:GetInSoldierRecommendId()
if bInSoldier then
if self:GetInSoldierChanged() then
if nInSoldierRecommendId == 0 then
return nil
end
return self.tbAllRecommendData[nInSoldierRecommendId]
else
if nRecommendId == 0 then
return nil
end
return self.tbAllRecommendData[nRecommendId]
end
else
if nRecommendId == 0 then
return nil
end
return self.tbAllRecommendData[nRecommendId]
end
end
function PlayerSoldierRecommendData:SaveData()
LocalData.SetPlayerLocalData("SoldierRecommend_Id", tostring(self.nRecommendId))
LocalData.SetPlayerLocalData("SoldierInSoldierRecommend_Id", tostring(self.nInSoldierRecommendId))
LocalData.SetPlayerLocalData("SoldierInSoldierChanged", self.bInSoldierChanged)
end
function PlayerSoldierRecommendData:GetSoldierPositionEffectDataId(nIndex)
return self.tbSoldierPositionEffectData[nIndex]
end
function PlayerSoldierRecommendData:GetAllRecommendData()
return self.tbAllRecommendData
end
function PlayerSoldierRecommendData:ClearInSoldierRecommendData()
self.nInSoldierRecommendId = 0
self.bInSoldierChanged = false
self:SaveData()
end
function PlayerSoldierRecommendData:CheckChessRecommendState(nChessId)
local nRecommendId = 0
if self:GetInSoldierRecommendId() == 0 then
nRecommendId = self:GetRecommendId()
else
nRecommendId = self:GetInSoldierRecommendId()
end
local recommendData = self.tbAllRecommendData[nRecommendId]
if recommendData == nil then
return false
end
for _, charData in ipairs(recommendData.charList) do
if charData.nId == nChessId then
return true
end
end
return false
end
function PlayerSoldierRecommendData:CheckStarterCardRecommendState(nStarterCardId)
local nRecommendId = 0
if self:GetInSoldierRecommendId() == 0 then
nRecommendId = self:GetRecommendId()
else
nRecommendId = self:GetInSoldierRecommendId()
end
local recommendData = self.tbAllRecommendData[nRecommendId]
if recommendData == nil then
return false
end
if recommendData.nStarterCardId == nStarterCardId then
return true
end
return false
end
function PlayerSoldierRecommendData:CheckStrategyCardRecommendState(nStrategyCardId)
local nRecommendId = 0
if self:GetInSoldierRecommendId() == 0 then
nRecommendId = self:GetRecommendId()
else
nRecommendId = self:GetInSoldierRecommendId()
end
local recommendData = self.tbAllRecommendData[nRecommendId]
if recommendData == nil then
return false
end
for _, strategyCardId in ipairs(recommendData.tbStrategyCardId) do
if strategyCardId == nStrategyCardId then
return true
end
end
return false
end
function PlayerSoldierRecommendData:CheckPartnerRecommendState(nPartnerType)
local nRecommendId = 0
if self:GetInSoldierRecommendId() == 0 then
nRecommendId = self:GetRecommendId()
else
nRecommendId = self:GetInSoldierRecommendId()
end
local recommendData = self.tbAllRecommendData[nRecommendId]
if recommendData == nil then
return false
end
if recommendData.tbPartner == nil then
return false
end
for _, partnerData in ipairs(recommendData.tbPartner) do
if partnerData.nType == nPartnerType then
return true
end
end
return false
end
function PlayerSoldierRecommendData:GetRecommendId()
if self.nRecommendId == nil then
local sJson = LocalData.GetPlayerLocalData("SoldierRecommend_Id") or "0"
local nRecommendId = tonumber(decodeJson(sJson)) or 0
self.nRecommendId = nRecommendId
end
return self.nRecommendId
end
function PlayerSoldierRecommendData:GetInSoldierRecommendId()
if self.nInSoldierRecommendId == nil then
local sJson = LocalData.GetPlayerLocalData("SoldierInSoldierRecommend_Id") or "0"
local nInSoldierRecommendId = tonumber(decodeJson(sJson)) or 0
self.nInSoldierRecommendId = nInSoldierRecommendId
end
return self.nInSoldierRecommendId
end
function PlayerSoldierRecommendData:GetInSoldierChanged()
if self.bInSoldierChanged == nil then
local sJson = LocalData.GetPlayerLocalData("SoldierInSoldierChanged")
self.bInSoldierChanged = sJson == true
end
return self.bInSoldierChanged
end
return PlayerSoldierRecommendData
@@ -0,0 +1,846 @@
local ConfigData = require("GameCore.Data.ConfigData")
local SoldierAttrData = {}
local SoldierAttachAttr = {
{
sKey = "Hp",
sLanguageId = "Attr_Hp_Simple"
},
{
sKey = "Atk",
sLanguageId = "Attr_Atk_Simple"
},
{
sKey = "Def",
sLanguageId = "Attr_Def_Simple"
},
{
sKey = "CritRate",
bPercent = true,
bIntFloat = true
},
{
sKey = "CritResistance",
bPercent = true
},
{
sKey = "CritPower",
bPercent = true,
bIntFloat = true
},
{sKey = "HitRate", bPercent = true},
{sKey = "Evd", bPercent = true},
{sKey = "DefPierce"},
{
sKey = "DefIgnore",
bPercent = true,
bIntFloat = true
},
{
sKey = "Suppress",
bPercent = true,
bIntFloat = true
},
{sKey = "Energy", bSoldier = true},
{
sKey = "InitialEnergy",
bSoldier = true
},
{sKey = "Recovery", bSoldier = true},
{
sKey = "ATKSPD_P",
bSoldier = true,
bPercent = true,
bIntFloat = true
}
}
local _showAttrKey = {
Hp = 1,
Energy = 2,
InitialEnergy = 3,
Atk = 4,
Def = 5,
Recovery = 6,
CritRate = 7,
CritPower = 8,
ATKSPD_P = 9
}
local _InitAttrMapSlots = function(map)
for _, v in pairs(SoldierAttachAttr) do
map[v.sKey] = 0
map["_" .. v.sKey] = 0
map["_" .. v.sKey .. "PercentAmend"] = 0
map["_" .. v.sKey .. "Amend"] = 0
end
end
local _ReadBaseFromConfig = function(map, nId, nStar)
local cfgChess = ConfigTable.GetData("SoldierCharacter", nId)
if cfgChess == nil then
printError("SoldierAttrData: SoldierCharacter not found, nId=" .. tostring(nId))
return nil, nil
end
local cfgAdjust = ConfigTable.GetData("MonsterValueTempleteAdjust", cfgChess.Templete)
if cfgAdjust == nil then
printError("SoldierAttrData: MonsterValueTempleteAdjust not found, Templete=" .. tostring(cfgChess.Templete))
return cfgChess, nil
end
local nTmplAttrId = UTILS.GetSoldierTempleteAttrId(cfgAdjust.TemplateId, nStar)
local cfgTmpl = ConfigTable.GetData("MonsterValueTemplete", nTmplAttrId)
if cfgTmpl == nil then
printError("SoldierAttrData: MonsterValueTemplete not found, id=" .. tostring(nTmplAttrId))
return cfgChess, cfgAdjust
end
for _, v in ipairs(SoldierAttachAttr) do
local mapCfg
if v.bSoldier == true then
mapCfg = cfgChess
else
mapCfg = cfgTmpl
end
map["_" .. v.sKey] = mapCfg and mapCfg[v.sKey] or 0
local nRatio, nFix = 0, 0
if cfgAdjust[v.sKey .. "Ratio"] ~= nil then
nRatio = cfgAdjust[v.sKey .. "Ratio"]
end
if cfgAdjust[v.sKey .. "Fix"] ~= nil then
nFix = cfgAdjust[v.sKey .. "Fix"]
end
map["_" .. v.sKey] = map["_" .. v.sKey] * (1 + nRatio * ConfigData.IntFloatPrecision) + nFix
end
end
local _Finalize = function(map)
for _, v in pairs(SoldierAttachAttr) do
map[v.sKey] = map["_" .. v.sKey] * (1 + map["_" .. v.sKey .. "PercentAmend"] / 100) + map["_" .. v.sKey .. "Amend"]
map[v.sKey] = math.floor(map[v.sKey])
end
end
local _FillAttrForUI = function(map)
local attrSortList = {}
local attrList = {}
for _, v in ipairs(SoldierAttachAttr) do
if _showAttrKey[v.sKey] ~= nil then
local nValue = map[v.sKey] or 0
nValue = v.bIntFloat and nValue * ConfigData.IntFloatPrecision or nValue
table.insert(attrSortList, {
sKey = v.sKey,
nValue = nValue,
sLanguageId = v.sLanguageId,
nIndex = _showAttrKey[v.sKey]
})
attrList[v.sKey] = {
nValue = nValue,
sLanguageId = v.sLanguageId
}
end
end
table.sort(attrSortList, function(a, b)
return a.nIndex < b.nIndex
end)
return attrSortList, attrList
end
local _FillAttrForBattle = function(map)
local stSoldier = CS.SoldierLevelController.SoldierAttr()
stSoldier.Energy = map.Energy
stSoldier.InitialEnergy = map.InitialEnergy
stSoldier.Recovery = map.Recovery
stSoldier.ATKSPD_P = map.ATKSPD_P
stSoldier.Hp = map.Hp
stSoldier.HpMax = map.HpMax or map.Hp
stSoldier.Atk = map.Atk
stSoldier.Def = map.Def
stSoldier.CritRate = map.CritRate
stSoldier.CritResistance = map.CritResistance
stSoldier.CritPower = map.CritPower
stSoldier.HitRate = map.HitRate
stSoldier.Evd = map.Evd
stSoldier.DefPierce = map.DefPierce
stSoldier.DefIgnore = map.DefIgnore
stSoldier.Suppress = map.Suppress
return stSoldier
end
local _BuildAttrMap = function(nId, nStar)
local map = {}
map.DataId = nId
_InitAttrMapSlots(map)
_ReadBaseFromConfig(map, nId, nStar)
return map
end
local _BuildBuffCtx = function(tbDeployed, tbActivePartner)
local ctx = {
tbDeployed = tbDeployed or {},
tbActivePartner = {},
nDeployedCount = 0,
nActivePartnerCount = 0,
tbPartnerTagAdd = {}
}
ctx.nDeployedCount = #ctx.tbDeployed
if tbActivePartner then
for _, nId in pairs(tbActivePartner) do
local mapPartnerCfg = ConfigTable.GetData("SoldierPartner", nId)
if mapPartnerCfg ~= nil then
local nType = mapPartnerCfg.PartnerType
local nLevel = mapPartnerCfg.Level
if nType and 0 < nType then
ctx.tbActivePartner[nType] = {
nLevel = nLevel or 1
}
ctx.nActivePartnerCount = ctx.nActivePartnerCount + 1
end
end
end
end
return ctx
end
local _GetTopXByBaseAttr = function(ctx, sAttrKey, nTopX, tbCandidates)
local tbResult, tbSorted = {}, {}
local _collect = function(idx, chess)
local nTempFinalValue = 0
if chess.mapAttr then
nTempFinalValue = chess.mapAttr["_" .. sAttrKey] * (1 + chess.mapAttr["_" .. sAttrKey .. "PercentAmend"] / 100) + chess.mapAttr["_" .. sAttrKey .. "Amend"]
end
table.insert(tbSorted, {nIdx = idx, nValue = nTempFinalValue})
end
if tbCandidates then
for idx in pairs(tbCandidates) do
local chess = ctx.tbDeployed[idx]
if chess then
_collect(idx, chess)
end
end
else
for idx, chess in ipairs(ctx.tbDeployed) do
_collect(idx, chess)
end
end
table.sort(tbSorted, function(a, b)
return a.nValue > b.nValue
end)
for i = 1, math.min(nTopX, #tbSorted) do
tbResult[tbSorted[i].nIdx] = true
end
return tbResult
end
local _tbCondDescriptors = {}
local _RegisterCondition = function(eCondType, descriptor)
_tbCondDescriptors[eCondType] = descriptor
end
local _FilterChessByConditions = function(ctx, tbInputSet, tbConds)
local tbCurrent = {}
if tbInputSet then
for idx in pairs(tbInputSet) do
tbCurrent[idx] = true
end
end
for _, cond in ipairs(tbConds or {}) do
local d = _tbCondDescriptors[cond.eType]
if d and d.fnFilter then
tbCurrent = d.fnFilter(ctx, tbCurrent, cond.tbParam) or {}
end
end
return tbCurrent
end
local _tbEffectDescriptors = {}
local _RegisterEffect = function(eEffectType, descriptor)
_tbEffectDescriptors[eEffectType] = descriptor
end
local _ApplyOneClientEffect = function(ctx, chess, idxChess, eEffectType, tbParam)
local d = _tbEffectDescriptors[eEffectType]
if d and d.fnApply then
d.fnApply(ctx, chess, idxChess, tbParam)
end
end
local _tbTargetDescriptors = {}
local _RegisterTarget = function(eTargetType, descriptor)
_tbTargetDescriptors[eTargetType] = descriptor
end
local _SelectTargets = function(ctx, eTargetType, tbCandidates, tbParam)
local d = _tbTargetDescriptors[eTargetType] or _tbTargetDescriptors[GameEnum.SoldierClientEffectTarget.None]
if not d or not d.fnSelect then
return tbCandidates
end
return d.fnSelect(ctx, tbCandidates, tbParam) or {}
end
local _CondFilter_None = function(ctx, tbCurrent, tbParam)
return tbCurrent
end
local _CondFilter_Partner = function(ctx, tbCurrent, tbParam)
local nTarget = tbParam and tonumber(tbParam[1]) or 0
if nTarget == 0 then
return {}
end
local tbResult = {}
for idx in pairs(tbCurrent) do
local chess = ctx.tbDeployed[idx]
if chess and chess.tbPartnerType and 0 < table.indexof(chess.tbPartnerType, nTarget) then
tbResult[idx] = true
end
end
return tbResult
end
local _CondFilter_PositionType = function(ctx, tbCurrent, tbParam)
local nPos = tbParam and tonumber(tbParam[1])
local tbResult = {}
for idx in pairs(tbCurrent) do
local chess = ctx.tbDeployed[idx]
if chess and chess.nPositionType == nPos then
tbResult[idx] = true
end
end
return tbResult
end
local _CondFilter_SoldierCount = function(ctx, tbCurrent, tbParam)
local nRequired = tbParam and tonumber(tbParam[1]) or 0
local nCount = 0
for _ in pairs(tbCurrent) do
nCount = nCount + 1
end
if nCount == nRequired then
return tbCurrent
end
return {}
end
local _CondFilter_SoldierLevel = function(ctx, tbCurrent, tbParam)
local nMinLevel = tbParam and tonumber(tbParam[1]) or 0
local tbResult = {}
for idx in pairs(tbCurrent) do
local chess = ctx.tbDeployed[idx]
if chess and nMinLevel <= (chess.nStar or 0) then
tbResult[idx] = true
end
end
return tbResult
end
local _CondFilter_SoldierAttr = function(ctx, tbCurrent, tbParam)
if not tbParam or #tbParam ~= 2 then
return {}
end
local nTopX = tonumber(tbParam[1])
local sKey = tbParam[2]
if not sKey or nTopX <= 0 then
return {}
end
return _GetTopXByBaseAttr(ctx, sKey, nTopX, tbCurrent)
end
local _CondFilter_SoldierId = function(ctx, tbCurrent, tbParam)
local nId = tbParam and tonumber(tbParam[1])
local tbResult = {}
for idx in pairs(tbCurrent) do
local chess = ctx.tbDeployed[idx]
if chess and chess.nId == nId then
tbResult[idx] = true
end
end
return tbResult
end
local _CondFilter_PartnerCount = function(ctx, tbCurrent, tbParam)
local nRequired = tbParam and tonumber(tbParam[1]) or 0
if ctx.nActivePartnerCount == nRequired then
return tbCurrent
end
return {}
end
_RegisterCondition(GameEnum.SoldierClientCond.None, {fnFilter = _CondFilter_None})
_RegisterCondition(GameEnum.SoldierClientCond.Partner, {fnFilter = _CondFilter_Partner})
_RegisterCondition(GameEnum.SoldierClientCond.PositionType, {fnFilter = _CondFilter_PositionType})
_RegisterCondition(GameEnum.SoldierClientCond.SoldierCount, {fnFilter = _CondFilter_SoldierCount})
_RegisterCondition(GameEnum.SoldierClientCond.SoldierLevel, {fnFilter = _CondFilter_SoldierLevel})
_RegisterCondition(GameEnum.SoldierClientCond.SoldierAttr, {fnFilter = _CondFilter_SoldierAttr})
_RegisterCondition(GameEnum.SoldierClientCond.SoldierId, {fnFilter = _CondFilter_SoldierId})
_RegisterCondition(GameEnum.SoldierClientCond.PartnerCount, {fnFilter = _CondFilter_PartnerCount})
local _ApplyAmendToChess = function(chess, sKey, nValue)
if not (chess and chess.mapAttr) or not sKey then
return
end
local sAmendKey = "_" .. sKey .. "Amend"
if chess.mapAttr[sAmendKey] == nil then
return
end
chess.mapAttr[sAmendKey] = chess.mapAttr[sAmendKey] + (nValue or 0)
end
local _ApplyPercentAmendToChess = function(chess, sKey, nValue)
if not (chess and chess.mapAttr) or not sKey then
return
end
local sPctKey = "_" .. sKey .. "PercentAmend"
if chess.mapAttr[sPctKey] == nil then
return
end
chess.mapAttr[sPctKey] = chess.mapAttr[sPctKey] + (nValue or 0)
end
local _EffectApply_None = function()
end
local _EffectApply_AmendAttr = function(ctx, chess, idxChess, tbParam)
if not tbParam or #tbParam ~= 2 then
return
end
_ApplyAmendToChess(chess, tbParam[1], tonumber(tbParam[2]) or 0)
end
local _EffectApply_PercentAmendAttr = function(ctx, chess, idxChess, tbParam)
if not tbParam or #tbParam ~= 2 then
return
end
_ApplyPercentAmendToChess(chess, tbParam[1], tonumber(tbParam[2]) or 0)
end
local _EffectApply_PartnerTag = function(ctx, chess, idxChess, tbParam)
local nType = tbParam and tbParam[1]
if not nType or nType == 0 then
return
end
ctx.tbPartnerTagAdd[idxChess] = ctx.tbPartnerTagAdd[idxChess] or {}
table.insert(ctx.tbPartnerTagAdd[idxChess], nType)
end
local _EffectApply_BattleAttrHalve = function(ctx, chess, idxChess, tbParam)
local sKey = tbParam and tbParam[1]
if not sKey then
return
end
ctx.tbBattleAttrHalve = ctx.tbBattleAttrHalve or {}
ctx.tbBattleAttrHalve[idxChess] = ctx.tbBattleAttrHalve[idxChess] or {}
table.insert(ctx.tbBattleAttrHalve[idxChess], sKey)
end
_RegisterEffect(GameEnum.SoldierClientEffect.None, {fnApply = _EffectApply_None})
_RegisterEffect(GameEnum.SoldierClientEffect.AmendAttr, {fnApply = _EffectApply_AmendAttr})
_RegisterEffect(GameEnum.SoldierClientEffect.PercentAmendAttr, {fnApply = _EffectApply_PercentAmendAttr})
_RegisterEffect(GameEnum.SoldierClientEffect.PartnerTag, {fnApply = _EffectApply_PartnerTag})
_RegisterEffect(GameEnum.SoldierClientEffect.BattleAttrHalve, {fnApply = _EffectApply_BattleAttrHalve})
local _TargetSelect_None = function(ctx, tbCandidates, tbParam)
return tbCandidates
end
local _TargetSelect_All = function(ctx, tbCandidates, tbParam)
if not tbCandidates or next(tbCandidates) == nil then
return {}
end
local tbResult = {}
for idx = 1, #ctx.tbDeployed do
tbResult[idx] = true
end
return tbResult
end
local _TargetSelect_Partner = function(ctx, tbCandidates, tbParam)
local nType = tbParam and tonumber(tbParam[1]) or 0
if nType == 0 then
return {}
end
local tbResult = {}
for idx, _ in pairs(tbCandidates) do
local chess = ctx.tbDeployed[idx]
if chess and chess.tbPartnerType and 0 < table.indexof(chess.tbPartnerType, nType) then
tbResult[idx] = true
end
end
return tbResult
end
local _TargetSelect_SoldierId = function(ctx, tbCandidates, tbParam)
local nId = tbParam and tonumber(tbParam[1]) or 0
if nId == 0 then
return {}
end
local tbResult = {}
for idx, _ in pairs(tbCandidates) do
local chess = ctx.tbDeployed[idx]
if chess and chess.nId == nId then
tbResult[idx] = true
end
end
return tbResult
end
_RegisterTarget(GameEnum.SoldierClientEffectTarget.None, {fnSelect = _TargetSelect_None})
_RegisterTarget(GameEnum.SoldierClientEffectTarget.All, {fnSelect = _TargetSelect_All})
_RegisterTarget(GameEnum.SoldierClientEffectTarget.Partner, {fnSelect = _TargetSelect_Partner})
_RegisterTarget(GameEnum.SoldierClientEffectTarget.SoldierId, {fnSelect = _TargetSelect_SoldierId})
local _ParseBuffConfig = function(cfgBuff)
if not cfgBuff then
return nil
end
local tbConds, tbEffects = {}, {}
for i = 1, 3 do
local eType = cfgBuff["Cond" .. i]
if eType and eType ~= 0 then
table.insert(tbConds, {
eType = eType,
tbParam = cfgBuff["CondParams" .. i] or {}
})
end
end
for i = 1, 3 do
local eType = cfgBuff["Effect" .. i]
if eType and eType ~= 0 then
table.insert(tbEffects, {
eType = eType,
tbParam = cfgBuff["EffectParams" .. i] or {}
})
end
end
local eTargetType = cfgBuff.TargetType or GameEnum.SoldierClientEffectTarget.None
local tbTargetParam = cfgBuff.TargetParam or {}
return {
tbConds = tbConds,
tbEffects = tbEffects,
eTargetType = eTargetType,
tbTargetParam = tbTargetParam
}
end
local _AddBuffIdToChess = function(chess, nBuffId)
chess.tbClientBuffIds = chess.tbClientBuffIds or {}
table.insert(chess.tbClientBuffIds, nBuffId)
end
local _DispatchBuff = function(ctx, nBuffId, buff, tbCandidates)
if not (buff and tbCandidates) or next(tbCandidates) == nil then
return
end
local tbTargets = _SelectTargets(ctx, buff.eTargetType, tbCandidates, buff.tbTargetParam)
if not tbTargets then
return
end
for idx, _ in pairs(tbTargets) do
local chess = ctx.tbDeployed[idx]
if chess then
_AddBuffIdToChess(chess, nBuffId)
end
end
end
local _AddPositionBuffs = function(ctx)
for idx, chess in ipairs(ctx.tbDeployed) do
if chess.nPositionType and chess.nIndex then
local tbPosEffect = CacheTable.GetData("_SoldierPositionEffect", chess.nPositionType)
local mapLine = tbPosEffect and tbPosEffect[chess.nIndex]
local nBuffId = mapLine and mapLine.KeyEffectId or 0
if nBuffId ~= 0 then
local buff = _ParseBuffConfig(ConfigTable.GetData("SoldierClientBuff", nBuffId))
if buff then
local tbInputSet = {
[idx] = true
}
local tbCandidates = _FilterChessByConditions(ctx, tbInputSet, buff.tbConds)
_DispatchBuff(ctx, nBuffId, buff, tbCandidates)
end
end
end
end
end
local _AddPartnerBuffs = function(ctx)
local tbItems = {}
for nType, info in pairs(ctx.tbActivePartner) do
local mapByLevel = CacheTable.GetData("_SoldierPartner", nType)
local cfgActive = mapByLevel and mapByLevel[info.nLevel or 1]
if cfgActive then
for _, nEffId in ipairs(cfgActive.ClientEffect) do
if nEffId and nEffId ~= 0 then
table.insert(tbItems, {
nId = nEffId,
nOrder = cfgActive.Order or 0
})
end
end
end
end
table.sort(tbItems, function(a, b)
return a.nOrder < b.nOrder
end)
local tbInputSet = {}
for i = 1, #ctx.tbDeployed do
tbInputSet[i] = true
end
for _, item in ipairs(tbItems) do
local buff = _ParseBuffConfig(ConfigTable.GetData("SoldierClientBuff", item.nId))
if buff then
local tbCandidates = _FilterChessByConditions(ctx, tbInputSet, buff.tbConds)
_DispatchBuff(ctx, item.nId, buff, tbCandidates)
end
end
end
local _ApplyAllBuffEffects = function(ctx)
for idx, chess in ipairs(ctx.tbDeployed) do
if chess.tbClientBuffIds then
for _, nBuffId in ipairs(chess.tbClientBuffIds) do
local buff = _ParseBuffConfig(ConfigTable.GetData("SoldierClientBuff", nBuffId))
if buff then
for _, eff in ipairs(buff.tbEffects) do
_ApplyOneClientEffect(ctx, chess, idx, eff.eType, eff.tbParam)
end
end
end
end
end
end
local _FinalizeAll = function(ctx)
for _, chess in ipairs(ctx.tbDeployed) do
if chess.mapAttr then
_Finalize(chess.mapAttr)
end
end
end
local _ApplyBattleAttrHalve = function(ctx)
if not ctx.tbBattleAttrHalve then
return
end
for idx, tbKeys in pairs(ctx.tbBattleAttrHalve) do
local chess = ctx.tbDeployed[idx]
if chess and chess.mapAttr then
for _, sKey in ipairs(tbKeys) do
if chess.mapAttr[sKey] ~= nil then
chess.mapAttr[sKey] = math.floor(chess.mapAttr[sKey] * 0.5)
end
end
end
end
end
local _AddServerBuffs = function(ctx, tbServerBuff)
if not tbServerBuff then
return
end
local tbInputSet = {}
for i = 1, #ctx.tbDeployed do
tbInputSet[i] = true
end
for _, nBuffId in ipairs(tbServerBuff) do
local buff = _ParseBuffConfig(ConfigTable.GetData("SoldierClientBuff", nBuffId))
if buff then
local tbCandidates = _FilterChessByConditions(ctx, tbInputSet, buff.tbConds)
_DispatchBuff(ctx, nBuffId, buff, tbCandidates)
end
end
end
local _CalcAllDeployedAttrs = function(tbCharacter, tbActivePartner, tbServerBuff, bIsForBattle)
if not tbCharacter then
return nil, nil
end
local tbDeployed = {}
for _, chess in ipairs(tbCharacter) do
if chess.nId and chess.nId ~= 0 then
table.insert(tbDeployed, chess)
end
end
for _, chess in ipairs(tbDeployed) do
chess.mapAttr = _BuildAttrMap(chess.nId, chess.nStar)
if chess.tbPartnerType == nil then
chess.tbPartnerType = SoldierAttrData.GetPartnerGroupsByChessId(chess.nId)
end
end
local ctx = _BuildBuffCtx(tbDeployed, tbActivePartner)
_AddPositionBuffs(ctx)
_AddServerBuffs(ctx, tbServerBuff)
_AddPartnerBuffs(ctx)
_ApplyAllBuffEffects(ctx)
_FinalizeAll(ctx)
if bIsForBattle then
for _, chess in ipairs(tbDeployed) do
if chess.mapAttr then
chess.mapAttr.HpMax = chess.mapAttr.Hp
end
end
_ApplyBattleAttrHalve(ctx)
end
return ctx, tbDeployed
end
local _FindChessAttr = function(tbDeployed, nId, nStar)
if not tbDeployed then
return nil
end
for _, chess in ipairs(tbDeployed) do
if chess.nId == nId and (nStar == nil or chess.nStar == nStar) then
return chess.mapAttr
end
end
return nil
end
function SoldierAttrData.CalcCharacterAttr(nId, nStar, tbCharacter, tbPartner, tbServerBuff)
if tbCharacter then
local _, tbDeployed = _CalcAllDeployedAttrs(clone(tbCharacter), tbPartner, tbServerBuff)
local map = _FindChessAttr(tbDeployed, nId, nStar)
if map then
_Finalize(map)
return _FillAttrForUI(map)
end
end
local map = _BuildAttrMap(nId, nStar)
if not map then
return nil
end
_Finalize(map)
return _FillAttrForUI(map)
end
function SoldierAttrData.CalcExtraPartnerTags(tbCharacter, tbPartner, tbServerBuff)
local mapResult = {}
if not tbCharacter then
return mapResult
end
local ctx, tbDeployed = _CalcAllDeployedAttrs(clone(tbCharacter), tbPartner, tbServerBuff)
if not ctx or not tbDeployed then
return mapResult
end
for idx, tbTypes in pairs(ctx.tbPartnerTagAdd or {}) do
local chess = tbDeployed[idx]
if chess and chess.nId and chess.nId ~= 0 and tbTypes and 0 < #tbTypes then
mapResult[chess.nId] = {
tbTypes = tbTypes,
nPositionType = chess.nPositionType,
nIndex = chess.nIndex
}
end
end
return mapResult
end
function SoldierAttrData.CalcAttrForBattle(tbCharacter, tbPartner, tbServerBuff)
local mapCharAttr = {}
if tbCharacter then
local _, tbDeployed = _CalcAllDeployedAttrs(clone(tbCharacter), tbPartner, tbServerBuff, true)
for _, chess in ipairs(tbDeployed) do
local map = _FindChessAttr(tbDeployed, chess.nId, chess.nStar)
if map then
mapCharAttr[chess.nId] = _FillAttrForBattle(map)
end
end
end
return mapCharAttr
end
function SoldierAttrData.GetPartnerGroupsByChessId(nId)
local mapCharacter = ConfigTable.GetData("SoldierCharacter", nId)
if mapCharacter ~= nil then
return mapCharacter.PartnerType
end
return {}
end
local _IsPartnerLevelActivated = function(nCount, nNum, eNumType)
if not nNum or nNum <= 0 then
return false
end
if eNumType == GameEnum.SoldierPartnerNumType.EQ then
return nCount == nNum
elseif eNumType == GameEnum.SoldierPartnerNumType.GE then
return nNum <= nCount
end
return false
end
function SoldierAttrData.CalcActivePartners(tbChess, tbExtraLevel, tbExtraCount)
local tbActivePartnerIds = {}
local tbUIData = {}
local mapTypeCount = {}
if tbChess then
for _, chess in ipairs(tbChess) do
if chess.nId and chess.nId ~= 0 then
local tbPartnerTypes = SoldierAttrData.GetPartnerGroupsByChessId(chess.nId)
if tbPartnerTypes then
for _, nType in ipairs(tbPartnerTypes) do
if nType and 0 < nType then
local nCount = 1
if mapTypeCount[nType] ~= nil then
nCount = mapTypeCount[nType].nCount + 1
end
mapTypeCount[nType] = {nCount = nCount}
end
end
end
end
end
end
if tbExtraCount == nil and tbExtraLevel == nil then
local curLevel = PlayerData.SoldierData:GetCurLevelData()
if curLevel ~= nil then
local tbServerPartner = curLevel:GetServerPartner()
if tbServerPartner ~= nil and next(tbServerPartner) ~= nil then
tbExtraCount = tbServerPartner
end
end
end
if tbExtraLevel then
for nType, nLevel in pairs(tbExtraLevel) do
if mapTypeCount[nType] ~= nil then
mapTypeCount[nType].nExtraLevel = nLevel
else
mapTypeCount[nType] = {nCount = 0, nExtraLevel = nLevel}
end
end
end
if tbExtraCount then
for nType, nCount in pairs(tbExtraCount) do
if mapTypeCount[nType] ~= nil then
mapTypeCount[nType].nExtraCount = nCount
else
mapTypeCount[nType] = {nCount = 0, nExtraCount = nCount}
end
end
end
for nType, data in pairs(mapTypeCount) do
local nExtraCount = data.nExtraCount or 0
local nCount = data.nCount + nExtraCount
local nExtraLevel = data.nExtraLevel or 0
local mapByLevel = CacheTable.GetData("_SoldierPartner", nType)
if mapByLevel then
local tbLevels = {}
for _, cfg in pairs(mapByLevel) do
table.insert(tbLevels, cfg)
end
table.sort(tbLevels, function(a, b)
return (a.Level or 0) < (b.Level or 0)
end)
local nMaxLevel = 0
if 0 < #tbLevels then
nMaxLevel = tbLevels[#tbLevels].Level or 0
end
local tbNumList = {}
local nActiveLevel = 0
local nActiveNum = 0
local nQuality = 0
for _, cfg in ipairs(tbLevels) do
table.insert(tbNumList, cfg.Num or 0)
if _IsPartnerLevelActivated(nCount, cfg.Num, cfg.SoldierPartnerNumType) and nActiveLevel < (cfg.Level or 0) then
nActiveLevel = cfg.Level or 0
nActiveNum = cfg.Num or 0
end
end
nActiveLevel = nActiveLevel + nExtraLevel
if 0 < nMaxLevel and nMaxLevel < nActiveLevel then
nActiveLevel = nMaxLevel
end
if 0 < nActiveLevel then
local cfg = mapByLevel[nActiveLevel]
if cfg and cfg.Id then
nQuality = cfg.PartnerLevelQuality
table.insert(tbActivePartnerIds, cfg.Id)
end
end
table.insert(tbUIData, {
nType = nType,
nQuality = nQuality,
nCurNum = nCount,
tbNumList = tbNumList,
nActiveNum = nActiveNum,
nActiveLevel = nActiveLevel
})
end
end
table.sort(tbUIData, function(a, b)
local nActA = a.nActiveLevel > 0 and 1 or 0
local nActB = b.nActiveLevel > 0 and 1 or 0
if nActA == nActB then
if a.nQuality == b.nQuality then
if a.nActiveNum == b.nActiveNum then
return a.nType < b.nType
end
return a.nActiveNum < b.nActiveNum
end
return a.nQuality > b.nQuality
end
return nActA > nActB
end)
return tbActivePartnerIds, tbUIData
end
function SoldierAttrData.GetPartnerLevelsByType(nPartnerType)
local tbPartnerLevel = {}
local tbPartner = CacheTable.GetData("_SoldierPartner", nPartnerType)
if tbPartner ~= nil then
for nLevel, mapCfg in pairs(tbPartner) do
local sDesc = mapCfg.Desc
table.insert(tbPartnerLevel, {
nLevel = nLevel,
sDesc = sDesc,
nConfigId = mapCfg.Id
})
end
end
table.sort(tbPartnerLevel, function(a, b)
return a.nLevel < b.nLevel
end)
return tbPartnerLevel
end
return SoldierAttrData