Search in sources :

Example 21 with FixedTargets

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

the class KillSwitchUntapEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ARTIFACT, source.getControllerId(), source.getSourceId(), game);
    Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
    if (sourcePermanent != null) {
        permanents.remove(sourcePermanent);
        game.addEffect(new KillSwitchUntapEffect().setTargetPointer(new FixedTargets(permanents, game)), source);
    }
    for (Permanent permanent : permanents) {
        permanent.tap(source, game);
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets)

Example 22 with FixedTargets

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

the class WakeThePastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_ARTIFACT, game));
    if (cards.isEmpty()) {
        return false;
    }
    player.moveCards(cards, Zone.BATTLEFIELD, source, game);
    cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.BATTLEFIELD);
    if (cards.isEmpty()) {
        return true;
    }
    game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(cards, game)), source);
    return true;
}
Also used : Player(mage.players.Player) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 23 with FixedTargets

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

the class ExileTopXMayPlayUntilEndOfTurnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
    if (cards.isEmpty()) {
        return true;
    }
    controller.moveCardsToExile(cards, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
    // remove cards that could not be moved to exile
    cards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId())));
    if (!cards.isEmpty()) {
        game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, duration).setTargetPointer(new FixedTargets(cards, game)), source);
    }
    return true;
}
Also used : Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) Card(mage.cards.Card)

Example 24 with FixedTargets

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

the class FogPatchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Effect effect = new BecomeBlockedTargetEffect();
    effect.setTargetPointer(new FixedTargets(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_ATTACKING_CREATURES, source.getSourceId(), game), game));
    return effect.apply(game, source);
}
Also used : BecomeBlockedTargetEffect(mage.abilities.effects.common.BecomeBlockedTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) OneShotEffect(mage.abilities.effects.OneShotEffect) BecomeBlockedTargetEffect(mage.abilities.effects.common.BecomeBlockedTargetEffect) Effect(mage.abilities.effects.Effect)

Example 25 with FixedTargets

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

the class GhostwayEffect 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) {
        Set<Card> toExile = new HashSet<>();
        toExile.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game));
        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.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;
    }
    return false;
}
Also used : Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FixedTargets(mage.target.targetpointer.FixedTargets) MageObject(mage.MageObject) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID) HashSet(java.util.HashSet)

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