updated target adjusters E through M

This commit is contained in:
Evan Kranzler 2018-09-27 20:20:52 -04:00
parent f6ed3a4d19
commit 1e94ebdd82
21 changed files with 480 additions and 495 deletions

View file

@ -1,38 +1,38 @@
package mage.cards.e;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.combat.CantBlockTargetEffect;
import mage.abilities.keyword.EternalizeAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.ComparisonType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class EarthshakerKhenra extends CardImpl {
private final UUID originalId;
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power less than or equal to {this}'s power");
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power less than or equal to this creature's power");
static {
filter.add(EarthshakerKhenraPredicate.instance);
}
public EarthshakerKhenra(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
@ -46,32 +46,20 @@ public final class EarthshakerKhenra extends CardImpl {
this.addAbility(HasteAbility.getInstance());
// When Earthshaker Khenra enters the battlefield, target creature with power less than or equal to Earthshaker Khenra's power can't block this turn.
Ability ability = new EntersBattlefieldTriggeredAbility(new EarthshakerKhenraEffect());
Ability ability = new EntersBattlefieldTriggeredAbility(
new CantBlockTargetEffect(Duration.EndOfTurn)
.setText("target creature with power less than or equal " +
"to {this}'s power can't block this turn")
);
ability.addTarget(new TargetCreaturePermanent(filter));
this.addAbility(ability);
originalId = ability.getOriginalId();
// Eternalize {4}{R}{R}
this.addAbility(new EternalizeAbility(new ManaCostsImpl("{4}{R}{R}"), this));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
Permanent sourcePermanent = game.getPermanent(ability.getSourceId());
if (sourcePermanent != null) {
FilterCreaturePermanent targetFilter = new FilterCreaturePermanent("creature with power less than or equal to " + getLogName() + "'s power");
targetFilter.add(new PowerPredicate(ComparisonType.FEWER_THAN, sourcePermanent.getPower().getValue() + 1));
ability.getTargets().clear();
ability.getTargets().add(new TargetCreaturePermanent(targetFilter));
}
}
}
public EarthshakerKhenra(final EarthshakerKhenra card) {
super(card);
this.originalId = card.originalId;
}
@Override
@ -80,39 +68,12 @@ public final class EarthshakerKhenra extends CardImpl {
}
}
class EarthshakerKhenraEffect extends OneShotEffect {
public EarthshakerKhenraEffect() {
super(Outcome.UnboostCreature);
this.staticText = "target creature with power less than or equal to {this}'s power can't block this turn";
}
public EarthshakerKhenraEffect(final EarthshakerKhenraEffect effect) {
super(effect);
}
enum EarthshakerKhenraPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Card>> {
instance;
@Override
public EarthshakerKhenraEffect copy() {
return new EarthshakerKhenraEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourceObject != null) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
/*
27.06.2017 The target creature's power is checked when you target it with Earthshaker Khenra's ability
and when that ability resolves. Once the ability resolves, if the creature's power increases
or Earthshaker Khenra's power decreases, the target creature will still be unable to block.
*/
if (targetCreature != null && targetCreature.getPower().getValue() <= sourceObject.getPower().getValue()) {
ContinuousEffect effect = new CantBlockTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(targetCreature, game));
game.addEffect(effect, source);
}
return true;
}
return false;
public boolean apply(ObjectSourcePlayer<Card> input, Game game) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId());
return sourcePermanent != null && input.getObject().getPower().getValue() <= sourcePermanent.getPower().getValue();
}
}

View file

@ -1,12 +1,8 @@
package mage.cards.h;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -21,10 +17,14 @@ import mage.game.permanent.token.EmptyToken;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import mage.util.CardUtil;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class HourOfEternity extends CardImpl {
@ -34,17 +34,7 @@ public final class HourOfEternity extends CardImpl {
// Exile X target creature cards from your graveyard. For each card exiled this way, create a token that's a copy of that card, except it's a 4/4 black Zombie.
this.getSpellAbility().addEffect(new HourOfEternityEffect());
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) {
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(HourOfEternityAdjuster.instance);
}
public HourOfEternity(final HourOfEternity card) {
@ -57,11 +47,25 @@ public final class HourOfEternity extends CardImpl {
}
}
enum HourOfEternityAdjuster 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);
}
}
class HourOfEternityEffect extends OneShotEffect {
HourOfEternityEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "Exile X target creature cards from your graveyard. For each card exiled this way, create a token that's a copy of that card, except it's a 4/4 black Zombie";
this.staticText = "Exile X target creature cards from your graveyard. " +
"For each card exiled this way, create a token that's a copy of that card, " +
"except it's a 4/4 black Zombie";
}
HourOfEternityEffect(final HourOfEternityEffect effect) {

View file

@ -1,9 +1,7 @@
package mage.cards.i;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.condition.LockedInCondition;
import mage.abilities.condition.common.FerociousCondition;
import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect;
@ -13,12 +11,13 @@ import mage.abilities.effects.common.TapTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
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 IcyBlast extends CardImpl {
@ -28,7 +27,6 @@ public final class IcyBlast extends CardImpl {
// Tap X target creatures.
this.getSpellAbility().addEffect(new TapTargetEffect("X target creatures"));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1, StaticFilters.FILTER_PERMANENT_CREATURE, false));
// <i>Ferocious</i> &mdash; If you control a creature with power 4 or greater, those creatures don't untap during their controllers' next untap steps.
Effect effect = new ConditionalContinuousRuleModifyingEffect(
@ -36,24 +34,25 @@ public final class IcyBlast extends CardImpl {
new LockedInCondition(FerociousCondition.instance));
effect.setText("<br/><i>Ferocious</i> &mdash; If you control a creature with power 4 or greater, those creatures don't untap during their controllers' next untap steps");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().setTargetAdjuster(IcyBlastAdjuster.instance);
}
public IcyBlast(final IcyBlast 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(StaticFilters.FILTER_PERMANENT_CREATURE, ability.getSourceId(), ability.getControllerId(), game), numberToTap);
ability.addTarget(new TargetCreaturePermanent(numberToTap));
}
}
@Override
public IcyBlast copy() {
return new IcyBlast(this);
}
}
enum IcyBlastAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
}
}

