use of mage.target.common.TargetCardInLibrary in project mage by magefree.
the class OathOfLiegesPredicate method apply.
@Override
public boolean apply(Game game, Ability source) {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer != null) {
if (activePlayer.chooseUse(outcome, "Search your library for a basic land card, put that card onto the battlefield, then shuffle?", source, game)) {
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), false, false, Outcome.PutLandInPlay, true);
effect.setTargetPointer(new FixedTarget(game.getActivePlayerId()));
return effect.apply(game, source);
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInLibrary in project mage by magefree.
the class PathToExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (controller != null && permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
// if the zone change to exile gets replaced does not prevent the target controller to be able to search
controller.moveCardToExileWithInfo(permanent, null, "", source, game, Zone.BATTLEFIELD, true);
if (player.chooseUse(Outcome.PutCardInPlay, "Search your library for a basic land card?", source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND);
if (player.searchLibrary(target, source, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
player.shuffleLibrary(source, game);
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInLibrary in project mage by magefree.
the class PrimeSpeakerVannifarEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sacrificedPermanent = null;
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
if (!sacrificeCost.getPermanents().isEmpty()) {
sacrificedPermanent = sacrificeCost.getPermanents().get(0);
}
break;
}
}
Player controller = game.getPlayer(source.getControllerId());
if (sacrificedPermanent == null || controller == null) {
return false;
}
int newConvertedCost = sacrificedPermanent.getManaValue() + 1;
FilterCard filter = new FilterCard("creature card with mana value " + newConvertedCost);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, newConvertedCost));
filter.add(CardType.CREATURE.getPredicate());
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, source, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
controller.shuffleLibrary(source, game);
return true;
}
use of mage.target.common.TargetCardInLibrary in project mage by magefree.
the class SchemingSymmetryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
source.getTargets().get(0).getTargets().stream().map(playerId -> game.getPlayer(playerId)).filter(player -> player != null).forEach(player -> {
TargetCardInLibrary targetCard = new TargetCardInLibrary();
if (player.searchLibrary(targetCard, source, game)) {
Cards cards = new CardsImpl();
cards.add(targetCard.getFirstTarget());
player.shuffleLibrary(source, game);
player.putCardsOnTopOfLibrary(cards, game, source, false);
}
});
return true;
}
use of mage.target.common.TargetCardInLibrary 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;
}
Aggregations