* Fixed alternate casting costs of shoal spells (e.g. Blazing Shoal).

This commit is contained in:
LevelX2 2014-02-23 17:39:37 +01:00
parent 22fccea168
commit 3c7b414ee6
8 changed files with 49 additions and 85 deletions

View file

@ -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<BlazingShoal> {
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<BlazingShoal> {
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;
}
}

View file

@ -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<DisruptingShoal> {
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<DisruptingShoal> {
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.

View file

@ -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<NourishingShoal> {
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<NourishingShoal> {
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()));

View file

@ -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<ShiningShoal> {
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<ShiningShoal> {
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<ShiningShoal> {
class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl<ShiningShoalPreventDamageTargetEffect> {
private DynamicValue dynamicAmount;
private final DynamicValue dynamicAmount;
private int amount;
public ShiningShoalPreventDamageTargetEffect(Duration duration, DynamicValue dynamicAmount) {
@ -126,7 +123,7 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl<Shining
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), event.getAmount(), false);
if (!game.replaceEvent(preventEvent)) {
int prevented = 0;
int prevented;
if (event.getAmount() >= this.amount) {
int damage = amount;
event.setAmount(event.getAmount() - amount);
@ -197,4 +194,4 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl<Shining
return false;
}
}
}

View file

@ -28,17 +28,17 @@
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.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.dynamicvalue.common.SignInversionDynamicValue;
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;
@ -52,8 +52,6 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class SickeningShoal extends CardImpl<SickeningShoal> {
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<SickeningShoal> {
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<SickeningShoal> {
public SickeningShoal copy() {
return new SickeningShoal(this);
}
}
}

View file

@ -146,7 +146,9 @@ public class AlternativeCostSourceAbility extends StaticAbility<AlternativeCostS
if (condition != null) {
sb.append(condition.toString());
sb.append(", rather than pay {source}'s mana cost, ");
}
} else {
sb.append("You may ");
}
int numberCosts = 0;
String remarkText = "";
for (AlternativeCost2 alternativeCost: alternateCosts) {

View file

@ -27,11 +27,8 @@
*/
package mage.abilities.dynamicvalue.common;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.costs.AlternativeCost;
import mage.abilities.costs.Cost;
import mage.abilities.costs.Costs;
import mage.abilities.costs.common.ExileFromHandCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.cards.Card;
@ -51,18 +48,13 @@ public class ExileFromHandCostCardConvertedMana implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
for (AlternativeCost aCost: (List<AlternativeCost>) 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 "";
}
}
}

View file

@ -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<BoostTargetEffect> {
}
/**
* @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) {