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;
import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetControllerEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
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;
/**
*
@ -20,11 +23,9 @@ public final class SmashToSmithereens extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{R}");
// Destroy target artifact. Smash to Smithereens deals 3 damage to that artifact's controller.
this.getSpellAbility().addEffect(new DestroyTargetEffect());
Effect effect = new DamageTargetControllerEffect(3);
effect.setText("{this} deals 3 damage to that artifact's controller");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetArtifactPermanent());
this.getSpellAbility().addEffect(new SmashToSmithereensEffect());
this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT));
}
public SmashToSmithereens(final SmashToSmithereens card) {
@ -36,3 +37,34 @@ public final class SmashToSmithereens extends CardImpl {
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;
}
}