diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 9d66fb23171..b7e96d35549 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -1930,4 +1930,7 @@ public class ComputerUtilCard { public static boolean isCardRemRandomDeck(final Card card) { return card.getRules() != null && card.getRules().getAiHints().getRemRandomDecks(); } + public static boolean isCardRemNonCommanderDeck(final Card card) { + return card.getRules() != null && card.getRules().getAiHints().getRemNonCommanderDecks(); + } } diff --git a/forge-core/src/main/java/forge/card/CardAiHints.java b/forge-core/src/main/java/forge/card/CardAiHints.java index b83e8459438..a7b2c8e7255 100644 --- a/forge-core/src/main/java/forge/card/CardAiHints.java +++ b/forge-core/src/main/java/forge/card/CardAiHints.java @@ -9,15 +9,17 @@ public class CardAiHints { private final boolean isRemovedFromAIDecks; private final boolean isRemovedFromRandomDecks; + private final boolean isRemovedFromNonCommanderDecks; private final DeckHints deckHints; private final DeckHints deckNeeds; private final DeckHints deckHas; - public CardAiHints(boolean remAi, boolean remRandom, DeckHints dh, DeckHints dn, DeckHints has) { + public CardAiHints(boolean remAi, boolean remRandom, boolean remUnlessCommander, DeckHints dh, DeckHints dn, DeckHints has) { isRemovedFromAIDecks = remAi; isRemovedFromRandomDecks = remRandom; + isRemovedFromNonCommanderDecks = remUnlessCommander; deckHints = dh; deckNeeds = dn; deckHas = has; @@ -42,8 +44,17 @@ public class CardAiHints { } /** - * @return the deckHints + * Gets the rem random decks. + * + * @return the rem random decks */ + public boolean getRemNonCommanderDecks() { + return this.isRemovedFromNonCommanderDecks; + } + + /** + * @return the deckHints + */ public DeckHints getDeckHints() { return deckHints; } diff --git a/forge-core/src/main/java/forge/card/CardRules.java b/forge-core/src/main/java/forge/card/CardRules.java index 6cd5b4daaee..0593a8c4362 100644 --- a/forge-core/src/main/java/forge/card/CardRules.java +++ b/forge-core/src/main/java/forge/card/CardRules.java @@ -291,6 +291,7 @@ public final class CardRules implements ICardCharacteristics { // fields to build CardAiHints private boolean removedFromAIDecks = false; private boolean removedFromRandomDecks = false; + private boolean removedFromNonCommanderDecks = false; private DeckHints hints = null; private DeckHints needs = null; private DeckHints has = null; @@ -310,6 +311,7 @@ public final class CardRules implements ICardCharacteristics { this.removedFromAIDecks = false; this.removedFromRandomDecks = false; + this.removedFromNonCommanderDecks = false; this.needs = null; this.hints = null; this.has = null; @@ -324,7 +326,7 @@ public final class CardRules implements ICardCharacteristics { * @return the card */ public final CardRules getCard() { - CardAiHints cah = new CardAiHints(removedFromAIDecks, removedFromRandomDecks, hints, needs, has); + CardAiHints cah = new CardAiHints(removedFromAIDecks, removedFromRandomDecks, removedFromNonCommanderDecks, hints, needs, has); faces[0].assignMissingFields(); if (null != faces[1]) faces[1].assignMissingFields(); final CardRules result = new CardRules(faces, altMode, cah); @@ -377,6 +379,7 @@ public final class CardRules implements ICardCharacteristics { if ( "RemoveDeck".equals(variable) ) { this.removedFromAIDecks = "All".equalsIgnoreCase(value); this.removedFromRandomDecks = "Random".equalsIgnoreCase(value); + this.removedFromNonCommanderDecks = "NonCommander".equalsIgnoreCase(value); } } else if ("AlternateMode".equals(key)) { //System.out.println(faces[curFace].getName()); @@ -551,7 +554,7 @@ public final class CardRules implements ICardCharacteristics { } public static CardRules getUnsupportedCardNamed(String name) { - CardAiHints cah = new CardAiHints(true, true, null, null, null); + CardAiHints cah = new CardAiHints(true, true, true,null, null, null); CardFace[] faces = { new CardFace(name), null}; faces[0].setColor(ColorSet.fromMask(0)); faces[0].setType(CardType.parse("")); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index ec0b0c270ba..677abaa805d 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -290,10 +290,17 @@ public abstract class DeckGeneratorBase { // remove cards that generated decks don't like Predicate canPlay = forAi ? AI_CAN_PLAY : HUMAN_CAN_PLAY; Predicate hasColor = new MatchColorIdentity(colors); + Predicate canUseInFormat = new Predicate() { + @Override + public boolean apply(CardRules c) { + return !c.getAiHints().getRemNonCommanderDecks() || format.hasCommander(); + } + }; + if (useArtifacts) { hasColor = Predicates.or(hasColor, COLORLESS_CARDS); } - return Iterables.filter(pool.getAllCards(),Predicates.compose(Predicates.and(canPlay, hasColor), PaperCard.FN_GET_RULES)); + return Iterables.filter(pool.getAllCards(),Predicates.compose(Predicates.and(canPlay, hasColor, canUseInFormat), PaperCard.FN_GET_RULES)); } protected static Map countLands(ItemPool outList) { diff --git a/forge-gui/res/cardsfolder/a/arcane_signet.txt b/forge-gui/res/cardsfolder/a/arcane_signet.txt index 0dcb51f1ae8..3392caee2d7 100644 --- a/forge-gui/res/cardsfolder/a/arcane_signet.txt +++ b/forge-gui/res/cardsfolder/a/arcane_signet.txt @@ -2,4 +2,5 @@ Name:Arcane Signet ManaCost:2 Types:Artifact A:AB$ Mana | Cost$ T | Produced$ Combo ColorIdentity | SpellDescription$ Add one mana of any color in your commander's color identity. +AI:RemoveDeck:NonCommander Oracle:{T}: Add one mana of any color in your commander's color identity. diff --git a/forge-gui/res/cardsfolder/c/command_tower.txt b/forge-gui/res/cardsfolder/c/command_tower.txt index cc90d04bf15..6767363dede 100644 --- a/forge-gui/res/cardsfolder/c/command_tower.txt +++ b/forge-gui/res/cardsfolder/c/command_tower.txt @@ -2,5 +2,6 @@ Name:Command Tower ManaCost:no cost Types:Land A:AB$ Mana | Cost$ T | Produced$ Combo ColorIdentity | SpellDescription$ Add one mana of any color in your commander's color identity. +AI:RemoveDeck:NonCommander SVar:Picture:http://www.wizards.com/global/images/magic/general/command_tower.jpg Oracle:{T}: Add one mana of any color in your commander's color identity. diff --git a/forge-gui/res/cardsfolder/o/opal_palace.txt b/forge-gui/res/cardsfolder/o/opal_palace.txt index 645dbfeeb62..d9b8fb16ba8 100644 --- a/forge-gui/res/cardsfolder/o/opal_palace.txt +++ b/forge-gui/res/cardsfolder/o/opal_palace.txt @@ -4,7 +4,6 @@ Types:Land A:AB$ Mana | Cost$ T | Produced$ C | SpellDescription$ Add {C}. A:AB$ Mana | Cost$ 1 T | Produced$ Combo ColorIdentity | AddsCounters$ Card.IsCommander_P1P1_ManaAddsCounterNum | SpellDescription$ Add one mana of any color in your commander's color identity. If you spend this mana to cast your commander, it enters the battlefield with a number of additional +1/+1 counters on it equal to the number of times it's been cast from the command zone this game. SVar:ManaAddsCounterNum:Count$CommanderCastFromCommandZone -AI:RemoveDeck:All -AI:RemoveDeck:Random +AI:RemoveDeck:NonCommander SVar:Picture:http://www.wizards.com/global/images/magic/general/opal_palace.jpg Oracle:{T}: Add {C}.\n{1}, {T}: Add one mana of any color in your commander's color identity. If you spend this mana to cast your commander, it enters the battlefield with a number of additional +1/+1 counters on it equal to the number of times it's been cast from the command zone this game. diff --git a/forge-gui/res/cardsfolder/p/path_of_ancestry.txt b/forge-gui/res/cardsfolder/p/path_of_ancestry.txt index 24b8f32cace..d092a3a1258 100644 --- a/forge-gui/res/cardsfolder/p/path_of_ancestry.txt +++ b/forge-gui/res/cardsfolder/p/path_of_ancestry.txt @@ -5,5 +5,6 @@ K:CARDNAME enters the battlefield tapped. A:AB$ Mana | Cost$ T | Produced$ Combo ColorIdentity | TriggersWhenSpent$ TrigScry | SpellDescription$ Add one mana of any color in your commander's color identity. When that mana is spent to cast a creature spell that shares a creature type with your commander, scry 1. SVar:TrigScry:Mode$ SpellCast | ValidCard$ Creature.sharesCreatureTypeWith Commander | ValidActivatingPlayer$ You | OneOff$ True | Execute$ DBScry | TriggerDescription$ When mana produced by CARDNAME is spent to cast a creature spell that shares a creature type with your commander, scry 1. SVar:DBScry:DB$ Scry | ScryNum$ 1 +AI:RemoveDeck:NonCommander SVar:Picture:http://www.wizards.com/global/images/magic/general/command_tower.jpg Oracle:Path of Ancestry enters the battlefield tapped.\n{T}: Add one mana of any color in your commander's color identity. When that mana is spent to cast a creature spell that shares a creature type with your commander, scry 1.