Search in sources :

Example 46 with FilterCard

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

the class DomriChaosBringerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getSourceId().equals(spellId)) {
        return false;
    }
    if (game.getTurnNum() != turnNumber) {
        return false;
    }
    MageObject mo = game.getObject(event.getTargetId());
    if (mo == null || !mo.isCreature(game)) {
        return false;
    }
    StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
    if (stackObject == null) {
        return false;
    }
    this.getEffects().clear();
    FilterCard filter = new FilterCard();
    filter.add(new CardIdPredicate(stackObject.getSourceId()));
    this.addEffect(new GainAbilityControlledSpellsEffect(new RiotAbility(), filter));
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) RiotAbility(mage.abilities.keyword.RiotAbility) MageObject(mage.MageObject) StackObject(mage.game.stack.StackObject) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate) GainAbilityControlledSpellsEffect(mage.abilities.effects.common.continuous.GainAbilityControlledSpellsEffect)

Example 47 with FilterCard

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

the class EnigmaticIncarnationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0 || !player.chooseUse(outcome, "Sacrifice an enchantment?", source, game)) {
        return false;
    }
    TargetPermanent target = new TargetPermanent(0, 1, filter, true);
    player.choose(outcome, target, source.getSourceId(), game);
    Permanent permanent = game.getPermanent(target.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    game.getState().processAction(game);
    int cmc = permanent.getManaValue();
    if (!permanent.sacrifice(source, game)) {
        return false;
    }
    FilterCard filterCard = new FilterCreatureCard("creature card with mana value " + (cmc + 1));
    filterCard.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc + 1));
    return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filterCard)).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) FilterControlledEnchantmentPermanent(mage.filter.common.FilterControlledEnchantmentPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 48 with FilterCard

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

the class FaithsShieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    if (controller != null && mageObject != null) {
        if (FatefulHourCondition.instance.apply(game, source)) {
            ChoiceColor choice = new ChoiceColor();
            if (!controller.choose(Outcome.Protect, choice, game)) {
                return false;
            }
            if (choice.getColor() != null) {
                game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
                FilterCard filter = new FilterCard();
                filter.add(new ColorPredicate(choice.getColor()));
                filter.setMessage(choice.getChoice());
                Ability ability = new ProtectionAbility(filter);
                game.addEffect(new GainAbilityControlledEffect(ability, Duration.EndOfTurn), source);
                game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
                return true;
            }
        } else {
            game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
            return true;
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) GainProtectionFromColorTargetEffect(mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) MageObject(mage.MageObject) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ChoiceColor(mage.choices.ChoiceColor) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect)

Example 49 with FilterCard

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

the class GiftsUngivenTarget method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card sourceCard = game.getCard(source.getSourceId());
    if (player == null || sourceCard == null) {
        return false;
    }
    Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (opponent == null) {
        return false;
    }
    GiftsUngivenTarget target = new GiftsUngivenTarget();
    if (player.searchLibrary(target, source, game)) {
        if (!target.getTargets().isEmpty()) {
            Cards cards = new CardsImpl();
            for (UUID cardId : target.getTargets()) {
                Card card = player.getLibrary().remove(cardId, game);
                if (card != null) {
                    cards.add(card);
                }
            }
            player.revealCards(sourceCard.getIdName(), cards, game);
            CardsImpl cardsToKeep = new CardsImpl();
            if (cards.size() > 2) {
                cardsToKeep.addAll(cards);
                TargetCard targetDiscard = new TargetCard(2, Zone.LIBRARY, new FilterCard("cards to put in graveyard"));
                if (opponent.choose(Outcome.Discard, cards, targetDiscard, game)) {
                    cardsToKeep.removeAll(targetDiscard.getTargets());
                    cards.removeAll(cardsToKeep);
                }
            }
            player.moveCards(cards, Zone.GRAVEYARD, source, game);
            player.moveCards(cardsToKeep, Zone.HAND, source, game);
        }
        player.shuffleLibrary(source, game);
        return true;
    }
    player.shuffleLibrary(source, game);
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard)

Example 50 with FilterCard

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

the class IsarethTheAwakenerReplacementEffect method makeFilter.

private static FilterCard makeFilter(int xValue) {
    FilterCard filter = new FilterCreatureCard("creature card with mana value " + xValue + " or less from your graveyard");
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
    return filter;
}
Also used : FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate)

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