Search in sources :

Example 91 with TargetPlayer

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

the class PersecuteEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    ChoiceColor choice = new ChoiceColor();
    if (controller == null || sourceObject == null || targetPlayer == null || !controller.choose(outcome, choice, game)) {
        return false;
    }
    FilterCard filterCard = new FilterCard();
    filterCard.add(new ColorPredicate(choice.getColor()));
    targetPlayer.revealCards(source, targetPlayer.getHand(), game);
    targetPlayer.discard(new CardsImpl(targetPlayer.getHand().getCards(filterCard, game)), false, source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) MageObject(mage.MageObject) ChoiceColor(mage.choices.ChoiceColor) CardsImpl(mage.cards.CardsImpl)

Example 92 with TargetPlayer

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

the class PersonalIncarnationLoseHalfLifeEffect method applies.

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

Example 93 with TargetPlayer

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

the class PeerIntoTheAbyssEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (targetPlayer == null) {
        return false;
    }
    targetPlayer.drawCards((int) Math.ceil(targetPlayer.getLibrary().size() / 2.0), source, game);
    targetPlayer.loseLife((int) Math.ceil(targetPlayer.getLife() / 2.0), game, source, false);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player)

Example 94 with TargetPlayer

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

the class SeasonsBeatingsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetPlayer != null) {
        Map<Integer, UUID> creatures = new HashMap<>();
        int numCreature = 0;
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, targetPlayer.getId(), game)) {
            if (permanent != null) {
                creatures.put(numCreature, permanent.getId());
                numCreature++;
            }
        }
        if (numCreature < 2) {
            return true;
        }
        for (Integer i : creatures.keySet()) {
            Permanent creature = game.getPermanent(creatures.get(i));
            int other = RandomUtil.nextInt(numCreature);
            while (other == i) {
                other = RandomUtil.nextInt(numCreature);
            }
            Permanent creature2 = game.getPermanent(creatures.get(other));
            if (creature != null && creature2 != null) {
                creature2.damage(creature.getPower().getValue(), creature.getId(), source, game, false, true);
            }
        }
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) HashMap(java.util.HashMap) UUID(java.util.UUID)

Example 95 with TargetPlayer

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

the class TezzeretAgentOfBolasEffect2 method apply.

@Override
public boolean apply(Game game, Ability source) {
    int count = new PermanentsOnBattlefieldCount(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT).calculate(game, source, this) * 2;
    if (count > 0) {
        Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
        if (targetPlayer != null) {
            targetPlayer.loseLife(count, game, source, false);
        }
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            controller.gainLife(count, game, source);
        }
    }
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)

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