[ZNR] Added images download for modal double faces cards (#7012)

This commit is contained in:
Oleg Agafonov 2020-10-01 13:23:04 +04:00
parent a73c9bddae
commit c60bf3ccef
4 changed files with 21 additions and 7 deletions

View file

@ -86,9 +86,9 @@ public enum ScryfallImageSource implements CardImageSource {
}
}
// double faced card
// double faced cards (modal double faces cards too)
// the front face can be downloaded normally
// the back face is prepared beforehand
// the back face is prepared before hand
if (baseUrl == null && card.isTwoFacedCard() && !card.isSecondSide()) {
baseUrl = "https://api.scryfall.com/cards/" + formatSetName(card.getSet(), isToken) + "/"
+ card.getCollectorId() + "/" + localizedCode + "?format=image";

View file

@ -449,12 +449,30 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
if (card.getFlipCardName() == null || card.getFlipCardName().trim().isEmpty()) {
throw new IllegalStateException("Flipped card can't have empty name.");
}
CardDownloadData cardDownloadData = new CardDownloadData(card.getFlipCardName(), card.getSetCode(), card.getCardNumber(), card.usesVariousArt(), 0, "", "", false, card.isDoubleFaced(), card.isNightCard());
CardDownloadData cardDownloadData = new CardDownloadData(
card.getFlipCardName(),
card.getSetCode(),
card.getCardNumber(),
card.usesVariousArt(),
0, "", "", false, card.isDoubleFaced(), card.isNightCard());
cardDownloadData.setFlipCard(true);
cardDownloadData.setFlippedSide(true);
cardDownloadData.setType2(isType2);
allCardsUrls.add(cardDownloadData);
}
if (card.isModalDoubleFacesCard()) {
if (card.getModalDoubleFacesSecondSideName() == null || card.getModalDoubleFacesSecondSideName().trim().isEmpty()) {
throw new IllegalStateException("MDF card can't have empty name.");
}
CardDownloadData cardDownloadData = new CardDownloadData(
card.getModalDoubleFacesSecondSideName(),
card.getSetCode(),
card.getCardNumber(),
card.usesVariousArt(),
0, "", "", false, true, true);
cardDownloadData.setType2(isType2);
allCardsUrls.add(cardDownloadData);
}
} else if (card.getCardNumber().isEmpty() || "0".equals(card.getCardNumber())) {
logger.error("Card has no collector ID and won't be sent to client: " + card.getName());
} else if (card.getSetCode().isEmpty()) {

View file

@ -58,8 +58,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
protected String flipCardName;
protected boolean usesVariousArt = false;
protected boolean morphCard;
protected boolean modalDFC; // modal double faces card
protected List<UUID> attachments = new ArrayList<>();
public CardImpl(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costs) {
@ -139,7 +137,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
flipCardName = card.flipCardName;
usesVariousArt = card.usesVariousArt;
morphCard = card.morphCard;
modalDFC = card.modalDFC;
this.attachments.addAll(card.attachments);
}

View file

@ -33,7 +33,6 @@ public abstract class ModalDoubleFacesCard extends CardImpl {
typesLeft, subTypesLeft, costsLeft, this, SpellAbilityType.MODAL_LEFT);
rightHalfCard = new ModalDoubleFacesCardHalfImpl(this.getOwnerId(), new CardSetInfo(secondSideName, setInfo.getExpansionSetCode(), setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()),
typesRight, subTypesRight, costsRight, this, SpellAbilityType.MODAL_RIGHT);
this.modalDFC = true;
}
public ModalDoubleFacesCard(ModalDoubleFacesCard card) {