c1_lua/lua/app/module/formation/formation_manager.lua
2025-09-23 19:55:35 +08:00

48 lines
1.6 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local FormationManager = class("FormationManager", BaseModule)
-- 主线编队
function FormationManager:upHeroToStageFormation(heroId, matchType)
local formation = DataManager.FormationData:getStageFormation()
if formation[matchType] == heroId then
return
end
local args = {
id = heroId
}
self:sendMessage(ProtoMsgType.FromMsgEnum.HeroPutOnReq, args, {}, self.upHeroToStageFormationFinish)
end
function FormationManager:upHeroToStageFormationFinish(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.FormationData:initStage(result)
DataManager.HeroData:setDirty()
local data = {}
data.formation, data.formation_lv, data.formation_atk, data.formation_hp = DataManager.FormationData:getStageFormationBIStr()
data.formation_lv = nil
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
if result.reqData then
BIReport:postHeroOpt(result.reqData.id, BIReport.HERO_OPT_TYPE.FORMATION)
end
end
end
-- 竞技场编队
function FormationManager:reqArenaFormation()
local parmas = {
-- 需要五个数据空位用0补齐
attack_heroIds = DataManager.FormationData:getArenaAttackFormation(),-- 进攻编队
defend_heroIds = DataManager.FormationData:getArenaDefendFormation(),-- 防守编队
}
self:sendMessage(ProtoMsgType.FromMsgEnum.PVPHeroesArrayReq, parmas, {}, self.rspArenaFormation, nil)
end
function FormationManager:rspArenaFormation(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
if result.reqData then
DataManager.FormationData:initArena(result.reqData.attack_heroIds, result.reqData.defend_heroIds)
end
end
end
return FormationManager