mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
add helper method for creating filters which only select from a collection of permanents
This commit is contained in:
parent
747e4e5569
commit
fda43021a4
12 changed files with 27 additions and 96 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
package mage.cards.b;
|
package mage.cards.b;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageItem;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -16,7 +15,6 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
@ -28,7 +26,6 @@ import mage.util.RandomUtil;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TheElk801
|
* @author TheElk801
|
||||||
|
|
@ -114,13 +111,7 @@ class BenthicAnomalyEffect extends OneShotEffect {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FilterPermanent filter = new FilterPermanent("a creature to create a copy of");
|
FilterPermanent filter = new FilterPermanent("a creature to create a copy of");
|
||||||
filter.add(Predicates.or(
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(permanents));
|
||||||
permanents
|
|
||||||
.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toSet())
|
|
||||||
));
|
|
||||||
TargetPermanent target = new TargetPermanent(filter);
|
TargetPermanent target = new TargetPermanent(filter);
|
||||||
target.withNotTarget(true);
|
target.withNotTarget(true);
|
||||||
player.choose(outcome, target, source, game);
|
player.choose(outcome, target, source, game);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import mage.MageItem;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.keyword.ConniveSourceEffect;
|
import mage.abilities.effects.keyword.ConniveSourceEffect;
|
||||||
|
|
@ -9,7 +8,6 @@ import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
@ -83,13 +81,7 @@ class ChangeOfPlansEffect extends OneShotEffect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
FilterPermanent filter = new FilterPermanent("creatures");
|
FilterPermanent filter = new FilterPermanent("creatures");
|
||||||
filter.add(Predicates.or(
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(permanents));
|
||||||
permanents
|
|
||||||
.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toSet())
|
|
||||||
));
|
|
||||||
TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
|
TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
|
||||||
player.choose(outcome, target.withChooseHint("to phase out"), source, game);
|
player.choose(outcome, target.withChooseHint("to phase out"), source, game);
|
||||||
for (UUID targetId : target.getTargets()) {
|
for (UUID targetId : target.getTargets()) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.cards.e;
|
package mage.cards.e;
|
||||||
|
|
||||||
import mage.MageItem;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
|
@ -10,7 +9,6 @@ import mage.constants.Outcome;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
@ -102,11 +100,7 @@ class ExoticPetsEffect extends OneShotEffect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
FilterPermanent filter = new FilterPermanent("creature");
|
FilterPermanent filter = new FilterPermanent("creature");
|
||||||
filter.add(Predicates.or(permanents
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(permanents));
|
||||||
.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toSet())));
|
|
||||||
TargetPermanent target = new TargetPermanent(filter);
|
TargetPermanent target = new TargetPermanent(filter);
|
||||||
target.withNotTarget(true);
|
target.withNotTarget(true);
|
||||||
for (CounterType counterType : counterTypes) {
|
for (CounterType counterType : counterTypes) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.cards.f;
|
package mage.cards.f;
|
||||||
|
|
||||||
import mage.MageItem;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||||
|
|
@ -13,7 +12,6 @@ import mage.constants.Outcome;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.FilterSpell;
|
import mage.filter.FilterSpell;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.mageobject.MageObjectReferencePredicate;
|
import mage.filter.predicate.mageobject.MageObjectReferencePredicate;
|
||||||
import mage.filter.predicate.other.HasOnlySingleTargetPermanentPredicate;
|
import mage.filter.predicate.other.HasOnlySingleTargetPermanentPredicate;
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
|
|
@ -125,13 +123,7 @@ class FrontlineHeroismEffect extends OneShotEffect {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FilterPermanent filter = new FilterPermanent("token to target with the copied spell");
|
FilterPermanent filter = new FilterPermanent("token to target with the copied spell");
|
||||||
filter.add(Predicates.or(
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(permanents));
|
||||||
permanents
|
|
||||||
.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toSet())
|
|
||||||
));
|
|
||||||
TargetPermanent target = new TargetPermanent(filter);
|
TargetPermanent target = new TargetPermanent(filter);
|
||||||
target.withNotTarget(true);
|
target.withNotTarget(true);
|
||||||
player.choose(outcome, target, source, game);
|
player.choose(outcome, target, source, game);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageItem;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility;
|
||||||
import mage.abilities.common.delayed.ReflexiveTriggeredAbility;
|
import mage.abilities.common.delayed.ReflexiveTriggeredAbility;
|
||||||
|
|
@ -14,7 +13,6 @@ import mage.constants.*;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
@ -165,13 +163,7 @@ class GilgameshMasterAtArmsAttachEffect extends OneShotEffect {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
FilterPermanent filterPermanent = new FilterPermanent("Equipment");
|
FilterPermanent filterPermanent = new FilterPermanent("Equipment");
|
||||||
Predicates.or(
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(permanents));
|
||||||
permanents
|
|
||||||
.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toSet())
|
|
||||||
);
|
|
||||||
return Optional
|
return Optional
|
||||||
.of(new TargetPermanent(0, 1, filterPermanent, true))
|
.of(new TargetPermanent(0, 1, filterPermanent, true))
|
||||||
.map(t -> {
|
.map(t -> {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.cards.h;
|
package mage.cards.h;
|
||||||
|
|
||||||
import mage.MageItem;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
|
@ -16,7 +15,6 @@ import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.mageobject.NamePredicate;
|
import mage.filter.predicate.mageobject.NamePredicate;
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Controllable;
|
import mage.game.Controllable;
|
||||||
|
|
@ -120,12 +118,7 @@ class HelmOfKaldraEffect extends OneShotEffect {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FilterPermanent filter = new FilterPermanent();
|
FilterPermanent filter = new FilterPermanent();
|
||||||
filter.add(Predicates.or(
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(permanents));
|
||||||
permanents.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toSet())
|
|
||||||
));
|
|
||||||
TargetPermanent target = new TargetPermanent(filter);
|
TargetPermanent target = new TargetPermanent(filter);
|
||||||
target.withNotTarget(true);
|
target.withNotTarget(true);
|
||||||
target.withChooseHint("to equip");
|
target.withChooseHint("to equip");
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.cards.n;
|
package mage.cards.n;
|
||||||
|
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.LoyaltyAbility;
|
import mage.abilities.LoyaltyAbility;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
|
|
@ -119,12 +118,7 @@ class NahiriHeirOfTheAncientsEffect extends OneShotEffect {
|
||||||
Permanent tokenCreature = tokens.get(0);
|
Permanent tokenCreature = tokens.get(0);
|
||||||
if (tokens.size() > 1) {
|
if (tokens.size() > 1) {
|
||||||
FilterPermanent tokenFilter = new FilterPermanent("token");
|
FilterPermanent tokenFilter = new FilterPermanent("token");
|
||||||
tokenFilter.add(Predicates.or(
|
tokenFilter.add(PermanentIdPredicate.makeCompoundPredicate(tokens));
|
||||||
tokens.stream()
|
|
||||||
.map(MageObject::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toSet())
|
|
||||||
));
|
|
||||||
TargetPermanent target = new TargetPermanent(tokenFilter);
|
TargetPermanent target = new TargetPermanent(tokenFilter);
|
||||||
target.withNotTarget(true);
|
target.withNotTarget(true);
|
||||||
player.choose(outcome, target, source, game);
|
player.choose(outcome, target, source, game);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.cards.r;
|
package mage.cards.r;
|
||||||
|
|
||||||
import mage.MageItem;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
|
@ -10,7 +9,6 @@ import mage.constants.Outcome;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
@ -90,12 +88,7 @@ class RetributionEffect extends OneShotEffect {
|
||||||
.map(game::getPlayer)
|
.map(game::getPlayer)
|
||||||
.map(player -> {
|
.map(player -> {
|
||||||
FilterPermanent filter = new FilterPermanent();
|
FilterPermanent filter = new FilterPermanent();
|
||||||
filter.add(Predicates.or(
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(canSac));
|
||||||
canSac.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
));
|
|
||||||
TargetPermanent target = new TargetPermanent(filter);
|
TargetPermanent target = new TargetPermanent(filter);
|
||||||
target.withNotTarget(true);
|
target.withNotTarget(true);
|
||||||
player.choose(Outcome.Sacrifice, target, source, game);
|
player.choose(Outcome.Sacrifice, target, source, game);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.cards.w;
|
package mage.cards.w;
|
||||||
|
|
||||||
import mage.MageItem;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.TapTargetEffect;
|
import mage.abilities.effects.common.TapTargetEffect;
|
||||||
|
|
@ -12,7 +11,6 @@ import mage.constants.Outcome;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
@ -87,13 +85,7 @@ class WickedSlumberEffect extends OneShotEffect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
FilterPermanent filter = new FilterCreaturePermanent();
|
FilterPermanent filter = new FilterCreaturePermanent();
|
||||||
filter.add(Predicates.or(
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(permanents));
|
||||||
permanents
|
|
||||||
.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
));
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
TargetPermanent target = new TargetPermanent(filter);
|
TargetPermanent target = new TargetPermanent(filter);
|
||||||
target.withNotTarget(true);
|
target.withNotTarget(true);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import mage.constants.SubType;
|
||||||
import mage.constants.SuperType;
|
import mage.constants.SuperType;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Controllable;
|
import mage.game.Controllable;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
@ -117,13 +116,7 @@ class ZackFairEffect extends OneShotEffect {
|
||||||
FilterPermanent filter = new FilterPermanent(
|
FilterPermanent filter = new FilterPermanent(
|
||||||
SubType.EQUIPMENT, "Equipment to attach to " + creature.getIdName()
|
SubType.EQUIPMENT, "Equipment to attach to " + creature.getIdName()
|
||||||
);
|
);
|
||||||
filter.add(Predicates.or(
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(permanents));
|
||||||
permanents
|
|
||||||
.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
));
|
|
||||||
TargetPermanent target = new TargetPermanent(filter);
|
TargetPermanent target = new TargetPermanent(filter);
|
||||||
target.withNotTarget(true);
|
target.withNotTarget(true);
|
||||||
Optional.ofNullable(source)
|
Optional.ofNullable(source)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
import mage.MageItem;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
@ -76,13 +74,7 @@ public class CreateTokenAttachSourceEffect extends CreateTokenEffect {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FilterPermanent filter = new FilterPermanent("token");
|
FilterPermanent filter = new FilterPermanent("token");
|
||||||
filter.add(Predicates.or(
|
filter.add(PermanentIdPredicate.makeCompoundPredicate(permanents));
|
||||||
permanents
|
|
||||||
.stream()
|
|
||||||
.map(MageItem::getId)
|
|
||||||
.map(PermanentIdPredicate::new)
|
|
||||||
.collect(Collectors.toSet())
|
|
||||||
));
|
|
||||||
TargetPermanent target = new TargetPermanent(filter);
|
TargetPermanent target = new TargetPermanent(filter);
|
||||||
target.withNotTarget(true);
|
target.withNotTarget(true);
|
||||||
target.withChooseHint("to attach to");
|
target.withChooseHint("to attach to");
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
|
|
||||||
package mage.filter.predicate.permanent;
|
package mage.filter.predicate.permanent;
|
||||||
|
|
||||||
import java.util.UUID;
|
import mage.MageItem;
|
||||||
import mage.filter.predicate.Predicate;
|
import mage.filter.predicate.Predicate;
|
||||||
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class PermanentIdPredicate implements Predicate<Permanent> {
|
public class PermanentIdPredicate implements Predicate<Permanent> {
|
||||||
|
|
@ -27,4 +30,14 @@ public class PermanentIdPredicate implements Predicate<Permanent> {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PermanentId(" + permanentId + ')';
|
return "PermanentId(" + permanentId + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Predicate<Permanent> makeCompoundPredicate(Collection<Permanent> permanents) {
|
||||||
|
return Predicates.or(
|
||||||
|
permanents
|
||||||
|
.stream()
|
||||||
|
.map(MageItem::getId)
|
||||||
|
.map(PermanentIdPredicate::new)
|
||||||
|
.collect(Collectors.toSet())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue