mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
1. added a method to determine if a printed card uses a different picture for its other face
2. remove unused imports from previous commit
This commit is contained in:
@@ -28,7 +28,6 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.player.Player;
|
||||
|
||||
@@ -200,7 +200,7 @@ public class ImageCache {
|
||||
hasManyPictures = cntPictures > 1;
|
||||
} else {
|
||||
// without set number of pictures equals number of urls provided in Svar:Picture
|
||||
String urls = backFace ? card.getPictureOtherSideUrl() : card.getPictureUrl();
|
||||
String urls = card.getPictureUrl(backFace);
|
||||
cntPictures = StringUtils.countMatches(urls, "\\") + 1;
|
||||
|
||||
// raise the art index limit to the maximum of the sets this card was printed in
|
||||
@@ -239,6 +239,10 @@ public class ImageCache {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasBackFacePicture(CardPrinted cp) {
|
||||
return cp.getRules().getSplitType() == CardSplitType.Transform; // do we take other image for flipped cards?
|
||||
}
|
||||
|
||||
public static String getSetFolder(String edition) {
|
||||
return !NewConstants.CACHE_CARD_PICS_SUBDIR.containsKey(edition)
|
||||
? Singletons.getModel().getEditions().getCode2ByCode(edition) // by default 2-letter codes from MWS are used
|
||||
@@ -247,8 +251,8 @@ public class ImageCache {
|
||||
|
||||
private static String getNameToUse(CardPrinted cp, boolean backFace) {
|
||||
final CardRules card = cp.getRules();
|
||||
if (backFace) {
|
||||
if ( card.getSplitType() == CardSplitType.Transform )
|
||||
if (backFace ) {
|
||||
if ( hasBackFacePicture(cp) )
|
||||
return card.getOtherPart().getName();
|
||||
else
|
||||
return null;
|
||||
|
||||
@@ -161,8 +161,7 @@ public final class CardRules implements ICardCharacteristics {
|
||||
// Downloadable image
|
||||
private String dlUrl;
|
||||
private String dlUrlOtherSide;
|
||||
public String getPictureUrl() { return dlUrl; }
|
||||
public String getPictureOtherSideUrl() { return dlUrlOtherSide; }
|
||||
public String getPictureUrl(boolean backface ) { return backface ? dlUrlOtherSide : dlUrl; }
|
||||
public void setDlUrls(String[] dlUrls) { this.dlUrl = dlUrls[0]; this.dlUrlOtherSide = dlUrls[1]; }
|
||||
|
||||
public final List<String> getReplacements() {
|
||||
|
||||
@@ -40,7 +40,6 @@ import forge.Constant;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.ArrayList;
|
||||
import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cost.CostPayment;
|
||||
import forge.game.zone.Zone;
|
||||
|
||||
@@ -35,7 +35,6 @@ import forge.CardUtil;
|
||||
import forge.Command;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.CardType;
|
||||
import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.effects.AttachEffect;
|
||||
|
||||
@@ -10,7 +10,6 @@ import forge.CardCharacteristicName;
|
||||
import forge.CardColor;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
|
||||
@@ -41,7 +41,6 @@ import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.toolbox.FLabel;
|
||||
|
||||
@@ -32,7 +32,6 @@ import forge.ImageCache;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.EditionCollection;
|
||||
import forge.item.CardDb;
|
||||
import forge.item.CardPrinted;
|
||||
@@ -295,7 +294,7 @@ public class MigrationSourceAnalyzer {
|
||||
|
||||
private void _addDefaultPicNames(CardPrinted c, boolean backFace) {
|
||||
CardRules card = c.getRules();
|
||||
String urls = backFace ? card.getPictureOtherSideUrl() : card.getPictureUrl();
|
||||
String urls = card.getPictureUrl(backFace);
|
||||
if (StringUtils.isEmpty(urls)) { return; }
|
||||
|
||||
int numPics = 1 + StringUtils.countMatches(urls, "\\");
|
||||
@@ -325,7 +324,7 @@ public class MigrationSourceAnalyzer {
|
||||
|
||||
for (CardPrinted c : CardDb.instance().getAllCards()) {
|
||||
_addDefaultPicNames(c, false);
|
||||
if ( c.getRules().getSplitType() == CardSplitType.Transform)
|
||||
if (ImageCache.hasBackFacePicture(c))
|
||||
_addDefaultPicNames(c, true);
|
||||
}
|
||||
|
||||
@@ -364,10 +363,9 @@ public class MigrationSourceAnalyzer {
|
||||
|
||||
private static void _addSetCards(Map<String, String> cardFileNames, Iterable<CardPrinted> library, Predicate<CardPrinted> filter) {
|
||||
for (CardPrinted c : Iterables.filter(library, filter)) {
|
||||
boolean hasBackFacePicture = null != c.getRules().getPictureOtherSideUrl();
|
||||
String filename = ImageCache.getImageKey(c, false, true) + ".jpg";
|
||||
cardFileNames.put(filename, filename);
|
||||
if (hasBackFacePicture) {
|
||||
if (ImageCache.hasBackFacePicture(c)) {
|
||||
filename = ImageCache.getImageKey(c, true, true) + ".jpg";
|
||||
cardFileNames.put(filename, filename);
|
||||
}
|
||||
@@ -397,10 +395,9 @@ public class MigrationSourceAnalyzer {
|
||||
};
|
||||
|
||||
for (CardPrinted c : Iterables.filter(CardDb.variants().getAllCards(), predPlanes)) {
|
||||
boolean hasBackFacePciture = null != c.getRules().getPictureOtherSideUrl();
|
||||
String baseName = ImageCache.getImageKey(c,false, true);
|
||||
_nameUpdates.put(baseName + ".full.jpg", baseName + ".jpg");
|
||||
if (hasBackFacePciture) {
|
||||
if (ImageCache.hasBackFacePicture(c)) {
|
||||
baseName = ImageCache.getImageKey(c, true, true);
|
||||
_nameUpdates.put(baseName + ".full.jpg", baseName + ".jpg");
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.item.CardDb;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.properties.NewConstants;
|
||||
@@ -42,7 +41,7 @@ public class GuiDownloadPicturesLQ extends GuiDownloader {
|
||||
|
||||
for (CardPrinted c : CardDb.instance().getAllCards()) {
|
||||
addDLObject(c, downloads, false);
|
||||
if ( c.getRules().getSplitType() == CardSplitType.Transform)
|
||||
if (ImageCache.hasBackFacePicture(c))
|
||||
addDLObject(c, downloads, true);
|
||||
}
|
||||
|
||||
@@ -58,7 +57,7 @@ public class GuiDownloadPicturesLQ extends GuiDownloader {
|
||||
|
||||
private void addDLObject(CardPrinted c, Map<String, String> downloads, boolean backFace) {
|
||||
CardRules cardRules = c.getRules();
|
||||
String urls = backFace ? cardRules.getPictureOtherSideUrl() : cardRules.getPictureUrl();
|
||||
String urls = cardRules.getPictureUrl(backFace);
|
||||
if (StringUtils.isEmpty(urls)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.item.CardDb;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.properties.NewConstants;
|
||||
@@ -51,7 +50,7 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
|
||||
String url = ImageCache.getDownloadUrl(c, false);
|
||||
addDLObject(url, ImageCache.getImageKey(c, false, true), downloads);
|
||||
|
||||
if ( c.getRules().getSplitType() == CardSplitType.Transform ) {
|
||||
if (ImageCache.hasBackFacePicture(c)) {
|
||||
String url2 = ImageCache.getDownloadUrl(c, true);
|
||||
addDLObject(url2, ImageCache.getImageKey(c, true, true), downloads);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import forge.CounterType;
|
||||
import forge.ImageCache;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.gui.CardContainer;
|
||||
import forge.gui.toolbox.CardFaceSymbols;
|
||||
|
||||
Reference in New Issue
Block a user