Cheats: added error dialog on wrong cheat command, added chat message about cheat try;

This commit is contained in:
Oleg Agafonov 2023-05-09 00:22:00 +04:00
parent 6882a9a49e
commit 5c705a92a3
3 changed files with 83 additions and 21 deletions

View file

@ -1636,15 +1636,16 @@ public abstract class GameImpl implements Game {
String info = this.getStack().stream().map(MageObject::toString).collect(Collectors.joining("\n"));
logger.info(String.format("\nStack before error %d: \n%s\n", this.getStack().size(), info));
// rollback game to prev state
GameState restoredState = restoreState(rollbackBookmark, "Game exception: " + ex.getMessage());
rollbackBookmark = 0;
// too many errors - end game
if (errorContinueCounter > 15) {
throw new MageException("Iterated player priority after game exception too often, game ends! Last error:\n "
+ ex.getMessage());
}
// rollback game to prev state
GameState restoredState = restoreState(rollbackBookmark, "Game exception: " + ex.getMessage());
rollbackBookmark = 0;
if (restoredState != null) {
this.informPlayers(String.format("Auto-restored to %s due game error: %s", restoredState, ex.getMessage()));
} else {