This commit includes major updates to the CardDb aligned with the new ICardDatabase (refactored) API.
The implementation of the API now includes a more standardised and linear approach in (single) card retrieval which leverages on the refactored methods.
All these methods rely on the **new** and revised CardRequest object that now support a new method to compose request strings, as well as extending support to requests including the collector numbers.
This is a major update going towards the direction of integrating the collector number in Deck Importer when analysing cards lists.
All these new implementations have been thoroughly tested considering all possible conditions, foil cards, cards with multiple arts, and date filtering, and results compared with **previous** card DB implementation to be sure no behaviour was left uncovered from previous implementation.
(Please see `LegacyDb` class in `forge.card` tests for more details).
Cards in CardPool are now added also including the collector number directly. This should avoid PaperCard instances to rely on the retrieveCollectorNumber methods in PaperCard. [THIS needs to be tested yet].
Another major change to class structure regards the new renamed SetPreference to a more intuitive CardArtPreference.
This will be used to set up card art preference in the UI, as well as to guide card retrieval default behaviour.
(This option will be later included in the Desktop GUI as well).
Tests to compare the behaviour of these new options, and the old ones have been conducted, and all passed.
Also, this attribute has been moved from StaticData to CardDb as it seems more appropriate encapsulation, without any circular dependency.
A new method (not included in ICardDatabase) has been added to CardDb API (i.e. getCardFromEditions(name) ) which relies on the default Card Art preference.
Last but not least, Anthologies edition file receives an update on the TYPE (from other to reprint) to also deal with expected testings - case "Hymn To Tourach" when `LatestPrintNoPromoNoOnline` is selected.
This is an attempt to start removing all the hard-coded values
used throughout the code base whenever art index should be
invoked, by relying on a more stable approach based on
constants.
The API for Magic Card Database has been refactored so to include card look up methods as organised in three main categories:
- single card lookup based on details (name, ed code, collector number)
- card lookup from a given edition (i.e. CardEdition instance)
- card lookup based on Art Preference
Methods to retrieve collection of cards have been renamed to allow
for overloading, within a more consistent API.
Same for utility methods to retrieve cards' art index and count.
Last but not least, the old "getFoiled" method has been removed to leave space to the new method in PaperCard API.
StaticData now includes a new method, namely `getCardEdition` which looks for a CardEdition instance into editions and customeditions given an input set code.
This new method has been refactored and used throughout the new changes in Advanced Search and Filters.
- 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).
- 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).
- 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).
PaperCard instance now includes a new attribute (i.e. `collectorNumber`) that will be used later on to fill in the "CN" Column in List view (see `ColumnDef.java`).
To allow for minor disruption to existing API, the collectorNumber attribute will be handled in a _Property-like_ fashion via the getter method (i.e. `getCollectorNumber`).
In particular, if collectorNumber is marked as `UNSET` (i.e. `PaperCard.UNSET_COLLECTOR_NUMBER`), the corresponding value will be automatically retrieved from the matched `CardEdition`, and updated for later use.
Nevertheless, Constructors including the new parameter have been also set for future API change.
Moreover, the new attribute has been also considered in methods for object comparison, for a more accurate sorting criterion.
The second new addition to PaperCard API regards FOIL cards (i.e. `getFoiled()`).
This method was originally part of `CardDb` API as described in ISSUE #1848.
With this API change, an internal reference to a `PaperCard` (foil) instance will be used to return the foil version of "itself" for each PaperCard Instance. This will avoid proliferation of PaperCard instances in memory, while keeping all information consistent with the original "unfoiled" card.
NOTE: at the moment, every card can be Foiled, with no restriction whatsoever on the _actual_ existence of original (true) PaperCard.
The IPaperCard interface now includes a method to return the Collector Number of a Card.
Moreover, two new constants have been included for Default Art Index (i.e. 1) and a flag to mark the absence of a Collector Number (i.e. 0).