Search in sources :

Example 16 with CreateTokenTargetEffect

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

the class CurseOfOpulenceEffect 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) {
        return false;
    }
    Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
    if (enchantedPlayer == null) {
        return false;
    }
    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 GoldToken());
        effect.setTargetPointer(new FixedTarget(player));
        effect.apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) 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) GoldToken(mage.game.permanent.token.GoldToken)

Example 17 with CreateTokenTargetEffect

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

the class CurseOfShallowEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player attacker = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (attacker != null && attacker.chooseUse(outcome, "create a tapped 2/2 black Zombie creature token?", source, game)) {
        Effect effect = new CreateTokenTargetEffect(new ZombieToken(), StaticValue.get(1), true, false);
        effect.setTargetPointer(targetPointer);
        return effect.apply(game, source);
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) 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)

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