Search in sources :

Example 16 with CreateTokenEffect

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

the class EwokAmbushCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        CreateTokenEffect effect = new CreateTokenEffect(new EwokToken(), 2);
        effect.apply(game, source);
        for (UUID tokenId : effect.getLastAddedTokenIds()) {
            Permanent token = game.getPermanent(tokenId);
            if (token != null) {
                ContinuousEffect continuousEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                continuousEffect.setTargetPointer(new FixedTarget(tokenId));
                game.addEffect(continuousEffect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : EwokToken(mage.game.permanent.token.EwokToken) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 17 with CreateTokenEffect

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

the class EtherealAbsolutionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (player == null || card == null) {
        return false;
    }
    if (card.isCreature(game)) {
        new CreateTokenEffect(new WhiteBlackSpiritToken()).apply(game, source);
    }
    return player.moveCards(card, Zone.EXILED, source, game);
}
Also used : Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) WhiteBlackSpiritToken(mage.game.permanent.token.WhiteBlackSpiritToken) Card(mage.cards.Card)

Example 18 with CreateTokenEffect

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

the class FinaleOfGloryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = source.getManaCostsToPay().getX();
    if (xValue == 0) {
        return false;
    }
    new CreateTokenEffect(new SoldierVigilanceToken(), xValue).apply(game, source);
    if (xValue >= 10) {
        new CreateTokenEffect(new AngelVigilanceToken(), xValue).apply(game, source);
    }
    return true;
}
Also used : SoldierVigilanceToken(mage.game.permanent.token.SoldierVigilanceToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) AngelVigilanceToken(mage.game.permanent.token.AngelVigilanceToken)

Example 19 with CreateTokenEffect

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

the class OonaQueenOfTheFaeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
    ChoiceColor choice = new ChoiceColor();
    if (controller == null || opponent == null || !controller.choose(outcome, choice, game)) {
        return false;
    }
    int cardsWithColor = 0;
    Cards cardsToExile = new CardsImpl();
    cardsToExile.addAll(opponent.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
    for (Card card : cardsToExile.getCards(game)) {
        if (card != null && card.getColor(game).contains(choice.getColor())) {
            cardsWithColor++;
        }
    }
    controller.moveCards(cardsToExile, Zone.EXILED, source, game);
    if (cardsWithColor > 0) {
        new CreateTokenEffect(new OonaQueenFaerieRogueToken(), cardsWithColor).apply(game, source);
    }
    game.informPlayers("Oona: " + cardsWithColor + " Token" + (cardsWithColor != 1 ? "s" : "") + " created");
    return true;
}
Also used : Player(mage.players.Player) OonaQueenFaerieRogueToken(mage.game.permanent.token.OonaQueenFaerieRogueToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 20 with CreateTokenEffect

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

the class RallyTheHordeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int nonLandCardsExiled = 0;
        while (controller.getLibrary().hasCards()) {
            nonLandCardsExiled += checkIfNextLibCardIsNonLandAndExile(controller, source, game);
            if (controller.getLibrary().hasCards()) {
                nonLandCardsExiled += checkIfNextLibCardIsNonLandAndExile(controller, source, game);
            }
            if (controller.getLibrary().hasCards()) {
                int nonLands = checkIfNextLibCardIsNonLandAndExile(controller, source, game);
                if (nonLands == 0) {
                    break;
                }
                nonLandCardsExiled += nonLands;
            }
        }
        return new CreateTokenEffect(new RallyTheHordeWarriorToken(), nonLandCardsExiled).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) RallyTheHordeWarriorToken(mage.game.permanent.token.RallyTheHordeWarriorToken)

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