use of mage.filter.common.FilterLandCard in project mage by magefree.
the class NissaNaturesArtisanEffect 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;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 2));
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
Set<Card> toBattlefield = new LinkedHashSet<>();
for (Card card : cards.getCards(new FilterLandCard(), source.getSourceId(), source.getControllerId(), game)) {
cards.remove(card);
toBattlefield.add(card);
}
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null);
controller.moveCards(cards, Zone.HAND, source, game);
}
return true;
}
use of mage.filter.common.FilterLandCard in project mage by magefree.
the class SuddenReclamationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cardsToHand = new CardsImpl();
Target target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cardsToHand.add(card);
}
}
target = new TargetCardInYourGraveyard(new FilterLandCard("land card from your graveyard"));
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cardsToHand.add(card);
}
}
controller.moveCards(cardsToHand, Zone.HAND, source, game);
return true;
}
return false;
}
use of mage.filter.common.FilterLandCard in project mage by magefree.
the class PatronOfTheMoonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCard target = new TargetCardInHand(0, 2, new FilterLandCard("up to two land cards to put onto the battlefield tapped"));
controller.chooseTarget(outcome, controller.getHand(), target, source, game);
return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
}
return false;
}
use of mage.filter.common.FilterLandCard in project mage by magefree.
the class ScapeshiftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int amount = 0;
TargetControlledPermanent sacrificeLand = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledLandPermanent("lands you control"), true);
if (controller.chooseTarget(Outcome.Sacrifice, sacrificeLand, source, game)) {
for (UUID uuid : sacrificeLand.getTargets()) {
Permanent land = game.getPermanent(uuid);
if (land != null) {
land.sacrifice(source, game);
amount++;
}
}
}
TargetCardInLibrary target = new TargetCardInLibrary(amount, new FilterLandCard("lands"));
if (controller.searchLibrary(target, source, game)) {
controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
return false;
}
use of mage.filter.common.FilterLandCard in project mage by magefree.
the class SameNameAsExiledCountValue method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(new FilterLandCard());
if (player.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
UUID cardId = target.getTargets().get(0);
Card card = player.getLibrary().remove(cardId, game);
if (card != null) {
card.moveToExile(source.getSourceId(), "Strata Scythe", source, game);
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.imprint(card.getId(), game);
}
}
}
}
player.shuffleLibrary(source, game);
return true;
}
Aggregations