128 lines
4.9 KiB
Lua
128 lines
4.9 KiB
Lua
GeneralTreasureMangaer = {}
|
|
local this = GeneralTreasureMangaer
|
|
|
|
function this.Initialize()
|
|
this.TreasureList = {
|
|
[ActivityTypeDef.QiJieTreasure] = {ActId = 0,endTime = 0,dataList = {},configName = ConfigName.QijieTreasure,itemId = 1242},
|
|
}
|
|
this.InitConfigData()
|
|
end
|
|
|
|
function this.InitConfigData()
|
|
for k,v in pairs(this.TreasureList) do
|
|
for _, configInfo in ConfigPairs(ConfigManager.GetConfig(v.configName)) do
|
|
if configInfo.Id then
|
|
local data = {}
|
|
data.Id = configInfo.Id
|
|
if configInfo.Level then
|
|
data.Level = configInfo.Level
|
|
end
|
|
if configInfo.Integral then
|
|
data.Integral = configInfo.Integral
|
|
end
|
|
if configInfo.Reward then
|
|
data.Reward = configInfo.Reward
|
|
end
|
|
if configInfo.TreasureReward then
|
|
data.TreasureReward = configInfo.TreasureReward
|
|
end
|
|
if configInfo.Level then
|
|
data.Level = configInfo.Level
|
|
end
|
|
data.State = -1
|
|
data.Progress = -1
|
|
data.oData = {}
|
|
v.dataList[data.Id] = data
|
|
end
|
|
end
|
|
table.sort(v.dataList,function (a,b)
|
|
return a.Id < b.Id
|
|
end)
|
|
end
|
|
end
|
|
|
|
function this.GetTreasureData(ActType)
|
|
this.curType = ActType
|
|
local actInfo = ActivityGiftManager.GetActivityTypeInfo(ActType)
|
|
if not actInfo then
|
|
PopupTipPanel.ShowTip("活动暂未开启。")
|
|
return
|
|
end
|
|
local curTypeData = this.TreasureList[ActType]
|
|
curTypeData.ActId = actInfo.activityId
|
|
curTypeData.endTime = actInfo.endTime
|
|
curTypeData.value = BagManager.GetTotalItemNum(curTypeData.itemId)
|
|
curTypeData.treasureState = 0
|
|
for k,v in pairs(actInfo.mission) do
|
|
if v.missionId == -1 then
|
|
curTypeData.treasureState = v.state
|
|
break
|
|
end
|
|
end
|
|
|
|
if ActType == 0 then
|
|
-- body
|
|
else--一般秘宝按钮状态
|
|
--4 未达成 3 可再次领取 2 可领取 1 已领取 -1 完美领取(充钱领取过的)
|
|
for k,v in pairs(actInfo.mission) do
|
|
if v.missionId and v.missionId > 0 then
|
|
if v.state == 0 then
|
|
if curTypeData.dataList[v.missionId].Integral[1][2] <= curTypeData.value then
|
|
curTypeData.dataList[v.missionId].State = 2--未领取
|
|
else
|
|
curTypeData.dataList[v.missionId].State = 4--未达成
|
|
end
|
|
elseif v.state == 1 then
|
|
if curTypeData.treasureState == 0 then
|
|
curTypeData.dataList[v.missionId].State = 1--不完美领取但不能领
|
|
else
|
|
curTypeData.dataList[v.missionId].State = 3--不完美领取可继续领
|
|
end
|
|
elseif v.state == -1 then
|
|
curTypeData.dataList[v.missionId].State = -1--完美领取
|
|
end
|
|
curTypeData.dataList[v.missionId].Progress = v.progress
|
|
end
|
|
end
|
|
end
|
|
return curTypeData
|
|
end
|
|
|
|
function this.GetAllRewardData()
|
|
local directData = {}
|
|
local indirectData = {}
|
|
local tempScore = BagManager.GetTotalItemNum(this.TreasureList[this.curType].itemId)
|
|
local config = ConfigManager.GetConfigDataByKey(ConfigName.RechargeCommodityConfig,"Id",108)
|
|
for i = 1,#config.BaseReward do
|
|
if config.BaseReward[i][1] == this.TreasureList[this.curType].itemId then
|
|
tempScore = tempScore + config.BaseReward[i][2]
|
|
end
|
|
end
|
|
for k,v in ConfigPairs(ConfigManager.GetConfig(this.TreasureList[this.curType].configName)) do
|
|
if tempScore >= v.Integral[1][2] then
|
|
for i = 1, #v.Reward do
|
|
if this.TreasureList[this.curType].dataList[v.Id].State ~= 3 then
|
|
if not directData[v.Reward[i][1]] then
|
|
directData[v.Reward[i][1]] = 0
|
|
end
|
|
directData[v.Reward[i][1]] = directData[v.Reward[i][1]] + v.Reward[i][2]
|
|
end
|
|
end
|
|
for i = 1, #v.TreasureReward do
|
|
if not directData[v.TreasureReward[i][1]] then
|
|
directData[v.TreasureReward[i][1]] = 0
|
|
end
|
|
directData[v.TreasureReward[i][1]] = directData[v.TreasureReward[i][1]] + v.TreasureReward[i][2]
|
|
end
|
|
end
|
|
for i = 1, #v.TreasureReward do
|
|
if not indirectData[v.TreasureReward[i][1]] then
|
|
indirectData[v.TreasureReward[i][1]] = 0
|
|
end
|
|
indirectData[v.TreasureReward[i][1]] = indirectData[v.TreasureReward[i][1]] + v.TreasureReward[i][2]
|
|
end
|
|
end
|
|
return directData,indirectData
|
|
end
|
|
|
|
return GeneralTreasureMangaer |