Improved player quits / leaves mage handling for tournaments (not perfect yet, will more improve it).

This commit is contained in:
LevelX2 2013-07-18 17:40:06 +02:00
parent 0d1e45fff6
commit 85b8edf630
12 changed files with 155 additions and 34 deletions

View file

@ -119,6 +119,7 @@ public interface MageServer {
//tournament methods
void startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
void joinTournament(UUID draftId, String sessionId) throws MageException;
void quitTournament(UUID tournamentId, String sessionId) throws MageException;
TournamentView getTournament(UUID tournamentId) throws MageException;
//draft methods

View file

@ -953,6 +953,20 @@ public class SessionImpl implements Session {
}
return false;
}
@Override
public boolean quitTournament(UUID tournamentId) {
try {
if (isConnected()) {
server.quitTournament(tournamentId, sessionId);
return true;
}
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
}
return false;
}
@Override
public boolean undo(UUID gameId) {

View file

@ -55,6 +55,8 @@ public interface GamePlay {
boolean quitMatch(UUID gameId);
boolean quitTournament(UUID tournamentId);
boolean submitDeck(UUID tableId, DeckCardLists deck);
boolean updateDeck(UUID tableId, DeckCardLists deck);

View file

@ -29,6 +29,7 @@
package mage.view;
import java.io.Serializable;
import mage.constants.TournamentPlayerState;
import mage.game.tournament.TournamentPlayer;
/**
@ -42,6 +43,7 @@ public class TournamentPlayerView implements Serializable {
private String state;
private String results;
private int points;
private boolean quit;
TournamentPlayerView(TournamentPlayer player) {
this.name = player.getPlayer().getName();
@ -52,6 +54,7 @@ public class TournamentPlayerView implements Serializable {
this.state = sb.toString();
this.points = player.getPoints();
this.results = player.getResults();
this.quit = player.getState().equals(TournamentPlayerState.ELIMINATED) || player.getState().equals(TournamentPlayerState.CANCELED);
}
public String getName() {
@ -69,4 +72,9 @@ public class TournamentPlayerView implements Serializable {
public String getResults() {
return results;
}
public boolean hasQuit() {
return quit;
}
}