diff --git a/Mage.Sets/src/mage/sets/avacynrestored/ArcaneMelee.java b/Mage.Sets/src/mage/sets/avacynrestored/ArcaneMelee.java index 4f359eaa23..4115e3649b 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/ArcaneMelee.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/ArcaneMelee.java @@ -70,7 +70,7 @@ public class ArcaneMelee extends CardImpl { class ArcaneMeleeCostReductionEffect extends CostModificationEffectImpl { ArcaneMeleeCostReductionEffect ( ) { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); staticText = "Instant and sorcery spells cost {2} less to cast"; } diff --git a/Mage.Sets/src/mage/sets/avacynrestored/HeraldOfWar.java b/Mage.Sets/src/mage/sets/avacynrestored/HeraldOfWar.java index ddf9a7a0b4..7023baa5ac 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/HeraldOfWar.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/HeraldOfWar.java @@ -83,7 +83,7 @@ public class HeraldOfWar extends CardImpl { class HeraldOfWarCostReductionEffect extends CostModificationEffectImpl { HeraldOfWarCostReductionEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); staticText = "Angel spells and Human spells you cast cost {1} less to cast for each +1/+1 counter on Herald of War"; } diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/KentaroTheSmilingCat.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/KentaroTheSmilingCat.java index 94e1660d20..2fe51ce67b 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/KentaroTheSmilingCat.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/KentaroTheSmilingCat.java @@ -76,13 +76,13 @@ public class KentaroTheSmilingCat extends CardImpl { return new KentaroTheSmilingCat(this); } - + //TODO : change CostModification to AlternativCost private class KentaroTheSmilingCatCostReductionEffect extends CostModificationEffectImpl { private static final String effectText = "You may pay {X} rather than pay the mana cost for Samurai spells you cast, where X is that spell's converted mana cost"; KentaroTheSmilingCatCostReductionEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.SET_COST); staticText = effectText; } diff --git a/Mage.Sets/src/mage/sets/darkascension/ThaliaGuardianOfThraben.java b/Mage.Sets/src/mage/sets/darkascension/ThaliaGuardianOfThraben.java index 9320409a2e..4d57cbae85 100644 --- a/Mage.Sets/src/mage/sets/darkascension/ThaliaGuardianOfThraben.java +++ b/Mage.Sets/src/mage/sets/darkascension/ThaliaGuardianOfThraben.java @@ -80,7 +80,7 @@ public class ThaliaGuardianOfThraben extends CardImpl { class ThaliaGuardianOfThrabenCostReductionEffect extends CostModificationEffectImpl { ThaliaGuardianOfThrabenCostReductionEffect ( ) { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST); staticText = "Noncreature spells cost {1} more to cast"; } diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/CouncilOfTheAbsolute.java b/Mage.Sets/src/mage/sets/dragonsmaze/CouncilOfTheAbsolute.java index 165257baf6..26ed64e01a 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/CouncilOfTheAbsolute.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/CouncilOfTheAbsolute.java @@ -49,6 +49,7 @@ import mage.cards.CardImpl; import mage.cards.repository.CardRepository; import mage.choices.Choice; import mage.choices.ChoiceImpl; +import mage.constants.CostModificationType; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; @@ -170,7 +171,7 @@ class CouncilOfTheAbsoluteReplacementEffect extends ReplacementEffectImpl { public CouncilOfTheAbsoluteCostReductionEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); this.staticText = "Spells with the chosen name cost 2 less for you to cast"; } diff --git a/Mage.Sets/src/mage/sets/innistrad/RooftopStorm.java b/Mage.Sets/src/mage/sets/innistrad/RooftopStorm.java index 9cb438d076..0ec38b4ce5 100644 --- a/Mage.Sets/src/mage/sets/innistrad/RooftopStorm.java +++ b/Mage.Sets/src/mage/sets/innistrad/RooftopStorm.java @@ -70,12 +70,14 @@ public class RooftopStorm extends CardImpl { } } + +//TODO : change to alternativCost class RooftopStormCostReductionEffect extends CostModificationEffectImpl { private static final String effectText = "You may pay {0} rather than pay the mana cost for Zombie creature spells you cast"; RooftopStormCostReductionEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); staticText = effectText; } diff --git a/Mage.Sets/src/mage/sets/magic2013/Omniscience.java b/Mage.Sets/src/mage/sets/magic2013/Omniscience.java index d5cd0bb45d..6678f22822 100644 --- a/Mage.Sets/src/mage/sets/magic2013/Omniscience.java +++ b/Mage.Sets/src/mage/sets/magic2013/Omniscience.java @@ -72,7 +72,7 @@ public class Omniscience extends CardImpl { class OmniscienceEffect extends CostModificationEffectImpl { public OmniscienceEffect() { - super(Duration.WhileOnBattlefield, Outcome.PlayForFree); + super(Duration.WhileOnBattlefield, Outcome.PlayForFree, CostModificationType.SET_COST); this.staticText = "You may cast nonland cards from your hand without paying their mana costs"; } diff --git a/Mage.Sets/src/mage/sets/modernmasters/GrandArbiterAugustinIV.java b/Mage.Sets/src/mage/sets/modernmasters/GrandArbiterAugustinIV.java index d0b6252ba2..91092b37fb 100644 --- a/Mage.Sets/src/mage/sets/modernmasters/GrandArbiterAugustinIV.java +++ b/Mage.Sets/src/mage/sets/modernmasters/GrandArbiterAugustinIV.java @@ -41,6 +41,7 @@ import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.CostModificationEffectImpl; import mage.abilities.effects.common.cost.SpellsCostReductionEffect; import mage.cards.CardImpl; +import mage.constants.CostModificationType; import mage.constants.Duration; import mage.filter.FilterCard; import mage.filter.predicate.mageobject.ColorPredicate; @@ -95,7 +96,7 @@ class GrandArbiterAugustinIVCostIncreaseEffect extends CostModificationEffectImp private static final String effectText = "Spells your opponents cast cost {1} more to cast"; GrandArbiterAugustinIVCostIncreaseEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST); staticText = effectText; } diff --git a/Mage.Sets/src/mage/sets/ninthedition/DefenseGrid.java b/Mage.Sets/src/mage/sets/ninthedition/DefenseGrid.java index 0b0822665b..5ed3b43b67 100644 --- a/Mage.Sets/src/mage/sets/ninthedition/DefenseGrid.java +++ b/Mage.Sets/src/mage/sets/ninthedition/DefenseGrid.java @@ -68,7 +68,7 @@ public class DefenseGrid extends CardImpl { class DefenseGridCostModificationEffect extends CostModificationEffectImpl { DefenseGridCostModificationEffect ( ) { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST); staticText = "Each spell costs {3} more to cast except during its controller's turn"; } diff --git a/Mage.Sets/src/mage/sets/planechase2012/ElderwoodScion.java b/Mage.Sets/src/mage/sets/planechase2012/ElderwoodScion.java index 7ad9a71894..85f454fede 100644 --- a/Mage.Sets/src/mage/sets/planechase2012/ElderwoodScion.java +++ b/Mage.Sets/src/mage/sets/planechase2012/ElderwoodScion.java @@ -47,6 +47,7 @@ import mage.target.Target; import mage.util.CardUtil; import java.util.UUID; +import mage.constants.CostModificationType; /** * @@ -89,7 +90,7 @@ class ElderwoodScionCostReductionEffect extends CostModificationEffectImpl { public AdjustingCostsEffect() { - super(Duration.Custom, Outcome.Benefit); + super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST); } public AdjustingCostsEffect(final AdjustingCostsEffect effect) { diff --git a/Mage.Sets/src/mage/sets/returntoravnica/RakdosLordOfRiots.java b/Mage.Sets/src/mage/sets/returntoravnica/RakdosLordOfRiots.java index 5c97fdd8a1..5e5ade65c6 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/RakdosLordOfRiots.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/RakdosLordOfRiots.java @@ -129,7 +129,7 @@ class RakdosLordOfRiotsCost extends CostImpl { class RakdosLordOfRiotsCostReductionEffect extends CostModificationEffectImpl { RakdosLordOfRiotsCostReductionEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); staticText = "Creature spells you cast cost {1} less to cast for each 1 life your opponents have lost this turn"; } diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/TrainingGrounds.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/TrainingGrounds.java index 63f28ca1f9..1563f6ce83 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/TrainingGrounds.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/TrainingGrounds.java @@ -38,6 +38,7 @@ import mage.abilities.effects.CostModificationEffectImpl; import mage.cards.CardImpl; import mage.choices.ChoiceImpl; import mage.constants.CardType; +import mage.constants.CostModificationType; import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Rarity; @@ -80,7 +81,7 @@ class TrainingGroundsEffect extends CostModificationEffectImpl { class LocketOfYesterdaysCostReductionEffect extends CostModificationEffectImpl { LocketOfYesterdaysCostReductionEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); staticText = "Spells you cast cost {1} less to cast for each card with the same name as that spell in your graveyard"; } diff --git a/Mage.Sets/src/mage/sets/visions/HelmOfAwakening.java b/Mage.Sets/src/mage/sets/visions/HelmOfAwakening.java index 5fab37c8b9..7d2854deba 100644 --- a/Mage.Sets/src/mage/sets/visions/HelmOfAwakening.java +++ b/Mage.Sets/src/mage/sets/visions/HelmOfAwakening.java @@ -44,6 +44,7 @@ import mage.filter.FilterSpell; */ public class HelmOfAwakening extends CardImpl { + public HelmOfAwakening(UUID ownerId) { super(ownerId, 145, "Helm of Awakening", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); this.expansionSetCode = "VIS"; diff --git a/Mage.Sets/src/mage/sets/worldwake/LodestoneGolem.java b/Mage.Sets/src/mage/sets/worldwake/LodestoneGolem.java index 8178d97538..a107d35dff 100644 --- a/Mage.Sets/src/mage/sets/worldwake/LodestoneGolem.java +++ b/Mage.Sets/src/mage/sets/worldwake/LodestoneGolem.java @@ -73,7 +73,7 @@ public class LodestoneGolem extends CardImpl { class LodestoneGolemCostReductionEffect extends CostModificationEffectImpl { LodestoneGolemCostReductionEffect ( ) { - super(Duration.WhileOnBattlefield, Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST); staticText = "Nonartifact spells cost {1} more to cast"; } diff --git a/Mage.Sets/src/mage/sets/worldwake/StoneIdolTrap.java b/Mage.Sets/src/mage/sets/worldwake/StoneIdolTrap.java index 463ff3abdc..60b0e81d82 100644 --- a/Mage.Sets/src/mage/sets/worldwake/StoneIdolTrap.java +++ b/Mage.Sets/src/mage/sets/worldwake/StoneIdolTrap.java @@ -91,7 +91,7 @@ class StoneIdolTrapCostReductionEffect extends CostModificationEffectImpl costEffects = getApplicableCostModificationEffects(game); for ( CostModificationEffect effect : costEffects) { - HashSet abilities = costModificationEffects.getAbility(effect.getId()); - for (Ability ability : abilities) { - if ( effect.applies(abilityToModify, ability, game) ) { - effect.apply(game, ability, abilityToModify); + if(effect.getModificationType() == CostModificationType.INCREASE_COST){ + HashSet abilities = costModificationEffects.getAbility(effect.getId()); + for (Ability ability : abilities) { + if ( effect.applies(abilityToModify, ability, game) ) { + effect.apply(game, ability, abilityToModify); + } + } + } + } + + for ( CostModificationEffect effect : costEffects) { + if(effect.getModificationType() == CostModificationType.REDUCE_COST){ + HashSet abilities = costModificationEffects.getAbility(effect.getId()); + for (Ability ability : abilities) { + if ( effect.applies(abilityToModify, ability, game) ) { + effect.apply(game, ability, abilityToModify); + } + } + } + } + + for ( CostModificationEffect effect : costEffects) { + if(effect.getModificationType() == CostModificationType.SET_COST){ + HashSet abilities = costModificationEffects.getAbility(effect.getId()); + for (Ability ability : abilities) { + if ( effect.applies(abilityToModify, ability, game) ) { + effect.apply(game, ability, abilityToModify); + } } } } diff --git a/Mage/src/mage/abilities/effects/CostModificationEffect.java b/Mage/src/mage/abilities/effects/CostModificationEffect.java index efe8a32d4a..280dffb863 100644 --- a/Mage/src/mage/abilities/effects/CostModificationEffect.java +++ b/Mage/src/mage/abilities/effects/CostModificationEffect.java @@ -29,6 +29,7 @@ package mage.abilities.effects; import mage.abilities.Ability; +import mage.constants.CostModificationType; import mage.game.Game; /** @@ -64,4 +65,10 @@ public interface CostModificationEffect> ext * @return */ boolean applies(Ability abilityToModify, Ability source, Game game); + + /** + * Return the type of modification + * @return + */ + CostModificationType getModificationType(); } diff --git a/Mage/src/mage/abilities/effects/CostModificationEffectImpl.java b/Mage/src/mage/abilities/effects/CostModificationEffectImpl.java index 23d0dbc5df..6ff35e901b 100644 --- a/Mage/src/mage/abilities/effects/CostModificationEffectImpl.java +++ b/Mage/src/mage/abilities/effects/CostModificationEffectImpl.java @@ -32,6 +32,7 @@ import mage.constants.Duration; import mage.constants.EffectType; import mage.constants.Outcome; import mage.abilities.Ability; +import mage.constants.CostModificationType; import mage.game.Game; /** @@ -42,14 +43,18 @@ import mage.game.Game; */ public abstract class CostModificationEffectImpl> extends ContinuousEffectImpl implements CostModificationEffect { - public CostModificationEffectImpl ( Duration duration, Outcome outcome ) { + private CostModificationType modificationType; + + public CostModificationEffectImpl ( Duration duration, Outcome outcome, CostModificationType type) { super(duration, outcome); this.effectType = EffectType.COSTMODIFICATION; + this.modificationType = type; } public CostModificationEffectImpl(final CostModificationEffectImpl effect) { super(effect); this.effectType = effect.effectType; + this.modificationType = effect.modificationType; } /** @@ -63,4 +68,10 @@ public abstract class CostModificationEffectImpl { private FilterControlledPermanent filter; public AffinityEffect(FilterControlledPermanent affinityFilter) { - super(Duration.Custom, Outcome.Benefit); + super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST); this.filter = affinityFilter; staticText = "Affinity for " + filter.getMessage(); } diff --git a/Mage/src/mage/abilities/effects/common/cost/CommanderCostModification.java b/Mage/src/mage/abilities/effects/common/cost/CommanderCostModification.java index 7f0cd804bf..838b9bb6f3 100644 --- a/Mage/src/mage/abilities/effects/common/cost/CommanderCostModification.java +++ b/Mage/src/mage/abilities/effects/common/cost/CommanderCostModification.java @@ -32,6 +32,7 @@ import mage.Mana; import mage.abilities.Ability; import mage.abilities.common.CastCommanderAbility; import mage.abilities.effects.CostModificationEffectImpl; +import mage.constants.CostModificationType; import mage.constants.Duration; import mage.constants.Outcome; import mage.game.Game; @@ -50,7 +51,7 @@ public class CommanderCostModification extends CostModificationEffectImpl { + + private FilterCard filter; + private int amount; + + public SpellsCostIncreasementAllEffect(int amount) { + this(new FilterCard("All Spells "), amount); + } + + public SpellsCostIncreasementAllEffect(FilterCard filter, int amount) { + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST); + this.filter = filter; + this.amount = amount; + this.staticText = new StringBuilder(filter.getMessage()).append(" cost {").append(amount).append("} more to cast").toString(); + } + + protected SpellsCostIncreasementAllEffect(SpellsCostIncreasementAllEffect effect) { + super(effect); + this.filter = effect.filter; + this.amount = effect.amount; + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + CardUtil.increaseCost(abilityToModify, this.amount); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility)) { + Card sourceCard = game.getCard(abilityToModify.getSourceId()); + return sourceCard != null && this.filter.match(sourceCard, game); + } + return false; + } + + @Override + public SpellsCostIncreasementAllEffect copy() { + return new SpellsCostIncreasementAllEffect(this); + } +} diff --git a/Mage/src/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java b/Mage/src/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java index 0e082f0d8e..4115a074cd 100644 --- a/Mage/src/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java +++ b/Mage/src/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java @@ -32,6 +32,7 @@ import mage.abilities.SpellAbility; import mage.abilities.effects.CostModificationEffectImpl; import mage.abilities.keyword.FlashbackAbility; import mage.cards.Card; +import mage.constants.CostModificationType; import mage.constants.Duration; import mage.constants.Outcome; import mage.filter.FilterCard; @@ -52,7 +53,7 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl