Search in sources :

Example 6 with FixedTargets

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

the class ExileFromGraveCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
            for (UUID targetId : targets.get(0).getTargets()) {
                Card card = game.getCard(targetId);
                if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) {
                    return false;
                }
                exiledCards.add(card);
            }
            Cards cardsToExile = new CardsImpl();
            cardsToExile.addAll(exiledCards);
            controller.moveCardsToExile(cardsToExile.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
            if (setTargetPointer) {
                source.getEffects().setTargetPointer(new FixedTargets(cardsToExile, game));
            }
            paid = true;
        }
    }
    return paid;
}
Also used : Player(mage.players.Player) FixedTargets(mage.target.targetpointer.FixedTargets) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 7 with FixedTargets

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

the class DorotheasRetributionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new DorotheasRetributionSpiritToken();
    token.putOntoBattlefield(1, game, source, source.getControllerId(), true, true);
    game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(new SacrificeTargetEffect().setTargetPointer(new FixedTargets(token, game)).setText("sacrifce that token")), source);
    return true;
}
Also used : FixedTargets(mage.target.targetpointer.FixedTargets) DorotheasRetributionSpiritToken(mage.game.permanent.token.DorotheasRetributionSpiritToken) DorotheasRetributionSpiritToken(mage.game.permanent.token.DorotheasRetributionSpiritToken) Token(mage.game.permanent.token.Token) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect)

Example 8 with FixedTargets

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

the class DollhouseOfHorrorsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card == null) {
        return false;
    }
    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), CardType.ARTIFACT, false, 1, false, false, null, 0, 0, false);
    effect.setSavedPermanent(new PermanentCard(card, source.getControllerId(), game));
    effect.setAdditionalSubType(SubType.CONSTRUCT);
    effect.addAdditionalAbilities(new SimpleStaticAbility(new BoostSourceEffect(ArtifactYouControlCount.instance, ArtifactYouControlCount.instance, Duration.WhileOnBattlefield).setText("This creature gets +1/+1 for each artifact you control")));
    effect.apply(game, source);
    game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(effect.getAddedPermanents(), game)), source);
    return true;
}
Also used : BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) FixedTargets(mage.target.targetpointer.FixedTargets) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Card(mage.cards.Card) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 9 with FixedTargets

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

the class GisaGloriousResurrectorReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Ability exiledWithSource = (Ability) game.getState().getValue("GisaGloriousResurrectorExile" + source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()));
    if (exiledWithSource == null) {
        return false;
    }
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, exiledWithSource));
    if (player == null || exileZone == null || exileZone.isEmpty()) {
        return false;
    }
    Cards cards = new CardsImpl(exileZone.getCards(StaticFilters.FILTER_CARD_CREATURE, game));
    if (cards.isEmpty()) {
        return false;
    }
    player.moveCards(cards, Zone.BATTLEFIELD, source, game);
    cards.retainZone(Zone.BATTLEFIELD, game);
    if (cards.isEmpty()) {
        return false;
    }
    game.addEffect(new GainAbilityTargetEffect(new DecayedAbility(), Duration.Custom).setTargetPointer(new FixedTargets(cards, game)), source);
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) DecayedAbility(mage.abilities.keyword.DecayedAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ExileZone(mage.game.ExileZone) DecayedAbility(mage.abilities.keyword.DecayedAbility) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 10 with FixedTargets

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

the class TangleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            doNotUntapNextUntapStep.add(permanent);
        }
        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) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DontUntapInControllersNextUntapStepTargetEffect(mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) ArrayList(java.util.ArrayList) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

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