* Collective Voyage - Undo mana payment if mana payment is canceled (fixes #3850).

This commit is contained in:
LevelX2 2017-08-24 23:19:15 +02:00
parent 4aca2506d8
commit de62867a5d

View file

@ -27,6 +27,8 @@
*/
package mage.cards.c;
import java.util.Objects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
@ -42,9 +44,6 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author LevelX2
@ -54,7 +53,6 @@ public class CollectiveVoyage extends CardImpl {
public CollectiveVoyage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{G}");
// Join forces - Starting with you, each player may pay any amount of mana. Each player searches his or her library for up to X basic land cards, where X is the total amount of mana paid this way, puts them onto the battlefield tapped, then shuffles his or her library.
this.getSpellAbility().addEffect(new CollectiveVoyageEffect());
}
@ -128,6 +126,8 @@ class CollectiveVoyageEffect extends OneShotEffect {
int xValue = 0;
boolean payed = false;
while (player.canRespond() && !payed) {
int bookmark = game.bookmarkState();
player.resetStoredBookmark(game);
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
@ -135,9 +135,14 @@ class CollectiveVoyageEffect extends OneShotEffect {
} else {
payed = true;
}
if (!payed) {
game.restoreState(bookmark, "Collective Voyage");
game.fireUpdatePlayersEvent();
} else {
game.removeBookmark(bookmark);
}
}
game.informPlayers(new StringBuilder(player.getLogName()).append(" pays {").append(xValue).append("}.").toString());
return xValue;
}
}