mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
[filters] added BlockedPredicate
This commit is contained in:
parent
99166a9d19
commit
61b5f8555e
2 changed files with 17 additions and 29 deletions
|
|
@ -32,8 +32,8 @@ import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.common.FilterBlockedCreature;
|
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.BlockedPredicate;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,7 +42,11 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
*/
|
*/
|
||||||
public class Smite extends CardImpl<Smite> {
|
public class Smite extends CardImpl<Smite> {
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter = new FilterBlockedCreature();
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("blocked creature");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(new BlockedPredicate());
|
||||||
|
}
|
||||||
|
|
||||||
public Smite(UUID ownerId) {
|
public Smite(UUID ownerId) {
|
||||||
super(ownerId, 43, "Smite", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{W}");
|
super(ownerId, 43, "Smite", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{W}");
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,9 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
package mage.filter.common;
|
package mage.filter.predicate.permanent;
|
||||||
|
|
||||||
|
import mage.filter.predicate.Predicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.combat.CombatGroup;
|
import mage.game.combat.CombatGroup;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
@ -35,37 +36,20 @@ import mage.game.permanent.Permanent;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class FilterBlockedCreature extends FilterCreaturePermanent {
|
public class BlockedPredicate implements Predicate<Permanent> {
|
||||||
|
|
||||||
public FilterBlockedCreature() {
|
|
||||||
this("blocked creature");
|
|
||||||
}
|
|
||||||
|
|
||||||
public FilterBlockedCreature(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FilterBlockedCreature(final FilterBlockedCreature filter) {
|
|
||||||
super(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FilterBlockedCreature copy() {
|
public boolean apply(Permanent input, Game game) {
|
||||||
return new FilterBlockedCreature(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean match(Permanent permanent, Game game) {
|
|
||||||
if (!super.match(permanent, game)) {
|
|
||||||
return notFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
|
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
|
||||||
if (!combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(permanent.getId())) {
|
if (!combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(input.getId())) {
|
||||||
return !notFilter;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return notFilter;
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Blocked";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue