Search in sources :

Example 41 with FilterCreatureCard

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

the class EnslavedHorrorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Set<Card> toBattlefield = new HashSet<>();
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            if (playerId.equals(controller.getId())) {
                continue;
            }
            Player player = game.getPlayer(playerId);
            if (player != null) {
                FilterCreatureCard filterCreatureCard = new FilterCreatureCard("creature card from your graveyard");
                filterCreatureCard.add(new OwnerIdPredicate(playerId));
                TargetCardInGraveyard target = new TargetCardInGraveyard(0, 1, filterCreatureCard);
                target.setNotTarget(true);
                if (target.canChoose(source.getSourceId(), playerId, game) && player.chooseTarget(outcome, target, source, game)) {
                    Card card = game.getCard(target.getFirstTarget());
                    if (card != null) {
                        toBattlefield.add(card);
                    }
                }
            }
        }
        // must happen simultaneously Rule 101.4
        controller.moveCards(toBattlefield, 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) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) UUID(java.util.UUID) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 42 with FilterCreatureCard

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

the class GishathSunsAvatarEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int xValue = (Integer) getValue("damage");
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
    if (!cards.isEmpty()) {
        controller.revealCards(source, cards, game);
        FilterCreatureCard filter = new FilterCreatureCard("Dinosaur creature cards");
        filter.add(SubType.DINOSAUR.getPredicate());
        TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
        target1.setNotTarget(true);
        controller.choose(Outcome.PutCardInPlay, cards, target1, game);
        Cards toBattlefield = new CardsImpl(target1.getTargets());
        cards.removeAll(toBattlefield);
        controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
        controller.putCardsOnBottomOfLibrary(cards, game, source, false);
    }
    return true;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 43 with FilterCreatureCard

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

the class MercadianLiftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int numberOfCounters = 0;
        for (Cost cost : source.getCosts()) {
            if (cost instanceof RemoveVariableCountersSourceCost) {
                numberOfCounters = ((RemoveVariableCountersSourceCost) cost).getAmount();
            }
        }
        System.out.println("The number is " + numberOfCounters);
        FilterCreatureCard filter = new FilterCreatureCard();
        filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, numberOfCounters));
        filter.setMessage("creature card with mana value " + numberOfCounters);
        TargetCardInHand target = new TargetCardInHand(filter);
        if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseUse(Outcome.PutCardInPlay, "Put " + filter.getMessage() + " from your hand onto the battlefield?", source, game) && controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
            target.setRequired(false);
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInHand(mage.target.common.TargetCardInHand) RemoveVariableCountersSourceCost(mage.abilities.costs.common.RemoveVariableCountersSourceCost) RemoveVariableCountersSourceCost(mage.abilities.costs.common.RemoveVariableCountersSourceCost) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 44 with FilterCreatureCard

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

the class MyojinOfLifesWebPutCreatureOnBattlefieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCreatureCard("creature cards from your hand to put onto the battlefield"));
    if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
        return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCardInHand(mage.target.common.TargetCardInHand) CardsImpl(mage.cards.CardsImpl)

Example 45 with FilterCreatureCard

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

the class FleshwritherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = source.getSourcePermanentOrLKI(game);
    if (sourcePermanent == null || controller == null) {
        return false;
    }
    FilterCard filter = new FilterCreatureCard("creature card with mana value " + sourcePermanent.getManaValue());
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, sourcePermanent.getManaValue()));
    TargetCardInLibrary target = new TargetCardInLibrary(filter);
    controller.searchLibrary(target, source, game);
    controller.moveCards(controller.getLibrary().getCard(target.getFirstTarget(), game), Zone.BATTLEFIELD, source, game);
    controller.shuffleLibrary(source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Permanent(mage.game.permanent.Permanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary)

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