mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
[ULG] reworked Goblin Welder and added currently failing test (#7672)
This commit is contained in:
parent
3d015a50a0
commit
970427e23f
2 changed files with 74 additions and 36 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue