diff --git a/src/net/socialgamer/cah/data/Game.java b/src/net/socialgamer/cah/data/Game.java index 6728bfd..6bd9228 100644 --- a/src/net/socialgamer/cah/data/Game.java +++ b/src/net/socialgamer/cah/data/Game.java @@ -508,7 +508,7 @@ public class Game { if (null == host) { return null; } - info.put(GameInfo.HOST, host.toString()); + info.put(GameInfo.HOST, host.getUser().getNickname()); info.put(GameInfo.STATE, state.toString()); final List cardSetIdsCopy; synchronized (this.cardSetIds) { @@ -528,14 +528,14 @@ public class Game { final Player[] playersCopy = players.toArray(new Player[players.size()]); final List playerNames = new ArrayList(playersCopy.length); for (final Player player : playersCopy) { - playerNames.add(player.toString()); + playerNames.add(player.getUser().getNickname()); } info.put(GameInfo.PLAYERS, playerNames); final User[] spectatorsCopy = spectators.toArray(new User[spectators.size()]); final List spectatorNames = new ArrayList(spectatorsCopy.length); for (final User spectator : spectatorsCopy) { - spectatorNames.add(spectator.toString()); + spectatorNames.add(spectator.getNickname()); } info.put(GameInfo.SPECTATORS, spectatorNames); @@ -557,6 +557,12 @@ public class Game { return info; } + public final List getPlayers() { + final List copy = new ArrayList(players.size()); + copy.addAll(players); + return copy; + } + /** * Get player information for a single player. * @@ -661,7 +667,9 @@ public class Game { started = false; } if (started) { - logger.info(String.format("Starting game %d.", id)); + logger.info(String.format("Starting game %d with card sets %s, %d blanks, %d max players, " + + "%d max spectators, %d score limit, players %s.", + id, cardSetIds, blanksInDeck, playerLimit, spectatorLimit, scoreGoal, players)); // do this stuff outside the players lock; they will lock players again later for much less // time, and not at the same time as trying to lock users, which has caused deadlocks synchronized (cardSetIds) { @@ -885,8 +893,7 @@ public class Game { for (final Player player : roundPlayers) { final List cards = playedCards.getCards(player); if (cards == null || cards.size() < blackCard.getPick()) { - logger.info(String.format("Skipping idle player %s in game %d.", - player.getUser().toString(), id)); + logger.info(String.format("Skipping idle player %s in game %d.", player, id)); player.skipped(); final HashMap data = getEventMap(); diff --git a/src/net/socialgamer/cah/data/Player.java b/src/net/socialgamer/cah/data/Player.java index 7fd6146..d98f93e 100644 --- a/src/net/socialgamer/cah/data/Player.java +++ b/src/net/socialgamer/cah/data/Player.java @@ -116,6 +116,6 @@ public class Player { @Override public String toString() { - return user.toString(); + return String.format("%s (%dp, %ds)", user.toString(), score, skipCount); } } diff --git a/src/net/socialgamer/cah/handlers/BanHandler.java b/src/net/socialgamer/cah/handlers/BanHandler.java index ea2c13b..ff62a67 100644 --- a/src/net/socialgamer/cah/handlers/BanHandler.java +++ b/src/net/socialgamer/cah/handlers/BanHandler.java @@ -21,10 +21,13 @@ import net.socialgamer.cah.data.QueuedMessage; import net.socialgamer.cah.data.QueuedMessage.MessageType; import net.socialgamer.cah.data.User; +import org.apache.log4j.Logger; + import com.google.inject.Inject; public class BanHandler extends Handler { + protected final Logger logger = Logger.getLogger(BanHandler.class); public static final String OP = AjaxOperation.BAN.toString(); diff --git a/src/net/socialgamer/cah/handlers/Handler.java b/src/net/socialgamer/cah/handlers/Handler.java index c4cf7b5..36e6ed2 100644 --- a/src/net/socialgamer/cah/handlers/Handler.java +++ b/src/net/socialgamer/cah/handlers/Handler.java @@ -33,8 +33,6 @@ import net.socialgamer.cah.Constants.ErrorCode; import net.socialgamer.cah.Constants.ReturnableData; import net.socialgamer.cah.RequestWrapper; -import org.apache.log4j.Logger; - /** * Implementations of this interface MUST also have a public static final String OP. There will be @@ -43,7 +41,6 @@ import org.apache.log4j.Logger; * @author Andy Janata (ajanata@socialgamer.net) */ public abstract class Handler { - protected final Logger logger = Logger.getLogger("net.socialgamer.cah.handlers.Handler"); /** * Handle a request. diff --git a/src/net/socialgamer/cah/handlers/KickHandler.java b/src/net/socialgamer/cah/handlers/KickHandler.java index 35ff7dc..a1ef745 100644 --- a/src/net/socialgamer/cah/handlers/KickHandler.java +++ b/src/net/socialgamer/cah/handlers/KickHandler.java @@ -19,10 +19,13 @@ import net.socialgamer.cah.data.QueuedMessage; import net.socialgamer.cah.data.QueuedMessage.MessageType; import net.socialgamer.cah.data.User; +import org.apache.log4j.Logger; + import com.google.inject.Inject; public class KickHandler extends Handler { + protected final Logger logger = Logger.getLogger(KickHandler.class); public static final String OP = AjaxOperation.KICK.toString(); diff --git a/src/net/socialgamer/cah/handlers/StopGameHandler.java b/src/net/socialgamer/cah/handlers/StopGameHandler.java index 3b2b9e6..844cd1a 100644 --- a/src/net/socialgamer/cah/handlers/StopGameHandler.java +++ b/src/net/socialgamer/cah/handlers/StopGameHandler.java @@ -37,6 +37,8 @@ import net.socialgamer.cah.data.Game; import net.socialgamer.cah.data.GameManager; import net.socialgamer.cah.data.User; +import org.apache.log4j.Logger; + import com.google.inject.Inject; @@ -45,6 +47,8 @@ import com.google.inject.Inject; */ public class StopGameHandler extends GameWithPlayerHandler { + protected final Logger logger = Logger.getLogger(GameWithPlayerHandler.class); + public static final String OP = AjaxOperation.STOP_GAME.toString(); @Inject @@ -62,6 +66,8 @@ public class StopGameHandler extends GameWithPlayerHandler { } else if (game.getState() == GameState.LOBBY) { return error(ErrorCode.ALREADY_STOPPED); } else { + logger.info(String.format("Game %d stopped by host %s. Players: %s", game.getId(), user, + game.getPlayers())); game.resetState(false); return data; }