mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
added SetTargetPointer Enum to AttackedByCreatureTriggeredAbility
PERMANENT targeting attacking creature PLAYER targeting attacking player modified Garruk Apex Predator (only card using this) to use SetTargetPointer
This commit is contained in:
parent
16d70585d9
commit
e324d53d97
2 changed files with 18 additions and 8 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue