use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class NessianGameWardenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller == null || sourcePermanent == null) {
return false;
}
int count = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, count));
controller.lookAtCards(sourcePermanent.getIdName(), cards, game);
if (!cards.isEmpty()) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put into your hand"));
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.revealCards(sourcePermanent.getName(), new CardsImpl(card), game);
cards.remove(card);
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class TheMimeoplasmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller != null && permanent != null) {
if (new CardsInAllGraveyardsCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this) >= 2) {
if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) {
TargetCardInGraveyard targetCopy = new TargetCardInGraveyard(new FilterCreatureCard("creature card to become a copy of"));
targetCopy.setNotTarget(true);
if (controller.choose(Outcome.Copy, targetCopy, source.getSourceId(), game)) {
Card cardToCopy = game.getCard(targetCopy.getFirstTarget());
if (cardToCopy != null) {
FilterCreatureCard filter = new FilterCreatureCard("creature card to determine amount of additional +1/+1 counters");
filter.add(Predicates.not(new CardIdPredicate(cardToCopy.getId())));
TargetCardInGraveyard targetCounters = new TargetCardInGraveyard(filter);
targetCounters.setNotTarget(true);
if (controller.choose(Outcome.Copy, targetCounters, source.getSourceId(), game)) {
Card cardForCounters = game.getCard(targetCounters.getFirstTarget());
if (cardForCounters != null) {
Cards cardsToExile = new CardsImpl();
cardsToExile.add(cardToCopy);
cardsToExile.add(cardForCounters);
controller.moveCards(cardsToExile, Zone.EXILED, source, game);
CopyEffect copyEffect = new CopyEffect(Duration.Custom, cardToCopy, source.getSourceId());
game.addEffect(copyEffect, source);
permanent.addCounters(CounterType.P1P1.createInstance(cardForCounters.getPower().getValue()), source.getControllerId(), source, game);
}
}
}
}
}
}
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class VenerableWarsingerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player player = game.getPlayer(event.getPlayerId());
if (player == null || !event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
FilterCard filter = new FilterCreatureCard("creature card with mana value " + event.getAmount() + " less from your graveyard");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, event.getAmount() + 1));
this.getTargets().clear();
this.addTarget(new TargetCardInYourGraveyard(filter));
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class CallToTheKindredEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment == null || controller == null || enchantment.getAttachedTo() == null) {
return false;
}
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
FilterCreatureCard filter = new FilterCreatureCard();
filter.add(new SharesCreatureTypePredicate(creature));
if (cards.count(filter, game) > 0) {
TargetCard target = new TargetCardInLibrary(0, 1, filter);
controller.choose(Outcome.PutCreatureInPlay, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class BriberyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && opponent != null) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, new FilterCreatureCard("creature card"));
if (controller.searchLibrary(target, source, game, opponent.getId())) {
Card card = opponent.getLibrary().getCard(target.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
opponent.shuffleLibrary(source, game);
return true;
}
return false;
}
Aggregations