102 lines
3.3 KiB
Lua
102 lines
3.3 KiB
Lua
local DailyChallengeManager = class("DailyChallengeManager", BaseModule)
|
|
|
|
function DailyChallengeManager:init()
|
|
-- body
|
|
end
|
|
|
|
function DailyChallengeManager:showBattleBuffUI()
|
|
UIManager:showUI("app/ui/battle/battle_daily_challenge_buff_ui")
|
|
end
|
|
|
|
function DailyChallengeManager:getBuffDesc(id)
|
|
local desc = I18N:getText("buff_daily_challenge", id, "desc")
|
|
return desc
|
|
end
|
|
|
|
-- 开始挑战
|
|
function DailyChallengeManager:startChallenge()
|
|
Logger.logHighlight("开始每日挑战")
|
|
-- 判断次数
|
|
if not DataManager.DailyChallengeData:isEnoughChallengeTime() then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
|
|
return
|
|
end
|
|
|
|
-- 判断体力
|
|
if not DataManager.DailyChallengeData:isEnoughHp() then
|
|
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
|
|
ModuleManager.CommerceManager:showBuyVitUI()
|
|
return
|
|
end
|
|
|
|
-- 检查阵容
|
|
if not ModuleManager.FormationManager:formationIsFull() then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_8))
|
|
return
|
|
end
|
|
|
|
if not DataManager.DailyChallengeData:isMeetChallenge() then
|
|
return
|
|
end
|
|
|
|
local cost = DataManager.DailyChallengeData:getChallengeHpCost()
|
|
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, lastBossRound)
|
|
local parmas = {
|
|
win = combatReport.victory,
|
|
chapter_id = chapterId,
|
|
pass_wave = combatReport.wave,
|
|
hero_info = heroInfo,
|
|
kills_boss_turn = lastBossRound,
|
|
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)
|
|
DataManager.DailyChallengeData:init(result.daily_challenge)
|
|
|
|
ModuleManager.TaskManager:addFightTaskProgress(reqData)
|
|
end
|
|
end
|
|
|
|
-- 获取波次(战斗)奖励
|
|
function DailyChallengeManager:getWaveReward()
|
|
-- body
|
|
end
|
|
|
|
-- 获取任务(箱子)奖励
|
|
function DailyChallengeManager:getTaskReward(taskId)
|
|
-- 跨天通关时,不算完成第二天的任务
|
|
end
|
|
|
|
return DailyChallengeManager |