local Array_Model = {} local private = {} function Array_Model.OnStartup() end function Array_Model.OnShutdown() end function private.SortByQualityAndLevel(a, b) local infoA = MDL.HeroSelect.GetHeroDataById(a.heroId) local infoB = MDL.HeroSelect.GetHeroDataById(b.heroId) -- 按照品质排序 local qualityA = infoA.HeroQuality local qualityB = infoB.HeroQuality if qualityA ~= qualityB then return qualityA < qualityB else --需要优先拆开表格数据 if a.heroLevel ~= b.heroLevel then return a.heroLevel > b.heroLevel else return infoA.Rank < infoB.Rank end end end function Array_Model.SortArrayHeroCell(a, b) local isALineUp = MDL.Player.HeroIsLineUp(a.heroId) local isBLineUp = MDL.Player.HeroIsLineUp(b.heroId) if isALineUp and isBLineUp then return a.Gs > b.Gs elseif isALineUp then return true elseif isBLineUp then return false else return a.Gs > b.Gs end end function Array_Model.HeroIdIndexBeforeAndNow(lastList, id) local nowList = MDL.Player.GetHeroLinUpIds() local last, now = nil, nil for i = 1,6 do if nowList[i] == id then now = i end if lastList[i] == id then last = i end end return last, now end function Array_Model.IsArrayPositionUnlock(index) local arrayList = MDL.Player.GetHeroLinUpIds() if arrayList[index] and arrayList[index] >= 0 then return true else return false end end function Array_Model.GetIndexCellByList(heroId, list) for i = 1, #list do if list[i].heroId == heroId then return i end end return nil end function Array_Model.GetIndexByList(heroId, list) for i = 1, #list do if list[i] == heroId then return i end end return 0 end function Array_Model.CheckArrayUpIdsLegal(arrayUpIds) for i = 1, #arrayUpIds, 2 do if arrayUpIds[i] <= 0 then if arrayUpIds[i + 1] > 0 then arrayUpIds[i] = arrayUpIds[i + 1] arrayUpIds[i + 1] = 0 CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_MainHeroFirst"], UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroNum:GetDataByID(arrayUpIds[i]).NameIDS])) end end end return arrayUpIds end return Array_Model