mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Random brawl deck generator working on Desktop
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package forge;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRules;
|
||||
@@ -32,6 +33,16 @@ public class StaticData {
|
||||
private final TokenDb allTokens;
|
||||
private final CardEdition.Collection editions;
|
||||
|
||||
public Predicate<PaperCard> getStandardPredicate() {
|
||||
return standardPredicate;
|
||||
}
|
||||
|
||||
public void setStandardPredicate(Predicate<PaperCard> standardPredicate) {
|
||||
this.standardPredicate = standardPredicate;
|
||||
}
|
||||
|
||||
private Predicate<PaperCard> standardPredicate;
|
||||
|
||||
// Loaded lazily:
|
||||
private IStorage<SealedProduct.Template> boosters;
|
||||
private IStorage<SealedProduct.Template> specialBoosters;
|
||||
|
||||
@@ -35,6 +35,7 @@ import forge.util.TextUtil;
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import java.awt.print.Paper;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -69,15 +70,7 @@ public enum DeckFormat {
|
||||
}
|
||||
}),
|
||||
Pauper ( Range.is(60), Range.between(0, 10), 1),
|
||||
Brawl ( Range.is(59), Range.between(0, 15), 1, new Predicate<CardRules>() {
|
||||
@Override
|
||||
public boolean apply(CardRules rules) {
|
||||
//must be standard legal
|
||||
//FModel.getFormats().getStandard();
|
||||
|
||||
return true;
|
||||
}
|
||||
}),
|
||||
Brawl ( Range.is(59), Range.between(0, 15), 1, StaticData.instance().getStandardPredicate(), null),
|
||||
TinyLeaders ( Range.is(49), Range.between(0, 10), 1, new Predicate<CardRules>() {
|
||||
private final Set<String> bannedCards = new HashSet<String>(Arrays.asList(
|
||||
"Ancestral Recall", "Balance", "Black Lotus", "Black Vise", "Channel", "Chaos Orb", "Contract From Below", "Counterbalance", "Darkpact", "Demonic Attorney", "Demonic Tutor", "Earthcraft", "Edric, Spymaster of Trest", "Falling Star",
|
||||
@@ -127,17 +120,32 @@ public enum DeckFormat {
|
||||
private final Range<Integer> sideRange; // null => no check
|
||||
private final int maxCardCopies;
|
||||
private final Predicate<CardRules> cardPoolFilter;
|
||||
private final Predicate<PaperCard> paperCardPoolFilter;
|
||||
private final static String ADVPROCLAMATION = "Advantageous Proclamation";
|
||||
private final static String SOVREALM = "Sovereign's Realm";
|
||||
|
||||
private DeckFormat(Range<Integer> mainRange0, Range<Integer> sideRange0, int maxCardCopies0) {
|
||||
this(mainRange0, sideRange0, maxCardCopies0, null);
|
||||
}
|
||||
private DeckFormat(Range<Integer> mainRange0, Range<Integer> sideRange0, int maxCardCopies0, Predicate<CardRules> cardPoolFilter0) {
|
||||
private DeckFormat(Range<Integer> mainRange0, Range<Integer> sideRange0, int maxCardCopies0, Predicate<PaperCard> paperCardPoolFilter0, Predicate<CardRules> cardPoolFilter0) {
|
||||
mainRange = mainRange0;
|
||||
sideRange = sideRange0;
|
||||
maxCardCopies = maxCardCopies0;
|
||||
cardPoolFilter = cardPoolFilter0;
|
||||
paperCardPoolFilter = paperCardPoolFilter0;
|
||||
}
|
||||
|
||||
private DeckFormat(Range<Integer> mainRange0, Range<Integer> sideRange0, int maxCardCopies0, Predicate<CardRules> cardPoolFilter0) {
|
||||
mainRange = mainRange0;
|
||||
sideRange = sideRange0;
|
||||
maxCardCopies = maxCardCopies0;
|
||||
paperCardPoolFilter = null;
|
||||
cardPoolFilter = cardPoolFilter0;
|
||||
}
|
||||
|
||||
private DeckFormat(Range<Integer> mainRange0, Range<Integer> sideRange0, int maxCardCopies0) {
|
||||
mainRange = mainRange0;
|
||||
sideRange = sideRange0;
|
||||
maxCardCopies = maxCardCopies0;
|
||||
paperCardPoolFilter = null;
|
||||
cardPoolFilter = null;
|
||||
}
|
||||
|
||||
private boolean hasCommander() {
|
||||
@@ -374,7 +382,16 @@ public enum DeckFormat {
|
||||
|
||||
public IDeckGenPool getCardPool(IDeckGenPool basePool) {
|
||||
if (cardPoolFilter == null) {
|
||||
return basePool;
|
||||
if (paperCardPoolFilter == null) {
|
||||
return basePool;
|
||||
}
|
||||
DeckGenPool filteredPool = new DeckGenPool();
|
||||
for (PaperCard pc : basePool.getAllCards()) {
|
||||
if (paperCardPoolFilter.apply(pc)) {
|
||||
filteredPool.add(pc);
|
||||
}
|
||||
}
|
||||
return filteredPool;
|
||||
}
|
||||
DeckGenPool filteredPool = new DeckGenPool();
|
||||
for (PaperCard pc : basePool.getAllCards()) {
|
||||
@@ -391,7 +408,10 @@ public enum DeckFormat {
|
||||
|
||||
public boolean isLegalCard(PaperCard pc) {
|
||||
if (cardPoolFilter == null) {
|
||||
return true;
|
||||
if (paperCardPoolFilter == null) {
|
||||
return true;
|
||||
}
|
||||
return paperCardPoolFilter.apply(pc);
|
||||
}
|
||||
return cardPoolFilter.apply(pc.getRules());
|
||||
}
|
||||
@@ -426,6 +446,13 @@ public enum DeckFormat {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (paperCardPoolFilter != null) {
|
||||
for (final Entry<PaperCard, Integer> cp : deck.getAllCardsInASinglePool()) {
|
||||
if (!paperCardPoolFilter.apply(cp.getKey())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user