refactor: improved card info

This commit is contained in:
Oleg Agafonov 2024-02-18 22:40:30 +04:00
parent b1e4ea2790
commit ad8e7daf97
47 changed files with 84 additions and 81 deletions

View file

@ -1705,7 +1705,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
java.util.List<CardInfo> cardPool = CardRepository.instance.findCards(cardCriteria);
if (!cardPool.isEmpty()) {
Card acard = cardPool.get(RandomUtil.nextInt(cardPool.size())).getMockCard();
Card acard = cardPool.get(RandomUtil.nextInt(cardPool.size())).createMockCard();
if (acard.getName().equals(card.getName())) {
CardView pimpedCard = new CardView(acard);
@ -1751,7 +1751,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
for (CardView card : stack) {
CardInfo oldestCardInfo = CardRepository.instance.findOldestNonPromoVersionCard(card.getName());
if (oldestCardInfo != null) {
CardView oldestCardView = new CardView(oldestCardInfo.getMockCard());
CardView oldestCardView = new CardView(oldestCardInfo.createMockCard());
this.removeCardView(card);
eventSource.fireEvent(card, ClientEventType.DECK_REMOVE_SPECIFIC_CARD);
this.addCardView(oldestCardView, false);

View file

@ -64,7 +64,7 @@ public class VirtualCardInfo {
return;
}
this.init(new CardView(cardInfo.getCard()), bigCard, gameId);
this.init(new CardView(cardInfo.createCard()), bigCard, gameId);
}
public void init(CardView cardView, BigCard bigCard, UUID gameId) {

View file

@ -126,7 +126,7 @@ public class MageEditorPane extends JEditorPane {
if (cardView == null) {
CardInfo card = CardRepository.instance.findCards(cardName).stream().findFirst().orElse(null);
if (card != null) {
cardView = new CardView(card.getMockCard());
cardView = new CardView(card.createMockCard());
}
}

View file

@ -4,16 +4,13 @@ import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.cards.repository.ExpansionRepository;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.sets.ConstructedFormats;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Rarity;
import mage.constants.SuperType;
import mage.util.RandomUtil;
import mage.util.TournamentUtil;
import java.util.*;
@ -230,6 +227,6 @@ public final class DeckGenerator {
private static Card getBasicLand(ColoredManaSymbol color, Map<String, List<CardInfo>> basicLands) {
String landName = DeckGeneratorPool.getBasicLandName(color.toString());
List<CardInfo> basicLandsInfo = basicLands.get(landName);
return basicLandsInfo.get(RandomUtil.nextInt(basicLandsInfo.size())).getMockCard().copy();
return basicLandsInfo.get(RandomUtil.nextInt(basicLandsInfo.size())).createMockCard().copy();
}
}

View file

@ -278,7 +278,7 @@ public class DeckGeneratorPool
public List<Card> filterLands(List<CardInfo> landCardsInfo) {
List<Card> matchingLandList = new ArrayList<>();
for(CardInfo landCardInfo: landCardsInfo) {
Card landCard = landCardInfo.getMockCard();
Card landCard = landCardInfo.createMockCard();
if(landProducesChosenColors(landCard)) {
matchingLandList.add(landCard);
}
@ -556,7 +556,7 @@ public class DeckGeneratorPool
if (retrievedCount > 0 && retrievedCount >= spellCount) {
int tries = 0;
while (count < spellCount) {
Card card = cardPool.get(RandomUtil.nextInt(retrievedCount)).getMockCard();
Card card = cardPool.get(RandomUtil.nextInt(retrievedCount)).createMockCard();
if (genPool.isValidSpellCard(card)) {
int cardCMC = card.getManaValue();
for (DeckGeneratorCMC.CMC deckCMC : deckCMCs) {

View file

@ -480,7 +480,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}
}
// filter by settings
Card card = cardInfo.getMockCard();
Card card = cardInfo.createMockCard();
if (!filter.match(card, null)) {
continue;
}

View file

@ -292,7 +292,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
if (card == null) {
// Need to make a new card
Logger.getLogger(DeckEditorPanel.class).info("Retrieve " + cardView.getCardNumber() + " Failed");
card = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber()).getCard();
card = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber()).createCard();
} else {
// Only need a temporary card once
temporaryCards.remove(cardView.getId());
@ -578,7 +578,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
// add cards
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
for (int i = cardsFound; i < numberToSet; i++) {
cards.add(cardInfo.getMockCard());
cards.add(cardInfo.createMockCard());
}
} else {
// remove cards
@ -605,7 +605,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
} else {
// editor: create mock card
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
card = cardInfo != null ? cardInfo.getMockCard() : null;
card = cardInfo != null ? cardInfo.createMockCard() : null;
}
if (card != null) {
@ -633,7 +633,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
SimpleCardView cardView = (SimpleCardView) event.getSource();
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
Card card = cardInfo != null ? cardInfo.createMockCard() : null;
if (card != null) {
deck.getSideboard().add(card);
}

View file

@ -443,7 +443,7 @@ public class MageBook extends JComponent {
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
cards.sort(new NaturalOrderCardNumberComparator());
List<Object> res = new ArrayList<>();
cards.forEach(card -> res.add(new CardView(card.getMockCard())));
cards.forEach(card -> res.add(new CardView(card.createMockCard())));
return res;
}

View file

@ -173,7 +173,7 @@ public class AddLandDialog extends MageDialog {
int foundLands = 0;
int foundNoneAfter = 0;
for (int i = 0; foundLands != number && foundNoneAfter < 1000; i++) {
Card land = cards.get(RandomUtil.nextInt(cards.size())).getMockCard();
Card land = cards.get(RandomUtil.nextInt(cards.size())).createMockCard();
boolean useLand = !useFullArt;
if (useFullArt && (land.getFrameStyle() == FrameStyle.BFZ_FULL_ART_BASIC
|| land.getFrameStyle() == FrameStyle.UGL_FULL_ART_BASIC

View file

@ -18,7 +18,7 @@ public final class CardsViewUtil {
for (SimpleCardView simple : view.values()) {
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
Card card = cardInfo != null ? cardInfo.createMockCard() : null;
if (card != null) {
cards.put(simple.getId(), new CardView(card, simple));
}
@ -35,7 +35,7 @@ public final class CardsViewUtil {
Card card = loadedCards.get(key);
if (card == null) {
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
card = cardInfo != null ? cardInfo.getMockCard() : null;
card = cardInfo != null ? cardInfo.createMockCard() : null;
loadedCards.put(key, card);
}
if (card != null) {

View file

@ -27,7 +27,7 @@ public final class DeckUtil {
deck.setName(view.getName());
for (SimpleCardView cardView : view.getCards().values()) {
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
Card card = cardInfo != null ? cardInfo.createMockCard() : null;
if (card != null) {
deck.getCards().add(card);
} else {
@ -36,7 +36,7 @@ public final class DeckUtil {
}
for (SimpleCardView cardView : view.getSideboard().values()) {
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
Card card = cardInfo != null ? cardInfo.createMockCard() : null;
if (card != null) {
deck.getSideboard().add(card);
} else {