c1_lua/lua/app/module/daily_challenge/daily_challenge_manager.lua
2023-05-26 15:43:01 +08:00

81 lines
2.6 KiB
Lua

local DailyChallengeManager = class("DailyChallengeManager", BaseModule)
function DailyChallengeManager:init()
-- body
end
-- 开始挑战
function DailyChallengeManager:startChallenge()
if not DataManager.DailyChallengeData:isEnoughChallengeTime() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
return
end
if not DataManager.DailyChallengeData:isMeetChallenge() then
return
end
if not ModuleManager.FormationManager:formationIsFull() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_8))
return
end
local cost = DataManager.DailyChallengeData:getFightCost()
local vitCostNum = 0
if cost then
vitCostNum = GFunc.getRewardNum(cost)
end
if vitCostNum > DataManager.BagData.ItemData:getVit() then -- 体力不足
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
ModuleManager.CommerceManager:showBuyVitUI()
return
end
local parmas = {}
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeStartReq, parmas, {}, self.rspStartChallenge, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE)
end
function DailyChallengeManager:rspStartChallenge(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.DailyChallengeData:setFixedChapterId(result.today_fixed_chapter_id)
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE)
end
end
-- 挑战结束
function DailyChallengeManager:endChallenge(chapterId, combatReport, taskProgress, heroInfo)
local parmas = {
win = combatReport.victory,
chapter_id = chapterId,
pass_wave = combatReport.wave,
hero_info = heroInfo,
combatReport = combatReport,
}
for fieldName, value in pairs(taskProgress) do
parmas[fieldName] = value
end
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterSettlementReq, parmas, {}, self.endChallengeFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_END)
end
function DailyChallengeManager:endChallengeFinish(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
local reqData = result.reqData
local rewards = result.rewards
ModuleManager.BattleManager:showBattleResultUI(rewards, reqData.combatReport)
-- todo
ModuleManager.TaskManager:addFightTaskProgress(reqData)
end
end
-- 获取波次(战斗)奖励
function DailyChallengeManager:getWaveReward()
-- body
end
-- 获取任务(箱子)奖励
function DailyChallengeManager:getTaskReward(taskId)
-- 跨天通关时,不算完成第二天的任务
end
return DailyChallengeManager