mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 05:52:06 -08:00
Changed SpellCostReduction effect to work with FilterSpell instead of FilterCard.
This commit is contained in:
parent
c560626883
commit
5f720983ee
35 changed files with 130 additions and 84 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
26
Mage/src/mage/filter/common/FilterCreatureSpell.java
Normal file
26
Mage/src/mage/filter/common/FilterCreatureSpell.java
Normal 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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue