From dcddc91144c0ff4174acaf6abfb06d1dfc464226 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 16 Sep 2017 21:08:52 -0400 Subject: [PATCH] Updated cards which target cards with attribute x --- .../src/mage/cards/d/DeepfireElemental.java | 4 -- .../src/mage/cards/g/GethLordOfTheVault.java | 27 +++++++----- Mage.Sets/src/mage/cards/g/GorillaShaman.java | 11 +++-- Mage.Sets/src/mage/cards/h/HearthKami.java | 4 -- .../src/mage/cards/l/LinessaZephyrMage.java | 4 -- .../src/mage/cards/m/MinamoSightbender.java | 42 +++++++++---------- Mage.Sets/src/mage/cards/p/Plaguebearer.java | 4 -- .../java/mage/constants/TargetAdjustment.java | 2 +- Mage/src/main/java/mage/target/Target.java | 9 ++-- .../src/main/java/mage/target/TargetImpl.java | 5 +++ 10 files changed, 53 insertions(+), 59 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/DeepfireElemental.java b/Mage.Sets/src/mage/cards/d/DeepfireElemental.java index f32e56862d..4cc1269083 100644 --- a/Mage.Sets/src/mage/cards/d/DeepfireElemental.java +++ b/Mage.Sets/src/mage/cards/d/DeepfireElemental.java @@ -79,11 +79,7 @@ public class DeepfireElemental extends CardImpl { if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) { int xValue = ability.getManaCostsToPay().getX(); FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy(); - StringBuilder message = new StringBuilder(filter2.getMessage()); - message.setLength(message.length() - 1); - message.append(xValue); filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue)); - filter2.setMessage(message.toString()); ability.getTargets().clear(); ability.getTargets().add(new TargetPermanent(filter2)); } diff --git a/Mage.Sets/src/mage/cards/g/GethLordOfTheVault.java b/Mage.Sets/src/mage/cards/g/GethLordOfTheVault.java index 7d397f5562..3a99811b27 100644 --- a/Mage.Sets/src/mage/cards/g/GethLordOfTheVault.java +++ b/Mage.Sets/src/mage/cards/g/GethLordOfTheVault.java @@ -50,7 +50,7 @@ import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; import mage.game.Game; import mage.players.Player; -import mage.target.Target; +import mage.target.TargetCard; import mage.target.common.TargetCardInOpponentsGraveyard; /** @@ -58,6 +58,14 @@ import mage.target.common.TargetCardInOpponentsGraveyard; */ public class GethLordOfTheVault extends CardImpl { + private static final FilterCard filter = new FilterCard("artifact or creature card with converted mana cost X from an opponent's graveyard"); + + static { + filter.add(Predicates.or( + new CardTypePredicate(CardType.ARTIFACT), + new CardTypePredicate(CardType.CREATURE))); + } + public GethLordOfTheVault(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}{B}"); addSuperType(SuperType.LEGENDARY); @@ -72,23 +80,20 @@ public class GethLordOfTheVault extends CardImpl { // {X}{B}: Put target artifact or creature card with converted mana cost X from an opponent's graveyard onto the battlefield under your control tapped. // Then that player puts the top X cards of his or her library into his or her graveyard. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GethLordOfTheVaultEffect(), new ManaCostsImpl("{X}{B}")); - ability.setTargetAdjustment(TargetAdjustment.X_CMC_EQUAL_NONPERM); - ability.addTarget(new TargetCardInOpponentsGraveyard(new FilterCard("artifact or creature card with converted mana cost X from an opponent's graveyard"))); + ability.setTargetAdjustment(TargetAdjustment.GETH); + ability.addTarget(new TargetCardInOpponentsGraveyard(filter)); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_NONPERM) { + if (ability.getTargetAdjustment() == TargetAdjustment.GETH) { int xValue = ability.getManaCostsToPay().getX(); + TargetCard oldTarget = (TargetCard) ability.getTargets().get(0); + FilterCard filter2 = oldTarget.getFilter().copy(); + filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue)); ability.getTargets().clear(); - FilterCard filter = new FilterCard("artifact or creature card with converted mana cost " + xValue + " from an opponent's graveyard"); - filter.add(Predicates.or( - new CardTypePredicate(CardType.ARTIFACT), - new CardTypePredicate(CardType.CREATURE))); - filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue)); - Target target = new TargetCardInOpponentsGraveyard(filter); - ability.addTarget(target); + ability.getTargets().add(new TargetCardInOpponentsGraveyard(filter2)); } } diff --git a/Mage.Sets/src/mage/cards/g/GorillaShaman.java b/Mage.Sets/src/mage/cards/g/GorillaShaman.java index 17d0d377f0..60d3ed4911 100644 --- a/Mage.Sets/src/mage/cards/g/GorillaShaman.java +++ b/Mage.Sets/src/mage/cards/g/GorillaShaman.java @@ -79,14 +79,13 @@ public class GorillaShaman extends CardImpl { public void adjustTargets(Ability ability, Game game) { if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) { int xValue = ability.getManaCostsToPay().getX(); - FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy(); - StringBuilder message = new StringBuilder(filter2.getMessage()); - message.setLength(message.length() - 1); - message.append(xValue); + TargetPermanent oldTarget = (TargetPermanent) ability.getTargets().get(0); + int minTargets = oldTarget.getMinNumberOfTargets(); + int maxTargets = oldTarget.getMaxNumberOfTargets(); + FilterPermanent filter2 = oldTarget.getFilter().copy(); filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue)); - filter2.setMessage(message.toString()); ability.getTargets().clear(); - ability.getTargets().add(new TargetPermanent(filter2)); + ability.getTargets().add(new TargetPermanent(minTargets, maxTargets, filter2, false)); } } diff --git a/Mage.Sets/src/mage/cards/h/HearthKami.java b/Mage.Sets/src/mage/cards/h/HearthKami.java index b2b0f851fa..5e15b83de5 100644 --- a/Mage.Sets/src/mage/cards/h/HearthKami.java +++ b/Mage.Sets/src/mage/cards/h/HearthKami.java @@ -79,11 +79,7 @@ public class HearthKami extends CardImpl { if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) { int xValue = ability.getManaCostsToPay().getX(); FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy(); - StringBuilder message = new StringBuilder(filter2.getMessage()); - message.setLength(message.length() - 1); - message.append(xValue); filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue)); - filter2.setMessage(message.toString()); ability.getTargets().clear(); ability.getTargets().add(new TargetPermanent(filter2)); } diff --git a/Mage.Sets/src/mage/cards/l/LinessaZephyrMage.java b/Mage.Sets/src/mage/cards/l/LinessaZephyrMage.java index c4201a00e4..c0df84cc21 100644 --- a/Mage.Sets/src/mage/cards/l/LinessaZephyrMage.java +++ b/Mage.Sets/src/mage/cards/l/LinessaZephyrMage.java @@ -102,11 +102,7 @@ public class LinessaZephyrMage extends CardImpl { if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) { int xValue = ability.getManaCostsToPay().getX(); FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy(); - StringBuilder message = new StringBuilder(filter2.getMessage()); - message.setLength(message.length() - 1); - message.append(xValue); filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue)); - filter2.setMessage(message.toString()); ability.getTargets().clear(); ability.getTargets().add(new TargetPermanent(filter2)); } diff --git a/Mage.Sets/src/mage/cards/m/MinamoSightbender.java b/Mage.Sets/src/mage/cards/m/MinamoSightbender.java index 2b58cb8755..2fcb0b0b4b 100644 --- a/Mage.Sets/src/mage/cards/m/MinamoSightbender.java +++ b/Mage.Sets/src/mage/cards/m/MinamoSightbender.java @@ -33,19 +33,20 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.combat.CantBeBlockedTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.ComparisonType; +import mage.constants.TargetAdjustment; import mage.constants.Zone; -import mage.filter.common.FilterCreaturePermanent; +import mage.filter.FilterPermanent; +import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.PowerPredicate; import mage.game.Game; import mage.target.Target; -import mage.target.common.TargetCreaturePermanent; +import mage.target.TargetPermanent; /** * @@ -53,11 +54,14 @@ import mage.target.common.TargetCreaturePermanent; */ public class MinamoSightbender extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power X or less"); - private final UUID originalId; + private static final FilterPermanent filter = new FilterPermanent("creature with power X or less"); + + static { + filter.add(new CardTypePredicate(CardType.CREATURE)); + } public MinamoSightbender(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.WIZARD); @@ -67,34 +71,30 @@ public class MinamoSightbender extends CardImpl { //TODO: Make ability properly copiable // {X}, {T}: Target creature with power X or less can't be blocked this turn. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CantBeBlockedTargetEffect(), new ManaCostsImpl("{X}")); - Target target = new TargetCreaturePermanent(filter); + Target target = new TargetPermanent(filter); + ability.setTargetAdjustment(TargetAdjustment.X_POWER_LEQ); ability.addTarget(target); ability.addCost(new TapSourceCost()); - originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability.getOriginalId().equals(originalId)) { - for (Effect effect : ability.getEffects()) { - if (effect instanceof CantBeBlockedTargetEffect) { - int manaX = ability.getManaCostsToPay().getX(); - ability.getTargets().clear(); - FilterCreaturePermanent newFilter = new FilterCreaturePermanent(new StringBuilder("creature with power ").append(manaX).append(" or less").toString()); - filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, manaX + 1)); - Target target = new TargetCreaturePermanent(newFilter); - ability.addTarget(target); - break; - } - } + if (ability.getTargetAdjustment() == TargetAdjustment.X_POWER_LEQ) { + int xValue = ability.getManaCostsToPay().getX(); + TargetPermanent oldTarget = (TargetPermanent) ability.getTargets().get(0); + int minTargets = oldTarget.getMinNumberOfTargets(); + int maxTargets = oldTarget.getMaxNumberOfTargets(); + FilterPermanent filter2 = oldTarget.getFilter().copy(); + filter2.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1)); + ability.getTargets().clear(); + ability.getTargets().add(new TargetPermanent(minTargets, maxTargets, filter2, false)); } } public MinamoSightbender(final MinamoSightbender card) { super(card); - this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/cards/p/Plaguebearer.java b/Mage.Sets/src/mage/cards/p/Plaguebearer.java index b36c7bf8d8..d3aeb685a4 100644 --- a/Mage.Sets/src/mage/cards/p/Plaguebearer.java +++ b/Mage.Sets/src/mage/cards/p/Plaguebearer.java @@ -81,11 +81,7 @@ public class Plaguebearer extends CardImpl { if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) { int xValue = ability.getManaCostsToPay().getX(); FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy(); - StringBuilder message = new StringBuilder(filter2.getMessage()); - message.setLength(message.length() - 1); - message.append(xValue); filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue)); - filter2.setMessage(message.toString()); ability.getTargets().clear(); ability.getTargets().add(new TargetPermanent(filter2)); } diff --git a/Mage/src/main/java/mage/constants/TargetAdjustment.java b/Mage/src/main/java/mage/constants/TargetAdjustment.java index a29b5eb436..110087be1c 100644 --- a/Mage/src/main/java/mage/constants/TargetAdjustment.java +++ b/Mage/src/main/java/mage/constants/TargetAdjustment.java @@ -6,5 +6,5 @@ package mage.constants; */ public enum TargetAdjustment { - NONE, X_TARGETS, X_CMC_EQUAL_PERM, X_CMC_EQUAL_NONPERM, DEFENDING_PLAYER + NONE, X_TARGETS, X_CMC_EQUAL_PERM, GETH, DEFENDING_PLAYER,X_POWER_LEQ } diff --git a/Mage/src/main/java/mage/target/Target.java b/Mage/src/main/java/mage/target/Target.java index 647c6281e7..e36ef210c1 100644 --- a/Mage/src/main/java/mage/target/Target.java +++ b/Mage/src/main/java/mage/target/Target.java @@ -53,8 +53,7 @@ public interface Target extends Serializable { boolean isNotTarget(); /** - * controls if it will be checked, if the target can be targeted from - * source + * controls if it will be checked, if the target can be targeted from source * * @param notTarget true = do not check for protection, false = check for * protection @@ -113,6 +112,8 @@ public interface Target extends Serializable { int getNumberOfTargets(); + int getMinNumberOfTargets(); + int getMaxNumberOfTargets(); void setMinNumberOfTargets(int minNumberofTargets); @@ -157,8 +158,8 @@ public interface Target extends Serializable { void setTargetTag(int tag); Target getOriginalTarget(); - + // used for cards like Spellskite void setTargetAmount(UUID targetId, int amount, Game game); - + } diff --git a/Mage/src/main/java/mage/target/TargetImpl.java b/Mage/src/main/java/mage/target/TargetImpl.java index 546bafd5ad..3dbe7568cc 100644 --- a/Mage/src/main/java/mage/target/TargetImpl.java +++ b/Mage/src/main/java/mage/target/TargetImpl.java @@ -105,6 +105,11 @@ public abstract class TargetImpl implements Target { return this.minNumberOfTargets; } + @Override + public int getMinNumberOfTargets() { + return this.minNumberOfTargets; + } + @Override public int getMaxNumberOfTargets() { return this.maxNumberOfTargets;