From 970427e23f04b857de34cadb490e219a5db04b98 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 4 May 2021 07:35:53 -0400 Subject: [PATCH] [ULG] reworked Goblin Welder and added currently failing test (#7672) --- Mage.Sets/src/mage/cards/g/GoblinWelder.java | 69 +++++++++---------- .../cards/single/ulg/GoblinWelderTest.java | 41 +++++++++++ 2 files changed, 74 insertions(+), 36 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/ulg/GoblinWelderTest.java diff --git a/Mage.Sets/src/mage/cards/g/GoblinWelder.java b/Mage.Sets/src/mage/cards/g/GoblinWelder.java index 87a93c366d..816297c771 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinWelder.java +++ b/Mage.Sets/src/mage/cards/g/GoblinWelder.java @@ -1,7 +1,5 @@ - package mage.cards.g; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -11,25 +9,25 @@ 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.common.FilterArtifactCard; -import mage.filter.common.FilterArtifactPermanent; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetArtifactPermanent; import mage.target.common.TargetCardInGraveyard; +import mage.target.targetpointer.EachTargetPointer; + +import java.util.UUID; /** - * * @author Plopman */ public final class GoblinWelder extends CardImpl { public GoblinWelder(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}"); this.subtype.add(SubType.GOBLIN); this.subtype.add(SubType.ARTIFICER); @@ -37,8 +35,8 @@ public final class GoblinWelder extends CardImpl { this.toughness = new MageInt(1); // {tap}: Choose target artifact a player controls and target artifact card in that player's graveyard. If both targets are still legal as this ability resolves, that player simultaneously sacrifices the artifact and returns the artifact card to the battlefield. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GoblinWelderEffect(), new TapSourceCost()); - ability.addTarget(new TargetArtifactPermanent(new FilterArtifactPermanent("artifact a player controls"))); + Ability ability = new SimpleActivatedAbility(new GoblinWelderEffect(), new TapSourceCost()); + ability.addTarget(new TargetArtifactPermanent()); ability.addTarget(new GoblinWelderTarget()); this.addAbility(ability); } @@ -52,11 +50,16 @@ public final class GoblinWelder extends CardImpl { return new GoblinWelder(this); } - public static class GoblinWelderEffect extends OneShotEffect { + private static class GoblinWelderEffect extends OneShotEffect { public GoblinWelderEffect() { super(Outcome.PutCardInPlay); - staticText = "Choose target artifact a player controls and target artifact card in that player's graveyard. If both targets are still legal as this ability resolves, that player simultaneously sacrifices the artifact and returns the artifact card to the battlefield"; + staticText = "Choose target artifact a player controls " + + "and target artifact card in that player's graveyard. " + + "If both targets are still legal as this ability resolves, " + + "that player simultaneously sacrifices the artifact " + + "and returns the artifact card to the battlefield"; + this.setTargetPointer(new EachTargetPointer()); } public GoblinWelderEffect(final GoblinWelderEffect effect) { @@ -66,22 +69,19 @@ public final class GoblinWelder extends CardImpl { @Override public boolean apply(Game game, Ability source) { Permanent artifact = game.getPermanent(getTargetPointer().getFirst(game, source)); - Card card = game.getCard(source.getTargets().get(1).getFirstTarget()); + Card card = game.getCard(getTargetPointer().getTargets(game, source).get(1)); Player controller = game.getPlayer(source.getControllerId()); - if (artifact != null && card != null && controller != null) { - Zone currentZone = game.getState().getZone(card.getId()); - Player owner = game.getPlayer(card.getOwnerId()); - if (owner != null - && artifact.isArtifact() - && card.isArtifact() - && currentZone == Zone.GRAVEYARD - && card.isOwnedBy(artifact.getControllerId())) { - boolean sacrifice = artifact.sacrifice(source, game); - boolean putOnBF = owner.moveCards(card, Zone.BATTLEFIELD, source, game); - if (sacrifice || putOnBF) { - return true; - } - } + if (artifact == null || card == null || controller == null) { + return false; + } + Player owner = game.getPlayer(card.getOwnerId()); + if (owner == null) { + return false; + } + boolean sacrifice = artifact.sacrifice(source, game); + boolean putOnBF = owner.moveCards(card, Zone.BATTLEFIELD, source, game); + if (sacrifice || putOnBF) { + return true; } return false; } @@ -93,10 +93,10 @@ public final class GoblinWelder extends CardImpl { } - static class GoblinWelderTarget extends TargetCardInGraveyard { + private static class GoblinWelderTarget extends TargetCardInGraveyard { public GoblinWelderTarget() { - super(1, 1, new FilterArtifactCard()); + super(); targetName = "target artifact card in that player's graveyard"; } @@ -106,16 +106,14 @@ public final class GoblinWelder extends CardImpl { @Override public boolean canTarget(UUID id, Ability source, Game game) { - Permanent artifact = game.getPermanent(source.getFirstTarget()); - if (artifact == null) { + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent == null) { return false; } - Player player = game.getPlayer(artifact.getControllerId()); Card card = game.getCard(id); - if (card != null && player != null && player.getGraveyard().contains(id)) { - return filter.match(card, game); - } - return false; + return card != null + && card.isArtifact() + && card.isOwnedBy(permanent.getControllerId()); } @Override @@ -123,5 +121,4 @@ public final class GoblinWelder extends CardImpl { return new GoblinWelderTarget(this); } } - } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/ulg/GoblinWelderTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/ulg/GoblinWelderTest.java new file mode 100644 index 0000000000..b7fad55f84 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/ulg/GoblinWelderTest.java @@ -0,0 +1,41 @@ +package org.mage.test.cards.single.ulg; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Ignore; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author TheElk801 + */ +public class GoblinWelderTest extends CardTestPlayerBase { + + private static final String welder = "Goblin Welder"; + private static final String wurmcoil = "Wurmcoil Engine"; + private static final String relic = "Darksteel Relic"; + private static final String aspirant = "Blood Aspirant"; + + @Ignore + @Test + public void testSacrificeDiesTrigger() { + addCard(Zone.BATTLEFIELD, playerA, welder); + addCard(Zone.BATTLEFIELD, playerA, wurmcoil); + addCard(Zone.BATTLEFIELD, playerA, aspirant); + addCard(Zone.GRAVEYARD, playerA, relic); + + addTarget(playerA, relic); + addTarget(playerA, wurmcoil); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}:"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, wurmcoil, 1); + assertPermanentCount(playerA, relic, 1); + assertCounterCount(aspirant, CounterType.P1P1, 1); + assertPermanentCount(playerA, "Wurm", 2); // TODO: currently fails here + } +}