diff --git a/lua/app/module/formation/formation_manager.lua b/lua/app/module/formation/formation_manager.lua index 5913278d..2c3852d1 100644 --- a/lua/app/module/formation/formation_manager.lua +++ b/lua/app/module/formation/formation_manager.lua @@ -1,20 +1,21 @@ local FormationManager = class("FormationManager", BaseModule) -- 主线编队 -function FormationManager:upHeroToStageFormation(heroId, matchType) +function FormationManager:upHeroToStageFormation(heroIds, matchType) local formation = DataManager.FormationData:getStageFormation() if formation[matchType] == heroId then return end local args = { - id = heroId + type = 1, + heroes = heroIds } - self:sendMessage(ProtoMsgType.FromMsgEnum.HeroPutOnReq, args, {}, self.upHeroToStageFormationFinish) + self:sendMessage(ProtoMsgType.FromMsgEnum.FormationSetReq, args, {}, self.upHeroToStageFormationFinish) end function FormationManager:upHeroToStageFormationFinish(result) if result.err_code == GConst.ERROR_STR.SUCCESS then - DataManager.FormationData:initStage(result) + DataManager.FormationData:initStage(result.reqData.heroes) DataManager.HeroData:setDirty() local data = {} diff --git a/lua/app/ui/hero/hero_comp.lua b/lua/app/ui/hero/hero_comp.lua index c6c5649d..fa5f038b 100644 --- a/lua/app/ui/hero/hero_comp.lua +++ b/lua/app/ui/hero/hero_comp.lua @@ -143,7 +143,10 @@ function HeroComp:refreshStageFormation() self.curFormation = DataManager.FormationData:getStageFormation() self.onClickUseFunc = function(id, type) - ModuleManager.FormationManager:upHeroToStageFormation(id, type) + local formation = DataManager.FormationData:getStageFormation() + local cfg = DataManager.HeroData:getHeroConfig(id) + formation[cfg.position] = id + ModuleManager.FormationManager:upHeroToStageFormation(formation, type) end self:refreshScrollRect() diff --git a/lua/app/userdata/formation/formation_data.lua b/lua/app/userdata/formation/formation_data.lua index 31d0d867..a76c0a48 100644 --- a/lua/app/userdata/formation/formation_data.lua +++ b/lua/app/userdata/formation/formation_data.lua @@ -26,18 +26,8 @@ end -- 初始化主线阵容 function FormationData:initStage(data) - data = data or {} self.formations = self.formations or {} - - if data.heroes then - local clientFormation = {} - for matchType, heroId in pairs(data.heroes) do - clientFormation[tonumber(matchType)] = heroId - end - self.formations[GConst.BattleConst.FORMATION_TYPE.STAGE] = clientFormation - else - self.formations[GConst.BattleConst.FORMATION_TYPE.STAGE] = {0,0,0,0,0} - end + self.formations[GConst.BattleConst.FORMATION_TYPE.STAGE] = data or {0,0,0,0,0} self:setDirty() end