From 19ccd5bc23024d38cf4fecd2166079cfec9f5c0d Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 23 May 2014 16:06:35 +0200 Subject: [PATCH] * Asceticism - Fixed a bug that no real Hexproof ability was gained (this fixed the problem with the failing PhantasmalImageTest). --- .../mage/sets/magic2012/TitanicGrowth.java | 2 +- .../mage/sets/scarsofmirrodin/Asceticism.java | 79 +++---------------- .../test/cards/copy/PhantasmalImageTest.java | 13 +-- .../common/continious/BoostTargetEffect.java | 2 +- 4 files changed, 23 insertions(+), 73 deletions(-) diff --git a/Mage.Sets/src/mage/sets/magic2012/TitanicGrowth.java b/Mage.Sets/src/mage/sets/magic2012/TitanicGrowth.java index 1c1697e7251..acbb0c4df9e 100644 --- a/Mage.Sets/src/mage/sets/magic2012/TitanicGrowth.java +++ b/Mage.Sets/src/mage/sets/magic2012/TitanicGrowth.java @@ -47,7 +47,7 @@ public class TitanicGrowth extends CardImpl { this.expansionSetCode = "M12"; this.color.setGreen(true); this.getSpellAbility().addEffect(new BoostTargetEffect(4, 4, Duration.EndOfTurn)); - this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(true)); } public TitanicGrowth(final TitanicGrowth card) { diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/Asceticism.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/Asceticism.java index 37e26f35f57..e22cb0459cb 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/Asceticism.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/Asceticism.java @@ -28,42 +28,37 @@ package mage.sets.scarsofmirrodin; -import mage.constants.*; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.RegenerateTargetEffect; +import mage.abilities.effects.common.continious.GainAbilityControlledEffect; +import mage.abilities.keyword.HexproofAbility; import mage.cards.CardImpl; -import mage.filter.FilterStackObject; -import mage.filter.predicate.permanent.ControllerPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.game.stack.StackObject; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.common.FilterControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; -import java.util.UUID; - /** * @author ayratn */ public class Asceticism extends CardImpl { - private static final FilterStackObject filter = new FilterStackObject("spells or abilities your opponents control"); - - static { - filter.add(new ControllerPredicate(TargetController.OPPONENT)); - } - public Asceticism(UUID ownerId) { super(ownerId, 110, "Asceticism", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}{G}"); this.expansionSetCode = "SOM"; this.color.setGreen(true); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AsceticismEffect(filter, Duration.WhileOnBattlefield))); + + // Creatures you control have hexproof. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(HexproofAbility.getInstance(), Duration.WhileOnBattlefield, new FilterControlledCreaturePermanent()))); + // {1}{G}: Regenerate target creature. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateTargetEffect(), new ManaCostsImpl("{1}{G}")); - ability.addTarget(new TargetCreaturePermanent()); + ability.addTarget(new TargetCreaturePermanent(true)); this.addAbility(ability); } @@ -77,51 +72,3 @@ public class Asceticism extends CardImpl { } } - -class AsceticismEffect extends ReplacementEffectImpl { - - private FilterStackObject filterSource; - - public AsceticismEffect(FilterStackObject filterSource, Duration duration) { - super(duration, Outcome.Benefit); - this.filterSource = filterSource; - staticText = "Creatures you control can't be the targets of spells or abilities your opponents control"; - } - - public AsceticismEffect(final AsceticismEffect effect) { - super(effect); - this.filterSource = effect.filterSource.copy(); - } - - @Override - public AsceticismEffect copy() { - return new AsceticismEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.TARGET) { - Permanent permanent = game.getBattlefield().getPermanent(event.getTargetId()); - if (permanent != null && permanent.getControllerId().equals(source.getControllerId()) - && permanent.getCardType().contains(CardType.CREATURE)) { - StackObject sourceObject = game.getStack().getStackObject(event.getSourceId()); - if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) { - return true; - } - } - } - return false; - } - -} - diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java index 53f4c88014a..d478c38785a 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java @@ -138,18 +138,19 @@ public class PhantasmalImageTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerB, "Island", 2); addCard(Zone.BATTLEFIELD, playerB, "Forest", 2); addCard(Zone.HAND, playerB, "Phantasmal Image"); + // Target creature gets +4/+4 until end of turn. addCard(Zone.HAND, playerB, "Titanic Growth"); - // Creatures you control have hexproof. + // Enchantment - Creatures you control have hexproof. addCard(Zone.HAND, playerA, "Asceticism"); // Whenever this creature enters the battlefield or transforms into // Huntmaster of the Fells, put a 2/2 green Wolf creature token onto // the battlefield and you gain 2 life. - // At the beginning of each upkeep, if no spells were cast last turn, transform Huntmaster of the Fells. + // At the beginning of each upkeep, if no spells were cast last turn, transform Huntmaster of the Fells. ==> Ravager of the Fells addCard(Zone.BATTLEFIELD, playerA, "Huntmaster of the Fells"); - castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Phantasmal Image"); + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Phantasmal Image"); // copy target: Ravergers of the Fells castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Asceticism"); castSpell(3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Titanic Growth", "Ravager of the Fells"); @@ -159,9 +160,11 @@ public class PhantasmalImageTest extends CardTestPlayerBase { assertLife(playerB, 18); // check opponent's creature wasn't chosen as a target for Titanic Growth assertPowerToughness(playerA, "Ravager of the Fells", 4, 4); - // check playerA's creature was sacrificed - assertPermanentCount(playerB, "Ravager of the Fells", 0); + assertGraveyardCount(playerB, "Titanic Growth", 1); + // check playerB's creature was sacrificed assertGraveyardCount(playerB, "Phantasmal Image", 1); + assertPermanentCount(playerB, "Ravager of the Fells", 0); + } /** diff --git a/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java b/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java index e39761a7197..227719ba0aa 100644 --- a/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java @@ -98,7 +98,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { int affectedTargets = 0; for (UUID permanentId : targetPointer.getTargets(game, source)) { - Permanent target = (Permanent) game.getPermanent(permanentId); + Permanent target = game.getPermanent(permanentId); if (target != null) { target.addPower(power.calculate(game, source)); target.addToughness(toughness.calculate(game, source));