401 lines
14 KiB
Lua
401 lines
14 KiB
Lua
QiJieShiLianManager = {}
|
||
local this = QiJieShiLianManager
|
||
local QijieHolyConfig = ConfigManager.GetConfig(ConfigName.QijieHolyConfig)
|
||
local QijieRanking = ConfigManager.GetConfig(ConfigName.QijieRanking)
|
||
local QijieStage = ConfigManager.GetConfig(ConfigName.QijieStage)
|
||
local QijieStageBuff = ConfigManager.GetConfig(ConfigName.QijieStageBuff)
|
||
local QijieTreasure = ConfigManager.GetConfig(ConfigName.QijieTreasure)
|
||
local QijieUpgrade = ConfigManager.GetConfig(ConfigName.QijieUpgrade)
|
||
local HeroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
||
local PassiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
|
||
local PassiveSkillLogicConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig)
|
||
|
||
function this.Initialize()
|
||
this.curLevelId = 1001
|
||
this.curRank = 1
|
||
this.curScore = 1
|
||
this.QijieType = 1
|
||
this.curProgress = 0
|
||
this.curMaxStage = 0
|
||
this.IsLock = false
|
||
|
||
this.treasureList = {}
|
||
this.treasureActiveList = {}
|
||
this.InitTreasureData()
|
||
this.battleResult = {}
|
||
|
||
-- 特权刷新时,刷新红点
|
||
Game.GlobalEvent:AddEvent(GameEvent.Privilege.OnPrivilegeZeroUpdate, function()
|
||
CheckRedPointStatus(RedPointType.QiJieShiLian)
|
||
end)
|
||
end
|
||
|
||
function this.InitTreasureData()
|
||
for _, configInfo in ConfigPairs(QijieHolyConfig) do
|
||
if configInfo.Id ~= 0 then
|
||
local data = {}
|
||
data.Id = configInfo.Id
|
||
data.Name = configInfo.Name
|
||
data.Quality = configInfo.Quality
|
||
data.Icon = configInfo.Icon
|
||
data.Type = configInfo.Type
|
||
data.Position = configInfo.Position
|
||
data.AttriType = configInfo.AttriType
|
||
data.Cost = configInfo.Cost
|
||
-- data.ConditionValue[1][2] = configInfo.ConditionValue[1][2]
|
||
data.Desc = configInfo.Desc
|
||
data.Buff = configInfo.Buff[1]
|
||
data.state = 2 --0未激活,1已激活,2未购买
|
||
this.treasureList[data.Id] = data
|
||
end
|
||
end
|
||
end
|
||
|
||
--界面获取信息
|
||
function this.GetQiJieData()
|
||
--上阵列表赋值
|
||
local curFormation = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
|
||
if FormationManager.GetFormationByID(FormationTypeDef.FORMATION_QIJIESHILIAN) then
|
||
curFormation = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_QIJIESHILIAN)
|
||
end
|
||
this.formationList ={}
|
||
for j = 1, #curFormation.teamHeroInfos do
|
||
this.formationList[j] = curFormation.teamHeroInfos[j]
|
||
end
|
||
--界面信息
|
||
local data = {}
|
||
data.curLevelId = this.curLevelId
|
||
data.curRank = this.curRank
|
||
data.curScore = this.curScore
|
||
data.curProgress = this.curProgress
|
||
data.curStageData = QijieStage[this.curLevelId]
|
||
return data
|
||
end
|
||
|
||
--获取服务器信息
|
||
function this.GetServerData(msg,func)
|
||
this.curLevelId = msg.id
|
||
this.curRank = msg.ranking
|
||
this.curScore = msg.integral
|
||
this.curProgress = msg.totalTier
|
||
this.curMaxStage = this.curMaxStage >= msg.id and this.curMaxStage or msg.id
|
||
-- LogRed("id:"..tostring(msg.id).." ranking:"..tostring(msg.ranking).." integral:"..tostring(msg.integral).." totalTier:"..tostring(msg.totalTier))
|
||
if func then
|
||
func()
|
||
end
|
||
end
|
||
|
||
--获取下方滑动条数据
|
||
function this.GetTabList()
|
||
local tabList = {}
|
||
for _, configInfo in ConfigPairs(QijieStage) do
|
||
if not tabList[configInfo.QijieType] then
|
||
tabList[configInfo.QijieType] = configInfo
|
||
end
|
||
end
|
||
return tabList
|
||
end
|
||
|
||
--检测该条目是否达成
|
||
function this.CheckGoalIsFinish(_dataId,_obj,_formationList)
|
||
local goalData = QijieUpgrade[_dataId]
|
||
local tempList = {}
|
||
local final = true
|
||
local heroList = {}
|
||
-- LogRed("Id:"..tostring(goalData.Id).." Describe:"..tostring(goalData.Describe).." PropertyName:"..tostring(goalData.PropertyName).." Profession:"..tostring(goalData.Profession).." Min:"..tostring(goalData.Min).." Max:"..tostring(goalData.Max))
|
||
heroList = _formationList and _formationList or this.formationList
|
||
if #heroList == 0 then
|
||
-- LogYellow("final = false0")
|
||
final = false
|
||
end
|
||
-- LogRed("##heroList:"..tostring(#heroList))
|
||
for i = 1, #heroList do
|
||
-- LogGreen("heroList[i].heroId:"..tostring(heroList[i].heroId))
|
||
table.insert(tempList,HeroManager.GetSingleHeroData(heroList[i].heroId))
|
||
end
|
||
if #tempList > 0 and final and goalData.PropertyName and goalData.PropertyName > 0 then
|
||
for i = #tempList, 1,-1 do
|
||
if goalData.PropertyName ~= tempList[i].changeProId then
|
||
table.remove(tempList,i)
|
||
if #tempList == 0 then
|
||
final = true
|
||
end
|
||
end
|
||
end
|
||
end
|
||
-- LogGreen("#tempList1:"..tostring(#tempList))
|
||
if #tempList > 0 and final and goalData.Profession and goalData.Profession > 0 then
|
||
for i = #tempList, 1,-1 do
|
||
if goalData.Profession ~= tempList[i].heroConfig.Profession then
|
||
table.remove(tempList,i)
|
||
if #tempList == 0 then
|
||
final = true
|
||
end
|
||
end
|
||
end
|
||
end
|
||
-- LogGreen("#tempList1:"..tostring(#tempList))
|
||
if final and goalData.Min and goalData.Min >= 0 then
|
||
if #tempList < goalData.Min then
|
||
-- LogYellow("final = false1")
|
||
final = false
|
||
end
|
||
end
|
||
if final and goalData.Max and goalData.Max >= 0 then
|
||
if #tempList > goalData.Max then
|
||
-- LogYellow("final = false2")
|
||
final = false
|
||
end
|
||
end
|
||
_obj.text = string.format( "<color=#BAAF98>%s</color>",goalData.Describe)
|
||
if final then
|
||
_obj.text = string.format( "<color=#27DD65>%s</color>",goalData.Describe)
|
||
end
|
||
return final
|
||
end
|
||
|
||
--把服务器发来的遗物数据加到本地数据中
|
||
function this.MixTreasureServerAndLocalData(msg)
|
||
this.treasureActiveList = {}
|
||
for i = 1, #msg.info do
|
||
if msg.info[i].status == 1 then
|
||
table.insert(this.treasureActiveList,msg.info[i].id)
|
||
end
|
||
if this.treasureList[msg.info[i].id] then
|
||
this.treasureList[msg.info[i].id].state = msg.info[i].status
|
||
else
|
||
LogError("服务器发来了前端不存在的遗物Id:"..tostring(msg.info[i].id))
|
||
end
|
||
end
|
||
end
|
||
|
||
--把1维的List换成2维的。并且增加稀有度条件
|
||
function this.FormatTreasureData(_tabNum)
|
||
local list = {}
|
||
for k,v in pairs(this.treasureList) do
|
||
table.insert(list,v)
|
||
end
|
||
table.sort(list,function (a,b)
|
||
if a.Quality == b.Quality then
|
||
return a.Id < b.Id
|
||
else
|
||
return a.Quality > b.Quality
|
||
end
|
||
end)
|
||
if _tabNum and _tabNum > 0 then
|
||
for i = #list, 1,-1 do
|
||
if list[i].Quality ~= _tabNum then
|
||
table.remove(list,i)
|
||
end
|
||
end
|
||
end
|
||
local num = math.ceil( LengthOfTable(list)/4 )
|
||
local dataList = {}
|
||
for i = 1, num do
|
||
dataList[i] = {}
|
||
for j = 1, 4 do
|
||
if list[(i-1)*4+j] then
|
||
dataList[i][j] = list[(i-1)*4+j]
|
||
else
|
||
return dataList
|
||
end
|
||
end
|
||
end
|
||
return dataList
|
||
end
|
||
|
||
--获取战斗结束后信息(拼接)
|
||
function this.GetBattleResult()
|
||
local config = QijieStage[this.curLevelId]
|
||
local data = {}
|
||
data[1] = "<color=#F9E7D3>阵容加成:</color> <color=#3DE181>"..(#this.battleResult.teamBuffIds)*(config.ConditionValue[1][2]/100).."%</color>\n<color=#AE7B20>("..#this.battleResult.teamBuffIds.."条)</color>"
|
||
data[2] = "<color=#F9E7D3>遗物加成:</color> <color=#3DE181>"..(this.GetBttleResultRelicdsAddition(this.battleResult.relicIds)).."%</color>\n<color=#AE7B20>("..#this.battleResult.relicIds.."个)</color>"
|
||
local bonue = 0
|
||
for i = #config.RoundReward, 1, -1 do
|
||
if this.battleResult.round <= config.RoundReward[i][1] then
|
||
bonue = config.RoundReward[i][2]
|
||
end
|
||
end
|
||
data[3] = "<color=#F9E7D3>回合加成:</color> <color=#3DE181>"..(bonue/100).."%</color>\n<color=#AE7B20>("..this.battleResult.round.."回合)</color>"
|
||
return data
|
||
end
|
||
|
||
function this.GetBttleResultRelicdsAddition(treasureList)
|
||
local num = 0
|
||
for i = 1, #treasureList do
|
||
num = num + QijieHolyConfig[treasureList[i]].Addition
|
||
end
|
||
return num/100
|
||
end
|
||
|
||
--获取遗物效果
|
||
function this.GetTreasureEffect(treasureList)
|
||
local moneyString = ""
|
||
local attriString = ""
|
||
local attriTitle = ""
|
||
local moneyNum = 0
|
||
local attriList1 = {}
|
||
local attriList2 = {}
|
||
-- LogYellow(tostring(#treasureList))
|
||
for i = 1, #treasureList do
|
||
-- LogYellow(tostring(treasureList[i]))
|
||
local tData = QijieHolyConfig[treasureList[i]]
|
||
--界灵数量加成
|
||
moneyNum = moneyNum + tData.Addition
|
||
-- LogYellow("moneyNum"..tostring(moneyNum))
|
||
--属性加成
|
||
if not attriList1[tData.AttriType] then
|
||
-- LogGreen("1")
|
||
attriList1[tData.AttriType] = {}
|
||
end
|
||
-- LogGreen("2")
|
||
attriList1[tData.AttriType].title = tData.Desc
|
||
if not attriList1[tData.AttriType].ValueList then
|
||
-- LogGreen("3,tData.AttriType:"..tostring(tData.AttriType))
|
||
attriList1[tData.AttriType].ValueList = {}
|
||
end
|
||
-- LogGreen("4,tData.Buff[1]:"..tostring(tData.Buff[1]))
|
||
table.insert(attriList1[tData.AttriType].ValueList,tData)
|
||
end
|
||
for k,v in pairs(attriList1) do
|
||
for m,n in pairs(v.ValueList) do
|
||
local buffData = PassiveSkillLogicConfig[n.Buff[1]]
|
||
if not attriList2[k] then
|
||
attriList2[k] = {}
|
||
end
|
||
attriList2[k].title = attriList1[k].title
|
||
-- LogGreen("5,Desc:"..tostring(attriList2[k].title))
|
||
if not attriList2[k][buffData.Value[1]] then
|
||
attriList2[k][buffData.Value[1]] = {}
|
||
end
|
||
-- LogYellow("Desc:"..tostring(PassiveSkillConfig[n.Buff[1]].Desc))
|
||
attriList2[k][buffData.Value[1]].Desc = PassiveSkillConfig[n.Buff[1]].Desc
|
||
if attriList2[k][buffData.Value[1]].Value then
|
||
attriList2[k][buffData.Value[1]].Value = attriList2[k][buffData.Value[1]].Value + tonumber(PassiveSkillConfig[n.Buff[1]].DescValue[1])/100
|
||
else
|
||
attriList2[k][buffData.Value[1]].Value = tonumber(PassiveSkillConfig[n.Buff[1]].DescValue[1])/100
|
||
end
|
||
end
|
||
end
|
||
|
||
moneyString = string.format( "挑战获得界灵数量<color=#4ab47a>+%s</color>",tostring(moneyNum/100).."%")
|
||
return moneyString,attriList2
|
||
end
|
||
|
||
function this.GetSring(stringList,type)
|
||
local str = ""
|
||
for k,v in pairs(stringList) do
|
||
-- LogPink("Desc1:"..tostring(v.title))
|
||
for m,n in pairs(v) do
|
||
if tonumber(m) then
|
||
str = str..v.title
|
||
-- LogBlue("m2:"..tostring(tonumber(m)))
|
||
-- LogBlue("Desc2:"..tostring(n.Desc))
|
||
-- LogBlue("Value2:"..tostring(n.Value))
|
||
str = str..string.format(n.Desc,n.Value.."%")
|
||
if type and type == 1 then
|
||
str = str.."\n"
|
||
end
|
||
end
|
||
end
|
||
end
|
||
return str
|
||
end
|
||
|
||
--左右切换检测
|
||
function this.SwitchBtnCheck(num,func)
|
||
if num == -1 then
|
||
this.IsLock = true
|
||
if not QijieStage[this.curLevelId - 1] then
|
||
return
|
||
end
|
||
this.curLevelId = this.curLevelId - 1
|
||
elseif num == 1 then
|
||
if not QijieStage[this.curLevelId + 1] then
|
||
return
|
||
end
|
||
if this.curLevelId + 1 > this.curMaxStage then
|
||
return
|
||
end
|
||
-- LogRed(this.curMaxStage.." "..this.curLevelId.." "..tostring(this.IsLock))
|
||
if this.curMaxStage == this.curLevelId + 1 then
|
||
this.IsLock = false
|
||
end
|
||
this.curLevelId = this.curLevelId + 1
|
||
end
|
||
-- LogYellow("请求的Id:"..tostring(this.curLevelId))
|
||
NetManager.SevenWorldInfoRequest(this.curLevelId,function ()
|
||
if func then
|
||
func()
|
||
end
|
||
end)
|
||
end
|
||
|
||
function this.CheckQiJieTreasureRedPoint()
|
||
local bool1 = false
|
||
local actInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.QiJieTreasure)
|
||
if not actInfo then
|
||
bool1 = false
|
||
else
|
||
local data = GeneralTreasureMangaer.GetTreasureData(ActivityTypeDef.QiJieTreasure)
|
||
for i = 1, #data.dataList do
|
||
if data.dataList[i].State == 3 or data.dataList[i].State == 2 then
|
||
bool1 = true
|
||
end
|
||
end
|
||
end
|
||
return bool1
|
||
end
|
||
|
||
function this.CheckQiJieRedPoint()
|
||
--判断功能是否开启
|
||
if not ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.QIJIESHILIAN) then
|
||
return false
|
||
end
|
||
--判断世界等级是否够
|
||
local conFigWorldLevel = ConfigManager.GetConfigData(ConfigName.MServerArenaSetting,3).WorldLevel
|
||
if PlayerManager.worldLeve < conFigWorldLevel then --如果世界等级不足
|
||
return false
|
||
end
|
||
-- 跨服相关判断
|
||
-- JumpServerManager.GetWorldArenaInfoRequest(function()
|
||
if not JumpServerManager.GetQiJieIsStart() then
|
||
return false
|
||
elseif not JumpServerManager.GetHightLadderDataIsGroup() then
|
||
return false
|
||
end
|
||
local bool1 = this.CheckQiJieTreasureRedPoint()
|
||
local bool2 = PrivilegeManager.GetPrivilegeRemainValue(3201) > 0 and true or false
|
||
return bool1 or bool2
|
||
-- end)
|
||
end
|
||
|
||
--功能ID,MServerArenaSetting,回调
|
||
function this.CheckQiJieJump(funcType,SettingNum,func)
|
||
--判断功能是否开启
|
||
if not ActTimeCtrlManager.IsQualifiled(funcType) then
|
||
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(funcType))
|
||
return
|
||
end
|
||
--判断世界等级是否够
|
||
local conFigWorldLevel = ConfigManager.GetConfigData(ConfigName.MServerArenaSetting,SettingNum).WorldLevel
|
||
if PlayerManager.worldLeve < conFigWorldLevel then --如果世界等级不足
|
||
PopupTipPanel.ShowTip(string.format("世界等级到达%s后开启!",conFigWorldLevel))
|
||
return
|
||
end
|
||
-- 跨服相关判断
|
||
JumpServerManager.GetWorldArenaInfoRequest(function()
|
||
if not JumpServerManager.GetQiJieIsStart() then
|
||
PopupTipPanel.ShowTip(string.format("开服第%s周开放!",ConfigManager.GetConfigData(ConfigName.MServerArenaSetting,SettingNum).OpenWeek))
|
||
return
|
||
elseif not JumpServerManager.GetHightLadderDataIsGroup() then
|
||
PopupTipPanel.ShowTip("未划分跨服分组,无法参与!")
|
||
return
|
||
end
|
||
if func then
|
||
func()
|
||
end
|
||
end)
|
||
end
|
||
|
||
return QiJieShiLianManager |