forked from External/mage
Improved reconnect and tournament handling. Reconnect time is now shown for disconneted players on player list and tournament panel. You can now reconnect (during 3 minutes) to a tournament also if meanwhile new game (after sideboarding ended) or round was started. Conceding the complete match in a tournament can no longer result in a draw, if you won games before. Quitting a tournament does now always end all active games of that quitting player.
This commit is contained in:
parent
c76529bf91
commit
9ff5bcbd92
29 changed files with 282 additions and 109 deletions
|
|
@ -47,6 +47,7 @@ import mage.game.match.MatchPlayer;
|
|||
import mage.game.tournament.Tournament;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.players.Player;
|
||||
import mage.server.game.GameManager;
|
||||
import mage.server.game.GamesRoomManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -175,6 +176,20 @@ public class TableManager {
|
|||
}
|
||||
}
|
||||
|
||||
// remove user from all sub tables of a tournament
|
||||
public void userQuitTournamentSubTables(UUID tournamentId, UUID userId) {
|
||||
for (TableController controller: controllers.values()) {
|
||||
if (controller.getTable().isTournamentSubTable() && controller.getTable().getTournament().getId().equals(tournamentId)) {
|
||||
Match match = controller.getTable().getMatch();
|
||||
if (match != null) {
|
||||
if (match.getGame() != null) {
|
||||
GameManager.getInstance().quitMatch(match.getGame().getId(), userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTableOwner(UUID tableId, UUID userId) {
|
||||
if (controllers.containsKey(tableId)) {
|
||||
return controllers.get(tableId).isOwner(userId);
|
||||
|
|
@ -341,20 +356,10 @@ public class TableManager {
|
|||
logger.warn("Table expired: id = " + table.getId() + ", created_by=" + table.getControllerName() + ". Removing...");
|
||||
toRemove.add(table.getId());
|
||||
}
|
||||
// remove immediately non tournament tables with no human players
|
||||
// remove tables not valid anymore
|
||||
else if (!table.isTournament()) {
|
||||
boolean canBeRemoved = true;
|
||||
for (MatchPlayer matchPlayer :table.getMatch().getPlayers()) {
|
||||
Player player = matchPlayer.getPlayer();
|
||||
if (player != null && player.isHuman() && !player.hasLeft()) {
|
||||
canBeRemoved = false;
|
||||
}
|
||||
// tournament sub tables may not be removed as long the tournament is not finished
|
||||
if(table.isTournamentSubTable() && table.getTournament().getEndTime() == null) {
|
||||
canBeRemoved = false;
|
||||
}
|
||||
}
|
||||
if (canBeRemoved) {
|
||||
TableController tableController = getController(table.getId());
|
||||
if (!tableController.isMatchTableStillValid()) {
|
||||
logger.warn("Table with no active human player: id = " + table.getId() + ", created_by=" + table.getControllerName() + ". Removing...");
|
||||
toRemove.add(table.getId());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue