Game status showing in Game Hall.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<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);
|
||||
|
||||
|
||||
@@ -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<String, TournamentQueue> tournamentQueueEntry : _tournamentQueues.entrySet()) {
|
||||
|
||||
@@ -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<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");
|
||||
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));
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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 = $("<tr></tr>");
|
||||
|
||||
row.append("<td>" + formatName + "</td>");
|
||||
|
||||
Reference in New Issue
Block a user