* Asceticism - Fixed a bug that no real Hexproof ability was gained (this fixed the problem with the failing PhantasmalImageTest).

This commit is contained in:
LevelX2 2014-05-23 16:06:35 +02:00
parent 9d8d1409b2
commit 19ccd5bc23
4 changed files with 23 additions and 73 deletions

View file

@ -47,7 +47,7 @@ public class TitanicGrowth extends CardImpl<TitanicGrowth> {
this.expansionSetCode = "M12"; this.expansionSetCode = "M12";
this.color.setGreen(true); this.color.setGreen(true);
this.getSpellAbility().addEffect(new BoostTargetEffect(4, 4, Duration.EndOfTurn)); 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) { public TitanicGrowth(final TitanicGrowth card) {

View file

@ -28,42 +28,37 @@
package mage.sets.scarsofmirrodin; package mage.sets.scarsofmirrodin;
import mage.constants.*; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.RegenerateTargetEffect; import mage.abilities.effects.common.RegenerateTargetEffect;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.keyword.HexproofAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.filter.FilterStackObject; import mage.constants.CardType;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.constants.Duration;
import mage.game.Game; import mage.constants.Rarity;
import mage.game.events.GameEvent; import mage.constants.Zone;
import mage.game.permanent.Permanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.stack.StackObject;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/** /**
* @author ayratn * @author ayratn
*/ */
public class Asceticism extends CardImpl<Asceticism> { public class Asceticism extends CardImpl<Asceticism> {
private static final FilterStackObject filter = new FilterStackObject("spells or abilities your opponents control");
static {
filter.add(new ControllerPredicate(TargetController.OPPONENT));
}
public Asceticism(UUID ownerId) { public Asceticism(UUID ownerId) {
super(ownerId, 110, "Asceticism", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}{G}"); super(ownerId, 110, "Asceticism", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}{G}");
this.expansionSetCode = "SOM"; this.expansionSetCode = "SOM";
this.color.setGreen(true); 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 ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateTargetEffect(), new ManaCostsImpl("{1}{G}"));
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent(true));
this.addAbility(ability); this.addAbility(ability);
} }
@ -77,51 +72,3 @@ public class Asceticism extends CardImpl<Asceticism> {
} }
} }
class AsceticismEffect extends ReplacementEffectImpl<AsceticismEffect> {
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;
}
}

View file

@ -138,18 +138,19 @@ public class PhantasmalImageTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerB, "Island", 2); addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
addCard(Zone.BATTLEFIELD, playerB, "Forest", 2); addCard(Zone.BATTLEFIELD, playerB, "Forest", 2);
addCard(Zone.HAND, playerB, "Phantasmal Image"); addCard(Zone.HAND, playerB, "Phantasmal Image");
// Target creature gets +4/+4 until end of turn.
addCard(Zone.HAND, playerB, "Titanic Growth"); addCard(Zone.HAND, playerB, "Titanic Growth");
// Creatures you control have hexproof. // Enchantment - Creatures you control have hexproof.
addCard(Zone.HAND, playerA, "Asceticism"); addCard(Zone.HAND, playerA, "Asceticism");
// Whenever this creature enters the battlefield or transforms into // Whenever this creature enters the battlefield or transforms into
// Huntmaster of the Fells, put a 2/2 green Wolf creature token onto // Huntmaster of the Fells, put a 2/2 green Wolf creature token onto
// the battlefield and you gain 2 life. // 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"); 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.PRECOMBAT_MAIN, playerA, "Asceticism");
castSpell(3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Titanic Growth", "Ravager of the Fells"); castSpell(3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Titanic Growth", "Ravager of the Fells");
@ -159,9 +160,11 @@ public class PhantasmalImageTest extends CardTestPlayerBase {
assertLife(playerB, 18); assertLife(playerB, 18);
// check opponent's creature wasn't chosen as a target for Titanic Growth // check opponent's creature wasn't chosen as a target for Titanic Growth
assertPowerToughness(playerA, "Ravager of the Fells", 4, 4); assertPowerToughness(playerA, "Ravager of the Fells", 4, 4);
// check playerA's creature was sacrificed assertGraveyardCount(playerB, "Titanic Growth", 1);
assertPermanentCount(playerB, "Ravager of the Fells", 0); // check playerB's creature was sacrificed
assertGraveyardCount(playerB, "Phantasmal Image", 1); assertGraveyardCount(playerB, "Phantasmal Image", 1);
assertPermanentCount(playerB, "Ravager of the Fells", 0);
} }
/** /**

View file

@ -98,7 +98,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int affectedTargets = 0; int affectedTargets = 0;
for (UUID permanentId : targetPointer.getTargets(game, source)) { for (UUID permanentId : targetPointer.getTargets(game, source)) {
Permanent target = (Permanent) game.getPermanent(permanentId); Permanent target = game.getPermanent(permanentId);
if (target != null) { if (target != null) {
target.addPower(power.calculate(game, source)); target.addPower(power.calculate(game, source));
target.addToughness(toughness.calculate(game, source)); target.addToughness(toughness.calculate(game, source));