Search in sources :

Example 11 with CreateTokenEffect

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

the class HelmOfKaldraEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (new HelmOfKaldraCondition().apply(game, source)) {
        CreateTokenEffect effect = new CreateTokenEffect(new KaldraToken());
        effect.apply(game, source);
        for (UUID tokenId : effect.getLastAddedTokenIds()) {
            Permanent kaldra = game.getPermanent(tokenId);
            if (kaldra != null) {
                // Attach helm to the token
                for (Permanent kaldrasHelm : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterHelm, source.getControllerId(), game)) {
                    kaldra.addAttachment(kaldrasHelm.getId(), source, game);
                    break;
                }
                // Attach shield to the token
                for (Permanent kaldrasShield : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterShield, source.getControllerId(), game)) {
                    kaldra.addAttachment(kaldrasShield.getId(), source, game);
                    break;
                }
                // Attach sword to the token
                for (Permanent kaldrasSword : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterSword, source.getControllerId(), game)) {
                    kaldra.addAttachment(kaldrasSword.getId(), source, game);
                    break;
                }
            }
            return true;
        }
    }
    return false;
}
Also used : KaldraToken(mage.game.permanent.token.KaldraToken) FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) UUID(java.util.UUID)

Example 12 with CreateTokenEffect

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

the class InvocationOfSaintTraftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    CreateTokenEffect effect = new CreateTokenEffect(new AngelToken(), 1, true, true);
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && (effect.apply(game, source))) {
        effect.exileTokensCreatedAtEndOfCombat(game, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) AngelToken(mage.game.permanent.token.AngelToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 13 with CreateTokenEffect

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

the class TaintedAdversaryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Integer timesPaid = (Integer) getValue("timesPaid");
    if (timesPaid == null || timesPaid <= 0) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(timesPaid)), false, staticText);
    ability.addEffect(new CreateTokenEffect(new ZombieDecayedToken(), 2 * timesPaid));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ZombieDecayedToken(mage.game.permanent.token.ZombieDecayedToken)

Example 14 with CreateTokenEffect

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

the class TreasureMapEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        player.scry(1, source, game);
        if (permanent != null) {
            permanent.addCounters(CounterType.LANDMARK.createInstance(), source.getControllerId(), source, game);
            int counters = permanent.getCounters(game).getCount(CounterType.LANDMARK);
            if (counters > 2) {
                permanent.removeCounters("landmark", counters, source, game);
                new TransformSourceEffect().apply(game, source);
                new CreateTokenEffect(new TreasureToken(), 3).apply(game, source);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) TreasureToken(mage.game.permanent.token.TreasureToken)

Example 15 with CreateTokenEffect

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

the class BrudicladTelchorEngineerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    CreateTokenEffect effect = new CreateTokenEffect(new BrudicladTelchorMyrToken(), 1);
    if (effect.apply(game, source)) {
        TargetControlledPermanent target = new TargetControlledPermanent(0, 1, filter, true);
        target.setNotTarget(true);
        if (controller.chooseUse(outcome, "Select a token to copy?", source, game) && controller.choose(Outcome.Neutral, target, source.getSourceId(), game)) {
            Permanent toCopyFromPermanent = game.getPermanent(target.getFirstTarget());
            if (toCopyFromPermanent != null) {
                for (Permanent toCopyToPermanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
                    if (!toCopyToPermanent.equals(toCopyFromPermanent)) {
                        game.copyPermanent(toCopyFromPermanent, toCopyToPermanent.getId(), source, new EmptyCopyApplier());
                    }
                }
                return true;
            }
        }
    }
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) BrudicladTelchorMyrToken(mage.game.permanent.token.BrudicladTelchorMyrToken)

Aggregations

CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)68 Player (mage.players.Player)45 Permanent (mage.game.permanent.Permanent)31 UUID (java.util.UUID)25 FixedTarget (mage.target.targetpointer.FixedTarget)11 OneShotEffect (mage.abilities.effects.OneShotEffect)8 Effect (mage.abilities.effects.Effect)7 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)7 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)7 ContinuousEffect (mage.abilities.effects.ContinuousEffect)6 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)5 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)5 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)4 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)4 Cost (mage.abilities.costs.Cost)4 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)4 HashSet (java.util.HashSet)3 MageObjectReference (mage.MageObjectReference)3 Ability (mage.abilities.Ability)3 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)3