update hasLegalCardsPredicate when deckconformance is turned off

- fixes #3271
This commit is contained in:
Anthony Calosa
2023-06-15 06:25:35 +08:00
parent f59cf3791e
commit cabd79b6b4
2 changed files with 7 additions and 5 deletions

View File

@@ -482,10 +482,12 @@ public enum DeckFormat {
};
}
public Predicate<Deck> hasLegalCardsPredicate() {
public Predicate<Deck> hasLegalCardsPredicate(boolean enforceDeckLegality) {
return new Predicate<Deck>() {
@Override
public boolean apply(Deck deck) {
if (!enforceDeckLegality)
return true;
if (cardPoolFilter != null) {
for (final Entry<PaperCard, Integer> cp : deck.getAllCardsInASinglePool()) {
if (!cardPoolFilter.apply(cp.getKey().getRules())) {

View File

@@ -473,9 +473,9 @@ public class DeckProxy implements InventoryItem {
public static Iterable<DeckProxy> getAllTinyLeadersDecks(Predicate<Deck> filter) {
final List<DeckProxy> result = new ArrayList<>();
if (filter == null) {
filter = DeckFormat.TinyLeaders.hasLegalCardsPredicate();
filter = DeckFormat.TinyLeaders.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY));
} else {
filter = Predicates.and(DeckFormat.TinyLeaders.hasLegalCardsPredicate(), filter);
filter = Predicates.and(DeckFormat.TinyLeaders.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)), filter);
}
addDecksRecursivelly("Tiny Leaders", GameType.TinyLeaders, result, "", FModel.getDecks().getTinyLeaders(), filter);
return result;
@@ -487,9 +487,9 @@ public class DeckProxy implements InventoryItem {
public static Iterable<DeckProxy> getAllBrawlDecks(Predicate<Deck> filter) {
final List<DeckProxy> result = new ArrayList<>();
if (filter == null) {
filter = DeckFormat.Brawl.hasLegalCardsPredicate();
filter = DeckFormat.Brawl.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY));
} else {
filter = Predicates.and(DeckFormat.Brawl.hasLegalCardsPredicate(), filter);
filter = Predicates.and(DeckFormat.Brawl.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)), filter);
}
addDecksRecursivelly("Brawl", GameType.Brawl, result, "", FModel.getDecks().getBrawl(), filter);
return result;