use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class CelestialKirinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
if (spell != null) {
int cmc = spell.getManaValue();
FilterPermanent filter = new FilterPermanent();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc));
return new DestroyAllEffect(filter).apply(game, source);
}
return false;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class EnigmaticIncarnationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0 || !player.chooseUse(outcome, "Sacrifice an enchantment?", source, game)) {
return false;
}
TargetPermanent target = new TargetPermanent(0, 1, filter, true);
player.choose(outcome, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
return false;
}
game.getState().processAction(game);
int cmc = permanent.getManaValue();
if (!permanent.sacrifice(source, game)) {
return false;
}
FilterCard filterCard = new FilterCreatureCard("creature card with mana value " + (cmc + 1));
filterCard.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc + 1));
return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filterCard)).apply(game, source);
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class IsarethTheAwakenerReplacementEffect method makeFilter.
private static FilterCard makeFilter(int xValue) {
FilterCard filter = new FilterCreatureCard("creature card with mana value " + xValue + " or less from your graveyard");
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
return filter;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class MetathranAerostatEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int xValue = source.getManaCostsToPay().getX();
FilterCreatureCard filter = new FilterCreatureCard("a creature with mana value " + xValue);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
if (new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source)) {
return new ReturnToHandSourceEffect(true).apply(game, source);
}
return false;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class PrimeSpeakerVannifarEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sacrificedPermanent = null;
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
if (!sacrificeCost.getPermanents().isEmpty()) {
sacrificedPermanent = sacrificeCost.getPermanents().get(0);
}
break;
}
}
Player controller = game.getPlayer(source.getControllerId());
if (sacrificedPermanent == null || controller == null) {
return false;
}
int newConvertedCost = sacrificedPermanent.getManaValue() + 1;
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;
}
Aggregations