use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class SisayWeatherlightCaptainEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (permanent == null) {
return false;
}
int power = permanent.getPower().getValue();
FilterCard filter = new FilterPermanentCard("legendary permanent card with mana value less than " + power);
filter.add(SuperType.LEGENDARY.getPredicate());
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, power));
return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)).apply(game, source);
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class SphereOfAnnihilationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (player == null || permanent == null) {
return false;
}
Cards cards = new CardsImpl(permanent);
int counters = permanent.getCounters(game).getCount(CounterType.VOID);
FilterPermanent filter = StaticFilters.FILTER_PERMANENT_CREATURE_OR_PLANESWALKER.copy();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, counters + 1));
cards.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game));
game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).map(g -> g.getCards(game)).flatMap(Collection::stream).filter(card -> card.isCreature(game) || card.isPlaneswalker(game)).filter(card -> card.getManaValue() <= counters).forEach(cards::add);
return player.moveCards(cards, Zone.EXILED, source, game);
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class VenarianGlimmerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
FilterCard filter = new FilterNonlandCard();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
Effect effect = new DiscardCardYouChooseTargetEffect(filter, TargetController.ANY);
effect.setTargetPointer(targetPointer);
effect.apply(game, source);
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class VelomachusLoreholdEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (controller == null || permanent == null) {
return false;
}
Set<Card> cardsSet = controller.getLibrary().getTopCards(game, 7);
Cards cards = new CardsImpl(cardsSet);
FilterCard filter = new FilterInstantOrSorceryCard("instant or sorcery card with mana value " + permanent.getPower().getValue() + " or less");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, permanent.getPower().getValue() + 1));
TargetCard target = new TargetCardInLibrary(0, 1, filter);
controller.choose(Outcome.PlayForFree, cards, target, game);
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card == null) {
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
if (cardWasCast) {
cards.remove(card);
}
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class YisanTheWandererBardEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && controller != null) {
int newConvertedCost = sourcePermanent.getCounters(game).getCount(CounterType.VERSE);
FilterCard filter = new FilterCard("creature card with mana value " + newConvertedCost);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, newConvertedCost));
filter.add(CardType.CREATURE.getPredicate());
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, source, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
Aggregations