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

Method getCardFromSet

forge-core/src/main/java/forge/StaticData.java:285–314  ·  view source on GitHub ↗

Attempt to retrieve a Card from a target Card Edition if found in any available card database. Note: Collector Number and Art Index will be used in a mutual exclusive fashion, that is: collector number will be tried first, and then artIndex will be used in alternative. If neither of those would corr

(final String cardName, final CardEdition edition,
                                    final String collectorNumber, final int artIndex, boolean isFoil)

Source from the content-addressed store, hash-verified

283 * @return <code>null</code> if no card can be found with the given search parameters.
284 */
285 public PaperCard getCardFromSet(final String cardName, final CardEdition edition,
286 final String collectorNumber, final int artIndex, boolean isFoil) {
287 CardDb.CardRequest cr = CardDb.CardRequest.fromString(cardName); // accounts for any foil request ending with+
288 cr.isFoil = cr.isFoil || isFoil;
289 CardDb targetDb = this.matchTargetCardDb(cr.cardName);
290 if (targetDb == null)
291 return null;
292 // Try with collector number first
293 PaperCard result = targetDb.getCardFromSet(cardName, edition, collectorNumber, cr.isFoil);
294 if (result == null && !collectorNumber.equals(IPaperCard.NO_COLLECTOR_NUMBER)) {
295 if (artIndex != IPaperCard.NO_ART_INDEX) {
296 // So here we know cardName exists (checked before invoking this method)
297 // and also a Collector Number was specified.
298 // The only case we would reach this point is either due to a wrong edition-card match
299 // (later resulting in Unknown card - e.g. "Counterspell|FEM") or due to the fact that
300 // art Index was specified instead of collector number! Let's give it a go with that
301 // but only if artIndex is not NO_ART_INDEX (e.g. collectorNumber = "*32")
302 int maxArtForCard = targetDb.getMaxArtIndex(cardName);
303 if (artIndex <= maxArtForCard) {
304 // if collNr was "78", it's hardly an artIndex. It was just the wrong collNr for the requested card
305 result = targetDb.getCardFromSet(cardName, edition, artIndex, cr.isFoil);
306 }
307 }
308 if (result == null) {
309 // Last chance, try without collector number and see if any match is found
310 result = targetDb.getCardFromSet(cardName, edition, cr.isFoil);
311 }
312 }
313 return result;
314 }
315
316 /**
317 * Retrieves a card from supportedEditions considering current default Card Art Preference,

Callers 1

recogniseCardTokenMethod · 0.95

Calls 5

matchTargetCardDbMethod · 0.95
getCardFromSetMethod · 0.95
getMaxArtIndexMethod · 0.95
fromStringMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected