Search in sources :

Example 56 with TargetPlayer

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

the class ScrabblingClawsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (targetPlayer == null) {
        return false;
    }
    FilterCard filter = new FilterCard("card from your graveyard");
    filter.add(new OwnerIdPredicate(targetPlayer.getId()));
    TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
    if (!targetPlayer.chooseTarget(Outcome.Exile, target, source, game)) {
        return false;
    }
    Card card = game.getCard(target.getFirstTarget());
    return card != null && targetPlayer.moveCards(card, Zone.EXILED, source, game);
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 57 with TargetPlayer

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

the class SludgeStriderEffect 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) {
        targetPlayer.loseLife(1, game, source, false);
    }
    if (you != null) {
        you.gainLife(1, game, source);
    }
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player)

Example 58 with TargetPlayer

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

the class AegisOfHonorEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (event.getTargetId().equals(source.getControllerId())) {
        // Checks to see the damage is to Aegis of Honor's controller
        Spell spell = null;
        StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
        if (stackObject == null) {
            stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
        }
        if (stackObject instanceof Spell) {
            spell = (Spell) stackObject;
        }
        // Checks if damage is from a sorcery or instants
        if (spell != null && instantOrSorceryfilter.match(spell.getCard(), game)) {
            TargetPlayer target = new TargetPlayer();
            target.add(spell.getControllerId(), game);
            redirectTarget = target;
            return true;
        }
    }
    return false;
}
Also used : StackObject(mage.game.stack.StackObject) Spell(mage.game.stack.Spell) TargetPlayer(mage.target.TargetPlayer)

Example 59 with TargetPlayer

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

the class BitterFeudEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanentEntering(source.getSourceId());
    if (controller != null && permanent != null) {
        TargetPlayer target = new TargetPlayer(2, 2, true);
        controller.chooseTarget(outcome, target, source, game);
        Player player1 = game.getPlayer(target.getFirstTarget());
        if (target.getTargets().size() > 1) {
            Player player2 = game.getPlayer(target.getTargets().get(1));
            if (player1 != null && player2 != null) {
                game.getState().setValue(source.getSourceId() + "_player1", player1);
                game.getState().setValue(source.getSourceId() + "_player2", player2);
                game.informPlayers(permanent.getLogName() + ": " + controller.getLogName() + " has chosen " + player1.getLogName() + " and " + player2.getLogName());
                permanent.addInfo("chosen players", "<font color = 'blue'>Chosen players: " + player1.getName() + ", " + player2.getName() + "</font>", game);
                return true;
            }
        }
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPlayer(mage.target.TargetPlayer)

Example 60 with TargetPlayer

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

the class BitterOrdealEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && targetPlayer != null) {
        TargetCardInLibrary target = new TargetCardInLibrary();
        if (controller.searchLibrary(target, source, game, targetPlayer.getId())) {
            Card card = targetPlayer.getLibrary().getCard(target.getFirstTarget(), game);
            if (card != null) {
                controller.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) Card(mage.cards.Card)

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