1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-10 09:11:04 -09:00

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

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
Mage.Client/src/main/java/org/mage/plugins/card
Mage/src/main/java/mage/cards

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 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()) { if (baseUrl == null && card.isTwoFacedCard() && !card.isSecondSide()) {
baseUrl = "https://api.scryfall.com/cards/" + formatSetName(card.getSet(), isToken) + "/" baseUrl = "https://api.scryfall.com/cards/" + formatSetName(card.getSet(), isToken) + "/"
+ card.getCollectorId() + "/" + localizedCode + "?format=image"; + 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()) { if (card.getFlipCardName() == null || card.getFlipCardName().trim().isEmpty()) {
throw new IllegalStateException("Flipped card can't have empty name."); 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.setFlipCard(true);
cardDownloadData.setFlippedSide(true); cardDownloadData.setFlippedSide(true);
cardDownloadData.setType2(isType2); cardDownloadData.setType2(isType2);
allCardsUrls.add(cardDownloadData); 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())) { } 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()); logger.error("Card has no collector ID and won't be sent to client: " + card.getName());
} else if (card.getSetCode().isEmpty()) { } else if (card.getSetCode().isEmpty()) {

View file

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

View file

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