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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations