fixed Soul Ransom not working correctly
@@ -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;
@@ -56,7 +57,6 @@ public class SoulRansom extends CardImpl {
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);
@@ -67,12 +67,13 @@ public class SoulRansom extends CardImpl {
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;
+ }
+}
