diff --git a/Mage.Sets/src/mage/cards/z/ZabazTheGlimmerwasp.java b/Mage.Sets/src/mage/cards/z/ZabazTheGlimmerwasp.java new file mode 100644 index 0000000000..90caaec27d --- /dev/null +++ b/Mage.Sets/src/mage/cards/z/ZabazTheGlimmerwasp.java @@ -0,0 +1,116 @@ +package mage.cards.z; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.ModularAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ZabazTheGlimmerwasp extends CardImpl { + + public ZabazTheGlimmerwasp(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.INSECT); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // Modular 1 + this.addAbility(new ModularAbility(this, 1)); + + // If a modular triggered ability would put one or more +1/+1 counters on a creature you control, that many plus one +1/+1 counters are put on it instead. + this.addAbility(new SimpleStaticAbility(new ZabazTheGlimmerwaspEffect())); + + // {R}: Destroy target artifact you control. + Ability ability = new SimpleActivatedAbility(new DestroyTargetEffect(), new ManaCostsImpl<>("{R}")); + ability.addTarget(new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT)); + this.addAbility(ability); + + // {W}: Zabaz, the Glimmerwasp gains flying until end of turn. + this.addAbility(new SimpleActivatedAbility(new GainAbilitySourceEffect( + FlyingAbility.getInstance(), Duration.EndOfTurn + ), new ManaCostsImpl<>("{W}"))); + } + + private ZabazTheGlimmerwasp(final ZabazTheGlimmerwasp card) { + super(card); + } + + @Override + public ZabazTheGlimmerwasp copy() { + return new ZabazTheGlimmerwasp(this); + } +} + +class ZabazTheGlimmerwaspEffect extends ReplacementEffectImpl { + + ZabazTheGlimmerwaspEffect() { + super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false); + staticText = "if a modular triggered ability would put one or more +1/+1 counters on a creature you control, " + + "that many plus one +1/+1 counters are put on it instead"; + } + + ZabazTheGlimmerwaspEffect(final ZabazTheGlimmerwaspEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + event.setAmountForCounters(event.getAmount() + 1, true); + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ADD_COUNTERS; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (!event.getData().equals(CounterType.P1P1.getName()) || event.getAmount() < 1) { + return false; + } + StackObject stackAbility = game.getStack().getStackObject(event.getSourceId()); + if (stackAbility == null || !(stackAbility.getStackAbility() instanceof ModularAbility)) { + return false; + } + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null) { + permanent = game.getPermanentEntering(event.getTargetId()); + } + return permanent != null + && permanent.isControlledBy(source.getControllerId()) + && permanent.isCreature(); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public ZabazTheGlimmerwaspEffect copy() { + return new ZabazTheGlimmerwaspEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons2.java b/Mage.Sets/src/mage/sets/ModernHorizons2.java index 461cd70fb2..5d587261b1 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons2.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons2.java @@ -323,6 +323,7 @@ public final class ModernHorizons2 extends ExpansionSet { cards.add(new SetCardInfo("Yavimaya, Cradle of Growth", 261, Rarity.RARE, mage.cards.y.YavimayaCradleOfGrowth.class)); cards.add(new SetCardInfo("Young Necromancer", 110, Rarity.UNCOMMON, mage.cards.y.YoungNecromancer.class)); cards.add(new SetCardInfo("Yusri, Fortune's Flame", 218, Rarity.RARE, mage.cards.y.YusriFortunesFlame.class)); + cards.add(new SetCardInfo("Zabaz, the Glimmerwasp", 243, Rarity.RARE, mage.cards.z.ZabazTheGlimmerwasp.class)); cards.add(new SetCardInfo("Zuran Orb", 300, Rarity.UNCOMMON, mage.cards.z.ZuranOrb.class)); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/mh2/ZabazTheGlimmerwaspTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/mh2/ZabazTheGlimmerwaspTest.java new file mode 100644 index 0000000000..e9804cf25f --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/mh2/ZabazTheGlimmerwaspTest.java @@ -0,0 +1,57 @@ +package org.mage.test.cards.single.mh2; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author TheElk801 + */ +public class ZabazTheGlimmerwaspTest extends CardTestPlayerBase { + + private static final String zabaz = "Zabaz, the Glimmerwasp"; + private static final String worker = "Arcbound Worker"; + private static final String atog = "Atog"; + + @Test + public void testModularETB() { + addCard(Zone.BATTLEFIELD, playerA, "Island"); + addCard(Zone.BATTLEFIELD, playerA, zabaz); + addCard(Zone.HAND, playerA, worker); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, worker); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPowerToughness(playerA, worker, 1, 1); + assertPowerToughness(playerA, zabaz, 1, 1); + } + + @Test + public void testModularDies() { + addCard(Zone.BATTLEFIELD, playerA, "Island"); + addCard(Zone.BATTLEFIELD, playerA, zabaz); + addCard(Zone.BATTLEFIELD, playerA, atog); + addCard(Zone.HAND, playerA, worker); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, worker); + + setChoice(playerA, worker); + addTarget(playerA, zabaz); + setChoice(playerA, "Yes"); + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Sacrifice"); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, worker, 1); + assertPowerToughness(playerA, zabaz, 1 + 1 + 1, 1 + 1 + 1); + assertPowerToughness(playerA, atog, 1 + 2, 2 + 2); + } +}