Search in sources :

Example 46 with FixedTargets

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

the class RiseAndShineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<Permanent> permanents = game.getBattlefield().getActivePermanents(RiseAndShine.filter, source.getControllerId(), source.getSourceId(), game);
    if (permanents.isEmpty()) {
        return false;
    }
    game.addEffect(new AddCardTypeTargetEffect(Duration.EndOfGame, CardType.ARTIFACT, CardType.CREATURE).setTargetPointer(new FixedTargets(permanents, game)), source);
    game.addEffect(new SetPowerToughnessTargetEffect(0, 0, Duration.EndOfGame).setTargetPointer(new FixedTargets(permanents, game)), source);
    for (Permanent permanent : permanents) {
        permanent.addCounters(CounterType.P1P1.createInstance(4), source.getControllerId(), source, game);
    }
    return true;
}
Also used : FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) FixedTargets(mage.target.targetpointer.FixedTargets) SetPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect) AddCardTypeTargetEffect(mage.abilities.effects.common.continuous.AddCardTypeTargetEffect)

Example 47 with FixedTargets

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

the class SuddenDisappearanceEffect 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) {
        Set<Card> permsSet = new HashSet<>(game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game));
        if (!permsSet.isEmpty()) {
            controller.moveCardsToExile(permsSet, source, game, true, source.getSourceId(), sourceObject.getIdName());
            Cards targets = new CardsImpl();
            for (Card card : permsSet) {
                targets.add(card.getId());
            }
            Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, true);
            effect.setText("Return the exiled cards to the battlefield under their owner's control at the beginning of the next end step");
            effect.setTargetPointer(new FixedTargets(targets, game));
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
        }
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) 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) HashSet(java.util.HashSet)

Example 48 with FixedTargets

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

the class EerieInterludeEffect 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<>();
        for (UUID targetId : getTargetPointer().getTargets(game, source)) {
            Permanent targetCreature = game.getPermanent(targetId);
            if (targetCreature != null) {
                toExile.add(targetCreature);
            }
        }
        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;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) 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) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 49 with FixedTargets

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

the class EiganjoUprisingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int amount = source.getManaCostsToPay().getX();
    if (amount < 1) {
        return false;
    }
    Token token = new SamuraiToken();
    token.putOntoBattlefield(amount, game, source);
    game.addEffect(new GainAbilityTargetEffect(new MenaceAbility(false)).setTargetPointer(new FixedTargets(token, game)), source);
    game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance()).setTargetPointer(new FixedTargets(token, game)), source);
    if (amount < 2) {
        return true;
    }
    for (UUID opponentId : game.getOpponents(source.getControllerId())) {
        token.putOntoBattlefield(amount - 1, game, source, opponentId);
    }
    return true;
}
Also used : MenaceAbility(mage.abilities.keyword.MenaceAbility) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SamuraiToken(mage.game.permanent.token.SamuraiToken) Token(mage.game.permanent.token.Token) SamuraiToken(mage.game.permanent.token.SamuraiToken) UUID(java.util.UUID)

Example 50 with FixedTargets

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

the class GodPharaohsGiftEffect 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) {
        return false;
    }
    TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD, true);
    controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game);
    Card cardChosen = game.getCard(target.getFirstTarget());
    if (cardChosen == null || !controller.moveCards(cardChosen, Zone.EXILED, source, game)) {
        return false;
    }
    // create token and modify all attributes permanently (without game usage)
    EmptyToken token = new EmptyToken();
    CardUtil.copyTo(token).from(cardChosen, game);
    token.removePTCDA();
    token.getPower().modifyBaseValue(4);
    token.getToughness().modifyBaseValue(4);
    token.getColor().setColor(ObjectColor.BLACK);
    token.removeAllCreatureTypes();
    token.addSubType(SubType.ZOMBIE);
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
    if (!permanents.isEmpty()) {
        game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(permanents, game)), source);
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Card(mage.cards.Card) EmptyToken(mage.game.permanent.token.EmptyToken)

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