From e22174b148d07ff39991d7bdfe5ece48fc40f490 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 27 Jul 2014 15:51:51 +0200 Subject: [PATCH] * Fixed that sacrifice was handled targeted (because of using other method now with sourceId and controllerId). --- .../sets/riseoftheeldrazi/MomentousFall.java | 35 +++++++++++-------- .../cost/sacrifice/MomentousFallTest.java | 7 ++++ .../costs/common/SacrificeTargetCost.java | 1 + 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/MomentousFall.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/MomentousFall.java index 96bd1ca94e..30b897f4a0 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/MomentousFall.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/MomentousFall.java @@ -82,24 +82,29 @@ class MomentousFallEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int power = 0; - int toughness = 0; - Player player = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { - for (Cost cost: source.getCosts()) { - if (cost instanceof SacrificeTargetCost && ((SacrificeTargetCost)cost).getPermanents().size() > 0) { - power = ((SacrificeTargetCost)cost).getPermanents().get(0).getPower().getValue(); - toughness = ((SacrificeTargetCost)cost).getPermanents().get(0).getToughness().getValue(); - break; + int power = 0; + int toughness = 0; + + for (Cost cost : source.getCosts()) { + if (cost instanceof SacrificeTargetCost && ((SacrificeTargetCost) cost).getPermanents().size() > 0) { + power = ((SacrificeTargetCost) cost).getPermanents().get(0).getPower().getValue(); + toughness = ((SacrificeTargetCost) cost).getPermanents().get(0).getToughness().getValue(); + break; + } } + if (power > 0) { + controller.drawCards(power, game); + } + if (toughness > 0) { + controller.gainLife(toughness, game); + } + return true; } - if (power > 0) { - player.drawCards(power, game); - } - if (toughness > 0) { - player.gainLife(toughness, game); - } - return true; + return false; + } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/cost/sacrifice/MomentousFallTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/cost/sacrifice/MomentousFallTest.java index 7a23d99e81..7212162e8f 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/cost/sacrifice/MomentousFallTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/cost/sacrifice/MomentousFallTest.java @@ -11,6 +11,13 @@ import org.mage.test.serverside.base.CardTestPlayerBase; */ public class MomentousFallTest extends CardTestPlayerBase { + /** + * Momentous Fall + * Instant {2}{G}{G} + * As an additional cost to cast Momentous Fall, sacrifice a creature. + * You draw cards equal to the sacrificed creature's power, then you + * gain life equal to its toughness. + */ @Test public void testSacrificeCostAndLKI() { addCard(Zone.BATTLEFIELD, playerA, "Forest", 4); diff --git a/Mage/src/mage/abilities/costs/common/SacrificeTargetCost.java b/Mage/src/mage/abilities/costs/common/SacrificeTargetCost.java index e49ec14471..d11efd57e4 100644 --- a/Mage/src/mage/abilities/costs/common/SacrificeTargetCost.java +++ b/Mage/src/mage/abilities/costs/common/SacrificeTargetCost.java @@ -48,6 +48,7 @@ public class SacrificeTargetCost extends CostImpl { public SacrificeTargetCost(TargetControlledPermanent target) { this.addTarget(target); + target.setNotTarget(true); // sacrifice is never targeted this.text = "Sacrifice " + target.getTargetName(); }