* Mana Vault - Fixed that it doesn't return mana if payment is cancelled (fixes
@@ -80,6 +80,7 @@ public class DoIfCostPaid extends OneShotEffect {
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
&& executingEffects.size() > 0 && (!optional || player.chooseUse(executingEffects.get(0).getOutcome(), message, source, game))) {
cost.clearPaid();
+ int bookmark = game.bookmarkState();
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
for (Effect effect : executingEffects) {
effect.setTargetPointer(this.targetPointer);
@@ -90,7 +91,10 @@ public class DoIfCostPaid extends OneShotEffect {
}
}
player.resetStoredBookmark(game); // otherwise you can e.g. undo card drawn with Mentor of the Meek
- } else if (!otherwiseEffects.isEmpty()) {
+ } else {
+ // Paying cost was cancels so try to undo payment so far
+ game.restoreState(bookmark, DoIfCostPaid.class.getName());
+ if (!otherwiseEffects.isEmpty()) {
for (Effect effect : otherwiseEffects) {
effect.setTargetPointer(this.targetPointer);
if (effect instanceof OneShotEffect) {
@@ -100,6 +104,7 @@ public class DoIfCostPaid extends OneShotEffect {
}
}
}
+ }
} else if (!otherwiseEffects.isEmpty()) {
for (Effect effect : otherwiseEffects) {
effect.setTargetPointer(this.targetPointer);
