From 9493487d7fbef1fc04264dd4b1ba0b599d197bce Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Sun, 17 Apr 2022 11:19:19 -0500 Subject: [PATCH] [SNC] Implemented Structural Assault --- .../src/mage/cards/s/StructuralAssault.java | 105 ++++++++++++++++++ .../src/mage/sets/StreetsOfNewCapenna.java | 1 + 2 files changed, 106 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/StructuralAssault.java diff --git a/Mage.Sets/src/mage/cards/s/StructuralAssault.java b/Mage.Sets/src/mage/cards/s/StructuralAssault.java new file mode 100644 index 0000000000..70f8f6a3ee --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/StructuralAssault.java @@ -0,0 +1,105 @@ +package mage.cards.s; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyAllEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.WatcherScope; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; +import mage.watchers.Watcher; + +/** + * + * @author weirddan455 + */ +public final class StructuralAssault extends CardImpl { + + public StructuralAssault(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{R}{R}"); + + // Destroy all artifacts, then Structural Assault deals damage to each creature equal to the number of artifacts that were put into graveyards from the battlefield this turn. + this.getSpellAbility().addEffect(new DestroyAllEffect(StaticFilters.FILTER_PERMANENT_ARTIFACTS)); + this.getSpellAbility().addEffect(new StructuralAssaultEffect()); + this.getSpellAbility().addWatcher(new StructuralAssaultWatcher()); + } + + private StructuralAssault(final StructuralAssault card) { + super(card); + } + + @Override + public StructuralAssault copy() { + return new StructuralAssault(this); + } +} + +// CardsPutIntoGraveyardWatcher does not count tokens so custom watcher is needed. +class StructuralAssaultWatcher extends Watcher { + + private int artifactsDied = 0; + + public StructuralAssaultWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + if (zEvent.isDiesEvent() && zEvent.getTarget().isArtifact(game)) { + artifactsDied++; + } + } + } + + @Override + public void reset() { + super.reset(); + artifactsDied = 0; + } + + public int getArtifactsDied() { + return artifactsDied; + } +} + +class StructuralAssaultEffect extends OneShotEffect { + + public StructuralAssaultEffect() { + super(Outcome.Damage); + this.staticText = ", then {this} deals damage to each creature equal to the number of artifacts that were put into graveyards from the battlefield this turn"; + } + + private StructuralAssaultEffect(final StructuralAssaultEffect effect) { + super(effect); + } + + @Override + public StructuralAssaultEffect copy() { + return new StructuralAssaultEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + StructuralAssaultWatcher watcher = game.getState().getWatcher(StructuralAssaultWatcher.class); + if (watcher != null) { + int artifacts = watcher.getArtifactsDied(); + if (artifacts > 0) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), source, game)) { + permanent.damage(artifacts, source, game); + } + return true; + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java index bb0782623b..acbe356ff4 100644 --- a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java +++ b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java @@ -222,6 +222,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet { cards.add(new SetCardInfo("Sticky Fingers", 124, Rarity.COMMON, mage.cards.s.StickyFingers.class)); cards.add(new SetCardInfo("Stimulus Package", 225, Rarity.UNCOMMON, mage.cards.s.StimulusPackage.class)); cards.add(new SetCardInfo("Strangle", 125, Rarity.COMMON, mage.cards.s.Strangle.class)); + cards.add(new SetCardInfo("Structural Assault", 126, Rarity.RARE, mage.cards.s.StructuralAssault.class)); cards.add(new SetCardInfo("Suspicious Bookcase", 245, Rarity.UNCOMMON, mage.cards.s.SuspiciousBookcase.class)); cards.add(new SetCardInfo("Swamp", 266, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Swooping Protector", 33, Rarity.UNCOMMON, mage.cards.s.SwoopingProtector.class));