mirror of
https://github.com/correl/mage.git
synced 2025-01-13 11:01:58 +00:00
Added Filter to BecomesBlockedByCreatureTriggeredAbility
This commit is contained in:
parent
1f44b8cde1
commit
140d7e9376
1 changed files with 16 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue