mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Removed unnecessary duplication in deck for card art optimisation
All the logic for smart card art in deck import is embedded in DeckImportController - leveraging on fetch method from StaticData :)
This commit is contained in:
@@ -266,7 +266,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
}
|
}
|
||||||
deferredSections = null; // set to null, just in case!
|
deferredSections = null; // set to null, just in case!
|
||||||
if (includeCardsFromUnspecifiedSet && smartCardArtSelection)
|
if (includeCardsFromUnspecifiedSet && smartCardArtSelection)
|
||||||
optimiseCardArtSelectionInDeckSections(cardsWithNoEdition, true);
|
optimiseCardArtSelectionInDeckSections(cardsWithNoEdition);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateDeferredSections() {
|
private void validateDeferredSections() {
|
||||||
@@ -352,16 +352,6 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
return String.format("%d %s", amount, poolCardRequest);
|
return String.format("%d %s", amount, poolCardRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void optimizeCardArtInMain() {
|
|
||||||
Map<DeckSection, ArrayList<String>> cardsWithNoEdition = new EnumMap<>(DeckSection.class);
|
|
||||||
List<String> mainCards = new ArrayList<>();
|
|
||||||
for (Entry<PaperCard, Integer> e: getMain())
|
|
||||||
mainCards.add(e.getKey().getName());
|
|
||||||
cardsWithNoEdition.put(DeckSection.Main, getAllCardNamesWithNoSpecifiedEdition(mainCards));
|
|
||||||
optimiseCardArtSelectionInDeckSections(cardsWithNoEdition, false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayList<String> getAllCardNamesWithNoSpecifiedEdition(List<String> cardsInSection) {
|
private ArrayList<String> getAllCardNamesWithNoSpecifiedEdition(List<String> cardsInSection) {
|
||||||
ArrayList<String> cardNamesWithNoEdition = new ArrayList<>();
|
ArrayList<String> cardNamesWithNoEdition = new ArrayList<>();
|
||||||
List<Pair<String, Integer>> cardRequests = CardPool.processCardList(cardsInSection);
|
List<Pair<String, Integer>> cardRequests = CardPool.processCardList(cardsInSection);
|
||||||
@@ -374,7 +364,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
return cardNamesWithNoEdition;
|
return cardNamesWithNoEdition;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void optimiseCardArtSelectionInDeckSections(Map<DeckSection, ArrayList<String>> cardsWithNoEdition, boolean multiArtPrint) {
|
private void optimiseCardArtSelectionInDeckSections(Map<DeckSection, ArrayList<String>> cardsWithNoEdition) {
|
||||||
StaticData data = StaticData.instance();
|
StaticData data = StaticData.instance();
|
||||||
// Get current Card Art Preference Settings
|
// Get current Card Art Preference Settings
|
||||||
boolean isCardArtPreferenceLatestArt = data.cardArtPreferenceIsLatest();
|
boolean isCardArtPreferenceLatestArt = data.cardArtPreferenceIsLatest();
|
||||||
@@ -407,13 +397,13 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
int totalToAddToPool = cp.getValue();
|
int totalToAddToPool = cp.getValue();
|
||||||
// A. Skip cards not requiring any update, because they add the edition specified!
|
// A. Skip cards not requiring any update, because they add the edition specified!
|
||||||
if (!cardNamesWithNoEditionInSection.contains(card.getName())) {
|
if (!cardNamesWithNoEditionInSection.contains(card.getName())) {
|
||||||
addCardToPool(newPool, card, totalToAddToPool, card.isFoil(), multiArtPrint);
|
addCardToPool(newPool, card, totalToAddToPool, card.isFoil());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// B. Determine if current card requires update
|
// B. Determine if current card requires update
|
||||||
boolean cardArtNeedsOptimisation = this.isCardArtUpdateRequired(card, releaseDatePivotEdition);
|
boolean cardArtNeedsOptimisation = this.isCardArtUpdateRequired(card, releaseDatePivotEdition);
|
||||||
if (!cardArtNeedsOptimisation) {
|
if (!cardArtNeedsOptimisation) {
|
||||||
addCardToPool(newPool, card, totalToAddToPool, card.isFoil(), multiArtPrint);
|
addCardToPool(newPool, card, totalToAddToPool, card.isFoil());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PaperCard alternativeCardPrint = data.getAlternativeCardPrint(card, releaseDatePivotEdition,
|
PaperCard alternativeCardPrint = data.getAlternativeCardPrint(card, releaseDatePivotEdition,
|
||||||
@@ -422,24 +412,20 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
isExpansionTheMajorityInThePool,
|
isExpansionTheMajorityInThePool,
|
||||||
isPoolModernFramed);
|
isPoolModernFramed);
|
||||||
if (alternativeCardPrint == null) // no alternative found, add original card in Pool
|
if (alternativeCardPrint == null) // no alternative found, add original card in Pool
|
||||||
addCardToPool(newPool, card, totalToAddToPool, card.isFoil(), multiArtPrint);
|
addCardToPool(newPool, card, totalToAddToPool, card.isFoil());
|
||||||
else
|
else
|
||||||
addCardToPool(newPool, alternativeCardPrint, totalToAddToPool, card.isFoil(), multiArtPrint);
|
addCardToPool(newPool, alternativeCardPrint, totalToAddToPool, card.isFoil());
|
||||||
}
|
}
|
||||||
parts.put(deckSection, newPool);
|
parts.put(deckSection, newPool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCardToPool(CardPool pool, PaperCard card, int totalToAdd, boolean isFoil, boolean multiArtPrint) {
|
private void addCardToPool(CardPool pool, PaperCard card, int totalToAdd, boolean isFoil) {
|
||||||
StaticData data = StaticData.instance();
|
StaticData data = StaticData.instance();
|
||||||
if (card.getArtIndex() != IPaperCard.NO_ART_INDEX && card.getArtIndex() != IPaperCard.DEFAULT_ART_INDEX)
|
if (card.getArtIndex() != IPaperCard.NO_ART_INDEX && card.getArtIndex() != IPaperCard.DEFAULT_ART_INDEX)
|
||||||
pool.add(isFoil ? card.getFoiled() : card, totalToAdd); // art index requested, keep that way!
|
pool.add(isFoil ? card.getFoiled() : card, totalToAdd); // art index requested, keep that way!
|
||||||
else {
|
else {
|
||||||
int artCount = 1;
|
int artCount = data.getCardArtCount(card);
|
||||||
|
|
||||||
if (multiArtPrint)
|
|
||||||
artCount = data.getCardArtCount(card);
|
|
||||||
|
|
||||||
if (artCount > 1)
|
if (artCount > 1)
|
||||||
addAlternativeCardPrintInPoolWithMultipleArt(card, pool, totalToAdd, artCount);
|
addAlternativeCardPrintInPoolWithMultipleArt(card, pool, totalToAdd, artCount);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user