From 1b71f505064b82893003207fc29954de533fbed5 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 20 Oct 2015 23:48:51 +0200 Subject: [PATCH] * Pattern of Rebirth - Fixed that the player that may search was not always the controller of the enchanted creature. --- .../sets/urzasdestiny/PatternOfRebirth.java | 8 ++++---- .../common/DiesAttachedTriggeredAbility.java | 19 +++++++++++++++++++ Mage/src/mage/constants/SetTargetPointer.java | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Mage.Sets/src/mage/sets/urzasdestiny/PatternOfRebirth.java b/Mage.Sets/src/mage/sets/urzasdestiny/PatternOfRebirth.java index 017063b773..038d5fda7d 100644 --- a/Mage.Sets/src/mage/sets/urzasdestiny/PatternOfRebirth.java +++ b/Mage.Sets/src/mage/sets/urzasdestiny/PatternOfRebirth.java @@ -32,12 +32,13 @@ import mage.abilities.Ability; import mage.abilities.common.DiesAttachedTriggeredAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.AttachEffect; -import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; +import mage.abilities.effects.common.search.SearchLibraryPutInPlayTargetPlayerEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; +import mage.constants.SetTargetPointer; import mage.filter.common.FilterCreatureCard; import mage.target.TargetPermanent; import mage.target.common.TargetCardInLibrary; @@ -54,7 +55,6 @@ public class PatternOfRebirth extends CardImpl { this.expansionSetCode = "UDS"; this.subtype.add("Aura"); - // Enchant creature TargetPermanent auraTarget = new TargetCreaturePermanent(); this.getSpellAbility().addTarget(auraTarget); @@ -63,9 +63,9 @@ public class PatternOfRebirth extends CardImpl { this.addAbility(ability); // When enchanted creature dies, that creature's controller may search his or her library for a creature card and put that card onto the battlefield. If that player does, he or she shuffles his or her library. - Effect effect = new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(new FilterCreatureCard()), false, true, Outcome.PutCreatureInPlay); + Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(new FilterCreatureCard()), false, true, Outcome.PutCreatureInPlay); effect.setText("that creature's controller may search his or her library for a creature card and put that card onto the battlefield. If that player does, he or she shuffles his or her library"); - this.addAbility(new DiesAttachedTriggeredAbility(effect, "enchanted creature", true, true)); + this.addAbility(new DiesAttachedTriggeredAbility(effect, "enchanted creature", true, true, SetTargetPointer.ATTACHED_TO_CONTROLLER)); } diff --git a/Mage/src/mage/abilities/common/DiesAttachedTriggeredAbility.java b/Mage/src/mage/abilities/common/DiesAttachedTriggeredAbility.java index 963df6092b..11d4a2764f 100644 --- a/Mage/src/mage/abilities/common/DiesAttachedTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/DiesAttachedTriggeredAbility.java @@ -2,11 +2,13 @@ package mage.abilities.common; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; +import mage.constants.SetTargetPointer; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; +import mage.target.targetpointer.FixedTarget; /** * "When enchanted/equipped creature dies" triggered ability @@ -17,6 +19,7 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl { private String attachedDescription; private boolean diesRuleText; + protected SetTargetPointer setTargetPointer; public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription) { this(effect, attachedDescription, false); @@ -27,15 +30,21 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl { } public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean diesRuleText) { + this(effect, attachedDescription, optional, diesRuleText, SetTargetPointer.NONE); + } + + public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean diesRuleText, SetTargetPointer setTargetPointer) { super(Zone.ALL, effect, optional); // because the trigger only triggers if the object was attached, it doesn't matter where the Attachment was moved to (e.g. by replacement effect) after the trigger triggered, so Zone.all this.attachedDescription = attachedDescription; this.diesRuleText = diesRuleText; + this.setTargetPointer = setTargetPointer; } public DiesAttachedTriggeredAbility(final DiesAttachedTriggeredAbility ability) { super(ability); this.attachedDescription = ability.attachedDescription; this.diesRuleText = ability.diesRuleText; + this.setTargetPointer = ability.setTargetPointer; } @Override @@ -69,6 +78,16 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl { if (triggered) { for (Effect effect : getEffects()) { effect.setValue("attachedTo", zEvent.getTarget()); + if (setTargetPointer.equals(SetTargetPointer.ATTACHED_TO_CONTROLLER)) { + Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId()); + if (attachment != null && attachment.getAttachedTo() != null) { + Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(), Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter()); + if (attachedTo != null) { + effect.setTargetPointer(new FixedTarget(attachedTo.getControllerId())); + } + } + + } } return true; } diff --git a/Mage/src/mage/constants/SetTargetPointer.java b/Mage/src/mage/constants/SetTargetPointer.java index 6aeca5e026..9f4acc8876 100644 --- a/Mage/src/mage/constants/SetTargetPointer.java +++ b/Mage/src/mage/constants/SetTargetPointer.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.constants; /** @@ -33,5 +32,6 @@ package mage.constants; * @author LevelX2 */ public enum SetTargetPointer { - NONE, PLAYER, SPELL, CARD, PERMANENT; + + NONE, PLAYER, SPELL, CARD, PERMANENT, ATTACHED_TO_CONTROLLER; }