Search in sources :

Example 21 with CreateTokenEffect

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

the class AmassEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = amassNumber.calculate(game, source, this);
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    if (!game.getBattlefield().containsControlled(filter, source, game, 1)) {
        new CreateTokenEffect(new ZombieArmyToken()).apply(game, source);
    }
    Target target = new TargetPermanent(filter);
    target.setNotTarget(true);
    if (!player.choose(outcome, target, source.getSourceId(), game)) {
        return false;
    }
    Permanent permanent = game.getPermanent(target.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    permanent.addCounters(CounterType.P1P1.createInstance(xValue), source.getControllerId(), source, game);
    this.amassedCreatureId = permanent.getId();
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) TargetPermanent(mage.target.TargetPermanent) ZombieArmyToken(mage.game.permanent.token.ZombieArmyToken)

Example 22 with CreateTokenEffect

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

the class BlightHerderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetCardInExile(2, 2, filter, null);
        if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
            if (controller.chooseTarget(outcome, target, source, game)) {
                Cards cardsToGraveyard = new CardsImpl(target.getTargets());
                controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game);
                return new CreateTokenEffect(new EldraziScionToken(), 3).apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetCardInExile(mage.target.common.TargetCardInExile) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) EldraziScionToken(mage.game.permanent.token.EldraziScionToken) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 23 with CreateTokenEffect

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

the class BoxOfFreerangeGoblinsEffect method apply.

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

Example 24 with CreateTokenEffect

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

the class UginTheIneffableLookAtFaceDownEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Card card = player.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    // exile and look
    UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
    if (player.moveCardsToExile(card, source, game, false, exileZoneId, sourceObject.getIdName() + " (" + player.getName() + ")")) {
        card.turnFaceDown(source, game, source.getControllerId());
        player.lookAtCards(player.getName() + " - " + card.getIdName() + " - " + CardUtil.sdf.format(System.currentTimeMillis()), card, game);
    }
    // create token
    Set<MageObjectReference> tokenObjs = new HashSet<>();
    CreateTokenEffect effect = new CreateTokenEffect(new UginTheIneffableToken());
    effect.apply(game, source);
    // with return ability
    for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
        // display referenced exiled face-down card on token
        SimpleStaticAbility sa = new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect("Referenced object: " + card.getId().toString().substring(0, 3)));
        GainAbilityTargetEffect gainAbilityEffect = new GainAbilityTargetEffect(sa, Duration.WhileOnBattlefield);
        gainAbilityEffect.setTargetPointer(new FixedTarget(addedTokenId));
        game.addEffect(gainAbilityEffect, source);
        // look at face-down card in exile
        UginTheIneffableLookAtFaceDownEffect lookAtEffect = new UginTheIneffableLookAtFaceDownEffect();
        lookAtEffect.setTargetPointer(new FixedTarget(card.getId(), game));
        game.addEffect(lookAtEffect, source);
        tokenObjs.add(new MageObjectReference(addedTokenId, game));
        game.addDelayedTriggeredAbility(new UginTheIneffableDelayedTriggeredAbility(tokenObjs, new MageObjectReference(card, game)), source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) UginTheIneffableToken(mage.game.permanent.token.UginTheIneffableToken) MageObject(mage.MageObject) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) InfoEffect(mage.abilities.effects.common.InfoEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) UUID(java.util.UUID) MageObjectReference(mage.MageObjectReference) HashSet(java.util.HashSet)

Example 25 with CreateTokenEffect

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

the class FlockOfRabidSheepEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int repeat = source.getManaCostsToPay().getX();
        int wonCount = 0;
        for (int i = 1; i <= repeat; i++) {
            if (controller.flipCoin(source, game, true)) {
                wonCount++;
            }
        }
        new CreateTokenEffect(new RabidSheepToken(), wonCount).apply(game, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) RabidSheepToken(mage.game.permanent.token.RabidSheepToken)

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