updated target adjusters P through W

This commit is contained in:
Evan Kranzler 2018-09-29 00:24:00 -04:00
parent 212d09b0a3
commit 2df976b2f0
40 changed files with 840 additions and 793 deletions

View file

@ -1,7 +1,6 @@
package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
@ -16,39 +15,31 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class Pandemonium extends CardImpl {
private final UUID originalId;
public Pandemonium(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
// Whenever a creature enters the battlefield, that creature's controller may have it deal damage equal to its power to any target of their choice.
Ability ability = new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new PandemoniumEffect(), StaticFilters.FILTER_PERMANENT_CREATURE, false, SetTargetPointer.PERMANENT, "");
Ability ability = new EntersBattlefieldAllTriggeredAbility(
Zone.BATTLEFIELD, new PandemoniumEffect(),
StaticFilters.FILTER_PERMANENT_CREATURE,
false, SetTargetPointer.PERMANENT, ""
);
ability.addTarget(new TargetAnyTarget());
originalId = ability.getOriginalId();
ability.setTargetAdjuster(PandemoniumAdjuster.instance);
this.addAbility(ability);
}
public Pandemonium(final Pandemonium card) {
super(card);
this.originalId = card.originalId;
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
UUID creatureId = ability.getEffects().get(0).getTargetPointer().getFirst(game, ability);
Permanent creature = game.getPermanent(creatureId);
if (creature != null) {
ability.getTargets().get(0).setTargetController(creature.getControllerId());
}
}
}
@Override
@ -57,6 +48,19 @@ public final class Pandemonium extends CardImpl {
}
}
enum PandemoniumAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
UUID creatureId = ability.getEffects().get(0).getTargetPointer().getFirst(game, ability);
Permanent creature = game.getPermanent(creatureId);
if (creature != null) {
ability.getTargets().get(0).setTargetController(creature.getControllerId());
}
}
}
class PandemoniumEffect extends OneShotEffect {
public PandemoniumEffect() {

View file

@ -1,9 +1,7 @@
package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.IslandwalkAbility;
@ -11,34 +9,26 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class PartWater extends CardImpl {
public PartWater(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{X}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{U}");
// X target creatures gain islandwalk until end of turn.
Effect effect = new GainAbilityTargetEffect(new IslandwalkAbility(false), Duration.EndOfTurn);
effect.setText("X target creatures gain islandwalk until end of turn");
this.getSpellAbility().getEffects().add(effect);
this.getSpellAbility().getTargets().add(new TargetCreaturePermanent(1,1));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures gain islandwalk until end of turn");
ability.getTargets().add(new TargetCreaturePermanent(0, xValue, filter, false));
}
this.getSpellAbility().getTargets().add(new TargetCreaturePermanent());
this.getSpellAbility().setTargetAdjuster(PartWaterAdjuster.instance);
}
public PartWater(final PartWater card) {
@ -50,3 +40,13 @@ public final class PartWater extends CardImpl {
return new PartWater(this);
}
}
enum PartWaterAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.getTargets().add(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
}
}

View file

@ -1,9 +1,6 @@
package mage.cards.p;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesMonstrousSourceTriggeredAbility;
@ -12,47 +9,44 @@ import mage.abilities.keyword.MonstrosityAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.TargetController;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanentAmount;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* * The value of X in Polukranos's last ability is equal to the value chosen
* for X when its activated ability was activated.
*
* for X when its activated ability was activated.
* <p>
* * The number of targets chosen for the triggered ability must be at least one
* (if X wasn't 0) and at most X. You choose the division of damage as you put
* the ability on the stack, not as it resolves. Each target must be assigned
* at least 1 damage. In multiplayer games, you may choose creatures controlled
* by different opponents.
*
* (if X wasn't 0) and at most X. You choose the division of damage as you put
* the ability on the stack, not as it resolves. Each target must be assigned
* at least 1 damage. In multiplayer games, you may choose creatures controlled
* by different opponents.
* <p>
* * If some, but not all, of the ability's targets become illegal, you can't change
* the division of damage. Damage that would've been dealt to illegal targets
* simply isn't dealt.
*
* the division of damage. Damage that would've been dealt to illegal targets
* simply isn't dealt.
* <p>
* * As Polukranos's triggered ability resolves, Polukranos deals damage first, then
* the target creatures do. Although no creature will die until after the ability
* finishes resolving, the order could matter if Polukranos has wither or infect.
* the target creatures do. Although no creature will die until after the ability
* finishes resolving, the order could matter if Polukranos has wither or infect.
*
* @author LevelX2
*/
public final class PolukranosWorldEater extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
static {
filter.add(new ControllerPredicate(TargetController.OPPONENT));
}
public PolukranosWorldEater(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{G}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HYDRA);
@ -61,20 +55,11 @@ public final class PolukranosWorldEater extends CardImpl {
// {X}{X}{G}: Monstrosity X.
this.addAbility(new MonstrosityAbility("{X}{X}{G}", Integer.MAX_VALUE));
// When Polukranos, World Eater becomes monstrous, it deals X damage divided as you choose among any number of target creatures your opponents control. Each of those creatures deals damage equal to its power to Polukranos.
Ability ability = new BecomesMonstrousSourceTriggeredAbility(new PolukranosWorldEaterEffect());
ability.addTarget(new TargetCreaturePermanentAmount(1, filter));
ability.setTargetAdjuster(PolukranosWorldEaterAdjuster.instance);
this.addAbility(ability);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof BecomesMonstrousSourceTriggeredAbility) {
int xValue = ((BecomesMonstrousSourceTriggeredAbility) ability).getMonstrosityValue();
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanentAmount(xValue, filter));
}
}
public PolukranosWorldEater(final PolukranosWorldEater card) {
@ -87,6 +72,17 @@ public final class PolukranosWorldEater extends CardImpl {
}
}
enum PolukranosWorldEaterAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = ((BecomesMonstrousSourceTriggeredAbility) ability).getMonstrosityValue();
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanentAmount(xValue, StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE));
}
}
class PolukranosWorldEaterEffect extends OneShotEffect {
public PolukranosWorldEaterEffect() {
@ -108,7 +104,7 @@ class PolukranosWorldEaterEffect extends OneShotEffect {
if (!source.getTargets().isEmpty()) {
Target multiTarget = source.getTargets().get(0);
Set<Permanent> permanents = new HashSet<>();
for (UUID target: multiTarget.getTargets()) {
for (UUID target : multiTarget.getTargets()) {
Permanent permanent = game.getPermanent(target);
if (permanent != null) {
permanents.add(permanent);
@ -118,7 +114,7 @@ class PolukranosWorldEaterEffect extends OneShotEffect {
// Each of those creatures deals damage equal to its power to Polukranos
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (sourceCreature != null) {
for (Permanent permanent :permanents) {
for (Permanent permanent : permanents) {
sourceCreature.damage(permanent.getPower().getValue(), permanent.getId(), game, false, true);
}
}

View file

@ -1,7 +1,6 @@
package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
@ -21,8 +20,11 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* @author North
*/
@ -34,6 +36,7 @@ public final class PostmortemLunge extends CardImpl {
// Return target creature card with converted mana cost X from your graveyard to the battlefield. It gains haste. Exile it at the beginning of the next end step.
this.getSpellAbility().addEffect(new PostmortemLungeEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD));
this.getSpellAbility().setTargetAdjuster(PostmortemLungeAdjuster.instance);
}
public PostmortemLunge(final PostmortemLunge card) {
@ -44,16 +47,18 @@ public final class PostmortemLunge extends CardImpl {
public PostmortemLunge copy() {
return new PostmortemLunge(this);
}
}
enum PostmortemLungeAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getAbilityType() == AbilityType.SPELL) { // otherwise the target is also added to the delayed triggered ability
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCard filter = new FilterCreatureCard("creature card with converted mana cost " + xValue + " or less from your graveyard");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().add(new TargetCardInYourGraveyard(filter));
}
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCard filter = new FilterCreatureCard("creature card with converted mana cost " + xValue + " or less from your graveyard");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().add(new TargetCardInYourGraveyard(filter));
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.common.DrawDiscardControllerEffect;
@ -14,9 +12,11 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.game.Game;
import mage.target.TargetPlayer;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class Probe extends CardImpl {
@ -33,16 +33,7 @@ public final class Probe extends CardImpl {
new DiscardTargetEffect(2),
KickedCondition.instance,
"<br><br>if this spell was kicked, target player discards two cards"));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
if (KickedCondition.instance.apply(game, ability)) {
ability.addTarget(new TargetPlayer());
}
}
this.getSpellAbility().setTargetAdjuster(ProbeAdjuster.instance);
}
public Probe(final Probe card) {
@ -54,3 +45,15 @@ public final class Probe extends CardImpl {
return new Probe(this);
}
}
enum ProbeAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
if (KickedCondition.instance.apply(game, ability)) {
ability.addTarget(new TargetPlayer());
}
}
}

View file

@ -1,7 +1,6 @@
package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
@ -26,6 +25,9 @@ import mage.game.Game;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
* @author LevelX2
@ -64,27 +66,8 @@ public final class ProfaneCommand extends CardImpl {
mode.getEffects().add(effect);
mode.getTargets().add(new TargetCreaturePermanent(0, 1));
this.getSpellAbility().addMode(mode);
}
@Override
public void adjustTargets(Ability ability, Game game) {
// adjust targets is called for every selected mode
Mode mode = ability.getModes().getMode();
for (Effect effect : mode.getEffects()) {
if (effect instanceof ReturnFromGraveyardToBattlefieldTargetEffect) {
mode.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCard filter = new FilterCreatureCard("creature card with converted mana cost " + xValue + " or less from your graveyard");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
mode.getTargets().add(new TargetCardInYourGraveyard(filter));
}
if (effect instanceof GainAbilityTargetEffect) {
mode.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures gain fear until end of turn");
mode.getTargets().add(new TargetCreaturePermanent(0, xValue, filter, false));
}
}
this.getSpellAbility().setTargetAdjuster(ProfaneCommandAdjuster.instance);
}
public ProfaneCommand(final ProfaneCommand card) {
@ -96,3 +79,27 @@ public final class ProfaneCommand extends CardImpl {
return new ProfaneCommand(this);
}
}
enum ProfaneCommandAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
// adjust targets is called for every selected mode
Mode mode = ability.getModes().getMode();
int xValue = ability.getManaCostsToPay().getX();
for (Effect effect : mode.getEffects()) {
if (effect instanceof ReturnFromGraveyardToBattlefieldTargetEffect) {
mode.getTargets().clear();
FilterCard filter = new FilterCreatureCard("creature card with converted mana cost " + xValue + " or less from your graveyard");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
mode.getTargets().add(new TargetCardInYourGraveyard(filter));
}
if (effect instanceof GainAbilityTargetEffect) {
mode.getTargets().clear();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures gain fear until end of turn");
mode.getTargets().add(new TargetCreaturePermanent(0, xValue, filter, false));
}
}
}
}

View file

@ -1,7 +1,6 @@
package mage.cards.q;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -21,10 +20,12 @@ import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class QuarantineField extends CardImpl {
@ -35,42 +36,43 @@ public final class QuarantineField extends CardImpl {
// Quarantine Field enters the battlefield with X isolation counters on it.
this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.ISOLATION.createInstance())));
// When Quarantine Field enters the battlefield, for each isolation counter on it, exile up to one target nonland permanent an opponenet controls until Quarantine Field leaves the battlefield.
// When Quarantine Field enters the battlefield, for each isolation counter on it, exile up to one target nonland permanent an opponent controls until Quarantine Field leaves the battlefield.
Ability ability = new EntersBattlefieldTriggeredAbility(new QuarantineFieldEffect(), false);
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new OnLeaveReturnExiledToBattlefieldAbility()));
ability.setTargetAdjuster(QuarantineFieldAdjuster.instance);
this.addAbility(ability);
}
public QuarantineField(final QuarantineField card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof EntersBattlefieldTriggeredAbility) {
Permanent sourceObject = game.getPermanent(ability.getSourceId());
if (sourceObject != null) {
int isolationCounters = sourceObject.getCounters(game).getCount(CounterType.ISOLATION);
FilterNonlandPermanent filter = new FilterNonlandPermanent("up to " + isolationCounters + " nonland permanents controlled by any opponents");
filter.add(new ControllerPredicate(TargetController.OPPONENT));
ability.addTarget(new TargetPermanent(0, isolationCounters, filter, false));
}
}
}
@Override
public QuarantineField copy() {
return new QuarantineField(this);
}
}
enum QuarantineFieldAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
Permanent sourceObject = game.getPermanent(ability.getSourceId());
if (sourceObject != null) {
int isolationCounters = sourceObject.getCounters(game).getCount(CounterType.ISOLATION);
FilterNonlandPermanent filter = new FilterNonlandPermanent("up to " + isolationCounters + " nonland permanents controlled by an opponent");
filter.add(new ControllerPredicate(TargetController.OPPONENT));
ability.addTarget(new TargetPermanent(0, isolationCounters, filter, false));
}
}
}
class QuarantineFieldEffect extends OneShotEffect {
public QuarantineFieldEffect() {
super(Outcome.Exile);
this.staticText = "for each isolation counter on it, exile up to one target nonland permanent an opponenet controls until {this} leaves the battlefield";
this.staticText = "for each isolation counter on it, exile up to one target nonland permanent an opponent controls until {this} leaves the battlefield";
}
public QuarantineFieldEffect(final QuarantineFieldEffect effect) {

View file

@ -1,63 +1,40 @@
package mage.cards.r;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetOpponent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author L_J
*/
public final class Reap extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("black permanents");
static {
filter.add(new ColorPredicate(ObjectColor.BLACK));
}
public Reap(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}");
// Return up to X target cards from your graveyard to your hand, where X is the number of black permanents target opponent controls as you cast Reap.
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setText("Return up to X target cards from your graveyard to your hand, where X is the number of black permanents target opponent controls as you cast Reap."));
this.getSpellAbility().addTarget(new TargetOpponent());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 0, new FilterCard("cards from your graveyard")));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 0));
this.getSpellAbility().setTargetAdjuster(ReapAdjuster.instance);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) {
ability.getTargets().clear();
UUID opponentId = null;
Target target = new TargetOpponent();
if (controller.chooseTarget(Outcome.ReturnToHand, target, ability, game)) {
opponentId = target.getFirstTarget();
}
int numbTargets = game.getBattlefield().getAllActivePermanents(filter, opponentId, game).size();
ability.addTarget(new TargetCardInYourGraveyard(0, numbTargets, new FilterCard("card" + (numbTargets == 1 ? "" : "s") + " from your graveyard")));
}
}
}
public Reap(final Reap card) {
super(card);
}
@ -67,3 +44,27 @@ public final class Reap extends CardImpl {
return new Reap(this);
}
}
enum ReapAdjuster implements TargetAdjuster {
instance;
private static final FilterPermanent filter = new FilterPermanent("black permanents");
static {
filter.add(new ColorPredicate(ObjectColor.BLACK));
}
@Override
public void adjustTargets(Ability ability, Game game) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) {
ability.getTargets().clear();
UUID opponentId = null;
Target target = new TargetOpponent();
if (controller.chooseTarget(Outcome.ReturnToHand, target, ability, game)) {
opponentId = target.getFirstTarget();
}
int numbTargets = game.getBattlefield().getAllActivePermanents(filter, opponentId, game).size();
ability.addTarget(new TargetCardInYourGraveyard(0, numbTargets, new FilterCard("card" + (numbTargets == 1 ? "" : "s") + " from your graveyard")));
}
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
@ -13,9 +11,11 @@ import mage.constants.CardType;
import mage.game.Game;
import mage.game.permanent.token.GremlinToken;
import mage.target.common.TargetArtifactPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author Styxo
*/
public final class ReleaseTheGremlins extends CardImpl {
@ -30,15 +30,7 @@ public final class ReleaseTheGremlins extends CardImpl {
// Create X 2/2 red Gremlin creature tokens.
this.getSpellAbility().addEffect(new CreateTokenEffect(new GremlinToken(), new ManacostVariableValue()));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
ability.addTarget(new TargetArtifactPermanent(xValue, xValue));
}
this.getSpellAbility().setTargetAdjuster(ReleaseTheGremlinsAdjuster.instance);
}
public ReleaseTheGremlins(final ReleaseTheGremlins card) {
@ -50,3 +42,13 @@ public final class ReleaseTheGremlins extends CardImpl {
return new ReleaseTheGremlins(this);
}
}
enum ReleaseTheGremlinsAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetArtifactPermanent(ability.getManaCostsToPay().getX()));
}
}

