Search in sources :

Example 36 with FixedTargets

use of mage.target.targetpointer.FixedTargets in project mage by magefree.

the class TwinflameCopyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        List<Permanent> toExile = new ArrayList<>();
        for (UUID creatureId : this.getTargetPointer().getTargets(game, source)) {
            Permanent creature = game.getPermanentOrLKIBattlefield(creatureId);
            if (creature != null) {
                CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
                effect.setTargetPointer(new FixedTarget(creature, game));
                effect.apply(game, source);
                toExile.addAll(effect.getAddedPermanents());
            }
        }
        ExileTargetEffect exileEffect = new ExileTargetEffect();
        exileEffect.setTargetPointer(new FixedTargets(toExile, game));
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) FixedTargets(mage.target.targetpointer.FixedTargets) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ArrayList(java.util.ArrayList) UUID(java.util.UUID) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 37 with FixedTargets

use of mage.target.targetpointer.FixedTargets in project mage by magefree.

the class VanishIntoMemoryEntersBattlefieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Cards cards = new CardsImpl(getTargetPointer().getTargets(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Set<Card> cardsToBattlefield = new HashSet<>();
        cardsToBattlefield.addAll(cards.getCards(game));
        ContinuousEffect effect = new VanishIntoMemoryEntersBattlefieldEffect();
        effect.setTargetPointer(new FixedTargets(cards, game));
        game.addEffect(effect, source);
        controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null);
    }
    return true;
}
Also used : Player(mage.players.Player) FixedTargets(mage.target.targetpointer.FixedTargets) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 38 with FixedTargets

use of mage.target.targetpointer.FixedTargets in project mage by magefree.

the class PollenLullabyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (player != null) {
        List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
        for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
            doNotUntapNextUntapStep.add(creature);
        }
        if (!doNotUntapNextUntapStep.isEmpty()) {
            ContinuousEffect effect = new DontUntapInControllersNextUntapStepTargetEffect("This creature");
            effect.setTargetPointer(new FixedTargets(doNotUntapNextUntapStep, game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DontUntapInControllersNextUntapStepTargetEffect(mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) ArrayList(java.util.ArrayList) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 39 with FixedTargets

use of mage.target.targetpointer.FixedTargets in project mage by magefree.

the class ThatcherRevoltEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ThatcherHumanToken token = new ThatcherHumanToken();
    token.putOntoBattlefield(3, game, source, source.getControllerId());
    List<Permanent> toSacrifice = new ArrayList<>();
    for (UUID tokenId : token.getLastAddedTokenIds()) {
        Permanent tokenPermanent = game.getPermanent(tokenId);
        if (tokenPermanent != null) {
            toSacrifice.add(tokenPermanent);
        }
    }
    SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect();
    sacrificeEffect.setTargetPointer(new FixedTargets(toSacrifice, game));
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
    return true;
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) ThatcherHumanToken(mage.game.permanent.token.ThatcherHumanToken) ArrayList(java.util.ArrayList) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) UUID(java.util.UUID)

Example 40 with FixedTargets

use of mage.target.targetpointer.FixedTargets in project mage by magefree.

the class YorionSkyNomadEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (sourceObject == null || controller == null) {
        return false;
    }
    TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
    controller.choose(outcome, target, source.getSourceId(), game);
    Set<Card> toExile = target.getTargets().stream().map(game::getPermanent).collect(Collectors.toSet());
    UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
    controller.moveCardsToExile(toExile, source, game, true, exileId, sourceObject.getIdName());
    Cards cardsToReturn = new CardsImpl();
    for (Card exiled : toExile) {
        if (exiled instanceof PermanentMeld) {
            MeldCard meldCard = (MeldCard) ((PermanentCard) exiled).getCard();
            Card topCard = meldCard.getTopHalfCard();
            Card bottomCard = meldCard.getBottomHalfCard();
            if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter()) {
                cardsToReturn.add(topCard);
            }
            if (bottomCard.getZoneChangeCounter(game) == meldCard.getBottomLastZoneChangeCounter()) {
                cardsToReturn.add(bottomCard);
            }
        } else if (exiled.getZoneChangeCounter(game) == game.getState().getZoneChangeCounter(exiled.getId()) - 1) {
            cardsToReturn.add(exiled);
        }
    }
    Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
    effect.setTargetPointer(new FixedTargets(cardsToReturn, game));
    AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : Player(mage.players.Player) FixedTargets(mage.target.targetpointer.FixedTargets) MageObject(mage.MageObject) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) PermanentCard(mage.game.permanent.PermanentCard) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) PermanentMeld(mage.game.permanent.PermanentMeld) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID)

Aggregations

FixedTargets (mage.target.targetpointer.FixedTargets)58 Player (mage.players.Player)36 Permanent (mage.game.permanent.Permanent)28 ArrayList (java.util.ArrayList)19 UUID (java.util.UUID)19 OneShotEffect (mage.abilities.effects.OneShotEffect)15 CardsImpl (mage.cards.CardsImpl)15 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)14 ContinuousEffect (mage.abilities.effects.ContinuousEffect)14 Effect (mage.abilities.effects.Effect)14 Card (mage.cards.Card)14 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)13 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)10 Cards (mage.cards.Cards)10 Token (mage.game.permanent.token.Token)9 TargetPermanent (mage.target.TargetPermanent)8 HashSet (java.util.HashSet)7 MageObject (mage.MageObject)7 DontUntapInControllersNextUntapStepTargetEffect (mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect)7 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)6