Search in sources :

Example 41 with TargetPlayer

use of mage.target.TargetPlayer in project mage by magefree.

the class ExtortionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    Player you = game.getPlayer(source.getControllerId());
    if (targetPlayer == null || you == null) {
        return false;
    }
    you.lookAtCards("Discard", targetPlayer.getHand(), game);
    TargetCard target = new TargetCardInHand(0, 2, StaticFilters.FILTER_CARD_CARDS);
    target.setNotTarget(true);
    you.choose(Outcome.Discard, targetPlayer.getHand(), target, game);
    targetPlayer.discard(new CardsImpl(target.getTargets()), false, source, game);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCard(mage.target.TargetCard) CardsImpl(mage.cards.CardsImpl)

Example 42 with TargetPlayer

use of mage.target.TargetPlayer in project mage by magefree.

the class ExtractEffect 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(1, 1, filter);
        if (player.searchLibrary(target, source, game, targetPlayer.getId())) {
            Card card = targetPlayer.getLibrary().remove(target.getFirstTarget(), game);
            if (card != null) {
                player.moveCardToExileWithInfo(card, null, null, source, game, Zone.LIBRARY, true);
            }
        }
        targetPlayer.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 43 with TargetPlayer

use of mage.target.TargetPlayer in project mage by magefree.

the class LinessaZephyrMageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Player targetPlayer = game.getPlayer(source.getFirstTarget());
        if (targetPlayer != null) {
            // Target player returns a creature they control to its owner's hand,
            Target target = new TargetControlledCreaturePermanent();
            target.setNotTarget(true);
            if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
                Permanent permanent = game.getPermanent(target.getFirstTarget());
                if (permanent != null) {
                    targetPlayer.moveCards(permanent, Zone.HAND, source, game);
                }
            }
            // then repeats this process for an artifact,
            FilterControlledPermanent filter = new FilterControlledPermanent("artifact you control");
            filter.add(CardType.ARTIFACT.getPredicate());
            target = new TargetControlledPermanent(filter);
            target.setNotTarget(true);
            if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
                Permanent permanent = game.getPermanent(target.getFirstTarget());
                if (permanent != null) {
                    targetPlayer.moveCards(permanent, Zone.HAND, source, game);
                }
            }
            // an enchantment,
            filter = new FilterControlledPermanent("enchantment you control");
            filter.add(CardType.ENCHANTMENT.getPredicate());
            target = new TargetControlledPermanent(filter);
            target.setNotTarget(true);
            if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
                Permanent permanent = game.getPermanent(target.getFirstTarget());
                if (permanent != null) {
                    targetPlayer.moveCards(permanent, Zone.HAND, source, game);
                }
            }
            // and a land.
            filter = new FilterControlledPermanent("land you control");
            filter.add(CardType.LAND.getPredicate());
            target = new TargetControlledPermanent(filter);
            target.setNotTarget(true);
            if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
                Permanent permanent = game.getPermanent(target.getFirstTarget());
                if (permanent != null) {
                    targetPlayer.moveCards(permanent, Zone.HAND, source, game);
                }
            }
            return true;
        }
    }
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer) Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 44 with TargetPlayer

use of mage.target.TargetPlayer in project mage by magefree.

the class MindWarpEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    Player you = game.getPlayer(source.getControllerId());
    if (targetPlayer == null || you == null) {
        return false;
    }
    int amountToDiscard = source.getManaCostsToPay().getX();
    TargetCard target = new TargetCardInHand(amountToDiscard, StaticFilters.FILTER_CARD_CARDS);
    you.choose(outcome, targetPlayer.getHand(), target, game);
    targetPlayer.discard(new CardsImpl(target.getTargets()), false, source, game);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCard(mage.target.TargetCard) CardsImpl(mage.cards.CardsImpl)

Example 45 with TargetPlayer

use of mage.target.TargetPlayer in project mage by magefree.

the class NicolBolasTheArisenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    Player controller = game.getPlayer(source.getControllerId());
    if (targetPlayer == null || controller == null) {
        return false;
    }
    return controller.moveCards(targetPlayer.getLibrary().getTopCards(game, targetPlayer.getLibrary().size() - 1), Zone.EXILED, source, game);
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player)

Aggregations

TargetPlayer (mage.target.TargetPlayer)134 Player (mage.players.Player)129 Card (mage.cards.Card)38 Permanent (mage.game.permanent.Permanent)32 FilterCard (mage.filter.FilterCard)27 UUID (java.util.UUID)25 MageObject (mage.MageObject)16 CardsImpl (mage.cards.CardsImpl)16 FilterPlayer (mage.filter.FilterPlayer)16 TargetCard (mage.target.TargetCard)13 Cards (mage.cards.Cards)12 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)12 ObjectSourcePlayer (mage.filter.predicate.ObjectSourcePlayer)10 Target (mage.target.Target)10 FixedTarget (mage.target.targetpointer.FixedTarget)10 Spell (mage.game.stack.Spell)9 ContinuousEffect (mage.abilities.effects.ContinuousEffect)8 TargetPermanent (mage.target.TargetPermanent)7 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)6 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)5