* Pattern of Rebirth - Fixed that the player that may search was not always the controller of the enchanted creature.

This commit is contained in:
LevelX2 2015-10-20 23:48:51 +02:00
parent 32429b4a4c
commit 1b71f50506
3 changed files with 25 additions and 6 deletions

View file

@ -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));
}

View file

@ -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;
}

View file

@ -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;
}