2021-05-11 17:23:19 +08:00
|
|
|
PracticeManager = {}
|
|
|
|
local this = PracticeManager
|
2021-05-13 17:37:47 +08:00
|
|
|
local XiuXianConfig = ConfigManager.GetConfig(ConfigName.XiuXianConfig)
|
2021-05-12 17:40:38 +08:00
|
|
|
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
2021-05-13 17:37:47 +08:00
|
|
|
local XiuXianSkillConfig = ConfigManager.GetConfig(ConfigName.XiuXianSkillConfig)
|
2021-05-13 21:03:27 +08:00
|
|
|
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
2021-05-11 17:23:19 +08:00
|
|
|
|
|
|
|
function this.Initialize()
|
2021-05-13 17:37:47 +08:00
|
|
|
this.PracticeLevel = 1--小境界id
|
|
|
|
this.PracticeBigLevel = 1--大境界数
|
|
|
|
this.StarNum = 0--星星的数量
|
|
|
|
-- this.PracticeConfigData = {}
|
|
|
|
this.ImprintServerData = {}--服务器发来的神印信息
|
|
|
|
this.BigLevelImprintList = {}--大境界对应的神印
|
2021-05-11 17:23:19 +08:00
|
|
|
end
|
2021-05-12 10:35:58 +08:00
|
|
|
--从服务器更新当前修行等级
|
2021-05-12 20:53:34 +08:00
|
|
|
function this.UpdataFromServer(_level)
|
|
|
|
this.PracticeLevel = _level
|
|
|
|
this.PracticeLevel = this.PracticeLevel > 0 and this.PracticeLevel or 1
|
2021-05-13 17:37:47 +08:00
|
|
|
this.PracticeBigLevel = XiuXianConfig[this.PracticeLevel].RealmId
|
2021-05-11 17:23:19 +08:00
|
|
|
this.StarNum = PlayerManager.level
|
|
|
|
end
|
|
|
|
|
2021-05-12 10:35:58 +08:00
|
|
|
--获取当前等级表数据
|
|
|
|
function this.GetCurConfigData()
|
2021-05-13 17:37:47 +08:00
|
|
|
return XiuXianConfig[this.PracticeLevel]
|
2021-05-12 10:35:58 +08:00
|
|
|
end
|
|
|
|
|
2021-05-12 20:53:34 +08:00
|
|
|
function this.BuildAddTemplate()
|
|
|
|
local TemplateList = {}
|
|
|
|
for _, configInfo in ConfigPairs(PropertyConfig) do
|
|
|
|
if configInfo.IfShow == 1 or configInfo.IfShow == 2 then
|
|
|
|
TemplateList[configInfo.PropertyId] = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return TemplateList
|
|
|
|
end
|
|
|
|
|
2021-05-12 10:35:58 +08:00
|
|
|
--获取每一小点属性加成
|
|
|
|
function this.GetSinglePointAdd()
|
|
|
|
local singlePointAddList = {}
|
2021-05-13 17:37:47 +08:00
|
|
|
local TotalPros = XiuXianConfig[this.PracticeLevel].TotalPros
|
2021-05-12 10:35:58 +08:00
|
|
|
for i = 1, #TotalPros do
|
|
|
|
if not singlePointAddList[TotalPros[i][1]] then
|
|
|
|
singlePointAddList[TotalPros[i][1]] = 0
|
|
|
|
end
|
|
|
|
singlePointAddList[TotalPros[i][1]] = TotalPros[i][2]
|
|
|
|
end
|
|
|
|
return singlePointAddList
|
|
|
|
end
|
|
|
|
|
|
|
|
--获取当前获得的所有属性相加
|
|
|
|
function this.GetCurAllGetAdd()
|
2021-05-12 20:53:34 +08:00
|
|
|
local PropertyList = this.BuildAddTemplate()
|
2021-05-12 10:35:58 +08:00
|
|
|
for i = 1, this.PracticeLevel do
|
2021-05-13 17:37:47 +08:00
|
|
|
-- LogPink("i:"..tostring(i))
|
|
|
|
if XiuXianConfig[i].TotalPros then
|
|
|
|
local Pros = XiuXianConfig[i].TotalPros
|
|
|
|
-- LogGreen("#Pros:"..tostring(#Pros))
|
2021-05-12 20:53:34 +08:00
|
|
|
for i = 1, #Pros do
|
2021-05-13 17:37:47 +08:00
|
|
|
-- LogBlue("ProsId:"..tostring(Pros[i][1]).." ProsNum:"..tostring(Pros[i][2]))
|
2021-05-13 21:03:27 +08:00
|
|
|
if PropertyConfig[Pros[i][1]].Style == 1 then
|
|
|
|
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]
|
|
|
|
elseif PropertyConfig[Pros[i][1]].Style == 2 then
|
|
|
|
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]/100
|
|
|
|
end
|
2021-05-12 20:53:34 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return PropertyList
|
|
|
|
end
|
|
|
|
|
2021-05-13 17:37:47 +08:00
|
|
|
--获取各个大境界中所有小属性加成的总和 +模板的
|
2021-05-12 20:53:34 +08:00
|
|
|
function this.GetAddsListWithTemplate()
|
|
|
|
local PropertyList = this.BuildAddTemplate()
|
|
|
|
local addsList = {}
|
2021-05-13 17:37:47 +08:00
|
|
|
for i, v in ConfigPairs(XiuXianConfig) do
|
2021-05-12 20:53:34 +08:00
|
|
|
if v.TotalPros then
|
|
|
|
local Pros = v.TotalPros
|
|
|
|
for i = 1, #Pros do
|
2021-05-13 21:03:27 +08:00
|
|
|
if PropertyConfig[Pros[i][1]].Style == 1 then
|
|
|
|
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]
|
|
|
|
elseif PropertyConfig[Pros[i][1]].Style == 2 then
|
|
|
|
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]/100
|
|
|
|
end
|
2021-05-12 10:35:58 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-05-12 20:53:34 +08:00
|
|
|
return PropertyList
|
2021-05-12 10:35:58 +08:00
|
|
|
end
|
|
|
|
|
2021-05-13 17:37:47 +08:00
|
|
|
--获取各个大境界中所有小属性加成的总和 不加模板的
|
2021-05-12 20:53:34 +08:00
|
|
|
function this.GetAddsListWithOutTemplate()
|
2021-05-12 10:35:58 +08:00
|
|
|
local addsList = {}
|
2021-05-13 17:37:47 +08:00
|
|
|
for i, v in ConfigPairs(XiuXianConfig) do
|
2021-05-12 10:35:58 +08:00
|
|
|
if not addsList[v.RealmId] then
|
|
|
|
addsList[v.RealmId] = {}
|
|
|
|
end
|
2021-05-12 17:40:38 +08:00
|
|
|
if v.TotalPros then
|
|
|
|
local Pros = v.TotalPros
|
|
|
|
for i = 1, #Pros do
|
|
|
|
if not addsList[v.RealmId][Pros[i][1]] then
|
|
|
|
addsList[v.RealmId][Pros[i][1]] = 0
|
|
|
|
end
|
2021-05-13 21:03:27 +08:00
|
|
|
if PropertyConfig[Pros[i][1]].Style == 1 then
|
|
|
|
addsList[v.RealmId][Pros[i][1]] = addsList[v.RealmId][Pros[i][1]] + Pros[i][2]
|
|
|
|
elseif PropertyConfig[Pros[i][1]].Style == 2 then
|
|
|
|
addsList[v.RealmId][Pros[i][1]] = addsList[v.RealmId][Pros[i][1]] + Pros[i][2]/100
|
|
|
|
end
|
2021-05-12 10:35:58 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return addsList
|
|
|
|
end
|
|
|
|
|
2021-05-12 17:40:38 +08:00
|
|
|
--获取预览界面数据
|
|
|
|
function this.GetPreViewData()
|
2021-05-12 20:53:34 +08:00
|
|
|
local AddListData = this.GetAddsListWithOutTemplate()
|
2021-05-12 17:40:38 +08:00
|
|
|
local previewList = {}
|
|
|
|
for i = 2, #AddListData do
|
|
|
|
local data = {}
|
|
|
|
local configData = ConfigManager.GetConfigDataByKey(ConfigName.XiuXianConfig,"RealmId",i)
|
|
|
|
data.RealmName = configData.RealmName
|
|
|
|
data.RealmDesc = configData.RealmDesc
|
|
|
|
data.IsActive = this.PracticeBigLevel >= i
|
|
|
|
data.AddList = AddListData[i]
|
|
|
|
table.insert(previewList,data)
|
|
|
|
end
|
|
|
|
return previewList
|
|
|
|
end
|
|
|
|
|
2021-05-13 17:37:47 +08:00
|
|
|
--返回预览界面文字
|
2021-05-12 17:40:38 +08:00
|
|
|
function this.GetPreviewSingleText(id,value)
|
2021-05-13 21:03:27 +08:00
|
|
|
if PropertyConfig[id].Style == 1 then
|
|
|
|
return string.format("全体神将%s+%s",PropertyConfig[id].Info,value)
|
|
|
|
elseif PropertyConfig[id].Style == 2 then
|
|
|
|
return string.format("全体神将%s+%s",PropertyConfig[id].Info,value).."%"
|
|
|
|
end
|
2021-05-12 17:40:38 +08:00
|
|
|
end
|
|
|
|
|
2021-05-13 17:37:47 +08:00
|
|
|
--获取所有神印信息
|
|
|
|
function this.GetAllImprintData()
|
|
|
|
local AllImprintList = {}
|
|
|
|
for i, v in ConfigPairs(XiuXianConfig) do
|
|
|
|
if v.TeamSkill then
|
|
|
|
table.insert(AllImprintList,v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return AllImprintList
|
|
|
|
end
|
|
|
|
|
|
|
|
--服务器发来的神印信息
|
|
|
|
function this.UpdataImprintDataFromServer(_imprintList)
|
|
|
|
this.BigLevelWithImprint()--初始化大境界对应的神印
|
|
|
|
for key, value in pairs(_imprintList) do
|
|
|
|
if value and value.id then
|
|
|
|
if not this.ImprintServerData[value.id] then
|
|
|
|
this.ImprintServerData[value.id] = {}
|
|
|
|
end
|
|
|
|
this.ImprintServerData[value.id].type = value.type
|
|
|
|
this.ImprintServerData[value.id].subId = value.subId
|
|
|
|
this.ImprintServerData[value.id].state = value.state
|
|
|
|
if value.state == 1 then
|
|
|
|
this.BigLevelImprintList[XiuXianSkillConfig[value.id].UnlockId] = value.id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--初始化大境界对应的神印
|
|
|
|
function this.BigLevelWithImprint()
|
|
|
|
for i, v in ConfigPairs(XiuXianSkillConfig) do
|
|
|
|
if v.UnlockId > 0 then
|
|
|
|
this.BigLevelImprintList[v.UnlockId] = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--获取单个神印的信息(服务器+表)
|
|
|
|
function this.GetSingleImprintData(id)
|
|
|
|
if this.ImprintServerData[id] then
|
|
|
|
return this.ImprintServerData[id],XiuXianSkillConfig[id]
|
|
|
|
else
|
|
|
|
return nil,XiuXianSkillConfig[id]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-11 17:23:19 +08:00
|
|
|
return PracticeManager
|