From e324d53d976c969caca4ed24d7912998282aeb01 Mon Sep 17 00:00:00 2001 From: zweistecken Date: Tue, 19 May 2015 18:33:10 +0200 Subject: [PATCH] added SetTargetPointer Enum to AttackedByCreatureTriggeredAbility PERMANENT targeting attacking creature PLAYER targeting attacking player modified Garruk Apex Predator (only card using this) to use SetTargetPointer --- .../sets/magic2015/GarrukApexPredator.java | 3 ++- .../AttackedByCreatureTriggeredAbility.java | 23 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Mage.Sets/src/mage/sets/magic2015/GarrukApexPredator.java b/Mage.Sets/src/mage/sets/magic2015/GarrukApexPredator.java index a328f4e5bd..30321f8cb2 100644 --- a/Mage.Sets/src/mage/sets/magic2015/GarrukApexPredator.java +++ b/Mage.Sets/src/mage/sets/magic2015/GarrukApexPredator.java @@ -48,6 +48,7 @@ import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Rarity; +import mage.constants.SetTargetPointer; import mage.constants.Zone; import mage.counters.CounterType; import mage.filter.FilterPermanent; @@ -171,7 +172,7 @@ class GarrukApexPredatorEmblem extends Emblem { setName("EMBLEM: Garruk, Apex Predator"); Effect effect = new BoostTargetEffect(5,5,Duration.EndOfTurn); effect.setText("it gets +5/+5"); - Ability ability = new AttackedByCreatureTriggeredAbility(Zone.COMMAND, effect, false, true); + Ability ability = new AttackedByCreatureTriggeredAbility(Zone.COMMAND, effect, false, SetTargetPointer.PERMANENT); effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn, "and gains trample until end of turn"); ability.addEffect(effect); diff --git a/Mage/src/mage/abilities/common/AttackedByCreatureTriggeredAbility.java b/Mage/src/mage/abilities/common/AttackedByCreatureTriggeredAbility.java index 478672b0b3..5b4e3053bf 100644 --- a/Mage/src/mage/abilities/common/AttackedByCreatureTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/AttackedByCreatureTriggeredAbility.java @@ -31,6 +31,7 @@ package mage.abilities.common; import java.util.UUID; 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; @@ -43,25 +44,25 @@ import mage.target.targetpointer.FixedTarget; */ public class AttackedByCreatureTriggeredAbility extends TriggeredAbilityImpl { - protected boolean setTargetPointer; + protected SetTargetPointer setTargetPointer; public AttackedByCreatureTriggeredAbility(Effect effect) { this(effect, false); } public AttackedByCreatureTriggeredAbility(Effect effect, boolean optional) { - this(effect, optional, false); + this(effect, optional, SetTargetPointer.PERMANENT); } - public AttackedByCreatureTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) { + public AttackedByCreatureTriggeredAbility(Effect effect, boolean optional, SetTargetPointer setTargetPointer) { this(Zone.BATTLEFIELD, effect, optional, setTargetPointer); } - public AttackedByCreatureTriggeredAbility(Zone zone, Effect effect, boolean optional, boolean setTargetPointer) { + public AttackedByCreatureTriggeredAbility(Zone zone, Effect effect, boolean optional, SetTargetPointer setTargetPointer) { super(zone, effect, optional); this.setTargetPointer = setTargetPointer; } - + public AttackedByCreatureTriggeredAbility(AttackedByCreatureTriggeredAbility ability) { super(ability); this.setTargetPointer = ability.setTargetPointer; @@ -77,9 +78,17 @@ public class AttackedByCreatureTriggeredAbility extends TriggeredAbilityImpl { UUID playerId = game.getCombat().getDefendingPlayerId(event.getSourceId(), game); Permanent attackingCreature = game.getPermanent(event.getSourceId()); if (getControllerId().equals(playerId) && attackingCreature != null) { - if (setTargetPointer) { + if (!setTargetPointer.equals(SetTargetPointer.NONE)) { for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getSourceId())); + switch(setTargetPointer) { + case PERMANENT: + effect.setTargetPointer(new FixedTarget(event.getTargetId())); + break; + case PLAYER: + effect.setTargetPointer(new FixedTarget(attackingCreature.getControllerId())); + break; + } + } } return true;