mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Prevent partial complete Tiny Leaders decks being filtered out
This commit is contained in:
@@ -344,6 +344,22 @@ public enum DeckFormat {
|
||||
};
|
||||
}
|
||||
|
||||
public Predicate<Deck> hasLegalCardsPredicate() {
|
||||
return new Predicate<Deck>() {
|
||||
@Override
|
||||
public boolean apply(Deck deck) {
|
||||
if (cardPoolFilter != null) {
|
||||
for (final Entry<PaperCard, Integer> cp : deck.getAllCardsInASinglePool()) {
|
||||
if (!cardPoolFilter.apply(cp.getKey().getRules())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Predicate<PaperCard> isLegalCardPredicate() {
|
||||
return new Predicate<PaperCard>() {
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.StaticData;
|
||||
@@ -351,8 +352,17 @@ public class DeckProxy implements InventoryItem {
|
||||
}
|
||||
|
||||
public static Iterable<DeckProxy> getAllTinyLeadersDecks() {
|
||||
return getAllTinyLeadersDecks(null);
|
||||
}
|
||||
public static Iterable<DeckProxy> getAllTinyLeadersDecks(Predicate<Deck> filter) {
|
||||
final List<DeckProxy> result = new ArrayList<DeckProxy>();
|
||||
addDecksRecursivelly("Tiny Leaders", GameType.TinyLeaders, result, "", FModel.getDecks().getCommander(), DeckFormat.TinyLeaders.isLegalDeckPredicate());
|
||||
if (filter == null) {
|
||||
filter = DeckFormat.TinyLeaders.hasLegalCardsPredicate();
|
||||
}
|
||||
else {
|
||||
filter = Predicates.and(DeckFormat.TinyLeaders.hasLegalCardsPredicate(), filter);
|
||||
}
|
||||
addDecksRecursivelly("Tiny Leaders", GameType.TinyLeaders, result, "", FModel.getDecks().getCommander(), filter);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class RandomDeckGenerator extends DeckProxy implements Comparable<RandomD
|
||||
decks = DeckProxy.getAllCommanderDecks(DeckFormat.Commander.isLegalDeckPredicate());
|
||||
break;
|
||||
case TinyLeaders:
|
||||
decks = DeckProxy.getAllTinyLeadersDecks(); //already applies isLegal check for TinyLeaders
|
||||
decks = DeckProxy.getAllTinyLeadersDecks(DeckFormat.TinyLeaders.isLegalDeckPredicate());
|
||||
break;
|
||||
case Archenemy:
|
||||
decks = DeckProxy.getAllSchemeDecks(DeckFormat.Archenemy.isLegalDeckPredicate());
|
||||
|
||||
Reference in New Issue
Block a user