use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class InfernalOfferingReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetOpponent(true);
target.choose(Outcome.PutCreatureInPlay, source.getControllerId(), source.getSourceId(), game);
Player opponent = game.getPlayer(target.getFirstTarget());
target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
if (target.choose(Outcome.PutCreatureInPlay, controller.getId(), source.getSourceId(), game)) {
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
if (opponent != null) {
target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
if (target.choose(Outcome.PutCreatureInPlay, opponent.getId(), source.getSourceId(), game)) {
Card card = opponent.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
opponent.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class JaradsOrdersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterCreatureCard("creature cards"));
if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
Cards revealed = new CardsImpl();
for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().getCard(cardId, game);
revealed.add(card);
}
controller.revealCards("Jarad's Orders", revealed, game);
if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game);
controller.moveCards(card, Zone.HAND, source, game);
revealed.remove(card);
Set<Card> cards = revealed.getCards(game);
card = cards.isEmpty() ? null : cards.iterator().next();
controller.moveCards(card, Zone.GRAVEYARD, source, game);
} else if (target.getTargets().size() == 1) {
Set<Card> cards = revealed.getCards(game);
Card card = cards.isEmpty() ? null : cards.iterator().next();
controller.moveCards(card, Zone.HAND, source, game);
}
}
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class MoorlandRescuerTarget method makeFilter.
private static FilterCard makeFilter(int xValue, Ability source, Game game) {
FilterCard filter = new FilterCreatureCard("creature cards with total power " + xValue + " or less from your graveyard");
filter.add(Predicates.not(new MageObjectReferencePredicate(source.getSourceObject(game), game)));
return filter;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class TemptWithImmortalityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
returnCreatureFromGraveToBattlefield(controller, source, game);
int opponentsReturnedCreatures = 0;
for (UUID playerId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(playerId);
if (opponent != null) {
FilterCard filter = new FilterCreatureCard("creature card from your graveyard");
filter.add(new OwnerIdPredicate(opponent.getId()));
Target targetCardOpponent = new TargetCardInGraveyard(filter);
if (targetCardOpponent.canChoose(source.getSourceId(), opponent.getId(), game)) {
if (opponent.chooseUse(outcome, "Return a creature card from your graveyard to the battlefield?", source, game)) {
if (opponent.chooseTarget(outcome, targetCardOpponent, source, game)) {
Card card = game.getCard(targetCardOpponent.getFirstTarget());
if (card != null) {
opponentsReturnedCreatures++;
opponent.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
}
}
}
if (opponentsReturnedCreatures > 0) {
for (int i = 0; i < opponentsReturnedCreatures; i++) {
returnCreatureFromGraveToBattlefield(controller, source, game);
}
}
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class TrackersInstinctsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
boolean creaturesFound = cards.count(StaticFilters.FILTER_CARD_CREATURE, game) > 0;
if (!cards.isEmpty()) {
controller.revealCards(source, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put in hand"));
if (creaturesFound && controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
Aggregations