View file

@ -2,7 +2,6 @@
package mage.cards.i;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.*;
import mage.constants.CardType;
@ -16,53 +15,64 @@ import mage.game.permanent.Permanent;
import mage.players.Library;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class IndomitableCreativity extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("artifacts and/or creatures");
static {
filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE)));
}
public IndomitableCreativity(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}{R}{R}");
// Destroy X target artifacts and/or creatures. For each permanent destroyed this way, its controller reveals cards from the top of their library until an artifact or creature card is revealed and exiles that card. Those players put the exiled card onto the battlefield, then shuffle their libraries.
getSpellAbility().addEffect(new IndomitableCreativityEffect());
this.getSpellAbility().addTarget(new TargetPermanent(filter));
this.getSpellAbility().addEffect(new IndomitableCreativityEffect());
this.getSpellAbility().setTargetAdjuster(IndomitableCreativityAdjuster.instance);
}
public IndomitableCreativity(final IndomitableCreativity card) {
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 TargetPermanent(xValue, xValue, filter, false));
}
}
@Override
public IndomitableCreativity copy() {
return new IndomitableCreativity(this);
}
}
enum IndomitableCreativityAdjuster implements TargetAdjuster {
instance;
private static final FilterPermanent filter = new FilterPermanent("artifacts and/or creatures");
static {
filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE)
));
}
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
ability.addTarget(new TargetPermanent(xValue, xValue, filter, false));
}
}
class IndomitableCreativityEffect extends OneShotEffect {
public IndomitableCreativityEffect() {
super(Outcome.Benefit);
this.staticText = "Destroy X target artifacts and/or creatures. For each permanent destroyed this way, its controller reveals cards from the top of their library until an artifact or creature card is revealed and exiles that card. Those players put the exiled card onto the battlefield, then shuffle their libraries";
this.staticText = "Destroy X target artifacts and/or creatures. " +
"For each permanent destroyed this way, " +
"its controller reveals cards from the top of their library" +
" until an artifact or creature card is revealed and exiles that card. " +
"Those players put the exiled card onto the battlefield, then shuffle their libraries";
}
public IndomitableCreativityEffect(final IndomitableCreativityEffect effect) {

View file

@ -1,9 +1,7 @@
package mage.cards.k;
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;
@ -17,9 +15,11 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author sinsedrix
*/
public final class KaerveksPurge extends CardImpl {
@ -28,19 +28,8 @@ public final class KaerveksPurge extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{B}{R}");
// Destroy target creature with converted mana cost X. If that creature dies this way, Kaervek's Purge deals damage equal to the creature's power to the creature's controller.
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature with converted mana cost X")));
this.getSpellAbility().addEffect(new KaerveksPurgeEffect());
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with converted mana cost X");
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.addTarget(new TargetCreaturePermanent(filter));
}
this.getSpellAbility().setTargetAdjuster(KaerveksPurgeAdjuster.instance);
}
public KaerveksPurge(final KaerveksPurge card) {
@ -53,11 +42,27 @@ public final class KaerveksPurge extends CardImpl {
}
}
enum KaerveksPurgeAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with converted mana cost " + xValue);
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.addTarget(new TargetCreaturePermanent(filter));
}
}
class KaerveksPurgeEffect extends OneShotEffect {
public KaerveksPurgeEffect() {
super(Outcome.DestroyPermanent);
this.staticText = "Destroy target creature with converted mana cost X. If that creature dies this way, {this} deals damage equal to the creature's power to the creature's controller";
this.staticText = "Destroy target creature with converted mana cost X. " +
"If that creature dies this way, " +
"{this} deals damage equal to the creature's power" +
" to the creature's controller";
}
public KaerveksPurgeEffect(final KaerveksPurgeEffect effect) {

View file

@ -1,12 +1,11 @@
package mage.cards.k;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.CumulativeUpkeepAbility;
import mage.cards.CardImpl;
@ -21,9 +20,11 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetAnyTarget;
import mage.target.common.TargetOpponent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author L_J
*/
public final class KarplusanMinotaur extends CardImpl {
@ -39,36 +40,10 @@ public final class KarplusanMinotaur extends CardImpl {
this.addAbility(new CumulativeUpkeepAbility(new KarplusanMinotaurCost()));
// Whenever you win a coin flip, Karplusan Minotaur deals 1 damage to any target.
Ability abilityWin = new KarplusanMinotaurFlipWinTriggeredAbility();
abilityWin.addTarget(new TargetAnyTarget());
this.addAbility(abilityWin);
this.addAbility(new KarplusanMinotaurFlipWinTriggeredAbility());
//TODO: Make ability properly copiable
// Whenever you lose a coin flip, Karplusan Minotaur deals 1 damage to any target of an opponent's choice.
Ability abilityLose = new KarplusanMinotaurFlipLoseTriggeredAbility();
abilityLose.addTarget(new TargetAnyTarget());
this.addAbility(abilityLose);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof KarplusanMinotaurFlipLoseTriggeredAbility) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) {
UUID opponentId = null;
if (game.getOpponents(controller.getId()).size() > 1) {
Target target = new TargetOpponent(true);
if (controller.chooseTarget(Outcome.Neutral, target, ability, game)) {
opponentId = target.getFirstTarget();
}
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
if (opponentId != null) {
ability.getTargets().get(0).setTargetController(opponentId);
}
}
}
this.addAbility(new KarplusanMinotaurFlipLoseTriggeredAbility());
}
public KarplusanMinotaur(final KarplusanMinotaur card) {
@ -81,10 +56,35 @@ public final class KarplusanMinotaur extends CardImpl {
}
}
enum KarplusanMinotaurAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller == null) {
return;
}
UUID opponentId = null;
if (game.getOpponents(controller.getId()).size() > 1) {
Target target = new TargetOpponent(true);
if (controller.chooseTarget(Outcome.Neutral, target, ability, game)) {
opponentId = target.getFirstTarget();
}
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
if (opponentId != null) {
ability.getTargets().get(0).setTargetController(opponentId);
}
}
}
class KarplusanMinotaurFlipWinTriggeredAbility extends TriggeredAbilityImpl {
public KarplusanMinotaurFlipWinTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(1), false);
this.addTarget(new TargetAnyTarget());
}
public KarplusanMinotaurFlipWinTriggeredAbility(final KarplusanMinotaurFlipWinTriggeredAbility ability) {
@ -116,6 +116,8 @@ class KarplusanMinotaurFlipLoseTriggeredAbility extends TriggeredAbilityImpl {
public KarplusanMinotaurFlipLoseTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(1), false);
this.addTarget(new TargetAnyTarget());
targetAdjuster = KarplusanMinotaurAdjuster.instance;
}
public KarplusanMinotaurFlipLoseTriggeredAbility(final KarplusanMinotaurFlipLoseTriggeredAbility ability) {

View file

@ -27,7 +27,6 @@
*/
package mage.cards.k;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -35,32 +34,25 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.FilterOpponent;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetOpponent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public class KeeperOfTheMind extends CardImpl {
public final UUID originalId;
private static final FilterOpponent filter = new FilterOpponent();
static {
filter.add(new KeeperOfTheMindPredicate());
}
public KeeperOfTheMind(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{U}");
@ -74,28 +66,12 @@ public class KeeperOfTheMind extends CardImpl {
effect.setText("Choose target opponent who had at least two more cards in hand than you did as you activated this ability. Draw a card.");
Ability ability = new SimpleActivatedAbility(effect, new ManaCostsImpl("{U}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetOpponent());
ability.setTargetAdjuster(KeeperOfTheMindAdjuster.instance);
this.addAbility(ability);
originalId = ability.getOriginalId();
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer != null) {
ability.getTargets().clear();
TargetPlayer target = new TargetPlayer(1, 1, false, filter);
target.setTargetController(activePlayer.getId());
ability.getTargets().add(target);
}
}
}
public KeeperOfTheMind(final KeeperOfTheMind card) {
super(card);
this.originalId = card.originalId;
}
@Override
@ -104,6 +80,28 @@ public class KeeperOfTheMind extends CardImpl {
}
}
enum KeeperOfTheMindAdjuster implements TargetAdjuster {
instance;
private static final FilterOpponent filter = new FilterOpponent();
static {
filter.add(new KeeperOfTheMindPredicate());
}
@Override
public void adjustTargets(Ability ability, Game game) {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer == null) {
return;
}
ability.getTargets().clear();
TargetPlayer target = new TargetPlayer(1, 1, false, filter);
target.setTargetController(activePlayer.getId());
ability.addTarget(target);
}
}
class KeeperOfTheMindPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Player>> {
@Override

View file

@ -1,9 +1,7 @@
package mage.cards.k;
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;
@ -13,21 +11,21 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class KillingGlare extends CardImpl {
public KillingGlare (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{B}");
public KillingGlare(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{B}");
// Destroy target creature with power X or less.
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature with power X or less")));
this.getSpellAbility().addEffect(new DestroyTargetEffect("destroy target creature with power X or less"));
this.getSpellAbility().setTargetAdjuster(KillingGlareAdjuster.instance);
}
public KillingGlare(final KillingGlare card) {
@ -35,19 +33,20 @@ public final class KillingGlare extends CardImpl {
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
FilterCreaturePermanent filter = new FilterCreaturePermanent(new StringBuilder("creature with power ").append(xValue).append(" or less").toString());
filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.addTarget(new TargetCreaturePermanent(filter));
}
}
@Override
public KillingGlare copy() {
public KillingGlare copy() {
return new KillingGlare(this);
}
}
enum KillingGlareAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power " + xValue + " or less");
filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.addTarget(new TargetCreaturePermanent(filter));
}
}

View file

@ -1,29 +1,32 @@
package mage.cards.k;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksAndIsNotBlockedTriggeredAbility;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageSourceEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.filter.predicate.permanent.DefendingPlayerControlsPredicate;
import mage.target.common.TargetArtifactPermanent;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class KukemssaPirates extends CardImpl {
private final UUID originalId;
private static final FilterArtifactPermanent filter = new FilterArtifactPermanent("artifact defending player controls");
static {
filter.add(new DefendingPlayerControlsPredicate());
}
public KukemssaPirates(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}");
@ -36,26 +39,12 @@ public final class KukemssaPirates extends CardImpl {
// Whenever Kukemssa Pirates attacks and isn't blocked, you may gain control of target artifact defending player controls. If you do, Kukemssa Pirates assigns no combat damage this turn.
Ability ability = new AttacksAndIsNotBlockedTriggeredAbility(new GainControlTargetEffect(Duration.Custom), true);
ability.addEffect(new AssignNoCombatDamageSourceEffect(Duration.EndOfTurn, true));
ability.addTarget(new TargetArtifactPermanent(new FilterArtifactPermanent("artifact defending player controls")));
originalId = ability.getOriginalId();
ability.addTarget(new TargetArtifactPermanent(filter));
this.addAbility(ability);
}
public KukemssaPirates(final KukemssaPirates card) {
super(card);
this.originalId = card.originalId;
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
ability.getTargets().clear();
FilterArtifactPermanent filter = new FilterArtifactPermanent("artifact defending player controls");
UUID defenderId = game.getCombat().getDefenderId(ability.getSourceId());
filter.add(new ControllerIdPredicate(defenderId));
TargetArtifactPermanent target = new TargetArtifactPermanent(filter);
ability.addTarget(target);
}
}
@Override

View file

@ -1,9 +1,6 @@
package mage.cards.l;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -12,50 +9,38 @@ 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.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;
/**
*
* @author LevelX2 & L_J
*/
public final class LivingInferno extends CardImpl {
private final UUID originalId;
public LivingInferno(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{6}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{6}{R}{R}");
this.subtype.add(SubType.ELEMENTAL);
this.power = new MageInt(8);
this.toughness = new MageInt(5);
// {T}: Living Inferno deals damage equal to its power divided as you choose among any number of target creatures. Each of those creatures deals damage equal to its power to Living Inferno.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LivingInfernoEffect(), new TapSourceCost());
ability.addTarget(new TargetCreaturePermanentAmount(1));
ability.setTargetAdjuster(LivingInfernoAdjuster.instance);
this.addAbility(ability);
originalId = ability.getOriginalId();
}
@Override
public void adjustTargets(Ability ability, Game game) {
if(ability.getOriginalId().equals(originalId)) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(ability.getSourceId());
if (sourcePermanent != null) {
int xValue = sourcePermanent.getPower().getValue();
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanentAmount(xValue));
}
}
}
public LivingInferno(final LivingInferno card) {
super(card);
this.originalId = card.originalId;
}
@Override
@ -64,11 +49,26 @@ public final class LivingInferno extends CardImpl {
}
}
enum LivingInfernoAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(ability.getSourceId());
if (sourcePermanent != null) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanentAmount(sourcePermanent.getPower().getValue()));
}
}
}
class LivingInfernoEffect extends OneShotEffect {
public LivingInfernoEffect() {
super(Outcome.Benefit);
this.staticText = "{this} deals damage equal to its power divided as you choose among any number of target creatures. Each of those creatures deals damage equal to its power to {this}";
this.staticText = "{this} deals damage equal to its power " +
"divided as you choose among any number of target creatures. " +
"Each of those creatures deals damage equal to its power to {this}";
}
public LivingInfernoEffect(final LivingInfernoEffect effect) {

View file

@ -1,7 +1,6 @@
package mage.cards.l;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -10,8 +9,8 @@ import mage.abilities.keyword.VigilanceAbility;
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.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
@ -19,15 +18,17 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class LuminatePrimordial extends CardImpl {
public LuminatePrimordial(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}{W}");
this.subtype.add(SubType.AVATAR);
this.power = new MageInt(4);
@ -38,23 +39,9 @@ public final class LuminatePrimordial extends CardImpl {
// When Luminate Primordial enters the battlefield, for each opponent, exile up to one target creature
// that player controls and that player gains life equal to its power.
this.addAbility(new EntersBattlefieldTriggeredAbility(new LuminatePrimordialEffect(),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) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature from opponent " + opponent.getLogName());
filter.add(new ControllerIdPredicate(opponentId));
TargetCreaturePermanent target = new TargetCreaturePermanent(0,1, filter,false);
ability.addTarget(target);
}
}
}
Ability ability = new EntersBattlefieldTriggeredAbility(new LuminatePrimordialEffect(), false);
ability.setTargetAdjuster(LuminatePrimordialAdjuster.instance);
this.addAbility(ability);
}
public LuminatePrimordial(final LuminatePrimordial card) {
@ -67,6 +54,24 @@ public final class LuminatePrimordial extends CardImpl {
}
}
enum LuminatePrimordialAdjuster 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) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature from opponent " + opponent.getLogName());
filter.add(new ControllerIdPredicate(opponentId));
TargetCreaturePermanent target = new TargetCreaturePermanent(0, 1, filter, false);
ability.addTarget(target);
}
}
}
}
class LuminatePrimordialEffect extends OneShotEffect {
public LuminatePrimordialEffect() {
@ -85,7 +90,7 @@ class LuminatePrimordialEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
for (Target target: source.getTargets()) {
for (Target target : source.getTargets()) {
if (target instanceof TargetCreaturePermanent) {
Permanent targetCreature = game.getPermanent(target.getFirstTarget());
if (targetCreature != null && !targetCreature.isControlledBy(source.getControllerId())) {

View file

@ -1,7 +1,6 @@
package mage.cards.m;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.costs.common.SacrificeTargetCost;
@ -13,18 +12,17 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetAnyTarget;
import mage.target.common.TargetControlledPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LoneFox
*
*/
public final class MagmaBurst extends CardImpl {
private final UUID originalId;
public MagmaBurst(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{R}");
@ -32,21 +30,13 @@ public final class MagmaBurst extends CardImpl {
this.addAbility(new KickerAbility(new SacrificeTargetCost(new TargetControlledPermanent(2, 2, new FilterControlledLandPermanent("two lands"), true))));
// Magma Burst deals 3 damage to any target. If Magma Burst was kicked, it deals 3 damage to another any target.
Effect effect = new DamageTargetEffect(3);
effect.setText("{this} deals 3 damage to any target. if this spell was kicked, it deals 3 damage to another target.");
effect.setText("{this} deals 3 damage to any target. If this spell was kicked, it deals 3 damage to another target.");
this.getSpellAbility().addEffect(effect);
originalId = this.getSpellAbility().getOriginalId();
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
ability.addTarget(new TargetAnyTarget(KickedCondition.instance.apply(game, ability) ? 2 : 1));
}
this.getSpellAbility().setTargetAdjuster(MagmaBurstAdjuster.instance);
}
public MagmaBurst(final MagmaBurst card) {
super(card);
this.originalId = card.originalId;
}
@Override
@ -54,3 +44,12 @@ public final class MagmaBurst extends CardImpl {
return new MagmaBurst(this);
}
}
enum MagmaBurstAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.addTarget(new TargetAnyTarget(KickedCondition.instance.apply(game, ability) ? 2 : 1));
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.m;
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;
@ -16,38 +14,24 @@ import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class MaliciousAdvice extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("artifacts, creatures, and/or lands");
static {
filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE),
new CardTypePredicate(CardType.LAND)));
}
public MaliciousAdvice(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}{B}");
// Tap X target artifacts, creatures, and/or lands. You lose X life.
Effect effect = new TapTargetEffect();
effect.setText("X target artifacts, creatures, and/or lands");
effect.setText("X target artifacts, creatures, and/or lands.");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(new ManacostVariableValue()));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
ability.addTarget(new TargetPermanent(ability.getManaCostsToPay().getX(), filter));
}
this.getSpellAbility().setTargetAdjuster(MaliciousAdviceAdjuster.instance);
}
public MaliciousAdvice(final MaliciousAdvice card) {
@ -59,3 +43,22 @@ public final class MaliciousAdvice extends CardImpl {
return new MaliciousAdvice(this);
}
}
enum MaliciousAdviceAdjuster implements TargetAdjuster {
instance;
private static final FilterPermanent filter = new FilterPermanent("artifacts, creatures, and/or lands");
static {
filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE),
new CardTypePredicate(CardType.LAND)
));
}
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new TargetPermanent(ability.getManaCostsToPay().getX(), filter));
}
}

View file

@ -1,80 +1,55 @@
package mage.cards.m;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.MultikickerCount;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.keyword.MultikickerAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*
*/
public final class MarshalsAnthem extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures you control");
private static final FilterCard filterCard = new FilterCard("creature card in your graveyard");
static {
filter.add(new ControllerPredicate(TargetController.YOU));
filterCard.add(new CardTypePredicate(CardType.CREATURE));
}
private final UUID originalId;
private static final String rule = "return up to X target creature cards from your graveyard to the battlefield, " +
"where X is the number of times {this} was kicked";
public MarshalsAnthem(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}");
// Multikicker {1}{W}
this.addAbility(new MultikickerAbility("{1}{W}"));
// Creatures you control get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false)));
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield)
));
// When Marshal's Anthem enters the battlefield, return up to X target creature cards from your graveyard to the battlefield, where X is the number of times Marshal's Anthem was kicked.
//TODO this should always trigger, even if it wasn't kicked
Ability ability = new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new ReturnFromGraveyardToBattlefieldTargetEffect(), false),
KickedCondition.instance,
"When {this} enters the battlefield, return up to X target creature cards from your graveyard to the battlefield, where X is the number of times {this} was kicked.");
originalId = ability.getOriginalId();
Ability ability = new EntersBattlefieldTriggeredAbility(
new ReturnFromGraveyardToBattlefieldTargetEffect().setText(rule), false
);
ability.setTargetAdjuster(MarshalsAnthemAdjuster.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 TargetCardInYourGraveyard(0, numbTargets, filterCard));
}
}
}
public MarshalsAnthem(final MarshalsAnthem card) {
super(card);
this.originalId = card.originalId;
}
@Override
@ -82,3 +57,17 @@ public final class MarshalsAnthem extends CardImpl {
return new MarshalsAnthem(this);
}
}
enum MarshalsAnthemAdjuster implements TargetAdjuster {
instance;
private static final FilterCard filter = new FilterCreatureCard("creature card in your graveyard");
@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 TargetCardInYourGraveyard(0, numbTargets, filter));
}
}
}

