update getImageType() to work only with IRenderableCard.

master
lodici 2016-10-12 18:21:43 +01:00
parent 18afab644e
commit 7d893ff28d
3 changed files with 12 additions and 5 deletions

View File

@ -140,4 +140,8 @@ public interface IRenderableCard {
default long getRenderKey() {
return getCardDefinition().getDistinctName().hashCode();
}
default boolean isUnknown() {
return getCardDefinition() == MagicCardDefinition.UNKNOWN;
}
}

View File

@ -278,9 +278,7 @@ public final class MagicImages {
private static ImageType getImageType(IRenderableCard face) {
final MagicCardDefinition cdef = face.getCardDefinition();
if (cdef == MagicCardDefinition.UNKNOWN) {
if (face.isUnknown()) {
return ImageType.UNKNOWN;
}
@ -292,11 +290,12 @@ public final class MagicImages {
return ImageType.PROXY;
}
if (GeneralConfig.getInstance().getImagesOnDemand() && !MagicFileSystem.getCardImageFile(cdef).exists()) {
if (GeneralConfig.getInstance().getImagesOnDemand()
&& !MagicFileSystem.getCardImageFile(face).exists()) {
return ImageType.FULL;
}
if (MagicFileSystem.getCardImageFile(cdef).exists()) {
if (MagicFileSystem.getCardImageFile(face).exists()) {
return ImageType.FULL;
}

View File

@ -141,6 +141,10 @@ public final class MagicFileSystem {
return new File(imageDirectory.toFile(), getImageFilename(card));
}
public static File getCardImageFile(IRenderableCard face) {
return getCardImageFile(face.getCardDefinition());
}
/**
* Returns a File object representing the given card's cropped image file.
*/