Search in sources :

Example 46 with Card

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

the class LongRoadHomeEntersBattlefieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(objectToReturn.getSourceId());
    if (card != null && objectToReturn.refersTo(card, game)) {
        Player owner = game.getPlayer(card.getOwnerId());
        if (owner != null) {
            if (card instanceof MeldCard) {
                MeldCard meldCard = (MeldCard) card;
                game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getTopHalfCard(), game)), source);
                game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getBottomHalfCard(), game)), source);
            } else {
                game.addEffect(new LongRoadHomeEntersBattlefieldEffect(objectToReturn), source);
            }
            owner.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) MeldCard(mage.cards.MeldCard) MageObjectReference(mage.MageObjectReference) MeldCard(mage.cards.MeldCard) Card(mage.cards.Card)

Example 47 with Card

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

the class LongTermPlansEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        TargetCardInLibrary target = new TargetCardInLibrary();
        if (player.searchLibrary(target, source, game)) {
            Card card = player.getLibrary().remove(target.getFirstTarget(), game);
            if (card != null) {
                player.shuffleLibrary(source, game);
                // must hides the card name from other players
                player.putCardOnTopXOfLibrary(card, game, source, 3, false);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Card(mage.cards.Card)

Example 48 with Card

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

the class LorcanWarlockCollectorReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (player == null || card == null) {
        return false;
    }
    Cost cost = new PayLifeCost(card.getManaValue());
    if (!cost.canPay(source, source, source.getControllerId(), game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    game.addEffect(new AddCardSubTypeTargetEffect(SubType.WARLOCK, Duration.Custom).setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1)), source);
    player.moveCards(card, Zone.BATTLEFIELD, source, game);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) Card(mage.cards.Card) AddCardSubTypeTargetEffect(mage.abilities.effects.common.continuous.AddCardSubTypeTargetEffect)

Example 49 with Card

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

the class LostHoursEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (targetPlayer != null && controller != null) {
        targetPlayer.revealCards(source, targetPlayer.getHand(), game);
        if (targetPlayer.getHand().size() > 0) {
            TargetCard target = new TargetCard(Zone.HAND, new FilterCard(StaticFilters.FILTER_CARD_A_NON_LAND));
            if (controller.choose(Outcome.Discard, targetPlayer.getHand(), target, game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    targetPlayer.putCardOnTopXOfLibrary(card, game, source, 3, true);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 50 with Card

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

the class LordOfTheVoidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (player == null || controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 7));
    controller.moveCards(cards, Zone.EXILED, source, game);
    if (!cards.getCards(StaticFilters.FILTER_CARD_CREATURE, game).isEmpty()) {
        TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_CREATURE);
        if (controller.chooseTarget(outcome, cards, target, source, game)) {
            Card card = cards.get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, false, null);
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) 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