Search in sources :

Example 66 with CardsImpl

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

the class MundaAmbushLeaderEffect 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 allCards = new CardsImpl();
        allCards.addAll(controller.getLibrary().getTopCards(game, 4));
        controller.lookAtCards(sourceObject.getIdName(), allCards, game);
        if (!allCards.isEmpty()) {
            Cards cardsToReveal = new CardsImpl();
            TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
            controller.chooseTarget(outcome, allCards, target, source, game);
            cardsToReveal.addAll(target.getTargets());
            if (!cardsToReveal.isEmpty()) {
                controller.revealCards(sourceObject.getIdName(), cardsToReveal, game, true);
                allCards.removeAll(cardsToReveal);
            }
            controller.putCardsOnTopOfLibrary(cardsToReveal, game, source, true);
        }
        if (!allCards.isEmpty()) {
            controller.putCardsOnBottomOfLibrary(allCards, game, source, true);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 67 with CardsImpl

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

the class NyleaKeenEyedEffect 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.revealCards(source, new CardsImpl(card), game);
    if (card.isCreature(game)) {
        return player.moveCards(card, Zone.HAND, source, game);
    }
    if (!player.chooseUse(Outcome.Detriment, "Put " + card.getName() + " into your graveyard?", source, game)) {
        return true;
    }
    return player.moveCards(card, Zone.GRAVEYARD, source, game);
}
Also used : Player(mage.players.Player) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 68 with CardsImpl

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

the class ParadoxicalOutcomeNumber method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cards cards = new CardsImpl(source.getTargets().get(0).getTargets());
        game.getState().setValue(CardUtil.getCardZoneString("ParadoxicalOutcomeEffect", source.getSourceId(), game), cards.size());
        controller.moveCards(new CardsImpl(source.getTargets().get(0).getTargets()), Zone.HAND, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 69 with CardsImpl

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

the class ParoxysmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent aura = game.getPermanent(source.getSourceId());
    if (aura != null) {
        Permanent creatureAttachedTo = game.getPermanent(aura.getAttachedTo());
        if (creatureAttachedTo != null) {
            Player controllerOfCreature = game.getPlayer(creatureAttachedTo.getControllerId());
            if (controllerOfCreature != null) {
                Card revealCardFromTop = controllerOfCreature.getLibrary().getFromTop(game);
                if (revealCardFromTop != null) {
                    Cards cards = new CardsImpl(revealCardFromTop);
                    controllerOfCreature.revealCards(source, cards, game);
                    if (revealCardFromTop.isLand(game)) {
                        creatureAttachedTo.destroy(source, game, false);
                    } else {
                        ContinuousEffect effect = new BoostTargetEffect(3, 3, Duration.EndOfTurn);
                        effect.setTargetPointer(new FixedTarget(creatureAttachedTo.getId(), game));
                        game.addEffect(effect, source);
                    }
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 70 with CardsImpl

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

the class PatronOfTheMoonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        TargetCard target = new TargetCardInHand(0, 2, new FilterLandCard("up to two land cards to put onto the battlefield tapped"));
        controller.chooseTarget(outcome, controller.getHand(), target, source, game);
        return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) FilterLandCard(mage.filter.common.FilterLandCard) TargetCard(mage.target.TargetCard) CardsImpl(mage.cards.CardsImpl)

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