Search in sources :

Example 11 with FixedTargets

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

the class WaylayEffect method apply.

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

Example 12 with FixedTargets

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

the class CreateTokenCopyTargetEffect method removeTokensCreatedAtEndOf.

private void removeTokensCreatedAtEndOf(Game game, Ability source, PhaseStep phaseStepToExileCards, boolean exile) {
    Effect effect;
    if (exile) {
        effect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD).setText("exile the token copies");
    } else {
        effect = new SacrificeTargetEffect("sacrifice the token copies");
    }
    effect.setTargetPointer(new FixedTargets(addedTokenPermanents, game));
    DelayedTriggeredAbility exileAbility;
    switch(phaseStepToExileCards) {
        case END_TURN:
            exileAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
            break;
        case END_COMBAT:
            exileAbility = new AtTheEndOfCombatDelayedTriggeredAbility(effect);
            break;
        default:
            return;
    }
    game.addDelayedTriggeredAbility(exileAbility, source);
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FixedTargets(mage.target.targetpointer.FixedTargets) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)

Example 13 with FixedTargets

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

the class BerserkersFrenzyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetPermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE);
    target.setNotTarget(true);
    player.choose(outcome, target, source.getSourceId(), game);
    game.addEffect(new BlocksIfAbleTargetEffect(Duration.EndOfTurn).setTargetPointer(new FixedTargets(new CardsImpl(target.getTargets()), game)), source);
    return true;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) TargetPermanent(mage.target.TargetPermanent) CardsImpl(mage.cards.CardsImpl)

Example 14 with FixedTargets

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

the class BurnDownTheHouseEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new DevilToken();
    token.putOntoBattlefield(3, game, source, source.getControllerId());
    game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(token, game)), source);
    return true;
}
Also used : FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) Token(mage.game.permanent.token.Token) DevilToken(mage.game.permanent.token.DevilToken) DevilToken(mage.game.permanent.token.DevilToken)

Example 15 with FixedTargets

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

the class DreamPillagerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        int amount = (Integer) getValue("damage");
        if (amount > 0) {
            Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
            if (!cards.isEmpty()) {
                controller.moveCards(cards, Zone.EXILED, source, game);
                Cards canBeCast = new CardsImpl();
                for (Card card : cards) {
                    if (!card.isLand(game)) {
                        canBeCast.add(card);
                    }
                }
                ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
                effect.setTargetPointer(new FixedTargets(canBeCast, game));
                game.addEffect(effect, source);
            }
            return true;
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

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