View file

@ -1,23 +1,21 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.common.DiscardXTargetCost;
import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.target.Target;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class RestlessDreams extends CardImpl {
@ -26,7 +24,7 @@ public final class RestlessDreams extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}");
// As an additional cost to cast Restless Dreams, discard X cards.
this.getSpellAbility().addCost(new DiscardXTargetCost(new FilterCard("cards"), true));
this.getSpellAbility().addCost(new DiscardXTargetCost(StaticFilters.FILTER_CARD_CARDS, true));
// Return X target creature cards from your graveyard to your hand.
Effect effect = new ReturnFromGraveyardToHandTargetEffect();
effect.setText("Return X target creature cards from your graveyard to your hand");
@ -37,15 +35,21 @@ public final class RestlessDreams extends CardImpl {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = new GetXValue().calculate(game, ability, null);
Target target = new TargetCardInYourGraveyard(xValue, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
ability.addTarget(target);
}
@Override
public RestlessDreams copy() {
return new RestlessDreams(this);
}
}
enum RestlessDreamsAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(
ability.getManaCostsToPay().getX(),
StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD
));
}
}

View file

@ -2,52 +2,87 @@
package mage.cards.r;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class ReturnToDust extends CardImpl {
public ReturnToDust(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}{W}");
// Exile target artifact or enchantment. If you cast this spell during your main phase, you may exile up to one other target artifact or enchantment.
Effect effect = new ExileTargetEffect();
effect.setText("Exile target artifact or enchantment. If you cast this spell during your main phase, you may exile up to one other target artifact or enchantment");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addEffect(new ReturnToDustEffect());
this.getSpellAbility().addTarget(new TargetPermanent(1, 2, StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT, false));
}
public ReturnToDust(final ReturnToDust card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
if (game.isActivePlayer(ability.getControllerId()) && game.isMainPhase()) {
ability.addTarget(new TargetPermanent(1, 2, StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT, false));
}
else {
ability.addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT));
}
}
}
@Override
public ReturnToDust copy() {
return new ReturnToDust(this);
}
}
class ReturnToDustEffect extends OneShotEffect {
ReturnToDustEffect() {
super(Outcome.DestroyPermanent);
staticText = "Exile target artifact or enchantment. If you cast this spell during your main phase, you may exile up to one other target artifact or enchantment";
}
private ReturnToDustEffect(final ReturnToDustEffect effect) {
super(effect);
}
@Override
public Effect copy() {
return new ReturnToDustEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int targetsCleared = 0;
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId);
if (permanent == null) {
continue;
}
if (targetsCleared == 0) {
player.moveCards(permanent, Zone.EXILED, source, game);
targetsCleared++;
} else if (targetsCleared == 1) {
if (game.isActivePlayer(source.getControllerId()) && game.isMainPhase()
&& player.chooseUse(outcome, "Exile another permanent?", source, game)) {
player.moveCards(permanent, Zone.EXILED, source, game);
targetsCleared++;
} else {
break;
}
} else {
break;
}
}
return true;
}
}

