Search in sources :

Example 46 with CreateTokenCopyTargetEffect

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

the class MinionReflectorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (permanent != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
        for (Permanent addedToken : effect.getAddedPermanents()) {
            ContinuousEffect continuousEffect = new GainAbilityTargetEffect(new BeginningOfEndStepTriggeredAbility(new SacrificeSourceEffect(), TargetController.ANY, false), Duration.Custom);
            continuousEffect.setTargetPointer(new FixedTarget(addedToken.getId()));
            game.addEffect(continuousEffect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) BeginningOfEndStepTriggeredAbility(mage.abilities.common.BeginningOfEndStepTriggeredAbility)

Example 47 with CreateTokenCopyTargetEffect

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

the class MythosOfIllunaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId());
    if (condition.apply(game, source)) {
        Ability ability = new ConditionalInterveningIfTriggeredAbility(new EntersBattlefieldTriggeredAbility(new FightTargetSourceEffect()), MythosOfIllunaCondition.instance, "When this permanent enters the battlefield, " + "if it's a creature, it fights up to one target creature you don't control.");
        ability.addTarget(new TargetPermanent(0, 1, StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, false));
        effect.addAdditionalAbilities(ability);
    }
    return effect.apply(game, source);
}
Also used : EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) ConditionalInterveningIfTriggeredAbility(mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) FightTargetSourceEffect(mage.abilities.effects.common.FightTargetSourceEffect) ConditionalInterveningIfTriggeredAbility(mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility)

Example 48 with CreateTokenCopyTargetEffect

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

the class ForceProjectionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (controller != null && permanent != null) {
        // Create a token that is a copy of target creature
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        // except that it is an Illusion in addition to its other types
        effect.setAdditionalSubType(SubType.SPIRIT);
        effect.apply(game, source);
        // and gains "When this creature becomes the target of a spell, sacrifice it."
        Effect sacrificeEffect = new SacrificeSourceEffect();
        sacrificeEffect.setTargetPointer(new FixedTarget(effect.getAddedPermanents().get(0), game));
        TriggeredAbility ability = new BecomesTargetTriggeredAbility(sacrificeEffect, new FilterSpell());
        game.addTriggeredAbility(ability, null);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) BecomesTargetTriggeredAbility(mage.abilities.common.BecomesTargetTriggeredAbility) Player(mage.players.Player) FilterSpell(mage.filter.FilterSpell) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ScryEffect(mage.abilities.effects.keyword.ScryEffect) Effect(mage.abilities.effects.Effect) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) TriggeredAbility(mage.abilities.TriggeredAbility) BecomesTargetTriggeredAbility(mage.abilities.common.BecomesTargetTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Example 49 with CreateTokenCopyTargetEffect

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

the class KindredChargeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
        if (subType != null) {
            FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control of the chosen type");
            filter.add(subType.getPredicate());
            for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
                if (permanent != null) {
                    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
                    effect.setTargetPointer(new FixedTarget(permanent, game));
                    effect.apply(game, source);
                    for (Permanent addedToken : effect.getAddedPermanents()) {
                        Effect exileEffect = new ExileTargetEffect();
                        exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
                        game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) SubType(mage.constants.SubType) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) MageObject(mage.MageObject) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ChooseCreatureTypeEffect(mage.abilities.effects.common.ChooseCreatureTypeEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 50 with CreateTokenCopyTargetEffect

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

the class OffspringsRevengeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (player == null || card == null) {
        return false;
    }
    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false, 1, false, false, null, 1, 1, false);
    effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1));
    player.moveCards(card, Zone.EXILED, source, game);
    effect.apply(game, source);
    effect.getAddedPermanents().stream().forEach(permanent -> {
        ContinuousEffect continuousEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.UntilYourNextTurn);
        continuousEffect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(continuousEffect, source);
    });
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

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