Fix Axelrod Gunnarson

This commit is contained in:
Plopman 2018-03-27 00:07:13 +02:00
parent a33916f3f4
commit 1466cc2a81
2 changed files with 18 additions and 4 deletions

View file

@ -40,6 +40,8 @@ import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SetTargetPointer;
import mage.filter.StaticFilters;
import mage.target.TargetPlayer;
/**
@ -60,11 +62,12 @@ public class AxelrodGunnarson extends CardImpl {
this.addAbility(TrampleAbility.getInstance());
// Whenever a creature dealt damage by Axelrod Gunnarson this turn dies, you gain 1 life and Axelrod deals 1 damage to target player.
Ability ability = new DealtDamageAndDiedTriggeredAbility(new GainLifeEffect(1), false);
Ability ability = new DealtDamageAndDiedTriggeredAbility(new GainLifeEffect(1), false, StaticFilters.FILTER_PERMANENT_CREATURE, SetTargetPointer.NONE);
Effect effect = new DamageTargetEffect(1);
effect.setText("and {this} deals 1 damage to target player");
ability.addEffect(effect);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
}
public AxelrodGunnarson(final AxelrodGunnarson card) {

View file

@ -3,7 +3,9 @@ package mage.abilities.common;
import mage.MageObjectReference;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.SetTargetPointer;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -13,23 +15,30 @@ import mage.target.targetpointer.FixedTarget;
public class DealtDamageAndDiedTriggeredAbility extends TriggeredAbilityImpl {
private final FilterCreaturePermanent filter;
protected SetTargetPointer setTargetPointer;
public DealtDamageAndDiedTriggeredAbility(Effect effect) {
this(effect, false);
}
public DealtDamageAndDiedTriggeredAbility(Effect effect, boolean optional) {
this(effect, optional, new FilterCreaturePermanent());
this(effect, optional, StaticFilters.FILTER_PERMANENT_CREATURE);
}
public DealtDamageAndDiedTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter) {
this(effect, optional, filter, SetTargetPointer.PERMANENT);
}
public DealtDamageAndDiedTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter, SetTargetPointer setTargetPointer) {
super(Zone.ALL, effect, optional);
this.filter = filter;
this.setTargetPointer = setTargetPointer;
}
public DealtDamageAndDiedTriggeredAbility(final DealtDamageAndDiedTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
this.setTargetPointer = ability.setTargetPointer;
}
@Override
@ -55,8 +64,10 @@ public class DealtDamageAndDiedTriggeredAbility extends TriggeredAbilityImpl {
}
}
if (damageDealt) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
if(this.setTargetPointer == SetTargetPointer.PERMANENT) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
}
}
return true;
}