Search in sources :

Example 6 with TargetPlayer

use of mage.target.TargetPlayer 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 7 with TargetPlayer

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

the class LoreholdCommandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (targetPlayer != null) {
        targetPlayer.damage(3, source.getSourceId(), source, game);
    }
    Permanent targetPermanent = game.getPermanent(source.getFirstTarget());
    if (targetPermanent != null) {
        targetPermanent.damage(3, source.getSourceId(), source, game);
    }
    Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());
    if (player != null) {
        player.gainLife(3, game, source);
    }
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

Example 8 with TargetPlayer

use of mage.target.TargetPlayer 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 9 with TargetPlayer

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

the class SufferThePastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterCard filter = new FilterCard("card in target player's graveyard");
    int numberExiled = 0;
    Player you = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetPlayer != null) {
        int numberToTarget = Math.min(targetPlayer.getGraveyard().size(), source.getManaCostsToPay().getX());
        TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(numberToTarget, numberToTarget, filter);
        if (you != null) {
            if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) {
                if (!target.getTargets().isEmpty()) {
                    List<UUID> targets = target.getTargets();
                    for (UUID targetId : targets) {
                        Card card = game.getCard(targetId);
                        if (card != null) {
                            card.moveToExile(id, "Suffer the Past", source, game);
                            numberExiled++;
                        }
                    }
                    you.gainLife(numberExiled, game, source);
                    targetPlayer.loseLife(numberExiled, game, source, false);
                }
            }
            return true;
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCardInOpponentsGraveyard(mage.target.common.TargetCardInOpponentsGraveyard) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 10 with TargetPlayer

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

the class VassalsDutyPreventDamageTargetEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
        TargetPlayer target = new TargetPlayer();
        target.add(source.getControllerId(), game);
        redirectTarget = target;
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer)

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