223 lines
5.6 KiB
Lua
223 lines
5.6 KiB
Lua
local DailyChallengeData = class("DailyChallengeData", BaseData)
|
||
local TASK_CFG = ConfigManager:getConfig("task_daily_challenge")
|
||
|
||
function DailyChallengeData:init(data)
|
||
data = data or {}
|
||
data = { -- 临时数据
|
||
max_wave = 1,
|
||
today_fixed_chapter_id = 1,
|
||
rand_chapter_daily_id = 1,
|
||
tasks = {
|
||
{
|
||
task_id = 1,
|
||
param = 0,
|
||
progress = 0,
|
||
claimed = false
|
||
},
|
||
{
|
||
task_id = 3,
|
||
param = 0,
|
||
progress = 0,
|
||
claimed = false
|
||
},
|
||
{
|
||
task_id = 8,
|
||
param = 12001,
|
||
progress = 0,
|
||
claimed = false
|
||
}
|
||
},
|
||
buff_id = {1, 11},
|
||
totalFightCount = 0,
|
||
today_challenge_count = 0,
|
||
}
|
||
-- 服务器的初始数据
|
||
self.maxWave = data.max_wave or 0
|
||
self.fixedChapterId = data.today_fixed_chapter_id or 1
|
||
self.chapterDailyId = data.rand_chapter_daily_id or 1
|
||
self.tasks = data.tasks or {}
|
||
self.buffId = data.buff_id or {}
|
||
self.totalFightCount = data.totalFightCount or 0
|
||
self.todayFightCount = data.today_challenge_count or 0
|
||
end
|
||
|
||
function DailyChallengeData:clear()
|
||
end
|
||
|
||
function DailyChallengeData:isOpen()
|
||
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DAILY_CHALLENGE, true)
|
||
end
|
||
|
||
-- 是否满足挑战条件
|
||
function DailyChallengeData:isMeetChallenge()
|
||
return self:isOpen() and self:isEnoughChallengeTime() and self:isEnoughHp()
|
||
end
|
||
|
||
-- 次数是否足够
|
||
function DailyChallengeData:isEnoughChallengeTime()
|
||
return self:getTodayRemainLimitCount() > 0
|
||
end
|
||
|
||
-- 体力是否足够
|
||
function DailyChallengeData:isEnoughHp()
|
||
return true
|
||
end
|
||
|
||
-- 获取今日挑战场景配置
|
||
function DailyChallengeData:getTodayConfig()
|
||
-- body
|
||
end
|
||
|
||
-- 获取今日挑战任务和奖励
|
||
function DailyChallengeData:getTodayTaskAndReward()
|
||
-- 三个任务需要区分类型,如:
|
||
-- 第一个:通关
|
||
-- 第二个:用xxx通关
|
||
-- 第三个:x回合杀怪、x颜色英雄技能释放几次
|
||
end
|
||
|
||
-- 获取今日通关次数
|
||
function DailyChallengeData:getTodayPassNum()
|
||
-- body
|
||
end
|
||
|
||
-- 获取今日增益、负面buff
|
||
function DailyChallengeData:getTodayBuff()
|
||
-- body
|
||
end
|
||
|
||
-- 获取今日剩余时间
|
||
function DailyChallengeData:getTodaySurplusTime()
|
||
-- body
|
||
end
|
||
|
||
-- 获取boss配置数据
|
||
function DailyChallengeData:getBossData(bossId)
|
||
-- body
|
||
end
|
||
|
||
-- 任务是否完成
|
||
function DailyChallengeData:isTaskFinish(index)
|
||
if not self.tasks[index] then
|
||
return false
|
||
end
|
||
return self.tasks[index].claim
|
||
end
|
||
|
||
function DailyChallengeData:getTaskById(taskId)
|
||
for index, taskInfo in ipairs(self.tasks) do
|
||
if taskInfo.task_id == taskId then
|
||
return taskInfo
|
||
end
|
||
end
|
||
|
||
return
|
||
end
|
||
|
||
function DailyChallengeData:canClaimTask(index)
|
||
if not self.tasks[index] then
|
||
return false
|
||
end
|
||
if self.tasks[index].claim then
|
||
return false
|
||
end
|
||
local cfg = self:getTaskCfgInfo(self.tasks[index].taskId)
|
||
if not cfg then
|
||
return false
|
||
end
|
||
|
||
return cfg.number <= self.tasks[index].progress
|
||
end
|
||
|
||
function DailyChallengeData:getTaskProgresss(index)
|
||
if not self.tasks[index] then
|
||
return 0
|
||
end
|
||
return self.tasks[index].progress
|
||
end
|
||
|
||
function DailyChallengeData:getTaskCfgInfo(taskId)
|
||
return TASK_CFG[taskId]
|
||
end
|
||
|
||
function DailyChallengeData:getTaskTotalNumber(taskId)
|
||
if self:getTaskCfgInfo(taskId) then
|
||
return self:getTaskCfgInfo(taskId).number
|
||
else
|
||
return 1 -- 容错,防止报错
|
||
end
|
||
end
|
||
|
||
function DailyChallengeData:getTaskRewards(taskId)
|
||
if self:getTaskCfgInfo(taskId) then
|
||
return self:getTaskCfgInfo(taskId).reward
|
||
end
|
||
return nil
|
||
end
|
||
|
||
function DailyChallengeData:getTaskDesc(taskId, needProgress, customProgress)
|
||
local desc = GConst.EMPTY_STRING
|
||
if not I18N:getConfig("task_daily_challenge")[taskId] then
|
||
return desc
|
||
end
|
||
local taskNum = self:getTaskTotalNumber(taskId)
|
||
if taskId == 7 or taskId == 8 then
|
||
taskNum = taskNum * 100 // GConst.DEFAULT_FACTOR
|
||
end
|
||
desc = I18N:getText("task_daily_challenge", taskId, "desc", taskNum)
|
||
if needProgress then
|
||
local progress = customProgress
|
||
if not progress then
|
||
progress = 0
|
||
local taskInfo = self:getTaskById(taskId)
|
||
if taskInfo then
|
||
progress = taskInfo.progress or 0
|
||
end
|
||
end
|
||
|
||
if taskId == 7 or taskId == 8 then
|
||
progress = progress * 100 // GConst.DEFAULT_FACTOR
|
||
end
|
||
local progressStr = string.format("<color=#5FFF53>(%s%%/%s%%)</color>", progress, taskNum)
|
||
desc = desc + progressStr
|
||
end
|
||
return desc
|
||
end
|
||
|
||
function DailyChallengeData:getFightCost()
|
||
return GFunc.getConstReward("daily_challenge_cost")
|
||
end
|
||
|
||
function DailyChallengeData:getFightLimitCount()
|
||
return GFunc.getConstIntValue("daily_challenge_limit")
|
||
end
|
||
|
||
function DailyChallengeData:getTodayRemainLimitCount()
|
||
local count = self:getFightLimitCount() - self.todayFightCount
|
||
if count < 0 then
|
||
count = 0
|
||
end
|
||
return count
|
||
end
|
||
|
||
function DailyChallengeData:getFixedChapterId()
|
||
return self.fixedChapterId
|
||
end
|
||
|
||
function DailyChallengeData:getChapterDailyId()
|
||
return self.chapterDailyId
|
||
end
|
||
|
||
function DailyChallengeData:setFixedChapterId(id)
|
||
self.fixedChapterId = id
|
||
end
|
||
|
||
function DailyChallengeData:getTotalFightCount()
|
||
return self.totalFightCount
|
||
end
|
||
|
||
function DailyChallengeData:dealTask(taskProgressInfo)
|
||
|
||
end
|
||
|
||
return DailyChallengeData |