use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class CitanulFluteSearchEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
FilterCard filter = new FilterCreatureCard("creature card with mana value X or less");
// Set the mana cost one higher to 'emulate' a less than or equal to comparison.
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
player.searchLibrary(target, source, game);
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.revealCards(source, new CardsImpl(card), game);
player.moveCards(card, Zone.HAND, source, game);
}
player.shuffleLibrary(source, game);
return true;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class BloodOnTheSnowEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int snow = ManaPaidSourceWatcher.getSnowPaid(source.getId(), game);
FilterCard filter = new FilterCard("a creature or planeswalker card with mana value " + snow + " or less from your graveyard");
filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.PLANESWALKER.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, snow + 1));
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(1, 1, filter, true);
controller.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
return true;
}
}
return false;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class HasLowestCMCAmongstNonlandPermanentsPredicate method apply.
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
FilterPermanent filter = new FilterNonlandPermanent();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, input.getObject().getManaValue()));
return !game.getBattlefield().contains(filter, input.getSourceId(), input.getPlayerId(), game, 1);
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class BringToLightEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int numberColors = ColorsOfManaSpentToCastCount.getInstance().calculate(game, source, this);
FilterCard filter = new FilterCard("a creature, instant, or sorcery card with mana value " + "less than or equal to " + numberColors);
filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.INSTANT.getPredicate(), CardType.SORCERY.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, numberColors + 1));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
controller.searchLibrary(target, source, game);
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
}
controller.shuffleLibrary(source, game);
if (card != null) {
if (controller.chooseUse(Outcome.PlayForFree, "Cast " + card.getName() + " without paying its mana cost?", source, game)) {
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);
}
}
return true;
}
return false;
}
Aggregations