use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class BlastZoneEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
int xValue = permanent.getCounters(game).getCount(CounterType.CHARGE);
FilterPermanent filter = new FilterNonlandPermanent();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
return new DestroyAllEffect(filter).apply(game, source);
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class LegacyOfTheBelovedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null) {
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
Permanent p = (Permanent) game.getLastKnownInformation(((SacrificeTargetCost) cost).getPermanents().get(0).getId(), Zone.BATTLEFIELD);
if (p != null) {
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, p.getManaValue()));
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, filter);
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.searchLibrary(target, source, game)) {
player.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
player.shuffleLibrary(source, game);
return true;
}
}
}
}
}
return false;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class LaviniaAzoriusRenegadeTriggeredAbility method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getPlayer(source.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
FilterCard filter = new FilterCard();
filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.MORE_THAN, getLandCount(source, event, game)));
Card card = game.getCard(event.getSourceId());
return card != null && filter.match(card, game);
}
return false;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class OrahSkyclaveHierophantTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent() || !zEvent.getTarget().isControlledBy(getControllerId()) || (!zEvent.getTarget().hasSubtype(SubType.CLERIC, game) && !zEvent.getTarget().getId().equals(getSourceId()))) {
return false;
}
FilterCard filterCard = new FilterCard("Cleric card with mana value less than " + (zEvent.getTarget().getManaValue()));
filterCard.add(SubType.CLERIC.getPredicate());
filterCard.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, zEvent.getTarget().getManaValue()));
this.getTargets().clear();
this.addTarget(new TargetCardInYourGraveyard(filterCard));
return true;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class PowderKegEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent == null) {
return false;
}
int count = sourcePermanent.getCounters(game).getCount(CounterType.FUSE);
FilterPermanent filter = new FilterPermanent();
filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, count));
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
perm.destroy(source, game, false);
}
return true;
}
Aggregations