mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Refactor logic for determining when a card can be a commander into CardRules
This commit is contained in:
@@ -187,6 +187,14 @@ public final class CardRules implements ICardCharacteristics {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canBeCommander() {
|
||||
CardType type = mainPart.getType();
|
||||
if (type.isLegendary() && type.isCreature()) {
|
||||
return true;
|
||||
}
|
||||
return mainPart.getOracleText().contains("can be your commander");
|
||||
}
|
||||
|
||||
// public Set<String> getSets() { return this.setsPrinted.keySet(); }
|
||||
// public CardInSet getEditionInfo(final String setCode) {
|
||||
// final CardInSet result = this.setsPrinted.get(setCode);
|
||||
|
||||
@@ -328,10 +328,7 @@ public enum DeckFormat {
|
||||
if (cardPoolFilter != null && !cardPoolFilter.apply(rules)) {
|
||||
return false;
|
||||
}
|
||||
if (rules.getType().isLegendary() && rules.getType().isCreature()) {
|
||||
return true;
|
||||
}
|
||||
return rules.getOracleText().contains("can be your commander");
|
||||
return rules.canBeCommander();
|
||||
}
|
||||
|
||||
public Predicate<Deck> isLegalDeckPredicate() {
|
||||
|
||||
@@ -24,7 +24,7 @@ import forge.assets.ISkinImage;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardEdition.CardInSet;
|
||||
import forge.card.CardType;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.deck.generation.DeckGenPool;
|
||||
@@ -226,14 +226,14 @@ public enum ConquestPlane {
|
||||
if (!bannedCards.contains(card.name)) {
|
||||
PaperCard pc = FModel.getMagicDb().getCommonCards().getCard(card.name, setCode);
|
||||
if (pc != null) {
|
||||
CardType type = pc.getRules().getType();
|
||||
boolean isCommander = type.isLegendary() && type.isCreature();
|
||||
CardRules rules = pc.getRules();
|
||||
boolean isCommander = pc.getRules().canBeCommander();
|
||||
cardPool.add(pc);
|
||||
if (isCommander) {
|
||||
commanders.add(pc);
|
||||
}
|
||||
int count = 0;
|
||||
if (!type.isBasicLand()) { //add all basic lands to all regions below
|
||||
if (!rules.getType().isBasicLand()) { //add all basic lands to all regions below
|
||||
for (Region region : regions) {
|
||||
if (region.pred.apply(pc)) {
|
||||
region.cardPool.add(pc);
|
||||
|
||||
Reference in New Issue
Block a user