Game status showing in Game Hall.

This commit is contained in:
marcins78@gmail.com
2012-07-04 15:33:22 +00:00
parent 25699e3cf9
commit c4fbe0aafc
6 changed files with 21 additions and 9 deletions

View File

@@ -108,7 +108,7 @@ public class LotroGameMediator {
final Phase currentPhase = _lotroGame.getGameState().getCurrentPhase(); final Phase currentPhase = _lotroGame.getGameState().getCurrentPhase();
if (currentPhase == Phase.PLAY_STARTING_FELLOWSHIP || currentPhase == Phase.PUT_RING_BEARER) if (currentPhase == Phase.PLAY_STARTING_FELLOWSHIP || currentPhase == Phase.PUT_RING_BEARER)
return "Preparation"; return "Preparation";
return "Playing"; return "Playing at sites: " + getPlayerPositions();
} }
public boolean isFinished() { public boolean isFinished() {
@@ -412,4 +412,15 @@ public class LotroGameMediator {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
return (int) ((currentTime - queryTime) / 1000); 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();
}
} }

View File

@@ -7,7 +7,7 @@ public interface HallInfoVisitor {
public void playerIsWaiting(boolean waiting); public void playerIsWaiting(boolean waiting);
public void visitTable(String tableId, String gameId, boolean noSpectators, String tableStatus, String formatName, String tournamentName, Set<String> playerIds, String winner); public void visitTable(String tableId, String gameId, boolean watchable, String tableStatus, String formatName, String tournamentName, Set<String> playerIds, String winner);
public void runningPlayerGame(String gameId); public void runningPlayerGame(String gameId);

View File

@@ -265,7 +265,7 @@ public class HallServer extends AbstractServer {
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningTable.getGameId()); LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningTable.getGameId());
if (lotroGameMediator != null) { if (lotroGameMediator != null) {
if (!lotroGameMediator.isFinished()) 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 else
finishedTables.put(runningGame.getKey(), runningTable); finishedTables.put(runningGame.getKey(), runningTable);
} }
@@ -276,7 +276,7 @@ public class HallServer extends AbstractServer {
final RunningTable runningTable = nonPlayingGame.getValue(); final RunningTable runningTable = nonPlayingGame.getValue();
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningTable.getGameId()); LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningTable.getGameId());
if (lotroGameMediator != null) 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<String, TournamentQueue> tournamentQueueEntry : _tournamentQueues.entrySet()) { for (Map.Entry<String, TournamentQueue> tournamentQueueEntry : _tournamentQueues.entrySet()) {

View File

@@ -256,13 +256,13 @@ public class HallResource extends AbstractResource {
} }
@Override @Override
public void visitTable(String tableId, String gameId, boolean noSpectators, String tableStatus, String formatName, String tournamentName, Set<String> playerIds, String winner) { public void visitTable(String tableId, String gameId, boolean watchable, String tableStatus, String formatName, String tournamentName, Set<String> playerIds, String winner) {
Element table = _doc.createElement("table"); Element table = _doc.createElement("table");
table.setAttribute("id", tableId); table.setAttribute("id", tableId);
if (gameId != null) if (gameId != null)
table.setAttribute("gameId", gameId); table.setAttribute("gameId", gameId);
table.setAttribute("status", tableStatus); table.setAttribute("status", tableStatus);
table.setAttribute("noSpectators", String.valueOf(noSpectators)); table.setAttribute("watchable", String.valueOf(watchable));
table.setAttribute("format", formatName); table.setAttribute("format", formatName);
table.setAttribute("tournament", tournamentName); table.setAttribute("tournament", tournamentName);
table.setAttribute("players", mergeStrings(playerIds)); table.setAttribute("players", mergeStrings(playerIds));

View File

@@ -80,7 +80,7 @@ public class TournamentResource extends AbstractResource {
Document doc = documentBuilder.newDocument(); Document doc = documentBuilder.newDocument();
Element tournaments = doc.createElement("tournaments"); 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"); Element tournamentElem = doc.createElement("tournament");
tournamentElem.setAttribute("id", tournament.getTournamentId()); tournamentElem.setAttribute("id", tournament.getTournamentId());

View File

@@ -197,6 +197,7 @@ var GempLotrHallUI = Class.extend({
var id = table.getAttribute("id"); var id = table.getAttribute("id");
var gameId = table.getAttribute("gameId"); var gameId = table.getAttribute("gameId");
var status = table.getAttribute("status"); var status = table.getAttribute("status");
var watchable = table.getAttribute("watchable");
var playersAttr = table.getAttribute("players"); var playersAttr = table.getAttribute("players");
var formatName = table.getAttribute("format"); var formatName = table.getAttribute("format");
var tournamentName = table.getAttribute("tournament"); var tournamentName = table.getAttribute("tournament");
@@ -205,7 +206,7 @@ var GempLotrHallUI = Class.extend({
players = playersAttr.split(","); players = playersAttr.split(",");
var winner = table.getAttribute("winner"); 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); 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 = $("<tr></tr>"); var row = $("<tr></tr>");
row.append("<td>" + formatName + "</td>"); row.append("<td>" + formatName + "</td>");