Images download: fixed broken download dialog

This commit is contained in:
Oleg Agafonov 2020-08-07 11:29:49 +04:00
parent 2954bbaf04
commit 3bf0f80033
5 changed files with 14 additions and 13 deletions

View file

@ -396,7 +396,7 @@ public enum MythicspoilerComSource implements CardImageSource {
String collectorId = card.getCollectorId();
String cardSet = card.getSet();
if (collectorId == null || cardSet == null) {
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet);
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ", card set: " + cardSet);
}
if (card.isFlippedSide()) { //doesn't support rotated images
return null;

View file

@ -4,8 +4,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import mage.cards.ExpansionSet;
import mage.cards.Sets;
import mage.client.util.CardLanguage;
import mage.util.CardUtil;
import org.apache.log4j.Logger;
@ -30,7 +28,7 @@ public enum ScryfallImageSource implements CardImageSource {
private final Map<CardLanguage, String> languageAliases;
private CardLanguage currentLanguage = CardLanguage.ENGLISH; // working language
private Map<CardDownloadData, String> preparedUrls = new HashMap<>();
private final Map<CardDownloadData, String> preparedUrls = new HashMap<>();
ScryfallImageSource() {
// LANGUAGES
@ -68,7 +66,7 @@ public enum ScryfallImageSource implements CardImageSource {
// TOKENS TRY
// tokens support only direct links
if (baseUrl == null && isToken) {
if (isToken) {
baseUrl = ScryfallImageSupportTokens.findTokenLink(card.getSet(), card.getName(), card.getType());
alternativeUrl = null;
}

View file

@ -461,7 +461,7 @@ public enum WizardCardsImageSource implements CardImageSource {
String collectorId = card.getCollectorId();
String cardSet = card.getSet();
if (collectorId == null || cardSet == null) {
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet);
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ", card set: " + cardSet);
}
if (card.isFlippedSide()) { //doesn't support rotated images
return null;

View file

@ -1,11 +1,11 @@
package org.mage.plugins.card.images;
import mage.util.CardUtil;
import java.util.Locale;
import java.util.Objects;
import mage.util.CardUtil;
/**
*
* @author North
*/
public class CardDownloadData {
@ -106,10 +106,7 @@ public class CardDownloadData {
if (this.secondSide != other.secondSide) {
return false;
}
if (this.isType2 != other.isType2) {
return false;
}
return true;
return this.isType2 == other.isType2;
}
@Override
@ -134,6 +131,12 @@ public class CardDownloadData {
return CardUtil.parseCardNumberAsInt(collectorId);
}
public String getCollectorIdAsFileName() {
// return file names compatible card number (e.g. replace special symbols)
return collectorId
.replace("*", "star");
}
public String getCollectorIdPostfix() {
return getCollectorId().replaceAll(getCollectorIdAsInt().toString(), "");
}

View file

@ -203,7 +203,7 @@ public final class CardImageUtils {
String finalFileName = "";
if (card.getUsesVariousArt()) {
// different arts uses name + collector id
finalFileName = cardName + prefixType + '.' + card.getCollectorId() + ".full.jpg";
finalFileName = cardName + prefixType + '.' + card.getCollectorIdAsFileName() + ".full.jpg";
} else {
// basic arts uses name
finalFileName = cardName + prefixType + ".full.jpg";