mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Fixed some more exception and/or logging problems.
This commit is contained in:
parent
9268281c4b
commit
2f016c8ea6
11 changed files with 63 additions and 47 deletions
|
|
@ -668,17 +668,20 @@ 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)) {
|
||||
throw new UnsupportedOperationException("It was not possible to do the requested undo operation (bookmark " + (bookmark - 1) + " does not exist) context: " + context);
|
||||
}
|
||||
int stateNum = savedStates.get(bookmark - 1);
|
||||
removeBookmark(bookmark);
|
||||
GameState restore = gameStates.rollback(stateNum);
|
||||
if (restore != null) {
|
||||
state.restore(restore);
|
||||
playerList.setCurrent(state.getPlayerByOrderId());
|
||||
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);
|
||||
GameState restore = gameStates.rollback(stateNum);
|
||||
if (restore != null) {
|
||||
state.restore(restore);
|
||||
playerList.setCurrent(state.getPlayerByOrderId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1355,7 +1358,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
logger.fatal(ex.getStackTrace());
|
||||
}
|
||||
this.fireErrorEvent("Game exception occurred: ", ex);
|
||||
restoreState(bookmark, "");
|
||||
restoreState(bookmark, "Game exception: " + ex.getMessage());
|
||||
bookmark = 0;
|
||||
Player activePlayer = this.getPlayer(getActivePlayerId());
|
||||
if (errorContinueCounter > 15) {
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
Map<UUID, Integer> assigned = new HashMap<>();
|
||||
if (blocked) {
|
||||
boolean excessDamageToDefender = true;
|
||||
for (UUID blockerId : blockerOrder) {
|
||||
for (UUID blockerId : new ArrayList<>(blockerOrder)) { // prevent ConcurrentModificationException
|
||||
Permanent blocker = game.getPermanent(blockerId);
|
||||
if (blocker != null) {
|
||||
int lethalDamage;
|
||||
|
|
|
|||
|
|
@ -703,7 +703,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
}
|
||||
if (getSpellAbility() == null) {
|
||||
logger.info("FATAL : no spell ability for attach to permanent: " + getName());
|
||||
// Can happen e.g. for Token Equipments like Stoneforged Blade
|
||||
return;
|
||||
}
|
||||
if (!getSpellAbility().getTargets().isEmpty() && (getSpellAbility().getTargets().get(0) instanceof TargetCard)) {
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@
|
|||
* 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.players;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -38,7 +37,8 @@ import mage.util.CircularList;
|
|||
*/
|
||||
public class PlayerList extends CircularList<UUID> {
|
||||
|
||||
public PlayerList() {}
|
||||
public PlayerList() {
|
||||
}
|
||||
|
||||
public PlayerList(final PlayerList list) {
|
||||
super(list);
|
||||
|
|
@ -47,23 +47,25 @@ public class PlayerList extends CircularList<UUID> {
|
|||
public Player getCurrent(Game game) {
|
||||
return game.getPlayer(this.get());
|
||||
}
|
||||
|
||||
|
||||
public Player getNextInRange(Player basePlayer, Game game) {
|
||||
UUID currentPlayerBefore = get();
|
||||
UUID currentPlayerBefore = get();
|
||||
UUID nextPlayerId = super.getNext();
|
||||
do {
|
||||
if (basePlayer.getInRange().contains(nextPlayerId)) {
|
||||
return game.getPlayer(nextPlayerId);
|
||||
return game.getPlayer(nextPlayerId);
|
||||
}
|
||||
nextPlayerId = super.getNext();
|
||||
}
|
||||
while (!nextPlayerId.equals(currentPlayerBefore));
|
||||
} while (!nextPlayerId.equals(currentPlayerBefore));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Player getNext(Game game) {
|
||||
Player player;
|
||||
UUID start = this.get();
|
||||
if (start == null) {
|
||||
return null;
|
||||
}
|
||||
Player player;
|
||||
while (true) {
|
||||
player = game.getPlayer(super.getNext());
|
||||
if (!player.hasLeft() && !player.hasLost()) {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@
|
|||
*/
|
||||
package mage.util;
|
||||
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
|
@ -111,7 +109,10 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
* @return
|
||||
*/
|
||||
public E get() {
|
||||
return list.get(this.index);
|
||||
if (list.size() > this.index) {
|
||||
return list.get(this.index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue