Fixing watching game gameId!=tableId mixup.
This commit is contained in:
@@ -5,7 +5,7 @@ import java.util.Set;
|
|||||||
public interface HallInfoVisitor {
|
public interface HallInfoVisitor {
|
||||||
public void playerIsWaiting(boolean waiting);
|
public void playerIsWaiting(boolean waiting);
|
||||||
|
|
||||||
public void visitTable(String tableId, String tableStatus, Set<String> playerIds);
|
public void visitTable(String tableId, String gameId, String tableStatus, Set<String> playerIds);
|
||||||
|
|
||||||
public void runningPlayerGame(String gameId);
|
public void runningPlayerGame(String gameId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,13 +133,13 @@ public class HallServer extends AbstractServer {
|
|||||||
|
|
||||||
Map<String, AwaitingTable> copy = new HashMap<String, AwaitingTable>(_awaitingTables);
|
Map<String, AwaitingTable> copy = new HashMap<String, AwaitingTable>(_awaitingTables);
|
||||||
for (Map.Entry<String, AwaitingTable> table : copy.entrySet())
|
for (Map.Entry<String, AwaitingTable> table : copy.entrySet())
|
||||||
visitor.visitTable(table.getKey(), "Waiting", table.getValue().getPlayerNames());
|
visitor.visitTable(table.getKey(), null, "Waiting", table.getValue().getPlayerNames());
|
||||||
|
|
||||||
Map<String, String> runningCopy = new LinkedHashMap<String, String>(_runningTables);
|
Map<String, String> runningCopy = new LinkedHashMap<String, String>(_runningTables);
|
||||||
for (Map.Entry<String, String> runningGame : runningCopy.entrySet()) {
|
for (Map.Entry<String, String> runningGame : runningCopy.entrySet()) {
|
||||||
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningGame.getValue());
|
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningGame.getValue());
|
||||||
if (lotroGameMediator != null)
|
if (lotroGameMediator != null)
|
||||||
visitor.visitTable(runningGame.getKey(), lotroGameMediator.getGameStatus(), lotroGameMediator.getPlayersPlaying());
|
visitor.visitTable(runningGame.getKey(), runningGame.getValue(), lotroGameMediator.getGameStatus(), lotroGameMediator.getPlayersPlaying());
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerTable = getNonFinishedPlayerTable(participantId);
|
String playerTable = getNonFinishedPlayerTable(participantId);
|
||||||
|
|||||||
@@ -553,9 +553,11 @@ public class ServerResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitTable(String tableId, String tableStatus, Set<String> playerIds) {
|
public void visitTable(String tableId, String gameId, String tableStatus, Set<String> playerIds) {
|
||||||
Element table = _doc.createElement("table");
|
Element table = _doc.createElement("table");
|
||||||
table.setAttribute("id", tableId);
|
table.setAttribute("id", tableId);
|
||||||
|
if (gameId != null)
|
||||||
|
table.setAttribute("gameId", gameId);
|
||||||
table.setAttribute("status", tableStatus);
|
table.setAttribute("status", tableStatus);
|
||||||
table.setAttribute("players", mergeStrings(playerIds));
|
table.setAttribute("players", mergeStrings(playerIds));
|
||||||
_hall.appendChild(table);
|
_hall.appendChild(table);
|
||||||
|
|||||||
@@ -99,13 +99,14 @@ var GempLotrHallUI = Class.extend({
|
|||||||
for (var i = 0; i < tables.length; i++) {
|
for (var i = 0; i < tables.length; i++) {
|
||||||
var table = tables[i];
|
var table = tables[i];
|
||||||
var id = table.getAttribute("id");
|
var id = table.getAttribute("id");
|
||||||
|
var gameId = table.getAttribute("gameId");
|
||||||
var status = table.getAttribute("status");
|
var status = table.getAttribute("status");
|
||||||
var playersAttr = table.getAttribute("players");
|
var playersAttr = table.getAttribute("players");
|
||||||
var players = new Array();
|
var players = new Array();
|
||||||
if (playersAttr.length > 0)
|
if (playersAttr.length > 0)
|
||||||
players = playersAttr.split(",");
|
players = playersAttr.split(",");
|
||||||
|
|
||||||
var tableDiv = this.createTableDiv(id, status, players, waiting);
|
var tableDiv = this.createTableDiv(id, gameId, status, players, waiting);
|
||||||
this.tablesDiv.append(tableDiv);
|
this.tablesDiv.append(tableDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +147,7 @@ var GempLotrHallUI = Class.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createTableDiv: function(id, status, players, waiting) {
|
createTableDiv: function(id, gameId, status, players, waiting) {
|
||||||
var tableDiv = $("<div></div>");
|
var tableDiv = $("<div></div>");
|
||||||
tableDiv.css({ display: "inline-block", width: "120px", height: "120px", margin: "5px", "background-color": "#333300", color: "#ffffff"});
|
tableDiv.css({ display: "inline-block", width: "120px", height: "120px", margin: "5px", "background-color": "#333300", color: "#ffffff"});
|
||||||
tableDiv.append("<div class='tableStatus'>" + status + "</div>");
|
tableDiv.append("<div class='tableStatus'>" + status + "</div>");
|
||||||
@@ -177,7 +178,7 @@ var GempLotrHallUI = Class.extend({
|
|||||||
var participantIdAppend = "";
|
var participantIdAppend = "";
|
||||||
if (participantId != null)
|
if (participantId != null)
|
||||||
participantIdAppend = "&participantId=" + participantId;
|
participantIdAppend = "&participantId=" + participantId;
|
||||||
location.href = "/gemp-lotr/game.html?gameId=" + id + participantIdAppend;
|
location.href = "/gemp-lotr/game.html?gameId=" + gameId + participantIdAppend;
|
||||||
});
|
});
|
||||||
tableDiv.append(but);
|
tableDiv.append(but);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user