use of mage.filter.common.FilterPermanentCard in project mage by magefree.
the class PackHuntEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
FilterCard filter = new FilterPermanentCard();
filter.add(new NamePredicate(permanent.getName()));
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 3, filter), true).apply(game, source);
}
use of mage.filter.common.FilterPermanentCard in project mage by magefree.
the class LinSivviDefiantHeroEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int xCost = source.getManaCostsToPay().getX();
FilterPermanentCard filter = new FilterPermanentCard("Rebel permanent card with mana value " + xCost + " or less");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xCost + 1));
filter.add(SubType.REBEL.getPredicate());
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;
}
use of mage.filter.common.FilterPermanentCard in project mage by magefree.
the class ChaosWarpRevealEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
if (permanent == null) {
return false;
}
Player owner = game.getPlayer(permanent.getOwnerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (owner == null || sourceObject == null) {
return false;
}
if (owner.getLibrary().hasCards()) {
Card card = owner.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);
owner.revealCards(sourceObject.getIdName(), cards, game);
if (new FilterPermanentCard().match(card, game)) {
owner.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
return true;
}
use of mage.filter.common.FilterPermanentCard in project mage by magefree.
the class AidFromTheCowlEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
Cards cards = new CardsImpl(card);
controller.revealCards(sourceObject.getIdName(), cards, game);
if (card != null) {
if (new FilterPermanentCard().match(card, game) && controller.chooseUse(Outcome.Neutral, "Put " + card.getIdName() + " onto the battlefield?", source, game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else if (controller.chooseUse(Outcome.Neutral, "Put " + card.getIdName() + " on the bottom of your library?", source, game)) {
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
} else {
game.informPlayers(controller.getLogName() + " puts the revealed card back to the top of the library.");
}
}
}
return true;
}
Aggregations