forked from External/mage
Fixed #11491
This commit is contained in:
parent
cd2ac9e8d8
commit
9131347698
4 changed files with 47 additions and 6 deletions
|
|
@ -7,6 +7,7 @@ import mage.game.Game;
|
|||
import mage.game.stack.StackObject;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.filter.predicate.other.ActivatedOrTriggeredAbilityPredicate;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
|
@ -15,6 +16,7 @@ public class FilterActivatedOrTriggeredAbility extends FilterStackObject {
|
|||
|
||||
public FilterActivatedOrTriggeredAbility() {
|
||||
this("activated or triggered ability");
|
||||
this.add(ActivatedOrTriggeredAbilityPredicate.instance); // this predicate is required to work correctly on the stack
|
||||
}
|
||||
|
||||
public FilterActivatedOrTriggeredAbility(String name) {
|
||||
|
|
@ -27,7 +29,9 @@ public class FilterActivatedOrTriggeredAbility extends FilterStackObject {
|
|||
|
||||
@Override
|
||||
public boolean match(StackObject stackObject, UUID playerId, Ability source, Game game) {
|
||||
if (!super.match(stackObject, playerId, source, game) || !(stackObject instanceof Ability)) {
|
||||
|
||||
if (!super.match(stackObject, playerId, source, game)
|
||||
|| !(stackObject instanceof Ability)) {
|
||||
return false;
|
||||
}
|
||||
Ability ability = (Ability) stackObject;
|
||||
|
|
@ -37,7 +41,9 @@ public class FilterActivatedOrTriggeredAbility extends FilterStackObject {
|
|||
|
||||
@Override
|
||||
public boolean match(StackObject stackObject, Game game) {
|
||||
if (!super.match(stackObject, game) || !(stackObject instanceof Ability)) {
|
||||
|
||||
if (!super.match(stackObject, game)
|
||||
|| !(stackObject instanceof Ability)) {
|
||||
return false;
|
||||
}
|
||||
Ability ability = (Ability) stackObject;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package mage.filter.predicate.other;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public enum ActivatedOrTriggeredAbilityPredicate implements Predicate<StackObject> {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(StackObject input, Game game) {
|
||||
if (!(input instanceof Ability)) {
|
||||
return false;
|
||||
}
|
||||
Ability ability = ((Ability) input);
|
||||
return ability.getAbilityType() == AbilityType.TRIGGERED
|
||||
|| ability.getAbilityType() == AbilityType.ACTIVATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "an activated or triggered ability";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue