Commit Graph

1485 Commits

Author SHA1 Message Date
leriomaggio
dde96156be Simplified condition on artIndex when retrieving relative path for card image. 2021-08-26 02:49:26 +01:00
leriomaggio
119ac88ad5 PaperCard now includes an ImageKeyFromSet attr. cached for later re-use! 2021-08-26 02:48:57 +01:00
leriomaggio
6fef56c8b7 Simplified isDirectoryWithFiles reducing I/O ops
(as per Grimm suggestions!)
2021-08-26 02:48:15 +01:00
leriomaggio
3acf7384e3 FIXED Sneaky bug that capped art index in DB requests to one digit!
(Added tests in cardDb and CardRequest to cover the case!)
2021-08-26 02:47:35 +01:00
leriomaggio
fed48e01c2 Pushed even further on improvements, making it run even faster than legacy
The huge improvement is due to a re-use of a getAllCards(Name, Predicate) method I started implementing into another branch for DeckImporter - re-using this method internally resolves a **lot** of duplicated iterations, and checks, which made the whole method to run even faster than the original legacy implementation!

An extra test method has been added to verify the corner case of querying for a card from editions with a very high (and weird) artIndex (like a land) - making sure that exact card is finally returned!
2021-08-25 21:03:15 +01:00
leriomaggio
bccf6e0a27 new method with tests to get all cards with a filter predicate.
New method in Interface API to get all cards in a given setCode.
This has changed the implementation of getArtCount avoiding to iterate over all the possible card prints.
2021-08-25 19:39:54 +01:00
leriomaggio
f507edada5 Same optimisation using iterator on getCardFromSet 2021-08-25 18:49:03 +01:00
leriomaggio
7b70a34da0 further optimisation by using iterator rather than forloop with if-clauses 2021-08-25 18:44:59 +01:00
leriomaggio
841c98dc12 First round of optimisation to CardDb
This optimisation removes redundant queries when looking for cards by specificed Art Preference.

getCardsFromSet has been worked-around, avoiding querying for potential candidates already in memory.
A preliminary benchmark/tests is implemented too.
2021-08-25 18:15:28 +01:00
Bug Hunter
dddacd5215 Fix Cascade from opponents zone 2021-08-25 17:07:11 +00:00
leriomaggio
d8f19fdda2 First CardDb optimisation - reusing same strategy for lazyLoading
There was a FIXME/TODO comment I just have found out relating to putCard implementation being inefficient.
I've re-used the new-methods implemented for lazyCardLoading to improve existing implementation.
Also, now all the PaperCard constructors won't miss collectorNumber and ArtistNames as gathered from CardInSet in CardEdition - YAY
2021-08-25 12:28:13 +01:00
leriomaggio
c726cf6fb0 Various Optimisations for re-use and removed dead-code
Various optimisation to the PaperCard implementation:

- removed once and for all retrieveCollectorNumber method - we're now safe and sound that all PaperCard instances will have a collector Number matched.

- That is also made sure by removing all the many (legacy) class constructors. Only left two - with correct parameter passing!

- finally, collectorNumberSortingKey is created onces, and saved - as this won't change (for better performance)
2021-08-25 12:22:02 +01:00
leriomaggio
b49fe104fc Added constant for NO artist name (for later re-use) 2021-08-25 12:18:53 +01:00
leriomaggio
fb27b66621 Added docstring to getCardInSet method 2021-08-25 12:07:00 +01:00
leriomaggio
7c2a2de12f Updates to new card formats, and support for new token types.
DeckRecognizer is **the** core of the new Deck Import functionalities.
DeckRecognizer has been extended with more flexible, and alternative reg/exp for better card recognition, as well as Deck sections, card types, and deck name.

When retrieving cards from the db, the recogniser will also incorporate validation to check against illegal (from set) or banned cards considering current game/deck format.