View file

@ -1,7 +1,6 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -25,17 +24,17 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInASingleGraveyard;
import mage.target.common.TargetCardInHand;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class MartyrOfBones extends CardImpl {
private final UUID originalId;
public MartyrOfBones(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{B}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD);
@ -49,27 +48,12 @@ public final class MartyrOfBones extends CardImpl {
ability.addCost(new RevealVariableBlackCardsFromHandCost());
ability.addCost(new SacrificeSourceCost());
ability.addTarget(new TargetCardInASingleGraveyard(0, 1, new FilterCard("cards in a single graveyard")));
originalId = ability.getOriginalId();
ability.setTargetAdjuster(MartyrOfBonesAdjuster.instance);
this.addAbility(ability);
}
public MartyrOfBones(final MartyrOfBones card) {
super(card);
this.originalId = card.originalId;
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
int amount = 0;
for (Cost cost : ability.getCosts()) {
if (cost instanceof RevealVariableBlackCardsFromHandCost) {
amount = ((VariableCost) cost).getAmount();
}
}
ability.getTargets().clear();
ability.addTarget(new TargetCardInASingleGraveyard(0, amount, new FilterCard()));
}
}
@Override
@ -78,6 +62,22 @@ public final class MartyrOfBones extends CardImpl {
}
}
enum MartyrOfBonesAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int amount = 0;
for (Cost cost : ability.getCosts()) {
if (cost instanceof RevealVariableBlackCardsFromHandCost) {
amount = ((VariableCost) cost).getAmount();
}
}
ability.getTargets().clear();
ability.addTarget(new TargetCardInASingleGraveyard(0, amount, new FilterCard()));
}
}
class RevealVariableBlackCardsFromHandCost extends VariableCostImpl {
private static final FilterCard filter = new FilterCard("X black cards from your hand");

View file

@ -1,9 +1,7 @@
package mage.cards.m;
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;
@ -17,9 +15,11 @@ import mage.game.Game;
import mage.game.permanent.token.ZombieToken;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author Skyler Sell
*/
public final class MidnightRitual extends CardImpl {
@ -31,14 +31,7 @@ public final class MidnightRitual extends CardImpl {
// For each creature card exiled this way, create a 2/2 black Zombie creature token.
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD));
this.getSpellAbility().addEffect(new MidnightRitualEffect());
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(ability.getManaCostsToPay().getX(), StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD));
}
this.getSpellAbility().setTargetAdjuster(MidnightRitualAdjuster.instance);
}
public MidnightRitual(final MidnightRitual card) {
@ -51,6 +44,16 @@ public final class MidnightRitual extends CardImpl {
}
}
enum MidnightRitualAdjuster 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));
}
}
class MidnightRitualEffect extends OneShotEffect {
public MidnightRitualEffect() {

View file

@ -2,7 +2,6 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -11,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.game.Game;
import mage.game.permanent.Permanent;
@ -20,59 +19,36 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetOpponentsCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author L_J
*/
public final class MoggAssassin extends CardImpl {
private final UUID originalId;
public MoggAssassin(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.subtype.add(SubType.GOBLIN);
this.subtype.add(SubType.ASSASSIN);
this.power = new MageInt(2);
this.toughness = new MageInt(1);
//TODO: Make ability properly copiable
// {T}: You choose target creature an opponent controls, and that opponent chooses target creature. Flip a coin. If you win the flip, destroy the creature you chose. If you lose the flip, destroy the creature your opponent chose.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MoggAssassinEffect(), new TapSourceCost());
Ability ability = new SimpleActivatedAbility(
Zone.BATTLEFIELD,
new MoggAssassinEffect(),
new TapSourceCost()
);
ability.addTarget(new TargetOpponentsCreaturePermanent());
ability.addTarget(new TargetCreaturePermanent());
ability.setTargetAdjuster(MoggAssassinAdjuster.instance);
this.addAbility(ability);
originalId = ability.getOriginalId();
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) {
UUID opponentId = null;
if (game.getOpponents(controller.getId()).size() > 1) {
Target target = ability.getTargets().get(0);
if (controller.chooseTarget(Outcome.DestroyPermanent, target, ability, game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
opponentId = permanent.getControllerId();
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
if (opponentId != null) {
ability.getTargets().get(1).setTargetController(opponentId);
}
}
}
}
public MoggAssassin(final MoggAssassin card) {
super(card);
this.originalId = card.originalId;
}
@Override
@ -82,6 +58,34 @@ public final class MoggAssassin extends CardImpl {
}
enum MoggAssassinAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller == null) {
return;
}
UUID opponentId = null;
if (game.getOpponents(controller.getId()).size() > 1) {
Target target = ability.getTargets().get(0);
if (controller.chooseTarget(Outcome.DestroyPermanent, target, ability, game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
opponentId = permanent.getControllerId();
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
if (opponentId != null) {
ability.getTargets().get(1).setTargetController(opponentId);
}
}
}
class MoggAssassinEffect extends OneShotEffect {
public MoggAssassinEffect() {
@ -100,21 +104,21 @@ class MoggAssassinEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent chosenPermanent = game.getPermanent(source.getTargets().get(0).getFirstTarget());
Permanent opponentsPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (controller.flipCoin(game)) {
if (chosenPermanent != null) {
chosenPermanent.destroy(source.getSourceId(), game, false);
return true;
}
} else {
if (opponentsPermanent != null) {
opponentsPermanent.destroy(source.getSourceId(), game, false);
return true;
}
if (controller == null) {
return false;
}
Permanent chosenPermanent = game.getPermanent(source.getTargets().get(0).getFirstTarget());
Permanent opponentsPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (controller.flipCoin(game)) {
if (chosenPermanent != null) {
chosenPermanent.destroy(source.getSourceId(), game, false);
return true;
}
} else {
if (opponentsPermanent != null) {
opponentsPermanent.destroy(source.getSourceId(), game, false);
return true;
}
}
return false;

View file

@ -1,7 +1,6 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -12,20 +11,22 @@ import mage.abilities.keyword.IntimidateAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.ColoredManaSymbol;
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 LevelX2
*/
public final class MogissMarauder extends CardImpl {
public MogissMarauder(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.BERSERKER);
@ -35,24 +36,13 @@ public final class MogissMarauder extends CardImpl {
// When Mogis's Marauder enters the battlefield, up to X target creatures each gain intimidate and haste, where X is your devotion to black.
Ability ability = new EntersBattlefieldTriggeredAbility(
new GainAbilityTargetEffect(IntimidateAbility.getInstance(), Duration.EndOfTurn,
"up to X target creatures each gain intimidate"), false);
"up to X target creatures each gain intimidate"), false);
ability.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn,
"and haste until end of turn, where X is your devotion to black"));
ability.addTarget(new TargetCreaturePermanent());
ability.setTargetAdjuster(MogissMarauderAdjuster.instance);
this.addAbility(ability);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof EntersBattlefieldTriggeredAbility) {
ability.getTargets().clear();
int numbTargets = new DevotionCount(ColoredManaSymbol.B).calculate(game, ability, null);
if (numbTargets > 0) {
ability.addTarget(new TargetCreaturePermanent(0,numbTargets));
}
}
}
public MogissMarauder(final MogissMarauder card) {
super(card);
}
@ -62,3 +52,16 @@ public final class MogissMarauder extends CardImpl {
return new MogissMarauder(this);
}
}
enum MogissMarauderAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int numbTargets = new DevotionCount(ColoredManaSymbol.B).calculate(game, ability, null);
if (numbTargets > 0) {
ability.addTarget(new TargetCreaturePermanent(0, numbTargets));
}
}
}

