()
| 275 | } |
| 276 | |
| 277 | private void loadDeferredSections() { |
| 278 | if (deferredSections == null && loadedSections == null) |
| 279 | return; |
| 280 | |
| 281 | if (loadedSections != null && !includeCardsFromUnspecifiedSet) |
| 282 | return; // deck loaded, and does not include ANY card with no specified edition: all good! |
| 283 | |
| 284 | String cardArtPreference = StaticData.instance().getCardArtPreferenceName(); |
| 285 | boolean smartCardArtSelection = StaticData.instance().isEnabledCardArtSmartSelection(); |
| 286 | |
| 287 | if (lastCardArtOptimisationOptionUsed == null) // first time here |
| 288 | lastCardArtOptimisationOptionUsed = smartCardArtSelection; |
| 289 | |
| 290 | if (loadedSections != null && cardArtPreference.equals(lastCardArtPreferenceUsed) && |
| 291 | lastCardArtOptimisationOptionUsed == smartCardArtSelection) |
| 292 | return; // deck loaded already - card with no set have been found, but no change since last time: all good! |
| 293 | |
| 294 | Map<String, List<String>> referenceDeckLoadingMap; |
| 295 | if (deferredSections != null) { |
| 296 | this.normalizeDeferredSections(); |
| 297 | referenceDeckLoadingMap = new HashMap<>(this.deferredSections); |
| 298 | } else |
| 299 | referenceDeckLoadingMap = new HashMap<>(loadedSections); |
| 300 | |
| 301 | loadedSections = new HashMap<>(); |
| 302 | lastCardArtPreferenceUsed = cardArtPreference; |
| 303 | lastCardArtOptimisationOptionUsed = smartCardArtSelection; |
| 304 | Map<DeckSection, ArrayList<String>> cardsWithNoEdition = null; |
| 305 | if (smartCardArtSelection) |
| 306 | cardsWithNoEdition = new EnumMap<>(DeckSection.class); |
| 307 | |
| 308 | for (Entry<String, List<String>> s : referenceDeckLoadingMap.entrySet()) { |
| 309 | // first thing, update loaded section |
| 310 | loadedSections.put(s.getKey(), s.getValue()); |
| 311 | DeckSection sec = DeckSection.smartValueOf(s.getKey()); |
| 312 | if (sec == null) |
| 313 | continue; |
| 314 | final List<String> cardsInSection = s.getValue(); |
| 315 | ArrayList<String> cardNamesWithNoEdition = getAllCardNamesWithNoSpecifiedEdition(cardsInSection); |
| 316 | if (!cardNamesWithNoEdition.isEmpty()) { |
| 317 | includeCardsFromUnspecifiedSet = true; |
| 318 | if (smartCardArtSelection) |
| 319 | cardsWithNoEdition.put(sec, cardNamesWithNoEdition); |
| 320 | } |
| 321 | |
| 322 | CardPool pool = CardPool.fromCardList(cardsInSection); |
| 323 | putSection(sec, pool); |
| 324 | } |
| 325 | deferredSections = null; // set to null, just in case! |
| 326 | if (includeCardsFromUnspecifiedSet && smartCardArtSelection) |
| 327 | optimiseCardArtSelectionInDeckSections(cardsWithNoEdition); |
| 328 | } |
| 329 | |
| 330 | private void normalizeDeferredSections() { |
| 331 | /* |
no test coverage detected