Search in sources :

Example 71 with CardsImpl

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

the class PrimitiveEtchingsAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getPlayerId().equals(this.getControllerId())) {
        if (game.isActivePlayer(this.getControllerId()) && this.lastTriggeredTurn != game.getTurnNum()) {
            Card card = game.getCard(event.getTargetId());
            Player controller = game.getPlayer(this.getControllerId());
            Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(this.getSourceId());
            if (card != null && controller != null && sourcePermanent != null) {
                lastTriggeredTurn = game.getTurnNum();
                controller.revealCards(sourcePermanent.getName(), new CardsImpl(card), game);
                this.getEffects().clear();
                if (card.isCreature(game)) {
                    this.addEffect(new DrawCardSourceControllerEffect(1));
                }
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 72 with CardsImpl

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

the class RaidersKarveEffect 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) {
        return false;
    }
    Card card = controller.getLibrary().getFromTop(game);
    if (card == null) {
        return true;
    }
    controller.lookAtCards(sourceObject.getIdName(), new CardsImpl(card), game);
    if (!card.isLand(game)) {
        return true;
    }
    String message = "Put " + card.getLogName() + " onto the battlefield tapped?";
    if (controller.chooseUse(Outcome.PutLandInPlay, message, source, game)) {
        controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
    }
    return true;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 73 with CardsImpl

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

the class RiddleOfLightningEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card sourceCard = game.getCard(source.getSourceId());
    if (sourceCard != null && controller != null) {
        if (controller.getLibrary().hasCards()) {
            Card card = controller.getLibrary().getFromTop(game);
            controller.revealCards(sourceCard.getName(), new CardsImpl(card), game);
            Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
            if (targetCreature != null) {
                targetCreature.damage(card.getManaValue(), source.getSourceId(), source, game, false, true);
                return true;
            }
            Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
            if (targetPlayer != null) {
                targetPlayer.damage(card.getManaValue(), source.getSourceId(), source, game);
                return true;
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 74 with CardsImpl

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

the class ReyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetPlayer != null && controller != null) {
        if (targetPlayer.getLibrary().hasCards()) {
            // reveal the top card of target player's library.
            Card topCard = targetPlayer.getLibrary().getFromTop(game);
            CardsImpl reveal = new CardsImpl();
            reveal.add(topCard);
            targetPlayer.revealCards(source, reveal, game);
            // You gain life equal to that card's converted mana cost.
            if (topCard != null) {
                controller.gainLife(topCard.getManaValue(), game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 75 with CardsImpl

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

the class SawtoothLoonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        controller.drawCards(2, source, game);
        TargetCardInHand target = new TargetCardInHand(2, 2, new FilterCard());
        controller.chooseTarget(Outcome.Detriment, target, source, game);
        Cards cardsToLibrary = new CardsImpl(target.getTargets());
        if (!cardsToLibrary.isEmpty()) {
            controller.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, false);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) Cards(mage.cards.Cards) 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