Search in sources :

Example 41 with CreateTokenCopyTargetEffect

use of mage.abilities.effects.common.CreateTokenCopyTargetEffect 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 42 with CreateTokenCopyTargetEffect

use of mage.abilities.effects.common.CreateTokenCopyTargetEffect in project mage by magefree.

the class ZndrspltsJudgmentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes();
    choice.chooseFriendOrFoe(controller, source, game);
    for (Player player : choice.getFriends()) {
        if (player == null) {
            continue;
        }
        FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control");
        filter.add(new ControllerIdPredicate(player.getId()));
        TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
        if (!player.choose(Outcome.Copy, target, source.getSourceId(), game)) {
            continue;
        }
        Effect effect = new CreateTokenCopyTargetEffect(player.getId());
        effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
        effect.apply(game, source);
    }
    for (Player player : choice.getFoes()) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control");
        filter.add(new ControllerIdPredicate(player.getId()));
        TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
        if (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
            continue;
        }
        Effect effect = new ReturnToHandTargetEffect();
        effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
        effect.apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ChooseFriendsAndFoes(mage.choices.ChooseFriendsAndFoes) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Example 43 with CreateTokenCopyTargetEffect

use of mage.abilities.effects.common.CreateTokenCopyTargetEffect in project mage by magefree.

the class FelhideSpiritbinderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (permanent != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, CardType.ENCHANTMENT, true);
        effect.setTargetPointer(getTargetPointer());
        if (effect.apply(game, source)) {
            for (Permanent tokenPermanent : effect.getAddedPermanents()) {
                ExileTargetEffect exileEffect = new ExileTargetEffect();
                exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
                game.addDelayedTriggeredAbility(delayedAbility, source);
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 44 with CreateTokenCopyTargetEffect

use of mage.abilities.effects.common.CreateTokenCopyTargetEffect in project mage by magefree.

the class FeldonOfTheThirdPathEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), CardType.ARTIFACT, true);
        effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
        effect.apply(game, source);
        for (Permanent addedToken : effect.getAddedPermanents()) {
            SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice the token at the beginning of the next end step", source.getControllerId());
            sacrificeEffect.setTargetPointer(new FixedTarget(addedToken, game));
            DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
            game.addDelayedTriggeredAbility(delayedAbility, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 45 with CreateTokenCopyTargetEffect

use of mage.abilities.effects.common.CreateTokenCopyTargetEffect in project mage by magefree.

the class GyrusWakerOfCorpsesPowerLessThanSourcePredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getFirstTarget());
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || card == null) {
        return false;
    }
    controller.moveCards(card, Zone.EXILED, source, game);
    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true, 1, true, true);
    effect.setTargetPointer(new FixedTarget(card, game));
    effect.apply(game, source);
    for (Permanent addedToken : effect.getAddedPermanents()) {
        Effect exileEffect = new ExileTargetEffect();
        exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
        new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), false).apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ObjectSourcePlayer(mage.filter.predicate.ObjectSourcePlayer) Permanent(mage.game.permanent.Permanent) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Aggregations

CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)64 FixedTarget (mage.target.targetpointer.FixedTarget)50 Permanent (mage.game.permanent.Permanent)46 Player (mage.players.Player)31 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)20 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)17 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)14 Card (mage.cards.Card)12 TargetPermanent (mage.target.TargetPermanent)10 UUID (java.util.UUID)9 Effect (mage.abilities.effects.Effect)8 OneShotEffect (mage.abilities.effects.OneShotEffect)8 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)7 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)7 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)7 FixedTargets (mage.target.targetpointer.FixedTargets)6 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)5 FilterPermanent (mage.filter.FilterPermanent)5 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)5 FilterCard (mage.filter.FilterCard)4