From 5b1de8915961f5d4cbd7bd614dd0dc33ea20ebd8 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 4 Mar 2013 08:49:03 +0100 Subject: [PATCH] Fixed extort that decision if player uses extort and mana payment now happens during resolution. --- .../mage/abilities/keyword/ExtortAbility.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/Mage/src/mage/abilities/keyword/ExtortAbility.java b/Mage/src/mage/abilities/keyword/ExtortAbility.java index c7e2ac7ee1..d4f4f8134a 100644 --- a/Mage/src/mage/abilities/keyword/ExtortAbility.java +++ b/Mage/src/mage/abilities/keyword/ExtortAbility.java @@ -33,6 +33,7 @@ import mage.Constants; import mage.Constants.Zone; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.costs.Cost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; import mage.game.Game; @@ -57,7 +58,6 @@ public class ExtortAbility extends TriggeredAbilityImpl { public ExtortAbility() { super(Zone.BATTLEFIELD, new ExtortEffect(), false); - this.costs.add(new ManaCostsImpl("{W/B}")); } public ExtortAbility(final ExtortAbility ability) { @@ -67,12 +67,7 @@ public class ExtortAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) { - Player player = game.getPlayer(this.getControllerId()); - Permanent sourcePerm = game.getPermanent(sourceId); - if (player != null && sourcePerm != null && - player.chooseUse(Constants.Outcome.Damage, new StringBuilder("Extort opponents? (").append(sourcePerm.getName()).append(")").toString(), game)) { - return true; - } + return true; } return false; } @@ -100,18 +95,27 @@ class ExtortEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int loseLife = 0; - for (UUID opponentId : game.getOpponents(source.getControllerId())) { - loseLife += game.getPlayer(opponentId).loseLife(1, game); - } - if (loseLife > 0) { - game.getPlayer(source.getControllerId()).gainLife(loseLife, game); - } + Player player = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - game.informPlayers(new StringBuilder(permanent.getName()).append(" extorted opponents ").append(loseLife).append(" life").toString()); + if (player != null && permanent != null) { + if (player.chooseUse(Constants.Outcome.Damage, new StringBuilder("Extort opponents? (").append(permanent.getName()).append(")").toString(), game)) { + Cost cost = new ManaCostsImpl("{W/B}"); + if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) { + int loseLife = 0; + for (UUID opponentId : game.getOpponents(source.getControllerId())) { + loseLife += game.getPlayer(opponentId).loseLife(1, game); + } + if (loseLife > 0) { + game.getPlayer(source.getControllerId()).gainLife(loseLife, game); + } + if (permanent != null) { + game.informPlayers(new StringBuilder(permanent.getName()).append(" extorted opponents ").append(loseLife).append(" life").toString()); + } + } + } + return true; } - return true; + return false; } @Override