* Fixed that all spells could be cast by canceling the mana payment process.

This commit is contained in:
LevelX2 2018-02-15 16:51:47 +01:00
parent 1ef84278c2
commit e679b1003d
3 changed files with 15 additions and 13 deletions

View file

@ -668,8 +668,10 @@ public abstract class GameImpl implements Game, Serializable {
if (!simulation && !this.hasEnded()) { // if player left or game is over no undo is possible - this could lead to wrong winner
if (bookmark != 0) {
if (!savedStates.contains(bookmark - 1)) {
logger.error("It was not possible to do the requested undo operation (bookmark " + (bookmark - 1) + " does not exist) context: " + context);
logger.info("Saved states: " + savedStates.toString());
if (!savedStates.isEmpty()) { // empty if rollback to a turn was requested before, otherwise unclear why
logger.error("It was not possible to do the requested undo operation (bookmark " + (bookmark - 1) + " does not exist) context: " + context);
logger.info("Saved states: " + savedStates.toString());
}
} else {
int stateNum = savedStates.get(bookmark - 1);
removeBookmark(bookmark);
@ -2972,6 +2974,9 @@ public abstract class GameImpl implements Game, Serializable {
informPlayers(GameLog.getPlayerRequestColoredText("Player request: Rolling back to start of turn " + restore.getTurnNum()));
state.restoreForRollBack(restore);
playerList.setCurrent(state.getPlayerByOrderId());
// Reset temporary created bookmarks because no longer valid after rollback
savedStates.clear();
gameStates.clear();
// because restore uses the objects without copy each copy the state again
gameStatesRollBack.put(getTurnNum(), state.copy());
executingRollback = true;

View file

@ -24,15 +24,13 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package mage.game;
import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import org.apache.log4j.Logger;
/**
*
@ -41,8 +39,6 @@ import java.util.List;
public class GameStates implements Serializable {
private static final Logger logger = Logger.getLogger(GameStates.class);
// private final List<byte[]> states;
private final List<GameState> states;
public GameStates() {
@ -88,4 +84,7 @@ public class GameStates implements Serializable {
return null;
}
public void clear() {
states.clear();
}
}

View file

@ -1190,11 +1190,9 @@ public abstract class PlayerImpl implements Player, Serializable {
}
protected void restoreState(int bookmark, String text, Game game) {
if (storedBookmark > -1) { // e.g. a turn rollback sets this to -1 so no more rollback of current action may be done
game.restoreState(bookmark, text);
if (storedBookmark >= bookmark) {
resetStoredBookmark(game);
}
game.restoreState(bookmark, text);
if (storedBookmark >= bookmark) {
resetStoredBookmark(game);
}
}