mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Merge branch 'BrawlFormat' into 'master'
Brawl format See merge request core-developers/forge!324
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,9 @@ public class StaticData {
|
||||
private final TokenDb allTokens;
|
||||
private final CardEdition.Collection editions;
|
||||
|
||||
private Predicate<PaperCard> standardPredicate;
|
||||
private Predicate<PaperCard> modernPredicate;
|
||||
|
||||
// Loaded lazily:
|
||||
private IStorage<SealedProduct.Template> boosters;
|
||||
private IStorage<SealedProduct.Template> specialBoosters;
|
||||
@@ -186,6 +190,18 @@ public class StaticData {
|
||||
|
||||
public TokenDb getAllTokens() { return allTokens; }
|
||||
|
||||
public Predicate<PaperCard> getStandardPredicate() {
|
||||
return standardPredicate;
|
||||
}
|
||||
|
||||
public void setStandardPredicate(Predicate<PaperCard> standardPredicate) { this.standardPredicate = standardPredicate; }
|
||||
|
||||
public void setModernPredicate(Predicate<PaperCard> modernPredicate) { this.modernPredicate = standardPredicate; }
|
||||
|
||||
public Predicate<PaperCard> getModernPredicate() {
|
||||
return modernPredicate;
|
||||
}
|
||||
|
||||
public PaperCard getCardByEditionDate(PaperCard card, Date editionDate) {
|
||||
|
||||
PaperCard c = this.getCommonCards().getCardFromEdition(card.getName(), editionDate, CardDb.SetPreference.LatestCoreExp, card.getArtIndex());
|
||||
|
||||
@@ -207,6 +207,11 @@ public final class CardRules implements ICardCharacteristics {
|
||||
return canBeCommander() && Iterables.contains(mainPart.getKeywords(), "Partner");
|
||||
}
|
||||
|
||||
public boolean canBeBrawlCommander() {
|
||||
CardType type = mainPart.getType();
|
||||
return (type.isLegendary() && type.isCreature()) || type.isPlaneswalker();
|
||||
}
|
||||
|
||||
public String getMeldWith() {
|
||||
return meldWith;
|
||||
}
|
||||
|
||||
@@ -572,6 +572,8 @@ public final class CardRulesPredicates {
|
||||
public static final Predicate<CardRules> IS_NON_CREATURE_SPELL = Predicates.not(Predicates.or(Presets.IS_CREATURE, Presets.IS_LAND));
|
||||
public static final Predicate<CardRules> CAN_BE_COMMANDER = Predicates.or(CardRulesPredicates.rules(StringOp.CONTAINS_IC, "can be your commander"),
|
||||
Predicates.and(Presets.IS_CREATURE, Presets.IS_LEGENDARY));
|
||||
public static final Predicate<CardRules> CAN_BE_BRAWL_COMMANDER = Predicates.or(Presets.IS_PLANESWALKER,
|
||||
Predicates.and(Presets.IS_CREATURE, Presets.IS_LEGENDARY));
|
||||
|
||||
/** The Constant IS_NONCREATURE_SPELL_FOR_GENERATOR. **/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -68,6 +68,8 @@ public enum DeckFormat {
|
||||
return true;
|
||||
}
|
||||
}),
|
||||
Pauper ( Range.is(60), Range.between(0, 10), 1),
|
||||
Brawl ( Range.is(59), Range.between(0, 15), 1, null, StaticData.instance() == null ? null : StaticData.instance().getStandardPredicate()),
|
||||
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",
|
||||
@@ -117,21 +119,36 @@ 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<CardRules> cardPoolFilter0, Predicate<PaperCard> paperCardPoolFilter0) {
|
||||
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() {
|
||||
return this == Commander || this == TinyLeaders;
|
||||
return this == Commander || this == TinyLeaders || this == Brawl;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,7 +381,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()) {
|
||||
@@ -381,7 +407,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());
|
||||
}
|
||||
@@ -390,6 +419,9 @@ public enum DeckFormat {
|
||||
if (cardPoolFilter != null && !cardPoolFilter.apply(rules)) {
|
||||
return false;
|
||||
}
|
||||
if(this.equals(DeckFormat.Brawl)) {
|
||||
return rules.canBeBrawlCommander();
|
||||
}
|
||||
return rules.canBeCommander();
|
||||
}
|
||||
|
||||
@@ -413,6 +445,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