The new set of regexp guarantee support for several M:TG deck format, including deckstats.net; tappedout; mtg-arena; mtgo
2021-08-23 00:02:58 +01:00
leriomaggio
0f8541154a Added method to **set** the name of a Deck
name attribute is now also accessible in write. This will make possible to set the name of a deck after the import process.
2021-08-22 23:30:06 +01:00
leriomaggio
89687a45ed Deck now integrates validation of Deck Sections
Validation of Deck Sections is applied only once per deck.
2021-08-22 23:28:48 +01:00
leriomaggio
057213342c DeckSection have been extended in order to support validation
Each section requiring Validation, now can incorporate a method for sanity check. This will be useful when the deck importer will import cards that are placed in the wrong section in the list.
2021-08-22 23:27:52 +01:00
leriomaggio
2950a567d8 New Method to filter a card pool based on a Predicate
This method will be used during the validation of each deck section.
2021-08-22 23:26:19 +01:00
leriomaggio
215c47b61d Updated with new API methods implementations & new compose for request
CardRequest now include a compose (parameter) alternative to just create a CardRequest by name, and/or a boolean flag.
Other changes include actual implementation of the new API methods (see prev. commit)
2021-08-22 23:13:17 +01:00
leriomaggio
4448cfca68 Extended DB API with pair of new methods
GetCardFromEditions (series of) methods now support to specify
a Predicate to filter the set of available candidates when gathering all the same card prints (by name).

For this reason, a new Predicate (isLegal) has been added to include limitations (filtering) based on set codes.

getAllCards method now include the possibility to provide a predicate
as a filter.
2021-08-22 23:10:53 +01:00
Anthony Calosa
e1a3c722cd Update ImageKeys.java 2021-08-19 12:33:07 +00:00
Anthony Calosa
96f8dc0791 Update ImageKeys.java 2021-08-17 09:11:10 +00:00
Anthony Calosa
6a99ee00f1 Simulation test don't need setlookup 2021-08-16 13:42:05 +08:00
Anthony Calosa
4c09b11b63 remove redundant code 2021-08-16 12:48:19 +08:00
Anthony Calosa
3d322e47ee Support Set lookup for J21 and other future sets.
Forge loads all files found on the setlookup folder.
Example J21.txt (J21 set code) contains a list of set codes (sorted from Newest to Oldest beforehand) to lookup for images on other sets.
2021-08-16 12:06:20 +08:00
leriomaggio
838f817be7 Merge remote-tracking branch 'upstream/master' into collector-number-in-card-list-and-card-db-refactoring 2021-08-14 08:27:09 +01:00
tool4EvEr
be81ba5e15 Fix life lost triggers 2021-08-13 21:25:24 +02:00
leriomaggio
258f57e080 Merge remote-tracking branch 'upstream/master' into collector-number-in-card-list-and-card-db-refactoring 2021-08-13 11:25:38 +01:00
leriomaggio
b870d519c9 Updating Deck to use the new method in StaticData to get Card Art Preference Name
(Forgot to include this in prev. commit)
2021-08-13 10:19:37 +01:00
leriomaggio
beaf98793b Renamed method to retrieve card art preference name and new method to return actual card art preference instance. 2021-08-13 10:15:08 +01:00
leriomaggio
4b1e9b6c0c Improved Implementation for Card Art Optimisation
The new implementation now contains a completely refactored version of the algorithm, also including the invocation of the latest method for getAlternativeCardPrint in StaticData (with extra statistics paramenters gathered from current pool). This include optimisation for card frame, and cards from Expansion sets.

Moreover, the new implementation now automatically distribute card arts for **all** the cards in the pool - regardless they need to be "replaced" with alternative print or not.

THE ONLY case when this is not happening is when there is NO card to update in the current pool. This makes sense as this means editions has been specified, so the Deck won't receive any UNDESIRED alteration.
2021-08-12 16:35:08 +01:00
leriomaggio
e54916e837 Extended API with new methods to gather Pool Statistics and the Pivot CardEdition
CardPool API has been extended by including utility methods to gather specific statistics about a cardPool. These statistics include:
- Distribution (card count frequency) of the Card Edition included in the Pool
- Distribution of the Card Edition Type included in the Pool
- Retrieving the most common Card Edition Type among those included in the Pool
- Determine whether or not the Pool "isModern" (i.e. the majority of cards is gathered from Modern Sets)
- get the PivotCardEdition: this is the cornerstone of card art optimisation for decks

