From 98eb5102280d8250feaa3596c95b34ff37f9fc62 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 1 Apr 2014 17:32:15 +0200 Subject: [PATCH] * Runed Halo - Fixed a bug that controlling player had protection from every name. --- .../src/mage/sets/futuresight/Narcomoeba.java | 2 +- .../src/mage/sets/shadowmoor/RunedHalo.java | 51 ++++++++++++++----- .../GainAbilityControllerEffect.java | 12 +++++ 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/Mage.Sets/src/mage/sets/futuresight/Narcomoeba.java b/Mage.Sets/src/mage/sets/futuresight/Narcomoeba.java index 5f69a77543..63b3712a85 100644 --- a/Mage.Sets/src/mage/sets/futuresight/Narcomoeba.java +++ b/Mage.Sets/src/mage/sets/futuresight/Narcomoeba.java @@ -88,6 +88,6 @@ class NarcomoebaAbility extends ZoneChangeTriggeredAbility { @Override public String getRule() { - return "When {this} is put into your graveyard from your library, you may put it onto the battlefield"; + return "When {this} is put into your graveyard from your library, you may put it onto the battlefield."; } } diff --git a/Mage.Sets/src/mage/sets/shadowmoor/RunedHalo.java b/Mage.Sets/src/mage/sets/shadowmoor/RunedHalo.java index f3ee8c7318..9779ee12e5 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/RunedHalo.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/RunedHalo.java @@ -28,27 +28,35 @@ package mage.sets.shadowmoor; import java.util.UUID; +import mage.MageObject; import mage.constants.CardType; import mage.constants.Rarity; import mage.constants.Zone; import mage.abilities.Ability; +import mage.abilities.StaticAbility; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.Effect; +import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continious.GainAbilityControllerEffect; import mage.abilities.keyword.ProtectionAbility; +import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.repository.CardRepository; import mage.choices.Choice; import mage.choices.ChoiceImpl; +import mage.constants.Duration; import mage.constants.Outcome; +import mage.filter.Filter; import mage.filter.FilterCard; import mage.filter.FilterObject; +import mage.filter.FilterPermanent; +import mage.filter.FilterSpell; import mage.filter.predicate.mageobject.NamePredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.game.stack.Spell; import mage.players.Player; /** @@ -76,9 +84,7 @@ public class RunedHalo extends CardImpl { * 5/1/2008: You may choose either one of a flip card's names. You'll have protection only from the appropriate version. For example, if you choose Nighteyes the Desecrator, you won't have protection from Nezumi Graverobber. */ // You have protection from the chosen name. - Effect effect = new GainAbilityControllerEffect(new ProtectionAbility(new FilterObject("empty"))); - effect.setText("You have protection from the chosen name (You can't be targeted, dealt damage, or enchanted by anything with that name.)"); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new RunedHaloRuleTextEffect())); } @@ -117,15 +123,14 @@ class NameCard extends OneShotEffect { } } String cardName = cardChoice.getChoice(); - game.informPlayers("Runed Halo, named card: [" + cardName + "]"); - FilterCard filter = new FilterCard(cardName); - filter.add(new NamePredicate(cardName)); - for (Ability ability : sourcePermanent.getAbilities()) { - if (ability instanceof ProtectionAbility) { - ((ProtectionAbility) ability).setFilter(filter); - } - } + game.informPlayers(new StringBuilder(sourcePermanent.getName()).append(", named card: [").append(cardName).append("]").toString()); sourcePermanent.addInfo("Named card", new StringBuilder("[Named card: ").append(cardName).append("]").toString()); + + FilterObject filter = new FilterObject("the name [" + cardName + "]"); + filter.add(new NamePredicate(cardName)); + ContinuousEffect effect = new GainAbilityControllerEffect(new ProtectionAbility(filter), Duration.Custom); + game.addEffect(effect, source); + return true; } return false; } @@ -136,3 +141,25 @@ class NameCard extends OneShotEffect { } } + +class RunedHaloRuleTextEffect extends OneShotEffect { + + public RunedHaloRuleTextEffect() { + super(Outcome.Benefit); + this.staticText = "You have protection from the chosen name (You can't be targeted, dealt damage, or enchanted by anything with that name.)"; + } + + public RunedHaloRuleTextEffect(final RunedHaloRuleTextEffect effect) { + super(effect); + } + + @Override + public RunedHaloRuleTextEffect copy() { + return new RunedHaloRuleTextEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } +} diff --git a/Mage/src/mage/abilities/effects/common/continious/GainAbilityControllerEffect.java b/Mage/src/mage/abilities/effects/common/continious/GainAbilityControllerEffect.java index c1d49588b6..97a04c8224 100644 --- a/Mage/src/mage/abilities/effects/common/continious/GainAbilityControllerEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/GainAbilityControllerEffect.java @@ -53,6 +53,11 @@ public class GainAbilityControllerEffect extends ContinuousEffectImpl