View file

@ -1,9 +1,7 @@
package mage.cards.m;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.GainLifeEffect;
@ -11,13 +9,16 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterArtifactOrEnchantmentPermanent;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class Molder extends CardImpl {
@ -26,20 +27,9 @@ public final class Molder extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{G}");
// Destroy target artifact or enchantment with converted mana cost X. It can't be regenerated. You gain X life.
this.getSpellAbility().addEffect(new DestroyTargetEffect(true));
this.getSpellAbility().addTarget(new TargetPermanent(new FilterArtifactOrEnchantmentPermanent("artifact or enchantment with converted mana cost X")));
this.getSpellAbility().addEffect(new DestroyTargetEffect("Destroy target artifact or enchantment with converted mana cost X.", true));
this.getSpellAbility().addEffect(new GainLifeEffect(new ManacostVariableValue()));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterArtifactOrEnchantmentPermanent filter = new FilterArtifactOrEnchantmentPermanent("artifact or enchantment with converted mana cost X");
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.addTarget(new TargetPermanent(filter));
}
this.getSpellAbility().setTargetAdjuster(MolderAdjuster.instance);
}
public Molder(final Molder card) {
@ -51,3 +41,16 @@ public final class Molder extends CardImpl {
return new Molder(this);
}
}
enum MolderAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterPermanent filter = new FilterArtifactOrEnchantmentPermanent("artifact or enchantment with converted mana cost " + xValue);
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.addTarget(new TargetPermanent(filter));
}
}

