Search in sources :

Example 61 with FilterCreatureCard

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;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 62 with FilterCreatureCard

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;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Permanent(mage.game.permanent.Permanent) CardsInAllGraveyardsCount(mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount) FilterCreatureCard(mage.filter.common.FilterCreatureCard) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Example 63 with FilterCreatureCard

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;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) DamagedEvent(mage.game.events.DamagedEvent) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 64 with FilterCreatureCard

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;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) SharesCreatureTypePredicate(mage.filter.predicate.mageobject.SharesCreatureTypePredicate) TargetCard(mage.target.TargetCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard)

Example 65 with FilterCreatureCard

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;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Aggregations

FilterCreatureCard (mage.filter.common.FilterCreatureCard)69 Player (mage.players.Player)58 Card (mage.cards.Card)31 FilterCard (mage.filter.FilterCard)26 Permanent (mage.game.permanent.Permanent)22 UUID (java.util.UUID)17 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)17 TargetCard (mage.target.TargetCard)16 CardsImpl (mage.cards.CardsImpl)15 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)15 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)14 MageObject (mage.MageObject)13 OwnerIdPredicate (mage.filter.predicate.card.OwnerIdPredicate)10 Target (mage.target.Target)10 HashSet (java.util.HashSet)8 Cards (mage.cards.Cards)8 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)7 Ability (mage.abilities.Ability)6 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)6 OneShotEffect (mage.abilities.effects.OneShotEffect)4