From c5c5fa933a288a24c0a94aa5ed7588aa4483ef51 Mon Sep 17 00:00:00 2001 From: Merlingilb Date: Sat, 4 Mar 2023 14:01:26 +0100 Subject: [PATCH] [SWS] fixed miss ability from Zam Wesell (#9799) Co-authored-by: Daniel Eberhard --- Mage.Sets/src/mage/cards/z/ZamWesell.java | 49 +++++++++++++---------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/Mage.Sets/src/mage/cards/z/ZamWesell.java b/Mage.Sets/src/mage/cards/z/ZamWesell.java index 1457b56d6a..64aa8d3a20 100644 --- a/Mage.Sets/src/mage/cards/z/ZamWesell.java +++ b/Mage.Sets/src/mage/cards/z/ZamWesell.java @@ -3,10 +3,12 @@ package mage.cards.z; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.condition.FixedCondition; +import mage.abilities.condition.common.AttachedCondition; +import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.CastSourceTriggeredAbility; -import mage.abilities.effects.common.CopyEffect; -import mage.abilities.effects.common.RevealHandTargetEffect; +import mage.abilities.effects.common.*; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -15,11 +17,13 @@ import mage.filter.StaticFilters; import mage.game.Game; import mage.players.Player; import mage.target.TargetCard; -import mage.target.common.TargetOpponent; +import mage.target.TargetPlayer; +import mage.target.common.*; +import mage.target.targetpointer.FixedTarget; /** * - * @author Styxo + * @author Styxo, Merlingilb */ public final class ZamWesell extends CardImpl { @@ -31,10 +35,7 @@ public final class ZamWesell extends CardImpl { this.toughness = new MageInt(2); // When you cast Zam Wesell, target opponent reveals their hand. You may choose a creature card from it and have Zam Wesell enter the battlefield as a copy of that creature card. - // TODO: Zam Wesell must be reworked to use on cast + etb abilities - Ability ability = new CastSourceTriggeredAbility(new RevealHandTargetEffect()); - ability.addEffect(new ZamWesselEffect()); - ability.addTarget(new TargetOpponent()); + Ability ability = new EntersBattlefieldAbility(new ZamWesselEffect(), new FixedCondition(true), "When you cast {this}, target opponent reveals his or her hand. You may choose a creature card from it and have {this} enter the battlefield as a copy of that creature card.", ""); this.addAbility(ability); } @@ -52,7 +53,7 @@ class ZamWesselEffect extends OneShotEffect { public ZamWesselEffect() { super(Outcome.Benefit); - this.staticText = "You may choose a creature card from it and have {this} enter the battlefield as a copy of that creature card"; + this.staticText = ""; } public ZamWesselEffect(final ZamWesselEffect effect) { @@ -66,20 +67,24 @@ class ZamWesselEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); - if (targetPlayer != null) { - TargetCard targetCard = new TargetCard(0, 1, Zone.HAND, StaticFilters.FILTER_CARD_CREATURE); - controller.choose(outcome, targetPlayer.getHand(), targetCard, game); - Card copyFromCard = game.getCard(targetCard.getFirstTarget()); - if (copyFromCard != null) { - game.informPlayers(controller.getLogName() + " chooses to copy " + copyFromCard.getName()); - CopyEffect copyEffect = new CopyEffect(Duration.Custom, copyFromCard, source.getSourceId()); - game.addEffect(copyEffect, source); + Player you = game.getPlayer(source.getControllerId()); + TargetPlayer targetOpponent = new TargetOpponent(); + if (you.chooseTarget(Outcome.Benefit, targetOpponent, source, game)) { + Player targetPlayer = game.getPlayer(targetOpponent.getFirstTarget()); + if (targetPlayer != null && you != null) { + if (!targetPlayer.getHand().isEmpty()) { + TargetCard target = new TargetCard(0, 1, Zone.HAND, StaticFilters.FILTER_CARD_CREATURE); + if (you.chooseTarget(Outcome.Benefit, targetPlayer.getHand(), target, source, game)) { + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + ContinuousEffect copyEffect = new CopyEffect(Duration.EndOfGame, card.getMainCard(), source.getSourceId()); + copyEffect.setTargetPointer(new FixedTarget(source.getSourceId(), game)); + game.addEffect(copyEffect, source); + return true; + } + } } } - return true; } return false; }