forked from External/mage
remove games from list when finished + added name and owner to tables
This commit is contained in:
parent
2f515e242b
commit
017b2b4339
12 changed files with 770 additions and 624 deletions
|
|
@ -66,26 +66,29 @@ public class TableController {
|
|||
|
||||
private UUID sessionId;
|
||||
private UUID chatId;
|
||||
private String controllerName;
|
||||
private Table table;
|
||||
private Match match;
|
||||
private MatchOptions options;
|
||||
private Tournament tournament;
|
||||
private ConcurrentHashMap<UUID, UUID> sessionPlayerMap = new ConcurrentHashMap<UUID, UUID>();
|
||||
|
||||
public TableController(UUID sessionId, MatchOptions options) {
|
||||
public TableController(UUID roomId, UUID sessionId, MatchOptions options) {
|
||||
this.sessionId = sessionId;
|
||||
chatId = ChatManager.getInstance().createChatSession();
|
||||
this.options = options;
|
||||
match = GameFactory.getInstance().createMatch(options.getGameType(), options);
|
||||
table = new Table(options.getGameType(), options.getName(), DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), match);
|
||||
controllerName = SessionManager.getInstance().getSession(sessionId).getUsername();
|
||||
table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), match);
|
||||
init();
|
||||
}
|
||||
|
||||
public TableController(UUID sessionId, TournamentOptions options) {
|
||||
public TableController(UUID roomId, UUID sessionId, TournamentOptions options) {
|
||||
this.sessionId = sessionId;
|
||||
chatId = ChatManager.getInstance().createChatSession();
|
||||
tournament = TournamentFactory.getInstance().createTournament(options.getTournamentType(), options);
|
||||
table = new Table(options.getTournamentType(), options.getName(), DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament);
|
||||
controllerName = SessionManager.getInstance().getSession(sessionId).getUsername();
|
||||
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
|
@ -320,7 +323,7 @@ public class TableController {
|
|||
UUID choosingPlayerId = match.getChooser();
|
||||
match.endGame();
|
||||
table.endGame();
|
||||
GameManager.getInstance().saveGame(match.getGame().getId());
|
||||
// GameManager.getInstance().saveGame(match.getGame().getId());
|
||||
GameManager.getInstance().removeGame(match.getGame().getId());
|
||||
try {
|
||||
if (!match.isMatchOver()) {
|
||||
|
|
@ -328,6 +331,9 @@ public class TableController {
|
|||
match.sideboard();
|
||||
startGame(choosingPlayerId);
|
||||
}
|
||||
else {
|
||||
GamesRoomManager.getInstance().getRoom(table.getRoomId()).removeTable(sessionId, table.getId());
|
||||
}
|
||||
} catch (GameException ex) {
|
||||
logger.fatal(null, ex);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue