diff --git a/src/main/java/forge/item/CardDb.java b/src/main/java/forge/item/CardDb.java index 342f9d230bc..35a7ca5f4dd 100644 --- a/src/main/java/forge/item/CardDb.java +++ b/src/main/java/forge/item/CardDb.java @@ -54,6 +54,7 @@ public final class CardDb { private static volatile CardDb commonCards = null; // 'volatile' keyword makes this working private static volatile CardDb variantCards = null; // 'volatile' keyword makes this working private final String foilSuffix = " foil"; + private final int foilSuffixLength = foilSuffix.length(); /** * Instance. @@ -141,7 +142,7 @@ public final class CardDb { } 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 */ 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) { 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) {