Commit Graph

1502 Commits

Author SHA1 Message Date
TRT
1529ffe630 Fix ImageKeys again 2021-08-28 07:38:32 +02:00
Michael Kamensky
18ab34e3d5 Merge branch 'patch-carddb-performance' into 'master'
Card Hover FIX in Catalog + extra optimisation in performance and refactoring

See merge request core-developers/forge!5263
2021-08-28 05:05:21 +00:00
Anthony Calosa
f6341a2bc9 fix ImageKeys.java 2021-08-27 22:13:46 +00:00
leriomaggio
b413b777bf Few impros for performance in itempool countAll
This implementation leverages on iterables.filter to filter all keys matching the input condition, which will be iterated for counting.
2021-08-27 20:05:12 +01:00
leriomaggio
e92871a3c7 Replacing all calls to ImageUtil.hasBackFacePicture to corresponding new methods in PaperCard class (hasBackFace)
The ImageUtil.hasBackFacePicture has been removed completely as not being in use anymore after the refactoring.
2021-08-27 17:30:32 +01:00
leriomaggio
ad7cad9a56 Added to iPaperCard new methods to get card art (alternate) keys, and whether there is a BackFace
These new methods will be used to cache the values of Image keys, as well as to determine whether a card has an alternate image (and so key).

Methods on CardImageKeys have been distinguished in names to not confuse them with similar names (but completely different use and output) from InventoryItems interface.
CardImageKeys for PaperCard are also cached in private attribute to reduce OPS in Card Catalogs that are consistently the same.
As for Tokens, the output of these two new methods is the same as getImageKey.

These methods have been also moved to interface (and so class) as this would result in better encapsulation (esp. hasBackFace - using CardRules within the card - similar to `Card` class).

ImageUtil.getImageKey calls will be replaced with these methods, limiting their use only to downloaders (when set attribute can be added or not). PaperCard will always add the set info).
2021-08-27 17:22:10 +01:00
leriomaggio
dbe0e15674 FIX in ImageKeys.hasImage removing Pattern.quote for //
Pattern.quote has some corner cases on MAC not working (`ME/` ended up in three splits).
Resorted back to `//` as the key will never be a true file path anyway!
2021-08-27 12:12:57 +01:00
leriomaggio
50dded5169 FIX in ImageKeys.hasImage using Pattern.quote to allow for Windows compatibility 2021-08-27 09:04:32 +01:00
Michael Kamensky
be34d5ee6c Merge branch 'patch-carddb-performance' into 'master'
CardDb Optimisations

See merge request core-developers/forge!5258
2021-08-27 04:20:40 +00:00
leriomaggio
970d9b4b8d removed unused import 2021-08-26 08:04:26 +01:00
leriomaggio
26ec34e019 Updated tests and capped artIndex to be two digits! 2021-08-26 07:23:09 +01:00
Anthony Calosa
7c56d50192 addAny must be random art 2021-08-26 05:43:41 +00:00
Anthony Calosa
74f86aa0c6 Update CardPool.java 2021-08-26 04:33:38 +00:00
Anthony Calosa
62ac73c916 Update CardPool.java 2021-08-26 04:12:37 +00:00
Anthony Calosa
847d165300 Update StaticData.java 2021-08-26 03:43:43 +00:00
leriomaggio
18a537bb5e Merge remote-tracking branch 'upstream/master' into patch-carddb-performance 2021-08-26 03:03:25 +01:00
leriomaggio
4fc0234ccc Improved performance w/ cached content for ImageKeys.hasImage
THe content of the setFolder is cached, filtering only images and key prefixes.
Working on prefixes only to get rid of all .full or .fullborder possible variations.
2021-08-26 03:02:52 +01:00
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