94 lines
2.8 KiB
Lua
94 lines
2.8 KiB
Lua
local DungeonDailyData = class("DungeonDailyData", BaseData)
|
|
|
|
function DungeonDailyData:ctor()
|
|
self.data.isDirty = false
|
|
end
|
|
|
|
function DungeonDailyData:setDirty()
|
|
self.data.isDirty = not self.data.isDirty
|
|
end
|
|
|
|
function DungeonDailyData:init(data)
|
|
data = data or GConst.EMPTY_TABLE
|
|
local dungeons = data.dungeons or GConst.EMPTY_TABLE
|
|
self.GoldData = require("app/userdata/dungeon/dungeon_gold_data"):create()
|
|
self.GoldData:init(dungeons[GConst.DungeonConst.DUNGEON_DAILY_TYPE.GOLD])
|
|
self.MaterialData = require("app/userdata/dungeon/dungeon_material_data"):create()
|
|
self.MaterialData:init(dungeons[GConst.DungeonConst.DUNGEON_DAILY_TYPE.MATERIAL])
|
|
|
|
DataManager:registerCrossDayFunc("DungeonDailyData", function()
|
|
self.GoldData:onCrossDay()
|
|
self.MaterialData:onCrossDay()
|
|
end)
|
|
end
|
|
|
|
function DungeonDailyData:isOpen(showToast)
|
|
return self.GoldData:isOpen(showToast) or self.MaterialData:isOpen(showToast)
|
|
end
|
|
|
|
function DungeonDailyData:getNotShowModuleKey()
|
|
if not self.GoldData:isOpen() then
|
|
return self.GoldData:getModuleKey()
|
|
end
|
|
if not self.MaterialData:isOpen() then
|
|
return self.MaterialData:getModuleKey()
|
|
end
|
|
return nil
|
|
end
|
|
|
|
function DungeonDailyData:getCurrChallengeChapterId()
|
|
return self.currChallengeChapterId
|
|
end
|
|
|
|
function DungeonDailyData:setCurrChallengeChapterId(id)
|
|
self.currChallengeChapterId = id
|
|
end
|
|
|
|
function DungeonDailyData:getDungeonDailyTypeByChapterId(chapterId)
|
|
local cfg = ConfigManager:getConfig("chapter_dungeon")[chapterId]
|
|
if cfg then
|
|
return cfg.type
|
|
else
|
|
return 1
|
|
end
|
|
end
|
|
|
|
function DungeonDailyData:getChapterMaxWave(chapterId)
|
|
local cfg = ConfigManager:getConfig("chapter_dungeon")[chapterId]
|
|
if cfg then
|
|
return #cfg.wave
|
|
else
|
|
return 1
|
|
end
|
|
end
|
|
|
|
function DungeonDailyData:getChapterName(chapterId)
|
|
return I18N:getConfig("chapter_dungeon")[chapterId].name
|
|
end
|
|
|
|
function DungeonDailyData:onFightDungeonDailyFinish(chapterId, victory)
|
|
if not victory then
|
|
return
|
|
end
|
|
local dungeonDailyType = self:getDungeonDailyTypeByChapterId(chapterId)
|
|
if dungeonDailyType == GConst.DungeonConst.DUNGEON_DAILY_TYPE.GOLD then
|
|
self.GoldData:onFightDungeonDailyFinish(chapterId, victory)
|
|
elseif dungeonDailyType == GConst.DungeonConst.DUNGEON_DAILY_TYPE.MATERIAL then
|
|
self.MaterialData:onFightDungeonDailyFinish(chapterId, victory)
|
|
end
|
|
end
|
|
|
|
function DungeonDailyData:onSweepDungeonDailyFinish(chapterId)
|
|
local dungeonDailyType = self:getDungeonDailyTypeByChapterId(chapterId)
|
|
if dungeonDailyType == GConst.DungeonConst.DUNGEON_DAILY_TYPE.GOLD then
|
|
self.GoldData:onSweepDungeonDailyFinish(chapterId)
|
|
elseif dungeonDailyType == GConst.DungeonConst.DUNGEON_DAILY_TYPE.MATERIAL then
|
|
self.MaterialData:onSweepDungeonDailyFinish(chapterId)
|
|
end
|
|
end
|
|
|
|
function DungeonDailyData:getIsShowRedPoint()
|
|
return self.GoldData:getIsShowRedPoint() or self.MaterialData:getIsShowRedPoint()
|
|
end
|
|
|
|
return DungeonDailyData |