Search in sources :

Example 86 with TargetPlayer

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

the class EmberGaleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (targetPlayer != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(targetPlayer.getId()));
        RestrictionEffect effect = new CantBlockAllEffect(filter, Duration.EndOfTurn);
        game.addEffect(effect, source);
        FilterPermanent filter2 = new FilterPermanent();
        filter2.add(new ControllerIdPredicate(targetPlayer.getId()));
        filter2.add(Predicates.or(new ColorPredicate(ObjectColor.WHITE), new ColorPredicate(ObjectColor.BLUE)));
        filter2.add(CardType.CREATURE.getPredicate());
        for (Permanent creature : game.getBattlefield().getAllActivePermanents(filter2, targetPlayer.getId(), game)) {
            creature.damage(1, source.getSourceId(), source, game, false, true);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) CantBlockAllEffect(mage.abilities.effects.common.combat.CantBlockAllEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) RestrictionEffect(mage.abilities.effects.RestrictionEffect)

Example 87 with TargetPlayer

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

the class EquipoiseEffect 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) {
        if (!Objects.equals(targetPlayer, controller)) {
            phaseOutCardType(controller, targetPlayer, CardType.LAND, source, game);
            phaseOutCardType(controller, targetPlayer, CardType.ARTIFACT, source, game);
            phaseOutCardType(controller, targetPlayer, CardType.CREATURE, source, game);
        }
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player)

Example 88 with TargetPlayer

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

the class RunEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getTargets().getFirstTarget());
    if (targetPlayer != null) {
        FilterControlledPermanent filter = new FilterControlledPermanent("artifact or creature");
        filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate()));
        TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
        if (target.canChoose(source.getSourceId(), targetPlayer.getId(), game)) {
            targetPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
            Permanent permanent = game.getPermanent(target.getFirstTarget());
            if (permanent != null) {
                permanent.sacrifice(source, game);
                int damage = permanent.getManaValue();
                if (damage > 0) {
                    targetPlayer.damage(damage, source.getSourceId(), source, game);
                }
            }
        }
    }
    return true;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent)

Example 89 with TargetPlayer

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

the class LilianasIndignationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    if (xValue < 1) {
        return true;
    }
    int creatures = controller.millCards(xValue, source, game).getCards(game).stream().filter(Objects::nonNull).filter(card -> game.getState().getZone(card.getId()) == Zone.GRAVEYARD).filter(card1 -> card1.isCreature(game)).mapToInt(x -> 2).sum();
    if (creatures > 0) {
        Player targetPlayer = game.getPlayer(source.getFirstTarget());
        if (targetPlayer != null) {
            targetPlayer.loseLife(creatures, game, source, false);
        }
    }
    return true;
}
Also used : CardSetInfo(mage.cards.CardSetInfo) Objects(java.util.Objects) Game(mage.game.Game) Zone(mage.constants.Zone) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) TargetPlayer(mage.target.TargetPlayer) UUID(java.util.UUID) Player(mage.players.Player) Ability(mage.abilities.Ability) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Objects(java.util.Objects)

Example 90 with TargetPlayer

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

the class MindshriekerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (targetPlayer == null) {
        return false;
    }
    int totalCMC = targetPlayer.millCards(1, source, game).getCards(game).stream().filter(Objects::nonNull).mapToInt(MageObject::getManaValue).sum();
    if (totalCMC > 0) {
        game.addEffect(new BoostSourceEffect(totalCMC, totalCMC, Duration.EndOfTurn), source);
    }
    return false;
}
Also used : BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Objects(java.util.Objects)

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