[ODY] simplified implementation of Ghastly Demise
package mage.cards.g;
-import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@@ -10,12 +9,12 @@ import mage.constants.Outcome;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
-import mage.target.Target;
+import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
-import mage.target.targetpointer.FirstTargetPointer;
+
+import java.util.UUID;
/**
- *
* @author cbt33
*/
public final class GhastlyDemise extends CardImpl {
@@ -25,7 +24,7 @@ public final class GhastlyDemise extends CardImpl {
// Destroy target nonblack creature if its toughness is less than or equal to the number of cards in your graveyard.
this.getSpellAbility().addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_PERMANENT_CREATURE_NON_BLACK));
- this.getSpellAbility().addEffect(new GhastlyDemiseEffect(false));
+ this.getSpellAbility().addEffect(new GhastlyDemiseEffect());
}
private GhastlyDemise(final GhastlyDemise card) {
@@ -40,17 +39,14 @@ public final class GhastlyDemise extends CardImpl {
class GhastlyDemiseEffect extends OneShotEffect {
- protected boolean noRegen;
-
- public GhastlyDemiseEffect(boolean noRegen) {
+ GhastlyDemiseEffect() {
super(Outcome.DestroyPermanent);
- staticText = "Destroy target nonblack creature if its toughness is less than or equal to the number of cards in your graveyard";
- this.noRegen = noRegen;
+ staticText = "destroy target nonblack creature if its toughness " +
+ "is less than or equal to the number of cards in your graveyard";
}
- public GhastlyDemiseEffect(final GhastlyDemiseEffect effect) {
+ private GhastlyDemiseEffect(final GhastlyDemiseEffect effect) {
super(effect);
- this.noRegen = effect.noRegen;
}
@Override
@@ -60,26 +56,10 @@ class GhastlyDemiseEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
- int affectedTargets = 0;
- if (source.getTargets().size() > 1 && this.targetPointer instanceof FirstTargetPointer) { // for Rain of Thorns
- for (Target target : source.getTargets()) {
- for (UUID permanentId : target.getTargets()) {
- Permanent permanent = game.getPermanent(permanentId);
- if (permanent != null && permanent.getToughness().getValue() <= game.getPlayer(source.getControllerId()).getGraveyard().size()) {
- permanent.destroy(source, game, noRegen);
- affectedTargets++;
- }
- }
- }
- } else if (this.targetPointer != null && !this.targetPointer.getTargets(game, source).isEmpty()) {
- for (UUID permanentId : this.targetPointer.getTargets(game, source)) {
- Permanent permanent = game.getPermanent(permanentId);
- if (permanent != null && permanent.getToughness().getValue() <= game.getPlayer(source.getControllerId()).getGraveyard().size()) {
- permanent.destroy(source, game, noRegen);
- affectedTargets++;
- }
- }
- }
- return affectedTargets > 0;
+ Permanent permanent = game.getPermanent(source.getFirstTarget());
+ Player player = game.getPlayer(source.getControllerId());
+ return permanent != null && player != null
+ && permanent.getToughness().getValue() <= player.getGraveyard().size()
+ && permanent.destroy(source, game);
}
}
