Files
Main/Assets/GameAssets/Resources/Lua/Logic/CrossFuDi/CrossFuDiData.lua
2025-01-25 04:38:09 +08:00

764 lines
21 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

------------------------------------------------
-- 作者: 王圣
-- 日期: 2021-02-01
-- 文件: CrossFuDiData.lua
-- 模块: CrossFuDiData
-- 描述: 跨服福地据点数据
------------------------------------------------
-- 引用
local L_TimeUtils = CS.Thousandto.Core.Base.TimeUtils
local CrossFuDiData = {
Id = 0,
-- 0出生点 1:城市
Type = 0,
-- 0:未占领 1:暂时占领 2:已占领
State = 0,
-- 存活boss数量
BossNum = 0,
-- 缝隙boss剩余数量
DevilBossNum = 0,
-- 本服玩家数量
OwnPlayerNum = 0,
-- 占领的阵营Id
CampId = 0,
-- 服务器列表
ServerList = List:New(),
-- 宝箱id
BoxId = 0,
-- 是否领取宝箱
IsGetBox = false,
-- 服务器积分排行{Rank, Score, ServerId}
ServerScoreRankList = List:New(),
-- 个人击杀排行
PersonKillRankList = List:New(),
-- 个人积分排行
PersonScoreRankList = List:New(),
-- 伤害排行
DamageRankList = List:New(),
-- boss列表 {Id, Name, Level, EndTime, Sort, State(0:存活,1:死亡)}
BossList = List:New(),
-- 占领奖励
FinalItem = nil,
-- 当前选中的BossId
CurSelectBossId = 0,
Cfg = nil,
-- 本阵营积分
OwnScore = 0,
-- 阵营积分
CampScore = 0,
-- 占领者积分
OccupierScore = 0,
-- 首领归属阵营数据
BossGuiShuCampData = nil
}
function CrossFuDiData:New()
local _m = Utils.DeepCopy(self)
return _m
end
-- 设置数据
function CrossFuDiData:SetData(msg)
if msg == nil then
return
end
self.Id = msg.cityId
-- 设置城市占领状态
self.State = msg.state
-- 设置占领奖励
if msg.box == nil then
self.BoxId = 0
else
self.BoxId = msg.box.boxId
end
self.IsGetBox = msg.box.isGet
-- 设置剩余boss数量
self.BossNum = msg.remainBoss
self.DevilBossNum = msg.remainDevilBoss
-- 设置本服参战人数
self.OwnPlayerNum = msg.enterRole
if msg.enterRole == nil then
self.OwnPlayerNum = 0
end
-- 设置阵营数据
self:SetCamp(msg.camp)
end
function CrossFuDiData:RewardedBox()
self.IsGetBox = true
end
-- 设置阵营
function CrossFuDiData:SetCamp(camp)
if camp == nil then
return
end
self.CampId = camp.camp
self.ServerList:Clear()
if camp.serverId ~= nil then
for i = 1, #camp.serverId do
self.ServerList:Add(camp.serverId[i])
end
end
self.CampScore = camp.score
end
-- 设置归属阵营数据
function CrossFuDiData:SetBossGuiShuCamp(camp)
if camp == nil then
return
end
local _name = nil
local _serverList = List:New()
if camp.serverId ~= nil and #camp.serverId > 0 then
local _serverId = camp.serverId[1]
local _crossType = GameCenter.CrossFuDiSystem:GetCrossType()
if _crossType == FuDiCrossType.Cross_2 or _crossType == FuDiCrossType.Cross_4 or _crossType ==
FuDiCrossType.Cross_8 then
local _sdata = GameCenter.ServerListSystem:FindServer(_serverId)
if _sdata ~= nil then
_name = UIUtils.CSFormat("S{0}_{1}", _sdata.ShowServerId, _sdata.Name)
end
end
end
self.BossGuiShuCampData = {
Id = camp.camp,
ServerList = _serverList,
Score = camp.score,
Name = _name
}
end
-- 获取占领者服务器Id
function CrossFuDiData:GetGetOccupierServerId()
local _ret = 0
if #self.ServerList > 0 then
_ret = self.ServerList[1]
end
return _ret
end
-- 是否是本服占领
function CrossFuDiData:IsLocalOwn()
local _ret = false
if self.State == 0 then
return _ret
end
for i = 1, #self.ServerList do
if GameCenter.ServerListSystem:GetCurrentServer().ReallyServerId == self.ServerList[i] then
_ret = true
end
end
return _ret
end
function CrossFuDiData:GetCfg()
if self.Cfg == nil then
self.Cfg = DataConfig.DataCrossFudiMain[self.Id]
end
return self.Cfg
end
-- 获取据点名字
function CrossFuDiData:GetName()
local _ret = ""
local _cfg = self:GetCfg()
if _cfg ~= nil then
_ret = _cfg.Name
end
return _ret
end
-- 获取据点类型
function CrossFuDiData:GetType()
local _ret = 0
local _cfg = self:GetCfg()
if _cfg ~= nil then
_ret = _cfg.Position
end
return _ret
end
-- 获取跨服类型
function CrossFuDiData:GetCrossType()
local _ret = 2
local _cfg = self:GetCfg()
if _cfg ~= nil then
_ret = _cfg.CrossStage
end
return _ret
end
-- 获取icon
function CrossFuDiData:GetIcon()
local _ret = nil
if self.Cfg ~= nil then
_ret = self.Cfg.Icon
end
return _ret
end
-- 获取我的排名
function CrossFuDiData:GetMyRank()
local _playerId = GameCenter.GameSceneSystem:GetLocalPlayerID()
local _rankList = self:GetPersonScoreRankDatas()
if _rankList ~= nil then
for i = 1, #_rankList do
local _rank = _rankList[i]
if _playerId == _rank.PlayerId then
return _rank.Rank
end
end
end
return 999
end
-- 获取奖励宝箱icon
function CrossFuDiData:GetBoxIcon()
local _ret = nil
local _index = 0
local _myRank = self:GetMyRank()
local _cfg = DataConfig.DataCrossFudiHoldReward[self.BoxId]
if _cfg ~= nil then
local _list = Utils.SplitStr(_cfg.Rank, ';')
for i = 1, #_list do
local _values = Utils.SplitNumber(_list[i], '_')
local _min = _values[1]
local _max = _values[2]
if _myRank >= _min and _myRank <= _max then
_index = i
break
end
end
local _occ = 0
local _player = GameCenter.GameSceneSystem:GetLocalPlayer()
if _player then
_occ = _player.IntOcc
end
if _occ == 0 then
_list = Utils.SplitStr(_cfg.Reward0, ';')
elseif _occ == 1 then
_list = Utils.SplitStr(_cfg.Reward1, ';')
end
if _list ~= nil and _index <= #_list then
local _values = Utils.SplitNumber(_list[_index], '_')
if _values ~= nil then
_ret = _values[1]
end
end
end
return _ret
end
-- 设置服务器积分排行
function CrossFuDiData:SetServerScoreRankDatas(msg)
if msg == nil then
return
end
self.ServerScoreRankList:Clear()
if msg.campList ~= nil then
for i = 1, #msg.campList do
local _camp = msg.campList[i]
local _score = _camp.score
local _name = ""
-- 判断当前跨服类型
local _crossType = GameCenter.CrossFuDiSystem:GetCrossType()
if _crossType == FuDiCrossType.Cross_2 or _crossType == FuDiCrossType.Cross_4 or _crossType ==
FuDiCrossType.Cross_8 then
if _camp.serverId ~= nil and #_camp.serverId > 0 then
local _sdata = GameCenter.ServerListSystem:FindServer(_camp.serverId[1])
if _sdata ~= nil then
_name = UIUtils.CSFormat("S{0}_{1}", _sdata.ShowServerId, _sdata.Name)
end
end
end
local _serverList = List:New()
if _camp ~= nil and _camp.serverId ~= nil then
for m = 1, #_camp.serverId do
_serverList:Add(_camp.serverId[m])
local _id = _camp.serverId[m]
if _id == GameCenter.ServerListSystem:GetCurrentServer().ReallyServerId then
-- self.CampScore = _camp.score
break
end
end
end
self.ServerScoreRankList:Add({
Rank = 0,
Score = _score,
Name = _name,
ServerList = _serverList
})
end
self.ServerScoreRankList:Sort(function(a, b)
return a.Score > b.Score
end)
for i = 1, #self.ServerScoreRankList do
self.ServerScoreRankList[i].Rank = i
if i == 1 then
self.CampScore = self.ServerScoreRankList[i].Score
end
end
end
end
-- 获取服务器积分排行
function CrossFuDiData:GetServerScoreRankDatas()
return self.ServerScoreRankList
end
-- 获取积分排名第一
function CrossFuDiData:GetNumberOneCampName()
local _ret = nil
if self.ServerScoreRankList ~= nil and #self.ServerScoreRankList > 0 then
_ret = self.ServerScoreRankList[1].Name
end
return _ret
end
-- 获取服务器积分
function CrossFuDiData:GetServerScore(id)
local _ret = 0
local _rankList = self:GetServerScoreRankDatas()
if _rankList ~= nil then
for i = 1, #_rankList do
local _data = _rankList[i]
for m = 1, #_data.ServerList do
if _data.ServerList[m] == id then
_ret = _data.Score
break
end
end
end
end
return _ret
end
-- 获取本服在该城市的积分
function CrossFuDiData:GetOwnSreverScore()
local _ret = 0
local _ownServerId = GameCenter.ServerListSystem:GetCurrentServer().ReallyServerId
_ret = self:GetServerScore(_ownServerId)
return _ret
end
-- 获取该城市占领者的积分
function CrossFuDiData:GetOccupierServerScore()
local _ret = 0
_ret = self.CampScore -- self:GetServerScore(self:GetGetOccupierServerId())
return _ret
end
-- 设置个人击杀排行
function CrossFuDiData:SetPersonKillRankDatas(rankList)
if rankList == nil then
return
end
self.PersonKillRankList:Clear()
-- {Rank, Name, ServerId, Score}
for i = 1, #rankList do
local _rank = rankList[i]
local _playerId = _rank.playerId
local _name = _rank.name
local _rankId = _rank.rank
local _score = _rank.kill
local _damage = _rank.damage
local _occ = _rank.career
local _campName = ""
-- 判断当前跨服类型
local _camp = _rank.camp
if _camp ~= nil then
local _crossType = self:GetCrossType()
if _crossType == FuDiCrossType.Cross_2 or _crossType == FuDiCrossType.Cross_4 or _crossType ==
FuDiCrossType.Cross_8 then
if _camp.serverId ~= nil and #_camp.serverId > 0 then
local _sdata = GameCenter.ServerListSystem:FindServer(_camp.serverId[1])
if _sdata ~= nil then
_campName = UIUtils.CSFormat("S{0}_{1}", _sdata.ShowServerId, _sdata.Name)
end
end
end
end
local _data = {
PlayerId = _playerId,
Name = _name,
Rank = _rankId,
Score = _score,
Damage = _damage,
Occ = _occ,
ServerName = _campName
}
self.PersonKillRankList:Add(_data)
end
end
-- 获取个人击杀排行
function CrossFuDiData:GetPersonKillRankDatas()
return self.PersonKillRankList
end
-- 设置个人积分排行
function CrossFuDiData:SetPersonScoreRankDatas(rankList)
if rankList == nil then
return
end
self.PersonScoreRankList:Clear()
-- {Rank, Name, ServerId, Score}
for i = 1, #rankList do
local _rank = rankList[i]
local _playerId = _rank.playerId
local _name = _rank.name
local _rankId = _rank.rank
local _score = _rank.score
local _damage = _rank.damage
local _occ = _rank.career
local _campName = ""
-- 判断当前跨服类型
local _camp = _rank.camp
if _camp ~= nil then
local _crossType = self:GetCrossType()
if _crossType == FuDiCrossType.Cross_2 or _crossType == FuDiCrossType.Cross_4 or _crossType ==
FuDiCrossType.Cross_8 then
if _camp.serverId ~= nil and #_camp.serverId > 0 then
local _sdata = GameCenter.ServerListSystem:FindServer(_camp.serverId[1])
if _sdata ~= nil then
_campName = UIUtils.CSFormat("S{0}_{1}", _sdata.ShowServerId, _sdata.Name)
end
end
end
end
local _data = {
PlayerId = _playerId,
Name = _name,
Rank = _rankId,
Score = _score,
Damage = _damage,
Occ = _occ,
ServerName = _campName
}
self.PersonScoreRankList:Add(_data)
end
end
-- 获取个人积分排行
function CrossFuDiData:GetPersonScoreRankDatas()
return self.PersonScoreRankList
end
-- 设置伤害排行
function CrossFuDiData:SetDamageRankList(rankList, bossId)
if rankList == nil then
return
end
self.DamageRankList:Clear()
for i = 1, #rankList do
local _rank = rankList[i]
self.DamageRankList:Add({
Rank = _rank.rank,
Name = _rank.name,
Damage = _rank.damage,
BossId = bossId
})
end
end
-- 获取伤害排行
function CrossFuDiData:GetDamageRankList()
return self.DamageRankList
end
-- 设置boss列表
function CrossFuDiData:SetBossDatas(bList)
if bList == nil then
Debug.LogError("服务器同步的boss列表是空的")
return
end
self.BossList:Clear()
for i = 1, #bList do
local _boss = bList[i]
-- {Id, Name, Level, EndTime, Sort, State(0:存活,1:死亡)}
local _id = _boss.bossId
local _blood = _boss.hp
local _state = _boss.isDie and 1 or 0
local _isCare = _boss.care
local _cfg = DataConfig.DataCrossFudiBoss[_id]
if _cfg ~= nil then
local _name = _cfg.Name
local _level = 0
local _monsterCfg = DataConfig.DataMonster[_id]
if _monsterCfg ~= nil then
_level = _monsterCfg.Level
end
local _sort = _cfg.Sort
local _icon = _cfg.Icon
local _data = {
Id = _id,
Name = _name,
Level = _level,
BossState = _state,
IsCare = _isCare,
Sort = _sort,
Head = _icon,
Blood = _blood,
Score = _cfg.Score,
MonsterType = _cfg.Type
}
self.BossList:Add(_data)
end
end
end
-- 获取boss列表
function CrossFuDiData:GetBossDatas()
self.BossList:Sort(function(a, b)
return a.Sort < b.Sort
end)
return self.BossList
end
-- 获取boss数据
function CrossFuDiData:GetBossData(id)
local _ret = nil
for i = 1, #self.BossList do
local _boss = self.BossList[i]
if _boss.Id == id then
_ret = _boss
end
end
return _ret
end
-- 通过序号获取boss数据
function CrossFuDiData:GetBossDataByIndex(index)
local _ret = 0
for i = 1, #self.BossList do
local _boss = self.BossList[i]
if i == index then
_ret = _boss
end
end
return _ret
end
-- 获取boss序号
function CrossFuDiData:GetBossIndex(id)
local _ret = 0
for i = 1, #self.BossList do
local _boss = self.BossList[i]
if _boss.Id == id then
_ret = i
end
end
return _ret
end
-- 获取boss总数量
function CrossFuDiData:GetBossCount()
return #self.BossList
end
-- 获取掉落展示
function CrossFuDiData:GetDropDatas()
local _ret = List:New()
local _occ = GameCenter.GameSceneSystem:GetLocalPlayer().IntOcc
local _bossList = self:GetBossDatas()
if _bossList ~= nil and #_bossList > 0 then
local _data = _bossList[1]
local _cfg = DataConfig.DataCrossFudiBoss[_data.Id]
if _cfg ~= nil then
local _list = Utils.SplitStr(_cfg.Reward, ';')
if _list ~= nil then
for i = 1, #_list do
local _values = Utils.SplitNumber(_list[i], '_')
if _occ == _values[1] or _values[1] == 9 then
local _itemData = {
Id = _values[2]
}
_ret:Add(_itemData)
end
end
end
end
end
return _ret
end
function CrossFuDiData:GetDropData(bossId)
local _ret = List:New()
local _occ = GameCenter.GameSceneSystem:GetLocalPlayer().IntOcc
local _cfg = DataConfig.DataCrossFudiBoss[bossId]
if _cfg ~= nil then
local _list = Utils.SplitStr(_cfg.Reward, ';')
if _list ~= nil then
for i = 1, #_list do
local _values = Utils.SplitNumber(_list[i], '_')
if _occ == _values[1] or _values[1] == 9 then
local _itemData = {
Id = _values[2]
}
_ret:Add(_itemData)
end
end
end
end
return _ret
end
function CrossFuDiData:SetFinalItem(data)
local _occ
local _reward = nil
local _cfg = DataConfig.DataCrossFudiHoldReward[data.boxId]
if _cfg == nil then
return
end
local _player = GameCenter.GameSceneSystem:GetLocalPlayer()
if _player then
_occ = _player.IntOcc
end
if _occ == 0 then
_reward = _cfg.Reward0
else
_reward = _cfg.Reward1
end
local _list = Utils.SplitStr(_reward, ';')
if _list == nil or #_list == 0 then
return
end
local _value = Utils.SplitNumber(_list[#_list], '_')
self.FinalItem = {
Id = _value[1],
Num = _value[2],
IsBind = true
}
end
function CrossFuDiData:GetFinalItem()
return self.FinalItem
end
-- 获取关联的城市
function CrossFuDiData:GetRelationCity()
local _ret = List:New()
local _cfg = self:GetCfg()
if _cfg ~= nil then
local _list = Utils.SplitNumber(_cfg.EnterPosition, '_')
if _list ~= nil then
for i = 1, #_list do
local _id = _list[i]
_ret:Add(_id)
end
end
end
return _ret
end
-- 获取相关的连线
function CrossFuDiData:GetRelationLine()
local _ret = List:New()
local _cfg = self:GetCfg()
if _cfg ~= nil then
local _list = Utils.SplitNumber(_cfg.Line, '_')
if _list ~= nil then
for i = 1, #_list do
local _id = _list[i]
_ret:Add(_id)
end
end
end
return _ret
end
-- 获取福城市名字
function CrossFuDiData:GetCityName()
local _ret = nil
local _cfg = self:GetCfg()
if _cfg ~= nil then
_ret = _cfg.Name
end
return _ret
end
-- 获取下一次刷新的时间
function CrossFuDiData:GetNextRefreshTime()
local _ret = 0
local _cfg = self:GetCfg()
if _cfg ~= nil then
local _list = Utils.SplitNumber(_cfg.RefreshTime, '_')
local _hour, _min, _sec = L_TimeUtils.GetStampTimeHHMMSSNotZone(math.floor(GameCenter.HeartSystem.ServerZoneTime))
local _time = _hour * 60 + _min
if _list ~= nil and #_list > 0 then
local _isFind = false
for i = 1, #_list do
if _time < _list[i] then
_ret = _list[i]
_isFind = true
break
end
end
if not _isFind and #_list > 0 then
_ret = _list[1]
end
end
end
return _ret
end
-- 获取下次刷新倒计时
function CrossFuDiData:GetLeftTime()
local _ret = 0
local _nextTime = self:GetNextRefreshTime() * 60
local _hour, _min, _sec = L_TimeUtils.GetStampTimeHHMMSSNotZone(math.floor(GameCenter.HeartSystem.ServerZoneTime))
local _time = _hour * 3600 + _min * 60 + _sec
if _time > _nextTime then
-- 跨天了
_ret = 24 * 3600 - _time + _nextTime
else
_ret = _nextTime - _time
end
return _ret
end
-- 设置当前选中的bossId
function CrossFuDiData:SetCurSelectBossId(id)
self.CurSelectBossId = id
end
-- 获取当前选中的BossId
function CrossFuDiData:GetCurSelectBossId()
return self.CurSelectBossId
end
-- 获取指定boss的类型
function CrossFuDiData:GetBossType(id)
local _ret = 1
local _bossData = self:GetBossData(id)
if _bossData ~= nil then
_ret = _bossData.MonsterType
end
return _ret
end
-- 获取有本服玩家参与的boss列表
function CrossFuDiData:GetOwnJoinBossList()
for i = 1, #self.BossList do
local _boss = self.BossList[i]
end
end
-- 获取副本id
function CrossFuDiData:GetMapId()
local _ret = 0
local _cfg = self:GetCfg()
if _cfg ~= nil then
local _cloneCfg = DataConfig.DataCloneMap[_cfg.CloneId]
if _cloneCfg ~= nil then
_ret = _cloneCfg.Mapid
end
end
return _ret
end
return CrossFuDiData