use of mage.filter.predicate.mageobject.MageObjectReferencePredicate in project mage by magefree.
the class RadiantPerformerEffect method prepareCopiesWithTargets.
@Override
protected List<MageObjectReferencePredicate> prepareCopiesWithTargets(StackObject stackObject, Player player, Ability source, Game game) {
List<MageObjectReferencePredicate> predicates = new ArrayList<>();
Ability ability = stackObject instanceof Spell ? ((Spell) stackObject).getSpellAbility() : (StackAbility) stackObject;
UUID targeted = ability == null ? null : ability.getModes().values().stream().map(Mode::getTargets).flatMap(Collection::stream).map(Target::getTargets).flatMap(Collection::stream).filter(Objects::nonNull).findAny().orElse(null);
game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, player.getId(), source.getSourceId(), game).stream().filter(Objects::nonNull).filter(p -> !p.equals(game.getPermanent(targeted))).filter(p -> stackObject.canTarget(game, p.getId())).map(p -> new MageObjectReference(p, game)).map(MageObjectReferencePredicate::new).forEach(predicates::add);
game.getState().getPlayersInRange(source.getControllerId(), game).stream().filter(uuid -> !uuid.equals(targeted)).filter(uuid -> stackObject.canTarget(game, uuid)).map(MageObjectReference::new).map(MageObjectReferencePredicate::new).forEach(predicates::add);
return predicates;
}
use of mage.filter.predicate.mageobject.MageObjectReferencePredicate in project mage by magefree.
the class MoorlandRescuerTarget method makeFilter.
private static FilterCard makeFilter(int xValue, Ability source, Game game) {
FilterCard filter = new FilterCreatureCard("creature cards with total power " + xValue + " or less from your graveyard");
filter.add(Predicates.not(new MageObjectReferencePredicate(source.getSourceObject(game), game)));
return filter;
}
use of mage.filter.predicate.mageobject.MageObjectReferencePredicate in project mage by magefree.
the class CopySpellForEachItCouldTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player actingPlayer = getPlayer(game, source);
StackObject stackObject = getStackObject(game, source);
if (actingPlayer == null || stackObject == null) {
return false;
}
List<MageObjectReferencePredicate> copies = prepareCopiesWithTargets(stackObject, actingPlayer, source, game);
stackObject.createCopyOnStack(game, source, actingPlayer.getId(), false, copies.size(), new ForEachCopyApplier(copies));
return true;
}
use of mage.filter.predicate.mageobject.MageObjectReferencePredicate in project mage by magefree.
the class CrownOfFuryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// Enchanted creature ...
ContinuousEffect effect = new BoostEnchantedEffect(1, 0, Duration.EndOfTurn);
game.addEffect(effect, source);
effect = new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.AURA, Duration.EndOfTurn);
game.addEffect(effect, source);
// ... and other creatures that share a creature type with it ...
Permanent enchantedCreature = game.getPermanent(source.getSourcePermanentOrLKI(game).getAttachedTo());
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new CrownOfFuryPredicate(enchantedCreature));
filter.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(enchantedCreature, game))));
game.addEffect(new BoostAllEffect(1, 0, Duration.EndOfTurn, filter, false), source);
game.addEffect(new GainAbilityAllEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, filter), source);
// ... get +1/+0 and gain first strike until end of turn.
return true;
}
use of mage.filter.predicate.mageobject.MageObjectReferencePredicate in project mage by magefree.
the class CrownOfAweEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// Enchanted creature
ContinuousEffect effect = new GainAbilityAttachedEffect(ProtectionAbility.from(ObjectColor.BLACK, ObjectColor.RED), AttachmentType.AURA, Duration.EndOfTurn);
game.addEffect(effect, source);
// and other creatures that share a creature type with it
Permanent enchantedCreature = game.getPermanent(source.getSourcePermanentOrLKI(game).getAttachedTo());
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new CrownOfAwePredicate(enchantedCreature));
filter.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(enchantedCreature, game))));
game.addEffect(effect, source);
// have protection from black and from red until end of turn.
return true;
}
Aggregations