Search in sources :

Example 66 with TargetPlayer

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

the class GerrardsVerdictEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (controller != null && targetPlayer != null) {
        controller.gainLife(targetPlayer.discard(2, false, false, source, game).count(new FilterLandCard(), game) * 3, game, source);
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterLandCard(mage.filter.common.FilterLandCard)

Example 67 with TargetPlayer

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

the class GraveyardShovelEffect 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 || targetPlayer.getGraveyard().isEmpty()) {
        return false;
    }
    TargetCardInYourGraveyard target = new TargetCardInYourGraveyard();
    target.setNotTarget(true);
    targetPlayer.chooseTarget(Outcome.Exile, target, source, game);
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return true;
    }
    targetPlayer.moveCards(card, Zone.EXILED, source, game);
    if (card.isCreature(game)) {
        controller.gainLife(2, game, source);
    }
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Card(mage.cards.Card)

Example 68 with TargetPlayer

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

the class InfernalKirinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
    if (spell == null) {
        return false;
    }
    int cmc = spell.getManaValue();
    Player targetPlayer = null;
    for (Target target : source.getTargets()) {
        if (target instanceof TargetPlayer) {
            targetPlayer = game.getPlayer(target.getFirstTarget());
        }
    }
    if (targetPlayer == null) {
        return false;
    }
    if (targetPlayer.getHand().isEmpty()) {
        return true;
    }
    targetPlayer.revealCards(source, targetPlayer.getHand(), game);
    Cards cards = targetPlayer.getHand().copy();
    cards.removeIf(uuid -> game.getCard(uuid).getManaValue() != cmc);
    targetPlayer.discard(cards, false, source, game);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Target(mage.target.Target) Spell(mage.game.stack.Spell) TargetPlayer(mage.target.TargetPlayer) Cards(mage.cards.Cards)

Example 69 with TargetPlayer

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

the class LeechesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (targetPlayer == null) {
        return false;
    }
    int countPoisonCounters = targetPlayer.getCounters().getCount(CounterType.POISON);
    if (countPoisonCounters > 0) {
        targetPlayer.removeCounters(CounterType.POISON.getName(), countPoisonCounters, source, game);
        targetPlayer.damage(countPoisonCounters, source.getSourceId(), source, game);
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player)

Example 70 with TargetPlayer

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

the class SearchWarrantEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (player != null && targetPlayer != null) {
        targetPlayer.revealCards("Search Warrant", targetPlayer.getHand(), game);
        int ctd = targetPlayer.getHand().size();
        player.gainLife(ctd, game, source);
        return true;
    }
    return false;
}
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