Search in sources :

Example 11 with CreateTokenTargetEffect

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

the class SylvanOfferingEffect2 method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetOpponent(true);
        target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), game);
        Player opponent = game.getPlayer(target.getFirstTarget());
        if (opponent != null) {
            int xValue = source.getManaCostsToPay().getX();
            Effect effect = new CreateTokenTargetEffect(new ElfWarriorToken(), xValue);
            effect.setTargetPointer(new FixedTarget(controller.getId()));
            effect.apply(game, source);
            effect.setTargetPointer(new FixedTarget(opponent.getId()));
            effect.apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) TargetOpponent(mage.target.common.TargetOpponent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) ElfWarriorToken(mage.game.permanent.token.ElfWarriorToken)

Example 12 with CreateTokenTargetEffect

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

the class ElephantResurgenceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Effect effect = new CreateTokenTargetEffect(new ElephantResurgenceToken(), 1);
            effect.setTargetPointer(new FixedTarget(playerId));
            effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) ElephantResurgenceToken(mage.game.permanent.token.ElephantResurgenceToken) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID)

Example 13 with CreateTokenTargetEffect

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

the class WarrenWeirdingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (player == null) {
        return false;
    }
    FilterControlledPermanent filter = new FilterControlledPermanent("creature");
    filter.add(CardType.CREATURE.getPredicate());
    filter.add(new ControllerIdPredicate(player.getId()));
    TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
    // had, if thats the case this ability should fizzle.
    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
        player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            permanent.sacrifice(source, game);
            if (filterGoblin.match(permanent, game)) {
                for (int i = 0; i < 2; i++) {
                    Token token = new GoblinRogueToken();
                    Effect effect = new CreateTokenTargetEffect(token);
                    effect.setTargetPointer(new FixedTarget(player.getId()));
                    if (effect.apply(game, source)) {
                        Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
                        if (tokenPermanent != null) {
                            ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                            hasteEffect.setTargetPointer(new FixedTarget(tokenPermanent.getId()));
                            game.addEffect(hasteEffect, source);
                        }
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) GoblinRogueToken(mage.game.permanent.token.GoblinRogueToken) Token(mage.game.permanent.token.Token) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) GoblinRogueToken(mage.game.permanent.token.GoblinRogueToken) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 14 with CreateTokenTargetEffect

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

the class SawtuskDemolisherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    Player player = game.getPlayer(permanent.getControllerId());
    permanent.destroy(source, game, false);
    if (player == null) {
        return false;
    }
    Effect effect = new CreateTokenTargetEffect(new BeastToken());
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) BeastToken(mage.game.permanent.token.BeastToken) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect)

Example 15 with CreateTokenTargetEffect

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

the class CavalierOfDawnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    Player player = game.getPlayer(permanent.getControllerId());
    permanent.destroy(source, game, false);
    if (player == null) {
        return false;
    }
    Effect effect = new CreateTokenTargetEffect(new GolemToken());
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetNonlandPermanent(mage.target.common.TargetNonlandPermanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ReturnFromGraveyardToHandTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) GolemToken(mage.game.permanent.token.GolemToken)

Aggregations

CreateTokenTargetEffect (mage.abilities.effects.common.CreateTokenTargetEffect)17 Effect (mage.abilities.effects.Effect)16 OneShotEffect (mage.abilities.effects.OneShotEffect)15 Player (mage.players.Player)14 FixedTarget (mage.target.targetpointer.FixedTarget)14 Permanent (mage.game.permanent.Permanent)9 TargetPlayer (mage.target.TargetPlayer)5 UUID (java.util.UUID)4 AttachEffect (mage.abilities.effects.common.AttachEffect)3 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)3 HashSet (java.util.HashSet)2 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)2 SurvivorToken (mage.game.permanent.token.SurvivorToken)2 ZombieToken (mage.game.permanent.token.ZombieToken)2 TargetPermanent (mage.target.TargetPermanent)2 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 TargetOpponent (mage.target.common.TargetOpponent)2 CountersSourceCount (mage.abilities.dynamicvalue.common.CountersSourceCount)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1