replaced various single-use adjusters

This commit is contained in:
Evan Kranzler 2018-09-17 14:13:52 -04:00
parent 42417b6711
commit b833fc7f77
11 changed files with 178 additions and 144 deletions

View file

@ -1,4 +1,3 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID; import java.util.UUID;
@ -6,6 +5,7 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.VariableCost;
import mage.abilities.costs.VariableCostImpl; import mage.abilities.costs.VariableCostImpl;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.common.TapTargetCost; import mage.abilities.costs.common.TapTargetCost;
@ -16,17 +16,21 @@ import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.constants.TargetAdjustment;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.TappedPredicate; import mage.filter.predicate.permanent.TappedPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.token.KnightToken; import mage.game.permanent.token.KnightToken;
import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
/** /**
* *
@ -57,9 +61,8 @@ public final class AryelKnightOfWindgrace extends CardImpl {
.setText("Destroy target creature with power X or less"), new ManaCostsImpl("{B}")); .setText("Destroy target creature with power X or less"), new ManaCostsImpl("{B}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addCost(new AryelTapXTargetCost()); ability.addCost(new AryelTapXTargetCost());
ability.setTargetAdjustment(TargetAdjustment.CREATURE_POWER_X_OR_LESS); ability.setTargetAdjuster(AryelKnightOfWindgraceAdjuster.instance);
this.addAbility(ability); this.addAbility(ability);
ability.getOriginalId();
} }
public AryelKnightOfWindgrace(final AryelKnightOfWindgrace card) { public AryelKnightOfWindgrace(final AryelKnightOfWindgrace card) {
@ -106,3 +109,19 @@ class AryelTapXTargetCost extends VariableCostImpl {
return new TapTargetCost(target); return new TapTargetCost(target);
} }
} }
enum AryelKnightOfWindgraceAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int value = 0;
for (VariableCost cost : ability.getCosts().getVariableCosts()) {
value = cost.getAmount();
}
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent("creature with power " + value + " or less");
filterCreaturePermanent.add(new PowerPredicate(ComparisonType.FEWER_THAN, value + 1));
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(filterCreaturePermanent));
}
}

View file

@ -1,7 +1,7 @@
package mage.cards.d; package mage.cards.d;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
@ -10,10 +10,12 @@ import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.TargetAdjustment;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.target.TargetSpell; import mage.target.TargetSpell;
import mage.target.targetadjustment.TargetAdjuster;
/** /**
* *
@ -31,7 +33,7 @@ public final class DeclarationOfNaught extends CardImpl {
// {U}: Counter target spell with the chosen name. // {U}: Counter target spell with the chosen name.
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CounterTargetEffect(), new ManaCostsImpl("{U}")); SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CounterTargetEffect(), new ManaCostsImpl("{U}"));
ability.setTargetAdjustment(TargetAdjustment.CHOSEN_NAME); ability.setTargetAdjuster(DeclarationOfNaughtAdjuster.instance);
ability.addTarget(new TargetSpell(filter)); ability.addTarget(new TargetSpell(filter));
this.addAbility(ability); this.addAbility(ability);
} }
@ -45,3 +47,17 @@ public final class DeclarationOfNaught extends CardImpl {
return new DeclarationOfNaught(this); return new DeclarationOfNaught(this);
} }
} }
enum DeclarationOfNaughtAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
String chosenName = (String) game.getState().getValue(ability.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
FilterSpell filterSpell = new FilterSpell("spell named " + chosenName);
filterSpell.add(new NamePredicate(chosenName));
TargetSpell target = new TargetSpell(1, filterSpell);
ability.addTarget(target);
}
}

View file

@ -14,7 +14,6 @@ import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.constants.TargetAdjustment;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
@ -24,6 +23,7 @@ import mage.filter.predicate.other.OwnerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInGraveyard;
import mage.target.targetadjustment.XCMCGraveyardAdjuster;
/** /**
* @author nantuko * @author nantuko
@ -52,7 +52,7 @@ public final 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. // {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 their library into their graveyard. // Then that player puts the top X cards of their library into their graveyard.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GethLordOfTheVaultEffect(), new ManaCostsImpl("{X}{B}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GethLordOfTheVaultEffect(), new ManaCostsImpl("{X}{B}"));
ability.setTargetAdjustment(TargetAdjustment.X_CMC_EQUAL_GY_CARD); ability.setTargetAdjuster(XCMCGraveyardAdjuster.instance);
ability.addTarget(new TargetCardInGraveyard(filter)); ability.addTarget(new TargetCardInGraveyard(filter));
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -18,7 +18,6 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetAdjustment;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreatureCard;
@ -28,6 +27,7 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard; import mage.game.permanent.PermanentCard;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInGraveyard;
import mage.target.targetadjustment.XCMCGraveyardAdjuster;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.functions.ApplyToPermanent; import mage.util.functions.ApplyToPermanent;
@ -62,7 +62,7 @@ public final class LazavTheMultifarious extends CardImpl {
new ManaCostsImpl("{X}") new ManaCostsImpl("{X}")
); );
ability.addTarget(new TargetCardInGraveyard(filter)); ability.addTarget(new TargetCardInGraveyard(filter));
ability.setTargetAdjustment(TargetAdjustment.X_CMC_EQUAL_GY_CARD); ability.setTargetAdjuster(XCMCGraveyardAdjuster.instance);
this.addAbility(ability); this.addAbility(ability);
} }
@ -137,7 +137,7 @@ class LazavTheMultifariousApplier extends ApplyToPermanent {
new ManaCostsImpl("{X}") new ManaCostsImpl("{X}")
); );
ability.addTarget(new TargetCardInGraveyard(filter)); ability.addTarget(new TargetCardInGraveyard(filter));
ability.setTargetAdjustment(TargetAdjustment.X_CMC_EQUAL_GY_CARD); ability.setTargetAdjuster(XCMCGraveyardAdjuster.instance);
permanent.getAbilities().add(ability); permanent.getAbilities().add(ability);
permanent.setName("Lazav, the Multifarious"); permanent.setName("Lazav, the Multifarious");
permanent.addSuperType(SuperType.LEGENDARY); permanent.addSuperType(SuperType.LEGENDARY);
@ -151,7 +151,7 @@ class LazavTheMultifariousApplier extends ApplyToPermanent {
new ManaCostsImpl("{X}") new ManaCostsImpl("{X}")
); );
ability.addTarget(new TargetCardInGraveyard(filter)); ability.addTarget(new TargetCardInGraveyard(filter));
ability.setTargetAdjustment(TargetAdjustment.X_CMC_EQUAL_GY_CARD); ability.setTargetAdjuster(XCMCGraveyardAdjuster.instance);
mageObject.getAbilities().add(ability); mageObject.getAbilities().add(ability);
mageObject.setName("Lazav, the Multifarious"); mageObject.setName("Lazav, the Multifarious");
mageObject.addSuperType(SuperType.LEGENDARY); mageObject.addSuperType(SuperType.LEGENDARY);

View file

@ -12,11 +12,15 @@ import mage.constants.SubType;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.common.FilterInstantOrSorcerySpell; import mage.filter.common.FilterInstantOrSorcerySpell;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.target.TargetSpell; import mage.target.TargetSpell;
import mage.target.targetadjustment.TargetAdjuster;
/** /**
* *
@ -53,6 +57,7 @@ public final class LeagueGuildmage extends CardImpl {
); );
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetSpell(filter)); ability.addTarget(new TargetSpell(filter));
ability.setTargetAdjuster(LeagueGuildmageAdjuster.instance);
this.addAbility(ability); this.addAbility(ability);
} }
@ -65,3 +70,17 @@ public final class LeagueGuildmage extends CardImpl {
return new LeagueGuildmage(this); return new LeagueGuildmage(this);
} }
} }
enum LeagueGuildmageAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
FilterSpell spellFilter = new FilterInstantOrSorcerySpell("instant or sorcery you control with converted mana cost " + xValue);
spellFilter.add(new ControllerPredicate(TargetController.YOU));
spellFilter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.getTargets().clear();
ability.addTarget(new TargetSpell(spellFilter));
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.l; package mage.cards.l;
import java.util.UUID; import java.util.UUID;
@ -11,13 +10,17 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.TargetAdjustment;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
/** /**
* @author LevelX2 * @author LevelX2
@ -36,7 +39,7 @@ public final class LegacysAllure extends CardImpl {
// Sacrifice Legacy's Allure: Gain control of target creature with power less than or equal to the number of treasure counters on Legacy's Allure. // Sacrifice Legacy's Allure: Gain control of target creature with power less than or equal to the number of treasure counters on Legacy's Allure.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlTargetEffect(Duration.EndOfGame, true), new SacrificeSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlTargetEffect(Duration.EndOfGame, true), new SacrificeSourceCost());
ability.addTarget(new TargetCreaturePermanent(0, 0, filter, false)); ability.addTarget(new TargetCreaturePermanent(0, 0, filter, false));
ability.setTargetAdjustment(TargetAdjustment.TREASURE_COUNTER_POWER); ability.setTargetAdjuster(LegacysAllureAdjuster.instance);
this.addAbility(ability); this.addAbility(ability);
} }
@ -49,3 +52,19 @@ public final class LegacysAllure extends CardImpl {
return new LegacysAllure(this); return new LegacysAllure(this);
} }
} }
enum LegacysAllureAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(ability.getSourceId());
if (sourcePermanent != null) {
int xValue = sourcePermanent.getCounters(game).getCount(CounterType.TREASURE);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature with power less than or equal to " + xValue);
filter2.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().clear();
ability.getTargets().add(new TargetCreaturePermanent(filter2));
}
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.m; package mage.cards.m;
import java.util.UUID; import java.util.UUID;
@ -11,13 +10,17 @@ import mage.abilities.effects.common.combat.CantBeBlockedTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.TargetAdjustment;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.target.Target; import mage.target.Target;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
/** /**
* *
@ -42,7 +45,7 @@ public final class MinamoSightbender extends CardImpl {
// {X}, {T}: Target creature with power X or less can't be blocked this turn. // {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}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CantBeBlockedTargetEffect(), new ManaCostsImpl("{X}"));
Target target = new TargetPermanent(filter); Target target = new TargetPermanent(filter);
ability.setTargetAdjustment(TargetAdjustment.X_POWER_LEQ); ability.setTargetAdjuster(MinamoSightbenderAdjuster.instance);
ability.addTarget(target); ability.addTarget(target);
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);
@ -58,3 +61,16 @@ public final class MinamoSightbender extends CardImpl {
return new MinamoSightbender(this); return new MinamoSightbender(this);
} }
} }
enum MinamoSightbenderAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
FilterPermanent permanentFilter = new FilterCreaturePermanent("creature with power " + xValue + " or less");
permanentFilter.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(permanentFilter));
}
}

View file

@ -1,8 +1,8 @@
package mage.cards.p; package mage.cards.p;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -19,7 +19,11 @@ import mage.constants.Zone;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.DestroyTargetEffect;
import mage.constants.TargetAdjustment; import mage.constants.ComparisonType;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.target.targetadjustment.TargetAdjuster;
/** /**
* *
@ -27,7 +31,7 @@ import mage.constants.TargetAdjustment;
*/ */
public final class PentarchPaladin extends CardImpl { public final class PentarchPaladin extends CardImpl {
FilterPermanent filter = new FilterPermanent("permanent of the chosen color."); private static final FilterPermanent filter = new FilterPermanent("permanent of the chosen color.");
public PentarchPaladin(UUID ownerId, CardSetInfo setInfo) { public PentarchPaladin(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}{W}");
@ -47,7 +51,7 @@ public final class PentarchPaladin extends CardImpl {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{W}{W}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{W}{W}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetPermanent(filter)); ability.addTarget(new TargetPermanent(filter));
ability.setTargetAdjustment(TargetAdjustment.CHOSEN_COLOR); ability.setTargetAdjuster(PentarchPaladinAdjuster.instance);
this.addAbility(ability); this.addAbility(ability);
} }
@ -60,3 +64,21 @@ public final class PentarchPaladin extends CardImpl {
return new PentarchPaladin(this); return new PentarchPaladin(this);
} }
} }
enum PentarchPaladinAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ObjectColor chosenColor = (ObjectColor) game.getState().getValue(ability.getSourceId() + "_color");
ability.getTargets().clear();
FilterPermanent filter = new FilterPermanent("permanent of the chosen color.");
if (chosenColor != null) {
filter.add(new ColorPredicate(chosenColor));
} else {
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, -5));// Pretty sure this is always false
}
TargetPermanent oldTargetPermanent = new TargetPermanent(filter);
ability.addTarget(oldTargetPermanent);
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID; import java.util.UUID;
@ -7,6 +6,7 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost; import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.RemoveVariableCountersTargetCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.continuous.GainControlTargetEffect; import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.keyword.EvolveAbility; import mage.abilities.keyword.EvolveAbility;
@ -21,7 +21,9 @@ import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate; import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
/** /**
* Gatecrash FAQ (01.2013) * Gatecrash FAQ (01.2013)
@ -37,7 +39,6 @@ import mage.target.common.TargetCreaturePermanent;
*/ */
public final class SimicManipulator extends CardImpl { public final class SimicManipulator extends CardImpl {
private final UUID originalId;
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("with power less than or equal to the number of +1/+1 counters removed this way"); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("with power less than or equal to the number of +1/+1 counters removed this way");
public SimicManipulator(UUID ownerId, CardSetInfo setInfo) { public SimicManipulator(UUID ownerId, CardSetInfo setInfo) {
@ -55,36 +56,38 @@ public final class SimicManipulator extends CardImpl {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlTargetEffect(Duration.Custom, true), new TapSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlTargetEffect(Duration.Custom, true), new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent(filter)); ability.addTarget(new TargetCreaturePermanent(filter));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.P1P1.createInstance(), 1, "Remove one or more +1/+1 counters from {this}")); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.P1P1.createInstance(), 1, "Remove one or more +1/+1 counters from {this}"));
ability.setTargetAdjuster(SimicManipulatorAdjuster.instance);
this.addAbility(ability); this.addAbility(ability);
this.originalId = ability.getOriginalId();
} }
public SimicManipulator(final SimicManipulator card) { public SimicManipulator(final SimicManipulator card) {
super(card); super(card);
this.originalId = card.originalId;
} }
@Override @Override
public SimicManipulator copy() { public SimicManipulator copy() {
return new SimicManipulator(this); return new SimicManipulator(this);
} }
}
enum SimicManipulatorAdjuster implements TargetAdjuster {
instance;
@Override @Override
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(ability.getSourceId());
ability.getTargets().clear(); if (sourcePermanent != null) {
int maxPower = 0; int xValue = 0;
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power less than or equal to the number of +1/+1 counters removed this way");
for (Cost cost : ability.getCosts()) { for (Cost cost : ability.getCosts()) {
if (cost instanceof RemoveVariableCountersSourceCost) { if (cost instanceof RemoveVariableCountersTargetCost) {
maxPower = ((RemoveVariableCountersSourceCost) cost).getAmount(); xValue = ((RemoveVariableCountersTargetCost) cost).getAmount();
break; break;
} }
} }
filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, maxPower + 1)); ability.getTargets().clear();
TargetCreaturePermanent target = new TargetCreaturePermanent(1, 1, filter, false); FilterCreaturePermanent newFilter = new FilterCreaturePermanent("creature with power " + xValue + " or less");
ability.addTarget(target); newFilter.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.addTarget(new TargetCreaturePermanent(newFilter));
} }
} }
} }

