diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/BlazingShoal.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/BlazingShoal.java index 66e1ea6f09b..45ee13055cc 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/BlazingShoal.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/BlazingShoal.java @@ -28,24 +28,20 @@ package mage.sets.betrayersofkamigawa; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Rarity; import mage.ObjectColor; -import mage.abilities.Ability; import mage.abilities.costs.AlternativeCostSourceAbility; -import mage.abilities.costs.Cost; import mage.abilities.costs.common.ExileFromHandCost; -import mage.abilities.costs.common.PayLifeCost; import mage.abilities.dynamicvalue.common.ExileFromHandCostCardConvertedMana; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.common.continious.BoostTargetEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; import mage.filter.common.FilterOwnedCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardIdPredicate; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; import mage.target.common.TargetCardInHand; import mage.target.common.TargetCreaturePermanent; @@ -62,13 +58,10 @@ public class BlazingShoal extends CardImpl { this.color.setRed(true); // You may exile a red card with converted mana cost X from your hand rather than pay Blazing Shoal's mana cost. - FilterOwnedCard filter = new FilterOwnedCard("red card from your hand"); + FilterOwnedCard filter = new FilterOwnedCard("a red card with converted mana cost X from your hand"); filter.add(new ColorPredicate(ObjectColor.RED)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself - - AlternativeCostSourceAbility ability = new BlazingShoalAlternativeCostAbility(new PayLifeCost(1)); - ability.addCost(new ExileFromHandCost(new TargetCardInHand(filter))); - this.addAbility(ability); + this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // Target creature gets +X/+0 until end of turn. this.getSpellAbility().addEffect(new BoostTargetEffect(new ExileFromHandCostCardConvertedMana(), new StaticValue(0), Duration.EndOfTurn)); @@ -84,19 +77,3 @@ public class BlazingShoal extends CardImpl { return new BlazingShoal(this); } } - -class BlazingShoalAlternativeCostAbility extends AlternativeCostSourceAbility { - - public BlazingShoalAlternativeCostAbility(Cost cost) { - super(cost, null, null); - } - - @Override - public boolean askToActivateAlternativeCosts(Ability ability, Game game) { - if (super.askToActivateAlternativeCosts(ability, game)) { - - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/DisruptingShoal.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/DisruptingShoal.java index c00fb50b482..8f5a63fb232 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/DisruptingShoal.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/DisruptingShoal.java @@ -28,18 +28,18 @@ package mage.sets.betrayersofkamigawa; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.Mode; -import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.common.ExileFromHandCost; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.ExileFromHandCostCardConvertedMana; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; import mage.filter.common.FilterOwnedCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardIdPredicate; @@ -55,8 +55,6 @@ import mage.target.common.TargetCardInHand; */ public class DisruptingShoal extends CardImpl { - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may exile a blue card with converted mana cost X from your hand rather than pay Disrupting Shoal's mana cost"; - public DisruptingShoal(UUID ownerId) { super(ownerId, 33, "Disrupting Shoal", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{X}{U}{U}"); this.expansionSetCode = "BOK"; @@ -64,10 +62,10 @@ public class DisruptingShoal extends CardImpl { this.color.setBlue(true); // You may exile a blue card with converted mana cost X from your hand rather than pay Disrupting Shoal's mana cost. - FilterOwnedCard filter = new FilterOwnedCard("blue card from your hand"); + FilterOwnedCard filter = new FilterOwnedCard("a blue card with converted mana cost X from your hand"); filter.add(new ColorPredicate(ObjectColor.BLUE)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, new ExileFromHandCost(new TargetCardInHand(filter)))); + this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // 2/1/2005: Disrupting Shoal can target any spell, but does nothing unless that spell's converted mana cost is X. // Counter target spell if its converted mana cost is X. diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/NourishingShoal.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/NourishingShoal.java index fd496ef43dd..fc3cf001a3d 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/NourishingShoal.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/NourishingShoal.java @@ -28,14 +28,14 @@ package mage.sets.betrayersofkamigawa; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; import mage.ObjectColor; -import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.common.ExileFromHandCost; import mage.abilities.dynamicvalue.common.ExileFromHandCostCardConvertedMana; import mage.abilities.effects.common.GainLifeEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.common.FilterOwnedCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardIdPredicate; @@ -48,8 +48,6 @@ import mage.target.common.TargetCardInHand; */ public class NourishingShoal extends CardImpl { - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may exile a green card with converted mana cost X from your hand rather than pay Nourishing Shoal's mana cost"; - public NourishingShoal(UUID ownerId) { super(ownerId, 137, "Nourishing Shoal", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{X}{G}{G}"); this.expansionSetCode = "BOK"; @@ -57,10 +55,10 @@ public class NourishingShoal extends CardImpl { this.color.setGreen(true); // You may exile a green card with converted mana cost X from your hand rather than pay Nourishing Shoal's mana cost. - FilterOwnedCard filter = new FilterOwnedCard("green card from your hand"); + FilterOwnedCard filter = new FilterOwnedCard("a green card with converted mana cost X from your hand"); filter.add(new ColorPredicate(ObjectColor.GREEN)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, new ExileFromHandCost(new TargetCardInHand(filter)))); + this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // You gain X life. this.getSpellAbility().addEffect(new GainLifeEffect(new ExileFromHandCostCardConvertedMana())); diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/ShiningShoal.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/ShiningShoal.java index e5f4f317d83..1829f30a16d 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/ShiningShoal.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/ShiningShoal.java @@ -28,19 +28,18 @@ package mage.sets.betrayersofkamigawa; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageObject; import mage.ObjectColor; import mage.abilities.Ability; -import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.common.ExileFromHandCost; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.ExileFromHandCostCardConvertedMana; import mage.abilities.effects.PreventionEffectImpl; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Rarity; import mage.filter.common.FilterOwnedCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardIdPredicate; @@ -59,8 +58,6 @@ import mage.target.common.TargetCreatureOrPlayer; */ public class ShiningShoal extends CardImpl { - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may exile a white card with converted mana cost X from your hand rather than pay Shining Shoal's mana cost"; - public ShiningShoal(UUID ownerId) { super(ownerId, 21, "Shining Shoal", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{X}{W}{W}"); this.expansionSetCode = "BOK"; @@ -68,10 +65,10 @@ public class ShiningShoal extends CardImpl { this.color.setWhite(true); // You may exile a white card with converted mana cost X from your hand rather than pay Shining Shoal's mana cost - FilterOwnedCard filter = new FilterOwnedCard("white card from your hand"); + FilterOwnedCard filter = new FilterOwnedCard("a white card with converted mana cost X from your hand"); filter.add(new ColorPredicate(ObjectColor.WHITE)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, new ExileFromHandCost(new TargetCardInHand(filter)))); + this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // The next X damage that a source of your choice would deal to you and/or creatures you control this turn is dealt to target creature or player instead. this.getSpellAbility().addEffect(new ShiningShoalPreventDamageTargetEffect(Duration.EndOfTurn, new ExileFromHandCostCardConvertedMana())); @@ -92,7 +89,7 @@ public class ShiningShoal extends CardImpl { class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl { - private DynamicValue dynamicAmount; + private final DynamicValue dynamicAmount; private int amount; public ShiningShoalPreventDamageTargetEffect(Duration duration, DynamicValue dynamicAmount) { @@ -126,7 +123,7 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl= this.amount) { int damage = amount; event.setAmount(event.getAmount() - amount); @@ -197,4 +194,4 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl { - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may exile a black card with converted mana cost X from your hand rather than pay Sickening Shoal's mana cost"; - public SickeningShoal(UUID ownerId) { super(ownerId, 82, "Sickening Shoal", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{X}{B}{B}"); this.expansionSetCode = "BOK"; @@ -61,10 +59,10 @@ public class SickeningShoal extends CardImpl { this.color.setBlack(true); // You may exile a black card with converted mana cost X from your hand rather than pay Sickening Shoal's mana cost. - FilterOwnedCard filter = new FilterOwnedCard("black card from your hand"); + FilterOwnedCard filter = new FilterOwnedCard("a black card with converted mana cost X from your hand"); filter.add(new ColorPredicate(ObjectColor.BLACK)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, new ExileFromHandCost(new TargetCardInHand(filter)))); + this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // Target creature gets -X/-X until end of turn. DynamicValue x = new SignInversionDynamicValue(new ExileFromHandCostCardConvertedMana()); @@ -80,4 +78,4 @@ public class SickeningShoal extends CardImpl { public SickeningShoal copy() { return new SickeningShoal(this); } -} \ No newline at end of file +} diff --git a/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java b/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java index fa0e9cb82ef..5a731088ad2 100644 --- a/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java +++ b/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java @@ -146,7 +146,9 @@ public class AlternativeCostSourceAbility extends StaticAbility) sourceAbility.getAlternativeCosts()) { - if (aCost.isPaid()) { - for (int x=0; x < ((Costs) aCost).size(); x++) { - Cost cost = (Cost) ((Costs) aCost).get(x); - if (cost instanceof ExileFromHandCost) { - int xValue = 0; - for (Card card : ((ExileFromHandCost) cost).getCards()) { - xValue += card.getManaCost().convertedManaCost(); - } - return xValue; - } + for (Cost cost: sourceAbility.getCosts()) { + if (cost.isPaid() && cost instanceof ExileFromHandCost) { + int xValue = 0; + for (Card card : ((ExileFromHandCost) cost).getCards()) { + xValue += card.getManaCost().convertedManaCost(); } + return xValue; } } return sourceAbility.getManaCostsToPay().getX(); @@ -82,4 +74,4 @@ public class ExileFromHandCostCardConvertedMana implements DynamicValue { public String getMessage() { return ""; } -} \ No newline at end of file +} diff --git a/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java b/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java index 066e78c7090..1a9e4f454b3 100644 --- a/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java @@ -27,20 +27,19 @@ */ package mage.abilities.effects.common.continious; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.SubLayer; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.Target; - -import java.util.UUID; import mage.util.CardUtil; /** @@ -62,6 +61,9 @@ public class BoostTargetEffect extends ContinuousEffectImpl { } /** + * @param power + * @param toughness + * @param duration * @param lockedIn if true, power and toughness will be calculated only once, when the ability resolves */ public BoostTargetEffect(DynamicValue power, DynamicValue toughness, Duration duration, boolean lockedIn) {