diff --git a/Mage.Sets/src/mage/sets/avacynrestored/DevoutChaplain.java b/Mage.Sets/src/mage/sets/avacynrestored/DevoutChaplain.java index 8e3a1fb328..06b8c0c7cf 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/DevoutChaplain.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/DevoutChaplain.java @@ -27,9 +27,10 @@ */ package mage.sets.avacynrestored; -import mage.Constants; +import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -40,13 +41,12 @@ import mage.cards.CardImpl; import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.Predicates; -import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.permanent.TappedPredicate; import mage.target.TargetPermanent; import mage.target.common.TargetControlledPermanent; -import java.util.UUID; /** * @author noxx @@ -79,7 +79,7 @@ public class DevoutChaplain extends CardImpl { this.toughness = new MageInt(2); // {tap}, Tap two untapped Humans you control: Exile target artifact or enchantment. - Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new ExileTargetEffect("Devout Chaplain"), new TapSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTargetEffect(), new TapSourceCost()); ability.addCost(new TapTargetCost(new TargetControlledPermanent(2, 2, humanFilter, false))); ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/PainwrackerOni.java b/Mage.Sets/src/mage/sets/championsofkamigawa/PainwrackerOni.java index f851e35662..e91ca15e87 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/PainwrackerOni.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/PainwrackerOni.java @@ -33,18 +33,17 @@ import mage.Constants.CardType; import mage.Constants.Rarity; import mage.Constants.Zone; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.SacrificeTargetEffect; +import mage.abilities.effects.common.SacrificeControllerEffect; import mage.abilities.keyword.FearAbility; import mage.cards.CardImpl; import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; -import mage.target.common.TargetControlledCreaturePermanent; /** * @@ -64,9 +63,7 @@ public class PainwrackerOni extends CardImpl { // Fear (This creature can't be blocked except by artifact creatures and/or black creatures.) this.addAbility(FearAbility.getInstance()); // At the beginning of your upkeep, sacrifice a creature if you don't control an Ogre. - Ability ability = new PainwrackerOniTriggeredAbility1(new SacrificeTargetEffect()); - ability.addTarget(new TargetControlledCreaturePermanent()); - this.addAbility(ability); + this.addAbility(new PainwrackerOniTriggeredAbility1(new SacrificeControllerEffect(new FilterControlledCreaturePermanent(), 1, ""))); } public PainwrackerOni (final PainwrackerOni card) { diff --git a/Mage.Sets/src/mage/sets/worldwake/StoneIdolTrap.java b/Mage.Sets/src/mage/sets/worldwake/StoneIdolTrap.java index 7a74f3402b..8f6aede126 100644 --- a/Mage.Sets/src/mage/sets/worldwake/StoneIdolTrap.java +++ b/Mage.Sets/src/mage/sets/worldwake/StoneIdolTrap.java @@ -30,14 +30,19 @@ package mage.sets.worldwake; import java.util.UUID; import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Outcome; import mage.Constants.Rarity; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.SpellAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.delayed.AtEndOfTurnDelayedTriggeredAbility; +import mage.abilities.effects.CostModificationEffectImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ExileTargetEffect; +import mage.abilities.keyword.FlashbackAbility; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; @@ -45,6 +50,7 @@ import mage.filter.predicate.permanent.AttackingPredicate; import mage.game.Game; import mage.game.permanent.token.Token; import mage.target.targetpointer.FixedTarget; +import mage.util.CardUtil; /** * @@ -52,11 +58,6 @@ import mage.target.targetpointer.FixedTarget; */ public class StoneIdolTrap extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); - - static { - filter.add(new AttackingPredicate()); - } public StoneIdolTrap(UUID ownerId) { super(ownerId, 93, "Stone Idol Trap", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{5}{R}"); @@ -66,7 +67,9 @@ public class StoneIdolTrap extends CardImpl { this.color.setRed(true); // Stone Idol Trap costs {1} less to cast for each attacking creature. - this.addAbility(new SimpleStaticAbility(Constants.Zone.STACK, new StoneIdolTrapCostReductionEffect())); + Ability ability = new SimpleStaticAbility(Constants.Zone.STACK, new StoneIdolTrapCostReductionEffect()); + ability.setRuleAtTheTop(true); + this.addAbility(ability); // Put a 6/12 colorless Construct artifact creature token with trample onto the battlefield. Exile it at the beginning of your next end step. this.getSpellAbility().addEffect(new StoneIdolTrapEffect()); @@ -76,42 +79,41 @@ public class StoneIdolTrap extends CardImpl { super(card); } - @Override - public void adjustCosts(Ability ability, Game game) { - super.adjustCosts(ability, game); - int cost = ability.getManaCostsToPay().convertedManaCost() - 1; - int reductionAmount = game.getBattlefield().getAllActivePermanents(filter, game).size(); - int newCost = cost - reductionAmount; - if (newCost < 0) { - newCost = 0; - } - String adjustedCost = "{R}"; - adjustedCost = "{" + String.valueOf(newCost) + "}" + adjustedCost; - ability.getManaCostsToPay().clear(); - ability.getManaCostsToPay().load(adjustedCost); - } - @Override public StoneIdolTrap copy() { return new StoneIdolTrap(this); } } -class StoneIdolTrapCostReductionEffect extends OneShotEffect { +class StoneIdolTrapCostReductionEffect extends CostModificationEffectImpl { - private static final String effectText = "{this} costs {1} less to cast for each attacking creature"; + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); - StoneIdolTrapCostReductionEffect() { - super(Constants.Outcome.Benefit); - this.staticText = effectText; + static { + filter.add(new AttackingPredicate()); + } + public StoneIdolTrapCostReductionEffect() { + super(Duration.WhileOnStack, Outcome.Benefit); + staticText = "{this} costs {1} less to cast for each attacking creature"; } - StoneIdolTrapCostReductionEffect(StoneIdolTrapCostReductionEffect effect) { + protected StoneIdolTrapCostReductionEffect(StoneIdolTrapCostReductionEffect effect) { super(effect); } @Override - public boolean apply(Game game, Ability source) { + public boolean apply(Game game, Ability source, Ability abilityToModify) { + int reductionAmount = game.getBattlefield().getAllActivePermanents(filter, game).size(); + CardUtil.adjustCost(abilityToModify, reductionAmount); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) + && abilityToModify.getSourceId().equals(source.getSourceId())) { + return game.getCard(abilityToModify.getSourceId()) != null; + } return false; } @@ -141,10 +143,10 @@ class StoneIdolTrapEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { StoneTrapIdolToken token = new StoneTrapIdolToken(); token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); - ExileTargetEffect exileEffect = new ExileTargetEffect("Exile this token at the end of turn step"); + ExileTargetEffect exileEffect = new ExileTargetEffect("exile the token"); exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken())); - DelayedTriggeredAbility delayedAbility = new AtEndOfTurnDelayedTriggeredAbility(exileEffect); - delayedAbility.setSourceId(token.getId()); + DelayedTriggeredAbility delayedAbility = new AtEndOfTurnDelayedTriggeredAbility(exileEffect, Constants.TargetController.YOU); + delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setControllerId(source.getControllerId()); game.addDelayedTriggeredAbility(delayedAbility);