View file

@ -1,7 +1,6 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
@ -14,41 +13,26 @@ import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class ReturnToTheRanks extends CardImpl {
private static final FilterCreatureCard filter = new FilterCreatureCard("creature cards with converted mana cost 2 or less from your graveyard");
static {
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 3));
}
public ReturnToTheRanks(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{W}{W}");
// Convoke
this.addAbility(new ConvokeAbility());
// Return X target creature cards with converted mana cost 2 or less from your graveyard to the battlefield.
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
effect.setText("Return X target creature cards with converted mana cost 2 or less from your graveyard to the battlefield");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,Integer.MAX_VALUE, filter));
}
@Override
public void adjustTargets(Ability ability, Game game) {
for (Effect effect : ability.getEffects()) {
if (effect instanceof ReturnFromGraveyardToBattlefieldTargetEffect) {
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(xValue,xValue, filter));
}
}
this.getSpellAbility().setTargetAdjuster(ReturnToTheRanksAdjuster.instance);
}
public ReturnToTheRanks(final ReturnToTheRanks card) {
@ -60,3 +44,19 @@ public final class ReturnToTheRanks extends CardImpl {
return new ReturnToTheRanks(this);
}
}
enum ReturnToTheRanksAdjuster implements TargetAdjuster {
instance;
private static final FilterCreatureCard filter = new FilterCreatureCard("creature cards with converted mana cost 2 or less from your graveyard");
static {
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 3));
}
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(xValue, xValue, filter));
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
@ -17,23 +15,25 @@ import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetNonlandPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import mage.target.targetpointer.SecondTargetPointer;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class RushingRiver extends CardImpl {
public RushingRiver(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}");
// Kicker-Sacrifice a land.
this.addAbility(new KickerAbility(new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent("a land")))));
// Return target nonland permanent to its owner's hand. If Rushing River was kicked, return another target nonland permanent to its owner's hand.
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect());
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect());
Effect effect = new ConditionalOneShotEffect(
new ReturnToHandTargetEffect(),
KickedCondition.instance,
@ -41,16 +41,7 @@ public final class RushingRiver extends CardImpl {
effect.setTargetPointer(new SecondTargetPointer());
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetNonlandPermanent());
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility && KickedCondition.instance.apply(game, ability)) {
ability.getTargets().clear();
ability.addTarget(new TargetNonlandPermanent(2));
}
this.getSpellAbility().setTargetAdjuster(RushingRiverAdjuster.instance);
}
public RushingRiver(final RushingRiver card) {
@ -62,3 +53,15 @@ public final class RushingRiver extends CardImpl {
return new RushingRiver(this);
}
}
enum RushingRiverAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
if (KickedCondition.instance.apply(game, ability)) {
ability.getTargets().clear();
ability.addTarget(new TargetNonlandPermanent(2));
}
}
}

View file

