Search in sources :

Example 41 with CreateTokenEffect

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

the class EntrapmentManeuverSacrificeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player == null) {
        return false;
    }
    FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
    filter.add(AttackingPredicate.instance);
    int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
    if (realCount > 0) {
        Target target = new TargetControlledPermanent(1, 1, filter, true);
        while (player.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game)) {
            player.chooseTarget(Outcome.Sacrifice, target, source, game);
        }
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            int amount = permanent.getToughness().getValue();
            permanent.sacrifice(source, game);
            new CreateTokenEffect(new SoldierToken(), amount).apply(game, source);
        } else {
            return false;
        }
    }
    return true;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) SoldierToken(mage.game.permanent.token.SoldierToken) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 42 with CreateTokenEffect

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

the class FeralLightningEffect method apply.

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

Example 43 with CreateTokenEffect

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

the class KalitasTraitorOfGhetEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
            Permanent permanent = ((ZoneChangeEvent) event).getTarget();
            if (permanent != null) {
                controller.moveCards(permanent, Zone.EXILED, source, game);
                new CreateTokenEffect(new ZombieToken()).apply(game, source);
                return true;
            }
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 44 with CreateTokenEffect

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

the class KrenkoTinStreetKingpinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
    game.getState().processAction(game);
    int xValue = permanent.getPower().getValue();
    return new CreateTokenEffect(new GoblinToken(), xValue).apply(game, source);
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GoblinToken(mage.game.permanent.token.GoblinToken)

Example 45 with CreateTokenEffect

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

the class LightningCoilsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent p = game.getPermanent(source.getSourceId());
    if (p != null && controller != null) {
        int counters = p.getCounters(game).getCount(CounterType.CHARGE);
        if (counters >= 5) {
            // remove all the counters and create that many tokens
            p.removeCounters(CounterType.CHARGE.getName(), p.getCounters(game).getCount(CounterType.CHARGE), source, game);
            CreateTokenEffect effect = new CreateTokenEffect(new ElementalTokenWithHaste(), counters);
            effect.apply(game, source);
            // exile those tokens at next end step
            effect.exileTokensCreatedAtNextEndStep(game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ElementalTokenWithHaste(mage.game.permanent.token.ElementalTokenWithHaste)

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