Search in sources :

Example 56 with FilterCreatureCard

use of mage.filter.common.FilterCreatureCard in project mage by magefree.

the class VivienMonstersAdvocateTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Spell spell = game.getSpell(event.getTargetId());
    if (spell != null && spell.isCreature(game)) {
        int cmc = spell.getManaValue();
        FilterCard filter = new FilterCreatureCard("creature card with mana value less than " + cmc);
        filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, cmc));
        this.getEffects().clear();
        this.getEffects().add(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)));
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Spell(mage.game.stack.Spell) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 57 with FilterCreatureCard

use of mage.filter.common.FilterCreatureCard in project mage by magefree.

the class ViviensArkbowEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue));
    player.lookAtCards(source, null, cards, game);
    FilterCard filter = new FilterCreatureCard("creature card with mana value " + xValue + " or less");
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
    TargetCard target = new TargetCardInLibrary(0, 1, filter);
    if (player.choose(outcome, cards, target, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            cards.remove(card);
        }
    }
    return player.putCardsOnBottomOfLibrary(cards, game, source, false);
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCard(mage.target.TargetCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard)

Example 58 with FilterCreatureCard

use of mage.filter.common.FilterCreatureCard in project mage by magefree.

the class VirtussManeuverEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes();
    if (controller != null && !choice.chooseFriendOrFoe(controller, source, game)) {
        return false;
    }
    Map<UUID, Card> getBackMap = new HashMap<>();
    for (Player player : choice.getFriends()) {
        if (player == null) {
            continue;
        }
        FilterCard filter = new FilterCreatureCard("creature card in your graveyard");
        filter.add(new OwnerIdPredicate(player.getId()));
        TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
        getBackMap.put(player.getId(), null);
        if (player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
            getBackMap.put(player.getId(), game.getCard(target.getFirstTarget()));
        }
    }
    for (Player player : choice.getFriends()) {
        if (player == null) {
            continue;
        }
        Card card = getBackMap.getOrDefault(player.getId(), null);
        if (card == null) {
            continue;
        }
        player.moveCards(card, Zone.HAND, source, game);
    }
    List<UUID> perms = new ArrayList<>();
    for (Player player : choice.getFoes()) {
        if (player == null) {
            continue;
        }
        TargetControlledPermanent target = new TargetControlledPermanent(1, 1, StaticFilters.FILTER_CONTROLLED_A_CREATURE, true);
        player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        perms.addAll(target.getTargets());
    }
    for (UUID permID : perms) {
        Permanent permanent = game.getPermanent(permID);
        if (permanent != null) {
            permanent.sacrifice(source, game);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterCreatureCard(mage.filter.common.FilterCreatureCard) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) ChooseFriendsAndFoes(mage.choices.ChooseFriendsAndFoes) UUID(java.util.UUID)

Example 59 with FilterCreatureCard

use of mage.filter.common.FilterCreatureCard in project mage by magefree.

the class WoodSageEffect 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) {
        return false;
    }
    String cardName = ChooseACardNameEffect.TypeOfName.CREATURE_NAME.getChoice(controller, game, source, false);
    FilterCreatureCard filter = new FilterCreatureCard("all of them with that name");
    filter.add(new NamePredicate(cardName));
    new RevealLibraryPutIntoHandEffect(4, filter, Zone.GRAVEYARD).apply(game, source);
    return true;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) RevealLibraryPutIntoHandEffect(mage.abilities.effects.common.RevealLibraryPutIntoHandEffect) MageObject(mage.MageObject)

Example 60 with FilterCreatureCard

use of mage.filter.common.FilterCreatureCard in project mage by magefree.

the class ReturnCreaturesFromExileEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ExileZone exile = game.getExile().getExileZone(exileId);
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && exile != null) {
        controller.moveCards(exile.getCards(new FilterCreatureCard(), game), Zone.BATTLEFIELD, source, game, false, false, this.byOwner, null);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ExileZone(mage.game.ExileZone)

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