Commit Graph

1261 Commits

Author SHA1 Message Date
Anthony Calosa
6f0ba03d24 [Mobile] Fix blinking card images while using online image fetcher
- also cache card list for faster lookup
2021-09-12 15:52:57 +08:00
leriomaggio
fb092c77a4 BUG FIX for Smart Card Art selection
This subtle bug occurred whenever the algorithm for smart card art selection wanted to add a card with multiple arts and the number of cards per art to add was not even. To avoid zeros, the cardsPerArtIndex was set at least to one, and so the rest - leading then to adding too many (extra) cards not originally present in the deck.

Thanks to @Snoops for the heads up.
2021-09-12 00:56:44 +01:00
leriomaggio
27ab4c35a3 Re-add to carddb the integration with CardPreferences on Mobile version
On Mobile Forge Port (only) there is the possibility to set a preferred art for a card, from card catalog.
Once a card art is selected, it will always be returned for that specific art whenever no other specific edition is specified.
This commit adds changes to cardDb setPreferredArtMethod (API) and CardRequest.fromString to work with any preferred art (if any).

CardRequests reflects this change by adding another (private) constructor which expects to create a CardRequest from a preferredArt entry in the form of (CardName|SetCode|ArtIndex)
2021-09-10 14:09:25 +01:00
leriomaggio
9d235924ec Re-add to carddb the integration with CardPreferences on Mobile version
On Mobile Forge Port (only) there is the possibility to set a preferred art for a card, from card catalog.
Once a card art is selected, it will always be returned for that specific art.
This commit adds changes to cardDb setPreferredArtMethod (API) and CardRequest.fromString to work with any preferred art (if any).

CardRequests reflects this change by adding another (private) constructor which expects to create a CardRequest from a preferredArt entry in the form of (CardName|SetCode|ArtIndex)
2021-09-10 13:26:30 +01:00
Michael Kamensky
d367f8abf9 Merge branch 'master' into 'master'
[Mobile] add Artist & adjust crop for modern/old frames

See merge request core-developers/forge!5290
2021-09-04 18:46:15 +00:00
Anthony Calosa
cd47c591b3 add Artist & adjust crop for modern/old frames 2021-09-04 18:54:49 +08:00
tool4EvEr
3bf978991c Revert Comment out some currently unsupported cards in Commander precons 2021-09-04 11:33:44 +02:00
leriomaggio
24c31e9de9 Restored sort in CardPool using Collections to allow for Android comp. 2021-08-29 11:02:26 +01:00
leriomaggio
b1ed8565d3 FIXED typo in using iterator rather than keyset directly 2021-08-29 08:06:43 +01:00
leriomaggio
831b40e753 Removed unused imports! 2021-08-28 21:13:59 +01:00
leriomaggio
924c57be70 FIX typo, and renamed vars! 2021-08-28 20:58:06 +01:00
leriomaggio
eea2b754ec Added new Lookup table for sortable collector number to avoid repeated computations for the same coll numbers!
FIX typo and made map final!
2021-08-28 20:55:33 +01:00
leriomaggio
e2034ebd51 Added new Lookup table for sortable collector number to avoid repeated computations for the same coll numbers! 2021-08-28 20:48:27 +01:00
leriomaggio
a8acbf0491 Improved CountAll method implementation using Maps 2021-08-28 20:46:44 +01:00
leriomaggio
8768900cf8 FIX cardDb bug for lazy card loading when issuing a request with a non-existing set code.
Code FIX + Test
Now the implementation in CardDb will automatically try to get the card with that name from an existing edition
2021-08-28 18:29:07 +01:00
leriomaggio
a7d1e7398a FIX cardDb bug for lazy card loading when issuing a request with a non-existing set code.
Code FIX + Test
2021-08-28 17:54:53 +01:00
leriomaggio
b1c50599e9 Improvements to getFilteredPool method.
Previous implementation did not consider the amount per card included in the pool already - so the filtered pool always got 1 amount for each card passing the filter.

This should be no problem considering where this method is used. However, to make it portable to other cases, I made the implementation to report the same amount of cards in the new filtered pool.
2021-08-28 16:59:26 +01:00
leriomaggio
7613b27e6e Still scratching a little of performance impros by avoiding checking class instance.
When StatTypeFilter is used withing Deck Editor (with all PaperCard instance in ItemPool), avoiding checking instance class improves performance a bit (saving a couple of hundreds of milliseconds).

However, when this filter with also other inventory items (pack or deck), the same code as before is executed.
2021-08-28 16:47:10 +01:00
leriomaggio
42e91b60ea Code to cover cases for Randomly generated Deck (from Archetypes) not having collectorNumbers and Artist Set 2021-08-28 16:39:59 +01: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
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