mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
FIX and Impros to CardEdition, CardInSet and Reader
- Reader has a new updated regexp to deal with non-numerical collectorNumbers - CardInSet have been now made sortable based on CollectorNumber. To do so, collectorNumbers are transformed accordingly to allow for natural ordering (as expected) instead of lexicographic order. - CardEdition now return cards (CardInSet) as sorted, to allow for correct artIndex matching when creating corresponding `PaperCard` instances. Moreover, `compareTo` of card edition has been improved to also take into account set name (in cases of same release date).
This commit is contained in:
committed by
Michael Kamensky
parent
a17c42e07e
commit
8b7ae19508
@@ -250,6 +250,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
|||||||
private String[] chaosDraftThemes = new String[0];
|
private String[] chaosDraftThemes = new String[0];
|
||||||
|
|
||||||
private final ListMultimap<String, CardInSet> cardMap;
|
private final ListMultimap<String, CardInSet> cardMap;
|
||||||
|
private final List<CardInSet> cardsInSet;
|
||||||
private final Map<String, Integer> tokenNormalized;
|
private final Map<String, Integer> tokenNormalized;
|
||||||
// custom print sheets that will be loaded lazily
|
// custom print sheets that will be loaded lazily
|
||||||
private final Map<String, List<String>> customPrintSheetsToParse;
|
private final Map<String, List<String>> customPrintSheetsToParse;
|
||||||
@@ -259,13 +260,18 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
|||||||
|
|
||||||
private CardEdition(ListMultimap<String, CardInSet> cardMap, Map<String, Integer> tokens, Map<String, List<String>> customPrintSheetsToParse) {
|
private CardEdition(ListMultimap<String, CardInSet> cardMap, Map<String, Integer> tokens, Map<String, List<String>> customPrintSheetsToParse) {
|
||||||
this.cardMap = cardMap;
|
this.cardMap = cardMap;
|
||||||
|
this.cardsInSet = new ArrayList<>(cardMap.values());
|
||||||
|
Collections.sort(cardsInSet);
|
||||||
this.tokenNormalized = tokens;
|
this.tokenNormalized = tokens;
|
||||||
this.customPrintSheetsToParse = customPrintSheetsToParse;
|
this.customPrintSheetsToParse = customPrintSheetsToParse;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CardEdition(CardInSet[] cards, Map<String, Integer> tokens) {
|
private CardEdition(CardInSet[] cards, Map<String, Integer> tokens) {
|
||||||
|
List<CardInSet> cardsList = Arrays.asList(cards);
|
||||||
this.cardMap = ArrayListMultimap.create();
|
this.cardMap = ArrayListMultimap.create();
|
||||||
this.cardMap.replaceValues("cards", Arrays.asList(cards));
|
this.cardMap.replaceValues("cards", cardsList);
|
||||||
|
this.cardsInSet = new ArrayList<>(cardsList);
|
||||||
|
Collections.sort(cardsInSet);
|
||||||
this.tokenNormalized = tokens;
|
this.tokenNormalized = tokens;
|
||||||
this.customPrintSheetsToParse = new HashMap<>();
|
this.customPrintSheetsToParse = new HashMap<>();
|
||||||
}
|
}
|
||||||
@@ -331,8 +337,6 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
|||||||
|
|
||||||
public List<CardInSet> getCards() { return cardMap.get("cards"); }
|
public List<CardInSet> getCards() { return cardMap.get("cards"); }
|
||||||
public List<CardInSet> getAllCardsInSet() {
|
public List<CardInSet> getAllCardsInSet() {
|
||||||
ArrayList<CardInSet> cardsInSet = Lists.newArrayList(cardMap.values());
|
|
||||||
Collections.sort(cardsInSet);
|
|
||||||
return cardsInSet;
|
return cardsInSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +393,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLargeSet() {
|
public boolean isLargeSet() {
|
||||||
return getAllCardsInSet().size() > 200 && !smallSetOverride;
|
return this.cardsInSet.size() > 200 && !smallSetOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCntBoosterPictures() {
|
public int getCntBoosterPictures() {
|
||||||
|
|||||||
@@ -308,6 +308,8 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
|
|||||||
private String retrieveCollectorNumber() {
|
private String retrieveCollectorNumber() {
|
||||||
CardEdition.Collection editions = StaticData.instance().getEditions();
|
CardEdition.Collection editions = StaticData.instance().getEditions();
|
||||||
CardEdition edition = editions.get(this.edition);
|
CardEdition edition = editions.get(this.edition);
|
||||||
|
if (edition == null) // don't bother continuing - non-existing card!
|
||||||
|
return NO_COLLECTOR_NUMBER;
|
||||||
int artIndexCount = 0;
|
int artIndexCount = 0;
|
||||||
String collectorNumberInEdition = "";
|
String collectorNumberInEdition = "";
|
||||||
for (CardEdition.CardInSet card : edition.getAllCardsInSet()) {
|
for (CardEdition.CardInSet card : edition.getAllCardsInSet()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user