50 lines
1.5 KiB
Lua
50 lines
1.5 KiB
Lua
local FormationManager = class("FormationManager", BaseModule)
|
|
|
|
function FormationManager:upHeroToStageFormation(heroId, matchType)
|
|
local formation = DataManager.FormationData:getStageFormation()
|
|
if formation[matchType] == heroId then
|
|
return
|
|
end
|
|
local args = {
|
|
-- formationType = GConst.BattleConst.BATTLE_TYPE.STAGE,
|
|
-- matchType = matchType,
|
|
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:init(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)
|
|
BIReport:postHeroOpt(result.reqData.id, BIReport.HERO_OPT_TYPE.FORMATION)
|
|
end
|
|
end
|
|
|
|
function FormationManager:formationIsFull()
|
|
local actvieMap = DataManager.HeroData:getMatchActiveHeroMap()
|
|
local formation = DataManager.FormationData:getStageFormation()
|
|
local count = 0
|
|
for matchtype = 1, GConst.BattleConst.ELEMENT_TYPE_COUNT do
|
|
if not formation[matchtype] or formation[matchtype] <= 0 then
|
|
if actvieMap[matchtype] and table.nums(actvieMap[matchtype]) > 0 then
|
|
return false
|
|
end
|
|
else
|
|
count = count + 1
|
|
end
|
|
end
|
|
|
|
if count <= 0 then
|
|
return false
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
return FormationManager |