From 10185a09992e57c5a31317e6dfdd5b7e4823457c Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 8 Nov 2021 08:04:16 -0500 Subject: [PATCH] [VOW] Implemented Screaming Swarm --- .../src/mage/cards/s/ScreamingSwarm.java | 111 ++++++++++++++++++ .../src/mage/sets/InnistradCrimsonVow.java | 1 + .../AttacksWithCreaturesTriggeredAbility.java | 14 ++- 3 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/s/ScreamingSwarm.java diff --git a/Mage.Sets/src/mage/cards/s/ScreamingSwarm.java b/Mage.Sets/src/mage/cards/s/ScreamingSwarm.java new file mode 100644 index 00000000000..51915a260d3 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/ScreamingSwarm.java @@ -0,0 +1,111 @@ +package mage.cards.s; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.AttacksWithCreaturesTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.MillCardsTargetEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetPlayer; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ScreamingSwarm extends CardImpl { + + public ScreamingSwarm(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}"); + + this.subtype.add(SubType.BIRD); + this.subtype.add(SubType.HORROR); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Whenever you attack with one or more creatures, target player mills that many cards. + Ability ability = new AttacksWithCreaturesTriggeredAbility( + new MillCardsTargetEffect(ScreamingSwarmValue.instance) + .setText("target player mills that many cards"), + 0 + ).setTriggerPhrase("Whenever you attack with one or more creatures, "); + ability.addTarget(new TargetPlayer()); + this.addAbility(ability); + + // {2}{U}: Put Screaming Swarm from your graveyard into your library second from the top. + this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, new ScreamingSwarmEffect(), new ManaCostsImpl<>("{2}{U}"))); + } + + private ScreamingSwarm(final ScreamingSwarm card) { + super(card); + } + + @Override + public ScreamingSwarm copy() { + return new ScreamingSwarm(this); + } +} + +enum ScreamingSwarmValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return (Integer) effect.getValue("attackers"); + } + + @Override + public ScreamingSwarmValue copy() { + return this; + } + + @Override + public String getMessage() { + return ""; + } +} + +class ScreamingSwarmEffect extends OneShotEffect { + + ScreamingSwarmEffect() { + super(Outcome.Benefit); + staticText = "put {this} from your graveyard into your library second from the top"; + } + + private ScreamingSwarmEffect(final ScreamingSwarmEffect effect) { + super(effect); + } + + @Override + public ScreamingSwarmEffect copy() { + return new ScreamingSwarmEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObjectIfItStillExists(game); + return player != null + && sourceObject instanceof Card + && player.putCardOnTopXOfLibrary( + (Card) sourceObject, game, source, 2, true + ); + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java index b61f27111db..b4075e65f00 100644 --- a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java +++ b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java @@ -246,6 +246,7 @@ public final class InnistradCrimsonVow extends ExpansionSet { cards.add(new SetCardInfo("Savage Packmate", 234, Rarity.UNCOMMON, mage.cards.s.SavagePackmate.class)); cards.add(new SetCardInfo("Sawblade Slinger", 217, Rarity.UNCOMMON, mage.cards.s.SawbladeSlinger.class)); cards.add(new SetCardInfo("Scattered Thoughts", 74, Rarity.COMMON, mage.cards.s.ScatteredThoughts.class)); + cards.add(new SetCardInfo("Screaming Swarm", 75, Rarity.UNCOMMON, mage.cards.s.ScreamingSwarm.class)); cards.add(new SetCardInfo("Selhoff Entomber", 76, Rarity.COMMON, mage.cards.s.SelhoffEntomber.class)); cards.add(new SetCardInfo("Serpentine Ambush", 77, Rarity.COMMON, mage.cards.s.SerpentineAmbush.class)); cards.add(new SetCardInfo("Shattered Sanctum", 264, Rarity.RARE, mage.cards.s.ShatteredSanctum.class)); diff --git a/Mage/src/main/java/mage/abilities/common/AttacksWithCreaturesTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksWithCreaturesTriggeredAbility.java index 66f769353e8..2ea2a0b5138 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksWithCreaturesTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksWithCreaturesTriggeredAbility.java @@ -49,14 +49,22 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - return isControlledBy(game.getCombat().getAttackingPlayerId()) - && game + if (!isControlledBy(game.getCombat().getAttackingPlayerId())) { + return false; + } + int attackers = game .getCombat() .getAttackers() .stream() .map(game::getPermanent) .filter(permanent -> filter.match(permanent, sourceId, controllerId, game)) - .mapToInt(x -> 1).sum() >= minAttackers; + .mapToInt(x -> 1) + .sum(); + if (attackers < minAttackers) { + return false; + } + getEffects().setValue("attackers", attackers); + return true; } @Override