From 8b9cdcd48c1c7e89f90797ab4addf67a001b6e08 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 7 Aug 2019 13:32:29 -0400 Subject: [PATCH] Implemented Voice of the Many --- .../src/mage/cards/v/VoiceOfTheMany.java | 78 +++++++++++++++++++ .../src/mage/sets/Commander2019Edition.java | 1 + 2 files changed, 79 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/v/VoiceOfTheMany.java diff --git a/Mage.Sets/src/mage/cards/v/VoiceOfTheMany.java b/Mage.Sets/src/mage/cards/v/VoiceOfTheMany.java new file mode 100644 index 0000000000..3911eb227e --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VoiceOfTheMany.java @@ -0,0 +1,78 @@ +package mage.cards.v; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.StaticFilters; +import mage.game.Game; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VoiceOfTheMany extends CardImpl { + + public VoiceOfTheMany(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{G}"); + + this.subtype.add(SubType.ELF); + this.subtype.add(SubType.DRUID); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // When Voice of the Many enters the battlefield, draw a card for each opponent who controls fewer creatures than you do. + this.addAbility(new EntersBattlefieldTriggeredAbility(new VoiceOfTheManyEffect())); + } + + private VoiceOfTheMany(final VoiceOfTheMany card) { + super(card); + } + + @Override + public VoiceOfTheMany copy() { + return new VoiceOfTheMany(this); + } +} + +class VoiceOfTheManyEffect extends OneShotEffect { + + VoiceOfTheManyEffect() { + super(Outcome.Benefit); + staticText = "draw a card for each opponent who controls fewer creatures than you do"; + } + + private VoiceOfTheManyEffect(final VoiceOfTheManyEffect effect) { + super(effect); + } + + @Override + public VoiceOfTheManyEffect copy() { + return new VoiceOfTheManyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int myCount = game.getBattlefield().getAllActivePermanents( + StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game + ).size(); + int toDraw = game + .getOpponents(source.getControllerId()) + .stream() + .mapToInt(uuid -> game.getBattlefield().getAllActivePermanents( + StaticFilters.FILTER_PERMANENT_CREATURE, uuid, game + ).size() < myCount ? 1 : 0) + .sum(); + if (toDraw == 0) { + return true; + } + return new DrawCardSourceControllerEffect(toDraw).apply(game, source); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Commander2019Edition.java b/Mage.Sets/src/mage/sets/Commander2019Edition.java index b218f9bdaf..5ca14de49d 100644 --- a/Mage.Sets/src/mage/sets/Commander2019Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2019Edition.java @@ -131,6 +131,7 @@ public final class Commander2019Edition extends ExpansionSet { cards.add(new SetCardInfo("Trostani, Selesnya's Voice", 204, Rarity.MYTHIC, mage.cards.t.TrostaniSelesnyasVoice.class)); cards.add(new SetCardInfo("Urban Evolution", 205, Rarity.UNCOMMON, mage.cards.u.UrbanEvolution.class)); cards.add(new SetCardInfo("Vesuvan Shapeshifter", 101, Rarity.RARE, mage.cards.v.VesuvanShapeshifter.class)); + cards.add(new SetCardInfo("Voice of the Many", 36, Rarity.UNCOMMON, mage.cards.v.VoiceOfTheMany.class)); cards.add(new SetCardInfo("Volrath, the Shapestealer", 51, Rarity.MYTHIC, mage.cards.v.VolrathTheShapestealer.class)); cards.add(new SetCardInfo("Vraska the Unseen", 207, Rarity.MYTHIC, mage.cards.v.VraskaTheUnseen.class)); cards.add(new SetCardInfo("Willbender", 102, Rarity.UNCOMMON, mage.cards.w.Willbender.class));