Search in sources :

Example 1 with CreateTokenTargetEffect

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

the class TransmogrifyingWandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getFirstTarget());
    if (creature == null) {
        return false;
    }
    Effect effect = new CreateTokenTargetEffect(new OxToken());
    effect.setTargetPointer(new FixedTarget(creature.getControllerId(), game));
    new DestroyTargetEffect().apply(game, source);
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) OxToken(mage.game.permanent.token.OxToken) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect)

Example 2 with CreateTokenTargetEffect

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

the class AllianceOfArmsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int xSum = 0;
        xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", controller, source, game);
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            if (!Objects.equals(playerId, controller.getId())) {
                Player player = game.getPlayer(playerId);
                if (player != null) {
                    xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", player, source, game);
                }
            }
        }
        if (xSum > 0) {
            for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
                Effect effect = new CreateTokenTargetEffect(new SoldierToken(), xSum);
                effect.setTargetPointer(new FixedTarget(playerId));
                effect.apply(game, source);
            }
        }
        // prevent undo
        controller.resetStoredBookmark(game);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SoldierToken(mage.game.permanent.token.SoldierToken) Player(mage.players.Player) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID)

Example 3 with CreateTokenTargetEffect

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

the class GrismoldTheDreadsowerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    game.getState().getPlayersInRange(source.getControllerId(), game).stream().forEach(playerId -> {
        Effect effect = new CreateTokenTargetEffect(new GrismoldPlantToken(), 1);
        effect.setTargetPointer(new FixedTarget(playerId, game));
        effect.apply(game, source);
    });
    return true;
}
Also used : GrismoldPlantToken(mage.game.permanent.token.GrismoldPlantToken) FixedTarget(mage.target.targetpointer.FixedTarget) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect)

Example 4 with CreateTokenTargetEffect

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

the class CurseOfDisturbanceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that the enchantment 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) {
        Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
        if (enchantedPlayer != null) {
            Set<UUID> players = new HashSet<>();
            for (UUID attacker : game.getCombat().getAttackers()) {
                UUID defender = game.getCombat().getDefenderId(attacker);
                if (defender.equals(enchantedPlayer.getId()) && game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
                    players.add(game.getPermanent(attacker).getControllerId());
                }
            }
            players.add(source.getControllerId());
            for (UUID player : players) {
                game.getPlayer(player);
                Effect effect = new CreateTokenTargetEffect(new ZombieToken());
                effect.setTargetPointer(new FixedTarget(player));
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) Permanent(mage.game.permanent.Permanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 5 with CreateTokenTargetEffect

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

the class PhantasmalSphereToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetOpponent = game.getPlayer(source.getFirstTarget());
    if (controller != null && targetOpponent != null) {
        Effect effect = new CreateTokenTargetEffect(new PhantasmalSphereToken(new CountersSourceCount(CounterType.P1P1).calculate(game, source, null)));
        effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect.apply(game, source);
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) Player(mage.players.Player) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) SacrificeSourceUnlessPaysEffect(mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect)

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