Search in sources :

Example 56 with CardsImpl

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

the class GlimpseOfTomorrowEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
    int count = permanents.size();
    player.shuffleCardsToLibrary(new CardsImpl(permanents), game, source);
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, count));
    player.revealCards(source, cards, game);
    Cards toBattlefield = new CardsImpl(cards.getCards(StaticFilters.FILTER_CARD_PERMANENT, game));
    toBattlefield.removeIf(uuid -> game.getCard(uuid).hasSubtype(SubType.AURA, game));
    player.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
    toBattlefield.clear();
    cards.retainZone(Zone.LIBRARY, game);
    toBattlefield.addAll(cards.getCards(StaticFilters.FILTER_CARD_PERMANENT, game));
    toBattlefield.removeIf(uuid -> !game.getCard(uuid).hasSubtype(SubType.AURA, game));
    player.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
    cards.retainZone(Zone.LIBRARY, game);
    player.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) CardsImpl(mage.cards.CardsImpl) Cards(mage.cards.Cards)

Example 57 with CardsImpl

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

the class GrimReminderWatcher 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) {
        TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_NON_LAND);
        if (controller.searchLibrary(target, source, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                Cards cardsToReveal = new CardsImpl(card);
                controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
                String cardName = card.getName();
                GrimReminderWatcher watcher = game.getState().getWatcher(GrimReminderWatcher.class);
                if (watcher != null) {
                    for (UUID playerId : watcher.getPlayersCastSpell(cardName)) {
                        Player player = game.getPlayer(playerId);
                        if (player != null) {
                            player.loseLife(6, game, source, false);
                        }
                    }
                }
            }
        }
        controller.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 58 with CardsImpl

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

the class HedronAlignmentEffect 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) {
        Cards cardsToReveal = new CardsImpl();
        controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
        // Check battlefield
        if (!game.getBattlefield().contains(filterPermanent, source, game, 1)) {
            return true;
        }
        if (controller.getHand().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) {
            return true;
        }
        if (controller.getGraveyard().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) {
            return true;
        }
        Cards cardsToCheck = new CardsImpl();
        cardsToCheck.addAll(game.getExile().getAllCards(game));
        if (cardsToCheck.count(filterCard, source.getSourceId(), controller.getId(), game) == 0) {
            return true;
        }
        controller.won(game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 59 with CardsImpl

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

the class JudgeUnworthyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card sourceCard = game.getCard(source.getSourceId());
    if (sourceCard != null && controller != null) {
        if (controller.getLibrary().hasCards()) {
            Card card = controller.getLibrary().getFromTop(game);
            controller.revealCards(sourceCard.getName(), new CardsImpl(card), game);
            Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
            if (targetCreature != null) {
                targetCreature.damage(card.getManaValue(), source.getSourceId(), source, game, false, true);
                return true;
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 60 with CardsImpl

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

the class LagonnaBandStorytellerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (controller == null || card == null || !card.isEnchantment(game) || game.getState().getZone(card.getId()) != Zone.GRAVEYARD) {
        return false;
    }
    int cmc = card.getManaValue();
    if (controller.putCardsOnTopOfLibrary(new CardsImpl(card), game, source, false)) {
        controller.gainLife(cmc, game, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) FilterEnchantmentCard(mage.filter.common.FilterEnchantmentCard) 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