Search in sources :

Example 66 with Card

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

the class SadisticSacramentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null && targetPlayer != null) {
        TargetCardInLibrary target = new TargetCardInLibrary(0, amount, new FilterCard("cards to exile"));
        if (player.searchLibrary(target, source, game, targetPlayer.getId())) {
            List<UUID> targets = target.getTargets();
            for (UUID targetId : targets) {
                Card card = targetPlayer.getLibrary().remove(targetId, game);
                if (card != null) {
                    card.moveToExile(null, "", source, game);
                }
            }
        }
        targetPlayer.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 67 with Card

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

the class RunoStromkirkEffect 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.lookAtCards(null, card, game);
    if (!player.chooseUse(outcome, "Reveal " + card.getName() + '?', source, game)) {
        return true;
    }
    player.revealCards(source, new CardsImpl(card), game);
    if (!card.isCreature(game) || card.getManaValue() < 6) {
        return true;
    }
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent != null) {
        permanent.transform(source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 68 with Card

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

the class SenTripletsPlayFromOpponentsHandEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    Card card = game.getCard(objectId);
    Zone zone;
    if (card instanceof Spell) {
        zone = ((Spell) card).getFromZone();
    } else if (card != null) {
        zone = game.getState().getZone(card.getMainCard().getId());
    } else {
        return false;
    }
    return card.isOwnedBy(getTargetPointer().getFirst(game, source)) && zone == Zone.HAND && source.isControlledBy(affectedControllerId);
}
Also used : Spell(mage.game.stack.Spell) Card(mage.cards.Card)

Example 69 with Card

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

the class SefrisOfTheHiddenWaysTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Boolean applies = false;
    /*
        Sefris of the Hidden Ways must be on the battlefield for its first ability to trigger. 
        It does not trigger when Sefris goes to the graveyard from the battlefield, even if other 
        creature cards also went to the graveyard at the same time.
         */
    Permanent sourceCard = game.getPermanent(sourceId);
    if (((ZoneChangeGroupEvent) event).getToZone() != Zone.GRAVEYARD || sourceCard == null) {
        return false;
    }
    ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
    Set<Card> cards = zEvent.getCards();
    for (Card card : cards) {
        if (card.isCreature(game) && // 603.6c, 603.10a, and 603.10.
        (Card) sourceCard != card && !card.isCopy() && card.isOwnedBy(controllerId)) {
            applies = true;
        }
    }
    return applies;
}
Also used : Permanent(mage.game.permanent.Permanent) ZoneChangeGroupEvent(mage.game.events.ZoneChangeGroupEvent) Card(mage.cards.Card)

Example 70 with Card

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

the class SifterWurmEffect 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) {
        controller.scry(3, source, game);
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            Cards cards = new CardsImpl();
            cards.add(card);
            controller.revealCards(sourceObject.getIdName(), cards, game);
            controller.gainLife(card.getManaValue(), game, source);
        }
        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)

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