@ -1,9 +1,6 @@
package mage.cards.s;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -13,8 +10,8 @@ import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
@ -25,16 +22,20 @@ import mage.game.permanent.Permanent;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import mage.target.targetpointer.FixedTarget;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SatyrFiredancer extends CardImpl {
public SatyrFiredancer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT,CardType.CREATURE},"{1}{R}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{1}{R}");
this.subtype.add(SubType.SATYR);
this.power = new MageInt(1);
@ -47,19 +48,7 @@ public final class SatyrFiredancer extends CardImpl {
public SatyrFiredancer(final SatyrFiredancer card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SatyrFiredancerTriggeredAbility) {
Player opponent = game.getPlayer(ability.getEffects().get(0).getTargetPointer().getFirst(game, ability));
if (opponent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature controlled by " + opponent.getLogName());
filter.add(new ControllerIdPredicate(opponent.getId()));
ability.getTargets().add(new TargetCreaturePermanent(filter));
}
}
}
@Override
public SatyrFiredancer copy() {
return new SatyrFiredancer(this);
@ -72,6 +61,7 @@ class SatyrFiredancerTriggeredAbility extends TriggeredAbilityImpl {
public SatyrFiredancerTriggeredAbility() {
super(Zone.BATTLEFIELD, new SatyrFiredancerDamageEffect(), false);
targetAdjuster = SatyrFiredancerAdjuster.instance;
}
public SatyrFiredancerTriggeredAbility(final SatyrFiredancerTriggeredAbility ability) {
@ -97,7 +87,7 @@ class SatyrFiredancerTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (isControlledBy(game.getControllerId(event.getSourceId()))) {
MageObject damageSource = game.getObject(event.getSourceId());
if (damageSource != null) {
if (damageSource != null) {
if (game.getOpponents(getControllerId()).contains(event.getTargetId())) {
MageObject object = game.getObject(event.getSourceId());
if (object.isInstant() || object.isSorcery()) {
@ -105,7 +95,7 @@ class SatyrFiredancerTriggeredAbility extends TriggeredAbilityImpl {
if (damageSource instanceof StackObject) {
handledStackObjects.add(damageSource.getId());
}
for (Effect effect: this.getEffects()) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); // used by adjust targets
effect.setValue("damage", event.getAmount());
}
@ -147,10 +137,24 @@ class SatyrFiredancerDamageEffect extends OneShotEffect {
if (targetCreature != null && controller != null) {
int damage = (Integer) this.getValue("damage");
if (damage > 0) {
targetCreature.damage(damage, source.getSourceId(), game, false, true);
targetCreature.damage(damage, source.getSourceId(), game, false, true);
}
return true;
}
return false;
}
}
enum SatyrFiredancerAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
Player opponent = game.getPlayer(ability.getEffects().get(0).getTargetPointer().getFirst(game, ability));
if (opponent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature controlled by " + opponent.getLogName());
filter.add(new ControllerIdPredicate(opponent.getId()));
ability.getTargets().add(new TargetCreaturePermanent(filter));
}
}
}

View file

@ -1,11 +1,9 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.TapTargetEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
@ -14,24 +12,26 @@ import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FirstTargetPointer;
import mage.filter.predicate.permanent.ControllerIsActivePlayerPredicate;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SentinelOfTheEternalWatch extends CardImpl {
private final UUID originalId;
private static final FilterPermanent filter = new FilterCreaturePermanent("creature controlled by the active player");
static {
filter.add(new ControllerIsActivePlayerPredicate());
}
public SentinelOfTheEternalWatch(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}");
this.subtype.add(SubType.GIANT);
this.subtype.add(SubType.SOLDIER);
this.power = new MageInt(4);
@ -39,38 +39,22 @@ public final class SentinelOfTheEternalWatch extends CardImpl {
// Vigilance
this.addAbility(VigilanceAbility.getInstance());
// At the beginning of combat on each opponent's turn, tap target creature that player controls.
Ability ability = new BeginningOfCombatTriggeredAbility(Zone.BATTLEFIELD, new TapTargetEffect("target creature that player controls"), TargetController.OPPONENT, false, true);
originalId = ability.getOriginalId();
this.addAbility(ability);
// At the beginning of combat on each opponent's turn, tap target creature that player controls.
Ability ability = new BeginningOfCombatTriggeredAbility(
Zone.BATTLEFIELD, new TapTargetEffect("target creature that player controls"),
TargetController.OPPONENT, false, false
);
ability.addTarget(new TargetPermanent(filter));
this.addAbility(ability);
}
public SentinelOfTheEternalWatch(final SentinelOfTheEternalWatch card) {
super(card);
this.originalId = card.originalId;
}
@Override
public SentinelOfTheEternalWatch copy() {
return new SentinelOfTheEternalWatch(this);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
for (Effect effect : ability.getEffects()) {
UUID opponentId = effect.getTargetPointer().getFirst(game, ability);
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
effect.setTargetPointer(new FirstTargetPointer());
FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature from the active opponent");
filter.add(new ControllerIdPredicate(opponentId));
Target target = new TargetCreaturePermanent(filter);
ability.addTarget(target);
}
}
}
}
}
}

View file

@ -1,9 +1,6 @@
package mage.cards.s;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -13,8 +10,8 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard;
@ -23,9 +20,13 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInOpponentsGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SepulchralPrimordial extends CardImpl {
@ -37,28 +38,14 @@ public final class SepulchralPrimordial extends CardImpl {
this.power = new MageInt(5);
this.toughness = new MageInt(4);
//Vigilance
// Intimidate
this.addAbility(IntimidateAbility.getInstance());
// When Sepulchral Primordial enters the battlefield, for each opponent, you may put up to one
// target creature card from that player's graveyard onto the battlefield under your control.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SepulchralPrimordialEffect(), false));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof EntersBattlefieldTriggeredAbility) {
ability.getTargets().clear();
for (UUID opponentId : game.getOpponents(ability.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterCard filter = new FilterCreatureCard("creature card from " + opponent.getName() + "'s graveyard");
filter.add(new OwnerIdPredicate(opponentId));
TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(0, 1, filter);
ability.addTarget(target);
}
}
}
Ability ability = new EntersBattlefieldTriggeredAbility(new SepulchralPrimordialEffect(), false);
ability.setTargetAdjuster(SepulchralPrimordialAdjuster.instance);
this.addAbility(ability);
}
public SepulchralPrimordial(final SepulchralPrimordial card) {
@ -71,6 +58,24 @@ public final class SepulchralPrimordial extends CardImpl {
}
}
enum SepulchralPrimordialAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
for (UUID opponentId : game.getOpponents(ability.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterCard filter = new FilterCreatureCard("creature card from " + opponent.getName() + "'s graveyard");
filter.add(new OwnerIdPredicate(opponentId));
TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(0, 1, filter);
ability.addTarget(target);
}
}
}
}
class SepulchralPrimordialEffect extends OneShotEffect {
public SepulchralPrimordialEffect() {

View file

@ -1,9 +1,7 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
@ -15,9 +13,11 @@ import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.target.Target;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class ShatteredCrypt extends CardImpl {
@ -30,17 +30,7 @@ public final class ShatteredCrypt extends CardImpl {
effect.setText("Return X target creature cards from your graveyard to your hand");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(new ManacostVariableValue()));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(1, new FilterCreatureCard()));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
Target target = new TargetCardInYourGraveyard(xValue, new FilterCreatureCard(new StringBuilder(xValue).append(xValue != 1 ? " creature cards" : "creature card").append(" from your graveyard").toString()));
ability.addTarget(target);
}
this.getSpellAbility().setTargetAdjuster(ShatteredCryptAdjuster.instance);
}
public ShatteredCrypt(final ShatteredCrypt card) {
@ -52,3 +42,15 @@ public final class ShatteredCrypt extends CardImpl {
return new ShatteredCrypt(this);
}
}
enum ShatteredCryptAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
Target target = new TargetCardInYourGraveyard(xValue, new FilterCreatureCard((xValue != 1 ? " creature cards" : "creature card") + " from your graveyard"));
ability.addTarget(target);
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.CounterTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -12,24 +10,22 @@ import mage.constants.ComparisonType;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.target.Target;
import mage.target.TargetSpell;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SpellBlast extends CardImpl {
private static final FilterSpell filter = new FilterSpell("spell with converted mana cost X");
public SpellBlast(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}");
// Counter target spell with converted mana cost X.
this.getSpellAbility().addEffect(new CounterTargetEffect());
this.getSpellAbility().addTarget(new TargetSpell(filter));
this.getSpellAbility().addEffect(new CounterTargetEffect().setText("counter target spell with converted mana cost X"));
this.getSpellAbility().setTargetAdjuster(SpellBlastAdjuster.instance);
}
public SpellBlast(final SpellBlast card) {
@ -40,17 +36,17 @@ public final class SpellBlast extends CardImpl {
public SpellBlast copy() {
return new SpellBlast(this);
}
}
enum SpellBlastAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
FilterSpell newfilter = new FilterSpell(new StringBuilder("spell with converted mana cost ").append(xValue).toString());
newfilter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
Target target = new TargetSpell(newfilter);
ability.addTarget(target);
}
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
FilterSpell filter = new FilterSpell("spell with converted mana cost " + xValue);
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.addTarget(new TargetSpell(filter));
}
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.CounterTargetEffect;
import mage.abilities.keyword.BuybackAbility;
import mage.cards.CardImpl;
@ -14,6 +12,9 @@ import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.target.TargetSpell;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
* @author LevelX2
@ -23,23 +24,12 @@ public final class SpellBurst extends CardImpl {
public SpellBurst(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}");
// Buyback {3}
this.addAbility(new BuybackAbility("{3}"));
// Counter target spell with converted mana cost X.
this.getSpellAbility().addEffect(new CounterTargetEffect());
this.getSpellAbility().addTarget(new TargetSpell(new FilterSpell("spell with converted mana cost X")));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
FilterSpell filter = new FilterSpell("spell with converted mana cost X");
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, ability.getManaCostsToPay().getX()));
ability.addTarget(new TargetSpell(filter));
}
this.getSpellAbility().addEffect(new CounterTargetEffect().setText("counter target spell with converted mana cost X"));
this.getSpellAbility().setTargetAdjuster(SpellBurstAdjuster.instance);
}
public SpellBurst(final SpellBurst card) {
@ -51,3 +41,16 @@ public final class SpellBurst extends CardImpl {
return new SpellBurst(this);
}
}
enum SpellBurstAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
FilterSpell filter = new FilterSpell("spell with converted mana cost " + xValue);
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.addTarget(new TargetSpell(filter));
}
}

View file

