From c4fbe0aafc41bfa6c03f32aaa4a3068621a4d076 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Wed, 4 Jul 2012 15:33:22 +0000 Subject: [PATCH] Game status showing in Game Hall. --- .../com/gempukku/lotro/game/LotroGameMediator.java | 13 ++++++++++++- .../com/gempukku/lotro/hall/HallInfoVisitor.java | 2 +- .../java/com/gempukku/lotro/hall/HallServer.java | 4 ++-- .../com/gempukku/lotro/server/HallResource.java | 4 ++-- .../gempukku/lotro/server/TournamentResource.java | 2 +- .../src/main/webapp/js/gemp-008/hallUi.js | 5 +++-- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroGameMediator.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroGameMediator.java index b0fd75d84..357ab681a 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroGameMediator.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroGameMediator.java @@ -108,7 +108,7 @@ public class LotroGameMediator { final Phase currentPhase = _lotroGame.getGameState().getCurrentPhase(); if (currentPhase == Phase.PLAY_STARTING_FELLOWSHIP || currentPhase == Phase.PUT_RING_BEARER) return "Preparation"; - return "Playing"; + return "Playing at sites: " + getPlayerPositions(); } public boolean isFinished() { @@ -412,4 +412,15 @@ public class LotroGameMediator { long currentTime = System.currentTimeMillis(); return (int) ((currentTime - queryTime) / 1000); } + + public String getPlayerPositions() { + StringBuilder stringBuilder = new StringBuilder(); + for (String player : _playersPlaying) { + stringBuilder.append(_lotroGame.getGameState().getPlayerPosition(player) + ", "); + } + if (stringBuilder.length() > 0) + stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length()); + + return stringBuilder.toString(); + } } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallInfoVisitor.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallInfoVisitor.java index c521b2c47..998feec70 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallInfoVisitor.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallInfoVisitor.java @@ -7,7 +7,7 @@ public interface HallInfoVisitor { public void playerIsWaiting(boolean waiting); - public void visitTable(String tableId, String gameId, boolean noSpectators, String tableStatus, String formatName, String tournamentName, Set playerIds, String winner); + public void visitTable(String tableId, String gameId, boolean watchable, String tableStatus, String formatName, String tournamentName, Set playerIds, String winner); public void runningPlayerGame(String gameId); diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallServer.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallServer.java index d992d146e..2c08726ea 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallServer.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallServer.java @@ -265,7 +265,7 @@ public class HallServer extends AbstractServer { LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningTable.getGameId()); if (lotroGameMediator != null) { if (!lotroGameMediator.isFinished()) - visitor.visitTable(runningGame.getKey(), runningTable.getGameId(), lotroGameMediator.isNoSpectators(), lotroGameMediator.getGameStatus(), runningTable.getFormatName(), runningTable.getTournamentName(), lotroGameMediator.getPlayersPlaying(), lotroGameMediator.getWinner()); + visitor.visitTable(runningGame.getKey(), runningTable.getGameId(), !lotroGameMediator.isNoSpectators(), lotroGameMediator.getGameStatus(), runningTable.getFormatName(), runningTable.getTournamentName(), lotroGameMediator.getPlayersPlaying(), lotroGameMediator.getWinner()); else finishedTables.put(runningGame.getKey(), runningTable); } @@ -276,7 +276,7 @@ public class HallServer extends AbstractServer { final RunningTable runningTable = nonPlayingGame.getValue(); LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningTable.getGameId()); if (lotroGameMediator != null) - visitor.visitTable(nonPlayingGame.getKey(), runningTable.getGameId(), lotroGameMediator.isNoSpectators(), lotroGameMediator.getGameStatus(), runningTable.getFormatName(), runningTable.getTournamentName(), lotroGameMediator.getPlayersPlaying(), lotroGameMediator.getWinner()); + visitor.visitTable(nonPlayingGame.getKey(), runningTable.getGameId(), false, lotroGameMediator.getGameStatus(), runningTable.getFormatName(), runningTable.getTournamentName(), lotroGameMediator.getPlayersPlaying(), lotroGameMediator.getWinner()); } for (Map.Entry tournamentQueueEntry : _tournamentQueues.entrySet()) { diff --git a/gemp-lotr/gemp-lotr-web-server/src/main/java/com/gempukku/lotro/server/HallResource.java b/gemp-lotr/gemp-lotr-web-server/src/main/java/com/gempukku/lotro/server/HallResource.java index d8c219db3..f77b0b09a 100644 --- a/gemp-lotr/gemp-lotr-web-server/src/main/java/com/gempukku/lotro/server/HallResource.java +++ b/gemp-lotr/gemp-lotr-web-server/src/main/java/com/gempukku/lotro/server/HallResource.java @@ -256,13 +256,13 @@ public class HallResource extends AbstractResource { } @Override - public void visitTable(String tableId, String gameId, boolean noSpectators, String tableStatus, String formatName, String tournamentName, Set playerIds, String winner) { + public void visitTable(String tableId, String gameId, boolean watchable, String tableStatus, String formatName, String tournamentName, Set playerIds, String winner) { Element table = _doc.createElement("table"); table.setAttribute("id", tableId); if (gameId != null) table.setAttribute("gameId", gameId); table.setAttribute("status", tableStatus); - table.setAttribute("noSpectators", String.valueOf(noSpectators)); + table.setAttribute("watchable", String.valueOf(watchable)); table.setAttribute("format", formatName); table.setAttribute("tournament", tournamentName); table.setAttribute("players", mergeStrings(playerIds)); diff --git a/gemp-lotr/gemp-lotr-web-server/src/main/java/com/gempukku/lotro/server/TournamentResource.java b/gemp-lotr/gemp-lotr-web-server/src/main/java/com/gempukku/lotro/server/TournamentResource.java index a781f1d1a..68567f160 100644 --- a/gemp-lotr/gemp-lotr-web-server/src/main/java/com/gempukku/lotro/server/TournamentResource.java +++ b/gemp-lotr/gemp-lotr-web-server/src/main/java/com/gempukku/lotro/server/TournamentResource.java @@ -80,7 +80,7 @@ public class TournamentResource extends AbstractResource { Document doc = documentBuilder.newDocument(); Element tournaments = doc.createElement("tournaments"); - for (Tournament tournament : _tournamentService.getOldTournaments(System.currentTimeMillis() - (1000 * 60 * 24 * 7))) { + for (Tournament tournament : _tournamentService.getOldTournaments(System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 7))) { Element tournamentElem = doc.createElement("tournament"); tournamentElem.setAttribute("id", tournament.getTournamentId()); diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-008/hallUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-008/hallUi.js index 507ae57bf..993a60eb5 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-008/hallUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-008/hallUi.js @@ -197,6 +197,7 @@ var GempLotrHallUI = Class.extend({ var id = table.getAttribute("id"); var gameId = table.getAttribute("gameId"); var status = table.getAttribute("status"); + var watchable = table.getAttribute("watchable"); var playersAttr = table.getAttribute("players"); var formatName = table.getAttribute("format"); var tournamentName = table.getAttribute("tournament"); @@ -205,7 +206,7 @@ var GempLotrHallUI = Class.extend({ players = playersAttr.split(","); var winner = table.getAttribute("winner"); - var tableDiv = this.appendTable(tablesTable, id, gameId, status, formatName, tournamentName, players, waiting, winner); + var tableDiv = this.appendTable(tablesTable, id, gameId, watchable, status, formatName, tournamentName, players, waiting, winner); } this.tablesDiv.append(tablesTable); @@ -294,7 +295,7 @@ var GempLotrHallUI = Class.extend({ }, - appendTable:function (container, id, gameId, status, formatName, tournamentName, players, waiting, winner) { + appendTable:function (container, id, gameId, watchable, status, formatName, tournamentName, players, waiting, winner) { var row = $(""); row.append("" + formatName + "");