Search in sources :

Example 16 with CreateTokenCopyTargetEffect

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

the class SaheeliTheGiftedTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_ARTIFACT_AN, source.getControllerId(), game)) {
        if (permanent != null) {
            CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
            effect.setTargetPointer(new FixedTarget(permanent, game));
            effect.setHasHaste(true);
            effect.apply(game, source);
            effect.exileTokensCreatedAtNextEndStep(game, source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Example 17 with CreateTokenCopyTargetEffect

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

the class SoulFoundryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent soulFoundry = game.getPermanentOrLKIBattlefield(source.getSourceId());
        if (soulFoundry != null && soulFoundry.getImprinted() != null && !soulFoundry.getImprinted().isEmpty()) {
            Card imprinted = game.getCard(soulFoundry.getImprinted().get(0));
            if (imprinted != null && game.getState().getZone(imprinted.getId()) == Zone.EXILED) {
                CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
                effect.setTargetPointer(new FixedTarget(imprinted.getId(), imprinted.getZoneChangeCounter(game)));
                return effect.apply(game, source);
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 18 with CreateTokenCopyTargetEffect

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

the class FollowedFootstepsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that Followed Footsteps is blinked
    Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (enchantment == null) {
        // It was not blinked, use the standard method
        enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (enchantment != null) {
        Permanent target = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
        if (target != null) {
            Effect effect = new CreateTokenCopyTargetEffect();
            effect.setTargetPointer(new FixedTarget(enchantment.getAttachedTo(), game));
            return effect.apply(game, source);
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Example 19 with CreateTokenCopyTargetEffect

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

the class HelmOfTheHostEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent equipment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (equipment == null) {
        return true;
    }
    Permanent creature = game.getPermanentOrLKIBattlefield(equipment.getAttachedTo());
    if (creature == null) {
        return true;
    }
    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
    effect.setTargetPointer(new FixedTarget(creature, game));
    effect.setIsntLegendary(true);
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Example 20 with CreateTokenCopyTargetEffect

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

the class NacatlWarPrideEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent origNactalWarPride = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (origNactalWarPride == null) {
        return false;
    }
    CreatureAttackedWhichPlayerWatcher PlayerAttackedWatcher = game.getState().getWatcher(CreatureAttackedWhichPlayerWatcher.class);
    // Count the number of creatures attacked opponent controls
    UUID defenderId = PlayerAttackedWatcher.getPlayerAttackedThisTurnByCreature(source.getSourceId());
    int count = 0;
    if (defenderId != null) {
        count = game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), defenderId, game);
    }
    if (count == 0) {
        return false;
    }
    List<Permanent> copies = new ArrayList<>();
    Player controller = game.getPlayer(source.getControllerId());
    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(controller.getId(), null, false, count, true, true);
    effect.setTargetPointer(new FixedTarget(origNactalWarPride, game));
    effect.apply(game, source);
    copies.addAll(effect.getAddedPermanents());
    if (!copies.isEmpty()) {
        FixedTargets fixedTargets = new FixedTargets(copies, game);
        ExileTargetEffect exileEffect = new ExileTargetEffect();
        exileEffect.setTargetPointer(fixedTargets).setText("exile the tokens");
        game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ArrayList(java.util.ArrayList) CreatureAttackedWhichPlayerWatcher(mage.watchers.common.CreatureAttackedWhichPlayerWatcher) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) UUID(java.util.UUID) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) 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