Search in sources :

Example 31 with CreateTokenEffect

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

the class KariZevSkyshipRaiderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    CreateTokenEffect effect = new CreateTokenEffect(new RagavanToken(), 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) RagavanToken(mage.game.permanent.token.RagavanToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 32 with CreateTokenEffect

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

the class LegionWarbossAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    CreateTokenEffect effect = new CreateTokenEffect(new GoblinToken());
    effect.apply(game, source);
    effect.getLastAddedTokenIds().stream().map((tokenId) -> {
        ContinuousEffect continuousEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
        continuousEffect.setTargetPointer(new FixedTarget(tokenId, game));
        return continuousEffect;
    }).forEachOrdered((continuousEffect) -> {
        game.addEffect(continuousEffect, source);
    });
    effect.getLastAddedTokenIds().stream().map((tokenId) -> {
        ContinuousEffect continuousEffect = new GainAbilityTargetEffect(new LegionWarbossAbility(), Duration.EndOfCombat);
        continuousEffect.setTargetPointer(new FixedTarget(tokenId, game));
        return continuousEffect;
    }).forEachOrdered((continuousEffect) -> {
        game.addEffect(continuousEffect, source);
    });
    return true;
}
Also used : BeginningOfCombatTriggeredAbility(mage.abilities.common.BeginningOfCombatTriggeredAbility) Zone(mage.constants.Zone) MentorAbility(mage.abilities.keyword.MentorAbility) HasteAbility(mage.abilities.keyword.HasteAbility) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) GoblinToken(mage.game.permanent.token.GoblinToken) MageInt(mage.MageInt) StaticAbility(mage.abilities.StaticAbility) SubType(mage.constants.SubType) TargetController(mage.constants.TargetController) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FixedTarget(mage.target.targetpointer.FixedTarget) CardSetInfo(mage.cards.CardSetInfo) Duration(mage.constants.Duration) Game(mage.game.Game) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) AttacksIfAbleSourceEffect(mage.abilities.effects.common.combat.AttacksIfAbleSourceEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) FixedTarget(mage.target.targetpointer.FixedTarget) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GoblinToken(mage.game.permanent.token.GoblinToken)

Example 33 with CreateTokenEffect

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

the class MalcolmKeenEyedNavigatorTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerBatchEvent dEvent = (DamagedPlayerBatchEvent) event;
    Set<UUID> opponents = new HashSet<>();
    for (DamagedEvent damagedEvent : dEvent.getEvents()) {
        Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
        if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.hasSubtype(SubType.PIRATE, game) || !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
            continue;
        }
        opponents.add(damagedEvent.getTargetId());
    }
    if (opponents.size() < 1) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new CreateTokenEffect(new TreasureToken(), opponents.size()));
    return true;
}
Also used : DamagedPlayerBatchEvent(mage.game.events.DamagedPlayerBatchEvent) DamagedEvent(mage.game.events.DamagedEvent) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) TreasureToken(mage.game.permanent.token.TreasureToken) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 34 with CreateTokenEffect

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

the class SwordOfDungeonsAndDragonsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int count = 1;
        int amount = controller.rollDice(outcome, source, game, 20);
        while (amount == 20) {
            count += 1;
            amount = controller.rollDice(outcome, source, game, 20);
        }
        return new CreateTokenEffect(new DragonTokenGold(), count).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) DragonTokenGold(mage.game.permanent.token.DragonTokenGold)

Example 35 with CreateTokenEffect

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

the class TilonallisSummonerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        ManaCosts cost = new ManaCostsImpl("{X}{R}");
        if (controller.chooseUse(outcome, "Pay " + cost.getText() + "? If you do, you create X 1/1 red Elemental creature tokens that are tapped and attacking.", source, game)) {
            int costX = controller.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
            cost.add(new GenericManaCost(costX));
            if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                // otherwise you can undo the payment
                controller.resetStoredBookmark(game);
                CreateTokenEffect effect = new CreateTokenEffect(new TilonallisSummonerElementalToken(), costX, true, true);
                effect.apply(game, source);
                Effect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD).setText("exile those tokens unless you have the city's blessing");
                exileEffect.setTargetPointer(new FixedTargets(new CardsImpl(effect.getLastAddedTokenIds()), game));
                game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.ANY, new InvertCondition(CitysBlessingCondition.instance)), source);
            }
        }
        return true;
    }
    return false;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) TilonallisSummonerElementalToken(mage.game.permanent.token.TilonallisSummonerElementalToken) FixedTargets(mage.target.targetpointer.FixedTargets) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) CitysBlessingHint(mage.abilities.hint.common.CitysBlessingHint) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) InvertCondition(mage.abilities.condition.InvertCondition) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) CardsImpl(mage.cards.CardsImpl) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

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