Search in sources :

Example 11 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class FiendArtisanEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = source.getManaCostsToPay().getX();
    FilterCard filter = new FilterCreatureCard("creature card with mana value " + xValue + " or less");
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
    return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 12 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class FroghemothEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (super.checkTrigger(event, game)) {
        FilterCard filter = new FilterCard("cards from defender's graveyard");
        filter.add(new OwnerIdPredicate(event.getPlayerId()));
        this.getTargets().clear();
        this.addTarget(new TargetCardInGraveyard(0, event.getAmount(), filter));
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard)

Example 13 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class HatcherySpiderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int xValue = new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this);
    FilterCard filter = new FilterPermanentCard("green permanent card with mana value " + xValue + " or less");
    filter.add(new ColorPredicate(ObjectColor.GREEN));
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
    TargetCard target = new TargetCardInLibrary(filter);
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue));
    if (player.chooseUse(outcome, "Put a card onto the battlefield?", source, game) && player.choose(outcome, cards, target, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            cards.remove(card);
        }
    }
    while (!cards.isEmpty()) {
        Card card = cards.getRandom(game);
        player.getLibrary().putOnBottom(card, game);
        cards.remove(card);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanentCard(mage.filter.common.FilterPermanentCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCard(mage.target.TargetCard) CardsInControllerGraveyardCount(mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

Example 14 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class HauntingEchoesPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player player = game.getPlayer(source.getFirstTarget());
    if (controller == null || player == null) {
        return false;
    }
    Cards cards = new CardsImpl();
    player.getGraveyard().getCards(game).stream().filter(Objects::nonNull).filter(card -> !card.isBasic() || !card.isLand(game)).forEach(cards::add);
    controller.moveCards(cards, Zone.EXILED, source, game);
    cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
    FilterCard filter = new FilterCard("cards with the same name as a card exiled this way");
    filter.add(new HauntingEchoesPredicate(cards));
    TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter);
    controller.searchLibrary(target, source, game, player.getId());
    cards.clear();
    cards.addAll(target.getTargets());
    controller.moveCards(cards, Zone.EXILED, source, game);
    player.shuffleLibrary(source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Zone(mage.constants.Zone) Predicate(mage.filter.predicate.Predicate) mage.cards(mage.cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) CardUtil(mage.util.CardUtil) TargetPlayer(mage.target.TargetPlayer) UUID(java.util.UUID) Player(mage.players.Player) Objects(java.util.Objects) Game(mage.game.Game) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) mage.cards(mage.cards) Objects(java.util.Objects) TargetCardInLibrary(mage.target.common.TargetCardInLibrary)

Example 15 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class HazoretsUndyingFuryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        controller.shuffleLibrary(source, game);
        // move cards from library to exile
        controller.moveCardsToExile(controller.getLibrary().getTopCards(game, 4), source, game, true, source.getSourceId(), sourceObject.getIdName());
        // cast the possible cards without paying the mana
        ExileZone hazoretsUndyingFuryExileZone = game.getExile().getExileZone(source.getSourceId());
        Cards cardsToCast = new CardsImpl();
        if (hazoretsUndyingFuryExileZone == null) {
            return true;
        }
        cardsToCast.addAll(hazoretsUndyingFuryExileZone.getCards(filter, source.getSourceId(), source.getControllerId(), game));
        while (controller.canRespond() && !cardsToCast.isEmpty()) {
            if (!controller.chooseUse(Outcome.PlayForFree, "Cast (another) a card exiled with " + sourceObject.getLogName() + " without paying its mana cost?", source, game)) {
                break;
            }
            TargetCard targetCard = new TargetCard(1, Zone.EXILED, new FilterCard("nonland card to cast for free"));
            if (controller.choose(Outcome.PlayForFree, cardsToCast, targetCard, game)) {
                Card card = game.getCard(targetCard.getFirstTarget());
                if (card != null) {
                    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                    Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
                    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
                    cardsToCast.remove(card);
                    if (!cardWasCast) {
                        game.informPlayer(controller, "You're not able to cast " + card.getIdName() + " or you canceled the casting.");
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard)

Aggregations

FilterCard (mage.filter.FilterCard)337 Player (mage.players.Player)287 Card (mage.cards.Card)148 TargetCard (mage.target.TargetCard)127 UUID (java.util.UUID)97 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)87 Permanent (mage.game.permanent.Permanent)79 MageObject (mage.MageObject)75 CardsImpl (mage.cards.CardsImpl)75 Cards (mage.cards.Cards)60 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)56 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)54 Target (mage.target.Target)41 TargetCardInHand (mage.target.common.TargetCardInHand)41 TargetPlayer (mage.target.TargetPlayer)35 ApprovingObject (mage.ApprovingObject)29 FilterCreatureCard (mage.filter.common.FilterCreatureCard)25 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)24 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)22 ArrayList (java.util.ArrayList)21