Search in sources :

Example 56 with CreateTokenEffect

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

the class WasitoraNekoruQueenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player damagedPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (damagedPlayer != null && controller != null) {
        FilterControlledPermanent filter = new FilterControlledPermanent("creature");
        filter.add(CardType.CREATURE.getPredicate());
        TargetPermanent target = new TargetPermanent(1, 1, filter, true);
        if (damagedPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
            Permanent objectToBeSacrificed = game.getPermanent(target.getFirstTarget());
            if (objectToBeSacrificed != null) {
                if (objectToBeSacrificed.sacrifice(source, game)) {
                    return true;
                }
            }
        }
        new CreateTokenEffect(new WasitoraCatDragonToken()).apply(game, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) WasitoraCatDragonToken(mage.game.permanent.token.WasitoraCatDragonToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) TargetPermanent(mage.target.TargetPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent)

Example 57 with CreateTokenEffect

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

the class WordsOfWildingEffect method replaceEvent.

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

Example 58 with CreateTokenEffect

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

the class CommanderAffinityTest method test_Gained_Affinity.

@Test
public void test_Gained_Affinity() {
    // bug: Mycosynth Golem did not allow my commander, Karn, Silver Golem, to cost 0 even though I had 7+ artifacts on the board.
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new CreateTokenEffect(new ArtifactWallToken(), 7), new ManaCostsImpl("R"));
    addCustomCardWithAbility("generate tokens", playerA, ability);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
    // 
    // {5}
    addCard(Zone.COMMAND, playerA, "Karn, Silver Golem", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
    // 
    // Destroy target artifact.
    // {1}{R}
    addCard(Zone.HAND, playerA, "Ancient Grudge", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
    // 
    // Artifact creature spells you cast have affinity for artifacts. (They cost {1} less to cast for each artifact you control.)
    addCard(Zone.BATTLEFIELD, playerA, "Mycosynth Golem", 1);
    // Affinity for artifacts
    // Artifact creature spells you cast have affinity for artifacts.
    // addCard(Zone.BATTLEFIELD, playerA, "Mycosynth Golem");
    // addCard(Zone.HAND, playerA, "Alpha Myr"); // Creature - Myr  2/1
    checkCommandCardCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Karn, Silver Golem", 1);
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Karn, Silver Golem", true);
    // first cast for 5 and destroy (prepare commander with additional cost)
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Karn, Silver Golem");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ancient Grudge", "Karn, Silver Golem");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkCommandCardCount("after destroy ", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Karn, Silver Golem", 1);
    checkPlayableAbility("after destroy", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Karn, Silver Golem", false);
    // move to command zone
    setChoice(playerA, true);
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    // can't do the second cast with additional cost (must pay 2 + 5, but have only R)
    checkPlayableAbility("after move", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Karn, Silver Golem", false);
    // generate artifact tokens
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{R}: Create");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkPermanentCount("after tokens", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wall", 7);
    checkPlayableAbility("after tokens", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Karn, Silver Golem", true);
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.END_TURN);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ArtifactWallToken(mage.game.permanent.token.ArtifactWallToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Test(org.junit.Test)

Example 59 with CreateTokenEffect

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

the class FirecatBlitzEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int xValue = source.getManaCostsToPay().getX();
        for (Cost cost : source.getCosts()) {
            if (cost instanceof SacrificeTargetCost) {
                xValue = ((SacrificeTargetCost) cost).getPermanents().size();
            }
        }
        CreateTokenEffect effect = new CreateTokenEffect(new ElementalCatToken(), xValue);
        effect.apply(game, source);
        for (UUID tokenId : effect.getLastAddedTokenIds()) {
            Permanent tokenPermanent = game.getPermanent(tokenId);
            if (tokenPermanent != null) {
                ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD);
                exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
                game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) ElementalCatToken(mage.game.permanent.token.ElementalCatToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) UUID(java.util.UUID) SacrificeXTargetCost(mage.abilities.costs.common.SacrificeXTargetCost) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 60 with CreateTokenEffect

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

the class JabbaTheHuttEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        CreateTokenEffect effect = new CreateTokenEffect(new HunterToken(), 1, true, false);
        effect.apply(game, source);
        Permanent token = game.getPermanent(effect.getLastAddedTokenIds().get(0));
        Permanent opponentCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (token != null && opponentCreature != null) {
            return token.fight(opponentCreature, source, game);
        }
    }
    return false;
}
Also used : Player(mage.players.Player) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterOpponentsCreaturePermanent(mage.filter.common.FilterOpponentsCreaturePermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) HunterToken(mage.game.permanent.token.HunterToken)

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