use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class SoulstealerAxeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int damage = (Integer) getValue("damage");
FilterCard filter = new FilterCard();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, damage));
return player.seekCard(filter, source, game);
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class WaveOfTerrorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (permanent == null) {
return false;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, permanent.getCounters(game).getCount(CounterType.AGE)));
return new DestroyAllEffect(filter, true).apply(game, source);
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class CastWithoutPayingManaCostEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int cmc = manaCost.calculate(game, source, this);
FilterCard filter = this.filter.copy();
filter.setMessage(filter.getMessage().replace("%mv", "" + cmc));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, cmc + 1));
Target target = new TargetCardInHand(filter);
if (!target.canChoose(source.getSourceId(), controller.getId(), game) || !controller.chooseUse(Outcome.PlayForFree, "Cast " + CardUtil.addArticle(filter.getMessage()) + " without paying its mana cost?", source, game)) {
return true;
}
Card cardToCast = null;
boolean cancel = false;
while (controller.canRespond() && !cancel) {
if (controller.chooseTarget(Outcome.PlayForFree, target, source, game)) {
cardToCast = game.getCard(target.getFirstTarget());
if (cardToCast != null) {
if (cardToCast.getSpellAbility() == null) {
Logger.getLogger(CastWithoutPayingManaCostEffect.class).fatal("Card: " + cardToCast.getName() + " is no land and has no spell ability!");
cancel = true;
}
if (cardToCast.getSpellAbility().canChooseTarget(game, controller.getId())) {
cancel = true;
}
}
} else {
cancel = true;
}
}
if (cardToCast != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + cardToCast.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(cardToCast, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + cardToCast.getId(), null);
}
return true;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class CryptChampionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Set<Card> toBattlefield = new HashSet<>();
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterCard filter = new FilterCreatureCard("creature card with mana value 3 or less from your graveyard");
filter.add(new OwnerIdPredicate(playerId));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 4));
Target target = new TargetCardInGraveyard(filter);
if (target.canChoose(source.getSourceId(), playerId, game) && player.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
toBattlefield.add(card);
}
}
}
}
// must happen simultaneously Rule 101.4
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null);
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.
the class HammerMageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterArtifactPermanent filter = new FilterArtifactPermanent();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
permanent.destroy(source, game, false);
}
return true;
}
Aggregations