use of mage.game.match.Match in project mage by magefree.
the class MatchView method initMatchTable.
// used for matches
private void initMatchTable(Table table) {
Match match = table.getMatch();
this.matchId = match.getId();
this.matchName = match.getName();
this.gameType = match.getOptions().getGameType();
if (table.getName() != null && !table.getName().isEmpty()) {
this.deckType = match.getOptions().getDeckType() + " [" + table.getName() + ']';
} else {
this.deckType = match.getOptions().getDeckType();
}
for (Game game : match.getGames()) {
games.add(game.getId());
}
StringBuilder sb1 = new StringBuilder();
StringBuilder sb2 = new StringBuilder();
for (MatchPlayer matchPlayer : match.getPlayers()) {
sb1.append(matchPlayer.getName());
if (matchPlayer.hasQuit()) {
if (matchPlayer.getPlayer().hasTimerTimeout()) {
sb1.append(" [timer] ");
} else if (matchPlayer.getPlayer().hasIdleTimeout()) {
sb1.append(" [idle] ");
} else {
sb1.append(" [quit] ");
}
}
int lostGames = match.getNumGames() - (matchPlayer.getWins() + match.getDraws());
sb1.append(", ");
sb2.append(matchPlayer.getName()).append(" [");
sb2.append(matchPlayer.getWins()).append('-');
if (match.getDraws() > 0) {
sb2.append(match.getDraws()).append('-');
}
sb2.append(lostGames).append("], ");
}
if (sb1.length() > 2) {
players = sb1.substring(0, sb1.length() - 2);
result = sb2.substring(0, sb2.length() - 2);
} else {
players = "[no players]";
result = "";
}
this.startTime = match.getStartTime();
this.endTime = match.getEndTime();
this.replayAvailable = match.isReplayAvailable();
this.rated = match.getOptions().isRated();
}
use of mage.game.match.Match in project mage by magefree.
the class TableManagerImpl method removeTable.
@Override
public void removeTable(UUID tableId) {
TableController tableController = controllers.get(tableId);
if (tableController != null) {
Lock w = controllersLock.writeLock();
w.lock();
try {
controllers.remove(tableId);
} finally {
w.unlock();
}
// deletes the table chat and references to users
tableController.cleanUp();
Table table = tables.get(tableId);
w = tablesLock.writeLock();
w.lock();
try {
tables.remove(tableId);
} finally {
w.unlock();
}
Match match = table.getMatch();
Game game = null;
if (match != null) {
game = match.getGame();
if (game != null && !game.hasEnded()) {
game.end();
}
}
// If table is not finished, the table has to be removed completly because it's not a normal state (if finished it will be removed in GamesRoomImpl.Update())
if (table.getState() != TableState.FINISHED) {
if (game != null) {
managerFactory.gameManager().removeGame(game.getId());
// something goes wrong, so don't add it to ended stats
}
managerFactory.gamesRoomManager().removeTable(tableId);
}
}
}
Aggregations