The PivotCardEdition is the edition that will be considered the threshold boundary for cards in the pool. Any decision of card arts for other cards will be considered based on the PivotEdition, that is "alternativeCardPrint" released BEFORE or AFTER (depending on the current Card Art Preference) the PIVOT EDITION RELEASE DATE.

Also, this commit includes an optimisation in add method implementation, getting rid of lots of duplicated code!
2021-08-12 16:30:33 +01:00
leriomaggio
788c2d8c14 Better renaming to existing methods for Card Art Preference and NEW getAlternativeCardPrint implementations
Methods related to Card Art Preference Settings, and for Card Art Smart Selection have been renamed with better wording.

Most importantly, StaticData now includes a new method to retrieve the number of art count for a given PaperCard, as well as a completely refactored and improved method for getAlternativeCardPrint.
In particular, the class now provides three different implementation of getAlternativeCardPrint, with the more sophisticated one also including normalisation wrt. the card frame, and whether or not the chosen alternative print should be gathered from an Expansion edition.

All these specialisation are part of the "Card Art Optimisation" algorithm included in Deck, and instructed by statistics gathered from Card Pool (next commit)
2021-08-12 16:17:31 +01:00
leriomaggio
000622cfae Added MEMO comment to get rid of retrieveCollectorNumber method 2021-08-12 15:52:58 +01:00
leriomaggio
a195bfd2b6 Minor adjustment to getArtCount implementation. 2021-08-11 08:16:21 +01:00
leriomaggio
8f99123059 Add new method to traverse and extract all directories recursively given a FilenameFilter
This method is part of the FIX for Issue #1949, that will be invoked by all the NetDeckXXX classes.
2021-08-11 08:05:08 +01:00
tool4EvEr
805e65d30c Small combat fixes for Planeswalkers 2021-08-10 21:10:45 +02:00
Michael Kamensky
1a7845117b [maven-release-plugin] prepare for next development iteration 2021-08-07 06:30:54 +03:00
Michael Kamensky
5c768baf64 [maven-release-plugin] prepare release forge-1.6.44 2021-08-07 06:30:45 +03:00
leriomaggio
05cfc48b43 Improved mechanism for on-the-fly (no restart) card art update in decks.
Now the smart card art selection is also included in the set of checkings that are performed to see whether or not card arts in Pools require any update.
2021-08-05 12:36:43 +01:00
leriomaggio
fe9274dabb Added mechanism to update card art when necessary
Deferred sections for deck are only used once, and just when the deck needs to be loaded. At that time, if any optimisation to card art is enabled (and required, that is "there are cards with no pre-specified edition").

After that, sections are memorised and later updated if anything needs updates, and the last used card art preference was different.
2021-08-04 18:00:13 +01:00
leriomaggio
f0f881dbeb Attempt to load Card now with setcode in use (also overloaded when not necessary) 2021-08-04 16:01:56 +01:00
leriomaggio
40b20e961a CASE INSENSITIVE card map lookup for lazy card load 2021-08-04 15:59:57 +01:00
leriomaggio
a9c1c01a20 FIXED bug in CardStorageReader to support numbers in card names w/ lazy card loading
Borrowing 100,000 Arrows was the driver test case
2021-08-04 15:59:31 +01:00
leriomaggio
58b2a070ed Added test for corner cases with different case in card name and set code (also compared to legacy implementation)
Also, now LoadCard also uses the provided setCode (if any).
If null or empty string is provided in request, all editions will be used!
2021-08-04 15:58:41 +01:00
leriomaggio
09822bdda2 Overloading PaperCard constructor without artIndex with default constant 2021-08-04 10:59:34 +01:00
leriomaggio
ce589ca6e8 removed previously introduced workaround for lowercase comparison 2021-08-04 10:58:23 +01:00
leriomaggio
ead4d134ea Merge remote-tracking branch 'upstream/master' into collector-number-in-card-list-and-card-db-refactoring 2021-08-04 08:51:56 +01:00
leriomaggio
eb9646a0c9 Faster method to load card w/ lazy card load 2021-08-04 08:24:11 +01:00