fixed Soul Ransom not working correctly

This commit is contained in:
Evan Kranzler 2018-05-06 00:38:50 -04:00
parent 1a4e892f04
commit 765c42b2c6

View file

@ -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;
}
}