From 5bfbeff87d0515abaf5317d2095dc412f3605017 Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Fri, 9 Sep 2022 15:41:37 -0400 Subject: [PATCH] Fix Render Silent and remove some unnecessary custom effects I noticed via the previous commit --- Mage.Sets/src/mage/cards/a/AetherBurst.java | 4 +- .../src/mage/cards/c/CloakingDevice.java | 58 +++---------------- Mage.Sets/src/mage/cards/r/RenderSilent.java | 38 ++++++++++-- .../src/mage/cards/y/YoseiTheMorningStar.java | 51 ++-------------- .../effects/common/TapTargetEffect.java | 18 +----- 5 files changed, 49 insertions(+), 120 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AetherBurst.java b/Mage.Sets/src/mage/cards/a/AetherBurst.java index 6557751c6c..eb7b2481da 100644 --- a/Mage.Sets/src/mage/cards/a/AetherBurst.java +++ b/Mage.Sets/src/mage/cards/a/AetherBurst.java @@ -26,8 +26,8 @@ public final class AetherBurst extends CardImpl { public AetherBurst(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}"); - // Return up to X target creatures to their owners' hands, where X is one plus the number of cards named Aether Burst in all graveyards as you cast Aether Burst. - this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setText("Return up to X target creatures to their owners' hands, where X is one plus the number of cards named Aether Burst in all graveyards as you cast Aether Burst")); + // Return up to X target creatures to their owners' hands, where X is one plus the number of cards named Aether Burst in all graveyards as you cast this spell. + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setText("Return up to X target creatures to their owners' hands, where X is one plus the number of cards named Aether Burst in all graveyards as you cast this spell")); this.getSpellAbility().addTarget(new DynamicTargetCreaturePermanent()); this.getSpellAbility().setTargetAdjuster(AetherBurstAdjuster.instance); } diff --git a/Mage.Sets/src/mage/cards/c/CloakingDevice.java b/Mage.Sets/src/mage/cards/c/CloakingDevice.java index a195126ad5..5b1f101ef1 100644 --- a/Mage.Sets/src/mage/cards/c/CloakingDevice.java +++ b/Mage.Sets/src/mage/cards/c/CloakingDevice.java @@ -2,25 +2,15 @@ package mage.cards.c; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.common.AttacksAttachedTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.dynamicvalue.DynamicValue; -import mage.abilities.dynamicvalue.common.StaticValue; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.LoseLifeTargetEffect; import mage.abilities.effects.common.combat.CantBeBlockedAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.AttachmentType; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Outcome; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; +import mage.constants.*; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; @@ -42,11 +32,15 @@ public final class CloakingDevice extends CardImpl { this.addAbility(ability); // Enchanted creature can't be blocked. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedAttachedEffect(AttachmentType.AURA))); + this.addAbility(new SimpleStaticAbility(new CantBeBlockedAttachedEffect(AttachmentType.AURA))); // Whenever enchanted creature attacks, defending player loses 1 life. - this.addAbility(new AttacksAttachedTriggeredAbility(new CloakingDeviceLoseLifeDefendingPlayerEffect(), AttachmentType.AURA, false)); - + this.addAbility(new AttacksAttachedTriggeredAbility( + new LoseLifeTargetEffect(1).setText("defending player loses 1 life"), + AttachmentType.AURA, + false, + SetTargetPointer.PLAYER + )); } private CloakingDevice(final CloakingDevice card) { @@ -58,37 +52,3 @@ public final class CloakingDevice extends CardImpl { return new CloakingDevice(this); } } - -class CloakingDeviceLoseLifeDefendingPlayerEffect extends OneShotEffect { - - public CloakingDeviceLoseLifeDefendingPlayerEffect() { - super(Outcome.Damage); - this.staticText = "defending player loses 1 life"; - } - - public CloakingDeviceLoseLifeDefendingPlayerEffect(final CloakingDeviceLoseLifeDefendingPlayerEffect effect) { - super(effect); - } - - @Override - public CloakingDeviceLoseLifeDefendingPlayerEffect copy() { - return new CloakingDeviceLoseLifeDefendingPlayerEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } - if (enchantment != null && enchantment.getAttachedTo() != null) { - Player defender = game.getPlayer(game.getCombat().getDefendingPlayerId(enchantment.getAttachedTo(), game)); - if (defender != null) { - defender.loseLife(1, game, source, false); - } - } - return true; - } -} diff --git a/Mage.Sets/src/mage/cards/r/RenderSilent.java b/Mage.Sets/src/mage/cards/r/RenderSilent.java index 40cbaadc9a..29834ca6c4 100644 --- a/Mage.Sets/src/mage/cards/r/RenderSilent.java +++ b/Mage.Sets/src/mage/cards/r/RenderSilent.java @@ -1,4 +1,3 @@ - package mage.cards.r; import java.util.UUID; @@ -7,14 +6,11 @@ import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.CounterTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; -import mage.filter.common.FilterControlledPermanent; -import mage.filter.predicate.mageobject.MulticoloredPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.stack.Spell; @@ -32,7 +28,7 @@ public final class RenderSilent extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{W}{U}{U}"); // Counter target spell. Its controller can't cast spells this turn. - this.getSpellAbility().addEffect(new CounterTargetEffect()); + this.getSpellAbility().addEffect(new RenderSilentCounterEffect()); this.getSpellAbility().addTarget(new TargetSpell()); this.getSpellAbility().addEffect(new RenderSilentEffect()); } @@ -47,6 +43,38 @@ public final class RenderSilent extends CardImpl { } } +class RenderSilentCounterEffect extends OneShotEffect { + + public RenderSilentCounterEffect() { + super(Outcome.Detriment); + } + + public RenderSilentCounterEffect(final RenderSilentCounterEffect effect) { + super(effect); + } + + @Override + public RenderSilentCounterEffect copy() { + return new RenderSilentCounterEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Spell spell = game.getStack().getSpell(source.getFirstTarget()); + if (spell != null) { + source.getEffects().get(1).setTargetPointer(new FixedTarget(spell.getControllerId())); + return game.getStack().counter(source.getFirstTarget(), source, game); + } + return false; + } + + @Override + public String getText(Mode mode) { + return "Counter target " + mode.getTargets().get(0).getTargetName(); + } + +} + class RenderSilentEffect extends ContinuousRuleModifyingEffectImpl { public RenderSilentEffect() { diff --git a/Mage.Sets/src/mage/cards/y/YoseiTheMorningStar.java b/Mage.Sets/src/mage/cards/y/YoseiTheMorningStar.java index 066153a1fb..4990398183 100644 --- a/Mage.Sets/src/mage/cards/y/YoseiTheMorningStar.java +++ b/Mage.Sets/src/mage/cards/y/YoseiTheMorningStar.java @@ -1,29 +1,24 @@ - package mage.cards.y; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.common.DiesSourceTriggeredAbility; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.SkipNextPlayerUntapStepEffect; +import mage.abilities.effects.common.TapTargetEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Outcome; import mage.constants.SuperType; import mage.filter.FilterPermanent; import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; -import mage.game.permanent.Permanent; import mage.players.Player; -import mage.target.Target; import mage.target.TargetPermanent; import mage.target.TargetPlayer; -import mage.target.Targets; +import mage.target.targetpointer.SecondTargetPointer; /** * @@ -47,7 +42,7 @@ public final class YoseiTheMorningStar extends CardImpl { Ability ability = new DiesSourceTriggeredAbility(new SkipNextPlayerUntapStepEffect("target")); ability.addTarget(new TargetPlayer()); ability.addTarget(new YoseiTheMorningStarTarget()); - ability.addEffect(new YoseiTheMorningStarTapEffect()); + ability.addEffect(new TapTargetEffect().setTargetPointer(new SecondTargetPointer())); this.addAbility(ability); } @@ -63,7 +58,7 @@ public final class YoseiTheMorningStar extends CardImpl { class YoseiTheMorningStarTarget extends TargetPermanent { - private static final FilterPermanent filterTemplate = new FilterPermanent("up to five target permanents that player controls that will be tapped"); + private static final FilterPermanent filterTemplate = new FilterPermanent("permanents that player controls"); public YoseiTheMorningStarTarget() { super(0, 5, filterTemplate, false); @@ -88,42 +83,4 @@ class YoseiTheMorningStarTarget extends TargetPermanent { public YoseiTheMorningStarTarget copy() { return new YoseiTheMorningStarTarget(this); } - -} - -class YoseiTheMorningStarTapEffect extends OneShotEffect { - - public YoseiTheMorningStarTapEffect() { - super(Outcome.Tap); - staticText = "Tap up to five target permanents that player controls"; - } - - public YoseiTheMorningStarTapEffect(final YoseiTheMorningStarTapEffect effect) { - super(effect); - } - - @Override - public YoseiTheMorningStarTapEffect copy() { - return new YoseiTheMorningStarTapEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Targets targets = source.getTargets(); - Target target1 = targets.get(1); - for (UUID target : target1.getTargets()) { - Permanent permanent = game.getPermanent(target); - if (permanent != null) { - permanent.tap(source, game); - } else { - return false; - } - } - return true; - } - - @Override - public String getText(Mode mode) { - return staticText; - } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/TapTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/TapTargetEffect.java index 5173c65fcf..8850116827 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/TapTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/TapTargetEffect.java @@ -52,22 +52,6 @@ public class TapTargetEffect extends OneShotEffect { if (staticText != null && !staticText.isEmpty()) { return staticText; } - - if (mode.getTargets().isEmpty()) { - return "tap target permanent"; - } - - Target target = mode.getTargets().get(0); - if (target.getMaxNumberOfTargets() > 1 || target.getNumberOfTargets() == 0) { - if (target.getMaxNumberOfTargets() == target.getNumberOfTargets()) { - return "tap " + CardUtil.numberToText(target.getNumberOfTargets()) + " target " + target.getTargetName() + 's'; - } else { - return "tap up to " + CardUtil.numberToText(target.getMaxNumberOfTargets()) + " target " + target.getTargetName() + (target.getMaxNumberOfTargets() > 1 ? "s" : ""); - } - } else if (target.getMaxNumberOfTargets() == 0) { - return "tap X target " + mode.getTargets().get(0).getTargetName(); - } else { - return "tap target " + mode.getTargets().get(0).getTargetName(); - } + return "tap " + getTargetPointer().describeTargets(mode.getTargets(), "that creature"); } }