Search in sources :

Example 11 with TargetPlayer

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

the class WandOfDenialEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (controller != null && targetPlayer != null) {
        Card card = targetPlayer.getLibrary().getFromTop(game);
        if (card != null) {
            MageObject sourceObject = game.getObject(source.getSourceId());
            controller.lookAtCards(sourceObject != null ? sourceObject.getName() : "", new CardsImpl(card), game);
            if (!card.isLand(game) && controller.canPayLifeCost(source) && controller.getLife() >= 2 && controller.chooseUse(Outcome.Neutral, "Pay 2 life to put " + card.getLogName() + " into graveyard?", source, game)) {
                controller.loseLife(2, game, source, false);
                controller.moveCards(card, Zone.GRAVEYARD, source, game);
            }
            return true;
        }
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) MageObject(mage.MageObject) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 12 with TargetPlayer

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

the class GainLifeOpponentCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        TargetPlayer target = new TargetPlayer(1, 1, true, filter);
        if (controller.chooseTarget(Outcome.Detriment, target, ability, game)) {
            Player opponent = game.getPlayer(target.getFirstTarget());
            if (opponent != null) {
                opponent.gainLife(amount, game, source);
                paid = true;
            }
        }
    }
    return paid;
}
Also used : FilterPlayer(mage.filter.FilterPlayer) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer)

Example 13 with TargetPlayer

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

the class ArchitectsOfWillEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (targetPlayer == null || controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 3));
    controller.lookAtCards(source, null, cards, game);
    controller.putCardsOnTopOfLibrary(cards, game, source, true);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player)

Example 14 with TargetPlayer

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

the class CompulsiveResearchDiscardEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (targetPlayer == null || targetPlayer.getHand().isEmpty()) {
        return false;
    }
    if (targetPlayer.getHand().count(StaticFilters.FILTER_CARD_LAND, game) < 1 || !targetPlayer.chooseUse(outcome, "Discard a land card?", source, game)) {
        return !targetPlayer.discard(2, false, false, source, game).isEmpty();
    }
    TargetDiscard target = new TargetDiscard(StaticFilters.FILTER_CARD_LAND_A, targetPlayer.getId());
    targetPlayer.choose(Outcome.Discard, target, source.getSourceId(), game);
    Card card = targetPlayer.getHand().get(target.getFirstTarget(), game);
    if (card != null && targetPlayer.discard(card, false, source, game)) {
        return true;
    }
    return !targetPlayer.discard(2, false, false, source, game).isEmpty();
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetDiscard(mage.target.common.TargetDiscard) Card(mage.cards.Card)

Example 15 with TargetPlayer

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

the class CollectiveDefianceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetPlayer == null) {
        return false;
    }
    int count = targetPlayer.discard(targetPlayer.getHand(), false, source, game).size();
    targetPlayer.drawCards(count, source, game);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterPlayer(mage.filter.FilterPlayer)

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