mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Refined implementation (+ test) for getEarliestEditionWithAllCards
This method should still be optimised, and definetly renamed.
This commit is contained in:
@@ -813,21 +813,14 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
*/
|
||||
public CardEdition getEarliestEditionWithAllCards(CardPool cards) {
|
||||
Set<String> minEditions = new HashSet<>();
|
||||
|
||||
CardArtPreference strictness = CardArtPreference.ORIGINAL_ART_CORE_EXPANSIONS_REPRINT_ONLY;
|
||||
|
||||
CardDb db = StaticData.instance().getCommonCards();
|
||||
for (Entry<PaperCard, Integer> k : cards) {
|
||||
PaperCard cp = StaticData.instance().getCommonCards().getCardFromEditions(k.getKey().getName(), strictness);
|
||||
if( cp == null && strictness == CardArtPreference.ORIGINAL_ART_CORE_EXPANSIONS_REPRINT_ONLY) {
|
||||
strictness = CardArtPreference.ORIGINAL_ART_ALL_EDITIONS; // card is not found in core and expansions only (probably something CMD or C13)
|
||||
cp = StaticData.instance().getCommonCards().getCardFromEditions(k.getKey().getName(), strictness);
|
||||
}
|
||||
PaperCard cp = db.getCardFromEditions(k.getKey().getName(),
|
||||
CardArtPreference.ORIGINAL_ART_CORE_EXPANSIONS_REPRINT_ONLY);
|
||||
if (cp == null)
|
||||
cp = k.getKey(); // it's unlikely, this code will ever run
|
||||
|
||||
minEditions.add(cp.getEdition());
|
||||
}
|
||||
|
||||
for (CardEdition ed : getOrderedEditions()) {
|
||||
if (minEditions.contains(ed.getCode()))
|
||||
return ed;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CardEditionCollectionTestCase extends ForgeCardMockTestCase {
|
||||
for (int i=0; i < 5; i++){
|
||||
String cardName = cardNames[i];
|
||||
String expectedSet = expectedSets[i];
|
||||
PaperCard card = cardDb.getCardFromEditions(cardName, CardDb.CardArtPreference.OldArtAllEditions);
|
||||
PaperCard card = cardDb.getCardFromEditions(cardName, CardDb.CardArtPreference.ORIGINAL_ART_ALL_EDITIONS);
|
||||
assertEquals(card.getEdition(), expectedSet);
|
||||
cards.add(card);
|
||||
}
|
||||
@@ -31,6 +31,6 @@ public class CardEditionCollectionTestCase extends ForgeCardMockTestCase {
|
||||
CardPool pool = new CardPool();
|
||||
pool.add(cards);
|
||||
CardEdition ed = editions.getEarliestEditionWithAllCards(pool);
|
||||
assertEquals(ed.getCode(), "LEA");
|
||||
assertEquals(ed.getCode(), "ALL");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user