Search in sources :

Example 21 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class NissaStewardOfElementsToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int count = 1 + new CountersSourceCount(CounterType.LOYALTY).calculate(game, source, this);
    FilterPermanentCard filter = new FilterPermanentCard();
    filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.LAND.getPredicate()));
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, count));
    Card card = controller.getLibrary().getFromTop(game);
    if (card != null) {
        controller.lookAtCards(source, null, new CardsImpl(card), game);
        if (filter.match(card, game)) {
            if (controller.chooseUse(outcome, "Put " + card.getName() + " onto the battlefield?", source, game)) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
    }
    return true;
}
Also used : CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) Player(mage.players.Player) FilterPermanentCard(mage.filter.common.FilterPermanentCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

Example 22 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class NoeticScalesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl();
    game.getBattlefield().getActivePermanents(filter, game.getActivePlayerId(), source.getSourceId(), game).stream().filter(Objects::nonNull).forEach(cards::add);
    return player.moveCards(cards, Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 23 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class PuresightMerrowEffect 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) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            Cards cards = new CardsImpl(card);
            controller.lookAtCards("Puresight Merrow", cards, game);
            if (controller.chooseUse(Outcome.Removal, "Exile the card from the top of your library?", source, game)) {
                controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.LIBRARY, true);
            } else {
                game.informPlayers(controller.getLogName() + " puts the card back on top of their library.");
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 24 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class PsychoticEpisodeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player != null && controller != null && sourceObject != null) {
        TargetCard targetCard = new TargetCard(Zone.ALL, new FilterCard());
        targetCard.setRequired(true);
        Cards options = player.getHand().copy();
        Card topdeck = player.getLibrary().getFromTop(game);
        options.add(topdeck);
        controller.lookAtCards("Top of Library (Psychotic Episode)", topdeck, game);
        if (controller.choose(Outcome.Discard, options, targetCard, game)) {
            Card card = game.getCard(targetCard.getFirstTarget());
            if (card != null) {
                CardsImpl cards = new CardsImpl();
                cards.add(card);
                player.revealCards(sourceObject.getIdName(), cards, game);
                player.putCardsOnBottomOfLibrary(cards, game, source, true);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 25 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class RunoStromkirkEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Card card = player.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    player.lookAtCards(null, card, game);
    if (!player.chooseUse(outcome, "Reveal " + card.getName() + '?', source, game)) {
        return true;
    }
    player.revealCards(source, new CardsImpl(card), game);
    if (!card.isCreature(game) || card.getManaValue() < 6) {
        return true;
    }
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent != null) {
        permanent.transform(source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Aggregations

CardsImpl (mage.cards.CardsImpl)507 Player (mage.players.Player)497 Cards (mage.cards.Cards)328 Card (mage.cards.Card)253 UUID (java.util.UUID)135 Permanent (mage.game.permanent.Permanent)114 FilterCard (mage.filter.FilterCard)108 MageObject (mage.MageObject)106 TargetCard (mage.target.TargetCard)99 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)53 TargetPlayer (mage.target.TargetPlayer)47 TargetCardInHand (mage.target.common.TargetCardInHand)41 OneShotEffect (mage.abilities.effects.OneShotEffect)37 Target (mage.target.Target)32 Ability (mage.abilities.Ability)27 FilterPermanent (mage.filter.FilterPermanent)27 CardSetInfo (mage.cards.CardSetInfo)25 Game (mage.game.Game)25 CardImpl (mage.cards.CardImpl)24 FilterCreatureCard (mage.filter.common.FilterCreatureCard)23