View file

@ -5,27 +5,12 @@ import mage.MageObjectImpl;
import mage.Mana; import mage.Mana;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.*; import mage.abilities.*;
import mage.abilities.costs.Cost;
import mage.abilities.costs.VariableCost;
import mage.abilities.costs.common.RemoveVariableCountersTargetCost;
import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl; import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.repository.PluginClassloaderRegistery; import mage.cards.repository.PluginClassloaderRegistery;
import mage.constants.*; import mage.constants.*;
import mage.counters.Counter; import mage.counters.Counter;
import mage.counters.CounterType;
import mage.counters.Counters; import mage.counters.Counters;
import mage.filter.FilterCard;
import mage.filter.FilterMana; import mage.filter.FilterMana;
import mage.filter.FilterPermanent;
import mage.filter.FilterSpell;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterInstantOrSorcerySpell;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.*; import mage.game.*;
import mage.game.command.CommandObject; import mage.game.command.CommandObject;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
@ -33,10 +18,6 @@ import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.game.stack.StackObject; import mage.game.stack.StackObject;
import mage.target.TargetCard;
import mage.target.TargetPermanent;
import mage.target.TargetSpell;
import mage.target.common.TargetCreaturePermanent;
import mage.util.GameLog; import mage.util.GameLog;
import mage.util.SubTypeList; import mage.util.SubTypeList;
import mage.watchers.Watcher; import mage.watchers.Watcher;
@ -48,7 +29,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.target.common.TargetCardInGraveyard;
public abstract class CardImpl extends MageObjectImpl implements Card { public abstract class CardImpl extends MageObjectImpl implements Card {
@ -353,93 +333,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override @Override
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
ability.adjustTargets(game); ability.adjustTargets(game);
int xValue;
TargetPermanent oldTargetPermanent;
FilterPermanent permanentFilter;
int minTargets;
int maxTargets;
switch (ability.getTargetAdjustment()) {
case NONE:
break;
case X_POWER_LEQ:// Minamo Sightbender only
xValue = ability.getManaCostsToPay().getX();
oldTargetPermanent = (TargetPermanent) ability.getTargets().get(0);
minTargets = oldTargetPermanent.getMinNumberOfTargets();
maxTargets = oldTargetPermanent.getMaxNumberOfTargets();
permanentFilter = oldTargetPermanent.getFilter().copy();
permanentFilter.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(minTargets, maxTargets, permanentFilter, false));
break;
case X_CMC_EQUAL_GY_CARD:
xValue = ability.getManaCostsToPay().getX();
FilterCard filterCard = ((TargetCard) ability.getTargets().get(0)).getFilter().copy();
filterCard.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
filterCard.setMessage(filterCard.getMessage().replace('X', (char) xValue));
ability.getTargets().clear();
ability.getTargets().add(new TargetCardInGraveyard(filterCard));
break;
case CHOSEN_NAME: //Declaration of Naught only
ability.getTargets().clear();
FilterSpell filterSpell = new FilterSpell("spell with the chosen name");
filterSpell.add(new NamePredicate((String) game.getState().getValue(ability.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY)));
TargetSpell target = new TargetSpell(1, filterSpell);
ability.addTarget(target);
break;
case CHOSEN_COLOR: //Pentarch Paladin only
ObjectColor chosenColor = (ObjectColor) game.getState().getValue(ability.getSourceId() + "_color");
ability.getTargets().clear();
FilterPermanent filter = new FilterPermanent("permanent of the chosen color.");
if (chosenColor != null) {
filter.add(new ColorPredicate(chosenColor));
} else {
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, -5));// Pretty sure this is always false
}
oldTargetPermanent = new TargetPermanent(filter);
ability.addTarget(oldTargetPermanent);
break;
case TREASURE_COUNTER_POWER: //Legacy's Allure only
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(ability.getSourceId());
if (sourcePermanent != null) {
xValue = sourcePermanent.getCounters(game).getCount(CounterType.TREASURE);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature with power less than or equal to the number of treasure counters on {this}");
filter2.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().clear();
ability.getTargets().add(new TargetCreaturePermanent(filter2));
}
break;
case SIMIC_MANIPULATOR: //Simic Manipulator only
xValue = 0;
for (Cost cost : ability.getCosts()) {
if (cost instanceof RemoveVariableCountersTargetCost) {
xValue = ((RemoveVariableCountersTargetCost) cost).getAmount();
break;
}
}
ability.getTargets().clear();
FilterCreaturePermanent newFilter = new FilterCreaturePermanent("creature with power less than or equal to " + xValue);
newFilter.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.addTarget(new TargetCreaturePermanent(newFilter));
break;
case CREATURE_POWER_X_OR_LESS: // Aryel, Knight of Windgrace
int value = 0;
for (VariableCost cost : ability.getCosts().getVariableCosts()) {
value = cost.getAmount();
}
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent("creature with power " + value + " or less");
filterCreaturePermanent.add(new PowerPredicate(ComparisonType.FEWER_THAN, value + 1));
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(filterCreaturePermanent));
break;
case X_CMC_EQUAL_SPELL_CONTROLLED: // League Guildmage
xValue = ability.getManaCostsToPay().getX();
FilterSpell spellFilter = new FilterInstantOrSorcerySpell("instant or sorcery you control with converted mana cost " + xValue);
spellFilter.add(new ControllerPredicate(TargetController.YOU));
spellFilter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.getTargets().clear();
ability.addTarget(new TargetSpell(spellFilter));
break;
}
} }
@Override @Override

View file

@ -0,0 +1,27 @@
package mage.target.targetadjustment;
import mage.abilities.Ability;
import mage.constants.ComparisonType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.target.TargetCard;
import mage.target.common.TargetCardInGraveyard;
/**
*
* @author TheElk801
*/
public enum XCMCGraveyardAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
FilterCard filterCard = ((TargetCard) ability.getTargets().get(0)).getFilter().copy();
filterCard.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
filterCard.setMessage(filterCard.getMessage().replace('X', (char) xValue));
ability.getTargets().clear();
ability.getTargets().add(new TargetCardInGraveyard(filterCard));
}
}