mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Fixed extort that decision if player uses extort and mana payment now happens during resolution.
This commit is contained in:
parent
9f8722c359
commit
5b1de89159
1 changed files with 21 additions and 17 deletions
|
@ -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<ExtortAbility> {
|
|||
|
||||
public ExtortAbility() {
|
||||
super(Zone.BATTLEFIELD, new ExtortEffect(), false);
|
||||
this.costs.add(new ManaCostsImpl("{W/B}"));
|
||||
}
|
||||
|
||||
public ExtortAbility(final ExtortAbility ability) {
|
||||
|
@ -67,13 +67,8 @@ public class ExtortAbility extends TriggeredAbilityImpl<ExtortAbility> {
|
|||
@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 false;
|
||||
}
|
||||
|
||||
|
@ -100,6 +95,12 @@ class ExtortEffect extends OneShotEffect<ExtortEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
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);
|
||||
|
@ -107,12 +108,15 @@ class ExtortEffect extends OneShotEffect<ExtortEffect> {
|
|||
if (loseLife > 0) {
|
||||
game.getPlayer(source.getControllerId()).gainLife(loseLife, game);
|
||||
}
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
game.informPlayers(new StringBuilder(permanent.getName()).append(" extorted opponents ").append(loseLife).append(" life").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtortEffect copy() {
|
||||
|
|
Loading…
Reference in a new issue