use of mage.target.common.TargetCardInLibrary in project mage by magefree.
the class SeekEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(source.getFirstTarget());
Player player = game.getPlayer(source.getControllerId());
if (player != null && opponent != null) {
if (opponent.getLibrary().hasCards()) {
TargetCardInLibrary target = new TargetCardInLibrary();
if (player.searchLibrary(target, source, game, opponent.getId())) {
UUID targetId = target.getFirstTarget();
Card card = opponent.getLibrary().remove(targetId, game);
if (card != null) {
player.moveCardToExileWithInfo(card, null, null, source, game, Zone.LIBRARY, true);
int cmc = card.getManaValue();
if (cmc > 0) {
player.gainLife(cmc, game, source);
}
}
}
}
opponent.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.target.common.TargetCardInLibrary in project mage by magefree.
the class LightPawsEmperorsVoiceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent aura = (Permanent) getValue("permanentEnteringBattlefield");
if (player == null || aura == null || !player.chooseUse(outcome, "Search for an Aura?", source, game)) {
return false;
}
FilterCard filter = new FilterCard("Aura card with mana value less than or equal to " + aura.getManaValue());
filter.add(SubType.AURA.getPredicate());
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, aura.getManaValue() + 1));
filter.add(LightPawsEmperorsVoiceEffectPredicate.instance);
TargetCardInLibrary target = new TargetCardInLibrary(filter);
player.searchLibrary(target, source, game);
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (card != null && permanent != null && new AuraCardCanAttachToPermanentId(permanent.getId()).apply(card, game)) {
game.getState().setValue("attachTo:" + card.getId(), permanent);
player.moveCards(card, Zone.BATTLEFIELD, source, game);
permanent.addAttachment(card.getId(), source, game);
}
player.shuffleLibrary(source, game);
return true;
}
use of mage.target.common.TargetCardInLibrary in project mage by magefree.
the class MythosOfBrokkosEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
if (condition.apply(game, source)) {
TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary();
if (player.searchLibrary(targetCardInLibrary, source, game)) {
Card card = game.getCard(targetCardInLibrary.getFirstTarget());
if (card != null) {
player.moveCards(card, Zone.GRAVEYARD, source, game);
}
player.shuffleLibrary(source, game);
}
}
TargetCard targetCard = new TargetCardInYourGraveyard(0, 2, filter, true);
player.choose(outcome, player.getGraveyard(), targetCard, game);
Cards cards = new CardsImpl(targetCard.getTargets());
return player.moveCards(cards, Zone.HAND, source, game);
}
use of mage.target.common.TargetCardInLibrary in project mage by magefree.
the class OldGrowthDryadsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Set<Player> playersThatSearched = new HashSet<>(1);
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null && opponent.chooseUse(Outcome.PutLandInPlay, "Search your library for a basic land card and put it onto the battlefield tapped?", source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(new FilterBasicLandCard());
if (opponent.searchLibrary(target, source, game)) {
Card targetCard = opponent.getLibrary().getCard(target.getFirstTarget(), game);
if (targetCard != null) {
opponent.moveCards(targetCard, Zone.BATTLEFIELD, source, game, true, false, false, null);
playersThatSearched.add(opponent);
}
}
}
}
for (Player opponent : playersThatSearched) {
opponent.shuffleLibrary(source, game);
}
return true;
}
use of mage.target.common.TargetCardInLibrary in project mage by magefree.
the class ShigekiJukaiVisionaryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 4));
player.revealCards(source, cards, game);
TargetCard target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_LAND);
player.choose(outcome, cards, target, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
cards.remove(card);
}
player.moveCards(cards, Zone.GRAVEYARD, source, game);
return true;
}
Aggregations