[SNC] Implemented Structural Assault

This commit is contained in:
Daniel Bomar 2022-04-17 11:19:19 -05:00
parent e03020e4d2
commit 9493487d7f
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 106 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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("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("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("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("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("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)); cards.add(new SetCardInfo("Swooping Protector", 33, Rarity.UNCOMMON, mage.cards.s.SwoopingProtector.class));