Some changes to debug messages and change to avoid conccurent change exception.

This commit is contained in:
LevelX2 2014-09-05 12:47:49 +02:00
parent 04d4e2cfd8
commit f12a616243
4 changed files with 22 additions and 20 deletions

View file

@ -159,7 +159,7 @@ public class ChatSession {
user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color, messageType, soundToPlay))); user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color, messageType, soundToPlay)));
} }
else { else {
logger.debug("user not found but chat still exists - userId: " + userId +" chatId: " +chatId); logger.error("User not found but connected to chat - userId: " + userId + " chatId: " + chatId);
} }
} }
} }

View file

@ -59,7 +59,8 @@ public class TriggeredAbilities extends HashMap<String, TriggeredAbility> {
} }
public void checkTriggers(GameEvent event, Game game) { public void checkTriggers(GameEvent event, Game game) {
for (TriggeredAbility ability: this.values()) { for (Iterator<TriggeredAbility> it = this.values().iterator(); it.hasNext();) {
TriggeredAbility ability = it.next();
// for effects like when leaves battlefield use ShortLKI to check if permanent was in the correct zone before (e.g. Oblivion Ring) // for effects like when leaves battlefield use ShortLKI to check if permanent was in the correct zone before (e.g. Oblivion Ring)
if (ability.isInUseableZone(game, null, event.getType().equals(GameEvent.EventType.ZONE_CHANGE))) { if (ability.isInUseableZone(game, null, event.getType().equals(GameEvent.EventType.ZONE_CHANGE))) {
if (!game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) { if (!game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) {

View file

@ -1086,7 +1086,7 @@ public abstract class GameImpl implements Game, Serializable {
} }
} }
catch (Exception ex) { catch (Exception ex) {
logger.fatal("Game exception ", ex); logger.fatal("Game exception gameId: " + getId(), ex);
ex.printStackTrace(); ex.printStackTrace();
this.fireErrorEvent("Game exception occurred: ", ex); this.fireErrorEvent("Game exception occurred: ", ex);
restoreState(bookmark); restoreState(bookmark);

View file

@ -121,7 +121,7 @@ import org.apache.log4j.Logger;
public abstract class PlayerImpl implements Player, Serializable { public abstract class PlayerImpl implements Player, Serializable {
private static final transient Logger log = Logger.getLogger(PlayerImpl.class); private static final transient Logger logger = Logger.getLogger(PlayerImpl.class);
private static Random rnd = new Random(); private static Random rnd = new Random();
@ -957,7 +957,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean triggerAbility(TriggeredAbility source, Game game) { public boolean triggerAbility(TriggeredAbility source, Game game) {
if (source == null) { if (source == null) {
log.warn("Null source in triggerAbility method"); logger.warn("Null source in triggerAbility method");
throw new IllegalArgumentException("source TriggeredAbility must not be null"); throw new IllegalArgumentException("source TriggeredAbility must not be null");
} }
//20091005 - 603.3c, 603.3d //20091005 - 603.3c, 603.3d
@ -1576,14 +1576,15 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public void quit(Game game) { public void quit(Game game) {
game.informPlayers(new StringBuilder(getName()).append(" quits the match.").toString()); logger.debug(getName() + " quits the match.");
game.informPlayers(getName() + " quits the match.");
quit = true; quit = true;
this.concede(game); this.concede(game);
} }
@Override @Override
public void timerTimeout(Game game) { public void timerTimeout(Game game) {
game.informPlayers(new StringBuilder(getName()).append(" has run out of time. Loosing the Match.").toString()); game.informPlayers(getName() + " has run out of time. Loosing the Match.");
quit = true; quit = true;
timerTimeout = true; timerTimeout = true;
this.concede(game); this.concede(game);
@ -1599,11 +1600,11 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public void concede(Game game) { public void concede(Game game) {
log.debug(this.getName() + (" concedes gameId:" +game.getId())); logger.debug(this.getName() + (" concedes gameId:" +game.getId()));
game.gameOver(playerId); game.gameOver(playerId);
log.debug("Before lost " + this.getName()); logger.debug("Before lost " + this.getName());
lost(game); lost(game);
log.debug("After lost " + this.getName()); logger.debug("After lost " + this.getName());
this.left = true; this.left = true;
} }
@ -1612,21 +1613,21 @@ public abstract class PlayerImpl implements Player, Serializable {
passedTurn = true; passedTurn = true;
passedAllTurns = true; passedAllTurns = true;
this.skip(); this.skip();
log.trace("Passed priority for turns"); logger.trace("Passed priority for turns");
} }
@Override @Override
public void passTurnPriority(Game game) { public void passTurnPriority(Game game) {
passedTurn = true; passedTurn = true;
this.skip(); this.skip();
log.trace("Passed priority for turn"); logger.trace("Passed priority for turn");
} }
@Override @Override
public void restorePriority(Game game) { public void restorePriority(Game game) {
passedAllTurns = false; passedAllTurns = false;
passedTurn = false; passedTurn = false;
log.trace("Restore priority"); logger.trace("Restore priority");
} }
@Override @Override
@ -1648,7 +1649,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public void lost(Game game) { public void lost(Game game) {
log.debug(this.getName() + " has lost gameId: " + game.getId()); logger.debug(this.getName() + " has lost gameId: " + game.getId());
if (canLose(game)) { if (canLose(game)) {
//20100423 - 603.9 //20100423 - 603.9
if (!this.wins) { if (!this.wins) {
@ -1656,11 +1657,11 @@ public abstract class PlayerImpl implements Player, Serializable {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LOST, null, null, playerId)); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LOST, null, null, playerId));
game.informPlayers(new StringBuilder(this.getName()).append(" has lost the game.").toString()); game.informPlayers(new StringBuilder(this.getName()).append(" has lost the game.").toString());
} else { } else {
log.debug(this.getName() + " has already won - stop lost"); logger.debug(this.getName() + " has already won - stop lost");
} }
// for draw - first all players that have lost have to be set to lost // for draw - first all players that have lost have to be set to lost
if (!hasLeft()) { if (!hasLeft()) {
log.debug("Game over playerId: " + playerId); logger.debug("Game over playerId: " + playerId);
game.gameOver(playerId); game.gameOver(playerId);
} }
} }
@ -1673,7 +1674,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public void won(Game game) { public void won(Game game) {
log.debug("player won -> start: " + this.getName()); logger.debug("player won -> start: " + this.getName());
if (!game.replaceEvent(new GameEvent(GameEvent.EventType.WINS, null, null, playerId))) { if (!game.replaceEvent(new GameEvent(GameEvent.EventType.WINS, null, null, playerId))) {
if (!this.loses) { if (!this.loses) {
//20130501 - 800.7, 801.16 //20130501 - 800.7, 801.16
@ -1681,7 +1682,7 @@ public abstract class PlayerImpl implements Player, Serializable {
for (UUID opponentId: game.getOpponents(playerId)) { for (UUID opponentId: game.getOpponents(playerId)) {
Player opponent = game.getPlayer(opponentId); Player opponent = game.getPlayer(opponentId);
if (opponent != null && !opponent.hasLost()) { if (opponent != null && !opponent.hasLost()) {
log.debug("player won -> calling opponent lost: " + this.getName() + " opponent: " + opponent.getName()); logger.debug("player won -> calling opponent lost: " + this.getName() + " opponent: " + opponent.getName());
opponent.lost(game); opponent.lost(game);
} }
} }
@ -1694,13 +1695,13 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
} }
if (opponentsAlive == 0 && !hasWon()) { if (opponentsAlive == 0 && !hasWon()) {
log.debug("player won -> No more oppononets alive game won: " + this.getName()); logger.debug("player won -> No more oppononets alive game won: " + this.getName());
game.informPlayers(new StringBuilder(this.getName()).append(" has won the game").toString()); game.informPlayers(new StringBuilder(this.getName()).append(" has won the game").toString());
this.wins = true; this.wins = true;
game.end(); game.end();
} }
} else { } else {
log.debug("player won -> but already lost before: " + this.getName()); logger.debug("player won -> but already lost before: " + this.getName());
} }
} }
} }