use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class MausoleumSecretsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int critterCount = player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, game);
FilterCard filter = new FilterCard("a black card with mana value less than or equal to " + critterCount);
filter.add(new ColorPredicate(ObjectColor.BLACK));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, critterCount + 1));
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true).apply(game, source);
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class NissaStewardOfElementsToken method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int count = 1 + new CountersSourceCount(CounterType.LOYALTY).calculate(game, source, this);
FilterPermanentCard filter = new FilterPermanentCard();
filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.LAND.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, count));
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.lookAtCards(source, null, new CardsImpl(card), game);
if (filter.match(card, game)) {
if (controller.chooseUse(outcome, "Put " + card.getName() + " onto the battlefield?", source, game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
return true;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class PerniciousDeedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterPermanent filter = new FilterPermanent("artifacts, creatures, and enchantments");
filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate(), CardType.ENCHANTMENT.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
return new DestroyAllEffect(filter).apply(game, source);
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class CardCanBeCastPredicate method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.getLibrary().hasCards()) {
/**
* 10/1/2005 Any card you find must be legally cast-able (for
* example, you have to be able to choose a legal target for
* it). If you can't find a cast-able card (or choose not to),
* nothing happens and you shuffle your library.
*/
FilterCard filter = new FilterCard("red or white instant card with mana value 4 or less");
TargetCardInLibrary target = new TargetCardInLibrary(filter);
filter.add(Predicates.or(new ColorPredicate(ObjectColor.RED), new ColorPredicate(ObjectColor.WHITE)));
filter.add(CardType.INSTANT.getPredicate());
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 5));
filter.add(new CardCanBeCastPredicate(source.getControllerId()));
if (controller.searchLibrary(target, source, game, controller.getId())) {
UUID targetId = target.getFirstTarget();
Card card = game.getCard(targetId);
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
}
}
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class TezzeretTheSeekerEffect3 method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int cmc = 0;
for (Cost cost : source.getCosts()) {
if (cost instanceof PayVariableLoyaltyCost) {
cmc = ((PayVariableLoyaltyCost) cost).getAmount();
}
}
FilterArtifactCard filter = new FilterArtifactCard("artifact card with mana value " + cmc + " or less");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, cmc + 1));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, source, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
return false;
}
Aggregations