Refactor logic for determining when a card can be a commander into CardRules

This commit is contained in:
drdev
2015-12-08 02:14:36 +00:00
parent d7d6fbc222
commit 64bc5e0484
3 changed files with 13 additions and 8 deletions

View File

@@ -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);

View File

@@ -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() {

View File

@@ -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);