Search in sources :

Example 36 with FilterCreatureCard

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

the class WildPairPowerToughnessPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = (Permanent) getValue("permanentEnteringBattlefield");
    if (controller == null || permanent == null) {
        return false;
    }
    int totalPT = permanent.getPower().getValue() + permanent.getToughness().getValue();
    FilterCreatureCard filter = new FilterCreatureCard("creature card with total power and toughness " + totalPT);
    filter.add(new WildPairPowerToughnessPredicate(totalPT));
    TargetCardInLibrary target = new TargetCardInLibrary(1, filter);
    controller.searchLibrary(target, source, game);
    controller.moveCards(new CardsImpl(controller.getLibrary().getCard(target.getFirstTarget(), game)), Zone.BATTLEFIELD, source, game);
    controller.shuffleLibrary(source, game);
    return true;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 37 with FilterCreatureCard

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

the class AethermagesTouchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
        if (!cards.isEmpty()) {
            FilterCreatureCard filter = new FilterCreatureCard("a creature card to put onto the battlefield");
            controller.revealCards(sourceObject.getIdName(), cards, game);
            TargetCard target = new TargetCard(Zone.LIBRARY, filter);
            if (cards.count(filter, game) > 0 && controller.choose(outcome, cards, target, game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    cards.remove(card);
                    if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                        // It gains \"At the beginning of your end step, return this creature to its owner's hand.\"
                        Permanent permanent = game.getPermanent(card.getId());
                        if (permanent != null) {
                            Ability ability = new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new ReturnToHandSourceEffect(true), TargetController.YOU, null, false);
                            ContinuousEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
                            effect.setTargetPointer(new FixedTarget(permanent, game));
                            game.addEffect(effect, source);
                        }
                    }
                }
            }
            controller.putCardsOnBottomOfLibrary(cards, game, source, true);
        }
        return true;
    }
    return false;
}
Also used : BeginningOfEndStepTriggeredAbility(mage.abilities.common.BeginningOfEndStepTriggeredAbility) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) BeginningOfEndStepTriggeredAbility(mage.abilities.common.BeginningOfEndStepTriggeredAbility) FilterCreatureCard(mage.filter.common.FilterCreatureCard) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 38 with FilterCreatureCard

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

the class GraveSifterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    typeChoice.setMessage("Choose creature type to return cards from your graveyard");
    Player controller = game.getPlayer(source.getControllerId());
    Set<Card> toHand = new HashSet<>();
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                typeChoice.clearChoice();
                if (player.choose(outcome, typeChoice, game)) {
                    game.informPlayers(player.getLogName() + " has chosen: " + typeChoice.getChoice());
                    FilterCard filter = new FilterCreatureCard("creature cards with creature type " + typeChoice.getChoice() + " from your graveyard");
                    filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
                    Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter);
                    player.chooseTarget(outcome, target, source, game);
                    toHand.addAll(new CardsImpl(target.getTargets()).getCards(game));
                }
            }
        }
        // must happen simultaneously Rule 101.4
        controller.moveCards(toHand, Zone.HAND, source, game, false, false, true, null);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Target(mage.target.Target) Choice(mage.choices.Choice) ChoiceCreatureType(mage.choices.ChoiceCreatureType) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 39 with FilterCreatureCard

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

the class LazavDimirMastermindCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    Ability ability = new PutCardIntoGraveFromAnywhereAllTriggeredAbility(new LazavDimirMastermindEffect(), true, new FilterCreatureCard("a creature card"), TargetController.OPPONENT, SetTargetPointer.CARD);
    blueprint.getAbilities().add(ability);
    blueprint.setName("Lazav, Dimir Mastermind");
    blueprint.addSuperType(SuperType.LEGENDARY);
    blueprint.getAbilities().add(HexproofAbility.getInstance());
    return true;
}
Also used : PutCardIntoGraveFromAnywhereAllTriggeredAbility(mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility) HexproofAbility(mage.abilities.keyword.HexproofAbility) Ability(mage.abilities.Ability) FilterCreatureCard(mage.filter.common.FilterCreatureCard) PutCardIntoGraveFromAnywhereAllTriggeredAbility(mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility)

Example 40 with FilterCreatureCard

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

the class ReincarnationDelayedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = (Permanent) game.getLastKnownInformation(target, Zone.BATTLEFIELD);
    if (permanent != null && controller != null) {
        Player player = game.getPlayer(permanent.getOwnerId());
        if (player != null) {
            FilterCreatureCard filter = new FilterCreatureCard("a creature card from " + player.getName() + "'s graveyard");
            filter.add(new OwnerIdPredicate(player.getId()));
            Target targetCreature = new TargetCardInGraveyard(filter);
            targetCreature.setNotTarget(true);
            if (targetCreature.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseTarget(outcome, targetCreature, source, game)) {
                Card card = game.getCard(targetCreature.getFirstTarget());
                if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
                    controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
                }
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) Target(mage.target.Target) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) 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