mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
carddb: support for getting foiled cards
This commit is contained in:
@@ -54,6 +54,7 @@ public final class CardDb {
|
|||||||
private static volatile CardDb commonCards = null; // 'volatile' keyword makes this working
|
private static volatile CardDb commonCards = null; // 'volatile' keyword makes this working
|
||||||
private static volatile CardDb variantCards = null; // 'volatile' keyword makes this working
|
private static volatile CardDb variantCards = null; // 'volatile' keyword makes this working
|
||||||
private final String foilSuffix = " foil";
|
private final String foilSuffix = " foil";
|
||||||
|
private final int foilSuffixLength = foilSuffix.length();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance.
|
* Instance.
|
||||||
@@ -141,7 +142,7 @@ public final class CardDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFoil(final String cardName) {
|
private boolean isFoil(final String cardName) {
|
||||||
return cardName.toLowerCase().endsWith(this.foilSuffix) && (cardName.length() > 5);
|
return cardName.toLowerCase().endsWith(this.foilSuffix) && (cardName.length() > this.foilSuffixLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,7 +152,7 @@ public final class CardDb {
|
|||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public String removeFoilSuffix(final String cardName) {
|
public String removeFoilSuffix(final String cardName) {
|
||||||
return cardName.substring(0, cardName.length() - 5);
|
return cardName.substring(0, cardName.length() - this.foilSuffixLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,7 +173,12 @@ public final class CardDb {
|
|||||||
if (nameWithSet.right == null) {
|
if (nameWithSet.right == null) {
|
||||||
return this.uniqueCards.get(nameWithSet.left);
|
return this.uniqueCards.get(nameWithSet.left);
|
||||||
}
|
}
|
||||||
return tryGetCard(nameWithSet.left, nameWithSet.right);
|
|
||||||
|
CardPrinted res = tryGetCard(nameWithSet.left, nameWithSet.right);
|
||||||
|
if ( null != res && isFoil )
|
||||||
|
return CardPrinted.makeFoiled(res);
|
||||||
|
return res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardPrinted tryGetCard(final String cardName, String setName) {
|
public CardPrinted tryGetCard(final String cardName, String setName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user