Fixed SpellsCostReductionEffect reducing the costs of FlashbackAbility.

This commit is contained in:
LevelX2 2012-11-19 23:00:43 +01:00
parent 3c97dc5fde
commit c8411395b7
3 changed files with 22 additions and 7 deletions

View file

@ -193,6 +193,9 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
Spell<?> spell = (Spell<?>) object;
String castText = spell.getSpellAbility().toString();
sb.append((castText.startsWith("Cast ") ? castText.substring(5):castText));
if (spell.getFromZone() == Zone.GRAVEYARD) {
sb.append(" from graveyard");
}
} else {
sb.append(object.getName());
}

View file

@ -30,8 +30,10 @@ package mage.abilities.effects.common.cost;
import mage.Constants.Duration;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.SpellAbility;
import mage.abilities.effects.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.filter.FilterCard;
import mage.game.Game;
@ -64,14 +66,13 @@ public class SpellsCostReductionEffect extends CostModificationEffectImpl<Spells
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
SpellAbility spellAbility = (SpellAbility) abilityToModify;
CardUtil.adjustCost(spellAbility, this.amount);
CardUtil.adjustCost(abilityToModify, this.amount);
return true;
}
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility)
&& abilityToModify.getControllerId().equals(source.getControllerId())) {
Card sourceCard = game.getCard(abilityToModify.getSourceId());
return sourceCard != null && this.filter.match(sourceCard, game);

View file

@ -30,6 +30,8 @@ package mage.util;
import mage.Constants;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.SpellAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCost;
@ -85,7 +87,6 @@ public class CardUtil {
return false;
}
/**
* Adjusts spell or ability cost to be paid.
*
@ -93,7 +94,17 @@ public class CardUtil {
* @param reduceCount
*/
public static void adjustCost(SpellAbility spellAbility, int reduceCount) {
ManaCosts<ManaCost> previousCost = spellAbility.getManaCostsToPay();
Ability ability = (Ability) spellAbility;
CardUtil.adjustCost(ability, reduceCount);
}
/**
* Adjusts ability cost to be paid.
*
* @param ability
* @param reduceCount
*/
public static void adjustCost(Ability ability, int reduceCount) {
ManaCosts<ManaCost> previousCost = ability.getManaCostsToPay();
ManaCosts<ManaCost> adjustedCost = new ManaCostsImpl<ManaCost>();
boolean reduced = false;
for (ManaCost manaCost : previousCost) {
@ -109,8 +120,8 @@ public class CardUtil {
adjustedCost.add(manaCost);
}
}
spellAbility.getManaCostsToPay().clear();
spellAbility.getManaCostsToPay().addAll(adjustedCost);
ability.getManaCostsToPay().clear();
ability.getManaCostsToPay().addAll(adjustedCost);
}
/**