use of mage.filter.FilterCard in project mage by magefree.
the class ShroudedLoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
if (you != null && opponent != null) {
FilterCard filter = new FilterCard();
filter.add(new OwnerIdPredicate(you.getId()));
Cost cost = new ManaCostsImpl("{B}");
TargetCardInGraveyard chosenCard;
Card card = null;
boolean done = false;
do {
chosenCard = new TargetCardInGraveyard(filter);
chosenCard.setNotTarget(true);
if (chosenCard.canChoose(source.getSourceId(), opponent.getId(), game)) {
opponent.chooseTarget(Outcome.ReturnToHand, chosenCard, source, game);
card = game.getCard(chosenCard.getFirstTarget());
if (card != null) {
filter.add(Predicates.not(new CardIdPredicate(card.getId())));
game.informPlayers("Shrouded Lore: " + opponent.getLogName() + " has chosen " + card.getLogName());
}
} else {
done = true;
}
if (!done) {
done = true;
if (cost.canPay(source, source, you.getId(), game) && you.chooseUse(Outcome.Benefit, "Pay {B} to choose a different card ?", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, you.getId(), false, null)) {
done = false;
}
}
}
} while (!done);
if (card != null) {
Cards cardsToHand = new CardsImpl();
cardsToHand.add(card);
you.moveCards(cardsToHand, Zone.HAND, source, game);
}
return true;
}
return false;
}
use of mage.filter.FilterCard in project mage by magefree.
the class SoullessOneDynamicCount method calculate.
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
FilterPermanent zombiesBattlefield = new FilterPermanent("Zombies on the battlefield");
FilterCard zombiesInGraveyard = new FilterCard("Zombie cards in all graveyards");
zombiesBattlefield.add(SubType.ZOMBIE.getPredicate());
zombiesInGraveyard.add(SubType.ZOMBIE.getPredicate());
int count = game.getBattlefield().count(zombiesBattlefield, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
count += player.getGraveyard().count(zombiesInGraveyard, game);
}
}
return count;
}
use of mage.filter.FilterCard in project mage by magefree.
the class SovereignsOfLostAlaraEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent attackingCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (controller != null && attackingCreature != null) {
FilterCard filter = new FilterCard("aura that could enchant the lone attacking creature");
filter.add(SubType.AURA.getPredicate());
filter.add(new AuraCardCanAttachToPermanentId(attackingCreature.getId()));
if (controller.chooseUse(Outcome.Benefit, "Search your library?", source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(filter);
target.setNotTarget(true);
if (controller.searchLibrary(target, source, game)) {
if (target.getFirstTarget() != null) {
Card aura = game.getCard(target.getFirstTarget());
game.getState().setValue("attachTo:" + aura.getId(), attackingCreature);
controller.moveCards(aura, Zone.BATTLEFIELD, source, game);
attackingCreature.addAttachment(aura.getId(), source, game);
}
}
}
controller.shuffleLibrary(source, game);
}
return false;
}
use of mage.filter.FilterCard in project mage by magefree.
the class SoulstealerAxeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int damage = (Integer) getValue("damage");
FilterCard filter = new FilterCard();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, damage));
return player.seekCard(filter, source, game);
}
use of mage.filter.FilterCard in project mage by magefree.
the class TajuruParagonEffect 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, 6));
player.revealCards(source, cards, game);
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (permanent != null) {
FilterCard filter = new FilterCard("card that shares a creature type with " + permanent.getName());
filter.add(new SharesCreatureTypePredicate(permanent));
TargetCard target = new TargetCardInLibrary(0, 1, filter);
player.choose(outcome, cards, target, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
player.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
Aggregations