Added Filter to BecomesBlockedByCreatureTriggeredAbility

This commit is contained in:
wetterlicht 2016-05-16 22:57:28 +02:00
parent 1f44b8cde1
commit 140d7e9376

View file

@ -30,8 +30,10 @@ package mage.abilities.common;
import mage.constants.Zone;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
@ -40,10 +42,17 @@ import mage.target.targetpointer.FixedTarget;
*/
public class BecomesBlockedByCreatureTriggeredAbility extends TriggeredAbilityImpl {
private static FilterCreaturePermanent filter = new FilterCreaturePermanent();
public BecomesBlockedByCreatureTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
}
public BecomesBlockedByCreatureTriggeredAbility(Effect effect, FilterCreaturePermanent filter, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
this.filter = filter;
}
public BecomesBlockedByCreatureTriggeredAbility(final BecomesBlockedByCreatureTriggeredAbility ability) {
super(ability);
}
@ -56,17 +65,20 @@ public class BecomesBlockedByCreatureTriggeredAbility extends TriggeredAbilityIm
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.getSourceId())) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getSourceId()));
Permanent blocker = game.getPermanent(event.getSourceId());
if (filter.match(blocker, game)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getSourceId()));
}
return true;
}
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever {this} becomes blocked by a creature, " + super.getRule();
return "Whenever {this} becomes blocked by a " + filter.getMessage() + ", " + super.getRule();
}
@Override