MCPcopy Create free account
hub / github.com/Card-Forge/forge / loadDeferredSections

Method loadDeferredSections

forge-core/src/main/java/forge/deck/Deck.java:277–328  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 /*

Callers 5

getMainMethod · 0.95
getMethod · 0.95
cloneFieldsToMethod · 0.95
iteratorMethod · 0.95
isEmptyMethod · 0.95

Calls 14

instanceMethod · 0.95
smartValueOfMethod · 0.95
fromCardListMethod · 0.95
putSectionMethod · 0.95
isEmptyMethod · 0.65
equalsMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected