Search in sources :

Example 46 with CardsImpl

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

the class AminatousAuguryCastFromExileEffect 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) {
        // move cards from library to exile
        controller.moveCardsToExile(controller.getLibrary().getTopCards(game, 8), source, game, true, source.getSourceId(), CardUtil.createObjectRealtedWindowTitle(source, game, null));
        ExileZone auguryExileZone = game.getExile().getExileZone(source.getSourceId());
        if (auguryExileZone == null) {
            return true;
        }
        Cards cardsToCast = new CardsImpl();
        cardsToCast.addAll(auguryExileZone.getCards(game));
        // put a land card from among them onto the battlefield
        TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_LAND_A);
        if (cardsToCast.count(StaticFilters.FILTER_CARD_LAND, game) > 0) {
            if (controller.chooseUse(Outcome.PutLandInPlay, "Put a land from among the exiled cards into play?", source, game)) {
                if (controller.choose(Outcome.PutLandInPlay, cardsToCast, target, game)) {
                    Card card = cardsToCast.get(target.getFirstTarget(), game);
                    if (card != null) {
                        cardsToCast.remove(card);
                        controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
                    }
                }
            }
        }
        for (Card card : cardsToCast.getCards(StaticFilters.FILTER_CARD_NON_LAND, game)) {
            AminatousAuguryCastFromExileEffect effect = new AminatousAuguryCastFromExileEffect();
            effect.setTargetPointer(new FixedTarget(card, game));
            game.addEffect(effect, source);
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 47 with CardsImpl

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

the class ArchghoulOfThrabenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Card topCard = controller.getLibrary().getFromTop(game);
    if (topCard == null) {
        return false;
    }
    controller.lookAtCards("Top card of library", topCard, game);
    if (topCard.hasSubtype(SubType.ZOMBIE, game)) {
        if (controller.chooseUse(Outcome.DrawCard, "Reveal " + topCard.getName() + " and put it into your hand?", source, game)) {
            controller.revealCards(source, new CardsImpl(topCard), game);
            controller.moveCards(topCard, Zone.HAND, source, game);
            return true;
        }
    }
    if (controller.chooseUse(Outcome.Neutral, "Put " + topCard.getName() + " into your graveyard?", source, game)) {
        controller.moveCards(topCard, Zone.GRAVEYARD, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 48 with CardsImpl

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

the class BagOfDevouringEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int result = player.rollDice(Outcome.Benefit, source, game, 10);
    TargetCard target = new TargetCardInExile(0, result, StaticFilters.FILTER_CARD, CardUtil.getExileZoneId(game, source));
    target.setNotTarget(true);
    player.choose(outcome, target, source.getSourceId(), game);
    player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetCardInExile(mage.target.common.TargetCardInExile) TargetCard(mage.target.TargetCard) CardsImpl(mage.cards.CardsImpl)

Example 49 with CardsImpl

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

the class CelebrateTheHarvestEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int powerCount = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source.getSourceId(), game).stream().filter(Objects::nonNull).map(MageObject::getPower).mapToInt(MageInt::getValue).distinct().map(x -> 1).sum();
    TargetCardInLibrary target = new TargetCardInLibrary(0, powerCount, StaticFilters.FILTER_CARD_BASIC_LAND);
    player.searchLibrary(target, source, game);
    Cards cards = new CardsImpl();
    target.getTargets().stream().map(cardId -> player.getLibrary().getCard(cardId, game)).forEach(cards::add);
    player.moveCards(cards.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null);
    player.shuffleLibrary(source, game);
    return true;
}
Also used : StaticFilters(mage.filter.StaticFilters) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Zone(mage.constants.Zone) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) MageInt(mage.MageInt) CardsImpl(mage.cards.CardsImpl) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Objects(java.util.Objects) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) MageObject(mage.MageObject) CovenHint(mage.abilities.hint.common.CovenHint) Ability(mage.abilities.Ability) Player(mage.players.Player) MageObject(mage.MageObject) CovenHint(mage.abilities.hint.common.CovenHint) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 50 with CardsImpl

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

the class ColfenorsPlansLookAtCardEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cards toExile = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
        UUID exileId = CardUtil.getCardExileZoneId(game, source);
        controller.moveCardsToExile(toExile.getCards(game), source, game, false, exileId, CardUtil.createObjectRealtedWindowTitle(source, game, null));
        ExileZone exileZone = game.getExile().getExileZone(exileId);
        if (exileZone != null) {
            for (Card card : exileZone.getCards(game)) {
                if (card != null) {
                    card.setFaceDown(true, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) Cards(mage.cards.Cards) 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