mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
Encode collector number + fallback
This commit is contained in:
@@ -9,6 +9,8 @@ import forge.item.IPaperCard;
|
|||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
public class ImageUtil {
|
public class ImageUtil {
|
||||||
public static float getNearestHQSize(float baseSize, float actualSize) {
|
public static float getNearestHQSize(float baseSize, float actualSize) {
|
||||||
//get nearest power of actualSize to baseSize so that the image renders good
|
//get nearest power of actualSize to baseSize so that the image renders good
|
||||||
@@ -100,7 +102,7 @@ public class ImageUtil {
|
|||||||
|
|
||||||
if (includeSet) {
|
if (includeSet) {
|
||||||
String editionAliased = isDownloadUrl ? StaticData.instance().getEditions().getCode2ByCode(edition) : ImageKeys.getSetFolder(edition);
|
String editionAliased = isDownloadUrl ? StaticData.instance().getEditions().getCode2ByCode(edition) : ImageKeys.getSetFolder(edition);
|
||||||
if (editionAliased == "") //FIXME: Custom Cards Workaround
|
if (editionAliased.isEmpty()) //FIXME: Custom Cards Workaround
|
||||||
editionAliased = edition;
|
editionAliased = edition;
|
||||||
return TextUtil.concatNoSpace(editionAliased, "/", fname);
|
return TextUtil.concatNoSpace(editionAliased, "/", fname);
|
||||||
} else {
|
} else {
|
||||||
@@ -164,7 +166,7 @@ public class ImageUtil {
|
|||||||
|
|
||||||
public static String getScryfallDownloadUrl(PaperCard cp, String face, String setCode, String langCode, boolean useArtCrop, boolean hyphenateAlchemy){
|
public static String getScryfallDownloadUrl(PaperCard cp, String face, String setCode, String langCode, boolean useArtCrop, boolean hyphenateAlchemy){
|
||||||
String editionCode;
|
String editionCode;
|
||||||
if ((setCode != null) && (setCode.length() > 0))
|
if (setCode != null && !setCode.isEmpty())
|
||||||
editionCode = setCode;
|
editionCode = setCode;
|
||||||
else
|
else
|
||||||
editionCode = cp.getEdition().toLowerCase();
|
editionCode = cp.getEdition().toLowerCase();
|
||||||
@@ -199,7 +201,17 @@ public class ImageUtil {
|
|||||||
// Hanweir Garrison EMN already has a appended.
|
// Hanweir Garrison EMN already has a appended.
|
||||||
cardCollectorNumber += face.equals("back") ? "b" : "a";
|
cardCollectorNumber += face.equals("back") ? "b" : "a";
|
||||||
}
|
}
|
||||||
return String.format("%s/%s/%s?format=image&version=%s%s", editionCode, cardCollectorNumber,
|
|
||||||
|
String cardCollectorNumberEncoded;
|
||||||
|
try {
|
||||||
|
cardCollectorNumberEncoded = URLEncoder.encode(cardCollectorNumber, "UTF-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Unlikely, for the possibility that "UTF-8" is not supported.
|
||||||
|
System.err.println("UTF-8 encoding not supported on this device.");
|
||||||
|
cardCollectorNumberEncoded = cardCollectorNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.format("%s/%s/%s?format=image&version=%s%s", editionCode, cardCollectorNumberEncoded,
|
||||||
langCode, versionParam, faceParam);
|
langCode, versionParam, faceParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user