Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions forge-core/src/main/java/forge/card/CardDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ public void loadCard(String cardName, String setCode, CardRules cr) {
return;
}
}
// addSetCard appends unconditionally, so skip if this card's printing from this set
// is already loaded (presence in other sets isn't enough — loadCard also adds new-set printings)
CardEdition guardEd = editions.get(setCode);
if (guardEd != null && !guardEd.equals(CardEdition.UNKNOWN) && hasPrintingInSet(cr, guardEd)) {
return;
}
boolean reIndexNecessary = false;
CardEdition ed = editions.get(setCode);
if (ed == null || ed.equals(CardEdition.UNKNOWN)) {
Expand All @@ -462,6 +468,18 @@ public void loadCard(String cardName, String setCode, CardRules cr) {
}
}

/** True if a printing of this card from edition is already loaded (no side effects, unlike getCardFromSet). */
private boolean hasPrintingInSet(CardRules cr, CardEdition edition) {
String code1 = edition.getCode(), code2 = edition.getCode2();
for (PaperCard pc : getAllCards(cr)) {
String ed = pc.getEdition();
if (ed.equalsIgnoreCase(code1) || ed.equalsIgnoreCase(code2)) {
return true;
}
}
return false;
}

public void initialize(boolean logMissingPerEdition, boolean logMissingSummary, boolean enableUnknownCards) {
Set<String> allMissingCards = new LinkedHashSet<>();
List<String> missingCards = new ArrayList<>();
Expand Down