Search in sources :

Example 31 with TargetPlayer

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

the class CryptIncursionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    Cards cards = new CardsImpl(targetPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
    player.moveCards(cards, Zone.EXILED, source, game);
    int count = cards.stream().map(game.getState()::getZone).map(Zone.EXILED::equals).mapToInt(x -> x ? 1 : 0).sum();
    player.gainLife(3 * count, game, source);
    return true;
}
Also used : StaticFilters(mage.filter.StaticFilters) Zone(mage.constants.Zone) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) TargetPlayer(mage.target.TargetPlayer) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 32 with TargetPlayer

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

the class HopeOfGhirapurCombatDamageWatcher method apply.

@Override
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
    Player targetPlayer = input.getObject();
    if (targetPlayer == null) {
        return false;
    }
    HopeOfGhirapurCombatDamageWatcher watcher = game.getState().getWatcher(HopeOfGhirapurCombatDamageWatcher.class);
    if (watcher != null) {
        return watcher.playerGotCombatDamage(input.getSourceId(), input.getObject().getId(), game);
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterPlayer(mage.filter.FilterPlayer) ObjectSourcePlayer(mage.filter.predicate.ObjectSourcePlayer)

Example 33 with TargetPlayer

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

the class NaturalSelectionEffect 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);
    if (controller.chooseUse(Outcome.Neutral, "You may have that player shuffle", source, game)) {
        targetPlayer.shuffleLibrary(source, game);
    }
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 34 with TargetPlayer

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

the class TorgaarFamineIncarnateEffectCostReductionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (targetPlayer != null) {
        int startingLifeTotal = game.getStartingLife();
        targetPlayer.setLife(startingLifeTotal / 2, game, source);
    }
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player)

Example 35 with TargetPlayer

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

the class VoidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int number = controller.announceXMana(0, Integer.MAX_VALUE, this.staticText, game, source);
    game.informPlayers(controller.getLogName() + " chooses " + number + '.');
    for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
        if ((permanent.isArtifact(game) || permanent.isCreature(game)) && permanent.getManaValue() == number) {
            permanent.destroy(source, game, false);
        }
    }
    FilterCard filterCard = new FilterCard();
    filterCard.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, number));
    filterCard.add(Predicates.not(CardType.LAND.getPredicate()));
    Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetPlayer == null) {
        return true;
    }
    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) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Permanent(mage.game.permanent.Permanent) CardsImpl(mage.cards.CardsImpl)

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