diff --git a/Mage.Sets/src/mage/cards/f/FracturedPowerstone.java b/Mage.Sets/src/mage/cards/f/FracturedPowerstone.java new file mode 100644 index 00000000000..cdb580f992c --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FracturedPowerstone.java @@ -0,0 +1,80 @@ +package mage.cards.f; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.ActivateAsSorceryActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.mana.ColorlessManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.abilities.Abilities; +import mage.abilities.common.ActivateIfConditionActivatedAbility; +import mage.game.command.CommandObject; +import mage.game.command.Plane; +import mage.game.stack.StackAbility; +import mage.watchers.common.PlanarRollWatcher; + +public final class FracturedPowerstone extends CardImpl { + + public FracturedPowerstone(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); + + // {tap}: Add {C}. + this.addAbility(new ColorlessManaAbility()); + // {tap}: Add roll planar die. + Ability ability = new ActivateAsSorceryActivatedAbility( + new FracturedPowerstoneEffect(), new TapSourceCost() + ); + this.addAbility(ability); + } + + public FracturedPowerstone(final FracturedPowerstone card) { + super(card); + } + + @Override + public FracturedPowerstone copy() { + return new FracturedPowerstone(this); + } +} + +class FracturedPowerstoneEffect extends OneShotEffect { + + FracturedPowerstoneEffect() { + super(Outcome.Benefit); + staticText = "Roll the planar"; + } + + private FracturedPowerstoneEffect(final FracturedPowerstoneEffect effect) { + super(effect); + } + + @Override + public FracturedPowerstoneEffect copy() { + return new FracturedPowerstoneEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for(CommandObject commandObject : game.getState().getCommand()){ + if(commandObject instanceof Plane){ + Abilities abilities = commandObject.getAbilities(); + for(Ability ability : abilities){ + if(ability instanceof ActivateIfConditionActivatedAbility){ + StackAbility stackAbility = new StackAbility(ability,game.getActivePlayerId()); + stackAbility.createCopyOnStack(game, source, source.getControllerId(), true); + + PlanarRollWatcher watcher = game.getState().getWatcher(PlanarRollWatcher.class); + watcher.removePlanarDieRoll(game.getActivePlayerId()); + return true; + } + } + } + } + return false; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Planechase2012Edition.java b/Mage.Sets/src/mage/sets/Planechase2012Edition.java index 3b456a8d7f7..98b81c6bef7 100644 --- a/Mage.Sets/src/mage/sets/Planechase2012Edition.java +++ b/Mage.Sets/src/mage/sets/Planechase2012Edition.java @@ -69,6 +69,7 @@ public final class Planechase2012Edition extends ExpansionSet { cards.add(new SetCardInfo("Forest", 154, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Forest", 155, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Forest", 156, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Fractured Powerstone", 111, Rarity.COMMON, mage.cards.f.FracturedPowerstone.class)); cards.add(new SetCardInfo("Fusion Elemental", 93, Rarity.UNCOMMON, mage.cards.f.FusionElemental.class)); cards.add(new SetCardInfo("Ghostly Prison", 7, Rarity.UNCOMMON, mage.cards.g.GhostlyPrison.class)); cards.add(new SetCardInfo("Glen Elendra Liege", 94, Rarity.RARE, mage.cards.g.GlenElendraLiege.class)); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/pc2/FracturedPowerstoneTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/pc2/FracturedPowerstoneTest.java new file mode 100644 index 00000000000..35cc75b5d68 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/pc2/FracturedPowerstoneTest.java @@ -0,0 +1,61 @@ +package org.mage.test.cards.single.pc2; + +import mage.constants.PhaseStep; +import mage.constants.Planes; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps; + +public class FracturedPowerstoneTest extends CardTestPlayerBaseWithAIHelps { + + @Test + public void test_FracturedPowerstone_Single() { + // Active player can roll the planar die: Whenever you roll {CHAOS}, create a 7/7 colorless Eldrazi creature with annhilator 1 + addPlane(playerA, Planes.PLANE_HEDRON_FIELDS_OF_AGADEEM); + addCard(Zone.BATTLEFIELD, playerA, "Fractured Powerstone", 1); + + // first chaos + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{0}: Roll the planar"); + setDieRollResult(playerA, 1); // make chaos + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + //second chaos (fractured powerstone) + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Roll the planar"); + setDieRollResult(playerA, 1); // make chaos + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Eldrazi Token", 2); + assertTappedCount("Fractured Powerstone", true, 1); + } + + @Test + public void test_FracturedPowerstone_NoCost() { + // Active player can roll the planar die: Whenever you roll {CHAOS}, create a 7/7 colorless Eldrazi creature with annhilator 1 + addPlane(playerA, Planes.PLANE_HEDRON_FIELDS_OF_AGADEEM); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + addCard(Zone.BATTLEFIELD, playerA, "Fractured Powerstone", 1); + + // first chaos + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{0}: Roll the planar"); + setDieRollResult(playerA, 1); // make chaos + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + //second chaos (fractured powerstone) + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Roll the planar"); + setDieRollResult(playerA, 1); // make chaos + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + // third chaos (with additional cost) + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{0}: Roll the planar"); + setDieRollResult(playerA, 1); // make chaos + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Eldrazi Token", 3); + assertTappedCount("Mountain", true, 1); // cost for second planar die + } +} diff --git a/Mage/src/main/java/mage/watchers/common/PlanarRollWatcher.java b/Mage/src/main/java/mage/watchers/common/PlanarRollWatcher.java index 65714bfc3a4..9bd1b184a93 100644 --- a/Mage/src/main/java/mage/watchers/common/PlanarRollWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlanarRollWatcher.java @@ -51,5 +51,12 @@ public class PlanarRollWatcher extends Watcher { super.reset(); numberTimesPlanarDieRolled.clear(); } + + public void removePlanarDieRoll(UUID playerId) { + Integer amount = numberTimesPlanarDieRolled.get(playerId); + if (amount != null){ + numberTimesPlanarDieRolled.put(playerId, amount-1); + } + } }