Changed SpellCostReduction effect to work with FilterSpell instead of FilterCard.

This commit is contained in:
LevelX2 2014-01-18 16:00:44 +01:00
parent c560626883
commit 5f720983ee
35 changed files with 130 additions and 84 deletions

View file

@ -35,8 +35,9 @@ import mage.abilities.effects.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.constants.CostModificationType;
import mage.filter.FilterCard;
import mage.filter.FilterSpell;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.util.CardUtil;
/**
@ -45,10 +46,10 @@ import mage.util.CardUtil;
*/
public class SpellsCostReductionEffect extends CostModificationEffectImpl<SpellsCostReductionEffect> {
private FilterCard filter;
private FilterSpell filter;
private int amount;
public SpellsCostReductionEffect(FilterCard filter, int amount) {
public SpellsCostReductionEffect(FilterSpell filter, int amount) {
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
this.filter = filter;
this.amount = amount;
@ -72,10 +73,10 @@ public class SpellsCostReductionEffect extends CostModificationEffectImpl<Spells
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility)
if ((abilityToModify instanceof SpellAbility)
&& abilityToModify.getControllerId().equals(source.getControllerId())) {
Card sourceCard = game.getCard(abilityToModify.getSourceId());
return sourceCard != null && this.filter.match(sourceCard, game);
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
return spell != null && this.filter.match(spell, game);
}
return false;
}

View file

@ -27,10 +27,7 @@
*/
package mage.abilities.keyword;
import mage.constants.Outcome;
import mage.constants.SpellAbilityType;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.SpellAbility;
import mage.abilities.costs.Cost;
@ -39,6 +36,8 @@ import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.ExileSourceEffect;
import mage.cards.Card;
import mage.cards.SplitCard;
import mage.constants.Outcome;
import mage.constants.SpellAbilityType;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.game.Game;
@ -51,14 +50,16 @@ import mage.target.Target;
*
* @author nantuko
*/
public class FlashbackAbility extends /*SpellAbility*/ ActivatedAbilityImpl<FlashbackAbility> {
public class FlashbackAbility extends SpellAbility {
private SpellAbilityType spellAbilityType;
private String abilityName;
public FlashbackAbility(Cost cost, TimingRule timingRule) {
//super(cost, "", new FlashbackEffect(), Constants.Zone.GRAVEYARD);
super(Zone.GRAVEYARD, new FlashbackEffect(), cost);
super(null, "", Zone.GRAVEYARD);
this.name = new StringBuilder("Flashback ").append(cost.getText()).toString();
this.addEffect(new FlashbackEffect());
this.addCost(cost);
this.timing = timingRule;
this.usesStack = false;
this.spellAbilityType = SpellAbilityType.BASE;
@ -104,10 +105,12 @@ public class FlashbackAbility extends /*SpellAbility*/ ActivatedAbilityImpl<Flas
return sbRule.toString();
}
@Override
public void setSpellAbilityType(SpellAbilityType spellAbilityType) {
this.spellAbilityType = spellAbilityType;
}
@Override
public SpellAbilityType getSpellAbilityType() {
return this.spellAbilityType;
}

View file

@ -0,0 +1,26 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mage.filter.common;
import mage.constants.CardType;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.CardTypePredicate;
/**
*
* @author LevelX2
*/
public class FilterCreatureSpell extends FilterSpell {
public FilterCreatureSpell() {
super("creature spell");
}
public FilterCreatureSpell(String name) {
super(name);
this.add(new CardTypePredicate(CardType.CREATURE));
}
}

View file

@ -840,6 +840,9 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
else if (ability instanceof ManaAbility) {
result = playManaAbility((ManaAbility)ability.copy(), game);
}
else if (ability instanceof FlashbackAbility){
result = playAbility((ActivatedAbility)ability.copy(), game);
}
else if (ability instanceof SpellAbility) {
result = cast((SpellAbility)ability, game, false);
}