37 lines
1.1 KiB
Lua
37 lines
1.1 KiB
Lua
local ChapterManager = class("ChapterManager", BaseModule)
|
|
|
|
function ChapterManager:startFight()
|
|
---- 通信
|
|
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE)
|
|
end
|
|
|
|
function ChapterManager:endFight(id, combatReport)
|
|
local cfg = ConfigManager:getConfig("chapter")[id]
|
|
local rewards = {}
|
|
for i = 1, combatReport.wave do
|
|
for _, reward in ipairs(cfg.wave_reward) do
|
|
table.insert(rewards, reward)
|
|
end
|
|
end
|
|
|
|
if combatReport.victory then
|
|
for _, reward in ipairs(cfg.finish_reward) do
|
|
table.insert(rewards, reward)
|
|
end
|
|
end
|
|
|
|
local parmas = {
|
|
id = id,
|
|
combatReport = combatReport,
|
|
rewards = GFunc.mergeRewards(rewards)
|
|
}
|
|
ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.END_FIGHT, parmas, function(result)
|
|
if result.status == 0 then
|
|
GFunc.addRewards(result.rewards, BIReport.ITEM_GET_TYPE.FIGHT_END)
|
|
ModuleManager.BattleManager:showBattleResultUI(parmas.rewards, combatReport)
|
|
DataManager.ChapterData:init(result.chapterData)
|
|
end
|
|
end)
|
|
end
|
|
|
|
return ChapterManager |