some more target adjusters

This commit is contained in:
Evan Kranzler 2018-09-22 16:52:18 -04:00
parent af32dfefb4
commit 7b309a6f7d
5 changed files with 88 additions and 83 deletions

View file

@ -1,9 +1,7 @@
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.dynamicvalue.common.MultikickerCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.MultikickerAbility;
@ -15,6 +13,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
import mage.target.targetadjustment.TargetAdjuster;
/**
*
@ -31,27 +30,30 @@ public final class CometStorm extends CardImpl {
// Choose any target, then choose another any target for each time Comet Storm was kicked. Comet Storm deals X damage to each of them.
this.getSpellAbility().addEffect(new CometStormEffect());
this.getSpellAbility().addTarget(new TargetAnyTarget(1));
this.getSpellAbility().setTargetAdjuster(CometStormAdjuster.instance);
}
public CometStorm(final CometStorm card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int numbTargets = new MultikickerCount().calculate(game, ability, null) + 1;
ability.addTarget(new TargetAnyTarget(numbTargets));
}
}
@Override
public CometStorm copy() {
return new CometStorm(this);
}
}
enum CometStormAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int numbTargets = new MultikickerCount().calculate(game, ability, null) + 1;
ability.addTarget(new TargetAnyTarget(numbTargets));
}
}
class CometStormEffect extends OneShotEffect {
public CometStormEffect() {

View file

@ -2,7 +2,6 @@ package mage.cards.e;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.abilities.keyword.MiracleAbility;
@ -14,6 +13,7 @@ import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.target.Target;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
/**
*
@ -27,25 +27,10 @@ public final class EntreatTheDead extends CardImpl {
// Return X target creature cards from your graveyard to the battlefield.
this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(1, StaticFilters.FILTER_CARD_CREATURE));
this.getSpellAbility().setTargetAdjuster(EntreatTheDeadAdjuster.instance);
// Miracle {X}{B}{B}
this.addAbility(new MiracleAbility(this, new ManaCostsImpl("{X}{B}{B}")));
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
String filterName = xValue
+ (xValue != 1 ? " creature cards" : "creature card")
+ " from your graveyard";
Target target = new TargetCardInYourGraveyard(
xValue, new FilterCreatureCard(filterName)
);
ability.addTarget(target);
}
}
public EntreatTheDead(final EntreatTheDead card) {
@ -57,3 +42,20 @@ public final class EntreatTheDead extends CardImpl {
return new EntreatTheDead(this);
}
}
enum EntreatTheDeadAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
String filterName = xValue
+ (xValue != 1 ? " creature cards" : "creature card")
+ " from your graveyard";
Target target = new TargetCardInYourGraveyard(
xValue, new FilterCreatureCard(filterName)
);
ability.addTarget(target);
}
}

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.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
@ -21,6 +19,7 @@ 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;
/**
@ -34,22 +33,7 @@ public final class MassMutiny extends CardImpl {
// For each opponent, gain control of up to one target creature that player controls until end of turn. Untap those creatures. They gain haste until end of turn.
this.getSpellAbility().addEffect(new MassMutinyEffect());
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
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.getName());
filter.add(new ControllerIdPredicate(opponentId));
TargetCreaturePermanent target = new TargetCreaturePermanent(0, 1, filter, false);
ability.addTarget(target);
}
}
}
this.getSpellAbility().setTargetAdjuster(MassMutinyAdjuster.instance);
}
public MassMutiny(final MassMutiny card) {
@ -62,6 +46,24 @@ public final class MassMutiny extends CardImpl {
}
}
enum MassMutinyAdjuster 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.getName());
filter.add(new ControllerIdPredicate(opponentId));
TargetCreaturePermanent target = new TargetCreaturePermanent(0, 1, filter, false);
ability.addTarget(target);
}
}
}
}
class MassMutinyEffect extends OneShotEffect {
public MassMutinyEffect() {

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import java.util.UUID;
@ -19,6 +18,7 @@ import mage.game.Game;
import mage.target.Target;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
import mage.target.targetpointer.FirstTargetPointer;
/**
@ -27,10 +27,8 @@ import mage.target.targetpointer.FirstTargetPointer;
*/
public final class SigilOfSleep extends CardImpl {
private final UUID originalId;
public SigilOfSleep(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}");
this.subtype.add(SubType.AURA);
// Enchant creature
@ -39,34 +37,17 @@ public final class SigilOfSleep extends CardImpl {
this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// Whenever enchanted creature deals damage to a player, return target creature that player controls to its owner's hand.
Effect effect = new ReturnToHandTargetEffect();
effect.setText("return target creature that player controls to its owner's hand");
ability = new DealsDamageToAPlayerAttachedTriggeredAbility(effect, "enchanted", false, true, false);
originalId = ability.getOriginalId();
ability.setTargetAdjuster(SigilOfSleepAdjuster.instance);
this.addAbility(ability);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
UUID playerId = ability.getEffects().get(0).getTargetPointer().getFirst(game, ability);
if (playerId != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that player controls");
filter.add(new ControllerIdPredicate(playerId));
Target target = new TargetCreaturePermanent(filter);
ability.getTargets().clear();
ability.addTarget(target);
ability.getEffects().get(0).setTargetPointer(new FirstTargetPointer());
}
}
}
public SigilOfSleep(final SigilOfSleep card) {
super(card);
this.originalId = card.originalId;
}
@Override
@ -74,3 +55,20 @@ public final class SigilOfSleep extends CardImpl {
return new SigilOfSleep(this);
}
}
enum SigilOfSleepAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
UUID playerId = ability.getEffects().get(0).getTargetPointer().getFirst(game, ability);
if (playerId != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that player controls");
filter.add(new ControllerIdPredicate(playerId));
Target target = new TargetCreaturePermanent(filter);
ability.getTargets().clear();
ability.addTarget(target);
ability.getEffects().get(0).setTargetPointer(new FirstTargetPointer());
}
}
}

View file

@ -1,10 +1,8 @@
package mage.cards.v;
import java.util.List;
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;
@ -18,6 +16,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetLandPermanent;
import mage.target.targetadjustment.TargetAdjuster;
/**
*
@ -25,23 +24,12 @@ import mage.target.common.TargetLandPermanent;
*/
public final class VolcanicEruption extends CardImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent(SubType.MOUNTAIN, "Mountain");
public VolcanicEruption(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{U}{U}{U}");
// Destroy X target Mountains. Volcanic Eruption deals damage to each creature and each player equal to the number of Mountains put into a graveyard this way.
this.getSpellAbility().addTarget(new TargetLandPermanent(filter));
this.getSpellAbility().addEffect(new VolcanicEruptionEffect());
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
ability.addTarget(new TargetLandPermanent(xValue, xValue, filter, false));
}
this.getSpellAbility().setTargetAdjuster(VolcanicEruptionAdjuster.instance);
}
public VolcanicEruption(final VolcanicEruption card) {
@ -54,6 +42,19 @@ public final class VolcanicEruption extends CardImpl {
}
}
enum VolcanicEruptionAdjuster implements TargetAdjuster {
instance;
private static final FilterLandPermanent filter
= new FilterLandPermanent(SubType.MOUNTAIN, "Mountain");
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
ability.addTarget(new TargetLandPermanent(xValue, xValue, filter, false));
}
}
class VolcanicEruptionEffect extends OneShotEffect {
public VolcanicEruptionEffect() {