Search in sources :

Example 51 with FilterCard

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

the class JestersScepterCounterEffect method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        TargetCardInExile target = new TargetCardInExile(new FilterCard(), CardUtil.getCardExileZoneId(game, ability));
        target.setNotTarget(true);
        Cards cards = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, ability));
        if (cards != null && !cards.isEmpty() && controller.choose(Outcome.Benefit, cards, target, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                if (controller.moveCardToGraveyardWithInfo(card, source, game, Zone.EXILED)) {
                    if (card instanceof SplitCard) {
                        game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment", ((SplitCard) card).getLeftHalfCard().getName());
                        game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment2", ((SplitCard) card).getRightHalfCard().getName());
                    } else if (card instanceof ModalDoubleFacesCard) {
                        game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment", ((ModalDoubleFacesCard) card).getLeftHalfCard().getName());
                        game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment2", ((ModalDoubleFacesCard) card).getRightHalfCard().getName());
                    } else {
                        game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment", card.getName());
                    }
                    paid = true;
                }
            }
        }
    }
    return paid;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCardInExile(mage.target.common.TargetCardInExile) FilterCard(mage.filter.FilterCard)

Example 52 with FilterCard

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

the class MindBombEffect 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;
    }
    Map<UUID, Cards> cardsToDiscard = new HashMap<>();
    // choose
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        Cards cards = new CardsImpl();
        Target target = new TargetDiscard(0, 3, new FilterCard(), playerId);
        player.chooseTarget(Outcome.Discard, target, source, game);
        cards.addAll(target.getTargets());
        cardsToDiscard.put(playerId, cards);
    }
    // discard
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            Cards cardsPlayer = cardsToDiscard.get(playerId);
            cardsToDiscard.put(playerId, player.discard(cardsPlayer, false, source, game));
        }
    }
    // damage
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        Cards cardsPlayer = cardsToDiscard.get(playerId);
        if (cardsPlayer != null) {
            player.damage(3 - cardsPlayer.size(), source.getSourceId(), source, game);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) Target(mage.target.Target) HashMap(java.util.HashMap) MageObject(mage.MageObject) UUID(java.util.UUID) TargetDiscard(mage.target.common.TargetDiscard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 53 with FilterCard

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

the class MoratoriumStoneEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getFirstTarget());
    if (card == null) {
        return false;
    }
    String cardName = card.getName();
    FilterCard filter1 = new FilterCard();
    filter1.add(new NamePredicate(cardName));
    FilterPermanent filter2 = new FilterPermanent();
    filter2.add(new NamePredicate(cardName));
    return new ExileGraveyardAllPlayersEffect(filter1).apply(game, source) && new ExileAllEffect(filter2).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) ExileGraveyardAllPlayersEffect(mage.abilities.effects.common.ExileGraveyardAllPlayersEffect) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterPermanent(mage.filter.FilterPermanent) ExileAllEffect(mage.abilities.effects.common.ExileAllEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 54 with FilterCard

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

the class NoxiousVaporsEffect method chooseCardForColor.

private void chooseCardForColor(ObjectColor color, Set<Card> chosenCards, Player player, Game game, Ability source) {
    FilterCard filter = new FilterCard();
    filter.add(new ColorPredicate(color));
    TargetCardInHand target = new TargetCardInHand(filter);
    if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            chosenCards.add(card);
        }
    }
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) TargetCardInHand(mage.target.common.TargetCardInHand) FilterCard(mage.filter.FilterCard) FilterNonlandCard(mage.filter.common.FilterNonlandCard) Card(mage.cards.Card)

Example 55 with FilterCard

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

the class OathOfGhoulsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject sourceObject = game.getObject(source.getSourceId());
    Player firstPlayer = game.getPlayer(game.getActivePlayerId());
    if (sourceObject == null || firstPlayer == null) {
        return false;
    }
    FilterCard filter = new FilterCreatureCard("creature card");
    filter.add(new OwnerIdPredicate(firstPlayer.getId()));
    Target target = new TargetCardInGraveyard(filter);
    target.setNotTarget(true);
    if (target.canChoose(source.getSourceId(), firstPlayer.getId(), game) && firstPlayer.chooseUse(outcome, "Return a creature card from your graveyard to your hand?", source, game) && firstPlayer.chooseTarget(Outcome.ReturnToHand, target, source, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            firstPlayer.moveCards(card, Zone.HAND, source, game);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ObjectSourcePlayer(mage.filter.predicate.ObjectSourcePlayer) TargetPlayer(mage.target.TargetPlayer) FilterPlayer(mage.filter.FilterPlayer) FilterCreatureCard(mage.filter.common.FilterCreatureCard) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) Target(mage.target.Target) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) MageObject(mage.MageObject) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

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