@ -1,40 +1,40 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CounterTargetEffect;
import mage.abilities.keyword.FlashAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.stack.StackObject;
import mage.target.TargetSpell;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SpellstutterSprite extends CardImpl {
static final FilterPermanent filter = new FilterPermanent("number of Faeries you control");
private static final FilterSpell filter = new FilterSpell("spell with converted mana cost X or less, where X is the number of Faeries you control");
static {
filter.add(new ControllerPredicate(TargetController.YOU));
filter.add(new SubtypePredicate(SubType.FAERIE));
filter.add(SpellstutterSpritePredicate.instance);
}
public SpellstutterSprite(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.FAERIE);
this.subtype.add(SubType.WIZARD);
@ -43,71 +43,37 @@ public final class SpellstutterSprite extends CardImpl {
// Flash
this.addAbility(FlashAbility.getInstance());
// Flying
this.addAbility(FlyingAbility.getInstance());
// When Spellstutter Sprite enters the battlefield, counter target spell with converted mana cost X or less, where X is the number of Faeries you control.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SpellstutterSpriteCounterTargetEffect()));
Ability ability = new EntersBattlefieldTriggeredAbility(new CounterTargetEffect());
ability.addTarget(new TargetSpell(filter));
this.addAbility(ability);
}
public SpellstutterSprite(final SpellstutterSprite card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof EntersBattlefieldTriggeredAbility) {
int numberFaeries = game.getState().getBattlefield().countAll(filter, ability.getControllerId(), game);
FilterSpell xFilter = new FilterSpell(new StringBuilder("spell with converted mana cost ").append(numberFaeries).append(" or less").toString());
xFilter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, numberFaeries + 1));
ability.getTargets().clear();
ability.addTarget(new TargetSpell(xFilter));
}
}
@Override
public SpellstutterSprite copy() {
return new SpellstutterSprite(this);
}
}
class SpellstutterSpriteCounterTargetEffect extends OneShotEffect {
enum SpellstutterSpritePredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<MageObject>> {
instance;
private static final FilterPermanent filter = new FilterPermanent();
public SpellstutterSpriteCounterTargetEffect() {
super(Outcome.Detriment);
}
public SpellstutterSpriteCounterTargetEffect(final SpellstutterSpriteCounterTargetEffect effect) {
super(effect);
static {
filter.add(new SubtypePredicate(SubType.FAERIE));
}
@Override
public SpellstutterSpriteCounterTargetEffect copy() {
return new SpellstutterSpriteCounterTargetEffect(this);
public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
return input.getObject().getConvertedManaCost() <=
game.getBattlefield().countAll(filter, game.getControllerId(input.getSourceId()), game);
}
@Override
public boolean apply(Game game, Ability source) {
/*
* The value of X needs to be determined both when the ability triggers (so you can choose
* a target) and again when the ability resolves (to check if that target is still legal).
* If the number of Faeries you control has decreased enough in that time to make the target
* illegal, Spellstutter Sprite's ability will be countered (and the targeted spell will
* resolve as normal).
*/
int numberFaeries = game.getState().getBattlefield().countAll(SpellstutterSprite.filter, source.getControllerId(), game);
StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget());
// If do'nt have any spell targeted
if (stackObject != null && stackObject.getConvertedManaCost() <= numberFaeries) {
if (game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) {
return true;
}
}
return false;
}
@Override
public String getText(Mode mode) {
return "counter target spell with converted mana cost X or less, where X is the number of Faeries you control";
}
}
}

View file

@ -1,7 +1,6 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.cards.CardImpl;
@ -13,29 +12,21 @@ import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class StirTheGrave extends CardImpl {
public StirTheGrave(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{B}");
// Return target creature card with converted mana cost X or less from your graveyard to the battlefield.
this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard("creature card with converted mana cost X or less from your graveyard")));
}
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCard filter = new FilterCreatureCard("creature card with converted mana cost " + xValue + " or less from your graveyard");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().add(new TargetCardInYourGraveyard(filter));
this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect().setText("return target creature card with converted mana cost X or less from your graveyard to the battlefield"));
this.getSpellAbility().setTargetAdjuster(StirTheGraveAdjuster.instance);
}
public StirTheGrave(final StirTheGrave card) {
@ -47,3 +38,16 @@ public final class StirTheGrave extends CardImpl {
return new StirTheGrave(this);
}
}
enum StirTheGraveAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCard filter = new FilterCreatureCard("creature card with converted mana cost " + xValue + " or less from your graveyard");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().add(new TargetCardInYourGraveyard(filter));
}
}

View file

