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:
leriomaggio
2021-05-27 10:38:51 +00:00
committed by Michael Kamensky
parent 68fe024d5a
commit 8d2d633f6d
4 changed files with 91 additions and 24 deletions

View File

@@ -661,24 +661,11 @@ public enum ColumnDef {
//make sure it's a card. if not, pointless to proceed.
String collectorNumber;
if (i instanceof PaperCard) {
collectorNumber = ((PaperCard) i).getCollectorNumber();
// First off, make all NO_COLLECTOR_NUMBER the last in sortings
if (collectorNumber.equals(IPaperCard.NO_COLLECTOR_NUMBER))
collectorNumber = "50000"; // very big number of 5 digits to have them in last positions
// Now, for proper sorting, let's zero-pad the collector number (if integer)
try {
int collNr = Integer.parseInt(collectorNumber);
collectorNumber = String.format("%05d", collNr);
} catch (NumberFormatException ex) {
String nonNumeric = collectorNumber.replaceAll("[0-9]", "");
String onlyNumeric = collectorNumber.replaceAll("[^0-9]", "");
collectorNumber = String.format("%05d", Integer.parseInt(onlyNumeric)) + nonNumeric;
}
collectorNumber = ((PaperCard) i).getCollectorNumberSortingKey();
} else {
collectorNumber = IPaperCard.NO_COLLECTOR_NUMBER;
}
return collectorNumber + toSortableName(i.getName());
return collectorNumber;
}
/**