This commit is contained in:
jeffwadsworth 2020-01-21 14:36:49 -06:00
parent a072d8275f
commit 507658e942

View file

@ -1,14 +1,17 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.abilities.effects.Effect; import mage.abilities.Ability;
import mage.abilities.effects.common.DamageTargetControllerEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.target.common.TargetArtifactPermanent; import mage.constants.Outcome;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
/** /**
* *
@ -17,14 +20,12 @@ import mage.target.common.TargetArtifactPermanent;
public final class SmashToSmithereens extends CardImpl { public final class SmashToSmithereens extends CardImpl {
public SmashToSmithereens(UUID ownerId, CardSetInfo setInfo) { public SmashToSmithereens(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{R}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{R}");
// Destroy target artifact. Smash to Smithereens deals 3 damage to that artifact's controller. // Destroy target artifact. Smash to Smithereens deals 3 damage to that artifact's controller.
this.getSpellAbility().addEffect(new DestroyTargetEffect()); this.getSpellAbility().addEffect(new SmashToSmithereensEffect());
Effect effect = new DamageTargetControllerEffect(3); this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT));
effect.setText("{this} deals 3 damage to that artifact's controller");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetArtifactPermanent());
} }
public SmashToSmithereens(final SmashToSmithereens card) { public SmashToSmithereens(final SmashToSmithereens card) {
@ -36,3 +37,34 @@ public final class SmashToSmithereens extends CardImpl {
return new SmashToSmithereens(this); return new SmashToSmithereens(this);
} }
} }
class SmashToSmithereensEffect extends OneShotEffect {
SmashToSmithereensEffect() {
super(Outcome.Detriment);
staticText = "Destroy target artifact. Smash to Smithereens deals 3 damage to that artifact's controller";
}
private SmashToSmithereensEffect(final SmashToSmithereensEffect effect) {
super(effect);
}
@Override
public SmashToSmithereensEffect copy() {
return new SmashToSmithereensEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent targetArtifact = game.getPermanentOrLKIBattlefield(source.getFirstTarget());
if (targetArtifact != null) {
Player controllerOfArtifact = game.getPlayer(targetArtifact.getControllerId());
targetArtifact.destroy(source.getSourceId(), game, false);
if (controllerOfArtifact != null) {
controllerOfArtifact.damage(3, source.getSourceId(), game);
}
return true;
}
return false;
}
}