Search in sources :

Example 6 with CreateTokenTargetEffect

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

the class GenerousGiftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    Player player = game.getPlayer(permanent.getControllerId());
    permanent.destroy(source, game, false);
    if (player == null) {
        return false;
    }
    Effect effect = new CreateTokenTargetEffect(new ElephantToken());
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) ElephantToken(mage.game.permanent.token.ElephantToken) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect)

Example 7 with CreateTokenTargetEffect

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

the class MoggInfestationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Cards creaturesDied = new CardsImpl();
    if (controller != null && getTargetPointer().getFirst(game, source) != null) {
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) {
            if (permanent.destroy(source, game, false)) {
                if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) {
                    // If a commander is replaced to command zone, the creature does not die
                    creaturesDied.add(permanent);
                }
            }
        }
        // Bug #8548
        game.getState().processAction(game);
        if (creaturesDied.isEmpty()) {
            return true;
        }
        for (Card c : creaturesDied.getCards(game)) {
            if (game.getState().getZone(c.getId()) == Zone.GRAVEYARD) {
                Effect effect = new CreateTokenTargetEffect(new GoblinToken(), 2);
                effect.setTargetPointer(getTargetPointer());
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) GoblinToken(mage.game.permanent.token.GoblinToken) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 8 with CreateTokenTargetEffect

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

the class VarchildBetrayerOfKjeldorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int damage = (int) this.getValue("damage");
    if (damage > 0) {
        Effect effect = new CreateTokenTargetEffect(new SurvivorToken(), damage);
        effect.setTargetPointer(getTargetPointer());
        return effect.apply(game, source);
    }
    return false;
}
Also used : CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) CantAttackYouOrPlaneswalkerAllEffect(mage.abilities.effects.common.combat.CantAttackYouOrPlaneswalkerAllEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) GainControlAllEffect(mage.abilities.effects.common.continuous.GainControlAllEffect) CantBlockAllEffect(mage.abilities.effects.common.combat.CantBlockAllEffect) SurvivorToken(mage.game.permanent.token.SurvivorToken)

Example 9 with CreateTokenTargetEffect

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

the class OpponentCreateSurvivorTokenCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        TargetOpponent target = new TargetOpponent();
        if (controller.chooseTarget(Outcome.Neutral, target, ability, game)) {
            Player opponent = game.getPlayer(target.getFirstTarget());
            if (opponent != null) {
                Effect effect = new CreateTokenTargetEffect(new SurvivorToken());
                effect.setTargetPointer(new FixedTarget(opponent.getId(), game));
                paid = effect.apply(game, ability);
            }
        }
    }
    return paid;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) SurvivorToken(mage.game.permanent.token.SurvivorToken)

Example 10 with CreateTokenTargetEffect

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

the class GallowsAtWillowHillEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
    if (permanent != null) {
        Player controller = game.getPlayer(permanent.getControllerId());
        permanent.destroy(source, game, false);
        if (controller != null) {
            CreateTokenTargetEffect effect = new CreateTokenTargetEffect(new SpiritWhiteToken());
            effect.setTargetPointer(new FixedTarget(controller.getId()));
            effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect)

Aggregations

CreateTokenTargetEffect (mage.abilities.effects.common.CreateTokenTargetEffect)17 Effect (mage.abilities.effects.Effect)16 OneShotEffect (mage.abilities.effects.OneShotEffect)15 Player (mage.players.Player)14 FixedTarget (mage.target.targetpointer.FixedTarget)14 Permanent (mage.game.permanent.Permanent)9 TargetPlayer (mage.target.TargetPlayer)5 UUID (java.util.UUID)4 AttachEffect (mage.abilities.effects.common.AttachEffect)3 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)3 HashSet (java.util.HashSet)2 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)2 SurvivorToken (mage.game.permanent.token.SurvivorToken)2 ZombieToken (mage.game.permanent.token.ZombieToken)2 TargetPermanent (mage.target.TargetPermanent)2 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 TargetOpponent (mage.target.common.TargetOpponent)2 CountersSourceCount (mage.abilities.dynamicvalue.common.CountersSourceCount)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1