@ -1,8 +1,5 @@
package mage.cards.s;
import java.util.Iterator;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
@ -10,42 +7,39 @@ import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbil
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PayVariableLoyaltyCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.OpponentsLostLifeCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.*;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.UntapTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.keyword.HasteAbility;
import mage.constants.*;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.Counter;
import mage.counters.CounterType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.players.PlayerList;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import mage.watchers.common.PlayerLostLifeNonCombatWatcher;
import mage.watchers.common.PlayerLostLifeWatcher;
import java.util.UUID;
/**
*
* @author NinthWorld
*/
public final class SupremeLeaderSnoke extends CardImpl {
UUID ability3Id;
public SupremeLeaderSnoke(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{U}{B}{R}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.SNOKE);
this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(3));
@ -61,35 +55,17 @@ public final class SupremeLeaderSnoke extends CardImpl {
// -X: Gain control of target creature with converted mana cost X. Untap that creature. It gains haste. Sacrifice that creature at the beginning of the next end step.
Ability ability3 = new LoyaltyAbility(new GainControlTargetEffect(Duration.WhileOnBattlefield)
.setText("Gain control of target creature with converted mana cost X"));
.setText("Gain control of target creature with converted mana cost X"));
ability3.addEffect(new UntapTargetEffect().setText("Untap that creature"));
ability3.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield).setText("It gains haste"));
ability3.addEffect(new GainAbilityTargetEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeSourceEffect()), Duration.WhileOnBattlefield)
.setText("Sacrifice that creature at the beginning of the next end step"));
ability3Id = ability3.getOriginalId();
ability3.addTarget(new TargetCreaturePermanent());
.setText("Sacrifice that creature at the beginning of the next end step"));
ability3.setTargetAdjuster(SupremeLeaderSnokeAdjuster.instance);
this.addAbility(ability3);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(ability3Id)) {
int cmc = 0;
for (Cost cost : ability.getCosts()) {
if (cost instanceof PayVariableLoyaltyCost) {
cmc = ((PayVariableLoyaltyCost) cost).getAmount();
}
}
FilterCreaturePermanent newFilter = StaticFilters.FILTER_PERMANENT_CREATURE.copy();
newFilter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, cmc));
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(newFilter));
}
}
public SupremeLeaderSnoke(final SupremeLeaderSnoke card) {
super(card);
this.ability3Id = card.ability3Id;
}
@Override
@ -98,12 +74,30 @@ public final class SupremeLeaderSnoke extends CardImpl {
}
}
enum SupremeLeaderSnokeAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int cmc = 0;
for (Cost cost : ability.getCosts()) {
if (cost instanceof PayVariableLoyaltyCost) {
cmc = ((PayVariableLoyaltyCost) cost).getAmount();
}
}
FilterCreaturePermanent newFilter = StaticFilters.FILTER_PERMANENT_CREATURE.copy();
newFilter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, cmc));
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(newFilter));
}
}
class OpponentNoncombatLostLifeCount implements DynamicValue {
@Override
public int calculate(Game game, Ability source, Effect effect) {
PlayerLostLifeNonCombatWatcher watcher = (PlayerLostLifeNonCombatWatcher) game.getState().getWatchers().get(PlayerLostLifeNonCombatWatcher.class.getSimpleName());
if(watcher != null) {
if (watcher != null) {
return watcher.getAllOppLifeLost(source.getControllerId(), game);
}
return 0;
@ -138,9 +132,9 @@ class SupremeLeaderSnokeCounterEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if(permanent != null) {
if (permanent != null) {
int amount = new OpponentNoncombatLostLifeCount().calculate(game, source, this);
if(amount > 0) {
if (amount > 0) {
Counter counterToAdd = counter.copy();
counterToAdd.add(amount - counter.getCount());
permanent.addCounters(counterToAdd, source, game);

View file

@ -1,7 +1,6 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -25,15 +24,17 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPermanent;
import mage.target.common.TargetCardInLibrary;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SylvanPrimordial extends CardImpl {
public SylvanPrimordial(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{G}{G}");
this.subtype.add(SubType.AVATAR);
this.power = new MageInt(6);
@ -43,24 +44,9 @@ public final class SylvanPrimordial extends CardImpl {
this.addAbility(ReachAbility.getInstance());
// When Sylvan Primordial enters the battlefield, for each opponent, destroy target noncreature permanent that player controls. For each permanent destroyed this way, search your library for a Forest card and put that card onto the battlefield tapped. Then shuffle your library.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SylvanPrimordialEffect(),false));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof EntersBattlefieldTriggeredAbility) {
ability.getTargets().clear();
for(UUID opponentId : game.getOpponents(ability.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterPermanent filter = new FilterPermanent("noncreature permanent from opponent " + opponent.getLogName());
filter.add(new ControllerIdPredicate(opponentId));
filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
TargetPermanent target = new TargetPermanent(0,1, filter,false);
ability.addTarget(target);
}
}
}
Ability ability = new EntersBattlefieldTriggeredAbility(new SylvanPrimordialEffect(), false);
ability.setTargetAdjuster(SylvanPrimordialAdjuster.instance);
this.addAbility(ability);
}
public SylvanPrimordial(final SylvanPrimordial card) {
@ -73,10 +59,30 @@ public final class SylvanPrimordial extends CardImpl {
}
}
enum SylvanPrimordialAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
for (UUID opponentId : game.getOpponents(ability.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterPermanent filter = new FilterPermanent("noncreature permanent from opponent " + opponent.getLogName());
filter.add(new ControllerIdPredicate(opponentId));
filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
TargetPermanent target = new TargetPermanent(0, 1, filter, false);
ability.addTarget(target);
}
}
}
}
class SylvanPrimordialEffect extends OneShotEffect {
private static final FilterLandCard filterForest = new FilterLandCard("Forest");
static{
static {
filterForest.add(new SubtypePredicate(SubType.FOREST));
}
@ -98,7 +104,7 @@ class SylvanPrimordialEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
boolean result = false;
int destroyedCreatures = 0;
for (Target target: source.getTargets()) {
for (Target target : source.getTargets()) {
if (target instanceof TargetPermanent) {
Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
if (targetPermanent != null) {
@ -109,7 +115,7 @@ class SylvanPrimordialEffect extends OneShotEffect {
}
}
if (destroyedCreatures > 0) {
new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(destroyedCreatures,filterForest), true, true).apply(game, source);
new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(destroyedCreatures, filterForest), true, true).apply(game, source);
}
return result;
}

View file

@ -1,7 +1,6 @@
package mage.cards.t;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -13,28 +12,24 @@ import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author Styxo
*/
public final class TheBattleOfNaboo extends CardImpl {
public TheBattleOfNaboo(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{X}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{U}{U}");
// Return X target creatures to their owner's hands. Draw twice that many cards.
Effect effect = new ReturnToHandTargetEffect();
effect.setText("Return X target creatures to their owner's hands");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addEffect(new TheBattleOfNabooEffect());
}
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
this.getSpellAbility().setTargetAdjuster(TheBattleOfNabooAdjuster.instance);
}
public TheBattleOfNaboo(final TheBattleOfNaboo card) {
@ -47,6 +42,16 @@ public final class TheBattleOfNaboo extends CardImpl {
}
}
enum TheBattleOfNabooAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
}
}
class TheBattleOfNabooEffect extends OneShotEffect {
public TheBattleOfNabooEffect() {
@ -72,9 +77,7 @@ class TheBattleOfNabooEffect extends OneShotEffect {
player.drawCards(2 * x, game);
}
return true;
}
return false;
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.t;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.keyword.AssistAbility;
@ -17,9 +15,11 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.CounterPredicate;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class TheCrowdGoesWild extends CardImpl {
@ -41,6 +41,7 @@ public final class TheCrowdGoesWild extends CardImpl {
.setText("Support X <i>(Put a +1/+1 counter on each of up to X target creatures.)</i><br>")
);
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().setTargetAdjuster(TheCrowdGoesWildAdjuster.instance);
// Each creature with a +1/+1 counter on it gains trample until end of turn.
this.getSpellAbility().addEffect(new GainAbilityAllEffect(TrampleAbility.getInstance(), Duration.EndOfTurn, filter));
@ -50,17 +51,18 @@ public final class TheCrowdGoesWild extends CardImpl {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
ability.addTarget(new TargetCreaturePermanent(0, xValue));
}
}
@Override
public TheCrowdGoesWild copy() {
return new TheCrowdGoesWild(this);
}
}
enum TheCrowdGoesWildAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(0, ability.getManaCostsToPay().getX()));
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.t;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl;
@ -12,21 +10,23 @@ import mage.constants.CardType;
import mage.counters.CounterType;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class Thrive extends CardImpl {
public Thrive(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{G}");
// Put a +1/+1 counter on each of X target creatures.
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
effect.setText("Put a +1/+1 counter on each of X target creatures");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1));
this.getSpellAbility().setTargetAdjuster(ThriveAdjuster.instance);
}
public Thrive(final Thrive card) {
@ -37,13 +37,14 @@ public final class Thrive extends CardImpl {
public Thrive copy() {
return new Thrive(this);
}
}
enum ThriveAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
ability.addTarget(new TargetCreaturePermanent(xValue));
}
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
}
}
}

View file

@ -1,60 +1,58 @@
package mage.cards.t;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.common.DiscardXTargetCost;
import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.StaticFilters;
import mage.filter.common.FilterNonlandPermanent;
import mage.game.Game;
import mage.target.Target;
import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class TurbulentDreams extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("nonland permanents");
static {
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
}
public TurbulentDreams(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{U}{U}");
// As an additional cost to cast Turbulent Dreams, discard X cards.
this.getSpellAbility().addCost(new DiscardXTargetCost(new FilterCard("cards"), true));
this.getSpellAbility().addCost(new DiscardXTargetCost(StaticFilters.FILTER_CARD_CARDS, true));
// Return X target nonland permanents to their owners' hands.
Effect effect = new ReturnToHandTargetEffect();
effect.setText("Return X target nonland permanents to their owners' hands");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().setTargetAdjuster(TurbulentDreamsAdjuster.instance);
}
public TurbulentDreams(final TurbulentDreams card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = new GetXValue().calculate(game, ability, null);
Target target = new TargetPermanent(0, xValue, filter, false);
ability.addTarget(target);
}
@Override
public TurbulentDreams copy() {
return new TurbulentDreams(this);
}
}
enum TurbulentDreamsAdjuster implements TargetAdjuster {
instance;
private static final FilterPermanent filter = new FilterNonlandPermanent("nonland permanents");
@Override
public void adjustTargets(Ability ability, Game game) {
Target target = new TargetPermanent(0, ability.getManaCostsToPay().getX(), filter, false);
ability.addTarget(target);
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.u;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
@ -18,9 +16,11 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.target.common.TargetPlayerOrPlaneswalker;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class UnstableFooting extends CardImpl {
@ -36,20 +36,12 @@ public final class UnstableFooting extends CardImpl {
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new DamageTargetEffect(5),
KickedCondition.instance,
"If this spell was kicked, it deals 5 damage to target player or planeswalker"));
"If this spell was kicked, it deals 5 damage to target player or planeswalker")
);
this.getSpellAbility().setTargetAdjuster(UnstableFootingAdjuster.instance);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
if (KickedCondition.instance.apply(game, ability)) {
ability.addTarget(new TargetPlayerOrPlaneswalker());
}
}
}
public UnstableFooting(final UnstableFooting card) {
super(card);
}
@ -60,6 +52,18 @@ public final class UnstableFooting extends CardImpl {
}
}
enum UnstableFootingAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
if (KickedCondition.instance.apply(game, ability)) {
ability.addTarget(new TargetPlayerOrPlaneswalker());
}
}
}
class UnstableFootingEffect extends ReplacementEffectImpl {
public UnstableFootingEffect() {

View file

@ -1,52 +1,58 @@
package mage.cards.v;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.common.DiscardXTargetCost;
import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterAttackingCreature;
import mage.game.Game;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class VengefulDreams extends CardImpl {
public VengefulDreams(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{W}{W}");
// As an additional cost to cast Vengeful Dreams, discard X cards.
this.getSpellAbility().addCost(new DiscardXTargetCost(new FilterCard("cards"), true));
// Exile X target attacking creatures.
Effect effect = new ExileTargetEffect();
effect.setText("Exile X target attacking creatures");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().setTargetAdjuster(VengefulDreamsAdjuster.instance);
}
public VengefulDreams(final VengefulDreams card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = new GetXValue().calculate(game, ability, null);
Target target = new TargetCreaturePermanent(0, xValue, new FilterAttackingCreature(), false);
ability.addTarget(target);
}
@Override
public VengefulDreams copy() {
return new VengefulDreams(this);
}
}
enum VengefulDreamsAdjuster implements TargetAdjuster {
instance;
private static final FilterPermanent filter = new FilterAttackingCreature();
@Override
public void adjustTargets(Ability ability, Game game) {
Target target = new TargetPermanent(0, ability.getManaCostsToPay().getX(), filter, false);
ability.addTarget(target);
}
}

View file

@ -1,11 +1,7 @@
package mage.cards.v;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
@ -16,12 +12,9 @@ import mage.abilities.keyword.FlashAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -30,8 +23,9 @@ import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.AttackedThisTurnWatcher;
import mage.watchers.common.BlockedThisTurnWatcher;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class VizierOfDeferment extends CardImpl {
@ -49,39 +43,10 @@ public final class VizierOfDeferment extends CardImpl {
// When Vizier of Deferment enters the battlefield, you may exile target creature if it attacked or blocked this turn. Return that card to the battlefield under its owner's control at the beginning of the next end step.
Ability ability = new EntersBattlefieldTriggeredAbility(new VizierOfDefermentEffect(), true);
ability.addTarget(new TargetCreaturePermanent());
ability.addWatcher(new AttackedThisTurnWatcher());
ability.addWatcher(new BlockedThisTurnWatcher());
this.addAbility(ability);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof EntersBattlefieldTriggeredAbility) {
List<PermanentIdPredicate> creaturesThatCanBeTargeted = new ArrayList<>();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that attacked or blocked this turn.");
AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
BlockedThisTurnWatcher watcherBlocked = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName());
if (watcherAttacked != null) {
for (MageObjectReference mor : watcherAttacked.getAttackedThisTurnCreatures()) {
Permanent permanent = mor.getPermanent(game);
if (permanent != null) {
creaturesThatCanBeTargeted.add(new PermanentIdPredicate(permanent.getId()));
}
}
if (watcherBlocked != null) {
for (MageObjectReference mor : watcherBlocked.getBlockedThisTurnCreatures()) {
Permanent permanent = mor.getPermanent(game);
if (permanent != null) {
creaturesThatCanBeTargeted.add(new PermanentIdPredicate(permanent.getId()));
}
}
}
filter.add(Predicates.or(creaturesThatCanBeTargeted));
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(filter));
}
}
}
public VizierOfDeferment(final VizierOfDeferment card) {
@ -98,7 +63,8 @@ class VizierOfDefermentEffect extends OneShotEffect {
public VizierOfDefermentEffect() {
super(Outcome.Detriment);
staticText = "you may exile target creature if it attacked or blocked this turn. Return that card to the battlefield under its owner's control at the beginning of the next end step";
staticText = "you may exile target creature if it attacked or blocked this turn. " +
"Return that card to the battlefield under its owner's control at the beginning of the next end step";
}
public VizierOfDefermentEffect(final VizierOfDefermentEffect effect) {
@ -110,8 +76,17 @@ class VizierOfDefermentEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getFirstTarget());
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
BlockedThisTurnWatcher watcherBlocked = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName());
boolean attackedOrBlocked = false;
if (watcherAttacked != null && watcherAttacked.checkIfAttacked(permanent, game)) {
attackedOrBlocked = true;
}
if (watcherBlocked != null && watcherBlocked.checkIfBlocked(permanent, game)) {
attackedOrBlocked = true;
}
if (controller != null
&& permanent != null
&& attackedOrBlocked
&& sourcePermanent != null) {
if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) {
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect();

View file

@ -1,9 +1,7 @@
package mage.cards.v;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -22,30 +20,22 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetOpponentsChoicePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class VolcanicOffering extends CardImpl {
private static final FilterLandPermanent filterLand = new FilterLandPermanent("nonbasic land you don't control");
private static final FilterCreaturePermanent filterCreature = new FilterCreaturePermanent("creature you don't control");
static {
filterLand.add(new ControllerPredicate(TargetController.NOT_YOU));
filterLand.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
filterCreature.add(new ControllerPredicate(TargetController.NOT_YOU));
}
public VolcanicOffering(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{4}{R}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{R}");
// Destroy target nonbasic land you don't control and target nonbasic land of an opponent's choice you don't control.
// Volcanic Offering deals 7 damage to target creature you don't control and 7 damage to target creature of an opponent's choice you don't control.
this.getSpellAbility().addEffect(new VolcanicOfferingEffect());
this.getSpellAbility().addTarget(new TargetPermanent(filterLand));
this.getSpellAbility().addTarget(new TargetPermanent(filterCreature));
this.getSpellAbility().setTargetAdjuster(VolcanicOfferingAdjuster.instance);
}
public VolcanicOffering(final VolcanicOffering card) {
@ -53,27 +43,39 @@ public final class VolcanicOffering extends CardImpl {
}
@Override
public void adjustTargets(Ability ability, Game game) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller != null && (ability instanceof SpellAbility)) {
ability.getTargets().clear();
ability.addTarget(new TargetPermanent(filterLand));
FilterLandPermanent filterLandForOpponent = new FilterLandPermanent("nonbasic land not controlled by " + controller.getLogName());
filterLandForOpponent.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
filterLandForOpponent.add(Predicates.not(new ControllerIdPredicate(controller.getId())));
ability.addTarget(new TargetOpponentsChoicePermanent(1, 1, filterLandForOpponent, false, true));
public VolcanicOffering copy() {
return new VolcanicOffering(this);
}
}
ability.addTarget(new TargetPermanent(filterCreature));
FilterCreaturePermanent filterCreatureForOpponent = new FilterCreaturePermanent("creature not controlled by " + controller.getLogName());
filterCreatureForOpponent.add(Predicates.not(new ControllerIdPredicate(controller.getId())));
ability.addTarget(new TargetOpponentsChoicePermanent(1, 1, filterCreatureForOpponent, false, true));
}
enum VolcanicOfferingAdjuster implements TargetAdjuster {
instance;
private static final FilterLandPermanent filterLand = new FilterLandPermanent("nonbasic land you don't control");
private static final FilterCreaturePermanent filterCreature = new FilterCreaturePermanent("creature you don't control");
static {
filterLand.add(new ControllerPredicate(TargetController.NOT_YOU));
filterLand.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
filterCreature.add(new ControllerPredicate(TargetController.NOT_YOU));
}
@Override
public VolcanicOffering copy() {
return new VolcanicOffering(this);
public void adjustTargets(Ability ability, Game game) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller == null) {
return;
}
ability.getTargets().clear();
ability.addTarget(new TargetPermanent(filterLand));
FilterLandPermanent filterLandForOpponent = new FilterLandPermanent("nonbasic land not controlled by " + controller.getLogName());
filterLandForOpponent.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
filterLandForOpponent.add(Predicates.not(new ControllerIdPredicate(controller.getId())));
ability.addTarget(new TargetOpponentsChoicePermanent(1, 1, filterLandForOpponent, false, true));
ability.addTarget(new TargetPermanent(filterCreature));
FilterCreaturePermanent filterCreatureForOpponent = new FilterCreaturePermanent("creature not controlled by " + controller.getLogName());
filterCreatureForOpponent.add(Predicates.not(new ControllerIdPredicate(controller.getId())));
ability.addTarget(new TargetOpponentsChoicePermanent(1, 1, filterCreatureForOpponent, false, true));
}
}

View file

@ -1,12 +1,9 @@
package mage.cards.v;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.MultikickerCount;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.FlyingAbility;
@ -14,21 +11,21 @@ import mage.abilities.keyword.MultikickerAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class VoyagerDrake extends CardImpl {
private final UUID originalId;
public VoyagerDrake(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}");
this.subtype.add(SubType.DRAKE);
this.power = new MageInt(3);
@ -41,29 +38,18 @@ public final class VoyagerDrake extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// When Voyager Drake enters the battlefield, up to X target creatures gain flying until end of turn, where X is the number of times Voyager Drake was kicked.
//TODO this should trigger even if it wasn't kicked at all
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), false),
KickedCondition.instance,
"When {this} enters the battlefield, up to X target creatures gain flying until end of turn, where X is the number of times {this} was kicked.");
originalId = ability.getOriginalId();
Ability ability = new EntersBattlefieldTriggeredAbility(
new GainAbilityTargetEffect(
FlyingAbility.getInstance(), Duration.EndOfTurn
).setText("up to X target creatures gain flying until end of turn, " +
"where X is the number of times {this} was kicked.")
);
ability.setTargetAdjuster(VoyagerDrakeAdjuster.instance);
this.addAbility(ability);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
ability.getTargets().clear();
int numbTargets = new MultikickerCount().calculate(game, ability, null);
if (numbTargets > 0) {
ability.addTarget(new TargetCreaturePermanent(0, numbTargets));
}
}
}
public VoyagerDrake(final VoyagerDrake card) {
super(card);
this.originalId = card.originalId;
}
@Override
@ -71,3 +57,16 @@ public final class VoyagerDrake extends CardImpl {
return new VoyagerDrake(this);
}
}
enum VoyagerDrakeAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int numbTargets = new MultikickerCount().calculate(game, ability, null);
if (numbTargets > 0) {
ability.addTarget(new TargetCreaturePermanent(0, numbTargets));
}
}
}

