* Fixed that sacrifice was handled targeted (because of using other method now with sourceId and controllerId).

This commit is contained in:
LevelX2 2014-07-27 15:51:51 +02:00
parent 7af34eb8b1
commit e22174b148
3 changed files with 28 additions and 15 deletions

View file

@ -82,25 +82,30 @@ class MomentousFallEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int power = 0;
int toughness = 0;
Player player = game.getPlayer(source.getControllerId());
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();
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) {
player.drawCards(power, game);
controller.drawCards(power, game);
}
if (toughness > 0) {
player.gainLife(toughness, game);
controller.gainLife(toughness, game);
}
return true;
}
return false;
}
@Override
public MomentousFallEffect copy() {

View file

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

View file

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