diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/TerashisGrasp.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/TerashisGrasp.java index a4f19520dda..68ce2ef71f8 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/TerashisGrasp.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/TerashisGrasp.java @@ -25,24 +25,22 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.betrayersofkamigawa; import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; -import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; @@ -60,12 +58,12 @@ public class TerashisGrasp extends CardImpl { new CardTypePredicate(CardType.ENCHANTMENT))); } - public TerashisGrasp (UUID ownerId) { + public TerashisGrasp(UUID ownerId) { super(ownerId, 26, "Terashi's Grasp", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{2}{W}"); this.expansionSetCode = "BOK"; this.subtype.add("Arcane"); this.color.setWhite(true); - + // Destroy target artifact or enchantment. this.getSpellAbility().addTarget(new TargetPermanent(filter)); this.getSpellAbility().addEffect(new DestroyTargetEffect()); @@ -73,7 +71,7 @@ public class TerashisGrasp extends CardImpl { this.getSpellAbility().addEffect(new TerashisGraspEffect()); } - public TerashisGrasp (final TerashisGrasp card) { + public TerashisGrasp(final TerashisGrasp card) { super(card); } @@ -84,31 +82,31 @@ public class TerashisGrasp extends CardImpl { private class TerashisGraspEffect extends OneShotEffect { - public TerashisGraspEffect() { - super(Outcome.DestroyPermanent); - staticText = "You gain life equal to its converted mana cost"; - } - - public TerashisGraspEffect(TerashisGraspEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - MageObject card = game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD); - if (card != null) { - int cost = card.getManaCost().get(0).convertedManaCost(); - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - player.gainLife(cost, game); - } - } - return true; - } - - @Override - public TerashisGraspEffect copy() { - return new TerashisGraspEffect(this); - } + public TerashisGraspEffect() { + super(Outcome.DestroyPermanent); + staticText = "You gain life equal to its converted mana cost"; } + + public TerashisGraspEffect(TerashisGraspEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent targetPermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + if (targetPermanent != null) { + int cost = targetPermanent.getManaCost().convertedManaCost(); + Player player = game.getPlayer(source.getControllerId()); + if (player != null) { + player.gainLife(cost, game); + } + } + return true; + } + + @Override + public TerashisGraspEffect copy() { + return new TerashisGraspEffect(this); + } + } } diff --git a/Mage.Sets/src/mage/sets/gatecrash/GrislySpectacle.java b/Mage.Sets/src/mage/sets/gatecrash/GrislySpectacle.java index a8efff42caf..51f500a1afe 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/GrislySpectacle.java +++ b/Mage.Sets/src/mage/sets/gatecrash/GrislySpectacle.java @@ -28,14 +28,15 @@ package mage.sets.gatecrash; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardTypePredicate; @@ -63,6 +64,7 @@ public class GrislySpectacle extends CardImpl { this.color.setBlack(true); // Destroy target nonartifact creature. Its controller puts a number of cards equal to that creature's power from the top of his or her library into his or her graveyard. + this.getSpellAbility().addEffect(new DestroyTargetEffect()); this.getSpellAbility().addEffect(new GrislySpectacleEffect()); this.getSpellAbility().addTarget(new TargetPermanent(filter)); } @@ -81,7 +83,7 @@ class GrislySpectacleEffect extends OneShotEffect { public GrislySpectacleEffect() { super(Outcome.DestroyPermanent); - this.staticText = "Destroy target nonartifact creature. Its controller puts a number of cards equal to that creature's power from the top of his or her library into his or her graveyard"; + this.staticText = "Its controller puts a number of cards equal to that creature's power from the top of his or her library into his or her graveyard"; } public GrislySpectacleEffect(final GrislySpectacleEffect effect) { @@ -95,13 +97,12 @@ class GrislySpectacleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source)); + // the mill effect works also if creature is indestructible or regenerated + Permanent creature = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); if (creature != null) { Player controller = game.getPlayer(creature.getControllerId()); if (controller != null) { int power = creature.getPower().getValue(); - creature.destroy(source.getSourceId(), game, false); - // the mill effect works also if creature is indestructible or regenerated Effect effect = new PutLibraryIntoGraveTargetEffect(power); effect.setTargetPointer(new FixedTarget(controller.getId())); return effect.apply(game, source); diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/DivineOffering.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/DivineOffering.java index f8b47a9b214..6920d04cdbc 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/DivineOffering.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/DivineOffering.java @@ -25,23 +25,21 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.mirrodinbesieged; import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; -import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; @@ -51,22 +49,24 @@ import mage.target.TargetPermanent; */ public class DivineOffering extends CardImpl { - private static FilterPermanent filter = new FilterPermanent("artifact"); + private final static FilterPermanent filter = new FilterPermanent("artifact"); static { filter.add(new CardTypePredicate(CardType.ARTIFACT)); } - public DivineOffering (UUID ownerId) { + public DivineOffering(UUID ownerId) { super(ownerId, 5, "Divine Offering", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{W}"); this.expansionSetCode = "MBS"; this.color.setWhite(true); - this.getSpellAbility().addTarget(new TargetPermanent(filter)); - this.getSpellAbility().addEffect(new DestroyTargetEffect()); - this.getSpellAbility().addEffect(new DivineOfferingEffect()); + + // Destroy target artifact. You gain life equal to its converted mana cost. + this.getSpellAbility().addTarget(new TargetPermanent(filter, true)); + this.getSpellAbility().addEffect(new DestroyTargetEffect()); + this.getSpellAbility().addEffect(new DivineOfferingEffect()); } - public DivineOffering (final DivineOffering card) { + public DivineOffering(final DivineOffering card) { super(card); } @@ -75,34 +75,34 @@ public class DivineOffering extends CardImpl { return new DivineOffering(this); } - private class DivineOfferingEffect extends OneShotEffect { - - public DivineOfferingEffect() { - super(Outcome.DestroyPermanent); - staticText = "You gain life equal to its converted mana cost"; - } - - public DivineOfferingEffect(DivineOfferingEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - MageObject card = game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD); - if (card != null) { - int cost = card.getManaCost().get(0).convertedManaCost(); - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - player.gainLife(cost, game); - } - } - return true; - } - - @Override - public DivineOfferingEffect copy() { - return new DivineOfferingEffect(this); - } + private class DivineOfferingEffect extends OneShotEffect { + public DivineOfferingEffect() { + super(Outcome.DestroyPermanent); + staticText = "You gain life equal to its converted mana cost"; } + + public DivineOfferingEffect(DivineOfferingEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent artefact = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + if (artefact != null) { + int cost = artefact.getManaCost().convertedManaCost(); + Player player = game.getPlayer(source.getControllerId()); + if (player != null) { + player.gainLife(cost, game); + } + } + return true; + } + + @Override + public DivineOfferingEffect copy() { + return new DivineOfferingEffect(this); + } + + } } diff --git a/Mage.Sets/src/mage/sets/ninthedition/Chastise.java b/Mage.Sets/src/mage/sets/ninthedition/Chastise.java index df30881c444..8197ac221f7 100644 --- a/Mage.Sets/src/mage/sets/ninthedition/Chastise.java +++ b/Mage.Sets/src/mage/sets/ninthedition/Chastise.java @@ -28,14 +28,14 @@ package mage.sets.ninthedition; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -55,6 +55,7 @@ public class Chastise extends CardImpl { // Destroy target attacking creature. You gain life equal to its power. this.getSpellAbility().addTarget(new TargetAttackingCreature()); + this.getSpellAbility().addEffect(new DestroyTargetEffect()); this.getSpellAbility().addEffect(new ChastiseEffect()); } @@ -70,13 +71,10 @@ public class Chastise extends CardImpl { class ChastiseEffect extends OneShotEffect { - public ChastiseEffect() { - super(Outcome.DestroyPermanent); + super(Outcome.GainLife); } - - public ChastiseEffect(final ChastiseEffect effect) { super(effect); } @@ -88,10 +86,9 @@ class ChastiseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(source.getFirstTarget()); + Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { int power = permanent.getPower().getValue(); - permanent.destroy(source.getId(), game, true); Player player = game.getPlayer(source.getControllerId()); if (player != null) { player.gainLife(power, game); @@ -103,7 +100,6 @@ class ChastiseEffect extends OneShotEffect { @Override public String getText(Mode mode) { - return "Destroy target attacking creature. You gain life equal to its power"; + return "You gain life equal to its power"; } - -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/Vendetta.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/Vendetta.java index d9193f2d0e3..ce5f446613d 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/Vendetta.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/Vendetta.java @@ -64,6 +64,7 @@ public class Vendetta extends CardImpl { this.color.setBlack(true); + // Destroy target nonblack creature. It can't be regenerated. You lose life equal to that creature's toughness. this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); this.getSpellAbility().addEffect(new DestroyTargetEffect(true)); this.getSpellAbility().addEffect(new VendettaEffect()); @@ -98,7 +99,7 @@ class VendettaEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - Permanent target = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD); + Permanent target = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); if (player != null && target != null) { player.loseLife(target.getToughness().getValue(), game); return true; @@ -106,4 +107,4 @@ class VendettaEffect extends OneShotEffect { return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/EngulfingSlagwurm.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/EngulfingSlagwurm.java index 50acbf4f78b..b93401c1e67 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/EngulfingSlagwurm.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/EngulfingSlagwurm.java @@ -29,19 +29,17 @@ package mage.sets.scarsofmirrodin; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; -import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.BlocksOrBecomesBlockedByCreatureTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.Zone; +import mage.constants.Rarity; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; /** @@ -88,9 +86,9 @@ class EngulfingSlagwurmEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject c = game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); - if (c != null && controller != null) { - controller.gainLife(c.getPower().getValue(), game); + Permanent creature = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + if (creature != null && controller != null) { + controller.gainLife(creature.getPower().getValue(), game); } return false; }