View file

@ -1,7 +1,6 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -13,9 +12,9 @@ import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
@ -23,16 +22,18 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class MoltenPrimordial extends CardImpl {
public MoltenPrimordial(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}{R}");
this.subtype.add(SubType.AVATAR);
this.power = new MageInt(6);
@ -42,23 +43,9 @@ public final class MoltenPrimordial extends CardImpl {
this.addAbility(HasteAbility.getInstance());
// When Molten Primordial enters the battlefield, for each opponent, take control of up to one target creature that player controls until end of turn. Untap those creatures. They have haste until end of turn.
this.addAbility(new EntersBattlefieldTriggeredAbility(new MoltenPrimordialEffect(),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) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature from opponent " + opponent.getLogName());
filter.add(new ControllerIdPredicate(opponentId));
TargetCreaturePermanent target = new TargetCreaturePermanent(0,1, filter,false);
ability.addTarget(target);
}
}
}
Ability ability = new EntersBattlefieldTriggeredAbility(new MoltenPrimordialEffect(), false);
ability.setTargetAdjuster(MoltenPrimordialAdjuster.instance);
this.addAbility(ability);
}
public MoltenPrimordial(final MoltenPrimordial card) {
@ -71,6 +58,24 @@ public final class MoltenPrimordial extends CardImpl {
}
}
enum MoltenPrimordialAdjuster 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) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature from opponent " + opponent.getLogName());
filter.add(new ControllerIdPredicate(opponentId));
TargetCreaturePermanent target = new TargetCreaturePermanent(0, 1, filter, false);
ability.addTarget(target);
}
}
}
}
class MoltenPrimordialEffect extends OneShotEffect {
public MoltenPrimordialEffect() {
@ -90,7 +95,7 @@ class MoltenPrimordialEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
for (Target target: source.getTargets()) {
for (Target target : source.getTargets()) {
if (target instanceof TargetCreaturePermanent) {
Permanent targetCreature = game.getPermanent(target.getFirstTarget());
if (targetCreature != null) {

View file

@ -1,7 +1,6 @@
package mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
@ -13,8 +12,9 @@ import mage.target.targetpointer.FirstTargetPointer;
import mage.target.targetpointer.SecondTargetPointer;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DestroyTargetEffect extends OneShotEffect {
@ -27,14 +27,18 @@ public class DestroyTargetEffect extends OneShotEffect {
}
public DestroyTargetEffect(String ruleText) {
this(false);
staticText = ruleText;
this(ruleText, false);
}
public DestroyTargetEffect(boolean noRegen) {
this(noRegen, false);
}
public DestroyTargetEffect(String ruleText, boolean noRegen) {
this(noRegen, false);
staticText = ruleText;
}
public DestroyTargetEffect(boolean noRegen, boolean multitargetHandling) {
super(Outcome.DestroyPermanent);
this.noRegen = noRegen;