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

Method initialize

forge-core/src/main/java/forge/card/CardDb.java:465–540  ·  view source on GitHub ↗
(boolean logMissingPerEdition, boolean logMissingSummary, boolean enableUnknownCards)

Source from the content-addressed store, hash-verified

463 }
464
465 public void initialize(boolean logMissingPerEdition, boolean logMissingSummary, boolean enableUnknownCards) {
466 Set<String> allMissingCards = new LinkedHashSet<>();
467 List<String> missingCards = new ArrayList<>();
468 CardEdition upcomingSet = null;
469 Date today = new Date();
470
471 for (CardEdition e : editions.getOrderedEditions()) {
472 boolean coreOrExpSet = e.getType() == CardEdition.Type.CORE || e.getType() == CardEdition.Type.EXPANSION;
473 boolean isCoreExpSet = coreOrExpSet || e.getType() == CardEdition.Type.REPRINT;
474 if (logMissingPerEdition && isCoreExpSet) {
475 System.out.print(e.getName() + " (" + e.getAllCardsInSet().size() + " cards)");
476 }
477 if (coreOrExpSet && e.getDate().after(today) && upcomingSet == null) {
478 upcomingSet = e;
479 }
480
481 for (CardEdition.EditionEntry cis : e.getAllCardsInSet()) {
482 CardRules cr = rulesByPrimaryName.get(cis.name());
483 if (cr == null)
484 cr = rulesByAltName.get(cis.name()); //Entry written using a flavor name
485 if (cr == null) {
486 missingCards.add(cis.name());
487 continue;
488 }
489 if (cr.hasFunctionalVariants()) {
490 if (StringUtils.isNotEmpty(cis.getFunctionalVariantName())
491 && !cr.getSupportedFunctionalVariants().contains(cis.getFunctionalVariantName())) {
492 //Supported card, unsupported variant.
493 //Could note the card as missing but since these are often un-cards,
494 //it's likely absent because it does something out of scope.
495 continue;
496 }
497 }
498 addSetCard(e, cis, cr);
499 }
500 if (isCoreExpSet && logMissingPerEdition) {
501 if (missingCards.isEmpty()) {
502 System.out.println(" ... 100% ");
503 } else {
504 int missing = (e.getAllCardsInSet().size() - missingCards.size()) * 10000 / e.getAllCardsInSet().size();
505 System.out.printf(" ... %.2f%% (%s missing: %s)%n", missing * 0.01f, Lang.nounWithAmount(missingCards.size(), "card"), StringUtils.join(missingCards, " | "));
506 }
507 }
508 if (isCoreExpSet && logMissingSummary) {
509 allMissingCards.addAll(missingCards);
510 }
511 missingCards.clear();
512 artIds.clear();
513 }
514
515 if (logMissingSummary) {
516 System.out.printf("Totally %d cards not implemented: %s\n", allMissingCards.size(), StringUtils.join(allMissingCards, " | "));
517 }
518
519 if (upcomingSet != null) {
520 System.err.println("Upcoming set " + upcomingSet + " dated in the future. All `upcoming` cards will be added to this set with unknown rarity.");
521 }
522

Callers

nothing calls this directly

Calls 15

hasFunctionalVariantsMethod · 0.95
addSetCardMethod · 0.95
nounWithAmountMethod · 0.95
containsMethod · 0.95
getNameMethod · 0.95
isCustomMethod · 0.95
getPathMethod · 0.95
addCardMethod · 0.95
getCodeMethod · 0.95
reIndexMethod · 0.95
getOrderedEditionsMethod · 0.80

Tested by

no test coverage detected