Skip to content

Commit d2c6b36

Browse files
committed
Try to get find cards in same set first
1 parent 7f9a439 commit d2c6b36

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

forge-core/src/main/java/forge/card/CardDb.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,29 @@ private PaperCard tryGetCard(CardRequest request) {
672672
CardEdition edition = editions.get(reqEditionCode.toUpperCase());
673673

674674
PaperCard cardFromSet = this.getCardFromSet(request.cardName, edition, request.artIndex, request.collectorNumber, request.isFoil);
675-
if(cardFromSet != null && request.flags != null)
675+
if (cardFromSet != null && request.flags != null) {
676676
cardFromSet = cardFromSet.copyWithFlags(request.flags);
677+
}
677678

678-
if (cardFromSet != null)
679+
if (cardFromSet != null) {
679680
return cardFromSet;
681+
}
682+
683+
if (request.artIndex > 0
684+
|| (request.collectorNumber != null && !request.collectorNumber.isEmpty() && !request.collectorNumber.equals(IPaperCard.NO_COLLECTOR_NUMBER))) {
685+
// If request failed, try again without artIndex and collectorNumber to attempt to find from same set first
686+
cardFromSet = this.getCardFromSet(request.cardName, edition, -1, IPaperCard.NO_COLLECTOR_NUMBER, request.isFoil);
687+
if(cardFromSet != null && request.flags != null)
688+
cardFromSet = cardFromSet.copyWithFlags(request.flags);
689+
690+
if (cardFromSet != null) {
691+
return cardFromSet;
692+
}
693+
}
694+
680695
}
681696

697+
682698
// 2. Card lookup in edition with specified filter didn't work.
683699
// So now check whether the cards exist in the DB first,
684700
// and select pick the card based on current SetPreference policy as a fallback

0 commit comments

Comments
 (0)