use of mage.filter.common.FilterPermanentCard in project mage by magefree.
the class MatterReshaperEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
controller.revealCards(source, new CardsImpl(card), game);
FilterPermanentCard filter = new FilterPermanentCard("permanent card with mana value 3 or less");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 4));
if (filter.match(card, game)) {
if (controller.chooseUse(Outcome.PutCardInPlay, "Put " + card.getName() + " onto the battlefield (otherwise put in hand)?", source, game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
return true;
}
}
controller.moveCards(card, Zone.HAND, source, game);
return true;
}
return false;
}
use of mage.filter.common.FilterPermanentCard in project mage by magefree.
the class MinnWilyIllusionistEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = (Permanent) getValue("creatureDied");
if (player == null || permanent == null) {
return false;
}
FilterCard filterCard = new FilterPermanentCard("permanent card with mana value " + permanent.getPower().getValue() + " or less");
filterCard.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, permanent.getPower().getValue() + 1));
TargetCardInHand target = new TargetCardInHand(0, 1, filterCard);
player.choose(Outcome.PutCardInPlay, player.getHand(), target, game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
return player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
use of mage.filter.common.FilterPermanentCard in project mage by magefree.
the class SisayWeatherlightCaptainEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (permanent == null) {
return false;
}
int power = permanent.getPower().getValue();
FilterCard filter = new FilterPermanentCard("legendary permanent card with mana value less than " + power);
filter.add(SuperType.LEGENDARY.getPredicate());
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, power));
return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)).apply(game, source);
}
use of mage.filter.common.FilterPermanentCard in project mage by magefree.
the class InSearchOfGreatnessEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int cmc = 0;
UUID permId = source.getSourceId();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controller.getId())) {
if (permanent != null && !permanent.getId().equals(permId)) {
int permCmc = permanent.getManaValue();
if (permCmc > cmc) {
cmc = permCmc;
}
}
}
if (controller.chooseUse(outcome, "Cast a permanent spell from your hand with CMC equal to " + ++cmc + "?", source, game)) {
FilterPermanentCard filter = new FilterPermanentCard("permanent spell from your hand");
filter.add(Predicates.not(CardType.LAND.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc));
TargetCardInHand target = new TargetCardInHand(filter);
if (controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
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);
if (cardWasCast) {
return true;
}
}
}
}
return controller.scry(1, source, game);
}
use of mage.filter.common.FilterPermanentCard in project mage by magefree.
the class LonisCryptozoologistEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && opponent != null) {
int xValue = GetXValue.instance.calculate(game, source, this);
Cards cards = new CardsImpl(opponent.getLibrary().getTopCards(game, xValue));
opponent.revealCards(source, cards, game);
if (controller.chooseUse(outcome, "Put a nonland permanent card with mana value " + xValue + " or less from among revealed cards onto the battlefield under your control?", source, game)) {
FilterPermanentCard filter = new FilterPermanentCard("nonland permanent card with mana value " + xValue + " or less");
filter.add(Predicates.not(CardType.LAND.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
if (controller.choose(outcome, cards, target, game)) {
Card selectedCard = game.getCard(target.getFirstTarget());
if (selectedCard != null) {
cards.remove(selectedCard);
controller.moveCards(selectedCard, Zone.BATTLEFIELD, source, game);
}
}
}
opponent.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
return false;
}
Aggregations