Search in sources :

Example 61 with Card

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

the class PuppeteerCliqueEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card == null) {
        return false;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        return false;
    }
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        return false;
    }
    ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
    hasteEffect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(hasteEffect, source);
    ExileTargetEffect exileEffect = new ExileTargetEffect("exile " + permanent.getLogName());
    exileEffect.setTargetPointer(new FixedTarget(permanent, game));
    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.YOU);
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 62 with Card

use of mage.cards.Card 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 63 with Card

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

the class PulseOfTheDrossReturnToHandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Player player = game.getPlayer(source.getFirstTarget());
        if (player != null) {
            if (player.getHand().size() > controller.getHand().size()) {
                Card card = game.getCard(source.getSourceId());
                controller.moveCards(card, Zone.HAND, source, game);
            }
            return true;
        }
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Card(mage.cards.Card)

Example 64 with Card

use of mage.cards.Card 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 65 with Card

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

the class PryingQuestionsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (targetOpponent != null) {
        if (!targetOpponent.getHand().isEmpty()) {
            TargetCardInHand target = new TargetCardInHand();
            target.setNotTarget(true);
            target.setTargetName("a card from your hand to put on top of your library");
            targetOpponent.choose(Outcome.Detriment, target, source.getSourceId(), game);
            Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
            if (card != null) {
                targetOpponent.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) 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