diff --git a/Mage.Sets/src/mage/cards/a/AuroraShifter.java b/Mage.Sets/src/mage/cards/a/AuroraShifter.java new file mode 100644 index 00000000000..e74f7f594c5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AuroraShifter.java @@ -0,0 +1,118 @@ +package mage.cards.a; + +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfCombatTriggeredAbility; +import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.costs.common.PayEnergyCost; +import mage.abilities.dynamicvalue.common.SavedDamageValue; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DoWhenCostPaid; +import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect; +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.util.functions.CopyApplier; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; + +/** + * + * @author grimreap124 + */ +public final class AuroraShifter extends CardImpl { + + public AuroraShifter(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[] { CardType.CREATURE }, "{1}{U}"); + + this.subtype.add(SubType.SHAPESHIFTER); + this.power = new MageInt(1); + this.toughness = new MageInt(3); + + // Whenever Aurora Shifter deals combat damage to a player, you get that many {E}. + this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility( + new GetEnergyCountersControllerEffect(SavedDamageValue.MUCH))); + + // At the beginning of combat on your turn, you may pay {E}{E}. When you do, Aurora Shifter becomes a copy of another target creature you control, except it has this ability and "Whenever this creature deals combat damage to a player, you get that many {E}." + ReflexiveTriggeredAbility reflexive = new ReflexiveTriggeredAbility( + new AuroraShifterCopyEffect(), + false); + reflexive.addTarget(new TargetPermanent(StaticFilters.FILTER_ANOTHER_TARGET_CREATURE_YOU_CONTROL)); + + this.addAbility(new BeginningOfCombatTriggeredAbility( + new DoWhenCostPaid(reflexive, new PayEnergyCost(2), + "Pay {E}{E}? When you do, {this} becomes a copy of another target creature you control, except it has this ability and \"Whenever this creature deals combat damage to a player, you get that many {E}.\""), + TargetController.YOU, false)); + } + + private AuroraShifter(final AuroraShifter card) { + super(card); + } + + @Override + public AuroraShifter copy() { + return new AuroraShifter(this); + } +} + +class AuroraShifterCopyEffect extends OneShotEffect { + + AuroraShifterCopyEffect() { + super(Outcome.Copy); + this.staticText = "{this} becomes a copy of another target creature you control, except it has this ability and \"Whenever this creature deals combat damage to a player, you get that many {E}.\""; + } + + private AuroraShifterCopyEffect(final AuroraShifterCopyEffect effect) { + super(effect); + } + + @Override + public AuroraShifterCopyEffect copy() { + return new AuroraShifterCopyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + Permanent copyFromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + + if (sourcePermanent != null && copyFromPermanent != null) { + game.copyPermanent(Duration.WhileOnBattlefield, copyFromPermanent, sourcePermanent.getId(), source, + new AuroraShifterCopyApplier()); + return true; + } + return false; + } +} + +class AuroraShifterCopyApplier extends CopyApplier { + + @Override + public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) { + + // At the beginning of combat on your turn, you may pay {E}{E}. When you do, Aurora Shifter becomes a copy of another target creature you control, except it has this ability and "Whenever this creature deals combat damage to a player, you get that many {E}." + ReflexiveTriggeredAbility reflexive = new ReflexiveTriggeredAbility( + new AuroraShifterCopyEffect(), + false); + reflexive.addTarget(new TargetPermanent(StaticFilters.FILTER_ANOTHER_TARGET_CREATURE_YOU_CONTROL)); + + blueprint.getAbilities().add(new BeginningOfCombatTriggeredAbility( + new DoWhenCostPaid(reflexive, new PayEnergyCost(2), + "Pay {E}{E}? When you do, {this} becomes a copy of another target creature you control, except it has this ability and \"Whenever this creature deals combat damage to a player, you get that many {E}.\""), + TargetController.YOU, false)); + + + blueprint.getAbilities().add(new DealsCombatDamageToAPlayerTriggeredAbility( + new GetEnergyCountersControllerEffect(SavedDamageValue.MANY))); + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ModernHorizons3Commander.java b/Mage.Sets/src/mage/sets/ModernHorizons3Commander.java index da927aa0ea6..77ab07189e0 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons3Commander.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons3Commander.java @@ -44,6 +44,7 @@ public final class ModernHorizons3Commander extends ExpansionSet { cards.add(new SetCardInfo("Archon of Cruelty", 197, Rarity.MYTHIC, mage.cards.a.ArchonOfCruelty.class)); cards.add(new SetCardInfo("Artisan of Kozilek", 153, Rarity.UNCOMMON, mage.cards.a.ArtisanOfKozilek.class)); cards.add(new SetCardInfo("Ash Barrens", 318, Rarity.COMMON, mage.cards.a.AshBarrens.class)); + cards.add(new SetCardInfo("Aurora Shifter", 45, Rarity.RARE, mage.cards.a.AuroraShifter.class)); cards.add(new SetCardInfo("Austere Command", 167, Rarity.RARE, mage.cards.a.AustereCommand.class)); cards.add(new SetCardInfo("Avenger of Zendikar", 221, Rarity.MYTHIC, mage.cards.a.AvengerOfZendikar.class)); cards.add(new SetCardInfo("Awakening Zone", 222, Rarity.RARE, mage.cards.a.AwakeningZone.class)); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/mh3/AuroraShifterTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/mh3/AuroraShifterTest.java new file mode 100644 index 00000000000..560b71ae717 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/mh3/AuroraShifterTest.java @@ -0,0 +1,60 @@ +package org.mage.test.cards.single.mh3; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.players.Player; +import org.junit.Assert; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +public class AuroraShifterTest extends CardTestPlayerBase { + + /** + * {@link mage.cards.a.AuroraShifter Aurora Shifter} {1}{U} + * Creature - Shapeshifter + * Changeling + * Whenever Aurora Shifter deals combat damage to a player, you get that many {E}. + * At the beginning of combat on your turn, you may pay {E}{E}. + * When you do, Aurora Shifter becomes a copy of another target creature you control, + * except it has this ability and "Whenever this creature deals combat damage to a player, you get that many {E}." + * + * 1/3 + */ + private static final String shifter = "Aurora Shifter"; + + private static void checkEnergyCount(String message, Player player, int expected) { + Assert.assertEquals(message, expected, player.getCountersCount(CounterType.ENERGY)); + } + + @Test + public void test_4_combats() { + setStrictChooseMode(true); + + addCard(Zone.BATTLEFIELD, playerA, shifter); + addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears"); + +// Combat 1 + attack(1, playerA, shifter, playerB); + runCode("energy counter is 1", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 1)); + setStopAt(1, PhaseStep.END_TURN); + +// Combat 2 + attack(3, playerA, shifter, playerB); + runCode("energy counter is 2", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 2)); + setStopAt(3, PhaseStep.END_TURN); + +// Combat 3 - can pay for copy + addTarget(playerA, "Grizzly Bears"); // Aurora Shifter becomes a copy of another target creature you control + setChoice(playerA, true); // you may pay {E}{E}. + showBattlefield("BEGIN_COMBAT", 5, PhaseStep.BEGIN_COMBAT, playerA); + showBattlefield("DECLARE_ATTACKERS", 5, PhaseStep.DECLARE_ATTACKERS, playerA); + attack(5, playerA, "Grizzly Bears", playerB); + runCode("energy counter is 0", 5, PhaseStep.POSTCOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 2)); + setStopAt(5, PhaseStep.END_TURN); + execute(); + assertLife(playerB, 20 - 1 - 1 - 2); // 1 damage from being shifter, 1 from shifter, 2 from transforming into Grizzly Bears + assertCounterCount(playerA, CounterType.ENERGY, 2); // 2 Energy from being a Grizzly Bears + } + +}