View file

@ -3,7 +3,6 @@ package mage.cards.w;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.SpellAbility;
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.condition.common.OnOpponentsTurnCondition;
@ -18,11 +17,13 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TurnPhase;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import mage.target.targetpointer.FixedTargets;
import java.util.ArrayList;
@ -30,29 +31,19 @@ import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class WakeTheDead extends CardImpl {
public WakeTheDead(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{B}{B}");
// Cast Wake the Dead only during combat on an opponent's turn.
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, OnOpponentsTurnCondition.instance));
// Return X target creature cards from your graveyard to the battlefield. Sacrifice those creatures at the beginning of the next end step.
this.getSpellAbility().addEffect(new WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, new FilterCreatureCard("creature cards from your graveyard")));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(xValue, xValue, new FilterCreatureCard("creature cards from your graveyard")));
}
this.getSpellAbility().setTargetAdjuster(WakeTheDeadAdjuster.instance);
}
public WakeTheDead(final WakeTheDead card) {
@ -65,6 +56,17 @@ public final class WakeTheDead extends CardImpl {
}
}
enum WakeTheDeadAdjuster implements TargetAdjuster {
instance;
private static final FilterCard filter = new FilterCreatureCard("creature cards from your graveyard");
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(ability.getManaCostsToPay().getX(), filter));
}
}
class WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect {
public WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect() {

View file

@ -1,21 +1,20 @@
package mage.cards.w;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.combat.CantBlockTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class WaveOfIndifference extends CardImpl {
@ -27,23 +26,25 @@ public final class WaveOfIndifference extends CardImpl {
Effect effect = new CantBlockTargetEffect(Duration.EndOfTurn);
effect.setText("X target creatures can't block this turn");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1, StaticFilters.FILTER_PERMANENT_CREATURE, false));
this.getSpellAbility().setTargetAdjuster(WaveOfIndifferenceAdjuster.instance);
}
public WaveOfIndifference(final WaveOfIndifference card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
}
}
@Override
public WaveOfIndifference copy() {
return new WaveOfIndifference(this);
}
}
enum WaveOfIndifferenceAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.w;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
@ -13,9 +11,11 @@ import mage.constants.CardType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class WildestDreams extends CardImpl {
@ -28,17 +28,8 @@ public final class WildestDreams extends CardImpl {
Effect effect = new ReturnFromGraveyardToHandTargetEffect();
effect.setText("Return X target cards from your graveyard to your hand");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().setTargetAdjuster(WildestDreamsAdjuster.instance);
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(xValue, StaticFilters.FILTER_CARD_FROM_YOUR_GRAVEYARD));
}
}
public WildestDreams(final WildestDreams card) {
@ -50,3 +41,16 @@ public final class WildestDreams extends CardImpl {
return new WildestDreams(this);
}
}
enum WildestDreamsAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(
ability.getManaCostsToPay().getX(),
StaticFilters.FILTER_CARD_FROM_YOUR_GRAVEYARD
));
}
}

View file

@ -1,8 +1,6 @@
package mage.cards.w;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -12,9 +10,11 @@ import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class WindgracesJudgment extends CardImpl {
@ -29,24 +29,7 @@ public final class WindgracesJudgment extends CardImpl {
+ "destroy target nonland permanent "
+ "that player controls")
);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
game.getOpponents(ability.getControllerId()).forEach(playerId -> {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterNonlandPermanent filter = new FilterNonlandPermanent(
"nonland permanent controlled by "
+ player.getLogName()
);
filter.add(new ControllerIdPredicate(playerId));
ability.addTarget(new TargetPermanent(0, 1, filter, false));
}
});
}
this.getSpellAbility().setTargetAdjuster(WindgracesJudgmentAdjuster.instance);
}
public WindgracesJudgment(final WindgracesJudgment card) {
@ -58,3 +41,23 @@ public final class WindgracesJudgment extends CardImpl {
return new WindgracesJudgment(this);
}
}
enum WindgracesJudgmentAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
game.getOpponents(ability.getControllerId()).forEach(playerId -> {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterNonlandPermanent filter = new FilterNonlandPermanent(
"nonland permanent controlled by "
+ player.getLogName()
);
filter.add(new ControllerIdPredicate(playerId));
ability.addTarget(new TargetPermanent(0, 1, filter, false));
}
});
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.w;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
@ -13,9 +11,11 @@ import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class WinterBlast extends CardImpl {
@ -26,15 +26,7 @@ public final class WinterBlast extends CardImpl {
// Tap X target creatures. Winter Blast deals 2 damage to each of those creatures with flying.
this.getSpellAbility().addEffect(new WinterBlastEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
ability.addTarget(new TargetCreaturePermanent(xValue));
}
this.getSpellAbility().setTargetAdjuster(WinterBlastAdjuster.instance);
}
public WinterBlast(final WinterBlast card) {
@ -47,6 +39,16 @@ public final class WinterBlast extends CardImpl {
}
}
enum WinterBlastAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
}
}
class WinterBlastEffect extends OneShotEffect {
WinterBlastEffect() {

View file

@ -1,19 +1,18 @@
package mage.cards.w;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.TapTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import static mage.filter.StaticFilters.FILTER_PERMANENT_CREATURES;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class WordOfBinding extends CardImpl {
@ -23,25 +22,25 @@ public final class WordOfBinding extends CardImpl {
// Tap X target creatures.
this.getSpellAbility().addEffect(new TapTargetEffect("X target creatures"));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1, FILTER_PERMANENT_CREATURES, false));
this.getSpellAbility().setTargetAdjuster(WordOfBindingAdjuster.instance);
}
public WordOfBinding(final WordOfBinding card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int numberToTap = ability.getManaCostsToPay().getX();
numberToTap = Math.min(game.getBattlefield().count(FILTER_PERMANENT_CREATURES, ability.getSourceId(), ability.getControllerId(), game), numberToTap);
ability.addTarget(new TargetCreaturePermanent(numberToTap, numberToTap, FILTER_PERMANENT_CREATURES, false));
}
}
@Override
public WordOfBinding copy() {
return new WordOfBinding(this);
}
}
enum WordOfBindingAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
}
}

View file

@ -1,15 +1,17 @@
package mage.watchers.common;
import mage.MageObjectReference;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import mage.MageObjectReference;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
/**
* @author magenoxx_at_gmail.com
@ -47,6 +49,15 @@ public class AttackedThisTurnWatcher extends Watcher {
return this.attackedThisTurnCreaturesCounts;
}
public boolean checkIfAttacked(Permanent permanent, Game game) {
for (MageObjectReference mor : attackedThisTurnCreatures) {
if (mor.refersTo(permanent, game)) {
return true;
}
}
return false;
}
@Override
public AttackedThisTurnWatcher copy() {
return new AttackedThisTurnWatcher(this);

View file

@ -1,17 +1,17 @@
package mage.watchers.common;
import java.util.HashSet;
import java.util.Set;
import mage.MageObjectReference;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
import java.util.HashSet;
import java.util.Set;
/**
*
* @author Quercitron
*/
public class BlockedThisTurnWatcher extends Watcher {
@ -44,6 +44,15 @@ public class BlockedThisTurnWatcher extends Watcher {
return this.blockedThisTurnCreatures;
}
public boolean checkIfBlocked(Permanent permanent, Game game) {
for (MageObjectReference mor : blockedThisTurnCreatures) {
if (mor.refersTo(permanent, game)) {
return true;
}
}
return false;
}
@Override
public void reset() {
super.reset();