Adding tournament name to table.
This commit is contained in:
@@ -5,7 +5,7 @@ import java.util.Set;
|
||||
public interface HallInfoVisitor {
|
||||
public void playerIsWaiting(boolean waiting);
|
||||
|
||||
public void visitTable(String tableId, String gameId, String tableStatus, String formatName, Set<String> playerIds, String winner);
|
||||
public void visitTable(String tableId, String gameId, String tableStatus, String formatName, String tournamentName, Set<String> playerIds, String winner);
|
||||
|
||||
public void runningPlayerGame(String gameId);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class HallServer extends AbstractServer {
|
||||
private Map<String, AwaitingTable> _awaitingTables = new ConcurrentHashMap<String, AwaitingTable>();
|
||||
private Map<String, String> _runningTables = new ConcurrentHashMap<String, String>();
|
||||
private Map<String, String> _runningTableFormatNames = new ConcurrentHashMap<String, String>();
|
||||
private Map<String, String> _runningTableTournamentNames = new ConcurrentHashMap<String, String>();
|
||||
private int _nextTableId = 1;
|
||||
|
||||
private final int _playerInactivityPeriod = 1000 * 10; // 10 seconds
|
||||
@@ -171,6 +172,14 @@ public class HallServer extends AbstractServer {
|
||||
createGame(tableId, awaitingTable);
|
||||
}
|
||||
|
||||
private String getTournamentName(AwaitingTable table) {
|
||||
String tournamentName = "Casual";
|
||||
final League league = table.getLeague();
|
||||
if (league != null)
|
||||
tournamentName = league.getName() + " - " + table.getLeagueSerie().getType();
|
||||
return tournamentName;
|
||||
}
|
||||
|
||||
private void createGame(String tableId, AwaitingTable awaitingTable) {
|
||||
Set<LotroGameParticipant> players = awaitingTable.getPlayers();
|
||||
LotroGameParticipant[] participants = players.toArray(new LotroGameParticipant[players.size()]);
|
||||
@@ -182,6 +191,7 @@ public class HallServer extends AbstractServer {
|
||||
lotroGameMediator.startGame();
|
||||
_runningTables.put(tableId, gameId);
|
||||
_runningTableFormatNames.put(tableId, awaitingTable.getLotroFormat().getName());
|
||||
_runningTableTournamentNames.put(tableId, getTournamentName(awaitingTable));
|
||||
_awaitingTables.remove(tableId);
|
||||
}
|
||||
|
||||
@@ -208,14 +218,17 @@ public class HallServer extends AbstractServer {
|
||||
visitor.playerIsWaiting(isPlayerWaiting(player.getName()));
|
||||
|
||||
Map<String, AwaitingTable> copy = new HashMap<String, AwaitingTable>(_awaitingTables);
|
||||
for (Map.Entry<String, AwaitingTable> table : copy.entrySet())
|
||||
visitor.visitTable(table.getKey(), null, "Waiting", table.getValue().getLotroFormat().getName(), table.getValue().getPlayerNames(), null);
|
||||
for (Map.Entry<String, AwaitingTable> tableInformation : copy.entrySet()) {
|
||||
final AwaitingTable table = tableInformation.getValue();
|
||||
|
||||
visitor.visitTable(tableInformation.getKey(), null, "Waiting", table.getLotroFormat().getName(), getTournamentName(table), table.getPlayerNames(), null);
|
||||
}
|
||||
|
||||
Map<String, String> runningCopy = new LinkedHashMap<String, String>(_runningTables);
|
||||
for (Map.Entry<String, String> runningGame : runningCopy.entrySet()) {
|
||||
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningGame.getValue());
|
||||
if (lotroGameMediator != null)
|
||||
visitor.visitTable(runningGame.getKey(), runningGame.getValue(), lotroGameMediator.getGameStatus(), _runningTableFormatNames.get(runningGame.getKey()), lotroGameMediator.getPlayersPlaying(), lotroGameMediator.getWinner());
|
||||
visitor.visitTable(runningGame.getKey(), runningGame.getValue(), lotroGameMediator.getGameStatus(), _runningTableFormatNames.get(runningGame.getKey()), _runningTableTournamentNames.get(runningGame.getKey()), lotroGameMediator.getPlayersPlaying(), lotroGameMediator.getWinner());
|
||||
}
|
||||
|
||||
String playerTable = getNonFinishedPlayerTable(player.getName());
|
||||
@@ -267,6 +280,7 @@ public class HallServer extends AbstractServer {
|
||||
if (_lotroServer.getGameById(runningTable.getValue()) == null) {
|
||||
_runningTables.remove(runningTable.getKey());
|
||||
_runningTableFormatNames.remove(runningTable.getKey());
|
||||
_runningTableTournamentNames.remove(runningTable.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,13 +136,14 @@ public class HallResource extends AbstractResource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTable(String tableId, String gameId, String tableStatus, String formatName, Set<String> playerIds, String winner) {
|
||||
public void visitTable(String tableId, String gameId, 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("format", formatName);
|
||||
table.setAttribute("tournament", tournamentName);
|
||||
table.setAttribute("players", mergeStrings(playerIds));
|
||||
if (winner != null)
|
||||
table.setAttribute("winner", winner);
|
||||
|
||||
@@ -153,13 +153,13 @@ var GempLotrHallUI = Class.extend({
|
||||
var status = table.getAttribute("status");
|
||||
var playersAttr = table.getAttribute("players");
|
||||
var formatName = table.getAttribute("format");
|
||||
var tournamentName = table.getAttribute("tournament");
|
||||
var players = new Array();
|
||||
if (playersAttr.length > 0)
|
||||
players = playersAttr.split(",");
|
||||
var winner = table.getAttribute("winner");
|
||||
|
||||
var tableDiv = this.createTableDiv(id, gameId, status, formatName, players, waiting, winner);
|
||||
this.tablesDiv.append(tableDiv);
|
||||
var tableDiv = this.appendTable(this.tablesDiv, id, gameId, status, formatName, tournamentName, players, waiting, winner);
|
||||
}
|
||||
|
||||
var games = root.getElementsByTagName("game");
|
||||
@@ -202,7 +202,7 @@ var GempLotrHallUI = Class.extend({
|
||||
}
|
||||
},
|
||||
|
||||
createTableDiv: function(id, gameId, status, formatName, players, waiting, winner) {
|
||||
appendTable: function(container, id, gameId, status, formatName, tournamentName, players, waiting, winner) {
|
||||
var tableDiv = $("<div></div>");
|
||||
tableDiv.css({ display: "inline-table", width: "120px", height: "120px", margin: "5px", "background-color": "#333300", color: "#ffffff"});
|
||||
tableDiv.append("<div class='tableFormatName'>" + formatName + "</div>");
|
||||
@@ -247,6 +247,6 @@ var GempLotrHallUI = Class.extend({
|
||||
tableDiv.append(but);
|
||||
}
|
||||
|
||||
return tableDiv;
|
||||
this.container.append(tableDiv);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user