mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Further optimised cardDb method with filter using AlwaysTrue + and Chain
Signed-off-by: leriomaggio <valeriomaggio@gmail.com>
This commit is contained in:
@@ -694,6 +694,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
|
|
||||||
List<PaperCard> cards;
|
List<PaperCard> cards;
|
||||||
Predicate<PaperCard> cardQueryFilter;
|
Predicate<PaperCard> cardQueryFilter;
|
||||||
|
filter = (filter != null) ? filter : Predicates.alwaysTrue();
|
||||||
if (releaseDate != null) {
|
if (releaseDate != null) {
|
||||||
cardQueryFilter = new Predicate<PaperCard>() {
|
cardQueryFilter = new Predicate<PaperCard>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -715,8 +716,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
return card.getArtIndex() == cr.artIndex;
|
return card.getArtIndex() == cr.artIndex;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (filter != null)
|
cardQueryFilter = Predicates.and(cardQueryFilter, filter);
|
||||||
cardQueryFilter = Predicates.and(cardQueryFilter, filter);
|
|
||||||
cards = getAllCards(cr.cardName, cardQueryFilter);
|
cards = getAllCards(cr.cardName, cardQueryFilter);
|
||||||
// Note: No need to check whether "cards" is empty; the next for loop will validate condition at L699
|
// Note: No need to check whether "cards" is empty; the next for loop will validate condition at L699
|
||||||
if (cards.size() == 1) // if only one candidate, there much else we should do
|
if (cards.size() == 1) // if only one candidate, there much else we should do
|
||||||
|
|||||||
Reference in New Issue
Block a user