From b3c0cc10b0dd27adb6266f4792ce17ae098dd50d Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 17 Sep 2014 15:56:23 +0200 Subject: [PATCH] * Aluren - Changed ability to handle the cast ability as alternate casting cost. --- Mage.Sets/src/mage/sets/tempest/Aluren.java | 134 ++++++++++++++------ 1 file changed, 96 insertions(+), 38 deletions(-) diff --git a/Mage.Sets/src/mage/sets/tempest/Aluren.java b/Mage.Sets/src/mage/sets/tempest/Aluren.java index 2e39029a9df..350d20aba87 100644 --- a/Mage.Sets/src/mage/sets/tempest/Aluren.java +++ b/Mage.Sets/src/mage/sets/tempest/Aluren.java @@ -29,35 +29,42 @@ package mage.sets.tempest; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.SpellAbility; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.AlternativeCostSourceAbility; +import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continious.CastAsThoughItHadFlashEffect; -import mage.abilities.effects.common.cost.CostModificationEffectImpl; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.CostModificationType; import mage.constants.Duration; +import mage.constants.Layer; import mage.constants.Outcome; import mage.constants.Rarity; +import mage.constants.SubLayer; import mage.constants.Zone; import mage.filter.Filter.ComparisonType; import mage.filter.common.FilterCreatureCard; import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; import mage.game.Game; -import mage.game.stack.Spell; -import mage.game.stack.StackObject; import mage.players.Player; -import mage.util.CardUtil; /** - * + * 10/4/2004 The mana cost of the creatures being cast is still the stated cost on the card, + * even though you did not pay the cost. + * 10/4/2004 Aluren checks the actual printed cost on the creature card, and is not affected + * by things which allow you to cast the spell for less. + * 10/4/2004 You can't choose to cast a creature as though it had flash via Aluren and still pay the mana cost. + * You either cast the creature normally, or via Aluren without paying the mana cost. + * 10/4/2004 You can't use Aluren when casting a creature using another alternate means, + * such as the Morph ability. + * 8/1/2008 If creature with X in its cost is cast this way, X can only be 0. + * * @author emerald000 */ public class Aluren extends CardImpl { - + private static final FilterCreatureCard filter = new FilterCreatureCard("creature cards with converted mana cost 3 or less"); + static { filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, 4)); } @@ -69,8 +76,9 @@ public class Aluren extends CardImpl { this.color.setGreen(true); // Any player may play creature cards with converted mana cost 3 or less without paying their mana cost - Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new AlurenEffect()); + Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new AlurenRuleEffect()); // and as though they had flash. + // TODO: This as thought effect may only be used if the creature is cast by the aluren effect Effect effect = new CastAsThoughItHadFlashEffect(Duration.WhileOnBattlefield, filter, true); effect.setText("and as though they had flash"); ability.addEffect(effect); @@ -87,45 +95,95 @@ public class Aluren extends CardImpl { } } -class AlurenEffect extends CostModificationEffectImpl { +class AlurenRuleEffect extends ContinuousEffectImpl { - AlurenEffect() { - super(Duration.WhileOnBattlefield, Outcome.PlayForFree, CostModificationType.SET_COST); - this.staticText = "Any player may play creature cards with converted mana cost 3 or less without paying their mana cost"; + private static final FilterCreatureCard filter = new FilterCreatureCard("creature cards with converted mana cost 3 or less"); + + static { + filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, 4)); } - AlurenEffect(final AlurenEffect effect) { + static AlternativeCostSourceAbility alternativeCastingCostAbility = new AlternativeCostSourceAbility(null, null, null, filter, true); + + public AlurenRuleEffect() { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + staticText = "Any player may play creature cards with converted mana cost 3 or less without paying their mana cost"; + } + + public AlurenRuleEffect(final AlurenRuleEffect effect) { super(effect); } - + @Override - public boolean apply(Game game, Ability source, Ability abilityToModify) { - SpellAbility spellAbility = (SpellAbility) abilityToModify; - spellAbility.getManaCostsToPay().clear(); - return true; + public AlurenRuleEffect copy() { + return new AlurenRuleEffect(this); } - + @Override - public boolean applies(Ability abilityToModify, Ability source, Game game) { - if (abilityToModify instanceof SpellAbility) { - Card sourceCard = game.getCard(abilityToModify.getSourceId()); - StackObject stackObject = game.getStack().getStackObject(abilityToModify.getSourceId()); - if (stackObject != null && stackObject instanceof Spell) { - if (sourceCard != null && sourceCard.getCardType().contains(CardType.CREATURE) && sourceCard.getManaCost().convertedManaCost() <= 3) { - Player player = game.getPlayer(stackObject.getControllerId()); - String message = "Cast " + sourceCard.getName() + " without paying its mana costs?"; - if (player != null && - (CardUtil.isCheckPlayableMode(abilityToModify) || player.chooseUse(outcome, message, game))) { - return true; - } + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + for (UUID playerId: controller.getInRange()){ + Player player = game.getPlayer(playerId); + if (player != null) { + player.getAlternativeSourceCosts().add(alternativeCastingCostAbility); } - } + } + return true; } return false; } - + @Override - public AlurenEffect copy() { - return new AlurenEffect(this); + public boolean apply(Game game, Ability source) { + return false; } -} \ No newline at end of file + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.RulesEffects; + } +} + +//class AlurenEffect extends CostModificationEffectImpl { +// +// AlurenEffect() { +// super(Duration.WhileOnBattlefield, Outcome.PlayForFree, CostModificationType.SET_COST); +// this.staticText = "Any player may play creature cards with converted mana cost 3 or less without paying their mana cost"; +// } +// +// AlurenEffect(final AlurenEffect effect) { +// super(effect); +// } +// +// @Override +// public boolean apply(Game game, Ability source, Ability abilityToModify) { +// SpellAbility spellAbility = (SpellAbility) abilityToModify; +// spellAbility.getManaCostsToPay().clear(); +// return true; +// } +// +// @Override +// public boolean applies(Ability abilityToModify, Ability source, Game game) { +// if (abilityToModify instanceof SpellAbility) { +// Card sourceCard = game.getCard(abilityToModify.getSourceId()); +// StackObject stackObject = game.getStack().getStackObject(abilityToModify.getSourceId()); +// if (stackObject != null && stackObject instanceof Spell) { +// if (sourceCard != null && sourceCard.getCardType().contains(CardType.CREATURE) && sourceCard.getManaCost().convertedManaCost() <= 3) { +// Player player = game.getPlayer(stackObject.getControllerId()); +// String message = "Cast " + sourceCard.getName() + " without paying its mana costs?"; +// if (player != null && +// (CardUtil.isCheckPlayableMode(abilityToModify) || player.chooseUse(outcome, message, game))) { +// return true; +// } +// } +// } +// } +// return false; +// } +// +// @Override +// public AlurenEffect copy() { +// return new AlurenEffect(this); +// } +//}