From 765c42b2c68593b66abdd7fc72257c1becb4b9df Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 6 May 2018 00:38:50 -0400 Subject: [PATCH] fixed Soul Ransom not working correctly --- Mage.Sets/src/mage/cards/s/SoulRansom.java | 57 +++++++++++++++++----- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/Mage.Sets/src/mage/cards/s/SoulRansom.java b/Mage.Sets/src/mage/cards/s/SoulRansom.java index fd0a77a8e13..6b060fdf5b8 100644 --- a/Mage.Sets/src/mage/cards/s/SoulRansom.java +++ b/Mage.Sets/src/mage/cards/s/SoulRansom.java @@ -32,16 +32,17 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.DiscardTargetCost; -import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.AttachEffect; -import mage.abilities.effects.common.DrawCardSourceControllerEffect; -import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.continuous.ControlEnchantedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.filter.FilterCard; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; import mage.target.TargetPermanent; import mage.target.common.TargetCardInHand; import mage.target.common.TargetCreaturePermanent; @@ -53,10 +54,9 @@ import mage.target.common.TargetCreaturePermanent; public class SoulRansom extends CardImpl { public SoulRansom(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{U}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}{B}"); this.subtype.add(SubType.AURA); - // Enchant creature TargetPermanent auraTarget = new TargetCreaturePermanent(); this.getSpellAbility().addTarget(auraTarget); @@ -65,14 +65,15 @@ public class SoulRansom extends CardImpl { this.addAbility(ability); // You control enchanted creature. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ControlEnchantedEffect())); - + // Discard two cards: Soul Ransom's controller sacrifices it, then draws two cards. Only any opponent may activate this ability. - Effect effect = new SacrificeSourceEffect(); - effect.setText("{this}'s controller sacrifices it"); - SimpleActivatedAbility ability2 = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect , new DiscardTargetCost(new TargetCardInHand(2,2, new FilterCard("two cards")))); - effect = new DrawCardSourceControllerEffect(2); - effect.setText("Then draws two cards. Only any opponent may activate this ability"); - ability2.addEffect(effect); + SimpleActivatedAbility ability2 = new SimpleActivatedAbility( + Zone.BATTLEFIELD, + new SoulRansomEffect(), + new DiscardTargetCost( + new TargetCardInHand(2, 2, new FilterCard("two cards")) + ) + ); ability2.setMayActivate(TargetController.OPPONENT); this.addAbility(ability2); @@ -87,3 +88,35 @@ public class SoulRansom extends CardImpl { return new SoulRansom(this); } } + +class SoulRansomEffect extends OneShotEffect { + + SoulRansomEffect() { + super(Outcome.Benefit); + this.staticText = "{this} controller sacrifices it, then draws two cards. Only any opponent may activate this ability"; + } + + SoulRansomEffect(final SoulRansomEffect effect) { + super(effect); + } + + @Override + public SoulRansomEffect copy() { + return new SoulRansomEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (permanent == null) { + return false; + } + Player controller = game.getPlayer(permanent.getControllerId()); + if (controller == null) { + return false; + } + controller.drawCards(2, game); + permanent.sacrifice(source.getSourceId(), game); + return true; + } +}