show completed matches - view replays

This commit is contained in:
BetaSteward 2011-08-26 10:41:28 -04:00
parent 8c9db5876e
commit 4a653d55cd
11 changed files with 396 additions and 46 deletions

View file

@ -56,6 +56,7 @@ import mage.utils.MageVersion;
import mage.view.ChatMessage.MessageColor;
import mage.view.DraftPickView;
import mage.view.GameView;
import mage.view.MatchView;
import mage.view.TableView;
import mage.view.TournamentView;
import mage.view.UserView;
@ -224,6 +225,17 @@ public class MageServerImpl implements MageServer {
}
@Override
public List<MatchView> getFinishedMatches(UUID roomId) throws MageException {
try {
return GamesRoomManager.getInstance().getRoom(roomId).getFinished();
}
catch (Exception ex) {
handleException(ex);
}
return null;
}
@Override
public List<String> getConnectedPlayers(UUID roomId) throws MageException {
try {
List<String> players = new ArrayList<String>();

View file

@ -377,9 +377,9 @@ public class TableController {
match.sideboard();
startGame(choosingPlayerId);
}
else {
GamesRoomManager.getInstance().removeTable(table.getId());
}
// else {
// GamesRoomManager.getInstance().removeTable(table.getId());
// }
} catch (GameException ex) {
logger.fatal(null, ex);
}

View file

@ -36,6 +36,7 @@ import mage.game.GameException;
import mage.game.match.MatchOptions;
import mage.game.tournament.TournamentOptions;
import mage.MageException;
import mage.view.MatchView;
import mage.view.TableView;
/**
@ -45,6 +46,7 @@ import mage.view.TableView;
public interface GamesRoom extends Room {
public List<TableView> getTables();
public List<MatchView> getFinished();
public boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException;
public boolean joinTournamentTable(UUID userId, UUID tableId, String name, String playerType, int skill) throws GameException;
public TableView createTable(UUID userId, MatchOptions options);

View file

@ -36,11 +36,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import mage.Constants.TableState;
import mage.cards.decks.DeckCardLists;
import mage.game.GameException;
import mage.game.match.MatchOptions;
import mage.game.tournament.TournamentOptions;
import mage.MageException;
import mage.view.MatchView;
import mage.view.TableView;
import org.apache.log4j.Logger;
@ -58,11 +60,22 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
public List<TableView> getTables() {
ArrayList<TableView> tableList = new ArrayList<TableView>();
for (Table table: tables.values()) {
tableList.add(new TableView(table));
if (table.getState() != TableState.FINISHED)
tableList.add(new TableView(table));
}
return tableList;
}
@Override
public List<MatchView> getFinished() {
ArrayList<MatchView> matchList = new ArrayList<MatchView>();
for (Table table: tables.values()) {
if (table.getState() == TableState.FINISHED)
matchList.add(new MatchView(table.getMatch()));
}
return matchList;
}
@Override
public boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException {
if (tables.containsKey(tableId)) {