mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 20:11:59 -08:00
Improved player quits / leaves mage handling for tournaments (not perfect yet, will more improve it).
This commit is contained in:
parent
0d1e45fff6
commit
85b8edf630
12 changed files with 155 additions and 34 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue