From ac0b3315eafb62be72f29dd547a8881bd1886bae Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 28 Jul 2018 17:18:52 -0400 Subject: [PATCH] Implemented Sower of Discord --- .../src/mage/cards/s/SowerOfDiscord.java | 162 ++++++++++++++++++ Mage.Sets/src/mage/sets/Commander2018.java | 1 + 2 files changed, 163 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SowerOfDiscord.java diff --git a/Mage.Sets/src/mage/cards/s/SowerOfDiscord.java b/Mage.Sets/src/mage/cards/s/SowerOfDiscord.java new file mode 100644 index 0000000000..480837f254 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SowerOfDiscord.java @@ -0,0 +1,162 @@ +package mage.cards.s; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.LoseLifeTargetEffect; +import mage.constants.SubType; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPlayer; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author TheElk801 + */ +public final class SowerOfDiscord extends CardImpl { + + public SowerOfDiscord(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}{B}"); + + this.subtype.add(SubType.DEMON); + this.power = new MageInt(6); + this.toughness = new MageInt(6); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // As Sower of Discord enters the battlefield, choose two players. + this.addAbility(new AsEntersBattlefieldAbility( + new BitterFeudEntersBattlefieldEffect() + )); + + // Whenever damage is dealt to one of the chosen players, the other chosen player also loses that much life. + this.addAbility(new SowerOfDiscordTriggeredAbility()); + } + + public SowerOfDiscord(final SowerOfDiscord card) { + super(card); + } + + @Override + public SowerOfDiscord copy() { + return new SowerOfDiscord(this); + } +} + +class BitterFeudEntersBattlefieldEffect extends OneShotEffect { + + public BitterFeudEntersBattlefieldEffect() { + super(Outcome.Damage); + staticText = "choose two players"; + } + + public BitterFeudEntersBattlefieldEffect(final BitterFeudEntersBattlefieldEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanentEntering(source.getSourceId()); + if (controller == null || permanent == null) { + return false; + } + TargetPlayer target = new TargetPlayer(2, 2, true); + controller.chooseTarget(outcome, target, source, game); + Player player1 = game.getPlayer(target.getFirstTarget()); + if (target.getTargets().size() <= 1) { + return false; + } + Player player2 = game.getPlayer(target.getTargets().get(1)); + if (player1 == null || player2 == null) { + return false; + } + game.getState().setValue(source.getSourceId() + "_player1", player1); + game.getState().setValue(source.getSourceId() + "_player2", player2); + game.informPlayers(permanent.getLogName() + ": " + + controller.getLogName() + " has chosen " + + player1.getLogName() + " and " + player2.getLogName() + ); + permanent.addInfo( + "chosen players", + "Chosen players: " + + player1.getName() + ", " + + player2.getName() + "", game + ); + return true; + } + + @Override + public BitterFeudEntersBattlefieldEffect copy() { + return new BitterFeudEntersBattlefieldEffect(this); + } + +} + +class SowerOfDiscordTriggeredAbility extends TriggeredAbilityImpl { + + public SowerOfDiscordTriggeredAbility() { + super(Zone.BATTLEFIELD, null); + } + + public SowerOfDiscordTriggeredAbility(final SowerOfDiscordTriggeredAbility ability) { + super(ability); + } + + @Override + public SowerOfDiscordTriggeredAbility copy() { + return new SowerOfDiscordTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGE_PLAYER; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + int damage = event.getAmount(); + Player player1 = (Player) game.getState().getValue( + this.getSourceId() + "_player1" + ); + Player player2 = (Player) game.getState().getValue( + this.getSourceId() + "_player2" + ); + if (player1 == null || player2 == null || damage == 0) { + return false; + } + Effect effect = new LoseLifeTargetEffect(damage); + if (event.getTargetId().equals(player1.getId())) { + this.getEffects().clear(); + effect.setTargetPointer(new FixedTarget(player2.getId())); + this.addEffect(effect); + return true; + } else if (event.getTargetId().equals(player2.getId())) { + this.getEffects().clear(); + effect.setTargetPointer(new FixedTarget(player1.getId())); + this.addEffect(effect); + return true; + } + return false; + } + + @Override + public String getRule() { + return "Whenever damage is dealt to one of the chosen players, " + + "the other chosen player also loses that much life."; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2018.java b/Mage.Sets/src/mage/sets/Commander2018.java index 1401860a88..45fd3874db 100644 --- a/Mage.Sets/src/mage/sets/Commander2018.java +++ b/Mage.Sets/src/mage/sets/Commander2018.java @@ -261,6 +261,7 @@ public final class Commander2018 extends ExpansionSet { cards.add(new SetCardInfo("Soul Snare", 76, Rarity.UNCOMMON, mage.cards.s.SoulSnare.class)); cards.add(new SetCardInfo("Soul of Innistrad", 118, Rarity.MYTHIC, mage.cards.s.SoulOfInnistrad.class)); cards.add(new SetCardInfo("Soul of New Phyrexia", 223, Rarity.MYTHIC, mage.cards.s.SoulOfNewPhyrexia.class)); + cards.add(new SetCardInfo("Sower of Discord", 19, Rarity.RARE, mage.cards.s.SowerOfDiscord.class)); cards.add(new SetCardInfo("Spawning Grounds", 163, Rarity.RARE, mage.cards.s.SpawningGrounds.class)); cards.add(new SetCardInfo("Sphinx of Jwar Isle", 103, Rarity.RARE, mage.cards.s.SphinxOfJwarIsle.class)); cards.add(new SetCardInfo("Sphinx of Uthuun", 104, Rarity.RARE, mage.cards.s.SphinxOfUthuun.class));