mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 02:52:02 -08:00
* GUI: double faced cards improves:
* fixed images download for alternative prints (#9826, #9701); * fixed wrong pair of main and second side arts for alternative prints;
This commit is contained in:
parent
18a3ec5247
commit
4e9ffdfaf9
12 changed files with 59 additions and 32 deletions
|
|
@ -643,7 +643,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
// must be non strict search in any sets, not one set
|
||||
// example: if set contains only one card side
|
||||
// method used in cards database creating, so can't use repository here
|
||||
ExpansionSet.SetCardInfo info = Sets.findCardByClass(cardClazz, expansionSetCode);
|
||||
ExpansionSet.SetCardInfo info = Sets.findCardByClass(cardClazz, expansionSetCode, cardNumber);
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,15 +199,23 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static ExpansionSet.SetCardInfo findCardByClass(Class<?> clazz, String preferredSetCode) {
|
||||
public static ExpansionSet.SetCardInfo findCardByClass(Class<?> clazz, String preferredSetCode, String preferredCardNumber) {
|
||||
ExpansionSet.SetCardInfo info = null;
|
||||
if (instance.containsKey(preferredSetCode)) {
|
||||
info = instance.get(preferredSetCode).findCardInfoByClass(clazz).stream().findFirst().orElse(null);
|
||||
info = instance.get(preferredSetCode).findCardInfoByClass(clazz)
|
||||
.stream()
|
||||
.filter(card -> preferredCardNumber == null || card.getCardNumber().equals(preferredCardNumber))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
if (info == null) {
|
||||
for (Map.Entry<String, ExpansionSet> entry : instance.entrySet()) {
|
||||
info = entry.getValue().findCardInfoByClass(clazz).stream().findFirst().orElse(null);
|
||||
info = entry.getValue().findCardInfoByClass(clazz)
|
||||
.stream()
|
||||
.filter(card -> preferredCardNumber == null || card.getCardNumber().equals(preferredCardNumber))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (info != null) {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class MockCard extends CardImpl {
|
|||
this.nightCard = card.isNightCard();
|
||||
|
||||
if (card.getSecondSideName() != null && !card.getSecondSideName().isEmpty()) {
|
||||
this.secondSideCard = new MockCard(CardRepository.instance.findCardWPreferredSet(card.getSecondSideName(), card.getSetCode()));
|
||||
this.secondSideCard = new MockCard(CardRepository.instance.findCardWithPreferredSetAndNumber(card.getSecondSideName(), card.getSetCode(), card.getCardNumber()));
|
||||
}
|
||||
|
||||
if (card.isAdventureCard()) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class MockSplitCard extends SplitCard {
|
|||
this.nightCard = card.isNightCard();
|
||||
|
||||
if (card.getSecondSideName() != null && !card.getSecondSideName().isEmpty()) {
|
||||
this.secondSideCard = new MockCard(CardRepository.instance.findCardWPreferredSet(card.getSecondSideName(), card.getSetCode()));
|
||||
this.secondSideCard = new MockCard(CardRepository.instance.findCardWithPreferredSetAndNumber(card.getSecondSideName(), card.getSetCode(), card.getCardNumber()));
|
||||
}
|
||||
|
||||
this.flipCardName = card.getFlipCardName();
|
||||
|
|
@ -49,13 +49,13 @@ public class MockSplitCard extends SplitCard {
|
|||
this.addAbility(textAbilityFromString(ruleText));
|
||||
}
|
||||
|
||||
CardInfo leftHalf = CardRepository.instance.findCardWPreferredSet(getLeftHalfName(card), card.getSetCode(), true);
|
||||
CardInfo leftHalf = CardRepository.instance.findCardWithPreferredSetAndNumber(getLeftHalfName(card), card.getSetCode(), card.getCardNumber(), true);
|
||||
if (leftHalf != null) {
|
||||
this.leftHalfCard = new MockSplitCardHalf(leftHalf);
|
||||
((SplitCardHalf) this.leftHalfCard).setParentCard(this);
|
||||
}
|
||||
|
||||
CardInfo rightHalf = CardRepository.instance.findCardWPreferredSet(getRightHalfName(card), card.getSetCode(), true);
|
||||
CardInfo rightHalf = CardRepository.instance.findCardWithPreferredSetAndNumber(getRightHalfName(card), card.getSetCode(), card.getCardNumber(), true);
|
||||
if (rightHalf != null) {
|
||||
this.rightHalfCard = new MockSplitCardHalf(rightHalf);
|
||||
((SplitCardHalf) this.rightHalfCard).setParentCard(this);
|
||||
|
|
|
|||
|
|
@ -394,32 +394,36 @@ public enum CardRepository {
|
|||
|
||||
/**
|
||||
* Function to find a card by name from a specific set.
|
||||
* Used for building cubes, packs, and for ensuring that dual faces and split cards have sides/halves from the same set.
|
||||
* Used for building cubes, packs, and for ensuring that dual faces and split cards have sides/halves from
|
||||
* the same set and variant art.
|
||||
*
|
||||
* @param name name of the card, or side of the card, to find
|
||||
* @param expansion the set name from which to find the card
|
||||
* @param cardNumber the card number for variant arts in one set
|
||||
* @param returnSplitCardHalf whether to return a half of a split card or the corresponding full card.
|
||||
* Want this `false` when user is searching by either names in a split card so that
|
||||
* the full card can be found by either name.
|
||||
* @return
|
||||
*/
|
||||
public CardInfo findCardWPreferredSet(String name, String expansion, boolean returnSplitCardHalf) {
|
||||
public CardInfo findCardWithPreferredSetAndNumber(String name, String expansion, String cardNumber, boolean returnSplitCardHalf) {
|
||||
List<CardInfo> cards;
|
||||
|
||||
cards = findCards(name, 0, returnSplitCardHalf);
|
||||
CardInfo bestCard = cards.stream()
|
||||
.filter(card -> expansion == null || expansion.equalsIgnoreCase(card.getSetCode()))
|
||||
.filter(card -> cardNumber == null || cardNumber.equals(card.getCardNumber()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (!cards.isEmpty()) {
|
||||
for (CardInfo cardinfo : cards) {
|
||||
if (cardinfo.getSetCode() != null && expansion != null && expansion.equalsIgnoreCase(cardinfo.getSetCode())) {
|
||||
return cardinfo;
|
||||
}
|
||||
}
|
||||
if (bestCard != null) {
|
||||
return bestCard;
|
||||
} else {
|
||||
return findPreferredCoreExpansionCard(name);
|
||||
}
|
||||
return findPreferredCoreExpansionCard(name);
|
||||
}
|
||||
|
||||
public CardInfo findCardWPreferredSet(String name, String expansion) {
|
||||
return findCardWPreferredSet(name, expansion, false);
|
||||
public CardInfo findCardWithPreferredSetAndNumber(String name, String expansion, String cardNumber) {
|
||||
return findCardWithPreferredSetAndNumber(name, expansion, cardNumber, false);
|
||||
}
|
||||
|
||||
public List<CardInfo> findCards(String name) {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public abstract class DraftCube {
|
|||
if (!cardId.getName().isEmpty()) {
|
||||
CardInfo cardInfo = null;
|
||||
if (!cardId.getExtension().isEmpty()) {
|
||||
cardInfo = CardRepository.instance.findCardWPreferredSet(cardId.getName(), cardId.getExtension());
|
||||
cardInfo = CardRepository.instance.findCardWithPreferredSetAndNumber(cardId.getName(), cardId.getExtension(), null);
|
||||
} else {
|
||||
cardInfo = CardRepository.instance.findPreferredCoreExpansionCard(cardId.getName());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue