Search in sources :

Example 21 with Card

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

the class CranialArchiveEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
        if (targetPlayer != null) {
            for (Card card : targetPlayer.getGraveyard().getCards(game)) {
                targetPlayer.moveCardToLibraryWithInfo(card, source, game, Zone.GRAVEYARD, true, true);
            }
            targetPlayer.shuffleLibrary(source, game);
        }
        controller.drawCards(1, source, game);
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Card(mage.cards.Card)

Example 22 with Card

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

the class DemilichPlayEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card card = game.getCard(targetPointer.getFirst(game, source));
    if (controller == null || card == null) {
        return false;
    }
    controller.moveCards(card, Zone.EXILED, source, game);
    if (controller.chooseUse(outcome, "Cast copy of " + card.getName() + '?', source, game)) {
        Card copiedCard = game.copyCard(card, source, controller.getId());
        game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), Boolean.TRUE);
        controller.cast(controller.chooseAbilityForCast(copiedCard, game, false), game, false, new ApprovingObject(source, game));
        game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), null);
    }
    return true;
}
Also used : Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) Card(mage.cards.Card)

Example 23 with Card

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

the class DiluvianPrimordialReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (Target target : source.getTargets()) {
            if (target instanceof TargetCardInOpponentsGraveyard) {
                Card targetCard = game.getCard(target.getFirstTarget());
                if (targetCard != null) {
                    if (controller.chooseUse(Outcome.PlayForFree, "Cast " + targetCard.getLogName() + '?', source, game)) {
                        game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), Boolean.TRUE);
                        Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(targetCard, game, true), game, true, new ApprovingObject(source, game));
                        game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), null);
                        if (cardWasCast) {
                            ContinuousEffect effect = new DiluvianPrimordialReplacementEffect();
                            effect.setTargetPointer(new FixedTarget(targetCard.getId(), game.getState().getZoneChangeCounter(targetCard.getId())));
                            game.addEffect(effect, source);
                        }
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) ApprovingObject(mage.ApprovingObject) TargetCardInOpponentsGraveyard(mage.target.common.TargetCardInOpponentsGraveyard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 24 with Card

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

the class DireFleetDaredevilReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
        if (targetCard != null) {
            if (controller.moveCards(targetCard, Zone.EXILED, source, game)) {
                targetCard = game.getCard(targetCard.getId());
                if (targetCard != null) {
                    // you may play and spend any mana
                    CardUtil.makeCardPlayable(game, source, targetCard, Duration.EndOfTurn, true);
                    // exile from graveyard
                    ContinuousEffect effect = new DireFleetDaredevilReplacementEffect();
                    effect.setTargetPointer(new FixedTarget(targetCard, game));
                    game.addEffect(effect, source);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 25 with Card

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

the class DireFleetDaredevilReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Card card = game.getCard(event.getTargetId());
    Player controller = game.getPlayer(source.getControllerId());
    if (card != null && controller != null) {
        return controller.moveCards(card, Zone.EXILED, source, game);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Aggregations

Card (mage.cards.Card)1448 Player (mage.players.Player)1096 Permanent (mage.game.permanent.Permanent)423 FilterCard (mage.filter.FilterCard)381 UUID (java.util.UUID)340 CardsImpl (mage.cards.CardsImpl)253 MageObject (mage.MageObject)212 FixedTarget (mage.target.targetpointer.FixedTarget)173 TargetCard (mage.target.TargetCard)165 Cards (mage.cards.Cards)159 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)111 ContinuousEffect (mage.abilities.effects.ContinuousEffect)99 TargetCardInHand (mage.target.common.TargetCardInHand)98 Target (mage.target.Target)86 HashSet (java.util.HashSet)85 FilterCreatureCard (mage.filter.common.FilterCreatureCard)84 ApprovingObject (mage.ApprovingObject)77 Ability (mage.abilities.Ability)71 TargetPlayer (mage.target.TargetPlayer)67 TargetPermanent (mage.target.TargetPermanent)64